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
5 changes: 2 additions & 3 deletions Apps/PackageTest/ios/PackageTest.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@
C5056CCD3641216F351DE750 /* Pods-PackageTest-tvOSTests.debug.xcconfig */,
C671E95B56582A5129BD9DC3 /* Pods-PackageTest-tvOSTests.release.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
Expand Down Expand Up @@ -828,7 +827,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)";
LIBRARY_SEARCH_PATHS = (
"\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
Expand Down Expand Up @@ -881,7 +880,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)";
LIBRARY_SEARCH_PATHS = (
"\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Apps/PackageTest/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ SPEC CHECKSUMS:
React-jsi: b6dc94a6a12ff98e8877287a0b7620d365201161
React-jsiexecutor: 1540d1c01bb493ae3124ed83351b1b6a155db7da
React-jsinspector: 512e560d0e985d0e8c479a54a4e5c147a9c83493
react-native-babylon: fb07a9209a7236b70d93bee5c6404d97b6eddfca
react-native-babylon: aefdca46971b35a7dbe99cd9c8ba4ea7d6d0b8b4
React-RCTActionSheet: f41ea8a811aac770e0cc6e0ad6b270c644ea8b7c
React-RCTAnimation: 49ab98b1c1ff4445148b72a3d61554138565bad0
React-RCTBlob: a332773f0ebc413a0ce85942a55b064471587a71
Expand Down
4 changes: 2 additions & 2 deletions Apps/PackageTest/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Apps/PackageTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@babylonjs/core": "^4.2.0-alpha.21",
"@babylonjs/react-native": "file:../Playground/node_modules/@babylonjs/react-native/babylonjs-react-native-0.0.1.tgz",
"@babylonjs/react-native": "file:../../Package/Assembled/babylonjs-react-native-0.0.1.tgz",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-permissions": "^2.1.5"
Expand Down
2 changes: 1 addition & 1 deletion Apps/Playground/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ SPEC CHECKSUMS:
React-jsi: 600d8e42510c3254fd2abd702f4b9d3f598d8f52
React-jsiexecutor: e9698dee4fd43ceb44832baf15d5745f455b0157
React-jsinspector: f74a62727e5604119abd4a1eda52c0a12144bcd5
react-native-babylon: fb07a9209a7236b70d93bee5c6404d97b6eddfca
react-native-babylon: 004630b2838450727c093bfcc30e05d5b08206c1
react-native-slider: e51492f1264d882a8815b71c5870f8978e52887d
React-RCTActionSheet: af8f28dd82fec89b8fe29637b8c779829e016a88
React-RCTAnimation: 0d21fff7c20fb8ee41de5f2ebb63221127febd96
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Submodule BabylonNative updated 29 files
+17 −17 Apps/ValidationTests/Scripts/validation_native.js
+1 −1 Dependencies/glslang
+139 −65 Dependencies/xr/Source/ARKit/XR.mm
+74 −0 Documentation/DebugRenderedFrameMetal.md
+ Documentation/Images/FrameCaptureiOS/CaptureDrawCall.jpg
+ Documentation/Images/FrameCaptureiOS/CaptureFragmentShaderSource.jpg
+ Documentation/Images/FrameCaptureiOS/CaptureFragmentUniforms.jpg
+ Documentation/Images/FrameCaptureiOS/CaptureFrameMenu.jpg
+ Documentation/Images/FrameCaptureiOS/CaptureGeometry.jpg
+ Documentation/Images/FrameCaptureiOS/CaptureGeometryReview.jpg
+ Documentation/Images/FrameCaptureiOS/CaptureResult.jpg
+ Documentation/Images/FrameCaptureiOS/CaptureVertexShaderSource.jpg
+ Documentation/Images/FrameCaptureiOS/CaptureVertexUniforms.jpg
+ Documentation/Images/FrameCaptureiOS/ReleaseFrameCapture.jpg
+ Documentation/Images/FrameCaptureiOS/Sampler.jpg
+ Documentation/Images/FrameCaptureiOS/SimulatorFrameToCapture.jpg
+ Documentation/Images/FrameCaptureiOS/Texture.jpg
+21 −0 Documentation/Readme.md
+31 −4 Plugins/NativeEngine/Source/BgfxCallback.cpp
+8 −2 Plugins/NativeEngine/Source/BgfxCallback.h
+4 −36 Plugins/NativeEngine/Source/NativeEngine.cpp
+122 −56 Plugins/NativeEngine/Source/NativeEngine.h
+1 −0 Plugins/NativeEngine/Source/ResourceLimits.cpp
+0 −4 Plugins/NativeEngine/Source/ShaderCompiler.cpp
+0 −4 Plugins/NativeEngine/Source/ShaderCompilerD3D.cpp
+0 −4 Plugins/NativeEngine/Source/ShaderCompilerTraversers.cpp
+5 −1 Plugins/NativeXr/Source/NativeXr.cpp
+4 −0 README.md
+4 −2 azure-pipelines.yml
3 changes: 3 additions & 0 deletions Package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Assembled
Build
node_modules
161 changes: 161 additions & 0 deletions Package/Android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
// android/build.gradle

// based on:
//
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
// original location:
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
//
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
// original location:
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle

def DEFAULT_COMPILE_SDK_VERSION = 28
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
def DEFAULT_MIN_SDK_VERSION = 18
def DEFAULT_TARGET_SDK_VERSION = 28

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: 'com.android.library'
apply plugin: 'maven'

buildscript {
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
if (project == rootProject) {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
}
}

apply plugin: 'com.android.library'
apply plugin: 'maven'

android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

repositories {
// ref: https://www.baeldung.com/maven-local-repository
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
// Android JSC is installed from npm
url "$rootDir/../node_modules/jsc-android/dist"
}
google()
jcenter()
}

dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation 'com.google.ar:core:1.14.0'
}

def configureReactNativePom(def pom) {
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)

pom.project {
name packageJson.title
artifactId packageJson.name
version = packageJson.version
group = "com.reactlibrary"
description packageJson.description
url packageJson.repository.baseUrl

licenses {
license {
name packageJson.license
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
distribution 'repo'
}
}

developers {
developer {
id packageJson.author.username
name packageJson.author.name
}
}
}
}

afterEvaluate { project ->
// some Gradle build hooks ref:
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
task androidJavadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += files(android.bootClasspath)
classpath += files(project.getConfigurations().getByName('compile').asList())
include '**/*.java'
}

