basalt-core 0.0.0-rc5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/cli/basalt.d.ts +3 -0
- package/dist/cli/basalt.d.ts.map +1 -0
- package/dist/cli/basalt.js +47 -0
- package/dist/cli/basalt.js.map +1 -0
- package/dist/cli/bundle-cli.d.ts +12 -0
- package/dist/cli/bundle-cli.d.ts.map +1 -0
- package/dist/cli/bundle-cli.js +124 -0
- package/dist/cli/bundle-cli.js.map +1 -0
- package/dist/cli/bundleWithAssets.d.ts +79 -0
- package/dist/cli/bundleWithAssets.d.ts.map +1 -0
- package/dist/cli/bundleWithAssets.js +198 -0
- package/dist/cli/bundleWithAssets.js.map +1 -0
- package/dist/cli/desktop.d.ts +339 -0
- package/dist/cli/desktop.d.ts.map +1 -0
- package/dist/cli/desktop.js +1029 -0
- package/dist/cli/desktop.js.map +1 -0
- package/dist/cli/doctor.d.ts +31 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +283 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/init.d.ts +77 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +442 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/metro.d.ts +49 -0
- package/dist/cli/metro.d.ts.map +1 -0
- package/dist/cli/metro.js +148 -0
- package/dist/cli/metro.js.map +1 -0
- package/dist/cli/packageApp.d.ts +102 -0
- package/dist/cli/packageApp.d.ts.map +1 -0
- package/dist/cli/packageApp.js +319 -0
- package/dist/cli/packageApp.js.map +1 -0
- package/dist/cli/steps.d.ts +34 -0
- package/dist/cli/steps.d.ts.map +1 -0
- package/dist/cli/steps.js +53 -0
- package/dist/cli/steps.js.map +1 -0
- package/dist/metro-config.d.ts +168 -0
- package/dist/metro-config.d.ts.map +1 -0
- package/dist/metro-config.js +671 -0
- package/dist/metro-config.js.map +1 -0
- package/dist/react-native.config.d.ts +7 -0
- package/dist/react-native.config.d.ts.map +1 -0
- package/dist/react-native.config.js +80 -0
- package/dist/react-native.config.js.map +1 -0
- package/dist/src/DragSource.d.ts +52 -0
- package/dist/src/DragSource.d.ts.map +1 -0
- package/dist/src/DragSource.js +97 -0
- package/dist/src/DragSource.js.map +1 -0
- package/dist/src/DropTarget.d.ts +58 -0
- package/dist/src/DropTarget.d.ts.map +1 -0
- package/dist/src/DropTarget.js +131 -0
- package/dist/src/DropTarget.js.map +1 -0
- package/dist/src/KeyHandler.d.ts +57 -0
- package/dist/src/KeyHandler.d.ts.map +1 -0
- package/dist/src/KeyHandler.js +48 -0
- package/dist/src/KeyHandler.js.map +1 -0
- package/dist/src/Menu.d.ts +72 -0
- package/dist/src/Menu.d.ts.map +1 -0
- package/dist/src/Menu.js +179 -0
- package/dist/src/Menu.js.map +1 -0
- package/dist/src/TitleBar.d.ts +75 -0
- package/dist/src/TitleBar.d.ts.map +1 -0
- package/dist/src/TitleBar.js +236 -0
- package/dist/src/TitleBar.js.map +1 -0
- package/dist/src/Window.d.ts +87 -0
- package/dist/src/Window.d.ts.map +1 -0
- package/dist/src/Window.js +248 -0
- package/dist/src/Window.js.map +1 -0
- package/dist/src/closeRequest.d.ts +55 -0
- package/dist/src/closeRequest.d.ts.map +1 -0
- package/dist/src/closeRequest.js +134 -0
- package/dist/src/closeRequest.js.map +1 -0
- package/dist/src/index.d.ts +45 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +92 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/overrides/Alert.d.ts +69 -0
- package/dist/src/overrides/Alert.d.ts.map +1 -0
- package/dist/src/overrides/Alert.js +112 -0
- package/dist/src/overrides/Alert.js.map +1 -0
- package/dist/src/overrides/BaseViewConfig.d.ts +28 -0
- package/dist/src/overrides/BaseViewConfig.d.ts.map +1 -0
- package/dist/src/overrides/BaseViewConfig.js +72 -0
- package/dist/src/overrides/BaseViewConfig.js.map +1 -0
- package/dist/src/overrides/Platform.linux.d.ts +10 -0
- package/dist/src/overrides/Platform.linux.d.ts.map +1 -0
- package/dist/src/overrides/Platform.linux.js +15 -0
- package/dist/src/overrides/Platform.linux.js.map +1 -0
- package/dist/src/overrides/Platform.macos.d.ts +10 -0
- package/dist/src/overrides/Platform.macos.d.ts.map +1 -0
- package/dist/src/overrides/Platform.macos.js +15 -0
- package/dist/src/overrides/Platform.macos.js.map +1 -0
- package/dist/src/overrides/Platform.windows.d.ts +10 -0
- package/dist/src/overrides/Platform.windows.d.ts.map +1 -0
- package/dist/src/overrides/Platform.windows.js +15 -0
- package/dist/src/overrides/Platform.windows.js.map +1 -0
- package/dist/src/overrides/ReactDevToolsSettingsManager.d.ts +24 -0
- package/dist/src/overrides/ReactDevToolsSettingsManager.d.ts.map +1 -0
- package/dist/src/overrides/ReactDevToolsSettingsManager.js +30 -0
- package/dist/src/overrides/ReactDevToolsSettingsManager.js.map +1 -0
- package/dist/src/overrides/RefreshControl.d.ts +52 -0
- package/dist/src/overrides/RefreshControl.d.ts.map +1 -0
- package/dist/src/overrides/RefreshControl.js +92 -0
- package/dist/src/overrides/RefreshControl.js.map +1 -0
- package/dist/src/overrides/ScrollView.d.ts +39 -0
- package/dist/src/overrides/ScrollView.d.ts.map +1 -0
- package/dist/src/overrides/ScrollView.js +59 -0
- package/dist/src/overrides/ScrollView.js.map +1 -0
- package/dist/src/overrides/Share.d.ts +96 -0
- package/dist/src/overrides/Share.d.ts.map +1 -0
- package/dist/src/overrides/Share.js +97 -0
- package/dist/src/overrides/Share.js.map +1 -0
- package/dist/src/overrides/TextInput.d.ts +81 -0
- package/dist/src/overrides/TextInput.d.ts.map +1 -0
- package/dist/src/overrides/TextInput.js +213 -0
- package/dist/src/overrides/TextInput.js.map +1 -0
- package/dist/src/overrides/View.d.ts +36 -0
- package/dist/src/overrides/View.d.ts.map +1 -0
- package/dist/src/overrides/View.js +99 -0
- package/dist/src/overrides/View.js.map +1 -0
- package/dist/src/overrides/createPlatform.d.ts +32 -0
- package/dist/src/overrides/createPlatform.d.ts.map +1 -0
- package/dist/src/overrides/createPlatform.js +84 -0
- package/dist/src/overrides/createPlatform.js.map +1 -0
- package/dist/src/overrides/setUpDeveloperTools.d.ts +28 -0
- package/dist/src/overrides/setUpDeveloperTools.d.ts.map +1 -0
- package/dist/src/overrides/setUpDeveloperTools.js +84 -0
- package/dist/src/overrides/setUpDeveloperTools.js.map +1 -0
- package/dist/src/overrides/setUpXHR.d.ts +46 -0
- package/dist/src/overrides/setUpXHR.d.ts.map +1 -0
- package/dist/src/overrides/setUpXHR.js +236 -0
- package/dist/src/overrides/setUpXHR.js.map +1 -0
- package/dist/src/quitRequest.d.ts +55 -0
- package/dist/src/quitRequest.d.ts.map +1 -0
- package/dist/src/quitRequest.js +121 -0
- package/dist/src/quitRequest.js.map +1 -0
- package/dist/src/resourcePath.d.ts +18 -0
- package/dist/src/resourcePath.d.ts.map +1 -0
- package/dist/src/resourcePath.js +31 -0
- package/dist/src/resourcePath.js.map +1 -0
- package/dist/src/responseBody.d.ts +76 -0
- package/dist/src/responseBody.d.ts.map +1 -0
- package/dist/src/responseBody.js +94 -0
- package/dist/src/responseBody.js.map +1 -0
- package/dist/src/responseHeaders.d.ts +40 -0
- package/dist/src/responseHeaders.d.ts.map +1 -0
- package/dist/src/responseHeaders.js +75 -0
- package/dist/src/responseHeaders.js.map +1 -0
- package/dist/src/titleBarState.d.ts +43 -0
- package/dist/src/titleBarState.d.ts.map +1 -0
- package/dist/src/titleBarState.js +77 -0
- package/dist/src/titleBarState.js.map +1 -0
- package/dist/src/useContextMenu.d.ts +113 -0
- package/dist/src/useContextMenu.d.ts.map +1 -0
- package/dist/src/useContextMenu.js +109 -0
- package/dist/src/useContextMenu.js.map +1 -0
- package/dist/src/useDialog.d.ts +98 -0
- package/dist/src/useDialog.d.ts.map +1 -0
- package/dist/src/useDialog.js +112 -0
- package/dist/src/useDialog.js.map +1 -0
- package/dist/src/useDisplays.d.ts +70 -0
- package/dist/src/useDisplays.d.ts.map +1 -0
- package/dist/src/useDisplays.js +118 -0
- package/dist/src/useDisplays.js.map +1 -0
- package/dist/src/useHandledKeys.d.ts +38 -0
- package/dist/src/useHandledKeys.d.ts.map +1 -0
- package/dist/src/useHandledKeys.js +70 -0
- package/dist/src/useHandledKeys.js.map +1 -0
- package/dist/src/useWindow.d.ts +140 -0
- package/dist/src/useWindow.d.ts.map +1 -0
- package/dist/src/useWindow.js +233 -0
- package/dist/src/useWindow.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/native/CMakeLists.txt +355 -0
- package/native/bootstrap.sh +613 -0
- package/native/cmake/CompilerFlags.cmake +49 -0
- package/native/cmake/Expo.cmake +125 -0
- package/native/cmake/ReactNativeCore.cmake +612 -0
- package/native/cmake/Reanimated.cmake +108 -0
- package/native/cmake/Skia.cmake +379 -0
- package/native/cmake/ThirdParty.cmake +290 -0
- package/native/cmake/Worklets.cmake +67 -0
- package/native/cmake/codegen/CMakeLists.txt +32 -0
- package/native/core/AppIdentity.cpp +85 -0
- package/native/core/AppIdentity.h +59 -0
- package/native/core/AppPaths.cpp +96 -0
- package/native/core/AppPaths.h +53 -0
- package/native/core/AppearanceModule.cpp +60 -0
- package/native/core/AppearanceModule.h +40 -0
- package/native/core/Backface.h +59 -0
- package/native/core/BlobModule.cpp +283 -0
- package/native/core/BlobModule.h +76 -0
- package/native/core/BlobRegistry.cpp +75 -0
- package/native/core/BlobRegistry.h +44 -0
- package/native/core/ColorScheme.cpp +105 -0
- package/native/core/ColorScheme.h +59 -0
- package/native/core/ComponentRegistry.h +30 -0
- package/native/core/ControlMetrics.h +37 -0
- package/native/core/CoreModules.cpp +592 -0
- package/native/core/CoreModules.h +308 -0
- package/native/core/DebuggingOverlay.cpp +106 -0
- package/native/core/DebuggingOverlay.h +65 -0
- package/native/core/DesktopControls.cpp +232 -0
- package/native/core/DesktopControls.h +170 -0
- package/native/core/DevBundle.cpp +108 -0
- package/native/core/DevBundle.h +69 -0
- package/native/core/DevMenu.cpp +99 -0
- package/native/core/DevMenu.h +75 -0
- package/native/core/DialogModule.cpp +150 -0
- package/native/core/DialogModule.h +51 -0
- package/native/core/DragAndDrop.cpp +45 -0
- package/native/core/DragAndDrop.h +225 -0
- package/native/core/ExpoImageComponent.cpp +79 -0
- package/native/core/ExpoImageComponent.h +80 -0
- package/native/core/ExpoModules.cpp +415 -0
- package/native/core/ExpoModules.h +115 -0
- package/native/core/ExpoRuntime.cpp +366 -0
- package/native/core/ExpoRuntime.h +42 -0
- package/native/core/FocusRing.h +36 -0
- package/native/core/FontRegistry.h +51 -0
- package/native/core/GestureHandlerModule.cpp +136 -0
- package/native/core/GestureHandlerModule.h +71 -0
- package/native/core/Gestures.cpp +533 -0
- package/native/core/Gestures.h +145 -0
- package/native/core/HoverTracker.cpp +69 -0
- package/native/core/HoverTracker.h +109 -0
- package/native/core/HttpClient.cpp +282 -0
- package/native/core/ImageBytes.cpp +205 -0
- package/native/core/ImageBytes.h +29 -0
- package/native/core/ImageCache.cpp +51 -0
- package/native/core/ImageCache.h +89 -0
- package/native/core/JsRuntimeAccess.cpp +70 -0
- package/native/core/JsRuntimeAccess.h +60 -0
- package/native/core/JsiPromise.h +51 -0
- package/native/core/KeyEvents.cpp +116 -0
- package/native/core/KeyEvents.h +144 -0
- package/native/core/LogBoxSurface.cpp +46 -0
- package/native/core/LogBoxSurface.h +68 -0
- package/native/core/MenuModel.h +117 -0
- package/native/core/MenuModule.cpp +209 -0
- package/native/core/MenuModule.h +66 -0
- package/native/core/MountingWalk.h +524 -0
- package/native/core/PackageModules.cpp.in +25 -0
- package/native/core/PackageModules.h +50 -0
- package/native/core/PlatformConstantsModule.cpp +63 -0
- package/native/core/PlatformConstantsModule.h +64 -0
- package/native/core/PlatformServices.h +213 -0
- package/native/core/PointerButtons.h +63 -0
- package/native/core/PullToRefresh.cpp +57 -0
- package/native/core/PullToRefresh.h +73 -0
- package/native/core/ReanimatedCompat.h +47 -0
- package/native/core/ReanimatedModule.cpp +203 -0
- package/native/core/ReanimatedModule.h +55 -0
- package/native/core/ScrollAnimation.cpp +59 -0
- package/native/core/ScrollAnimation.h +70 -0
- package/native/core/ScrollBounds.cpp +26 -0
- package/native/core/ScrollBounds.h +68 -0
- package/native/core/ScrollIndicator.cpp +50 -0
- package/native/core/ScrollIndicator.h +69 -0
- package/native/core/ScrollMomentum.cpp +71 -0
- package/native/core/ScrollMomentum.h +73 -0
- package/native/core/ScrollSnap.cpp +123 -0
- package/native/core/ScrollSnap.h +80 -0
- package/native/core/ShareFallback.cpp +101 -0
- package/native/core/ShareFallback.h +45 -0
- package/native/core/SkiaPictureViewComponent.cpp +11 -0
- package/native/core/SkiaPictureViewComponent.h +47 -0
- package/native/core/SourceCodeModule.cpp +55 -0
- package/native/core/SourceCodeModule.h +53 -0
- package/native/core/StatusBarModule.cpp +23 -0
- package/native/core/StatusBarModule.h +42 -0
- package/native/core/TestDialog.cpp +148 -0
- package/native/core/TestDialog.h +96 -0
- package/native/core/TestKeys.cpp +78 -0
- package/native/core/TestKeys.h +50 -0
- package/native/core/TestQuitFile.cpp +33 -0
- package/native/core/TestQuitFile.h +60 -0
- package/native/core/TestSettle.h +192 -0
- package/native/core/TitleBarRegions.h +31 -0
- package/native/core/TurboModuleProxy.cpp +51 -0
- package/native/core/TurboModuleProxy.h +46 -0
- package/native/core/UIManagerAccess.cpp +43 -0
- package/native/core/UIManagerAccess.h +43 -0
- package/native/core/WindowBoundsCache.cpp +319 -0
- package/native/core/WindowControl.h +235 -0
- package/native/core/WindowHost.h +158 -0
- package/native/core/WindowMethods.cpp +167 -0
- package/native/core/WindowMethods.h +84 -0
- package/native/core/WindowsModule.cpp +448 -0
- package/native/core/WindowsModule.h +133 -0
- package/native/core/WorkletsModule.cpp +199 -0
- package/native/core/WorkletsModule.h +57 -0
- package/native/core/portability_probe.cpp +210 -0
- package/native/tests/EventRecorder.h +124 -0
- package/native/tests/TestHarness.cpp +109 -0
- package/native/tests/TestHarness.h +89 -0
- package/native/tests/TreeDump.h +49 -0
- package/native/tests/test_app_identity.cpp +114 -0
- package/native/tests/test_app_paths.cpp +48 -0
- package/native/tests/test_appearance.cpp +107 -0
- package/native/tests/test_backface.cpp +79 -0
- package/native/tests/test_blobs.cpp +157 -0
- package/native/tests/test_controls.cpp +185 -0
- package/native/tests/test_devbundle.cpp +103 -0
- package/native/tests/test_drag_and_drop.cpp +143 -0
- package/native/tests/test_gestures.cpp +331 -0
- package/native/tests/test_hover.cpp +92 -0
- package/native/tests/test_image_cache.cpp +109 -0
- package/native/tests/test_js_runtime_access.cpp +137 -0
- package/native/tests/test_key_events.cpp +235 -0
- package/native/tests/test_momentum.cpp +138 -0
- package/native/tests/test_quit_file.cpp +104 -0
- package/native/tests/test_scroll_animation.cpp +120 -0
- package/native/tests/test_scroll_bounds.cpp +66 -0
- package/native/tests/test_scroll_indicator.cpp +149 -0
- package/native/tests/test_scroll_snap.cpp +112 -0
- package/native/tests/test_settle.cpp +115 -0
- package/native/tests/test_share.cpp +75 -0
- package/native/tests/test_sourcecode.cpp +62 -0
- package/native/tests/test_window_close.cpp +119 -0
- package/native/tests/test_window_limits.cpp +123 -0
- package/package.json +43 -0
- package/react-native.config.js +86 -0
- package/supported-versions.json +66 -0
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Fetches and builds everything this project needs that is not in the repo:
|
|
3
|
+
# vendored third-party sources, Hermes, and React Native's codegen output.
|
|
4
|
+
#
|
|
5
|
+
# Usage: scripts/bootstrap.sh /path/to/react-native-checkout
|
|
6
|
+
#
|
|
7
|
+
# Idempotent: each step is skipped if its output already exists. Pass --force
|
|
8
|
+
# to redo everything.
|
|
9
|
+
|
|
10
|
+
set -euo pipefail
|
|
11
|
+
|
|
12
|
+
RN_DIR_ARG="${1:-}"
|
|
13
|
+
FORCE="${2:-}"
|
|
14
|
+
[ "${1:-}" = "--force" ] && { FORCE="--force"; RN_DIR_ARG=""; }
|
|
15
|
+
|
|
16
|
+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
17
|
+
|
|
18
|
+
# Where the vendored dependencies go. Not beside this script: this script now
|
|
19
|
+
# ships inside the npm package, and npm deletes and rewrites node_modules, which
|
|
20
|
+
# is not a place to leave a Hermes build. An app passes its own directory;
|
|
21
|
+
# scripts/bootstrap.sh in this repository passes the repository root.
|
|
22
|
+
TP="${BASALT_THIRD_PARTY:-$PWD/third_party}"
|
|
23
|
+
mkdir -p "$TP"
|
|
24
|
+
TP="$(cd "$TP" && pwd)"
|
|
25
|
+
|
|
26
|
+
# Only used to guess where a React Native checkout might be, and only when one
|
|
27
|
+
# was not named. Two levels up from the package is the repository root in a
|
|
28
|
+
# development checkout, and node_modules in an installed one, where the guess
|
|
29
|
+
# will simply fail and the path has to be given.
|
|
30
|
+
REPO_ROOT="$(cd "$HERE/../../.." && pwd)"
|
|
31
|
+
|
|
32
|
+
# Versions are React Native's own pins, from
|
|
33
|
+
# packages/react-native/gradle/libs.versions.toml. Check them after an RN bump.
|
|
34
|
+
#
|
|
35
|
+
# Hermes is not here. It is pinned per supported React Native in
|
|
36
|
+
# ../supported-versions.json, because it is coupled to ReactCommon and one
|
|
37
|
+
# version cannot serve several React Natives.
|
|
38
|
+
FOLLY_VERSION="2024.11.18.00"
|
|
39
|
+
FAST_FLOAT_VERSION="8.0.0"
|
|
40
|
+
NLOHMANN_VERSION="3.11.3"
|
|
41
|
+
|
|
42
|
+
# React Native requires ^22.13.0 || ^24.3.0 || >= 26.0.0. Node 25.x is
|
|
43
|
+
# excluded and yarn install fails an engine check in a preinstall hook.
|
|
44
|
+
NODE_VERSION="24"
|
|
45
|
+
|
|
46
|
+
log() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
|
|
47
|
+
die() { printf '\033[1;31merror:\033[0m %s\n' "$*" >&2; exit 1; }
|
|
48
|
+
|
|
49
|
+
# --- which desktop is this ---------------------------------------------------
|
|
50
|
+
#
|
|
51
|
+
# Windows means Git Bash or MSYS, which is where this script runs there -- it is
|
|
52
|
+
# a bash script and there is no reason for a second one in PowerShell that would
|
|
53
|
+
# drift from it. `uname -s` reports MINGW64_NT-10.0 or MSYS_NT-10.0 under those.
|
|
54
|
+
#
|
|
55
|
+
# What differs on Windows is not the shape of the bootstrap but four details:
|
|
56
|
+
# there is no pkg-config and no GTK, the compiler is clang-cl rather than
|
|
57
|
+
# clang++, Hermes needs three extra flags and a one-word patch, and the library
|
|
58
|
+
# it produces is called something else. Each is handled where it arises rather
|
|
59
|
+
# than in a parallel branch.
|
|
60
|
+
case "$(uname -s)" in
|
|
61
|
+
MINGW*|MSYS*|CYGWIN*) HOST_OS=windows ;;
|
|
62
|
+
Darwin) HOST_OS=macos ;;
|
|
63
|
+
*) HOST_OS=linux ;;
|
|
64
|
+
esac
|
|
65
|
+
|
|
66
|
+
# `nice` is POSIX and Git Bash does not have it. Used to keep a long compile
|
|
67
|
+
# from making the machine unusable, which is a courtesy rather than a
|
|
68
|
+
# requirement, so on Windows it simply becomes nothing.
|
|
69
|
+
if [ "$HOST_OS" = windows ]; then
|
|
70
|
+
NICE=()
|
|
71
|
+
else
|
|
72
|
+
NICE=(nice -n 10)
|
|
73
|
+
fi
|
|
74
|
+
run_nice() { ${NICE[@]+"${NICE[@]}"} "$@"; }
|
|
75
|
+
|
|
76
|
+
if [ -n "$FORCE" ]; then
|
|
77
|
+
log "--force: removing fetched trees"
|
|
78
|
+
rm -rf "$TP/folly" "$TP/fast_float" "$TP/nlohmann_json" "$TP/hermes" \
|
|
79
|
+
"$TP/hermes-build" "$TP/node"
|
|
80
|
+
# Not the whole codegen dir: its CMakeLists.txt is checked in and replaces
|
|
81
|
+
# the Android-only one the generator emits. Only the generated tree goes.
|
|
82
|
+
rm -rf "$TP/codegen/react" "$TP"/codegen/*.h "$TP"/codegen/*.cpp
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
# --- locate the React Native checkout ---------------------------------------
|
|
86
|
+
RN_DIR="${RN_DIR_ARG:-${RN_DIR:-}}"
|
|
87
|
+
if [ -z "$RN_DIR" ]; then
|
|
88
|
+
for candidate in "$REPO_ROOT/../react-native" "$HOME/Workspace/react-native"; do
|
|
89
|
+
[ -d "$candidate/packages/react-native/ReactCommon" ] && { RN_DIR="$candidate"; break; }
|
|
90
|
+
done
|
|
91
|
+
fi
|
|
92
|
+
[ -n "$RN_DIR" ] || die "pass the React Native checkout path, or set RN_DIR.
|
|
93
|
+
git clone --depth 1 https://github.com/react/react-native"
|
|
94
|
+
RN_DIR="$(cd "$RN_DIR" && pwd)"
|
|
95
|
+
|
|
96
|
+
# Two shapes are accepted. A source checkout, where the package sits under
|
|
97
|
+
# packages/react-native, and an installed one, where the directory given *is*
|
|
98
|
+
# the package. The second is what an app has, and it very nearly works: React
|
|
99
|
+
# Native ships its C++, the codegen script, the Hermes pin and the version table
|
|
100
|
+
# in the npm package. The one thing missing is ReactCxxPlatform, which is absent
|
|
101
|
+
# from the package's `files` list, and which is the layer this host is built on.
|
|
102
|
+
# See docs/PORTING.md.
|
|
103
|
+
if [ -d "$RN_DIR/packages/react-native/ReactCommon" ]; then
|
|
104
|
+
RN_PKG="$RN_DIR/packages/react-native"
|
|
105
|
+
RN_LAYOUT=checkout
|
|
106
|
+
elif [ -d "$RN_DIR/ReactCommon" ]; then
|
|
107
|
+
RN_PKG="$RN_DIR"
|
|
108
|
+
RN_LAYOUT=installed
|
|
109
|
+
else
|
|
110
|
+
die "not a React Native checkout or package: $RN_DIR"
|
|
111
|
+
fi
|
|
112
|
+
RN_VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' \
|
|
113
|
+
"$RN_PKG/package.json" | head -1)"
|
|
114
|
+
log "React Native $RN_VERSION ($RN_LAYOUT): $RN_PKG"
|
|
115
|
+
|
|
116
|
+
# --- is this version supported ----------------------------------------------
|
|
117
|
+
# Asked here, before anything is downloaded or compiled, because the answer for
|
|
118
|
+
# an unsupported version used to arrive as a compile error inside Hermes.
|
|
119
|
+
HERMES_VERSION="$(node -e '
|
|
120
|
+
const table = require(process.argv[1]);
|
|
121
|
+
const version = process.argv[2];
|
|
122
|
+
if (version === table.development.reactNative) {
|
|
123
|
+
process.stdout.write(table.development.hermes + " " + table.development.hermesTarget);
|
|
124
|
+
} else {
|
|
125
|
+
const minor = version.split(".").slice(0, 2).join(".");
|
|
126
|
+
const entry = table.supported.find(s => s.reactNative === minor);
|
|
127
|
+
if (!entry) {
|
|
128
|
+
const ok = [...table.supported.map(s => s.reactNative + ".x"), table.development.reactNative];
|
|
129
|
+
console.error(`basalt-core does not support React Native ${version}.`);
|
|
130
|
+
console.error(`Supported: ${ok.join(", ")}.`);
|
|
131
|
+
console.error("");
|
|
132
|
+
console.error("packages/basalt-core/supported-versions.json says what is");
|
|
133
|
+
console.error("tested and why the rest is not simply allowed. Adding a version");
|
|
134
|
+
console.error("means building against it and running both suites, not editing");
|
|
135
|
+
console.error("a range.");
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
process.stdout.write(entry.hermes + " " + entry.hermesTarget);
|
|
139
|
+
}
|
|
140
|
+
' "$HERE/../supported-versions.json" "$RN_VERSION")" || exit 1
|
|
141
|
+
HERMES_TARGET="${HERMES_VERSION##* }"
|
|
142
|
+
HERMES_VERSION="${HERMES_VERSION%% *}"
|
|
143
|
+
|
|
144
|
+
# --- ReactCxxPlatform -------------------------------------------------------
|
|
145
|
+
# The one thing React Native does not put in its npm package.
|
|
146
|
+
#
|
|
147
|
+
# `files` in packages/react-native/package.json lists ReactCommon, ReactAndroid
|
|
148
|
+
# and ReactApple but not ReactCxxPlatform, so an installed React Native has
|
|
149
|
+
# everything needed to build a C++ host except the host layer itself. A checkout
|
|
150
|
+
# has it; an app does not.
|
|
151
|
+
#
|
|
152
|
+
# Fetched at the app's *exact* version rather than vendored into this package,
|
|
153
|
+
# because vendoring cannot work: this layer tracks ReactCommon closely, and
|
|
154
|
+
# `main`'s copy fails to compile against 0.87.1 on a missing ResizeObserver
|
|
155
|
+
# header and a ReactInstance method that did not exist yet. One copy cannot
|
|
156
|
+
# serve several React Natives, so the copy has to come from the version in use.
|
|
157
|
+
#
|
|
158
|
+
# A sparse, blobless clone of one directory at one tag: about 3MB and a few
|
|
159
|
+
# seconds, which is the same bargain as the folly and Hermes downloads below.
|
|
160
|
+
if [ "$RN_LAYOUT" = installed ] && [ ! -d "$RN_PKG/ReactCxxPlatform" ]; then
|
|
161
|
+
CXX_PLATFORM="$TP/ReactCxxPlatform"
|
|
162
|
+
|
|
163
|
+
if [ ! -f "$CXX_PLATFORM/.version" ] || \
|
|
164
|
+
[ "$(cat "$CXX_PLATFORM/.version" 2>/dev/null)" != "$RN_VERSION" ]; then
|
|
165
|
+
log "fetching ReactCxxPlatform for React Native $RN_VERSION"
|
|
166
|
+
rm -rf "$CXX_PLATFORM" "$TP/.rn-sparse"
|
|
167
|
+
git clone -q --depth 1 --filter=blob:none --sparse \
|
|
168
|
+
--branch "v$RN_VERSION" https://github.com/facebook/react-native \
|
|
169
|
+
"$TP/.rn-sparse" 2>/dev/null || die "no React Native tag v$RN_VERSION on GitHub.
|
|
170
|
+
ReactCxxPlatform is not in the npm package, so it has to come from the tag
|
|
171
|
+
matching your react-native, and there is no such tag. See
|
|
172
|
+
docs/PORTING.md."
|
|
173
|
+
(cd "$TP/.rn-sparse" && git sparse-checkout set --no-cone \
|
|
174
|
+
packages/react-native/ReactCxxPlatform >/dev/null)
|
|
175
|
+
[ -d "$TP/.rn-sparse/packages/react-native/ReactCxxPlatform" ] \
|
|
176
|
+
|| die "tag v$RN_VERSION has no ReactCxxPlatform"
|
|
177
|
+
mv "$TP/.rn-sparse/packages/react-native/ReactCxxPlatform" "$CXX_PLATFORM"
|
|
178
|
+
rm -rf "$TP/.rn-sparse"
|
|
179
|
+
echo "$RN_VERSION" > "$CXX_PLATFORM/.version"
|
|
180
|
+
fi
|
|
181
|
+
log "ReactCxxPlatform $RN_VERSION at $CXX_PLATFORM"
|
|
182
|
+
fi
|
|
183
|
+
|
|
184
|
+
# --- toolchain --------------------------------------------------------------
|
|
185
|
+
#
|
|
186
|
+
# The compiler differs by name rather than by kind. clang everywhere, because
|
|
187
|
+
# React Native is a clang codebase built -Wall -Werror -Wpedantic and
|
|
188
|
+
# docs/DECISIONS.md declines to paper over its own warnings with -Wno-*; on
|
|
189
|
+
# Windows that same compiler is called clang-cl and takes MSVC's command line.
|
|
190
|
+
# cl is not an alternative for the core build -- it understands neither -Werror
|
|
191
|
+
# nor clang's -Wall, and Static Hermes uses __builtin_expect, which it does not
|
|
192
|
+
# have. See docs/PORTING.md.
|
|
193
|
+
if [ "$HOST_OS" = windows ]; then
|
|
194
|
+
BOOTSTRAP_TOOLS="cmake ninja clang-cl curl tar node"
|
|
195
|
+
else
|
|
196
|
+
BOOTSTRAP_TOOLS="cmake ninja clang++ pkg-config curl tar node"
|
|
197
|
+
fi
|
|
198
|
+
for tool in $BOOTSTRAP_TOOLS; do
|
|
199
|
+
command -v "$tool" >/dev/null || die "missing required tool: $tool"
|
|
200
|
+
done
|
|
201
|
+
|
|
202
|
+
if [ "$HOST_OS" = windows ]; then
|
|
203
|
+
# vcpkg is what Windows has instead of apt or Homebrew.
|
|
204
|
+
#
|
|
205
|
+
# Checked by looking for a header this build cannot do without, not by looking
|
|
206
|
+
# for vcpkg itself, and the difference is not pedantry: **vcvars64.bat sets
|
|
207
|
+
# VCPKG_ROOT** to the copy bundled with Visual Studio, which has nothing
|
|
208
|
+
# installed in it. A check for the directory passes against that one and hands
|
|
209
|
+
# back a toolchain file that finds no packages, which then fails much later
|
|
210
|
+
# inside CMake with a message about glog.
|
|
211
|
+
vcpkg_has_packages() {
|
|
212
|
+
[ -n "$1" ] && [ -f "$1/scripts/buildsystems/vcpkg.cmake" ] &&
|
|
213
|
+
[ -f "$1/installed/x64-windows/include/glog/logging.h" ]
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
for candidate in "${VCPKG_ROOT:-}" "$HOME/Tools/vcpkg" "$HOME/vcpkg" "C:/vcpkg"; do
|
|
217
|
+
if vcpkg_has_packages "$candidate"; then
|
|
218
|
+
VCPKG_ROOT="$candidate"
|
|
219
|
+
break
|
|
220
|
+
fi
|
|
221
|
+
VCPKG_ROOT=""
|
|
222
|
+
done
|
|
223
|
+
|
|
224
|
+
[ -n "$VCPKG_ROOT" ] || die \
|
|
225
|
+
"no vcpkg with this build's packages installed in it.
|
|
226
|
+
|
|
227
|
+
Note that vcvars64.bat sets VCPKG_ROOT to the copy bundled with Visual Studio,
|
|
228
|
+
which is empty -- so having that variable set is not the same as having the
|
|
229
|
+
packages. Set it to one that does, or clone your own:
|
|
230
|
+
|
|
231
|
+
git clone https://github.com/microsoft/vcpkg \$HOME/Tools/vcpkg
|
|
232
|
+
\$HOME/Tools/vcpkg/bootstrap-vcpkg.bat
|
|
233
|
+
|
|
234
|
+
then install what React Native's C++ needs, which on Linux comes from apt:
|
|
235
|
+
|
|
236
|
+
vcpkg install --triplet x64-windows glog fmt double-conversion \\
|
|
237
|
+
boost-regex boost-beast boost-asio boost-thread openssl curl
|
|
238
|
+
|
|
239
|
+
boost-thread is not on React Native's own list and is needed anyway: folly's
|
|
240
|
+
Windows PThread.cpp shim is written over boost::thread."
|
|
241
|
+
export VCPKG_ROOT
|
|
242
|
+
log "vcpkg at $VCPKG_ROOT"
|
|
243
|
+
else
|
|
244
|
+
pkg-config --exists gtk4 || die "gtk4 development files not found (pkg-config gtk4)"
|
|
245
|
+
log "gtk4 $(pkg-config --modversion gtk4), pango $(pkg-config --modversion pango 2>/dev/null || echo '?')"
|
|
246
|
+
fi
|
|
247
|
+
|
|
248
|
+
# mise is optional; without it, the ambient node must satisfy RN's engines.
|
|
249
|
+
if command -v mise >/dev/null; then
|
|
250
|
+
NODE_RUN=(mise exec "node@${NODE_VERSION}" --)
|
|
251
|
+
mise ls node 2>/dev/null | grep -q "^node *${NODE_VERSION}\." || {
|
|
252
|
+
log "installing node@${NODE_VERSION} via mise"
|
|
253
|
+
mise install "node@${NODE_VERSION}"
|
|
254
|
+
}
|
|
255
|
+
else
|
|
256
|
+
# Empty array; expanded below with the ${arr[@]+"${arr[@]}"} idiom because
|
|
257
|
+
# bash < 4.4 (macOS ships 3.2) treats "${arr[@]}" of an empty array as unbound
|
|
258
|
+
# under set -u.
|
|
259
|
+
NODE_RUN=()
|
|
260
|
+
node_major="$(node -p 'process.versions.node.split(".")[0]')"
|
|
261
|
+
case "$node_major" in
|
|
262
|
+
22|24|26|27|28) : ;;
|
|
263
|
+
*) die "node $node_major is outside RN's supported range (^22.13 || ^24.3 || >=26).
|
|
264
|
+
Install mise, or switch node." ;;
|
|
265
|
+
esac
|
|
266
|
+
fi
|
|
267
|
+
|
|
268
|
+
mkdir -p "$TP"
|
|
269
|
+
|
|
270
|
+
# --- vendored headers -------------------------------------------------------
|
|
271
|
+
if [ ! -d "$TP/folly" ]; then
|
|
272
|
+
log "fetching folly $FOLLY_VERSION"
|
|
273
|
+
curl -fsSL "https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz" \
|
|
274
|
+
| tar xz -C "$TP" && mv "$TP/folly-${FOLLY_VERSION}" "$TP/folly"
|
|
275
|
+
fi
|
|
276
|
+
|
|
277
|
+
if [ ! -d "$TP/fast_float" ]; then
|
|
278
|
+
log "fetching fast_float $FAST_FLOAT_VERSION"
|
|
279
|
+
curl -fsSL "https://github.com/fastfloat/fast_float/archive/v${FAST_FLOAT_VERSION}.tar.gz" \
|
|
280
|
+
| tar xz -C "$TP" && mv "$TP/fast_float-${FAST_FLOAT_VERSION}" "$TP/fast_float"
|
|
281
|
+
fi
|
|
282
|
+
|
|
283
|
+
if [ ! -f "$TP/nlohmann_json/include/nlohmann/json.hpp" ]; then
|
|
284
|
+
log "fetching nlohmann_json $NLOHMANN_VERSION"
|
|
285
|
+
mkdir -p "$TP/nlohmann_json/include/nlohmann"
|
|
286
|
+
curl -fsSL -o "$TP/nlohmann_json/include/nlohmann/json.hpp" \
|
|
287
|
+
"https://github.com/nlohmann/json/releases/download/v${NLOHMANN_VERSION}/json.hpp"
|
|
288
|
+
fi
|
|
289
|
+
|
|
290
|
+
# --- Hermes -----------------------------------------------------------------
|
|
291
|
+
# Which Hermes, according to the supported-versions table rather than according
|
|
292
|
+
# to the app.
|
|
293
|
+
#
|
|
294
|
+
# Following the app was tried and abandoned. Hermes is coupled to ReactCommon as
|
|
295
|
+
# tightly as ReactCxxPlatform is, so an old React Native brings an old Hermes,
|
|
296
|
+
# and 0.81's wants a jsi header newer React Native does not ship and names its
|
|
297
|
+
# build target differently. Chasing that leads three compile errors deep into a
|
|
298
|
+
# version nobody claimed to support. The table says what was actually tested,
|
|
299
|
+
# and this refuses anything else rather than half-working.
|
|
300
|
+
log "Hermes $HERMES_VERSION (target $HERMES_TARGET) for React Native $RN_VERSION"
|
|
301
|
+
|
|
302
|
+
# Keyed by version: switching React Native means a different Hermes, and a
|
|
303
|
+
# stale build of the wrong one fails deep in a compile rather than here.
|
|
304
|
+
HERMES_STAMP="$TP/hermes/.version"
|
|
305
|
+
if [ -d "$TP/hermes" ] && [ ! -f "$HERMES_STAMP" ]; then
|
|
306
|
+
# An unstamped tree predates this file. There was exactly one pinned Hermes
|
|
307
|
+
# before it, so an existing tree is that one, and stamping it saves every
|
|
308
|
+
# checkout a 200MB download and a rebuild it does not need. A wrong guess
|
|
309
|
+
# here surfaces immediately as a compile error, not as a silent mismatch.
|
|
310
|
+
log "assuming the existing Hermes is $HERMES_VERSION"
|
|
311
|
+
echo "$HERMES_VERSION" > "$HERMES_STAMP"
|
|
312
|
+
fi
|
|
313
|
+
if [ -d "$TP/hermes" ] && [ "$(cat "$HERMES_STAMP" 2>/dev/null)" != "$HERMES_VERSION" ]; then
|
|
314
|
+
log "Hermes was $(cat "$HERMES_STAMP"), rebuilding for $HERMES_VERSION"
|
|
315
|
+
rm -rf "$TP/hermes" "$TP/hermes-build"
|
|
316
|
+
fi
|
|
317
|
+
|
|
318
|
+
if [ ! -d "$TP/hermes" ]; then
|
|
319
|
+
log "fetching Hermes $HERMES_VERSION (~200MB)"
|
|
320
|
+
mkdir -p "$TP/hermes"
|
|
321
|
+
curl -fsSL "https://github.com/facebook/hermes/tarball/${HERMES_VERSION}" \
|
|
322
|
+
| tar xz -C "$TP/hermes" --strip-components=1
|
|
323
|
+
echo "$HERMES_VERSION" > "$HERMES_STAMP"
|
|
324
|
+
fi
|
|
325
|
+
|
|
326
|
+
# --- the one patch this project applies to anything it downloads -------------
|
|
327
|
+
#
|
|
328
|
+
# Static Hermes asserts that its C++ `Environment` and its C `SHEnvironment`
|
|
329
|
+
# have identical field offsets. `Environment` multiply-inherits from
|
|
330
|
+
# `VariableSizeRuntimeCell` and an *empty* base, `llvh::TrailingObjects`, and
|
|
331
|
+
# the MSVC ABI does not collapse empty bases the way the Itanium ABI does. So
|
|
332
|
+
# sizeof matches, the offsets do not, and the build stops on a static_assert
|
|
333
|
+
# that no flag can affect.
|
|
334
|
+
#
|
|
335
|
+
# Hermes already has the fix and does not use it. `Support/Compiler.h` defines
|
|
336
|
+
#
|
|
337
|
+
# #define HERMES_EMPTY_BASES __declspec(empty_bases)
|
|
338
|
+
#
|
|
339
|
+
# with a comment saying it is "necessary for PointerBase alignment requirements
|
|
340
|
+
# in some cases when using HERMESVM_CONTIGUOUS_HEAP" -- the mode this builds in
|
|
341
|
+
# -- and applies it to nothing in the entire tree. This puts it on the one class
|
|
342
|
+
# that needs it.
|
|
343
|
+
#
|
|
344
|
+
# Patching a download is not something this project does lightly, and it is
|
|
345
|
+
# worth being clear about why this one is tolerable where patching React Native
|
|
346
|
+
# is not: third_party/hermes is a tarball this script fetched, not a checkout
|
|
347
|
+
# anybody works in, and --force deletes and refetches it. The real fix is
|
|
348
|
+
# upstream and the backlog says so.
|
|
349
|
+
if [ "$HOST_OS" = windows ]; then
|
|
350
|
+
HERMES_CALLABLE="$TP/hermes/include/hermes/VM/Callable.h"
|
|
351
|
+
if [ -f "$HERMES_CALLABLE" ] && ! grep -q "HERMES_EMPTY_BASES Environment" "$HERMES_CALLABLE"; then
|
|
352
|
+
log "patching Hermes: HERMES_EMPTY_BASES on VM::Environment (see docs/PORTING.md)"
|
|
353
|
+
# The macro comes from a header Callable.h does not already include.
|
|
354
|
+
grep -q '#include "hermes/Support/Compiler.h"' "$HERMES_CALLABLE" || \
|
|
355
|
+
sed -i '/#include "hermes\/VM\/ArrayStorage.h"/i #include "hermes/Support/Compiler.h"' \
|
|
356
|
+
"$HERMES_CALLABLE"
|
|
357
|
+
sed -i 's|^class Environment final$|class HERMES_EMPTY_BASES Environment final|' \
|
|
358
|
+
"$HERMES_CALLABLE"
|
|
359
|
+
grep -q "HERMES_EMPTY_BASES Environment" "$HERMES_CALLABLE" || die \
|
|
360
|
+
"could not apply the HERMES_EMPTY_BASES patch to $HERMES_CALLABLE.
|
|
361
|
+
Hermes $HERMES_VERSION may have changed that declaration. See
|
|
362
|
+
docs/PORTING.md for what the patch is and why."
|
|
363
|
+
fi
|
|
364
|
+
fi
|
|
365
|
+
|
|
366
|
+
# Whether Hermes is already built, asked in the naming convention of the
|
|
367
|
+
# platform. A static archive on Windows is `hermesvm_a.lib` rather than
|
|
368
|
+
# `libhermesvm.a`, and the `_a` is not decoration: the plain `hermesvm.lib` next
|
|
369
|
+
# to it is a one-kilobyte import library for a DLL that exports nothing, because
|
|
370
|
+
# a Windows DLL exports nothing without __declspec(dllexport) and Hermes does
|
|
371
|
+
# not annotate. See ThirdParty.cmake, which picks the archive for the same
|
|
372
|
+
# reason.
|
|
373
|
+
hermes_is_built() {
|
|
374
|
+
if [ "$HOST_OS" = windows ]; then
|
|
375
|
+
ls "$TP"/hermes-build/lib/"${HERMES_TARGET#lib}"_a.lib >/dev/null 2>&1
|
|
376
|
+
else
|
|
377
|
+
ls "$TP"/hermes-build/lib/lib"${HERMES_TARGET#lib}".* >/dev/null 2>&1 || \
|
|
378
|
+
ls "$TP"/hermes-build/API/hermes/lib"${HERMES_TARGET#lib}".* >/dev/null 2>&1
|
|
379
|
+
fi
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if ! hermes_is_built; then
|
|
383
|
+
log "building Hermes (slow; RN's own host flags)"
|
|
384
|
+
|
|
385
|
+
# Three extra arguments on Windows, each answering something that only goes
|
|
386
|
+
# wrong there. docs/PORTING.md has the detail; briefly:
|
|
387
|
+
#
|
|
388
|
+
# HERMES_ALLOW_BOOST_CONTEXT=0 its vendored boost::context's *Windows*
|
|
389
|
+
# stack allocator throws where the POSIX one
|
|
390
|
+
# does not, and Hermes builds without
|
|
391
|
+
# exceptions. Hermes' own option, the one its
|
|
392
|
+
# ASAN and Emscripten builds use.
|
|
393
|
+
# HERMES_ENABLE_EH / _RTTI React Native's jsi throws, and arrives here
|
|
394
|
+
# through JSI_DIR without passing through the
|
|
395
|
+
# helper that would give it /EHsc. clang with
|
|
396
|
+
# no flag defaults exceptions on; clang-cl
|
|
397
|
+
# defaults them off, which is the whole bug.
|
|
398
|
+
# The two must agree or Hermes refuses.
|
|
399
|
+
# CMAKE_CXX_FLAGS /EHs /EHc rather than /EHsc, because Hermes
|
|
400
|
+
# string-REPLACEs the latter out of this
|
|
401
|
+
# variable. /DWIN32 /D_WINDOWS are CMake's own
|
|
402
|
+
# defaults and have to be repeated, because
|
|
403
|
+
# setting this replaces them -- and Hermes'
|
|
404
|
+
# OSCompat.h reaches for <unistd.h> without
|
|
405
|
+
# _WINDOWS.
|
|
406
|
+
HERMES_ARGS=(-DJSI_DIR="$RN_PKG/ReactCommon/jsi"
|
|
407
|
+
-DCMAKE_BUILD_TYPE=Release
|
|
408
|
+
-DHERMES_ENABLE_DEBUGGER=True
|
|
409
|
+
-DHERMESVM_HEAP_HV_MODE=HEAP_HV_PREFER32)
|
|
410
|
+
if [ "$HOST_OS" = windows ]; then
|
|
411
|
+
HERMES_ARGS+=(-DCMAKE_C_COMPILER=clang-cl
|
|
412
|
+
-DCMAKE_CXX_COMPILER=clang-cl
|
|
413
|
+
-DHERMES_ALLOW_BOOST_CONTEXT=0
|
|
414
|
+
-DHERMES_ENABLE_EH=ON
|
|
415
|
+
-DHERMES_ENABLE_RTTI=ON
|
|
416
|
+
"-DCMAKE_CXX_FLAGS=/DWIN32 /D_WINDOWS /EHs /EHc")
|
|
417
|
+
else
|
|
418
|
+
HERMES_ARGS+=(-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++)
|
|
419
|
+
fi
|
|
420
|
+
|
|
421
|
+
# One argument is excluded from Git Bash's path conversion, and exactly one.
|
|
422
|
+
#
|
|
423
|
+
# `/DWIN32` looks like an absolute POSIX path, so the MSYS runtime rewrites it
|
|
424
|
+
# on its way to a native program and clang-cl is handed
|
|
425
|
+
# `C:/Program Files/Git/DWIN32` -- which it reports as two missing input
|
|
426
|
+
# files, naming something nobody wrote:
|
|
427
|
+
#
|
|
428
|
+
# clang-cl: error: no such file or directory: 'C:/Program'
|
|
429
|
+
# clang-cl: error: no such file or directory: 'Files/Git/DWIN32'
|
|
430
|
+
#
|
|
431
|
+
# Turning conversion off wholesale is the obvious fix and is wrong: `-S` and
|
|
432
|
+
# `-B` below are POSIX paths that a native CMake cannot read, and *they* are
|
|
433
|
+
# only correct because the same conversion rewrites them. So the exclusion
|
|
434
|
+
# names the one prefix that must be left alone.
|
|
435
|
+
#
|
|
436
|
+
# This path had never run. Hermes was built by hand in phase 41 and every
|
|
437
|
+
# bootstrap since has found it already built, which is what docs/BACKLOG.md
|
|
438
|
+
# meant by "nothing has run bootstrap from an empty third_party on Windows".
|
|
439
|
+
if [ "$HOST_OS" = windows ]; then
|
|
440
|
+
MSYS2_ARG_CONV_EXCL='-DCMAKE_CXX_FLAGS=' \
|
|
441
|
+
cmake --log-level=ERROR -G Ninja -S "$TP/hermes" -B "$TP/hermes-build" "${HERMES_ARGS[@]}"
|
|
442
|
+
else
|
|
443
|
+
cmake --log-level=ERROR -G Ninja -S "$TP/hermes" -B "$TP/hermes-build" "${HERMES_ARGS[@]}"
|
|
444
|
+
fi
|
|
445
|
+
# -j is capped deliberately: a full-width build makes laptops unusable and
|
|
446
|
+
# pins the fans for minutes afterwards.
|
|
447
|
+
run_nice cmake --build "$TP/hermes-build" --target "$HERMES_TARGET" -j "${BUILD_JOBS:-12}"
|
|
448
|
+
fi
|
|
449
|
+
|
|
450
|
+
# --- yarn -------------------------------------------------------------------
|
|
451
|
+
# React Native's codegen shells out to `yarn install` itself, so yarn has to be
|
|
452
|
+
# *on PATH*, not merely invocable -- npx is not enough.
|
|
453
|
+
#
|
|
454
|
+
# Installing it globally is not an option either: on Linux npm's global prefix
|
|
455
|
+
# is root-owned (/usr/lib/node_modules) and `npm install -g` fails with EACCES,
|
|
456
|
+
# which a bootstrap script has no business needing sudo to avoid. Homebrew's
|
|
457
|
+
# node has a user-writable prefix, which is why this only bites off macOS.
|
|
458
|
+
#
|
|
459
|
+
# So yarn goes under third_party/ like every other fetched dependency.
|
|
460
|
+
if ! command -v yarn >/dev/null; then
|
|
461
|
+
if [ ! -x "$TP/node/node_modules/.bin/yarn" ]; then
|
|
462
|
+
log "installing yarn under third_party/node"
|
|
463
|
+
mkdir -p "$TP/node"
|
|
464
|
+
${NODE_RUN[@]+"${NODE_RUN[@]}"} npm install --prefix "$TP/node" \
|
|
465
|
+
--silent --no-fund --no-audit yarn@1.22.22
|
|
466
|
+
fi
|
|
467
|
+
export PATH="$TP/node/node_modules/.bin:$PATH"
|
|
468
|
+
fi
|
|
469
|
+
log "yarn $(yarn --version)"
|
|
470
|
+
|
|
471
|
+
# --- React Native codegen ---------------------------------------------------
|
|
472
|
+
# 24 targets need react_codegen_rncore, ReactCxxPlatform's react/runtime among
|
|
473
|
+
# them, so this is mandatory for a host that runs JS.
|
|
474
|
+
# --- React Native's dependencies --------------------------------------------
|
|
475
|
+
# Deliberately not folded into the codegen step below. Codegen needs these, but
|
|
476
|
+
# so does Metro when bundling, and the two are cached separately: a checkout
|
|
477
|
+
# with a populated third_party/codegen and an empty node_modules skips this
|
|
478
|
+
# step and then cannot bundle. That is exactly what CI hit the first time its
|
|
479
|
+
# third_party cache was warm.
|
|
480
|
+
#
|
|
481
|
+
# `node_modules` being populated is not enough to conclude yarn has run here,
|
|
482
|
+
# which is the same bug one layer down and cost a fortnight of red Windows
|
|
483
|
+
# builds. `@react-native/codegen` is a workspace symlink out of node_modules
|
|
484
|
+
# to `packages/react-native-codegen`, and the `lib/` that babel-plugin-codegen
|
|
485
|
+
# requires is built by yarn's own prepare step -- into the package, not into
|
|
486
|
+
# node_modules. So a cache of `node_modules` alone restores a tree that looks
|
|
487
|
+
# installed and cannot bundle: "Cannot find module
|
|
488
|
+
# '@react-native/codegen/lib/parsers/flow/parser'".
|
|
489
|
+
#
|
|
490
|
+
# Checking for that directory as well is what makes a warm cache honest. It
|
|
491
|
+
# showed on Windows and not on Linux only because the Linux job kept being
|
|
492
|
+
# cancelled by a newer push before it got this far; release.yml was green
|
|
493
|
+
# throughout because a cold build restores no cache and always installs.
|
|
494
|
+
RN_CODEGEN_LIB="$RN_DIR/packages/react-native-codegen/lib"
|
|
495
|
+
if [ "$RN_LAYOUT" = checkout ] && { [ ! -d "$RN_DIR/node_modules" ] || [ -z "$(ls -A "$RN_DIR/node_modules" 2>/dev/null)" ]; }; then
|
|
496
|
+
log "installing React Native's monorepo dependencies"
|
|
497
|
+
(cd "$RN_DIR" && run_nice ${NODE_RUN[@]+"${NODE_RUN[@]}"} yarn install --network-timeout 600000)
|
|
498
|
+
fi
|
|
499
|
+
|
|
500
|
+
# And codegen's own JavaScript, which the install above does not build.
|
|
501
|
+
#
|
|
502
|
+
# `packages/react-native-codegen` declares `prepare: yarn run build`, and
|
|
503
|
+
# yarn 1 does not run `prepare` for workspace children -- only for the root
|
|
504
|
+
# package. So a plain `yarn install` leaves `lib/` absent, and
|
|
505
|
+
# babel-plugin-codegen fails the first time Metro touches a file: "Cannot
|
|
506
|
+
# find module '@react-native/codegen/lib/parsers/flow/parser'".
|
|
507
|
+
#
|
|
508
|
+
# Nothing noticed because the two things that build it both happen only on a
|
|
509
|
+
# cold tree. The codegen step below shells out to React Native's own script,
|
|
510
|
+
# which builds it on the way past; with a warm third_party/codegen that step
|
|
511
|
+
# is skipped. So a machine with both caches warm had an installed checkout
|
|
512
|
+
# that could compile and could not bundle -- six red Windows runs, and green
|
|
513
|
+
# release runs throughout, because a release restores no cache at all.
|
|
514
|
+
#
|
|
515
|
+
# Its own check rather than folded into the install: the install is a
|
|
516
|
+
# five-minute network operation and this is a 1.6-second transpile, and the
|
|
517
|
+
# case that matters is precisely the one where the install is not needed.
|
|
518
|
+
if [ "$RN_LAYOUT" = checkout ] && [ ! -d "$RN_CODEGEN_LIB" ]; then
|
|
519
|
+
log "building React Native's codegen"
|
|
520
|
+
(cd "$RN_DIR/packages/react-native-codegen" &&
|
|
521
|
+
run_nice ${NODE_RUN[@]+"${NODE_RUN[@]}"} yarn run build)
|
|
522
|
+
fi
|
|
523
|
+
|
|
524
|
+
# Codegen output belongs to one React Native version and to no other: the
|
|
525
|
+
# generated spec headers name every feature flag that version has, so building
|
|
526
|
+
# 0.87.1 against artifacts generated from `main` fails on the flags `main` added
|
|
527
|
+
# since. The directory is shared rather than per-version, so that
|
|
528
|
+
# third_party/codegen/CMakeLists.txt stays put and CI's cache key still works;
|
|
529
|
+
# a stamp is what makes reuse safe. Switching versions regenerates.
|
|
530
|
+
CODEGEN_STAMP="$TP/codegen/.react-native-version"
|
|
531
|
+
|
|
532
|
+
if [ ! -d "$TP/codegen/react" ] || [ "$(cat "$CODEGEN_STAMP" 2>/dev/null)" != "$RN_VERSION" ]; then
|
|
533
|
+
if [ -d "$TP/codegen/react" ]; then
|
|
534
|
+
log "codegen was generated from $(cat "$CODEGEN_STAMP" 2>/dev/null || echo 'an unknown version'), rebuilding for $RN_VERSION"
|
|
535
|
+
rm -rf "$TP/codegen/react" "$TP"/codegen/*.h "$TP"/codegen/*.cpp
|
|
536
|
+
fi
|
|
537
|
+
log "generating codegen artifacts for React Native $RN_VERSION"
|
|
538
|
+
CODEGEN_TMP="$(mktemp -d)"
|
|
539
|
+
# Failure is judged by what it produced, not by its exit status. React Native
|
|
540
|
+
# 0.81's codegen writes every artifact, prints "Done", and then exits non-zero
|
|
541
|
+
# after failing to stat an output directory it never used, because -f does not
|
|
542
|
+
# exist there and core artifacts went to its own fixed folder instead. The
|
|
543
|
+
# check below is the real one.
|
|
544
|
+
(cd "$RN_PKG" && ${NODE_RUN[@]+"${NODE_RUN[@]}"} node scripts/generate-codegen-artifacts.js \
|
|
545
|
+
-p . -t android -o "$CODEGEN_TMP" -s library -f) || true
|
|
546
|
+
|
|
547
|
+
# Where the output lands depends on the version. 0.87 and main honour -f and
|
|
548
|
+
# write core artifacts to the path given. 0.81 has no such flag: its core
|
|
549
|
+
# libraries have a fixed output folder inside React Native itself, so the
|
|
550
|
+
# artifacts appear under the package's own ReactAndroid/build. That writes
|
|
551
|
+
# generated files into node_modules, which is what React Native does on
|
|
552
|
+
# Android too, and they are regenerable.
|
|
553
|
+
#
|
|
554
|
+
# Detected by looking rather than by version, so a future layout change fails
|
|
555
|
+
# with the message below instead of being mistaken for one of these two.
|
|
556
|
+
JNI="$CODEGEN_TMP/android/app/build/generated/source/codegen/jni"
|
|
557
|
+
if [ ! -d "$JNI/react" ]; then
|
|
558
|
+
JNI="$RN_PKG/ReactAndroid/build/generated/source/codegen/jni"
|
|
559
|
+
fi
|
|
560
|
+
[ -d "$JNI/react" ] || die "codegen produced no react/ tree, in $CODEGEN_TMP or $RN_PKG/ReactAndroid/build"
|
|
561
|
+
mkdir -p "$TP/codegen"
|
|
562
|
+
cp -R "$JNI/react" "$TP/codegen/"
|
|
563
|
+
cp "$JNI"/*.h "$JNI"/*.cpp "$TP/codegen/" 2>/dev/null || true
|
|
564
|
+
rm -rf "$CODEGEN_TMP"
|
|
565
|
+
echo "$RN_VERSION" > "$CODEGEN_STAMP"
|
|
566
|
+
fi
|
|
567
|
+
|
|
568
|
+
# The CMakeLists that builds those artifacts is ours, not codegen's. Codegen
|
|
569
|
+
# writes one too and it links Android-only targets, so it is deliberately not
|
|
570
|
+
# copied out with the rest. Installed every time rather than only alongside a
|
|
571
|
+
# regeneration, so that a third_party directory from an older version of this
|
|
572
|
+
# package still gets the current one.
|
|
573
|
+
cp "$HERE/cmake/codegen/CMakeLists.txt" "$TP/codegen/CMakeLists.txt"
|
|
574
|
+
|
|
575
|
+
log "bootstrap complete, into $TP. Configure with:"
|
|
576
|
+
if [ "$HOST_OS" = windows ]; then
|
|
577
|
+
# CMake here is a native Windows program and this shell is not, so the paths
|
|
578
|
+
# have to change shape on the way out: it does not understand /c/Users/... and
|
|
579
|
+
# silently fails to find the toolchain file, then reports the confusing
|
|
580
|
+
# "unable to find a build program corresponding to Ninja". `cygpath -m` gives
|
|
581
|
+
# C:/Users/... -- drive letter, forward slashes -- which both understand.
|
|
582
|
+
winpath() { command -v cygpath >/dev/null && cygpath -m "$1" || printf '%s' "$1"; }
|
|
583
|
+
|
|
584
|
+
# From a shell that has run vcvars64.bat: the Windows SDK's headers and
|
|
585
|
+
# libraries are not on PATH otherwise, and clang-cl finds neither.
|
|
586
|
+
cat <<EOF
|
|
587
|
+
|
|
588
|
+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo \\
|
|
589
|
+
-DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl \\
|
|
590
|
+
-DCMAKE_TOOLCHAIN_FILE=$(winpath "$VCPKG_ROOT")/scripts/buildsystems/vcpkg.cmake \\
|
|
591
|
+
-DRN_DIR=$(winpath "$RN_PKG")
|
|
592
|
+
cmake --build build -j \${BUILD_JOBS:-12}
|
|
593
|
+
|
|
594
|
+
Run it from a shell that has run vcvars64.bat, or clang-cl will not find the
|
|
595
|
+
Windows SDK. clang-cl rather than cl: see docs/PORTING.md.
|
|
596
|
+
|
|
597
|
+
CMAKE_BUILD_TYPE is not optional here, unlike on the other two desktops. Left
|
|
598
|
+
unset, MSVC picks the debug C runtime -- and vcpkg follows it to the debug
|
|
599
|
+
packages -- while Hermes above was built Release. The two cannot be linked
|
|
600
|
+
together: the failure is lld-link reporting a mismatch on _ITERATOR_DEBUG_LEVEL,
|
|
601
|
+
which names neither the build type nor the library that disagrees.
|
|
602
|
+
|
|
603
|
+
EOF
|
|
604
|
+
else
|
|
605
|
+
cat <<EOF
|
|
606
|
+
|
|
607
|
+
cmake -B build -G Ninja \\
|
|
608
|
+
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \\
|
|
609
|
+
-DRN_DIR=$RN_PKG
|
|
610
|
+
nice -n 10 cmake --build build -j \${BUILD_JOBS:-12}
|
|
611
|
+
|
|
612
|
+
EOF
|
|
613
|
+
fi
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# The same intentions, spelled for two compiler front ends.
|
|
2
|
+
#
|
|
3
|
+
# Everything in this build was written for clang's command line, because until
|
|
4
|
+
# Windows there were only clang targets: `docs/DECISIONS.md` records why the
|
|
5
|
+
# project is a clang codebase rather than a GCC one, and both desktops it had
|
|
6
|
+
# were clang. MSVC's front end takes none of those spellings, and clang-cl takes
|
|
7
|
+
# MSVC's rather than clang's -- it is the same compiler behind a different
|
|
8
|
+
# command line, which is exactly the trap: `-frtti` on clang-cl is silently
|
|
9
|
+
# interpreted as an input filename, not as a request for RTTI.
|
|
10
|
+
#
|
|
11
|
+
# So each flag this build actually depends on is named here once, and the two
|
|
12
|
+
# spellings sit side by side where a reader can check they mean the same thing.
|
|
13
|
+
# The alternative -- `if(MSVC)` scattered through ThirdParty.cmake and
|
|
14
|
+
# ReactNativeCore.cmake -- would put the two halves of each decision in
|
|
15
|
+
# different files.
|
|
16
|
+
#
|
|
17
|
+
# Note the guard is `MSVC`, not the compiler id: CMake sets MSVC for clang-cl
|
|
18
|
+
# too, which is what we want, because the command line is what differs.
|
|
19
|
+
|
|
20
|
+
if(MSVC)
|
|
21
|
+
# /EHsc: C++ exceptions, and extern "C" assumed not to throw. React Native
|
|
22
|
+
# and folly both throw across their own boundaries, so this is not optional.
|
|
23
|
+
set(BASALT_EXCEPTIONS_FLAG /EHsc)
|
|
24
|
+
# /GR is MSVC's default, stated anyway because folly's is not a default it
|
|
25
|
+
# can afford to have changed underneath it -- folly::dynamic is built on
|
|
26
|
+
# dynamic_cast.
|
|
27
|
+
set(BASALT_RTTI_FLAG /GR)
|
|
28
|
+
set(BASALT_FRAME_POINTER_FLAG /Oy-)
|
|
29
|
+
# C4018 and C4389 are the signed/unsigned comparison warnings folly's own
|
|
30
|
+
# build turns off with -Wno-sign-compare.
|
|
31
|
+
set(BASALT_NO_SIGN_COMPARE_FLAG /wd4018 /wd4389)
|
|
32
|
+
# C4068 is "unknown pragma", which is `#pragma mark` in React Native's Apple
|
|
33
|
+
# heritage.
|
|
34
|
+
set(BASALT_NO_UNKNOWN_PRAGMAS_FLAG /wd4068)
|
|
35
|
+
# /FI is MSVC's -include, and clang-cl takes it too. See the upstream
|
|
36
|
+
# portability bug in ReactNativeCore.cmake for why this is force-included.
|
|
37
|
+
set(BASALT_FORCE_INCLUDE_CSTDINT_FLAG /FIcstdint)
|
|
38
|
+
# C4996: the CRT's "this function is unsafe" campaign, which fires on most of
|
|
39
|
+
# POSIX. React Native and folly are not going to stop calling strncpy.
|
|
40
|
+
set(BASALT_NO_DEPRECATED_FLAG /wd4996)
|
|
41
|
+
else()
|
|
42
|
+
set(BASALT_EXCEPTIONS_FLAG -fexceptions)
|
|
43
|
+
set(BASALT_RTTI_FLAG -frtti)
|
|
44
|
+
set(BASALT_FRAME_POINTER_FLAG -fno-omit-frame-pointer)
|
|
45
|
+
set(BASALT_NO_SIGN_COMPARE_FLAG -Wno-sign-compare)
|
|
46
|
+
set(BASALT_NO_UNKNOWN_PRAGMAS_FLAG -Wno-unknown-pragmas)
|
|
47
|
+
set(BASALT_FORCE_INCLUDE_CSTDINT_FLAG -include cstdint)
|
|
48
|
+
set(BASALT_NO_DEPRECATED_FLAG -Wno-deprecated-declarations)
|
|
49
|
+
endif()
|