@ng-native/desktop 0.25.0 → 0.26.0
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/native/CMakeLists.txt +47 -4
- package/native/appkit/CMakeLists.txt +2 -1
- package/native/appkit/cg-canvas.h +5 -0
- package/native/appkit/cg-canvas.mm +21 -6
- package/native/appkit/desktop-expo.h +6 -0
- package/native/appkit/desktop-expo.mm +5 -0
- package/native/appkit/host-view.mm +32 -0
- package/native/appkit/image-request.h +2 -10
- package/native/appkit/image-request.mm +0 -22
- package/native/appkit/image-view.mm +94 -6
- package/native/appkit/main.mm +130 -185
- package/native/appkit/split-view.mm +3 -9
- package/native/appkit/system-access.mm +3 -0
- package/native/appkit/system.mm +33 -48
- package/native/appkit/view-effects.h +27 -0
- package/native/appkit/view-effects.mm +90 -0
- package/native/cmake/runtime-dependencies.cmake +11 -1
- package/native/core/include/ngn/app-info.h +3 -2
- package/native/core/include/ngn/app-menus.h +5 -11
- package/native/core/include/ngn/default-menu.h +16 -6
- package/native/core/include/ngn/desktop-expo.h +0 -5
- package/native/core/include/ngn/desktop-modules.h +144 -0
- package/native/core/include/ngn/dev-server.h +12 -3
- package/native/core/include/ngn/host-os.h +45 -0
- package/native/core/include/ngn/host-views.h +25 -0
- package/native/core/include/ngn/image-source.h +18 -0
- package/native/core/include/ngn/launch-settings.h +9 -7
- package/native/core/include/ngn/module-registry.h +2 -0
- package/native/core/include/ngn/notifications.h +6 -0
- package/native/core/include/ngn/runtime.h +4 -1
- package/native/core/include/ngn/spawn-rules.h +3 -2
- package/native/core/include/ngn/split-view.h +12 -0
- package/native/core/include/ngn/system.h +47 -0
- package/native/core/include/ngn/undo.h +27 -0
- package/native/core/include/ngn/updates.h +3 -2
- package/native/core/include/ngn/view-filter.h +33 -0
- package/native/core/src/app-menus.cpp +9 -11
- package/native/core/src/default-menu.cpp +6 -2
- package/native/core/src/dev-server-helper.cpp +3 -2
- package/native/core/src/dev-server.cpp +22 -5
- package/native/core/src/host-os.cpp +20 -0
- package/native/core/src/host-views.cpp +25 -0
- package/native/core/src/image-source.cpp +30 -0
- package/native/core/src/launch-settings.cpp +10 -6
- package/native/core/src/module-registry.cpp +9 -0
- package/native/core/src/modules/app-info.cpp +4 -4
- package/native/core/src/modules/desktop-expo.cpp +0 -5
- package/native/core/src/modules/desktop-modules.cpp +132 -0
- package/native/core/src/modules/notifications.cpp +4 -4
- package/native/core/src/runtime.cpp +2 -0
- package/native/core/src/spawn-rules.cpp +1 -4
- package/native/core/src/split-view.cpp +10 -0
- package/native/core/src/system.cpp +52 -0
- package/native/core/src/undo-stacks.cpp +71 -0
- package/native/core/src/view-filter.cpp +114 -0
- package/native/scripts/build-hermes.sh +19 -7
- package/native/scripts/build-icu.sh +36 -0
- package/native/scripts/build-lock.sh +21 -0
- package/native/scripts/build.sh +40 -7
- package/native/scripts/fetch.sh +24 -2
- package/native/scripts/hermes-built.sh +5 -4
- package/native/scripts/hermes-target.sh +18 -0
- package/native/scripts/icu-filter.json +22 -0
- package/native/shim/openssl/sha.h +108 -3
- package/package.json +2 -2
- package/prebuilt.json +6 -6
|
@@ -6,9 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
namespace ngn {
|
|
8
8
|
|
|
9
|
-
const std::vector<std::string> kSearchPath{
|
|
10
|
-
"/usr/bin", "/bin", "/usr/sbin", "/sbin", "/opt/homebrew/bin", "/usr/local/bin"};
|
|
11
|
-
|
|
12
9
|
namespace {
|
|
13
10
|
|
|
14
11
|
const std::set<std::string> kRefusedPrograms{
|
|
@@ -260,7 +257,7 @@ std::optional<std::string> resolveProgram(const std::string &program, const Prog
|
|
|
260
257
|
if (program[0] == '/') {
|
|
261
258
|
candidates.push_back(program);
|
|
262
259
|
} else {
|
|
263
|
-
for (const auto &dir :
|
|
260
|
+
for (const auto &dir : lookup.searchPath) {
|
|
264
261
|
candidates.push_back(dir + "/" + program);
|
|
265
262
|
}
|
|
266
263
|
}
|
|
@@ -25,6 +25,16 @@ SplitPaneProps::SplitPaneProps(const PropsParserContext &context, const SplitPan
|
|
|
25
25
|
paneMaxWidth(convertRawProp(context, rawProps, "paneMaxWidth", sourceProps.paneMaxWidth, Float{0})),
|
|
26
26
|
autosaveName(convertRawProp(context, rawProps, "autosaveName", sourceProps.autosaveName, std::string{})) {}
|
|
27
27
|
|
|
28
|
+
SidebarWidths sidebarWidths(const SplitPaneProps *props) {
|
|
29
|
+
constexpr Float minimum = 150;
|
|
30
|
+
constexpr Float maximum = 400;
|
|
31
|
+
SidebarWidths widths;
|
|
32
|
+
widths.minimum = props && props->paneMinWidth > 0 ? props->paneMinWidth : minimum;
|
|
33
|
+
widths.maximum = std::max(widths.minimum, props && props->paneMaxWidth > 0 ? props->paneMaxWidth : maximum);
|
|
34
|
+
widths.starting = std::min(std::max(kSidebarDefaultWidth, widths.minimum), widths.maximum);
|
|
35
|
+
return widths;
|
|
36
|
+
}
|
|
37
|
+
|
|
28
38
|
SidebarSectionProps::SidebarSectionProps(
|
|
29
39
|
const PropsParserContext &context,
|
|
30
40
|
const SidebarSectionProps &sourceProps,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#include "ngn/system.h"
|
|
2
|
+
|
|
3
|
+
#include <folly/json.h>
|
|
4
|
+
|
|
5
|
+
namespace ngn {
|
|
6
|
+
|
|
7
|
+
ColorSchemeOverride::ColorSchemeOverride(std::string systemScheme) : system_(std::move(systemScheme)) {}
|
|
8
|
+
|
|
9
|
+
std::string ColorSchemeOverride::current() const {
|
|
10
|
+
std::lock_guard lock(mutex_);
|
|
11
|
+
return override_.value_or(system_);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void ColorSchemeOverride::set(std::optional<std::string> scheme) {
|
|
15
|
+
std::lock_guard lock(mutex_);
|
|
16
|
+
override_ = std::move(scheme);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
void ColorSchemeOverride::systemChanged(std::string scheme) {
|
|
20
|
+
std::lock_guard lock(mutex_);
|
|
21
|
+
system_ = std::move(scheme);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
std::string ColorSchemeOverride::applied(const std::optional<std::string> &scheme) const {
|
|
25
|
+
std::lock_guard lock(mutex_);
|
|
26
|
+
return scheme.value_or(system_);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
JsonPreferences::JsonPreferences(std::shared_ptr<StringStore> store, const std::string &appId, bool sharedStore)
|
|
30
|
+
: store_(std::move(store)), prefix_(sharedStore ? appId + "." : std::string{}) {}
|
|
31
|
+
|
|
32
|
+
std::optional<folly::dynamic> JsonPreferences::get(const std::string &key) const {
|
|
33
|
+
auto json = store_->get(prefix_ + key);
|
|
34
|
+
if (!json) {
|
|
35
|
+
return std::nullopt;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
return folly::parseJson(*json);
|
|
39
|
+
} catch (...) {
|
|
40
|
+
return std::nullopt;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void JsonPreferences::set(const std::string &key, const std::optional<folly::dynamic> &value) const {
|
|
45
|
+
if (value) {
|
|
46
|
+
store_->set(prefix_ + key, folly::toJson(*value));
|
|
47
|
+
} else {
|
|
48
|
+
store_->remove(prefix_ + key);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
} // namespace ngn
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#include "ngn/undo.h"
|
|
2
|
+
|
|
3
|
+
namespace ngn {
|
|
4
|
+
|
|
5
|
+
namespace {
|
|
6
|
+
|
|
7
|
+
// Sets a flag for one action's run and puts back its earlier value however the run ends, so an
|
|
8
|
+
// action that throws does not leave later registrations going to the wrong stack, and an undo run
|
|
9
|
+
// inside another undo's action leaves the outer one still undoing.
|
|
10
|
+
struct Running {
|
|
11
|
+
bool &flag;
|
|
12
|
+
bool before;
|
|
13
|
+
explicit Running(bool &flag) : flag(flag), before(flag) {
|
|
14
|
+
flag = true;
|
|
15
|
+
}
|
|
16
|
+
~Running() {
|
|
17
|
+
flag = before;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
} // namespace
|
|
22
|
+
|
|
23
|
+
void UndoStacks::registerAction(const std::string &label, std::function<void()> action) {
|
|
24
|
+
if (undoing_) {
|
|
25
|
+
redos_.push_back({label, std::move(action)});
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
undos_.push_back({label, std::move(action)});
|
|
29
|
+
if (!redoing_) {
|
|
30
|
+
redos_.clear();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
bool UndoStacks::undoing() const {
|
|
35
|
+
return undoing_;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
void UndoStacks::undo() {
|
|
39
|
+
if (undos_.empty()) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
auto action = std::move(undos_.back());
|
|
43
|
+
undos_.pop_back();
|
|
44
|
+
Running running(undoing_);
|
|
45
|
+
action.run();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
void UndoStacks::redo() {
|
|
49
|
+
if (redos_.empty()) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
auto action = std::move(redos_.back());
|
|
53
|
+
redos_.pop_back();
|
|
54
|
+
Running running(redoing_);
|
|
55
|
+
action.run();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void UndoStacks::clear() {
|
|
59
|
+
undos_.clear();
|
|
60
|
+
redos_.clear();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
std::optional<std::string> UndoStacks::undoLabel() const {
|
|
64
|
+
return undos_.empty() ? std::nullopt : std::optional(undos_.back().label);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
std::optional<std::string> UndoStacks::redoLabel() const {
|
|
68
|
+
return redos_.empty() ? std::nullopt : std::optional(redos_.back().label);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
} // namespace ngn
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#include "ngn/view-filter.h"
|
|
2
|
+
|
|
3
|
+
#include "ngn/svg.h"
|
|
4
|
+
|
|
5
|
+
#include <react/renderer/graphics/Color.h>
|
|
6
|
+
|
|
7
|
+
#include <algorithm>
|
|
8
|
+
#include <cmath>
|
|
9
|
+
#include <optional>
|
|
10
|
+
#include <variant>
|
|
11
|
+
|
|
12
|
+
using namespace facebook::react;
|
|
13
|
+
|
|
14
|
+
namespace ngn {
|
|
15
|
+
|
|
16
|
+
namespace {
|
|
17
|
+
|
|
18
|
+
using Matrix = std::array<double, 20>;
|
|
19
|
+
|
|
20
|
+
constexpr Matrix kIdentity{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0};
|
|
21
|
+
|
|
22
|
+
// Each colour channel times `slope` plus `intercept`: feComponentTransfer's linear function.
|
|
23
|
+
Matrix linear(double slope, double intercept) {
|
|
24
|
+
return {slope, 0, 0, 0, intercept, 0, slope, 0, 0, intercept, 0, 0, slope, 0, intercept, 0, 0, 0, 1, 0};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// The Filter Effects spec's grayscale and sepia matrices, at `amount` from 0 to 1.
|
|
28
|
+
Matrix grayscale(double amount) {
|
|
29
|
+
double s = 1 - amount;
|
|
30
|
+
return {0.2126 + 0.7874 * s, 0.7152 - 0.7152 * s, 0.0722 - 0.0722 * s, 0, 0,
|
|
31
|
+
0.2126 - 0.2126 * s, 0.7152 + 0.2848 * s, 0.0722 - 0.0722 * s, 0, 0,
|
|
32
|
+
0.2126 - 0.2126 * s, 0.7152 - 0.7152 * s, 0.0722 + 0.9278 * s, 0, 0,
|
|
33
|
+
0, 0, 0, 1, 0};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Matrix sepia(double amount) {
|
|
37
|
+
double s = 1 - amount;
|
|
38
|
+
return {0.393 + 0.607 * s, 0.769 - 0.769 * s, 0.189 - 0.189 * s, 0, 0,
|
|
39
|
+
0.349 - 0.349 * s, 0.686 + 0.314 * s, 0.168 - 0.168 * s, 0, 0,
|
|
40
|
+
0.272 - 0.272 * s, 0.534 - 0.534 * s, 0.131 + 0.869 * s, 0, 0,
|
|
41
|
+
0, 0, 0, 1, 0};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
std::optional<Matrix> colorMatrix(FilterType type, double value) {
|
|
45
|
+
double unit = std::clamp(value, 0.0, 1.0);
|
|
46
|
+
switch (type) {
|
|
47
|
+
case FilterType::Brightness:
|
|
48
|
+
return linear(value, 0);
|
|
49
|
+
case FilterType::Contrast:
|
|
50
|
+
return linear(value, 0.5 - 0.5 * value);
|
|
51
|
+
case FilterType::Grayscale:
|
|
52
|
+
return grayscale(unit);
|
|
53
|
+
case FilterType::Sepia:
|
|
54
|
+
return sepia(unit);
|
|
55
|
+
case FilterType::Invert:
|
|
56
|
+
return linear(1 - 2 * unit, unit);
|
|
57
|
+
case FilterType::Saturate:
|
|
58
|
+
return svgColorMatrix(1, {value});
|
|
59
|
+
case FilterType::HueRotate:
|
|
60
|
+
return svgColorMatrix(2, {value});
|
|
61
|
+
case FilterType::Opacity: {
|
|
62
|
+
Matrix m = kIdentity;
|
|
63
|
+
m[18] = unit;
|
|
64
|
+
return m;
|
|
65
|
+
}
|
|
66
|
+
default:
|
|
67
|
+
return std::nullopt;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
} // namespace
|
|
72
|
+
|
|
73
|
+
std::vector<FilterStep> filterSteps(const std::vector<FilterFunction> &filter) {
|
|
74
|
+
std::vector<FilterStep> steps;
|
|
75
|
+
for (const auto &function : filter) {
|
|
76
|
+
if (function.type == FilterType::DropShadow) {
|
|
77
|
+
const auto *shadow = std::get_if<DropShadowParams>(&function.parameters);
|
|
78
|
+
if (!shadow) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
FilterStep step{.type = FilterStep::Type::DropShadow};
|
|
82
|
+
step.offsetX = shadow->offsetX;
|
|
83
|
+
step.offsetY = shadow->offsetY;
|
|
84
|
+
step.standardDeviation = std::max<double>(0, shadow->standardDeviation);
|
|
85
|
+
if (shadow->color) {
|
|
86
|
+
auto c = colorComponentsFromColor(shadow->color);
|
|
87
|
+
auto byte = [](float v) { return static_cast<uint32_t>(std::clamp(v, 0.0f, 1.0f) * 255 + 0.5f); };
|
|
88
|
+
step.argb = byte(c.alpha) << 24 | byte(c.red) << 16 | byte(c.green) << 8 | byte(c.blue);
|
|
89
|
+
}
|
|
90
|
+
steps.push_back(step);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const auto *value = std::get_if<Float>(&function.parameters);
|
|
94
|
+
if (!value) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (function.type == FilterType::Blur) {
|
|
98
|
+
if (*value > 0) {
|
|
99
|
+
steps.push_back({.type = FilterStep::Type::Blur, .standardDeviation = *value});
|
|
100
|
+
}
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
auto matrix = colorMatrix(function.type, *value);
|
|
104
|
+
bool identity = matrix && std::equal(matrix->begin(), matrix->end(), kIdentity.begin(), [](double a, double b) {
|
|
105
|
+
return std::abs(a - b) < 1e-9;
|
|
106
|
+
});
|
|
107
|
+
if (matrix && !identity) {
|
|
108
|
+
steps.push_back({.type = FilterStep::Type::ColorMatrix, .matrix = *matrix});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return steps;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
} // namespace ngn
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
#
|
|
5
5
|
# build-hermes.sh <node_modules/react-native> [architectures, default: this Mac's]
|
|
6
6
|
#
|
|
7
|
-
# Release, debugger on, Intl on (as React Native's Apple builds are),
|
|
7
|
+
# Release, debugger on, HV32 heap. Intl on macOS (as React Native's Apple builds are), over
|
|
8
|
+
# Foundation; elsewhere Intl is off, and the Unicode layer links the static ICU build-icu.sh builds
|
|
9
|
+
# into <out>/icu, which cmake/runtime-dependencies.cmake links the host against. The flags follow
|
|
8
10
|
# Basalt's bootstrap.sh (Basalt 0.2.9, MIT, Copyright (c) 2026 Vince Vella), which mirrors React
|
|
9
11
|
# Native's own host build. jsi is not in the archive: the host compiles React Native's copy once.
|
|
10
12
|
set -euo pipefail
|
|
@@ -15,12 +17,21 @@ RN_VERSION="$(node -p 'require(process.argv[1] + "/package.json").version' "$RN_
|
|
|
15
17
|
CACHE="$("$here/cache-dir.sh" "$RN_VERSION")"
|
|
16
18
|
JOBS="${NGN_JOBS:-8}"
|
|
17
19
|
OUT="$CACHE/hermes-${ARCHS//;/-}"
|
|
18
|
-
|
|
20
|
+
MACOS_TARGET="$("$here/macos-target.sh")"
|
|
21
|
+
TARGET="$("$here/hermes-target.sh")"
|
|
19
22
|
|
|
20
23
|
[ -d "$CACHE/src/hermes" ] || { echo "build-hermes.sh: run fetch.sh first" >&2; exit 1; }
|
|
24
|
+
# Unfinished until the stamp is written again at the end.
|
|
25
|
+
rm -f "$OUT/target"
|
|
21
26
|
|
|
22
27
|
intl=OFF
|
|
23
|
-
|
|
28
|
+
icu_args=()
|
|
29
|
+
if [ "$(uname -s)" = "Darwin" ]; then
|
|
30
|
+
intl=ON
|
|
31
|
+
else
|
|
32
|
+
"$here/build-icu.sh" "$CACHE" "$OUT/icu"
|
|
33
|
+
icu_args=(-DHERMES_USE_STATIC_ICU=ON -DICU_ROOT="$OUT/icu")
|
|
34
|
+
fi
|
|
24
35
|
launcher_args=()
|
|
25
36
|
while IFS= read -r arg; do
|
|
26
37
|
launcher_args+=("$arg")
|
|
@@ -29,16 +40,17 @@ cmake --log-level=ERROR -G Ninja -S "$CACHE/src/hermes" -B "$OUT" \
|
|
|
29
40
|
-DJSI_DIR="$RN_PKG/ReactCommon/jsi" \
|
|
30
41
|
-DCMAKE_BUILD_TYPE=Release \
|
|
31
42
|
-DCMAKE_OSX_ARCHITECTURES="$ARCHS" \
|
|
32
|
-
-DCMAKE_OSX_DEPLOYMENT_TARGET="$
|
|
43
|
+
-DCMAKE_OSX_DEPLOYMENT_TARGET="$MACOS_TARGET" \
|
|
33
44
|
-DHERMES_ENABLE_DEBUGGER=ON \
|
|
34
45
|
-DHERMES_ENABLE_INTL="$intl" \
|
|
35
46
|
-DHERMESVM_HEAP_HV_MODE=HEAP_HV_PREFER32 \
|
|
36
47
|
-DHERMES_ENABLE_TEST_SUITE=OFF \
|
|
37
48
|
-DHERMES_BUILD_APPLE_FRAMEWORK=OFF \
|
|
38
49
|
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
|
|
39
|
-
${launcher_args[@]+"${launcher_args[@]}"}
|
|
50
|
+
${launcher_args[@]+"${launcher_args[@]}"} \
|
|
51
|
+
${icu_args[@]+"${icu_args[@]}"}
|
|
40
52
|
# hermesc too, which compiles a packaged app's bundle to this Hermes's bytecode.
|
|
41
53
|
nice -n 10 cmake --build "$OUT" --target hermesvm_a hermesc -j "$JOBS"
|
|
42
|
-
# What hermes-built.sh checks:
|
|
43
|
-
echo "$TARGET" > "$OUT/
|
|
54
|
+
# What hermes-built.sh checks: what this build is for (hermes-target.sh).
|
|
55
|
+
echo "$TARGET" > "$OUT/target"
|
|
44
56
|
echo "$OUT"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Builds the ICU fetch.sh pinned as static archives with their data linked in, for Hermes off
|
|
3
|
+
# macOS: its Unicode layer (case mapping, normalize, localeCompare, dates' toLocaleString) needs ICU
|
|
4
|
+
# even with Intl off, and a static copy ties the host to no distribution's ICU.
|
|
5
|
+
#
|
|
6
|
+
# build-icu.sh <cache> <out-prefix>
|
|
7
|
+
#
|
|
8
|
+
# The data is built from its sources through icu-filter.json: English only, without the conversion
|
|
9
|
+
# tables, transliteration, break iterators and display-name trees Hermes never reads.
|
|
10
|
+
set -euo pipefail
|
|
11
|
+
here="$(cd "$(dirname "$0")" && pwd)"
|
|
12
|
+
CACHE="${1:?usage: build-icu.sh <cache> <out-prefix>}"
|
|
13
|
+
OUT="${2:?usage: build-icu.sh <cache> <out-prefix>}"
|
|
14
|
+
JOBS="${NGN_JOBS:-8}"
|
|
15
|
+
# Absolute, since the build runs from its work directory.
|
|
16
|
+
case "$CACHE" in /*) ;; *) CACHE="$PWD/$CACHE" ;; esac
|
|
17
|
+
case "$OUT" in /*) ;; *) OUT="$PWD/$OUT" ;; esac
|
|
18
|
+
[ -x "$CACHE/src/icu/source/configure" ] || { echo "build-icu.sh: run fetch.sh first" >&2; exit 1; }
|
|
19
|
+
|
|
20
|
+
work="$OUT.build"
|
|
21
|
+
rm -rf "$work" "$OUT"
|
|
22
|
+
mkdir -p "$work"
|
|
23
|
+
cd "$work"
|
|
24
|
+
# Read when configure lays out the data build.
|
|
25
|
+
export ICU_DATA_FILTER_FILE="$here/icu-filter.json"
|
|
26
|
+
CC=clang CXX=clang++ CFLAGS="-O2 -fPIC" CXXFLAGS="-O2 -fPIC -std=c++17" \
|
|
27
|
+
"$CACHE/src/icu/source/configure" --prefix="$OUT" --enable-static --disable-shared \
|
|
28
|
+
--with-data-packaging=static --disable-tests --disable-samples --disable-extras \
|
|
29
|
+
--disable-icuio --disable-layoutex > configure.log 2>&1 || { tail -40 configure.log >&2; exit 1; }
|
|
30
|
+
nice -n 10 make -j "$JOBS" > make.log 2>&1 || { tail -40 make.log >&2; exit 1; }
|
|
31
|
+
make install > install.log 2>&1 || { tail -40 install.log >&2; exit 1; }
|
|
32
|
+
for lib in icuuc icui18n icudata; do
|
|
33
|
+
[ -f "$OUT/lib/lib$lib.a" ] || { echo "build-icu.sh: no lib$lib.a in $OUT/lib" >&2; exit 1; }
|
|
34
|
+
done
|
|
35
|
+
cd /
|
|
36
|
+
rm -rf "$work"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# shellcheck shell=bash
|
|
2
|
+
# Sourced by build.sh: one build at a time in a build directory.
|
|
3
|
+
#
|
|
4
|
+
# lock_build <build dir>
|
|
5
|
+
#
|
|
6
|
+
# Two ninja processes in one build directory both append to its .ninja_deps, and the next build
|
|
7
|
+
# finds the log corrupt ("premature end of file; recovering"), drops every record after the
|
|
8
|
+
# clash and compiles those objects again: a run beside another, or beside one a killed command
|
|
9
|
+
# left running, recompiles hundreds of objects on the run after it. The lock is the kernel's flock
|
|
10
|
+
# on <build dir>/.ngn-build-lock, held through the calling shell's descriptor 7 (Perl takes it,
|
|
11
|
+
# since macOS has no flock command) until that shell exits, and by the cmake and ninja it starts,
|
|
12
|
+
# which inherit the descriptor, so a build whose script was killed still holds it until ninja
|
|
13
|
+
# stops. A second build waits for it, then finds nothing left to do.
|
|
14
|
+
lock_build() {
|
|
15
|
+
mkdir -p "$1"
|
|
16
|
+
exec 7>> "$1/.ngn-build-lock"
|
|
17
|
+
if ! perl -MFcntl=:flock -e 'open(my $fd, ">&=", 7) or die "build.sh: $!\n"; exit(flock($fd, LOCK_EX | LOCK_NB) ? 0 : 1)'; then
|
|
18
|
+
echo "build.sh: waiting for another build in $1" >&2
|
|
19
|
+
perl -MFcntl=:flock -e 'open(my $fd, ">&=", 7) or die "build.sh: $!\n"; flock($fd, LOCK_EX) or die "build.sh: $!\n"'
|
|
20
|
+
fi
|
|
21
|
+
}
|
package/native/scripts/build.sh
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
# Builds the desktop host (or only the core and its tests) in the per-user cache, fetching the
|
|
3
3
|
# pinned sources and building Hermes first when they are missing. Prints the build directory.
|
|
4
4
|
#
|
|
5
|
-
# build.sh [node_modules/react-native] [--backend appkit|none] [--
|
|
6
|
-
# [--test | --no-tests] [--no-debug-info]
|
|
7
|
-
# [--build-dir <dir>]
|
|
5
|
+
# build.sh [node_modules/react-native] [--backend appkit|none] [--runtime] [--universal]
|
|
6
|
+
# [--debug|--release] [--test | --no-tests] [--no-debug-info]
|
|
7
|
+
# [--library <node_modules/library>]... [--build-dir <dir>]
|
|
8
8
|
#
|
|
9
9
|
# Without a path, react-native is resolved from the current directory.
|
|
10
10
|
#
|
|
11
11
|
# --backend none the toolkit-free core and its tests only: any OS, no Hermes
|
|
12
|
+
# --runtime with --backend none, the core's runtime half too: Hermes, ReactHost and the
|
|
13
|
+
# runtime tests, still with no toolkit (what Linux builds until it has a backend)
|
|
12
14
|
# --universal arm64 and x86_64 in one binary (default: this machine's architecture)
|
|
13
15
|
# --debug a Debug build (default: RelWithDebInfo)
|
|
14
16
|
# --release a Release build without the core tests, as a packaged app ships it
|
|
@@ -49,12 +51,14 @@ config=RelWithDebInfo
|
|
|
49
51
|
run_tests=0
|
|
50
52
|
tests=ON
|
|
51
53
|
no_tests=0
|
|
54
|
+
runtime=0
|
|
52
55
|
libraries=()
|
|
53
56
|
build_dir=""
|
|
54
57
|
debug_info=1
|
|
55
58
|
while [ $# -gt 0 ]; do
|
|
56
59
|
case "$1" in
|
|
57
60
|
--backend) backend="$2"; shift ;;
|
|
61
|
+
--runtime) runtime=1 ;;
|
|
58
62
|
--universal) archs="arm64;x86_64" ;;
|
|
59
63
|
--debug) config=Debug ;;
|
|
60
64
|
--release) config=Release; tests=OFF ;;
|
|
@@ -72,6 +76,8 @@ if [ "$run_tests" = 1 ] && [ "$tests" = OFF ]; then
|
|
|
72
76
|
echo "build.sh: --test needs the core tests, which $left_out leaves out" >&2
|
|
73
77
|
exit 2
|
|
74
78
|
fi
|
|
79
|
+
# A backend always has the runtime half.
|
|
80
|
+
[ "$backend" = "none" ] || runtime=1
|
|
75
81
|
# CMAKE_OSX_ARCHITECTURES means nothing off macOS.
|
|
76
82
|
[ "$(uname -s)" = "Darwin" ] || archs=""
|
|
77
83
|
|
|
@@ -140,7 +146,10 @@ if [ "$config" = RelWithDebInfo ]; then
|
|
|
140
146
|
done
|
|
141
147
|
fi
|
|
142
148
|
|
|
149
|
+
# Off macOS archs is blank, and Hermes is built for this machine's architecture, under the same
|
|
150
|
+
# name as on macOS.
|
|
143
151
|
arch_key="${archs//;/-}"
|
|
152
|
+
[ -n "$arch_key" ] || arch_key="$(uname -m)"
|
|
144
153
|
hermes_args=()
|
|
145
154
|
if [ "$backend" = "appkit" ]; then
|
|
146
155
|
# React Native's own prebuilt Hermes, universal: with the debugger for a dev build, as React
|
|
@@ -148,20 +157,36 @@ if [ "$backend" = "appkit" ]; then
|
|
|
148
157
|
hermes_flavour=debug
|
|
149
158
|
[ "$config" = Release ] && hermes_flavour=release
|
|
150
159
|
hermes_args=(-DNGN_HERMES_PREBUILT="$("$here/fetch-hermes.sh" "$RN_PKG" "$hermes_flavour")")
|
|
151
|
-
elif [ "$
|
|
160
|
+
elif [ "$runtime" = 1 ]; then
|
|
152
161
|
hermes="$CACHE/hermes-$arch_key"
|
|
153
162
|
# Built again when missing, or built for another macOS than the host's.
|
|
154
163
|
if ! "$here/hermes-built.sh" "$hermes"; then
|
|
155
|
-
|
|
164
|
+
# One Hermes build at a time for this cache and architecture: build-hermes.sh (and, off macOS,
|
|
165
|
+
# build-icu.sh) clears and refills one output directory, which a second build would delete from
|
|
166
|
+
# under the first. Locked as fetch.sh locks (the kernel's flock through this shell's descriptor
|
|
167
|
+
# 8, taken by Perl since macOS has no flock command), and checked again once held, so a build
|
|
168
|
+
# that waited uses the Hermes the first one finished.
|
|
169
|
+
exec 8>> "$CACHE/.hermes-$arch_key-lock"
|
|
170
|
+
perl -MFcntl=:flock -e 'open(my $fd, ">&=", 8) or die "build.sh: $!\n"; flock($fd, LOCK_EX) or die "build.sh: $!\n"'
|
|
171
|
+
if ! "$here/hermes-built.sh" "$hermes"; then
|
|
172
|
+
"$here/build-hermes.sh" "$RN_PKG" "$archs" >&2
|
|
173
|
+
fi
|
|
174
|
+
exec 8>&-
|
|
156
175
|
fi
|
|
157
176
|
hermes_args=(-DNGN_HERMES_BUILD="$hermes")
|
|
158
177
|
fi
|
|
159
178
|
|
|
160
|
-
|
|
179
|
+
variant="$backend"
|
|
180
|
+
[ "$backend" = "none" ] && [ "$runtime" = 1 ] && variant=none-runtime
|
|
181
|
+
BUILD="${build_dir:-$host_dir/$variant-$arch_key-$config}"
|
|
182
|
+
# One build at a time in it (build-lock.sh), held until this script and the ninja it runs end.
|
|
183
|
+
. "$here/build-lock.sh"
|
|
184
|
+
lock_build "$BUILD"
|
|
161
185
|
cmake --log-level=WARNING -G Ninja -S "$native_dir" -B "$BUILD" \
|
|
162
186
|
-DCMAKE_BUILD_TYPE="$config" \
|
|
163
187
|
-DCMAKE_OSX_ARCHITECTURES="$archs" \
|
|
164
188
|
-DNGN_BACKEND="$backend" \
|
|
189
|
+
-DNGN_RUNTIME="$([ "$runtime" = 1 ] && echo ON || echo OFF)" \
|
|
165
190
|
-DRN_DIR="$RN_PKG" \
|
|
166
191
|
-DNGN_SOURCES="$CACHE/src" \
|
|
167
192
|
-DNGN_LIBRARIES="$library_dirs" \
|
|
@@ -170,9 +195,17 @@ cmake --log-level=WARNING -G Ninja -S "$native_dir" -B "$BUILD" \
|
|
|
170
195
|
${launcher_args[@]+"${launcher_args[@]}"} \
|
|
171
196
|
${flags_args[@]+"${flags_args[@]}"} \
|
|
172
197
|
${hermes_args[@]+"${hermes_args[@]}"} >&2
|
|
173
|
-
|
|
198
|
+
# Ninja itself, as CMake chose it, rather than through `cmake --build`: CMake starts its build tool
|
|
199
|
+
# with none of this shell's descriptors, so a ninja left running after a killed `cmake --build`
|
|
200
|
+
# would build on without the lock. Started from here it holds descriptor 7 until it ends.
|
|
201
|
+
ninja=$(sed -n 's/^CMAKE_MAKE_PROGRAM:[A-Z]*=//p' "$BUILD/CMakeCache.txt")
|
|
202
|
+
nice -n 10 "${ninja:-ninja}" -C "$BUILD" -j "$JOBS" >&2
|
|
174
203
|
if [ "$run_tests" = 1 ]; then
|
|
175
204
|
"$BUILD/ngn_core_tests" >&2
|
|
205
|
+
# Hermes and the runtime half, which a build with the runtime has.
|
|
206
|
+
if [ -x "$BUILD/ngn_runtime_tests" ]; then
|
|
207
|
+
"$BUILD/ngn_runtime_tests" >&2
|
|
208
|
+
fi
|
|
176
209
|
# The AppKit view tests, which a build with the AppKit backend has.
|
|
177
210
|
if [ -x "$BUILD/appkit/ngn_appkit_tests" ]; then
|
|
178
211
|
"$BUILD/appkit/ngn_appkit_tests" >&2
|
package/native/scripts/fetch.sh
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
# ReactCommon comes from the installed react-native package; everything else is fetched here:
|
|
8
8
|
# ReactCxxPlatform (in the git tag, not the npm package), Hermes, folly and the libraries React
|
|
9
9
|
# Native's Android build would normally download (glog, fmt, double-conversion, boost headers,
|
|
10
|
-
# fast_float), nlohmann_json for the dev-server client, doctest for the core tests,
|
|
11
|
-
# Sparkle's framework, which `package --format dmg` embeds for whole-app updates
|
|
10
|
+
# fast_float), nlohmann_json for the dev-server client, doctest for the core tests, on macOS
|
|
11
|
+
# Sparkle's framework, which `package --format dmg` embeds for whole-app updates, and elsewhere ICU,
|
|
12
|
+
# which Hermes's Unicode layer needs there (build-icu.sh builds it).
|
|
12
13
|
# Each source records what it was fetched at, so a changed pin fetches it again. A download whose
|
|
13
14
|
# checksum or commit does not match fails the script; nothing is ever used unverified.
|
|
14
15
|
#
|
|
@@ -49,6 +50,11 @@ DOCTEST_URL=https://raw.githubusercontent.com/doctest/doctest/v2.4.12/doctest/do
|
|
|
49
50
|
DOCTEST_SHA256=94029a7d32da24a56249658147dbd2b33ff0b9ed665295cbbaf19aafff5b0ced
|
|
50
51
|
SPARKLE_URL=https://github.com/sparkle-project/Sparkle/releases/download/2.6.4/Sparkle-2.6.4.tar.xz
|
|
51
52
|
SPARKLE_SHA256=50612a06038abc931f16011d7903b8326a362c1074dabccb718404ce8e585f0b
|
|
53
|
+
# ICU's sources and, to build its data filtered (build-icu.sh), the data's sources.
|
|
54
|
+
ICU_URL=https://github.com/unicode-org/icu/releases/download/release-77-1/icu4c-77_1-src.tgz
|
|
55
|
+
ICU_SHA256=588e431f77327c39031ffbb8843c0e3bc122c211374485fa87dc5f3faff24061
|
|
56
|
+
ICU_DATA_URL=https://github.com/unicode-org/icu/releases/download/release-77-1/icu4c-77_1-data.zip
|
|
57
|
+
ICU_DATA_SHA256=1e08bfafa442260ccabf9a872d4eab12de813d42b90769df056bab032b37e1d3
|
|
52
58
|
|
|
53
59
|
if [ "$(cat "$RN_PKG/sdks/.hermesv1version")" != "$HERMES_TAG" ]; then
|
|
54
60
|
echo "fetch.sh: react-native names Hermes $(cat "$RN_PKG/sdks/.hermesv1version"), pinned $HERMES_TAG" >&2
|
|
@@ -151,6 +157,22 @@ if [ "$(uname -s)" = "Darwin" ] && ! fresh sparkle "$SPARKLE_SHA256"; then
|
|
|
151
157
|
rm -rf "$SRC/.sparkle.tmp"
|
|
152
158
|
stamp sparkle "$SPARKLE_SHA256"
|
|
153
159
|
fi
|
|
160
|
+
|
|
161
|
+
# ICU, with its data's sources in place of the prebuilt data, so build-icu.sh can filter them.
|
|
162
|
+
if [ "$(uname -s)" != "Darwin" ] && ! fresh icu "$ICU_SHA256-$ICU_DATA_SHA256"; then
|
|
163
|
+
echo "==> icu"
|
|
164
|
+
rm -rf "$SRC/icu" "$SRC/.icu.tmp"
|
|
165
|
+
mkdir -p "$SRC/.icu.tmp"
|
|
166
|
+
download "$ICU_URL" "$ICU_SHA256" "$SRC/.icu.tmp/icu.tgz"
|
|
167
|
+
download "$ICU_DATA_URL" "$ICU_DATA_SHA256" "$SRC/.icu.tmp/data.zip"
|
|
168
|
+
tar -xzf "$SRC/.icu.tmp/icu.tgz" -C "$SRC/.icu.tmp"
|
|
169
|
+
rm -rf "$SRC/.icu.tmp/icu/source/data"
|
|
170
|
+
unzip -q "$SRC/.icu.tmp/data.zip" -d "$SRC/.icu.tmp/icu/source"
|
|
171
|
+
[ -d "$SRC/.icu.tmp/icu/source/data/locales" ] || { echo "fetch.sh: ICU's data archive has no data/locales" >&2; exit 1; }
|
|
172
|
+
mv "$SRC/.icu.tmp/icu" "$SRC/icu"
|
|
173
|
+
rm -rf "$SRC/.icu.tmp"
|
|
174
|
+
stamp icu "$ICU_SHA256-$ICU_DATA_SHA256"
|
|
175
|
+
fi
|
|
154
176
|
t1=$(date +%s)
|
|
155
177
|
|
|
156
178
|
# React Native's own component codegen (FBReactNativeSpec), from the installed package.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Succeeds when <dir> holds a Hermes build-hermes.sh finished for
|
|
3
|
-
#
|
|
2
|
+
# Succeeds when <dir> holds a Hermes build-hermes.sh finished for what the host is built for now
|
|
3
|
+
# (hermes-target.sh: the macOS, or off macOS the C library and the ICU); build.sh builds it again
|
|
4
|
+
# otherwise, so a raised target or a new ICU reaches Hermes too.
|
|
4
5
|
#
|
|
5
6
|
# hermes-built.sh <dir>
|
|
6
7
|
set -euo pipefail
|
|
7
8
|
here="$(cd "$(dirname "$0")" && pwd)"
|
|
8
9
|
dir="${1:?usage: hermes-built.sh <dir>}"
|
|
9
|
-
[ -f "$dir/lib/libhermesvm_a.a" ] && [ -f "$dir/
|
|
10
|
-
[ "$(cat "$dir/
|
|
10
|
+
[ -f "$dir/lib/libhermesvm_a.a" ] && [ -f "$dir/target" ] &&
|
|
11
|
+
[ "$(cat "$dir/target")" = "$("$here/hermes-target.sh")" ]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Prints what a Hermes build is for, which build-hermes.sh records beside it and hermes-built.sh
|
|
3
|
+
# compares, so a change to any of it builds Hermes again: on macOS the oldest macOS the host runs on
|
|
4
|
+
# (macos-target.sh); elsewhere the C library it links against and the ICU it links in (fetch.sh's
|
|
5
|
+
# pin, and how build-icu.sh builds it).
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
here="$(cd "$(dirname "$0")" && pwd)"
|
|
8
|
+
if [ "$(uname -s)" = "Darwin" ]; then
|
|
9
|
+
echo "macos $("$here/macos-target.sh")"
|
|
10
|
+
exit 0
|
|
11
|
+
fi
|
|
12
|
+
sha256() {
|
|
13
|
+
if command -v sha256sum > /dev/null; then sha256sum; else shasum -a 256; fi | cut -d' ' -f1
|
|
14
|
+
}
|
|
15
|
+
glibc="$(getconf GNU_LIBC_VERSION | cut -d' ' -f2)"
|
|
16
|
+
icu="$(sed -n 's/^ICU\(_DATA\)\{0,1\}_SHA256=\([0-9a-f]*\)$/\2/p' "$here/fetch.sh" | tr '\n' ' ')"
|
|
17
|
+
[ -n "$glibc" ] && [ "$(wc -w <<< "$icu")" -eq 2 ] || { echo "hermes-target.sh: no glibc version or ICU pin" >&2; exit 1; }
|
|
18
|
+
echo "linux glibc $glibc icu ${icu% } build $(cat "$here/build-icu.sh" "$here/icu-filter.json" | sha256)"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"localeFilter": {
|
|
3
|
+
"filterType": "language",
|
|
4
|
+
"includelist": ["en"]
|
|
5
|
+
},
|
|
6
|
+
"featureFilters": {
|
|
7
|
+
"conversion_mappings": "exclude",
|
|
8
|
+
"cnvalias": "exclude",
|
|
9
|
+
"confusables": "exclude",
|
|
10
|
+
"translit": "exclude",
|
|
11
|
+
"brkitr_dictionaries": "exclude",
|
|
12
|
+
"brkitr_rules": "exclude",
|
|
13
|
+
"brkitr_tree": "exclude",
|
|
14
|
+
"stringprep": "exclude",
|
|
15
|
+
"unames": "exclude",
|
|
16
|
+
"rbnf_tree": "exclude",
|
|
17
|
+
"curr_tree": "exclude",
|
|
18
|
+
"lang_tree": "exclude",
|
|
19
|
+
"region_tree": "exclude",
|
|
20
|
+
"unit_tree": "exclude"
|
|
21
|
+
}
|
|
22
|
+
}
|