Skip to content

Commit 5b3d583

Browse files
committed
restructure example projects
1 parent ab245c0 commit 5b3d583

14 files changed

+85
-82
lines changed

CMakeLists.txt

+33-22
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,49 @@ cmake_minimum_required(VERSION 3.1)
22

33
set(project_name hls-example) ## rename your project here
44

5-
project(${project_name}-loader)
5+
project(${project_name})
66

7-
include(ExternalProject)
7+
set(CMAKE_CXX_STANDARD 11)
88

9-
#############################################################################
10-
## load all dependencies
9+
add_library(${project_name}-lib
10+
src/AppComponent.hpp
11+
src/Utils.cpp
12+
src/Utils.hpp
13+
src/controller/MediaController.hpp
14+
src/hls/Playlist.cpp
15+
src/hls/Playlist.hpp
16+
)
1117

12-
ExternalProject_Add(oatpp
13-
GIT_REPOSITORY "https://github.com/oatpp/oatpp.git"
14-
GIT_TAG origin/master
15-
CMAKE_ARGS -DOATPP_BUILD_TESTS=OFF
18+
target_include_directories(${project_name}-lib
19+
PUBLIC src
1620
)
1721

18-
ExternalProject_Add(main
19-
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/main
20-
INSTALL_COMMAND cmake -E echo "SKIP INSTALL"
21-
DEPENDS oatpp
22+
## link libs
23+
24+
find_package(oatpp 0.19.4 REQUIRED)
25+
26+
target_link_libraries(${project_name}-lib
27+
PUBLIC oatpp::oatpp
28+
PUBLIC oatpp::oatpp-test
2229
)
2330

24-
#############################################################################
25-
## make run command
31+
add_definitions(
32+
-DEXAMPLE_MEDIA_FOLDER="${CMAKE_CURRENT_LIST_DIR}/video"
33+
)
2634

27-
ExternalProject_Get_Property(main BINARY_DIR)
35+
## add executables
2836

29-
add_custom_target(run
30-
COMMAND ${BINARY_DIR}/${project_name}-exe
31-
DEPENDS main
32-
WORKING_DIRECTORY ${BINARY_DIR}
37+
add_executable(${project_name}-exe
38+
src/App.cpp
3339
)
40+
target_link_libraries(${project_name}-exe ${project_name}-lib)
41+
add_dependencies(${project_name}-exe ${project_name}-lib)
3442

35-
#############################################################################
36-
## make test command
43+
add_executable(${project_name}-test
44+
test/tests.cpp
45+
)
46+
target_link_libraries(${project_name}-test ${project_name}-lib)
47+
add_dependencies(${project_name}-test ${project_name}-lib)
3748

3849
enable_testing()
39-
add_test(all-tests ${BINARY_DIR}/${project_name}-test)
50+
add_test(project-tests ${project_name}-test)

Dockerfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ FROM lganzzzo/alpine-cmake:latest
22

33
ADD . /service
44

5+
WORKDIR /service/utility
6+
7+
RUN ./install-oatpp-modules.sh
8+
59
WORKDIR /service/build
610

711
RUN cmake ..
812
RUN make
913

1014
EXPOSE 8000 8000
1115

12-
ENTRYPOINT ["make", "run"]
16+
ENTRYPOINT ["./hls-example-exe"]

README.md

+14-11
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@ Server is built using oat++ Async-Api and has following endpoints:
2626

2727
```
2828
29-
|- CMakeLists.txt // project loader script. load and build dependencies
30-
|- main/ // main project directory
31-
| |
32-
| |- CMakeLists.txt // projects CMakeLists.txt
33-
| |- src/ // source folder
34-
| |- test/ // test folder
29+
|- CMakeLists.txt // projects CMakeLists.txt
30+
|- src/ // source folder
31+
|- test/ // test folder
32+
|- utility/install-oatpp-modules.sh // utility script to install required oatpp-modules.
3533
|
36-
|- video/ // media files and playlists here
37-
|- generate_pls.sh // example how to use ```ffmpeg``` to generate initial playlist and video chunks
38-
|- playlist_live.m3u8 // playlist used to generate infinite playlist for http-live-streaming
34+
|- video/ // media files and playlists here
35+
|- generate_pls.sh // example how to use ```ffmpeg``` to generate initial playlist and video chunks
36+
|- playlist_live.m3u8 // playlist used to generate infinite playlist for http-live-streaming
3937
4038
```
4139
```
@@ -56,11 +54,16 @@ Server is built using oat++ Async-Api and has following endpoints:
5654

5755
#### Using CMake
5856

57+
**Requires**
58+
59+
- `oatpp` module installed. You may run `utility/install-oatpp-modules.sh`
60+
script to install required oatpp modules.
61+
5962
```
6063
$ mkdir build && cd build
6164
$ cmake ..
62-
$ make run ## Download, build, and install all dependencies. Run project
63-
65+
$ make
66+
$ ./hls-example-exe # - run application.
6467
```
6568

6669
#### In Docker

azure-pipelines.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ jobs:
1414
workspace:
1515
clean: all
1616
steps:
17+
- script: |
18+
sudo ./install-oatpp-modules.sh
19+
displayName: 'install oatpp modules'
20+
workingDirectory: utility
1721
- script: |
1822
mkdir build
1923
- script: |
@@ -24,4 +28,4 @@ jobs:
2428
- script: |
2529
make test ARGS="-V"
2630
displayName: 'Test'
27-
workingDirectory: build
31+
workingDirectory: build

main/CMakeLists.txt

-47
This file was deleted.

main/src/App.cpp src/App.cpp

File renamed without changes.
File renamed without changes.

main/src/Utils.cpp src/Utils.cpp

File renamed without changes.

main/src/Utils.hpp src/Utils.hpp

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

main/test/tests.cpp test/tests.cpp

File renamed without changes.

utility/install-oatpp-modules.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
rm -rf tmp
4+
5+
mkdir tmp
6+
cd tmp
7+
8+
##########################################################
9+
## install oatpp
10+
11+
MODULE_NAME="oatpp"
12+
13+
git clone --depth=1 https://github.com/oatpp/$MODULE_NAME
14+
15+
cd $MODULE_NAME
16+
mkdir build
17+
cd build
18+
19+
cmake ..
20+
make install
21+
22+
cd ../../
23+
24+
##########################################################
25+
26+
cd ../
27+
28+
rm -rf tmp

0 commit comments

Comments
 (0)