Skip to content

Commit

Permalink
Test installation iOS/Linux/MacOS (#1401)
Browse files Browse the repository at this point in the history
forum:
https://forum.babylonjs.com/t/integrate-babylon-native-in-existing-swift-project/35886/28?u=cedric

- Because of CMake and Xcode, there are incompatilities with `install`
scheme on iOS. So, build needs to be started with the playground, then
using `cmake --install` . Also iOS install needs absolute prefix (
https://gitlab.kitware.com/cmake/cmake/-/issues/21282 )
- MacOS install scheme is fine but I could not enable scheme creation on
that target. So, it's been enabled for all targets.
- `if (TARGET ...` in cmake script test if the target exists. But if the
target exists but is not used, it will not be built. This is the case
for NativeTracing, disabling its build for iOS otherwise its .a is not
found at installation. Why is it not an issue for other build/installs?

- disable gtest fetching for ios
- disable openXR not other than win32 platforms
- `UNIX` is true in cmake scripts for Apple platforms, update checks
accordingly
- bump iOS deployment target to 15
- bump gradle task version because deprecate
- bump Xcode version from 15.3 to 15.4
  • Loading branch information
CedricGuillemet authored Sep 12, 2024
1 parent dd56a4d commit c2bf9df
Show file tree
Hide file tree
Showing 20 changed files with 226 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/jobs/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'

- task: Gradle@2
- task: Gradle@3
inputs:
workingDirectory: 'Apps/Playground/Android'
gradleWrapperFile: 'Apps/Playground/Android/gradlew'
Expand Down
14 changes: 6 additions & 8 deletions .github/jobs/ios.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
parameters:
name: ''
vmImage: ''
xcodeVersion: ''
deploymentTarget: '12'
deploymentTarget: '15'

jobs:
- job: ${{ parameters.name }}
Expand All @@ -16,13 +15,11 @@ jobs:
vmImage: ${{ parameters.vmImage }}

- script: |
sudo xcode-select --switch /Applications/Xcode_${{ parameters.xcodeVersion }}.app/Contents/Developer
displayName: 'Select Xcode ${{ parameters.xcodeVersion }}'
sudo xcode-select --switch /Applications/Xcode_$(XCODE_VERSION).app/Contents/Developer
displayName: 'Select Xcode $(XCODE_VERSION)'
- script: |
mkdir buildiOS
cd buildiOS
cmake .. -G Xcode -D IOS=ON -D DEPLOYMENT_TARGET=${{ parameters.deploymentTarget }} -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D BABYLON_DEBUG_TRACE=ON
cmake -G Xcode -B buildiOS -D IOS=ON -D DEPLOYMENT_TARGET=${{ parameters.deploymentTarget }} -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D BABYLON_DEBUG_TRACE=ON -D CMAKE_IOS_INSTALL_COMBINED=NO
displayName: 'Generate iOS solution'
- task: Xcode@5
Expand All @@ -31,6 +28,7 @@ jobs:
scheme: 'Playground'
sdk: 'iphoneos'
useXcpretty: false
configuration: RelWithDebInfo
configuration: Release
displayName: 'Build Playground iOS'


6 changes: 2 additions & 4 deletions .github/jobs/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ jobs:
displayName: 'Install packages'
- script: |
mkdir build
cd build
cmake .. -G Ninja -D JAVASCRIPTCORE_LIBRARY=/usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so -D NAPI_JAVASCRIPT_ENGINE=${{ parameters.JSEngine }} -D CMAKE_BUILD_TYPE=RelWithDebInfo -D BX_CONFIG_DEBUG=ON -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D BABYLON_DEBUG_TRACE=ON
ninja
cmake -G Ninja -B build -D JAVASCRIPTCORE_LIBRARY=/usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so -D NAPI_JAVASCRIPT_ENGINE=${{ parameters.JSEngine }} -D CMAKE_BUILD_TYPE=RelWithDebInfo -D BX_CONFIG_DEBUG=ON -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D OpenGL_GL_PREFERENCE=GLVND -D BABYLON_DEBUG_TRACE=ON
ninja -C build
displayName: 'Build X11'
# - script: |
Expand Down
13 changes: 7 additions & 6 deletions .github/jobs/macos.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
parameters:
name: ''
vmImage: ''
xcodeVersion: ''

jobs:
- job: ${{ parameters.name }}
Expand All @@ -15,15 +14,17 @@ jobs:
vmImage: ${{ parameters.vmImage }}

- script: |
sudo xcode-select --switch /Applications/Xcode_${{ parameters.xcodeVersion }}.app/Contents/Developer
displayName: 'Select XCode ${{ parameters.xcodeVersion }}'
sudo xcode-select --switch /Applications/Xcode_$(XCODE_VERSION).app/Contents/Developer
displayName: 'Select XCode $(XCODE_VERSION)'
- script: |
mkdir buildmacOS
cd buildmacOS
cmake .. -G Xcode -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D BABYLON_DEBUG_TRACE=ON
cmake -G Xcode -B buildmacOS -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D BABYLON_DEBUG_TRACE=ON
displayName: 'Generate macOS solution'
- script: |
xcodebuild -list -project buildmacOS/BabylonNative.xcodeproj
displayName: 'List available project schemes'
- task: Xcode@5
inputs:
xcWorkspacePath: 'buildmacOS/BabylonNative.xcodeproj'
Expand Down
39 changes: 39 additions & 0 deletions .github/jobs/test_install_ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
parameters:
name: ''
vmImage: ''
deploymentTarget: '15'

jobs:
- job: ${{ parameters.name }}
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
timeoutInMinutes: 40
pool:
vmImage: ${{ parameters.vmImage }}

steps:
- template: cmake.yml
parameters:
vmImage: ${{ parameters.vmImage }}

- script: |
sudo xcode-select --switch /Applications/Xcode_$(XCODE_VERSION).app/Contents/Developer
displayName: 'Select Xcode $(XCODE_VERSION)'
- script: |
cmake -G Xcode -B buildiOS -D IOS=ON -D DEPLOYMENT_TARGET=${{ parameters.deploymentTarget }} -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D BABYLON_DEBUG_TRACE=ON -D CMAKE_IOS_INSTALL_COMBINED=NO
displayName: 'Generate iOS solution'
- task: Xcode@5
inputs:
xcWorkspacePath: 'buildiOS/BabylonNative.xcodeproj'
scheme: 'Playground'
sdk: 'iphoneos'
useXcpretty: false
configuration: Release
displayName: 'Build Playground iOS'

- script: |
cmake --install buildiOS --prefix="$(Build.SourcesDirectory)/Install"
lipo -info $(Build.SourcesDirectory)/Install/lib/libxr.a
displayName: 'Install'
36 changes: 36 additions & 0 deletions .github/jobs/test_install_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
parameters:
name: ''
vmImage: ''
CC: ''
CXX: ''
JSEngine: ''

jobs:
- job: ${{ parameters.name }}
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
timeoutInMinutes: 30
pool:
vmImage: ${{ parameters.vmImage }}

variables:
CC: ${{ parameters.CC }}
CXX: ${{ parameters.CXX }}

steps:
- template: cmake.yml
parameters:
vmImage: ${{ parameters.vmImage }}

- script: |
sudo apt-get update
sudo apt-get install libjavascriptcoregtk-4.0-dev libgl1-mesa-dev libcurl4-openssl-dev
displayName: 'Install packages'
- script: |
cmake -G Ninja -B build -D JAVASCRIPTCORE_LIBRARY=/usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so -D NAPI_JAVASCRIPT_ENGINE=${{ parameters.JSEngine }} -D CMAKE_BUILD_TYPE=RelWithDebInfo -D BX_CONFIG_DEBUG=ON -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D OpenGL_GL_PREFERENCE=GLVND -D BABYLON_DEBUG_TRACE=ON
ninja -C build
displayName: 'Build X11'
- script: |
cmake --install build --prefix="./install"
displayName: 'Install'
36 changes: 36 additions & 0 deletions .github/jobs/test_install_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
parameters:
name: ''
vmImage: ''

jobs:
- job: ${{ parameters.name }}
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
timeoutInMinutes: 30
pool:
vmImage: ${{ parameters.vmImage }}

steps:
- template: cmake.yml
parameters:
vmImage: ${{ parameters.vmImage }}

- script: |
sudo xcode-select --switch /Applications/Xcode_$(XCODE_VERSION).app/Contents/Developer
displayName: 'Select XCode $(XCODE_VERSION)'
- script: |
cmake -G Xcode -B buildmacOS -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D BABYLON_DEBUG_TRACE=ON
displayName: 'Generate macOS solution'
- script: |
xcodebuild -list -project buildmacOS/BabylonNative.xcodeproj
displayName: 'List available project schemes'
- task: Xcode@5
inputs:
xcWorkspacePath: 'buildmacOS/BabylonNative.xcodeproj'
scheme: 'install'
sdk: 'macosx'
useXcpretty: false
configuration: Release
displayName: 'Build Installation content macOS'
55 changes: 55 additions & 0 deletions .github/jobs/test_install_win32.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
parameters:
- name: name
type: string
- name: vmImage
type: string
- name: platform
type: string
- name: napiType
type: string
default: direct
values:
- direct
- jsi
- V8
- name: graphics_api
type: string
default: D3D11

jobs:
- job: ${{ parameters.name }}
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
timeoutInMinutes: 20
pool:
vmImage: ${{ parameters.vmImage }}
variables:
${{ if eq(parameters.napiType, 'jsi') }}:
napiSuffix: '_JSI'
jsEngineDefine: '-DNAPI_JAVASCRIPT_ENGINE=JSI'
${{ elseif eq(parameters.napiType, 'V8') }}:
napiSuffix: '_V8'
jsEngineDefine: '-DNAPI_JAVASCRIPT_ENGINE=V8'
${{ else }}:
napiSuffix: ''
jsEngineDefine: ''
solutionName: 'Win32_${{ parameters.platform }}${{variables.napiSuffix}}'

steps:
- script: |
# BGFX_CONFIG_MAX_FRAME_BUFFERS is set so enough Framebuffers are available before V8 starts disposing unused ones
cmake -B build${{ variables.solutionName }} -A ${{ parameters.platform }} ${{ variables.jsEngineDefine }} -D BX_CONFIG_DEBUG=ON -D GRAPHICS_API=${{ parameters.graphics_api }} -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D BGFX_CONFIG_MAX_FRAME_BUFFERS=256 -D BABYLON_DEBUG_TRACE=ON
displayName: 'Generate ${{ variables.solutionName }} solution'
- task: MSBuild@1
inputs:
solution: 'build${{ variables.solutionName }}/BabylonNative.sln'
maximumCpuCount: true
configuration: 'RelWithDebInfo'
displayName: 'Build ${{ variables.solutionName }}'

- script: |
cmake --build build${{ variables.solutionName }} --target INSTALL --config RelWithDebInfo
cd Install/Test
cmake . -DBINARY_DIR=../../build${{ variables.solutionName }} ${{ variables.jsEngineDefine }}
cmake --build . --config RelWithDebInfo
displayName: 'Install'
4 changes: 1 addition & 3 deletions .github/jobs/uwp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ jobs:

steps:
- script: |
mkdir build${{ variables.solutionName }}
cd build${{ variables.solutionName }}
cmake .. -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 ${{ variables.jsEngineDefine }} -A ${{ parameters.platform }} -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D BABYLON_DEBUG_TRACE=ON
cmake -B build${{ variables.solutionName }} -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 ${{ variables.jsEngineDefine }} -A ${{ parameters.platform }} -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D BABYLON_DEBUG_TRACE=ON
displayName: 'Generate ${{ variables.solutionName }} solution'
- task: VSBuild@1
Expand Down
11 changes: 1 addition & 10 deletions .github/jobs/win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ jobs:

steps:
- script: |
mkdir build${{ variables.solutionName }}
cd build${{ variables.solutionName }}
# BGFX_CONFIG_MAX_FRAME_BUFFERS is set so enough Framebuffers are available before V8 starts disposing unused ones
cmake -A ${{ parameters.platform }} ${{ variables.jsEngineDefine }} -D BX_CONFIG_DEBUG=ON -D GRAPHICS_API=${{ parameters.graphics_api }} -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D BGFX_CONFIG_MAX_FRAME_BUFFERS=256 -D BABYLON_DEBUG_TRACE=ON ..
cmake -B build${{ variables.solutionName }} -A ${{ parameters.platform }} ${{ variables.jsEngineDefine }} -D BX_CONFIG_DEBUG=ON -D GRAPHICS_API=${{ parameters.graphics_api }} -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D BGFX_CONFIG_MAX_FRAME_BUFFERS=256 -D BABYLON_DEBUG_TRACE=ON
displayName: 'Generate ${{ variables.solutionName }} solution'
- task: MSBuild@1
Expand Down Expand Up @@ -66,13 +64,6 @@ jobs:
Playground app:///Scripts/validation_native.js
displayName: 'Validation Tests'
- script: |
cmake --build build${{ variables.solutionName }} --target INSTALL --config RelWithDebInfo
cd Install/Test
cmake . -DBINARY_DIR=../../build${{ variables.solutionName }} ${{ variables.jsEngineDefine }}
cmake --build . --config RelWithDebInfo
displayName: 'Install'
- task: PublishBuildArtifacts@1
inputs:
artifactName: '${{ variables.solutionName }} - ${{ parameters.graphics_api }} Rendered Pictures'
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ jobs:
- name: View Apps\node_modules content
run: Get-ChildItem -Path .\Apps\node_modules -Recurse
- name: Make Solution
run: mkdir buildWin32_x64 &&
cd buildWin32_x64 &&
cmake -A x64 -D BX_CONFIG_DEBUG=ON ..
run: |
cmake -A x64 -B buildWin32_x64 -D BX_CONFIG_DEBUG=ON
- name: NPM download nightly
run: npm run getNightly
working-directory: ./Apps
Expand Down
2 changes: 1 addition & 1 deletion Apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if(NOT ANDROID)
add_subdirectory(Playground)
endif()

if((WIN32 AND NOT WINDOWS_STORE) OR (APPLE AND NOT IOS AND NOT VISIONOS) OR (UNIX AND NOT ANDROID))
if((WIN32 AND NOT WINDOWS_STORE) OR (APPLE AND NOT IOS AND NOT VISIONOS) OR (UNIX AND NOT ANDROID AND NOT APPLE))
add_subdirectory(UnitTests)
endif()

Expand Down
2 changes: 0 additions & 2 deletions Apps/Playground/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ if(APPLE)
FOLDER "Playground")
endif()
set_property(TARGET Playground PROPERTY UNITY_BUILD false)
set_property(TARGET Playground PROPERTY XCODE_GENERATE_SCHEME YES)
set_property(TARGET Playground PROPERTY XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED YES)
endif()

Expand Down Expand Up @@ -251,5 +250,4 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SCRIPTS})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES})
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Playground)

