Skip to content

Commit

Permalink
Create pch for all platforms V3 (#20705)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyhappygame authored Dec 6, 2021
1 parent 387f56a commit cd7446f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 35 deletions.
37 changes: 19 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ jobs:
- run: cmake -B b -S .
- run: cmake --build b

ubuntu-20_04:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- run: python download-deps.py --r no
- run: echo -e "y" | bash build/install-deps-linux.sh
- run: cmake -B b -S .
- run: cmake --build b
# https://github.com/cocos2d/cocos2d-x/issues/20471
# ubuntu-20_04:
# runs-on: ubuntu-20.04
# steps:
# - uses: actions/checkout@v2
# - run: python download-deps.py --r no
# - run: echo -e "y" | bash build/install-deps-linux.sh
# - run: cmake -B b -S .
# - run: cmake --build b

windows-2019:
runs-on: windows-2019
Expand All @@ -51,34 +52,34 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: python download-deps.py --r no
- run: cmake -B b -S .
- run: cmake --build b
- run: cmake -B b -S . -GXcode
- run: cmake --build b --target cpp-tests

macos-11:
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- run: python download-deps.py --r no
- run: cmake -B b -S .
- run: cmake --build b
- run: cmake -B b -S . -GXcode
- run: cmake --build b --target cpp-tests

macos-10_15_ios:
ios_macos-10_15:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
- run: python download-deps.py --r no
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_SYSTEM_PROCESSOR=arm64
- run: cmake --build b --config Release --target cpp-tests -- -quiet

macos-11_ios:
ios_macos-11:
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- run: python download-deps.py --r no
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_SYSTEM_PROCESSOR=arm64
- run: cmake --build b --config Release --target cpp-tests -- -quiet -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)"

windows-2019-android:
android_windows-2019:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
Expand All @@ -87,7 +88,7 @@ jobs:
shell: bash
working-directory: tests/cpp-tests/proj.android

ubuntu-20_04-android:
android_ubuntu-20_04:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
Expand Down
11 changes: 4 additions & 7 deletions cocos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,8 @@ if(XCODE OR VS)
cocos_mark_code_files("cocos2d")
endif()

if(WINDOWS)
# precompiled header. Compilation time speedup ~4x.
target_sources(cocos2d PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp")
set_target_properties(cocos2d PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
# compile c as c++. needed for precompiled header
set_source_files_properties(${COCOS_SPINE_SRC} base/ccFPSImages.c PROPERTIES LANGUAGE CXX)
if(${CMAKE_VERSION} VERSION_GREATER "3.16.0")
message("CMake 3.16 target_precompile_headers")
target_precompile_headers(cocos2d PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:cocos2d.h>")
endif()
9 changes: 4 additions & 5 deletions cocos/scripting/js-bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ if(XCODE OR VS)
cocos_mark_code_files("jscocos2d")
endif()

if(WINDOWS)
# precompiled header
target_sources(jscocos2d PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp")
set_target_properties(jscocos2d PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
if(${CMAKE_VERSION} VERSION_GREATER "3.16.0")
message("CMake 3.16 target_precompile_headers")
target_precompile_headers(jscocos2d PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:precheader.h>")
endif()
9 changes: 4 additions & 5 deletions tests/cpp-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,8 @@ if(LINUX OR WINDOWS)
cocos_copy_target_res(${APP_NAME} COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
endif()

if(WINDOWS)
# precompiled header. Compilation time speedup ~4x.
target_sources(${APP_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp")
set_target_properties(${APP_NAME} PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
if(${CMAKE_VERSION} VERSION_GREATER "3.16.0")
message("CMake 3.16 target_precompile_headers")
target_precompile_headers(${APP_NAME} PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:precheader.h>")
endif()

0 comments on commit cd7446f

Please sign in to comment.