Skip to content

Commit

Permalink
CMake Fetchcontent instead of submodules (#613)
Browse files Browse the repository at this point in the history
* CMake Fetchcontent instead of submodules

* include(FetchContent)

* up BN

* fix order of inclusion

* urllib decl

* use BN with fetchcontent

* fetch content instead of add_subdirectory

* forgot to remove 1 line in pr.yml

* 2 steps fetching

* simplify path for windows

* BN version

* 2times populated

* source paths for header copy. Android one is wrong.

* windows library paths

* fix windows build paths

* windows path

* windows paths

* Update fetch commit
  • Loading branch information
CedricGuillemet authored Oct 25, 2023
1 parent 073ed48 commit 6617896
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 95 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/bn_master_commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ jobs:
- name: NPM Install (Binary Package)
run: npm install
working-directory: ./Package
- name: Git (Update to BabylonNative ${{ github.event.client_payload.sha }})
run: npx gulp initializeSubmodulesMostRecentBabylonNative --sha ${{ github.event.client_payload.sha }}
working-directory: ./Package
- name: Gulp (Android)
run: npx gulp buildAndroid
working-directory: ./Package
Expand Down Expand Up @@ -65,9 +62,6 @@ jobs:
- name: NPM Install (Binary Package)
run: npm install
working-directory: ./Package
- name: Git (Update to BabylonNative ${{ github.event.client_payload.sha }})
run: npx gulp initializeSubmodulesMostRecentBabylonNative --sha ${{ github.event.client_payload.sha }}
working-directory: ./Package
- name: Gulp (iOS)
run: npx gulp buildIOS
working-directory: ./Package
Expand Down Expand Up @@ -103,9 +97,6 @@ jobs:
- name: NPM Install (Binary Package)
run: npm install
working-directory: ./Package
- name: Git (Update to BabylonNative ${{ github.event.client_payload.sha }})
run: npx gulp initializeSubmodulesMostRecentBabylonNative --sha ${{ github.event.client_payload.sha }} --windows
working-directory: ./Package
- name: Gulp Setup Project ${{ matrix.platform }} (Windows)
run: npx gulp makeUWPProject${{ matrix.platform }}
working-directory: ./Package
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ jobs:
- name: NPM Install (Binary Package)
run: npm install
working-directory: ./Package
- name: Git (Windows)
run: npx gulp initializeSubmodulesWindowsAgent
working-directory: ./Package
- name: Gulp Setup Project ${{ matrix.platform }} (Windows)
run: npx gulp makeUWPProject${{ matrix.platform }}
working-directory: ./Package
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ jobs:
- name: NPM Install (Binary Package)
run: npm install
working-directory: ./Package
- name: Git (Windows)
run: npx gulp initializeSubmodulesWindowsAgent --reactNative ${{ inputs.react-native-version }} --releaseVersion ${{ inputs.release-version }}
working-directory: ./Package
- name: Gulp (Windows)
run: npx gulp buildUWPPublish --reactNative ${{ inputs.react-native-version }} --releaseVersion ${{ inputs.release-version }}
working-directory: ./Package
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

3 changes: 0 additions & 3 deletions Apps/Playground/scripts/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ function postInstall() {
console.log(chalk.black.bgCyan('Installing Babylon React Native npm packages...'));
shelljs.exec('npm install --legacy-peer-deps', {cwd: '../../../Modules/@babylonjs/react-native'});

console.log(chalk.black.bgCyan('Updating submodules...'));
shelljs.exec('git submodule update --init --recursive', {cwd: '../../../'});

if (os.platform() === 'darwin') {
iosCMake();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ target_include_directories(jsi INTERFACE ${REACTNATIVE_DIR_CMAKE}/ReactCommon/js
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/src/")

set(BABYLON_NATIVE_BUILD_APPS OFF CACHE BOOL "")
set(BABYLON_NATIVE_DIR "${CMAKE_CURRENT_LIST_DIR}/../submodules/BabylonNative")
add_subdirectory(${BABYLON_NATIVE_DIR} ${BABYLON_NATIVE_DIR}/build/Android_${CMAKE_ANDROID_ARCH_ABI}/)
add_subdirectory(${babylonnative_SOURCE_DIR} ${babylonnative_SOURCE_DIR}/build/Android_${CMAKE_ANDROID_ARCH_ABI}/)

set(BABYLON_REACT_NATIVE_SHARED_DIR "${CMAKE_CURRENT_LIST_DIR}/../../react-native/shared")
add_subdirectory(${BABYLON_REACT_NATIVE_SHARED_DIR} ${CMAKE_CURRENT_BINARY_DIR}/shared)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ target_include_directories(reactnative INTERFACE ${REACTNATIVE_DIR}/ReactCommon/
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/")

set(BABYLON_NATIVE_BUILD_APPS OFF CACHE BOOL "")
set(BABYLON_NATIVE_DIR "${CMAKE_CURRENT_LIST_DIR}/../submodules/BabylonNative")
add_subdirectory(${BABYLON_NATIVE_DIR} ${BABYLON_NATIVE_DIR}/build/ios)
add_subdirectory(${babylonnative_SOURCE_DIR} ${babylonnative_SOURCE_DIR}/build/ios)

set(BABYLON_REACT_NATIVE_SHARED_DIR "${CMAKE_CURRENT_LIST_DIR}/../../react-native/shared")
add_subdirectory(${BABYLON_REACT_NATIVE_SHARED_DIR} ${CMAKE_CURRENT_BINARY_DIR}/shared)
Expand Down
Submodule BabylonNative deleted from b04555
Original file line number Diff line number Diff line change
Expand Up @@ -127,32 +127,31 @@
<!-- Library directories when building in repo -->
<!-- Note: you can add BabylonNative component build folders here as needed -->
<AdditionalLibraryDirectories Condition="'$(BabylonNativeBuildDir)' != ''">
$(BabylonNativeBuildDir)BabylonNative\Core\JsRuntime\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Core\Graphics\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Dependencies\bgfx.cmake\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Dependencies\glslang\glslang\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Dependencies\glslang\glslang\OSDependent\Windows\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Dependencies\glslang\OGLCompilersDLL\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Dependencies\glslang\SPIRV\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Dependencies\SPIRV-Cross\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Dependencies\xr\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Dependencies\xr\Dependencies\OpenXR-SDK\src\loader\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Plugins\NativeCamera\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Plugins\NativeCapture\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Plugins\NativeEngine\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Plugins\NativeInput\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Plugins\NativeOptimizations\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Plugins\NativeTracing\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Plugins\NativeXr\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Polyfills\Window\$(Configuration);
$(BabylonNativeBuildDir)BabylonNative\Polyfills\Canvas\$(Configuration);
$(BabylonNativeBuildDir)babylonnative\Core\Graphics\$(Configuration);
$(BabylonNativeBuildDir)babylonnative\Dependencies\xr\$(Configuration);
$(BabylonNativeBuildDir)babylonnative\Plugins\NativeCamera\$(Configuration);
$(BabylonNativeBuildDir)babylonnative\Plugins\NativeCapture\$(Configuration);
$(BabylonNativeBuildDir)babylonnative\Plugins\NativeEngine\$(Configuration);
$(BabylonNativeBuildDir)babylonnative\Plugins\NativeInput\$(Configuration);
$(BabylonNativeBuildDir)babylonnative\Plugins\NativeOptimizations\$(Configuration);
$(BabylonNativeBuildDir)babylonnative\Plugins\NativeTracing\$(Configuration);
$(BabylonNativeBuildDir)babylonnative\Plugins\NativeXr\$(Configuration);
$(BabylonNativeBuildDir)babylonnative\Polyfills\Window\$(Configuration);
$(BabylonNativeBuildDir)babylonnative\Polyfills\Canvas\$(Configuration);
$(BabylonNativeBuildDir)jsi\$(Configuration);
$(BabylonNativeBuildDir)$(Configuration);
$(BabylonNativeBuildDir)_deps\arcana-build\$(Configuration);
$(BabylonNativeBuildDir)_deps\jsruntimehost-build\Core\JsRuntime\$(Configuration);
$(BabylonNativeBuildDir)_deps\jsruntimehost-build\Core\Node-API-JSI\$(Configuration);
$(BabylonNativeBuildDir)_deps\jsruntimehost-build\Polyfills\XMLHttpRequest\$(Configuration);
$(BabylonNativeBuildDir)_deps\urllib-build\$(Configuration);
$(BabylonNativeBuildDir)_deps\bgfx-build\$(Configuration);
$(BabylonNativeBuildDir)_deps\glslang-build\glslang\$(Configuration);
$(BabylonNativeBuildDir)_deps\glslang-build\glslang\OSDependent\Windows\$(Configuration);
$(BabylonNativeBuildDir)_deps\glslang-build\OGLCompilersDLL\$(Configuration);
$(BabylonNativeBuildDir)_deps\glslang-build\SPIRV\$(Configuration);
$(BabylonNativeBuildDir)_deps\spirv-cross-build\$(Configuration);
$(BabylonNativeBuildDir)_deps\openxr-sdk-build\src\loader\$(Configuration);
%(AdditionalLibraryDirectories);
</AdditionalLibraryDirectories>
<!-- Library directories when building from npm package -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ include(${BABYLON_REACT_NATIVE_DIR}/shared/CMakeLists.txt)
# Note: We should avoid installing node_modules in the Module\@babylonjs\react-native folder.
# Installing react-native dependencies for both the Playground app and the @babylonjs\react-native package will generate a bad bundle/runtime errors.
set(NAPI_JAVASCRIPT_ENGINE "JSI" CACHE STRING "")
set(REACTNATIVE_DIR_CMAKE "${CMAKE_CURRENT_LIST_DIR}/../../../../Apps/Playground/Playground/node_modules/react-native")
get_filename_component(REACTNATIVE_DIR_CMAKE "${CMAKE_CURRENT_LIST_DIR}/../../../../Apps/Playground/Playground/node_modules/react-native" ABSOLUTE)
add_subdirectory("${REACTNATIVE_DIR_CMAKE}/ReactCommon/jsi/jsi" ${CMAKE_CURRENT_BINARY_DIR}/jsi)
target_include_directories(jsi INTERFACE ${REACTNATIVE_DIR_CMAKE}/ReactCommon/jsi)

set(BABYLON_NATIVE_BUILD_APPS OFF CACHE BOOL "")
set(BABYLON_NATIVE_USE_SWAPCHAINPANEL ON CACHE BOOL "")
set(BABYLON_NATIVE_DIR "${BABYLON_REACT_NATIVE_IOSANDROID}/submodules/BabylonNative")
add_subdirectory(${BABYLON_NATIVE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/BabylonNative EXCLUDE_FROM_ALL)
add_subdirectory(${babylonnative_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/BabylonNative EXCLUDE_FROM_ALL)
# Disable Unity build for UrlLib because of conflict in header between windows.h and winrt
set_property(TARGET UrlLib PROPERTY UNITY_BUILD false)

Expand Down
10 changes: 10 additions & 0 deletions Modules/@babylonjs/react-native/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
include(FetchContent)

FetchContent_Declare(babylonnative
GIT_REPOSITORY https://github.com/BabylonJS/BabylonNative.git
GIT_TAG abd41d50d4ce156af452dcdfacf45210989280a1)

set(SHARED_INCLUDES
"${CMAKE_CURRENT_LIST_DIR}")

Expand All @@ -10,3 +16,7 @@ if (${BASEKIT_BUILD})
set(BABYLON_NATIVE_PLUGIN_NATIVEXR OFF CACHE BOOL "")
set(BABYLON_NATIVE_PLUGIN_NATIVECAMERA OFF CACHE BOOL "")
endif()
FetchContent_GetProperties(babylonnative)
if(NOT babylonnative_POPULATED)
FetchContent_Populate(babylonnative)
endif()
55 changes: 8 additions & 47 deletions Package/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,42 +93,6 @@ const buildAndroid = async () => {
exec(`./gradlew babylonjs_react-native:assembleRelease --stacktrace --info ${basekitBuildProp}`, '../Apps/Playground/Playground/android');
};

const initializeSubmodulesWindowsAgent = async () => {
// windows build agents don't support the path lengths required for initializing arcore dependencies,
// so we manually initialize the submodules we need here.
exec('git -c submodule."Dependencies/xr/Dependencies/arcore-android-sdk".update=none submodule update --init --recursive "./../Modules/@babylonjs/react-native-iosandroid/submodules/BabylonNative');
}

const initializeSubmodulesMostRecentBabylonNative = async () => {
let shaFound = false;
const shaOptionIndex = process.argv.indexOf('--sha');
if (shaOptionIndex >= 0) {
const shaIndex = shaOptionIndex + 1;
if (process.argv.length > shaIndex) {
shaFound = true;
const sha = process.argv[shaIndex];
console.log("Using provided commit: " + sha);
exec('git submodule init ./../Modules/@babylonjs/react-native-iosandroid/submodules/BabylonNative');
exec('git fetch origin ' + sha, './../Modules/@babylonjs/react-native-iosandroid/submodules/BabylonNative');
exec('git checkout ' + sha, './../Modules/@babylonjs/react-native-iosandroid/submodules/BabylonNative');
}
}

if (!shaFound) {
exec('git submodule init ./../Modules/@babylonjs/react-native/submodules/BabylonNative');
exec('git fetch origin master', './../Modules/@babylonjs/react-native/submodules/BabylonNative');
exec('git checkout origin/master', './../Modules/@babylonjs/react-native/submodules/BabylonNative');
}

if (process.argv.indexOf('--windows') >= 0) {
exec('git -c submodule."Dependencies/xr/Dependencies/arcore-android-sdk".update=none submodule update --init --recursive *', './../Modules/@babylonjs/react-native/submodules/BabylonNative');
} else {
exec('git submodule update --init --recursive', './../Modules/@babylonjs/react-native/submodules/BabylonNative');
}

exec('git status');
}

const makeUWPProjectPlatform = async (name, arch) => {
shelljs.mkdir('-p', `./../Modules/@babylonjs/react-native/Build/uwp_${name}`);
exec(`cmake -G "Visual Studio 16 2019" -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 -DCMAKE_UNITY_BUILD=true ${cmakeBasekitBuildDefinition} -A ${arch} ./../../../react-native-windows/windows`, `./../Modules/@babylonjs/react-native/Build/uwp_${name}`);
Expand Down Expand Up @@ -268,7 +232,7 @@ const copyIOSFiles = async () => {
});

await new Promise(resolve => {
gulp.src('../Apps/Playground/Playground/node_modules/@babylonjs/react-native-iosandroid/submodules/BabylonNative/Dependencies/xr/Source/ARKit/Include/*')
gulp.src('../Package/iOS/Build/_deps/babylonnative-src/Dependencies/xr/Source/ARKit/Include/*')
.pipe(gulp.dest(`${assemblediOSAndroidDir}/ios/include`))
.on('end', resolve);
});
Expand All @@ -290,7 +254,7 @@ const copyAndroidFiles = async () => {
});

await new Promise(resolve => {
gulp.src('../Apps/Playground/Playground/node_modules/@babylonjs/react-native-iosandroid/submodules/BabylonNative/Dependencies/xr/Source/ARCore/Include/*')
gulp.src('../Package/iOS/Build/_deps/babylonnative-src/Dependencies/xr/Source/ARCore/Include/*')
.pipe(gulp.dest(`${assemblediOSAndroidDir}/android/include`))
.on('end', resolve);
});
Expand Down Expand Up @@ -399,23 +363,23 @@ const copyVCXProjUWPFiles = () => {
}

const copyOpenXRInfoFiles = () => {
return gulp.src('../Modules/@babylonjs/react-native-iosandroid/submodules/BabylonNative/Dependencies/xr/Dependencies/OpenXR-MixedReality/LICENSE')
.pipe(gulp.src('../Modules/@babylonjs/react-native-iosandroid/submodules/BabylonNative/Dependencies/xr/Dependencies/OpenXR-MixedReality/README.md'))
return gulp.src('../Modules/@babylonjs/react-native/Build/uwp_x64/_deps/openxr-mixedreality-src/LICENSE')
.pipe(gulp.src('../Modules/@babylonjs/react-native/Build/uwp_x64/_deps/openxr-mixedreality-src/README.md'))
.pipe(gulp.dest(`${assembledWindowsDir}/windows/OpenXR-MixedReality`));
}

const copyOpenXRPreviewHeaders = () => {
return gulp.src('../Modules/@babylonjs/react-native-iosandroid/submodules/BabylonNative/Dependencies/xr/Dependencies/OpenXR-MixedReality/openxr_preview/include/openxr/*')
return gulp.src('../Modules/@babylonjs/react-native/Build/uwp_x64/_deps/openxr-mixedreality-src/openxr_preview/include/openxr/*')
.pipe(gulp.dest(`${assembledWindowsDir}/windows/OpenXR-MixedReality/include/openxr`));
}

const copyOpenXRUtilityHeaders = () => {
return gulp.src('../Modules/@babylonjs/react-native-iosandroid/submodules/BabylonNative/Dependencies/xr/Dependencies/OpenXR-MixedReality/shared/XrUtility/*')
return gulp.src('../Modules/@babylonjs/react-native/Build/uwp_x64/_deps/openxr-mixedreality-src/shared/XrUtility/*')
.pipe(gulp.dest(`${assembledWindowsDir}/windows/OpenXR-MixedReality/include/XrUtility`));
}

const copyOpenXRHelperHeaders = () => {
return gulp.src('../Modules/@babylonjs/react-native-iosandroid/submodules/BabylonNative/Dependencies/xr/Source/OpenXR/Include/*')
return gulp.src('../Modules/@babylonjs/react-native/Build/uwp_x64/_deps/babylonnative-src/Dependencies/xr/Source/OpenXR/Include/*')
.pipe(gulp.src('../Modules/@babylonjs/react-native-windows/windows/include/*'))
.pipe(gulp.dest(`${assembledWindowsDir}/windows/include`));
}
Expand Down Expand Up @@ -707,12 +671,11 @@ exports.buildAndroid = buildAndroid;
exports.packAndroid = packAndroid;

const copyPackageFilesUWP = gulp.series(copyUWPFiles);
const buildUWPPublish = gulp.series(buildUWP, copyPackageFilesUWP, switchToBaseKit, patchPackageVersion, buildUWP, copyPackageFilesUWP);
const buildUWPPublish = gulp.series(patchPackageVersion, buildUWP, copyPackageFilesUWP, switchToBaseKit, patchPackageVersion, buildUWP, copyPackageFilesUWP);
const packUWP = gulp.series(clean, buildUWP, copyPackageFilesUWP, createPackage, createPackageUWP);
const packUWPNoBuild = gulp.series(clean, copyPackageFilesUWP, createPackage, createPackageUWP);

exports.buildTS = buildTS;
exports.initializeSubmodulesWindowsAgent = gulp.series(patchPackageVersion, initializeSubmodulesWindowsAgent);
exports.makeUWPProjectx86 = makeUWPProjectx86;
exports.makeUWPProjectx64 = makeUWPProjectx64;
exports.makeUWPProjectARM = makeUWPProjectARM;
Expand Down Expand Up @@ -747,6 +710,4 @@ exports.copyUWPFiles = copyUWPFiles;
exports.packUWP = packUWP;
exports.packUWPNoBuild = packUWPNoBuild;

exports.initializeSubmodulesMostRecentBabylonNative = initializeSubmodulesMostRecentBabylonNative;

exports.default = build;

0 comments on commit 6617896

Please sign in to comment.