set_property(TARGET Playground PROPERTY XCODE_GENERATE_SCHEME YES)
set_property(TARGET Playground PROPERTY XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED YES)
1 change: 0 additions & 1 deletion Apps/UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,3 @@ endforeach()
set_property(TARGET UnitTests PROPERTY FOLDER Apps)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES} ${SCRIPTS})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/../node_modules PREFIX node_modules FILES ${EXTERNAL_SCRIPTS})
set_property(TARGET UnitTests PROPERTY XCODE_GENERATE_SCHEME YES)
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ if(APPLE)
# Without this option on azure pipelines, there is a mismatch with math.h giving a lot of undefined functions on macOS.
# Only enabled for Apple as there is no issue for Windows.
set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE)
# Create scheme for installation and other targets
set(CMAKE_XCODE_GENERATE_SCHEME TRUE)
endif()

if(BABYLON_DEBUG_TRACE)
Expand Down
2 changes: 1 addition & 1 deletion Dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ set_property(TARGET SPIRV PROPERTY FOLDER Dependencies/glslang)
# --------------------------------------------------
# googletest
# --------------------------------------------------
if(BABYLON_NATIVE_BUILD_APPS AND (WIN32 OR (APPLE AND NOT IOS AND NOT VISIONOS) OR (UNIX AND NOT ANDROID)))
if(BABYLON_NATIVE_BUILD_APPS AND (WIN32 OR (APPLE AND NOT IOS AND NOT VISIONOS) OR (UNIX AND NOT ANDROID AND NOT APPLE)))
if(WIN32)
# For Windows: Prevent overriding the parent project's compiler/linker settings
# Default build type for my test projects are /MDd (MultiThreaded DLL) but GTests default to /MTd (MultiTreaded)
Expand Down
8 changes: 5 additions & 3 deletions Dependencies/xr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ endif()

