← Winnitude! Search  ·  Reader Mode (1200 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 54 LINKS

GitHub - NativeScript/runtime-common: Shared C++ runtime core for the NativeScript iOS and Android runtimes

Repository navigation

runtime-common
Public

About

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

Resources

Readme Apache-2.0 license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy Activity Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks Report repository
Branches

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 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

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

Resources

Readme Apache-2.0 license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy Activity Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks Report repository

Releases

Packages

Contributors

Languages