Skip to content

About

Shared C++ runtime core for the NativeScript iOS and Android runtimes

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

 
 

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 namespace v8: it would hide ::v8 inside nativescript::common.
  • src/: implementation. Plain C++20, with no Objective-C and no JNI.
  • Formatting: .clang-format is 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-ignore until 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

  1. Add it to NS_RUNTIME_COMMON_V8_FREE_SOURCES or NS_RUNTIME_COMMON_V8_SOURCES in CMakeLists.txt (Android and host tests).
  2. Add it to the RuntimeCommon target in the iOS runtime's v8ios.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

License

Apache 2.0, the same as both runtimes. See LICENSE.

About

Shared C++ runtime core for the NativeScript iOS and Android runtimes

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages