Skip to content

Commit 6a0b808

Browse files
hassanctechsirknightj
authored andcommitted
Build optimizations
1 parent ed7b2f1 commit 6a0b808

File tree

8 files changed

+46
-125
lines changed

8 files changed

+46
-125
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
runs-on: macos-13
1616
env:
1717
AWS_KVS_LOG_LEVEL: 2
18+
CC: /usr/bin/clang
19+
CXX: /usr/bin/clang++
1820
permissions:
1921
id-token: write
2022
contents: read

CMake/Dependencies/libautoconf-CMakeLists.txt

Lines changed: 0 additions & 18 deletions
This file was deleted.

CMake/Dependencies/libautomake-CMakeLists.txt

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,36 @@
11
cmake_minimum_required(VERSION 3.6.3)
2-
find_program(MAKE_EXE NAMES make)
3-
42
project(log4cplus-download NONE)
53

6-
set(BUILD_SHARED_LIBS 1)
4+
set(BUILD_SHARED_LIBS ON)
75
if (BUILD_STATIC)
8-
set(BUILD_SHARED_LIBS 0)
9-
set(CONFIGURE_STATIC --disable-shared --enable-static)
10-
endif()
11-
12-
if (DEFINED BUILD_LOG4CPLUS_HOST AND NOT BUILD_LOG4CPLUS_HOST STREQUAL OFF)
13-
SET(CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/build/src/project_log4cplus/configure "CFLAGS=${CMAKE_C_FLAGS}" --prefix=${OPEN_SRC_INSTALL_PREFIX} ${CONFIGURE_STATIC} --host=${BUILD_LOG4CPLUS_HOST})
14-
else()
15-
SET(CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/build/src/project_log4cplus/configure "CFLAGS=${CMAKE_C_FLAGS}" --prefix=${OPEN_SRC_INSTALL_PREFIX} ${CONFIGURE_STATIC})
6+
set(BUILD_SHARED_LIBS OFF)
167
endif()
178

18-
if (DEFINED CMAKE_OSX_SYSROOT AND NOT CMAKE_OSX_SYSROOT STREQUAL "")
19-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isysroot${CMAKE_OSX_SYSROOT}")
9+
set(EXTRA_CMAKE_ARGS "")
10+
if (DEFINED BUILD_LOG4CPLUS_HOST AND NOT BUILD_LOG4CPLUS_HOST STREQUAL "OFF")
11+
list(APPEND EXTRA_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=${BUILD_LOG4CPLUS_HOST}")
2012
endif()
2113

22-
2314
include(ExternalProject)
2415

2516
if (WIN32)
26-
ExternalProject_Add(project_log4cplus
27-
GIT_REPOSITORY https://github.com/log4cplus/log4cplus
28-
GIT_TAG REL_2_0_1
29-
GIT_SHALLOW TRUE
30-
GIT_PROGRESS TRUE
31-
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build
32-
TEST_COMMAND ""
33-
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX} -DLOG4CPLUS_BUILD_TESTING=0 -DLOG4CPLUS_BUILD_LOGGINGSERVER=0 -DUNICODE=0 -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
34-
)
35-
else()
36-
ExternalProject_Add(project_log4cplus
37-
GIT_REPOSITORY https://github.com/log4cplus/log4cplus
38-
GIT_TAG REL_2_0_1
39-
GIT_SHALLOW TRUE
40-
GIT_PROGRESS TRUE
41-
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build
42-
CONFIGURE_COMMAND ${CONFIGURE_COMMAND}
43-
BUILD_COMMAND ${MAKE_EXE}
44-
BUILD_IN_SOURCE TRUE
45-
INSTALL_COMMAND ${MAKE_EXE} install
46-
TEST_COMMAND ""
47-
)
17+
list(APPEND EXTRA_CMAKE_ARGS "-DUNICODE=0")
4818
endif()
19+
20+
ExternalProject_Add(project_log4cplus
21+
GIT_REPOSITORY https://github.com/log4cplus/log4cplus
22+
GIT_TAG REL_2_1_2
23+
GIT_SHALLOW TRUE
24+
GIT_PROGRESS TRUE
25+
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build
26+
CMAKE_ARGS
27+
-DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX}
28+
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
29+
-DLOG4CPLUS_ENABLE_THREAD_POOL=OFF
30+
-DLOG4CPLUS_BUILD_TESTING=OFF
31+
-DLOG4CPLUS_BUILD_LOGGINGSERVER=OFF
32+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
33+
${EXTRA_CMAKE_ARGS}
34+
BUILD_ALWAYS TRUE
35+
TEST_COMMAND ""
36+
)

