Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ci-pr-on-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jobs:
-t ${{env.BUILD_TYPE}}
-f ${{ steps.strings.outputs.build-dir }}
-b ${{ steps.strings.outputs.build-output-dir }}
-U ON
-S ON
-U
-S

- name: Unit Test
working-directory: ${{ steps.strings.outputs.build-dir }}/linux/x86_64/tests/unit_test
Expand Down Expand Up @@ -73,8 +73,8 @@ jobs:
-t ${{env.BUILD_TYPE}}
-f ${{ steps.strings.outputs.build-dir }}
-b ${{ steps.strings.outputs.build-output-dir }}
-U ON
-S ON
-U
-S

- name: Unit Test
working-directory: ${{ steps.strings.outputs.build-dir }}\\x64\\tests/unit_test
Expand Down Expand Up @@ -108,8 +108,8 @@ jobs:
-t ${{env.BUILD_TYPE}}
-f ${{ steps.strings.outputs.build-dir }}
-b ${{ steps.strings.outputs.build-output-dir }}
-U ON
-S ON
-U
-S

- name: Unit Test
working-directory: ${{ steps.strings.outputs.build-dir }}/macos/tests/unit_test
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/custom-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,21 @@ jobs:
-f ${{ steps.strings.outputs.build-dir }}
-b ${{ steps.strings.outputs.build-output-dir }}

- name: Build for macOS iOS and xrOS
if: ${{ matrix.os == 'macos-latest' && (matrix.target_platform == 'macos' || matrix.target_platform == 'ios' || matrix.target_platform == 'xros') }}
- name: Build for iOS and xrOS
if: ${{ matrix.os == 'macos-latest' && (matrix.target_platform == 'ios' || matrix.target_platform == 'xros') }}
run: >
sh scripts/build.sh -p ${{ matrix.target_platform }}
-v ${{ inputs.build_version }}
-t ${{ inputs.build_type }}
-f ${{ steps.strings.outputs.build-dir }}
-b ${{ steps.strings.outputs.build-output-dir }}

- name: Build for macOS
if: ${{ matrix.os == 'macos-latest' && (matrix.target_platform == 'macos') }}
run: |
sh scripts/build.sh -p ${{ matrix.target_platform }} -v ${{ inputs.build_version }} -t ${{ inputs.build_type }} -f ${{ steps.strings.outputs.build-dir }} -b ${{ steps.strings.outputs.build-output-dir }}
sh scripts/build.sh -p ${{ matrix.target_platform }} -v ${{ inputs.build_version }} -t ${{ inputs.build_type }} -f ${{ steps.strings.outputs.build-dir }} -b ${{ steps.strings.outputs.build-output-dir }} --no-framework

- name: Upload artifacts
if: ${{ inputs.upload_artifacts == true }}
uses: actions/upload-artifact@v4
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Name project traa.
project(traa C CXX)
message(STATUS "[TRAA] configuring...")
if(NOT DEFINED TRAA_OPTION_VERSION OR TRAA_OPTION_VERSION STREQUAL "")
set(TRAA_OPTION_VERSION "1.0.0")
endif()
message(STATUS "[TRAA] configuring ${TRAA_OPTION_VERSION}...")

# CMAKE_SYSTEM_NAME only be set after project defined.
message(STATUS "[TRAA] current target system name ${CMAKE_SYSTEM_NAME}")
Expand All @@ -55,6 +58,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
# Options
option(TRAA_OPTION_ENABLE_UNIT_TEST "Enable unit test" OFF)
option(TRAA_OPTION_ENABLE_SMOKE_TEST "Enable smoke test" OFF)
option(TRAA_OPTION_NO_FRAMEWORK "Do not build framework for Apple platforms" OFF)

