-
Notifications
You must be signed in to change notification settings - Fork 23
Incremental steps to support Android XR #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 34 commits
79e03c1
43d677a
22d1f96
435c798
e1d0f2f
dbef5ba
1159300
39f1536
82b17e8
2dd6185
98c40b5
02a7dc5
99c49b1
a40c852
f98247a
7faff92
b3480ca
118450b
4d9eb96
e5e5648
d205c4a
4633fa3
465685e
fcc3ce1
c1fdff4
a54a121
be1baf6
a6a258d
b9aa23c
27eed75
9a268bb
56be206
f378d3f
ed53fd9
863f962
2e467dd
84005c0
9e3cfc9
98e80ef
499ae36
51f1f45
496c67f
403b452
5253492
ebf6950
cfb1af6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ schedules: | |
|
|
||
| variables: | ||
| - name: ndkVersion | ||
| value: 25.2.9519653 | ||
| value: 28.2.13676358 | ||
|
|
||
| jobs: | ||
| # WIN32 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| /Build | ||
| /Tests/UnitTests/dist/ | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,38 @@ struct napi_callback_info__ { | |
| }; | ||
|
|
||
| namespace { | ||
| // Template specialization to provide char_traits functionality for JSChar (unsigned short) | ||
| // at compile time, mimicking std::char_traits interface | ||
| template<typename CharT> | ||
| struct jschar_traits; | ||
|
|
||
| template<> | ||
| struct jschar_traits<JSChar> { | ||
| using char_type = JSChar; | ||
|
|
||
| static constexpr size_t length(const char_type* str) noexcept { | ||
| if (!str) return 0; | ||
| const char_type* s = str; | ||
| while (*s) ++s; | ||
| return s - str; | ||
| } | ||
|
|
||
| static constexpr int compare(const char_type* s1, const char_type* s2, size_t n) noexcept { | ||
| for (size_t i = 0; i < n; ++i) { | ||
| if (s1[i] < s2[i]) return -1; | ||
| if (s1[i] > s2[i]) return 1; | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| static constexpr const char_type* find(const char_type* s, size_t n, const char_type& c) noexcept { | ||
| for (size_t i = 0; i < n; ++i) { | ||
| if (s[i] == c) return s + i; | ||
| } | ||
| return nullptr; | ||
| } | ||
|
||
| }; | ||
|
|
||
| class JSString { | ||
| public: | ||
| JSString(const JSString&) = delete; | ||
|
|
@@ -33,7 +65,7 @@ namespace { | |
| } | ||
|
|
||
| JSString(const JSChar* string, size_t length = NAPI_AUTO_LENGTH) | ||
| : _string{JSStringCreateWithCharacters(string, length == NAPI_AUTO_LENGTH ? std::char_traits<JSChar>::length(string) : length)} { | ||
| : _string{JSStringCreateWithCharacters(string, length == NAPI_AUTO_LENGTH ? jschar_traits<JSChar>::length(string) : length)} { | ||
| } | ||
|
|
||
| ~JSString() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "dependencies": { | ||
| "jsc-android": "250231.0.0" | ||
| "jsc-android": "294992.0.0" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ polyfills that consumers can include if required. | |
|
|
||
| ## **Building - All Development Platforms** | ||
|
|
||
| **Required Tools:** [git](https://git-scm.com/), [CMake](https://cmake.org/), [node.js](https://nodejs.org/en/) | ||
| **Required Tools:** [git](https://git-scm.com/), [CMake 3.29 (or newer)](https://cmake.org/), [node.js (20.x or newer)](https://nodejs.org/en/) | ||
matthargett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The first step for all development environments and targets is to clone this repository. | ||
|
|
||
|
|
@@ -32,9 +32,11 @@ npm install | |
| _Follow the steps from [All Development Platforms](#all-development-platforms) before proceeding._ | ||
|
|
||
| **Required Tools:** | ||
| [Android Studio](https://developer.android.com/studio), [Node.js](https://nodejs.org/en/download/), [Ninja](https://ninja-build.org/) | ||
| [Android Studio](https://developer.android.com/studio) (with Android NDK 28.2.13676358 and API level 35 SDK platforms installed), [Node.js (20.x or newer)](https://nodejs.org/en/download/), [Ninja](https://ninja-build.org/) | ||
matthargett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The minimal requirement target is Android 5.0. | ||
| The minimal requirement target is Android 10.0, which has [~95%](https://gs.statcounter.com/android-version-market-share/mobile-tablet/worldwide) active device coverage globally. Android 10 support covers Meta Quest 1 (and newer), HTC Vive Focus 2 (and newer), and Pico 3 (and newer). | ||
|
|
||
| > **Note:** JsRuntimeHost uses NDK 28.2 for Android XR compatibility. The project automatically downloads and uses a prebuilt V8 JavaScript engine optimized for Android. | ||
matthargett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Only building with Android Studio is supported. CMake is not used directly. Instead, Gradle | ||
| is used for building and CMake is automatically invocated for building the native part. | ||
|
|
@@ -68,4 +70,4 @@ Security Response Center (MSRC) at [[email protected]](mailto:secure@microsof | |
| You should receive a response within 24 hours. If for some reason you do not, please | ||
| follow up via email to ensure we received your original message. Further information, | ||
| including the [MSRC PGP](https://technet.microsoft.com/en-us/security/dn606155) key, can | ||
| be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/default). | ||
| be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/default). | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| #include <jni.h> | ||
| #include <Android/log.h> | ||
| #include <android/log.h> | ||
| #include <AndroidExtensions/Globals.h> | ||
| #include <AndroidExtensions/JavaWrappers.h> | ||
| #include <AndroidExtensions/StdoutLogger.h> | ||
|
|
@@ -17,16 +17,17 @@ Java_com_jsruntimehost_unittests_Native_javaScriptTests(JNIEnv* env, jclass claz | |
| jclass webSocketClass{env->FindClass("com/jsruntimehost/unittests/WebSocket")}; | ||
| java::websocket::WebSocketClient::InitializeJavaWebSocketClass(webSocketClass, env); | ||
|
|
||
| android::StdoutLogger::Start(); | ||
| // Temporarily disable StdoutLogger due to fdsan issue with NDK 28 | ||
| // android::StdoutLogger::Start(); | ||
|
||
|
|
||
| android::global::Initialize(javaVM, context); | ||
|
|
||
| Babylon::DebugTrace::EnableDebugTrace(true); | ||
| Babylon::DebugTrace::SetTraceOutput([](const char* trace) { printf("%s\n", trace); fflush(stdout); }); | ||
| Babylon::DebugTrace::SetTraceOutput([](const char* trace) { __android_log_print(ANDROID_LOG_INFO, "JsRuntimeHost", "%s", trace); }); | ||
|
|
||
| auto testResult = RunTests(); | ||
|
|
||
| android::StdoutLogger::Stop(); | ||
| // android::StdoutLogger::Stop(); | ||
|
|
||
| java::websocket::WebSocketClient::DestructJavaWebSocketClass(env); | ||
| return testResult; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.