2 find_program(ARES_PACKAGE ares-package PATHS ${TOOLCHAIN}/../CLI ENV WEBOS_CLI_PATH
6 set(APP_PACKAGE_DIR ${CMAKE_BINARY_DIR}/tools/webOS/packaging)
8 # Configure files into packaging environment.
9 configure_file(${CMAKE_SOURCE_DIR}/tools/webOS/packaging/appinfo.json.in ${APP_PACKAGE_DIR}/appinfo.json @ONLY)
10 configure_file(${CMAKE_SOURCE_DIR}/tools/webOS/packaging/icon.png ${APP_PACKAGE_DIR}/icon.png COPYONLY)
11 configure_file(${CMAKE_SOURCE_DIR}/tools/webOS/packaging/largeIcon.png ${APP_PACKAGE_DIR}/largeIcon.png COPYONLY)
14 # Webos-userland are stubs for libs on the target device not contained in the toolchain,
15 # we don't package them, but still add them to the search path for verify
16 # Using DEPENDS_PATH/lib could result finding libs that are not on the target device, so
17 # we specifically use the build dir
18 get_filename_component(arch_dir ${DEPENDS_PATH} NAME)
19 set(WEBOS_USERLAND_LIBS ${CMAKE_SOURCE_DIR}/tools/depends/target/webos-userland/${arch_dir}/build)
22 set(WEBOS_ROOTFS ${TOOLCHAIN}/${HOST}/sysroot)
23 set(WEBOS_LD_LIBRARY_PATH ${WEBOS_USERLAND_LIBS}:${APP_PACKAGE_DIR}/lib)
24 set(VERIFY_EXE ${CMAKE_SOURCE_DIR}/tools/webOS/verify-symbols.sh)
27 set(APP_INSTALL_DIRS ${CMAKE_BINARY_DIR}/addons
28 ${CMAKE_BINARY_DIR}/media
29 ${CMAKE_BINARY_DIR}/system
30 ${CMAKE_BINARY_DIR}/userdata)
31 set(APP_TOOLCHAIN_FILES ${TOOLCHAIN}/${HOST}/sysroot/lib/libatomic.so.1
32 ${TOOLCHAIN}/${HOST}/sysroot/lib/libcrypt.so.1
33 ${CMAKE_BINARY_DIR}/libAcbAPI.so.1)
34 set(BIN_ADDONS_DIR ${DEPENDS_PATH}/addons)
36 file(WRITE ${CMAKE_BINARY_DIR}/install.cmake "
37 file(INSTALL ${APP_BINARY} DESTINATION ${APP_PACKAGE_DIR}
38 FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
39 file(INSTALL ${APP_INSTALL_DIRS} DESTINATION ${APP_PACKAGE_DIR})
40 file(CREATE_LINK python${PYTHON_VERSION} python3 SYMBOLIC)
41 file(INSTALL python3 DESTINATION ${APP_PACKAGE_DIR}/lib)
42 file(INSTALL ${DEPENDS_PATH}/lib/python${PYTHON_VERSION} DESTINATION ${APP_PACKAGE_DIR}/lib FOLLOW_SYMLINK_CHAIN
43 PATTERN config-${PYTHON_VERSION}-arm-linux-gnueabi EXCLUDE)
44 file(INSTALL ${APP_TOOLCHAIN_FILES} DESTINATION ${APP_PACKAGE_DIR}/lib FOLLOW_SYMLINK_CHAIN)
46 file(STRINGS ${CMAKE_BINARY_DIR}/missing_libs.txt missing_libs)
47 foreach(lib IN LISTS missing_libs)
48 file(INSTALL ${DEPENDS_PATH}/lib/\$\{lib\} DESTINATION ${APP_PACKAGE_DIR}/lib FOLLOW_SYMLINK_CHAIN)
51 if(EXISTS ${BIN_ADDONS_DIR})
52 file(INSTALL ${BIN_ADDONS_DIR} DESTINATION ${APP_PACKAGE_DIR})
56 # Copy files to the location expected by the webOS packaging scripts.
57 add_custom_target(bundle
58 DEPENDS ${APP_NAME_LC} ${CMAKE_BINARY_DIR}/missing_libs.txt AcbAPI
59 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/install.cmake
63 OUTPUT ${CMAKE_BINARY_DIR}/missing_libs.txt
64 DEPENDS ${CMAKE_BINARY_DIR}/${APP_BINARY}
65 COMMAND bash -c "WEBOS_ROOTFS=${WEBOS_ROOTFS} WEBOS_LD_LIBRARY_PATH=${WEBOS_LD_LIBRARY_PATH} \
66 ${VERIFY_EXE} ${CMAKE_BINARY_DIR}/${APP_BINARY} \
67 | awk '/Missing library:/ { print $3 }'" > missing_libs.txt
71 add_custom_target(verify-libs
72 DEPENDS bundle ${CMAKE_BINARY_DIR}/missing_libs.txt
73 COMMAND echo verifying dynamic library dependencies
74 COMMAND env WEBOS_ROOTFS=${WEBOS_ROOTFS} WEBOS_LD_LIBRARY_PATH=${WEBOS_LD_LIBRARY_PATH}
75 ${VERIFY_EXE} ${APP_PACKAGE_DIR}/${APP_BINARY}
76 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
80 if(CMAKE_BUILD_TYPE STREQUAL Release)
81 add_custom_target(strip
82 DEPENDS bundle verify-libs
83 COMMAND find ${APP_PACKAGE_DIR} -iname *.so* -exec ${CMAKE_STRIP} ${APP_PACKAGE_DIR}/${APP_BINARY} {} \;
84 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
87 set(IPK_DEPENDS strip)
91 DEPENDS bundle ${IPK_DEPENDS}
92 COMMAND ${ARES_PACKAGE} ${APP_PACKAGE_DIR}
93 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
97 add_custom_target(ipk-clean
98 COMMAND ${CMAKE_COMMAND} -E rm -r ${APP_PACKAGE_DIR}
99 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}