CMake/FindLog4cplus.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ find_path(LOG4CPLUS_INCLUDE_DIR
3636
find_library(LOG4CPLUS_LIBRARY
3737
NAMES
3838
log4cplus
39+
log4cplusS
3940
PATHS
4041
/usr/local
4142
/usr

CMake/Utilities.cmake

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ endfunction()
3939
# build library from source
4040
function(build_dependency lib_name)
4141
set(supported_libs
42-
autoconf
43-
automake
44-
kvspic
4542
log4cplus)
4643
list(FIND supported_libs ${lib_name} index)
4744
if(${index} EQUAL -1)
@@ -51,24 +48,12 @@ function(build_dependency lib_name)
5148

5249
set(target_found NOTFOUND)
5350

54-
if (${lib_name} STREQUAL "autoconf" OR ${lib_name} STREQUAL "automake")
55-
find_program(
56-
target_found
57-
NAMES ${lib_name}
58-
PATHS ${OPEN_SRC_INSTALL_PREFIX}/bin
59-
NO_DEFAULT_PATH)
60-
else()
61-
set(lib_file_name ${lib_name})
62-
if (${lib_name} STREQUAL "openssl")
63-
set(lib_file_name ssl)
64-
endif()
51+
set(lib_file_name ${lib_name})
6552

66-
find_library(
67-
target_found
53+
find_library(target_found
6854
NAMES ${lib_file_name}
6955
PATHS ${OPEN_SRC_INSTALL_PREFIX}/lib
7056
NO_DEFAULT_PATH)
71-
endif()
7257

7358
if(target_found)
7459
message(STATUS "${lib_name} already built")

CMakeLists.txt

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ if(NOT BUILD_JNI_ONLY)
7474

7575

7676
message(STATUS "Begin building dependencies.")
77-
if (NOT WIN32)
78-
build_dependency(autoconf)
79-
build_dependency(automake)
80-
endif()
8177

8278
if(BUILD_LOG4CPLUS_HOST)
8379
set(BUILD_ARGS -DBUILD_LOG4CPLUS_HOST=${BUILD_LOG4CPLUS_HOST})
@@ -89,12 +85,6 @@ if(NOT BUILD_JNI_ONLY)
8985
message(STATUS "Finished building dependencies.")
9086
endif()
9187

92-
set(BUILD_COMMON_LWS
93-
FALSE
94-
CACHE BOOL "Build ProducerC without LWS Support" FORCE)
95-
set(BUILD_COMMON_CURL
96-
TRUE
97-
CACHE BOOL "Build ProducerC with CURL Support" FORCE)
9888
set(DEPENDENCY_DOWNLOAD_PATH ${CMAKE_CURRENT_SOURCE_DIR}/dependency)
9989
if(NOT EXISTS ${DEPENDENCY_DOWNLOAD_PATH})
10090
file(MAKE_DIRECTORY ${DEPENDENCY_DOWNLOAD_PATH})
@@ -107,26 +97,18 @@ if(NOT BUILD_JNI_ONLY)
10797
find_package(Threads)
10898
find_package(PkgConfig REQUIRED)
10999

110-
if (OPEN_SRC_INSTALL_PREFIX)
111-
find_package(CURL REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX})
112-
else()
113-
find_package(CURL REQUIRED)
114-
endif()
115-
116-
set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS})
117-
link_directories(${CURL_LIBRARY_DIRS})
118-
119100
if (WIN32)
120101
find_package(Log4cplus
121102
NAMES log4cplus REQUIRED
122103
PATHS ${OPEN_SRC_INSTALL_PREFIX}/lib)
123-
SET(Log4cplus "log4cplus::log4cplus")
104+
SET(LOG4CPLUS_LIBRARIES "log4cplus::log4cplus")
124105
else()
125106
find_package(Log4cplus REQUIRED)
126-
include_directories(${LOG4CPLUS_INCLUDE_DIR})
127-
set(Log4cplus ${LOG4CPLUS_LIBRARIES})
128107
endif()
129108

109+
message("LOG4CPLUS_INCLUDE_DIR is ${LOG4CPLUS_INCLUDE_DIR}")
110+
message("LOG4CPLUS_LIBRARIES is ${LOG4CPLUS_LIBRARIES}")
111+
130112
if (WIN32)
131113
if(EXISTS "C:\\gstreamer\\1.0\\msvc_x86_64\\bin\\pkg-config.exe")
132114
set(PKG_CONFIG_EXECUTABLE "C:\\gstreamer\\1.0\\msvc_x86_64\\bin\\pkg-config.exe")
@@ -183,19 +165,20 @@ include_directories(${KINESIS_VIDEO_PRODUCER_CPP_SRC}/src)
183165
include_directories(${KINESIS_VIDEO_PRODUCER_CPP_SRC}/src/credential-providers)
184166
include_directories(${KINESIS_VIDEO_PRODUCER_CPP_SRC}/src/common)
185167
include_directories(${KINESIS_VIDEO_PRODUCER_CPP_SRC}/src/JNI/include)
168+
include_directories(${LOG4CPLUS_INCLUDE_DIR})
186169

187170
if (NOT BUILD_JNI_ONLY)
188171
install(
189172
DIRECTORY ${KINESIS_VIDEO_PRODUCER_CPP_SRC}/src
190173
DESTINATION .)
191174