project(xr)

# Avoid picking up system installed jsoncpp in favor of source distributed with openxr_loader project
set(BUILD_WITH_SYSTEM_JSONCPP OFF BOOL "disable using system installed jsoncpp")
FetchContent_MakeAvailable_With_Message(OpenXR-SDK OpenXR-MixedReality)

if(WIN32)
# Avoid picking up system installed jsoncpp in favor of source distributed with openxr_loader project
set(BUILD_WITH_SYSTEM_JSONCPP OFF BOOL "disable using system installed jsoncpp")
FetchContent_MakeAvailable_With_Message(OpenXR-SDK OpenXR-MixedReality)

set_property(TARGET openxr_loader PROPERTY FOLDER Dependencies/xr/OpenXR)
set_property(TARGET generate_openxr_header PROPERTY FOLDER Dependencies/xr/OpenXR/Generated)
set_property(TARGET xr_global_generated_files PROPERTY FOLDER Dependencies/xr/OpenXR/Generated)
Expand Down
6 changes: 5 additions & 1 deletion Install/Install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ if(TARGET openxr_loader)
install_targets(openxr_loader)
endif()

if(TARGET xr)
install_targets(xr)
endif()

## UrlLib
install_targets(UrlLib)

Expand Down Expand Up @@ -172,4 +176,4 @@ endif()
if(TARGET XMLHttpRequest)
install_targets(XMLHttpRequest)
install_include_for_targets(XMLHttpRequest)
endif()
endif()
Loading

0 comments on commit c2bf9df

Please sign in to comment.