diff options
author | Youngjae Shin <yj99.shin@samsung.com> | 2020-08-13 10:45:55 +0900 |
---|---|---|
committer | Youngjae Shin <yj99.shin@samsung.com> | 2020-08-13 10:45:55 +0900 |
commit | f5a13a8c51bd407b49df10231fe6b3195cf5a5d6 (patch) | |
tree | fc4484d2f1151d13d647aa0f1b07479bef3645ba | |
parent | 37e64214af1dd0b88b810607b4a79fd7dc313121 (diff) | |
download | mtp-responder-f5a13a8c51bd407b49df10231fe6b3195cf5a5d6.tar.gz mtp-responder-f5a13a8c51bd407b49df10231fe6b3195cf5a5d6.tar.bz2 mtp-responder-f5a13a8c51bd407b49df10231fe6b3195cf5a5d6.zip |
[cleanup]revise build scripts and packagingsubmit/tizen/20200814.044257accepted/tizen/unified/20200819.035920
Change-Id: I7238356a3cff1b687cd3660e6c3873e1782a8b47
-rw-r--r-- | CMakeLists.txt | 55 | ||||
-rw-r--r-- | conf/mtp-responder.service.in (renamed from conf/mtp-responder.service) | 6 | ||||
-rw-r--r-- | ffs_tool/CMakeLists.txt | 16 | ||||
-rw-r--r-- | packaging/mtp-responder.spec | 77 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 63 |
5 files changed, 95 insertions, 122 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e6ba45..2e80df8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,44 +1,39 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(mtp-responder C) +CMAKE_MINIMUM_REQUIRED(VERSION 3.9) +PROJECT(mtp-responder) + +INCLUDE(FindPkgConfig) + +SET(EXTRA_FLAGS "-Wall -Werror -fvisibility=hidden") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_FLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS} -std=c++11") +SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src SRCS) +SET(REQUIRED_PKGS capi-content-media-content capi-media-metadata-extractor + capi-system-info dlog glib-2.0 libsystemd storage tapi vconf +) +PKG_CHECK_MODULES(PKGS REQUIRED ${REQUIRED_PKGS}) +INCLUDE_DIRECTORIES(${PKGS_INCLUDE_DIRS}) +LINK_DIRECTORIES(${PKGS_LIBRARY_DIRS}) IF(BUILD_GCOV) ADD_DEFINITIONS("-DTIZEN_TEST_GCOV") ENDIF(BUILD_GCOV) -INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED glib-2.0 capi-content-media-content - capi-media-metadata-extractor vconf dlog tapi capi-system-info storage libsystemd-daemon libsystemd) - -FOREACH(flag ${pkgs_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Werror") -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fexceptions -fvisibility=hidden -fprofile-arcs -ftest-coverage") - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") -SET(CMAKE_EXE_LINKER_FLAGS " -Wl,--as-needed -pie -Wl,--hash-style=both,-z,relroi ") - +FILE(GLOB SRCS src/*.c) ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} pthread rt gcrypt) - -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) -INSTALL(FILES conf/mtp-responder.conf DESTINATION /opt/var/lib/misc) - -ADD_EXECUTABLE(extract_descs_strs ${CMAKE_SOURCE_DIR}/ffs_tool/ffs_descs_strs_writer.c - ${CMAKE_SOURCE_DIR}/src/mtp_descs_strings.c) -ADD_CUSTOM_COMMAND(OUTPUT descs strs - COMMAND ./extract_descs_strs - DEPENDS extract_descs_strs) -ADD_CUSTOM_TARGET(descs_strs ALL DEPENDS descs strs) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PKGS_LIBRARIES} pthread gcrypt) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BIN_INSTALL_DIR}) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/descs DESTINATION /etc/mtp-responder) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/strs DESTINATION /etc/mtp-responder) +CONFIGURE_FILE(conf/${PROJECT_NAME}.service.in ${PROJECT_NAME}.service @ONLY) +INSTALL(FILES ${PROJECT_NAME}.service DESTINATION ${SYSTEMD_DIR}) +INSTALL(FILES conf/${PROJECT_NAME}.socket DESTINATION ${SYSTEMD_DIR}) +INSTALL(FILES conf/${PROJECT_NAME}.conf DESTINATION /opt/var/lib/misc) +INSTALL(FILES conf/99-${PROJECT_NAME}.rules DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/udev/rules.d/) +ADD_SUBDIRECTORY(ffs_tool) IF(BUILD_GTESTS) ADD_SUBDIRECTORY(tests) ENDIF(BUILD_GTESTS) diff --git a/conf/mtp-responder.service b/conf/mtp-responder.service.in index dc2ee98..fa8e775 100644 --- a/conf/mtp-responder.service +++ b/conf/mtp-responder.service.in @@ -6,10 +6,10 @@ StartLimitIntervalSec=0 User=network_fw Group=network_fw SupplementaryGroups=priv_mediastorage priv_externalstorage -ExecStart=/usr/bin/mtp-responder +ExecStart=@BIN_INSTALL_DIR@/@PROJECT_NAME@ KillMode=process SmackProcessLabel=System -USBFunctionDescriptors=/etc/mtp-responder/descs -USBFunctionStrings=/etc/mtp-responder/strs +USBFunctionDescriptors=@SYSCONF_DIR@/@PROJECT_NAME@/descs +USBFunctionStrings=@SYSCONF_DIR@/@PROJECT_NAME@/strs RestartSec=3 Restart=on-failure diff --git a/ffs_tool/CMakeLists.txt b/ffs_tool/CMakeLists.txt new file mode 100644 index 0000000..d782f3b --- /dev/null +++ b/ffs_tool/CMakeLists.txt @@ -0,0 +1,16 @@ + +SET(FFS_WRITER "functionfs-desc-str-writer") +FILE(GLOB WRITER_SRCS *.c ${CMAKE_SOURCE_DIR}/src/mtp_descs_strings.c) + +ADD_EXECUTABLE(${FFS_WRITER} ${WRITER_SRCS}) +SET_TARGET_PROPERTIES(${FFS_WRITER} PROPERTIES POSITION_INDEPENDENT_CODE ON) +ADD_CUSTOM_COMMAND(OUTPUT descs strs + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${FFS_WRITER} + DEPENDS ${FFS_WRITER} +) + +ADD_CUSTOM_TARGET(FFS_FILE DEPENDS descs strs) +ADD_DEPENDENCIES(${PROJECT_NAME} FFS_FILE) + +INSTALL(FILES descs DESTINATION ${SYSCONF_DIR}/${PROJECT_NAME}) +INSTALL(FILES strs DESTINATION ${SYSCONF_DIR}/${PROJECT_NAME}) diff --git a/packaging/mtp-responder.spec b/packaging/mtp-responder.spec index b4434ed..fddda5d 100644 --- a/packaging/mtp-responder.spec +++ b/packaging/mtp-responder.spec @@ -13,72 +13,79 @@ Source0: %{name}-%{version}.tar.gz Source1001: %{name}.manifest BuildRequires: cmake BuildRequires: libgcrypt-devel -BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(vconf) -BuildRequires: pkgconfig(tapi) BuildRequires: pkgconfig(capi-content-media-content) BuildRequires: pkgconfig(capi-media-metadata-extractor) BuildRequires: pkgconfig(capi-system-info) -Buildrequires: pkgconfig(storage) -BuildRequires: pkgconfig(libsystemd-daemon) +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(libsystemd) -Requires(post): /usr/bin/vconftool - +Buildrequires: pkgconfig(storage) +BuildRequires: pkgconfig(tapi) +BuildRequires: pkgconfig(vconf) %if 0%{?gtests:1} BuildRequires: pkgconfig(gmock) %endif +%if 0%{?gcov:1} +BuildRequires: lcov +BuildRequires: tar +%endif %description This package includes a daemon which processes Media Transper Protocol(MTP) commands as MTP responder role. +%if 0%{?gcov:1} +%package gcov +Summary: Coverage Data of %{name} +Group: Network & Connectivity/Testing + +%description gcov +The %{name}-gcov pacakge contains gcov objects +%endif %prep %setup -q cp %{SOURCE1001} . - %build -export CFLAGS="$CFLAGS -Wno-deprecated-declarations" - %if 0%{?gcov:1} export CFLAGS+=" -fprofile-arcs -ftest-coverage" export CXXFLAGS+=" -fprofile-arcs -ftest-coverage" export LDFLAGS+=" -lgcov" %endif -%cmake . \ -%if 0%{?gtests:1} +%cmake . -DCMAKE_VERBOSE_MAKEFILE=OFF \ + -DBIN_INSTALL_DIR:PATH=%{_bindir} \ + -DSYSCONF_DIR:PATH=%{_sysconfdir} \ + -DSYSTEMD_DIR:PATH=%{_unitdir} \ -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \ -%endif -%if 0%{?gcov:1} -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} -%endif - -make %{?jobs:-j%jobs} - +make %{?_smp_mflags} %install %make_install -mkdir -p %{buildroot}/%{_prefix}/lib/udev/rules.d -cp conf/99-mtp-responder.rules %{buildroot}/%{_prefix}/lib/udev/rules.d/99-mtp-responder.rules - -install -D -m 0644 conf/mtp-responder.service %{buildroot}/%{_unitdir}/mtp-responder.service -install -D -m 0644 conf/mtp-responder.socket %{buildroot}/%{_unitdir}/mtp-responder.socket +%if 0%{?gcov:1} +find .. -name '*.gcno' | tar cf %{name}-gcov.tar -T - +install -d -m 755 %{buildroot}%{_datadir}/gcov/obj +tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj +%endif %files -%manifest mtp-responder.manifest -%license LICENSE.APLv2 -%defattr(-,root,root,-) -%{_bindir}/mtp-responder -%{_unitdir}/mtp-responder.service -%{_unitdir}/mtp-responder.socket -%{_prefix}/lib/udev/rules.d/99-mtp-responder.rules -/opt/var/lib/misc/mtp-responder.conf -/etc/mtp-responder/descs -/etc/mtp-responder/strs - +%manifest %{name}.manifest +%{_bindir}/%{name} +%{_unitdir}/%{name}.service +%{_unitdir}/%{name}.socket +%{_prefix}/lib/udev/rules.d/99-%{name}.rules +/opt/var/lib/misc/%{name}.conf +%{_sysconfdir}/%{name}/descs +%{_sysconfdir}/%{name}/strs %if 0%{?gtests:1} %{_bindir}/gtest* %endif +%license LICENSE.APLv2 + +%if 0%{?gcov:1} +%files gcov +%{_datadir}/gcov/* +%endif + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 44ad8c2..02a4c97 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,61 +1,16 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(gtest-mtp-responder C CXX) - SET(GTEST_TEST "gtest-mtp-responder") ADD_DEFINITIONS("-DUSE_DLOG") -SET(REQUIRES_LIST ${REQUIRES_LIST} - glib-2.0 - gio-2.0 - gmock - dlog - capi-content-media-content - capi-media-metadata-extractor - vconf - dlog - tapi - capi-system-info - storage - libsystemd-daemon - libsystemd -) - -IF(BUILD_GTESTS) - ADD_DEFINITIONS("-DTIZEN_TEST_GTESTS") -ENDIF(BUILD_GTESTS) -IF(BUILD_GCOV) - ADD_DEFINITIONS("-DTIZEN_TEST_GCOV") -ENDIF(BUILD_GCOV) - -INCLUDE(FindPkgConfig) - +ADD_DEFINITIONS("-DTIZEN_TEST_GTESTS") FILE(GLOB GTEST_TEST_SRCS *.cpp ${CMAKE_SOURCE_DIR}/src/*.c) +SET(REQUIRED_PKGS ${REQUIRED_PKGS} gmock) -PKG_CHECK_MODULES(GTEST_TEST_PKG REQUIRED ${REQUIRES_LIST}) - -FOREACH(flag ${GTEST_TEST_PKG_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -INCLUDE_DIRECTORIES(${GTEST_TEST_PKG_INCLUDE_DIRS}) -LINK_DIRECTORIES(${GTEST_TEST_PKG_LIBRARY_DIRS}) - -INCLUDE_DIRECTORIES(${pkgs_INCLUDE_DIRS}) -LINK_DIRECTORIES(${pkgs_LIBRARY_DIRS}) - - -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) - -#AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src SRCS) -#AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/entity SRCS) -#AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/transport SRCS) -#AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/util SRCS) +PKG_CHECK_MODULES(TEST_PKGS REQUIRED ${REQUIRED_PKGS}) +INCLUDE_DIRECTORIES(${TEST_PKGS_INCLUDE_DIRS}) +LINK_DIRECTORIES(${TEST_PKGS_LIBRARY_DIRS}) ADD_EXECUTABLE(${GTEST_TEST} ${GTEST_TEST_SRCS}) -TARGET_LINK_LIBRARIES(${GTEST_TEST} ${GTEST_TEST_LDFLAGS} ${GTEST_TEST_PKG_LDFLAGS} ${LIBRARY} ${pkgs_LDFLAGS} -ldl -lgcov -lpthread -lrt -lgcrypt) -INSTALL(TARGETS ${GTEST_TEST} RUNTIME DESTINATION bin) +TARGET_COMPILE_OPTIONS(${GTEST_TEST} PUBLIC ${TEST_PKGS_CFLAGS_OTHER}) +SET_TARGET_PROPERTIES(${GTEST_TEST} PROPERTIES POSITION_INDEPENDENT_CODE ON) +TARGET_LINK_LIBRARIES(${GTEST_TEST} ${TEST_PKGS_LIBRARIES} pthread gcrypt) +INSTALL(TARGETS ${GTEST_TEST} DESTINATION ${BIN_INSTALL_DIR}) |