task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
classifier = 'javadoc'
from androidJavadoc.destinationDir
}

task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
include '**/*.java'
}

android.libraryVariants.all { variant ->
def name = variant.name.capitalize()
def javaCompileTask = variant.javaCompileProvider.get()

task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
from javaCompileTask.destinationDir
}
}

artifacts {
archives androidSourcesJar
archives androidJavadocJar
}

task installArchives(type: Upload) {
configuration = configurations.archives
repositories.mavenDeployer {
// Deploy to react-native-event-bridge/maven, ready to publish to npm
repository url: "file://${projectDir}/../android/maven"
configureReactNativePom pom
}
}
}

task validateSdk {
def minSdkVersion = safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
if (minSdkVersion < DEFAULT_MIN_SDK_VERSION) {
throw new GradleException("minSdkVersion must be at least ${DEFAULT_MIN_SDK_VERSION} but is currently ${minSdkVersion}")
}
}
106 changes: 106 additions & 0 deletions Package/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
const util = require('util');
const fs = require('fs');
const readdirAsync = util.promisify(fs.readdir);
const log = require('fancy-log');
const gulp = require('gulp');
const shelljs = require('shelljs');

function exec(command, workingDirectory = '.', logCommand = true) {
if (logCommand) {
log(command);
}

shelljs.pushd('-q', workingDirectory);
try {
if (shelljs.exec(command, {fatal: true}).code) {
throw `'${command}' finished with non-zero exit code.`;
}
} finally {
shelljs.popd('-q');
}
}

const clean = async () => {
if (shelljs.test('-d', 'Assembled')) {
shelljs.rm('-r', 'Assembled');
}
};

const makeXCodeProj = async () => {
shelljs.mkdir('-p', 'iOS/Build');
exec('cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=../../../Apps/Playground/node_modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/ios-cmake/ios.toolchain.cmake -DPLATFORM=OS64COMBINED -DENABLE_ARC=0 -DDEPLOYMENT_TARGET=12 -DENABLE_GLSLANG_BINARIES=OFF -DSPIRV_CROSS_CLI=OFF ..', 'iOS/Build');
};

const buildIphoneOS = async () => {
exec('xcodebuild -sdk iphoneos -configuration Release -project ReactNativeBabylon.xcodeproj -scheme BabylonNative build CODE_SIGNING_ALLOWED=NO', 'iOS/Build');
};