175+
link_directories(${OPEN_SRC_INSTALL_PREFIX}/lib)
176+
192177
add_library(KinesisVideoProducer ${LINKAGE} ${PRODUCER_CPP_SOURCE_FILES})
193178
target_link_libraries(
194179
KinesisVideoProducer
195-
PUBLIC kvsCommonCurl
196-
cproducer
197-
${Log4cplus}
198-
${LIBCURL_LIBRARIES})
180+
PUBLIC cproducer
181+
${LOG4CPLUS_LIBRARIES})
199182

200183
install(
201184
TARGETS KinesisVideoProducer
@@ -226,28 +209,29 @@ if(BUILD_GSTREAMER_PLUGIN)
226209
pkg_check_modules(GST_APP REQUIRED gstreamer-app-1.0)
227210
include_directories(${GST_APP_INCLUDE_DIRS})
228211
link_directories(${GST_APP_LIBRARY_DIRS})
212+
include_directories(${OPEN_SRC_INSTALL_PREFIX}/include)
229213

230214
if(BUILD_STATIC)
231215
add_library(gstkvssink STATIC ${GST_PLUGIN_SOURCE_FILES})
232216
else()
233217
add_library(gstkvssink MODULE ${GST_PLUGIN_SOURCE_FILES})
234218
endif()
235-
target_link_libraries(gstkvssink PRIVATE ${GST_APP_LIBRARIES} KinesisVideoProducer)
219+
target_link_libraries(gstkvssink PRIVATE ${LOG4CPLUS_LIBRARIES} ${GST_APP_LIBRARIES} KinesisVideoProducer)
236220

237221
add_executable(kvssink_gstreamer_sample samples/kvssink_gstreamer_sample.cpp)
238-
target_link_libraries(kvssink_gstreamer_sample ${GST_APP_LIBRARIES} KinesisVideoProducer)
222+
target_link_libraries(kvssink_gstreamer_sample ${LOG4CPLUS_LIBRARIES} ${GST_APP_LIBRARIES} kvspic)
239223

240224
add_executable(kvs_gstreamer_sample samples/kvs_gstreamer_sample.cpp)
241-
target_link_libraries(kvs_gstreamer_sample ${GST_APP_LIBRARIES} KinesisVideoProducer kvspic)
225+
target_link_libraries(kvs_gstreamer_sample ${LOG4CPLUS_LIBRARIES} ${GST_APP_LIBRARIES} KinesisVideoProducer kvspic)
242226

243227
add_executable(kvs_gstreamer_multistream_sample samples/kvs_gstreamer_multistream_sample.cpp)
244-
target_link_libraries(kvs_gstreamer_multistream_sample ${GST_APP_LIBRARIES} KinesisVideoProducer)
228+
target_link_libraries(kvs_gstreamer_multistream_sample ${LOG4CPLUS_LIBRARIES} ${GST_APP_LIBRARIES} KinesisVideoProducer)
245229

246230
add_executable(kvs_gstreamer_audio_video_sample samples/kvs_gstreamer_audio_video_sample.cpp)
247-
target_link_libraries(kvs_gstreamer_audio_video_sample ${GST_APP_LIBRARIES} KinesisVideoProducer)
231+
target_link_libraries(kvs_gstreamer_audio_video_sample ${LOG4CPLUS_LIBRARIES} ${GST_APP_LIBRARIES} KinesisVideoProducer)
248232

249233
add_executable(kvs_gstreamer_file_uploader_sample samples/kvs_gstreamer_file_uploader_sample.cpp)
250-
target_link_libraries(kvs_gstreamer_file_uploader_sample ${GST_APP_LIBRARIES})
234+
target_link_libraries(kvs_gstreamer_file_uploader_sample ${LOG4CPLUS_LIBRARIES} ${GST_APP_LIBRARIES})
251235
endif()
252236

253237
if(BUILD_TEST)

samples/kvssink_gstreamer_sample.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <string.h>
33
#include <chrono>
44
#include <Logger.h>
5-
#include "KinesisVideoProducer.h"
65
#include <vector>
76
#include <stdlib.h>
87
#include <mutex>
@@ -58,12 +57,10 @@ typedef struct _CustomData {
5857
first_pts(GST_CLOCK_TIME_NONE),
5958
use_absolute_fragment_times(true),
6059
max_runtime(0) {
61-
producer_start_time = chrono::duration_cast<nanoseconds>(systemCurrentTime().time_since_epoch()).count();
60+
producer_start_time = chrono::duration_cast<nanoseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
6261
}
6362

6463
GMainLoop *main_loop;
65-
unique_ptr<KinesisVideoProducer> kinesis_video_producer;
66-
shared_ptr<KinesisVideoStream> kinesis_video_stream;
6764
bool stream_started;
6865
bool h264_stream_supported;
6966
char *stream_name;

0 commit comments

Comments
 (0)