GitHub - NativeScript/runtime-common: Shared C++ runtime core for the NativeScript iOS and Android runtimes
Repository navigation
runtime-commonPublic
About
Shared C++ runtime core for the NativeScript iOS and Android runtimes
Resources
Readme Apache-2.0 licenseCode of conduct
Code of conductContributing
ContributingSecurity policy
Security policy Activity Custom propertiesStars
0 starsWatchers
0 watchingForks
0 forks Report repositoryBranches
Tags
Go to Branches page Go to Tags page
Latest commit
History
154 Commits
View commit history for this file.
Folders and files
| Name | Name | Last commit message | Last commit date |
|---|---|---|---|
| .github/ workflows | .github/ workflows | ||
| docs | docs | ||
| include/ ns | include/ ns | ||
| src | src | ||
| tests | tests | ||
| .clang-format | .clang-format | ||
| .clang-format-ignore | .clang-format-ignore | ||
| .gitignore | .gitignore | ||
| CMakeLists.txt | CMakeLists.txt | ||
| LICENSE | LICENSE | ||
| README.md | README.md | ||
Repository files navigation
runtime-common
C++ shared by the NativeScript iOS runtime (NativeScript/ios ) and Android runtime (NativeScript/android ). Both runtimes build against the same V8, and this repository holds the code that does not depend on the platform. The plan and its open decisions are in docs/DESIGN.md .
Layout
include/ns/: public headers. Include them as"ns/<Name>.h", never by a bare file name: Xcode header maps resolve bare names project-wide, so a shared header and a runtime header with the same name would collide silently.- Namespace:
nativescript::common, subdivided by component (nativescript::common::base64, ...). Never name a nested namespacev8: it would hide::v8insidenativescript::common. src/: implementation. Plain C++20, with no Objective-C and no JNI.- Formatting:
.clang-formatis the iOS runtime's style and CI enforces it (clang-format 22.1.8). A file moved from a runtime and kept comparable with its copy goes in.clang-format-ignoreuntil the migration ends. tests/: host unit tests for the sources that do not need V8.
Core code includes only its own headers, V8 and the standard library. Anything platform-specific goes through an interface the runtime implements (DESIGN.md §4).
How the runtimes consume it
Each runtime pins this repository as a git submodule.
| Runtime | Path | Build |
|---|---|---|
| iOS | NativeScript/runtime-common |
RuntimeCommon static library target in v8ios.xcodeproj, linked into NativeScript.framework |
| Android | test-app/runtime/src/main/cpp/runtime-common |
add_subdirectory() from test-app/runtime/CMakeLists.txt, linked into libNativeScript.so |
The library compiles with the including runtime's V8 configuration: its
CMAKE_CXX_FLAGS on Android, its prefix header on iOS. Never set V8
configuration defines (pointer compression, smi size and so on) here; a mismatch
with the V8 build compiles and links, then fails at run time.
Adding a source file
- Add it to
NS_RUNTIME_COMMON_V8_FREE_SOURCESorNS_RUNTIME_COMMON_V8_SOURCESinCMakeLists.txt(Android and host tests). - Add it to the
RuntimeCommontarget in the iOS runtime'sv8ios.xcodeproj.
A change here is not done until both runtimes build against it.
Host tests
cmake -S . -B build -DNS_RUNTIME_COMMON_HOST_TESTS=ON cmake --build build ctest --test-dir build --output-on-failure
platform::ParseUrl is a hand-written stand-in by default. Add
-DNS_ADA_DIR=<folder holding ada.h and ada.cpp> (either runtime's vendored
ada) to run the tests against the real WHATWG parser.
License
Apache 2.0, the same as both runtimes. See LICENSE .
About
Shared C++ runtime core for the NativeScript iOS and Android runtimes