const buildIphoneSimulator = async () => {
exec('xcodebuild -sdk iphonesimulator -configuration Release -project ReactNativeBabylon.xcodeproj -scheme BabylonNative build CODE_SIGNING_ALLOWED=NO', 'iOS/Build');
};

const buildIOS = gulp.series(makeXCodeProj, buildIphoneOS, buildIphoneSimulator);

const buildAndroid = async () => {
exec('./gradlew babylonjs_react-native:assembleRelease', '../Apps/Playground/android');
};

const copyCommonFiles = () => {
return gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/package.json')
.pipe(gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/README.md'))
.pipe(gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/*.ts*'))
.pipe(gulp.src('react-native-babylon.podspec'))
.pipe(gulp.dest('Assembled'));
};

const copyIOSFiles = () => {
return gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/ios/*.h')
.pipe(gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/ios/*.mm'))
// This xcodeproj is garbage that we don't need in the package, but `pod install` ignores the package if it doesn't contain at least one xcodeproj. 🤷🏼‍♂️
.pipe(gulp.src('iOS/Build/ReactNativeBabylon.xcodeproj**/**/*'))
.pipe(gulp.dest('Assembled/ios'));
};

const createIOSUniversalLibs = async () => {
shelljs.mkdir('-p', 'Assembled/ios/libs');
const libs = await readdirAsync('iOS/Build/Release-iphoneos');
libs.map(lib => exec(`lipo -create iOS/Build/Release-iphoneos/${lib} iOS/Build/Release-iphonesimulator/${lib} -output Assembled/ios/libs/${lib}`));
};

const copyAndroidFiles = async () => {
await new Promise(resolve => {
gulp.src('Android/build.gradle')
.pipe(gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/android/src**/main/AndroidManifest.xml'))
.pipe(gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/android/src**/main/java/**/*'))
.pipe(gulp.dest('Assembled/android'))
.on('end', resolve);
});

await new Promise(resolve => {
gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/android/build/intermediates/library_and_local_jars_jni/release/jni/**/*')
.pipe(gulp.dest('Assembled/android/src/main/jniLibs/'))
.on('end', resolve);
});
Comment on lines +71 to +83
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is using new Promise really necessary here? Seems like you can use gulp.parallel like below?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if i use gulp.parallel, then Gulp treats these as individual atomic "tasks." I think it makes more sense to have these grouped together in a single "logical task."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean use gulp.parallel on the "tasks" returned by each section of the gulp.pipe.pipe:

Suggested change
await new Promise(resolve => {
gulp.src('Android/build.gradle')
.pipe(gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/android/src**/main/AndroidManifest.xml'))
.pipe(gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/android/src**/main/java/**/*'))
.pipe(gulp.dest('Assembled/android'))
.on('end', resolve);
});
await new Promise(resolve => {
gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/android/build/intermediates/library_and_local_jars_jni/release/jni/**/*')
.pipe(gulp.dest('Assembled/android/src/main/jniLibs/'))
.on('end', resolve);
});
gulp.parallel(
gulp.src('Android/build.gradle')
.pipe(gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/android/src**/main/AndroidManifest.xml'))
.pipe(gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/android/src**/main/java/**/*'))
.pipe(gulp.dest('Assembled/android')),
gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/android/build/intermediates/library_and_local_jars_jni/release/jni/**/*')
.pipe(gulp.dest('Assembled/android/src/main/jniLibs/'))
);

Does this work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that will create two nodes in the task hierarchy named "anonymous function" (or something like that). Talked offline, leaving as is.

};

const createPackage = async () => {
exec('npm pack', 'Assembled');
};

const copyFiles = gulp.parallel(copyCommonFiles, copyIOSFiles, copyAndroidFiles);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the difference between gulp.parallel and Promise.all. Why use one vs. the other?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gulp functions/tasks can return Promises, but they can also return a variety of other objects representing asynchronous work (such as those using the src/pipe/dest stuff). gulp.parallel understands all these, and also makes it so gulp understands the task hierarchy and can display reasonable command line output for the tasks that it is running.


const build = gulp.series(buildIOS, buildAndroid, createIOSUniversalLibs, copyFiles);
const rebuild = gulp.series(clean, build);
const pack = gulp.series(rebuild, createPackage);

exports.buildIOS = buildIOS;
exports.buildAndroid = buildAndroid;
exports.createIOSUniversalLibs = createIOSUniversalLibs;
exports.copyFiles = copyFiles;

exports.clean = clean;
exports.build = build;
exports.rebuild = rebuild;
exports.pack = pack;

exports.default = build;
Loading