if(LINUX)
# To enable x11 you have install x11 and x11-xext and x11-xcomposite development packages.
Expand Down
16 changes: 6 additions & 10 deletions scripts/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ goto:eof
echo -s, --source-dir Source directory [default: current directory]
echo -v, --version Version number [default: 0.0.1]
echo -V, --verbose Verbose output
echo -U, --unittest Build unit tests (ON/OFF) [default: OFF]
echo -S, --smoketest Build smoke tests (ON/OFF) [default: OFF]
echo -U, --unittest Build unit tests
echo -S, --smoketest Build smoke tests
echo -h, --help Show this help message
exit 0
goto:eof
Expand Down Expand Up @@ -121,17 +121,13 @@ goto:eof
) else if "%arg%"=="--verbose" (
set "VERBOSE=1"
) else if "%arg%"=="-U" (
set "BUILD_UNITTEST=%~1"
shift
set "BUILD_UNITTEST=ON"
) else if "%arg%"=="--unittest" (
set "BUILD_UNITTEST=%~1"
shift
set "BUILD_UNITTEST=ON"
) else if "%arg%"=="-S" (
set "BUILD_SMOKETEST=%~1"
shift
set "BUILD_SMOKETEST=ON"
) else if "%arg%"=="--smoketest" (
set "BUILD_SMOKETEST=%~1"
shift
set "BUILD_SMOKETEST=ON"
) else if "%arg%"=="-h" (
call :show_usage
) else (
Expand Down
19 changes: 13 additions & 6 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ BUILD_UNITTEST=OFF
BUILD_SMOKETEST=OFF
ANDROID_ABI="arm64-v8a,armeabi-v7a,x86,x86_64"
TARGET_ARCH="x86_64"
NO_FRAMEWORK=OFF

# cpu_features library on Android implements getauxval() for API level < 18, see cpu_features/src/hwcaps_linux_or_android.c
# The implementation call dlopen() to load libc.so and then call dlsym() to get the address of getauxval().
Expand Down Expand Up @@ -45,13 +46,14 @@ show_usage() {
echo " -b, --bin-folder Binary output folder [default: bin]"
echo " -s, --source-dir Source directory [default: current directory]"
echo " -v, --version Version of the build [default: 1.0.0]"
echo " -U, --unittest Build unit tests (ON/OFF) [default: OFF]"
echo " -S, --smoketest Build smoke tests (ON/OFF) [default: OFF]"
echo " -U, --unittest Build unit tests"
echo " -S, --smoketest Build smoke tests"
echo " -A, --android-abi Android ABI [default: arm64-v8a,armeabi-v7a,x86,x86_64]"
echo " -V, --verbose Verbose output"
echo " -h, --help Show this help message"
echo " -L, --api-level Android API level [default: 18]"
echo " -a, --arch Target architecture for Linux (x86_64/aarch64_clang/aarch64_gnu) [default: x86_64]"
echo " --no-framework Do not build framework for Apple platforms"
}

# parse command line arguments
Expand Down Expand Up @@ -82,12 +84,12 @@ while [[ $# -gt 0 ]]; do
shift 2
;;
-U|--unittest)
BUILD_UNITTEST="$2"
shift 2
BUILD_UNITTEST="ON"
shift
;;
-S|--smoketest)
BUILD_SMOKETEST="$2"
shift 2
BUILD_SMOKETEST="ON"
shift
;;
-A|--android-abi)
ANDROID_ABI="$2"
Expand All @@ -109,6 +111,10 @@ while [[ $# -gt 0 ]]; do
TARGET_ARCH="$2"
shift 2
;;
--no-framework)
NO_FRAMEWORK="ON"
shift
;;
*)
log "ERROR" "Unknown option: $1"
show_usage
Expand Down Expand Up @@ -249,6 +255,7 @@ build() {
-DTRAA_OPTION_ENABLE_UNIT_TEST="$BUILD_UNITTEST" \
-DTRAA_OPTION_ENABLE_SMOKE_TEST="$BUILD_SMOKETEST" \
-DTRAA_OPTION_VERSION="$VERSION" \
-DTRAA_OPTION_NO_FRAMEWORK="$NO_FRAMEWORK" \
-S "$SOURCE_DIR"
;;
"linux")
Expand Down
33 changes: 21 additions & 12 deletions src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ endif()
# add compile definitions
target_compile_definitions(${TRAA_LIBRARY_MAIN} PUBLIC TRAA_EXPORT)
set_target_properties(${TRAA_LIBRARY_MAIN} PROPERTIES
VERSION "${TRAA_VERSION_SHORT}"
SOVERSION "${TRAA_VERSION_SHORT}"
VERSION "${TRAA_OPTION_VERSION}"
SOVERSION "${TRAA_OPTION_VERSION}"
PUBLIC_HEADER "${TRAA_LIBRARY_PUBLIC_HEADER_FILES}"
ARCHIVE_OUTPUT_DIRECTORY "${TRAA_ARCHIVE_OUTPUT_DIRECTORY}"
LIBRARY_OUTPUT_DIRECTORY "${TRAA_ARCHIVE_OUTPUT_DIRECTORY}"
Expand All @@ -86,26 +86,35 @@ if(APPLE)
target_link_libraries(${TRAA_LIBRARY_MAIN} PRIVATE "${TRAA_LIBRARY_FRAMEWORKS}")

set_target_properties(${TRAA_LIBRARY_MAIN} PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION A
MACOSX_FRAMEWORK_IDENTIFIER "${TRAA_LIBRARY_IDENTIFIER}"
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${TRAA_VERSION_SHORT}"
MACOSX_FRAMEWORK_BUNDLE_VERSION "${TRAA_VERSION_SHORT}"
XCODE_ATTRIBUTE_ENABLE_BITCODE "NO"
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${TRAA_LIBRARY_IDENTIFIER}"
LINK_FLAGS "-Wl ${TRAA_LIBRARY_FRAMEWORKS_FOLDERS} -rpath @loader_path"
)

set_target_properties(${TRAA_LIBRARY_MAIN} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")

if(NOT TRAA_OPTION_NO_FRAMEWORK)
set_target_properties(${TRAA_LIBRARY_MAIN} PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION A
MACOSX_FRAMEWORK_IDENTIFIER "${TRAA_LIBRARY_IDENTIFIER}"
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${TRAA_OPTION_VERSION}"
MACOSX_FRAMEWORK_BUNDLE_VERSION "${TRAA_OPTION_VERSION}"
)

set(TRAA_LIBRARY_TRUELY_OUTPUT_FILE "${TRAA_LIBRARY_MAIN_OUTPUT_NAME}.framework/${TRAA_LIBRARY_MAIN_OUTPUT_NAME}")
set(TRAA_LIBRARY_TRUELY_OUTPUT_FILE_DSYM "${TRAA_LIBRARY_MAIN_OUTPUT_NAME}.framework.dSYM")
else()
set(TRAA_LIBRARY_TRUELY_OUTPUT_FILE "lib${TRAA_LIBRARY_MAIN_OUTPUT_NAME}.${TRAA_OPTION_VERSION}.dylib")
set(TRAA_LIBRARY_TRUELY_OUTPUT_FILE_DSYM "${TRAA_LIBRARY_TRUELY_OUTPUT_FILE}.dSYM")
endif()

# dsymutil to generate dsym file
add_custom_command(
TARGET ${TRAA_LIBRARY_MAIN}
POST_BUILD
COMMAND dsymutil
"${TRAA_ARCHIVE_OUTPUT_DIRECTORY}/${TRAA_LIBRARY_MAIN_OUTPUT_NAME}.framework/${TRAA_LIBRARY_MAIN_OUTPUT_NAME}"
"${TRAA_ARCHIVE_OUTPUT_DIRECTORY}/${TRAA_LIBRARY_TRUELY_OUTPUT_FILE}"
"-o"
"${TRAA_ARCHIVE_OUTPUT_DIRECTORY}/${TRAA_LIBRARY_MAIN_OUTPUT_NAME}.framework.dSYM"
"${TRAA_ARCHIVE_OUTPUT_DIRECTORY}/${TRAA_LIBRARY_TRUELY_OUTPUT_FILE_DSYM}"
COMMENT "Generate dsym file done on final binary."
)

Expand All @@ -114,7 +123,7 @@ if(APPLE)
TARGET ${TRAA_LIBRARY_MAIN}
POST_BUILD
COMMAND strip -r -S -x
"${TRAA_ARCHIVE_OUTPUT_DIRECTORY}/${TRAA_LIBRARY_MAIN_OUTPUT_NAME}.framework/${TRAA_LIBRARY_MAIN_OUTPUT_NAME}"
"${TRAA_ARCHIVE_OUTPUT_DIRECTORY}/${TRAA_LIBRARY_TRUELY_OUTPUT_FILE}"
COMMENT "Strip debug and local symbols done on final binary."
)
elseif(WIN32)
Expand Down
6 changes: 2 additions & 4 deletions tests/smoke_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ if(APPLE)
target_link_libraries(${TRAA_SMOKE_TEST} PRIVATE "${TRAA_LIBRARY_FRAMEWORKS}")

set_target_properties(${TRAA_SMOKE_TEST} PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION A
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_HOME_DIRECTORY}/src/base/devices/screen/test/simple_window/mac/info.plist"
MACOSX_FRAMEWORK_IDENTIFIER "${TRAA_SMOKE_TEST_IDENTIFIER}"
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${TRAA_VERSION_SHORT}"
MACOSX_FRAMEWORK_BUNDLE_VERSION "${TRAA_VERSION_SHORT}"
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${TRAA_OPTION_VERSION}"
MACOSX_FRAMEWORK_BUNDLE_VERSION "${TRAA_OPTION_VERSION}"
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${TRAA_SMOKE_TEST_IDENTIFIER}"
CXX_VISIBILITY_PRESET hidden
LINK_FLAGS "-Wl ${TRAA_SMOKE_TEST_FRAMEWORKS_FOLDERS} -rpath @loader_path"
Expand Down
6 changes: 2 additions & 4 deletions tests/unit_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,10 @@ if(APPLE)
target_link_libraries(${TRAA_UNIT_TEST} PRIVATE "${TRAA_LIBRARY_FRAMEWORKS}")

set_target_properties(${TRAA_UNIT_TEST} PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION A
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_HOME_DIRECTORY}/src/base/devices/screen/test/simple_window/mac/info.plist"
MACOSX_FRAMEWORK_IDENTIFIER "${TRAA_UNIT_TEST_IDENTIFIER}"
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${TRAA_VERSION_SHORT}"
MACOSX_FRAMEWORK_BUNDLE_VERSION "${TRAA_VERSION_SHORT}"
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${TRAA_OPTION_VERSION}"
MACOSX_FRAMEWORK_BUNDLE_VERSION "${TRAA_OPTION_VERSION}"
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${TRAA_UNIT_TEST_IDENTIFIER}"
CXX_VISIBILITY_PRESET hidden
LINK_FLAGS "-Wl ${TRAA_UNIT_TEST_FRAMEWORKS_FOLDERS} -rpath @loader_path"
Expand Down