@ng-native/desktop 0.26.1 → 0.27.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/README.md +6 -3
- package/bin/app-config.mjs +1 -0
- package/bin/archive.mjs +166 -0
- package/bin/autolink.mjs +61 -30
- package/bin/cli.mjs +127 -27
- package/bin/host.mjs +255 -58
- package/bin/package-linux.mjs +1394 -0
- package/bin/package.mjs +171 -35
- package/bin/plist.mjs +6 -2
- package/bin/png-icon.mjs +315 -0
- package/bin/prebuilt.mjs +147 -26
- package/bin/toolchain.mjs +258 -19
- package/native/CMakeLists.txt +64 -6
- package/native/appkit/CMakeLists.txt +2 -1
- package/native/appkit/appkit-backend.h +1 -0
- package/native/appkit/appkit-backend.mm +13 -0
- package/native/appkit/header-toolbar.mm +28 -25
- package/native/appkit/host-view.h +10 -0
- package/native/appkit/host-view.mm +146 -40
- package/native/appkit/input-replay.h +6 -0
- package/native/appkit/input-replay.mm +21 -12
- package/native/appkit/main.mm +11 -7
- package/native/appkit/native-controls.mm +13 -1
- package/native/appkit/split-view.mm +7 -13
- package/native/appkit/text-input-field.h +4 -0
- package/native/appkit/text-input-field.mm +20 -1
- package/native/cmake/curl.cmake +79 -0
- package/native/cmake/libraries/react-native-reanimated.cmake +5 -0
- package/native/cmake/libraries/react-native-worklets.cmake +5 -0
- package/native/cmake/linked-modules.cmake +20 -4
- package/native/cmake/react-native.cmake +18 -1
- package/native/core/include/ngn/accent-colors.h +38 -0
- package/native/core/include/ngn/accessibility-relations.h +65 -0
- package/native/core/include/ngn/accessibility.h +26 -0
- package/native/core/include/ngn/animated-frame-loop.h +56 -0
- package/native/core/include/ngn/app-info.h +24 -8
- package/native/core/include/ngn/app-menus.h +14 -1
- package/native/core/include/ngn/app-windows.h +15 -2
- package/native/core/include/ngn/aria-role.h +96 -0
- package/native/core/include/ngn/audio.h +2 -0
- package/native/core/include/ngn/camera.h +9 -0
- package/native/core/include/ngn/control-sizes.h +7 -2
- package/native/core/include/ngn/crash-report.h +31 -0
- package/native/core/include/ngn/curl-network.h +93 -0
- package/native/core/include/ngn/dbus-menu.h +39 -0
- package/native/core/include/ngn/default-menu.h +36 -0
- package/native/core/include/ngn/desktop-expo.h +7 -1
- package/native/core/include/ngn/desktop-modules.h +22 -0
- package/native/core/include/ngn/desktop-props.h +21 -1
- package/native/core/include/ngn/desktop-view-props.h +6 -0
- package/native/core/include/ngn/focus-order.h +10 -0
- package/native/core/include/ngn/header-bar.h +22 -0
- package/native/core/include/ngn/host-os.h +6 -0
- package/native/core/include/ngn/host-reload.h +21 -0
- package/native/core/include/ngn/host-state.h +23 -0
- package/native/core/include/ngn/image-source.h +26 -1
- package/native/core/include/ngn/input-script.h +3 -3
- package/native/core/include/ngn/input.h +4 -1
- package/native/core/include/ngn/launch-frame.h +21 -0
- package/native/core/include/ngn/launch-settings.h +23 -5
- package/native/core/include/ngn/mounting-backend.h +5 -0
- package/native/core/include/ngn/mounting-manager.h +1 -0
- package/native/core/include/ngn/native-controls.h +26 -5
- package/native/core/include/ngn/notification-schedule.h +74 -0
- package/native/core/include/ngn/notifications.h +2 -1
- package/native/core/include/ngn/openssl-update-crypto.h +15 -0
- package/native/core/include/ngn/photo-library.h +60 -20
- package/native/core/include/ngn/posix-locale.h +43 -0
- package/native/core/include/ngn/runtime.h +5 -0
- package/native/core/include/ngn/safe-areas.h +14 -2
- package/native/core/include/ngn/split-view.h +78 -0
- package/native/core/include/ngn/surface-metrics.h +7 -0
- package/native/core/include/ngn/system.h +14 -0
- package/native/core/include/ngn/text-input.h +13 -0
- package/native/core/include/ngn/text-units.h +38 -0
- package/native/core/include/ngn/updates.h +14 -2
- package/native/core/include/ngn/view-box.h +40 -0
- package/native/core/include/ngn/view-transform.h +15 -0
- package/native/core/include/ngn/web-browser.h +46 -0
- package/native/core/src/accent-colors.cpp +88 -0
- package/native/core/src/accessibility-relations.cpp +138 -0
- package/native/core/src/accessibility.cpp +50 -0
- package/native/core/src/animated-frame-loop.cpp +166 -0
- package/native/core/src/app-menus.cpp +26 -9
- package/native/core/src/app-windows.cpp +27 -6
- package/native/core/src/aria-role.cpp +127 -0
- package/native/core/src/control-sizes.cpp +9 -5
- package/native/core/src/crash-report.cpp +196 -0
- package/native/core/src/curl-network.cpp +1562 -0
- package/native/core/src/dbus-menu.cpp +71 -0
- package/native/core/src/default-menu.cpp +134 -0
- package/native/core/src/desktop-view-props.cpp +14 -0
- package/native/core/src/focus-order.cpp +19 -0
- package/native/core/src/header-bar.cpp +20 -0
- package/native/core/src/host-os.cpp +19 -0
- package/native/core/src/host-reload.cpp +45 -0
- package/native/core/src/host-state.cpp +8 -0
- package/native/core/src/image-source.cpp +90 -0
- package/native/core/src/input-dispatcher.cpp +27 -5
- package/native/core/src/input-script.cpp +3 -2
- package/native/core/src/launch-settings.cpp +76 -0
- package/native/core/src/libraries/react-native-reanimated.cpp +6 -1
- package/native/core/src/modules/app-info.cpp +55 -6
- package/native/core/src/modules/app-modules.cpp +1 -1
- package/native/core/src/modules/audio.cpp +4 -2
- package/native/core/src/modules/camera.cpp +8 -11
- package/native/core/src/modules/desktop-expo.cpp +10 -5
- package/native/core/src/modules/desktop-modules.cpp +106 -41
- package/native/core/src/modules/file-photo-picker.cpp +408 -0
- package/native/core/src/modules/notifications.cpp +13 -17
- package/native/core/src/modules/photo-library.cpp +42 -13
- package/native/core/src/modules/web-browser.cpp +89 -0
- package/native/core/src/mounting-manager.cpp +12 -0
- package/native/core/src/native-controls.cpp +42 -1
- package/native/core/src/notification-schedule.cpp +429 -0
- package/native/core/src/openssl-update-crypto.cpp +83 -0
- package/native/core/src/posix-locale.cpp +192 -0
- package/native/core/src/runtime.cpp +30 -1
- package/native/core/src/safe-areas.cpp +19 -4
- package/native/core/src/spawn-rules.cpp +4 -1
- package/native/core/src/split-view.cpp +93 -0
- package/native/core/src/system.cpp +19 -0
- package/native/core/src/text-input.cpp +18 -1
- package/native/core/src/text-units.cpp +99 -0
- package/native/core/src/updates.cpp +76 -17
- package/native/core/src/view-box.cpp +75 -40
- package/native/core/src/view-transform.cpp +28 -0
- package/native/docker/Dockerfile +38 -0
- package/native/docker/Dockerfile.fedora +36 -0
- package/native/docker/glibc-floor.sh +49 -0
- package/native/gtk/CMakeLists.txt +137 -0
- package/native/gtk/accent-colour.cpp +57 -0
- package/native/gtk/accent-colour.h +41 -0
- package/native/gtk/accessibility-settings.cpp +159 -0
- package/native/gtk/accessibility-settings.h +62 -0
- package/native/gtk/accessible-text.cpp +151 -0
- package/native/gtk/accessible-text.h +49 -0
- package/native/gtk/accessible.cpp +306 -0
- package/native/gtk/accessible.h +75 -0
- package/native/gtk/alerts.cpp +267 -0
- package/native/gtk/alerts.h +30 -0
- package/native/gtk/animation-frames.cpp +159 -0
- package/native/gtk/animation-frames.h +20 -0
- package/native/gtk/app-info.cpp +91 -0
- package/native/gtk/app-info.h +25 -0
- package/native/gtk/app-windows.cpp +439 -0
- package/native/gtk/app-windows.h +150 -0
- package/native/gtk/audio.cpp +370 -0
- package/native/gtk/audio.h +54 -0
- package/native/gtk/auth-session.cpp +73 -0
- package/native/gtk/auth-session.h +16 -0
- package/native/gtk/battery.cpp +110 -0
- package/native/gtk/battery.h +19 -0
- package/native/gtk/box-paint.cpp +262 -0
- package/native/gtk/box-paint.h +32 -0
- package/native/gtk/cairo-canvas.cpp +755 -0
- package/native/gtk/cairo-canvas.h +49 -0
- package/native/gtk/camera.cpp +909 -0
- package/native/gtk/camera.h +69 -0
- package/native/gtk/capture.cpp +46 -0
- package/native/gtk/capture.h +19 -0
- package/native/gtk/clock-format.cpp +151 -0
- package/native/gtk/clock-format.h +36 -0
- package/native/gtk/crypto.cpp +75 -0
- package/native/gtk/crypto.h +14 -0
- package/native/gtk/dbus-properties.cpp +131 -0
- package/native/gtk/dbus-properties.h +61 -0
- package/native/gtk/drag-and-drop.cpp +339 -0
- package/native/gtk/drag-and-drop.h +30 -0
- package/native/gtk/file-dialogs.cpp +239 -0
- package/native/gtk/file-dialogs.h +21 -0
- package/native/gtk/file-system.cpp +212 -0
- package/native/gtk/file-system.h +25 -0
- package/native/gtk/focus.cpp +282 -0
- package/native/gtk/focus.h +37 -0
- package/native/gtk/fonts.cpp +89 -0
- package/native/gtk/fonts.h +22 -0
- package/native/gtk/gst-frames.cpp +150 -0
- package/native/gtk/gst-frames.h +47 -0
- package/native/gtk/gst-playback.cpp +496 -0
- package/native/gtk/gst-playback.h +81 -0
- package/native/gtk/gtk-backend.cpp +690 -0
- package/native/gtk/gtk-backend.h +134 -0
- package/native/gtk/host-sources.cpp +354 -0
- package/native/gtk/host-sources.h +46 -0
- package/native/gtk/image-manipulator.cpp +254 -0
- package/native/gtk/image-manipulator.h +30 -0
- package/native/gtk/image-view.cpp +256 -0
- package/native/gtk/image-view.h +54 -0
- package/native/gtk/input-replay.cpp +299 -0
- package/native/gtk/input-replay.h +36 -0
- package/native/gtk/launcher-badge.cpp +29 -0
- package/native/gtk/launcher-badge.h +21 -0
- package/native/gtk/locales.cpp +131 -0
- package/native/gtk/locales.h +23 -0
- package/native/gtk/location.cpp +274 -0
- package/native/gtk/location.h +19 -0
- package/native/gtk/main.cpp +1092 -0
- package/native/gtk/menus.cpp +447 -0
- package/native/gtk/menus.h +100 -0
- package/native/gtk/native-controls.cpp +831 -0
- package/native/gtk/native-controls.h +58 -0
- package/native/gtk/network-state.cpp +72 -0
- package/native/gtk/network-state.h +24 -0
- package/native/gtk/notifications.cpp +235 -0
- package/native/gtk/notifications.h +30 -0
- package/native/gtk/pango-text.cpp +274 -0
- package/native/gtk/pango-text.h +73 -0
- package/native/gtk/portal.cpp +451 -0
- package/native/gtk/portal.h +71 -0
- package/native/gtk/printing.cpp +338 -0
- package/native/gtk/printing.h +34 -0
- package/native/gtk/proxy-resolver.cpp +74 -0
- package/native/gtk/proxy-resolver.h +20 -0
- package/native/gtk/screens.cpp +1461 -0
- package/native/gtk/screens.h +274 -0
- package/native/gtk/scroll-view.cpp +414 -0
- package/native/gtk/scroll-view.h +82 -0
- package/native/gtk/secret-store.cpp +120 -0
- package/native/gtk/secret-store.h +27 -0
- package/native/gtk/settings-portal.cpp +129 -0
- package/native/gtk/settings-portal.h +47 -0
- package/native/gtk/split-view.cpp +1105 -0
- package/native/gtk/split-view.h +195 -0
- package/native/gtk/status-notifier.cpp +487 -0
- package/native/gtk/status-notifier.h +43 -0
- package/native/gtk/surface-input.cpp +251 -0
- package/native/gtk/surface-input.h +57 -0
- package/native/gtk/system-access.cpp +295 -0
- package/native/gtk/system-access.h +37 -0
- package/native/gtk/text-field.cpp +827 -0
- package/native/gtk/text-field.h +78 -0
- package/native/gtk/video.cpp +527 -0
- package/native/gtk/video.h +47 -0
- package/native/gtk/view-widget.cpp +431 -0
- package/native/gtk/view-widget.h +105 -0
- package/native/gtk/window-scale.cpp +95 -0
- package/native/gtk/window-scale.h +35 -0
- package/native/scripts/atspi-check.py +310 -0
- package/native/scripts/atspi-check.test.py +48 -0
- package/native/scripts/build.sh +20 -3
- package/native/scripts/compilers.sh +17 -0
- package/native/scripts/deb-depends-check.sh +22 -0
- package/native/scripts/fetch.sh +23 -2
- package/native/scripts/launch-cell.sh +157 -0
- package/native/scripts/launch-probe.sh +14 -3
- package/native/scripts/make-prebuilt.mjs +133 -44
- package/native/scripts/prebuilt-host-cache.mjs +71 -40
- package/native/scripts/reset-for-compilers.sh +44 -0
- package/native/scripts/start-xvfb.sh +35 -0
- package/native/shim/paragraph-platform/react/renderer/components/text/HostPlatformParagraphProps.h +35 -0
- package/native/shim/view-platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +5 -2
- package/native/shim/worklets/linux-reanimated-props.h +14 -0
- package/native/shim/worklets/linux-worklets.h +23 -0
- package/package.json +6 -3
- package/prebuilt.json +70 -6
package/bin/prebuilt.mjs
CHANGED
|
@@ -9,9 +9,12 @@
|
|
|
9
9
|
* the package is packed (`docs/desktop-host.md` has the steps), so the SHA-256 of each archive
|
|
10
10
|
* travels inside the npm package, not beside the archive it vouches for. An archive holds `appkit/ngn-macos`, `appkit/hermesc`,
|
|
11
11
|
* `appkit/hermesvm.framework` and `appkit/Sparkle.framework`, the files a host build's `appkit` folder has, and unpacks into the
|
|
12
|
-
* per-user cache under its own hash, so a new archive never reuses an old one's files.
|
|
12
|
+
* per-user cache under its own hash, so a new archive never reuses an old one's files. An entry
|
|
13
|
+
* with `os: 'linux'` is a Linux host for the one `arch` it names, whose archive holds
|
|
14
|
+
* `gtk/ngn-linux` and `gtk/hermesc`. Each release publishes both flavours for macOS and for Linux on
|
|
15
|
+
* x64 and arm64 (`RELEASE_HOSTS`).
|
|
13
16
|
*
|
|
14
|
-
* `native/scripts/make-prebuilt.mjs` builds and packs one.
|
|
17
|
+
* `native/scripts/make-prebuilt.mjs` builds and packs one. A macOS host is signed ad hoc unless
|
|
15
18
|
* `NGN_SIGN_IDENTITY` names an identity: an app re-signs it when it packages, and the download is
|
|
16
19
|
* checked by SHA-256, so no Developer ID is needed.
|
|
17
20
|
*/
|
|
@@ -35,8 +38,10 @@ export const FLAVOURS = /** @type {const} */ (['debug', 'release']);
|
|
|
35
38
|
|
|
36
39
|
/**
|
|
37
40
|
* @typedef {typeof FLAVOURS[number]} Flavour
|
|
38
|
-
* @typedef {
|
|
41
|
+
* @typedef {'macos' | 'linux'} HostOs
|
|
42
|
+
* @typedef {{ reactNative: string, flavour?: Flavour, os?: HostOs, arch?: 'x64' | 'arm64', url: string, sha256: string, libraries: Record<string, string>, inputs?: string }} PrebuiltHost
|
|
39
43
|
* `flavour` is `release` when it is left out, as a manifest from before the debug host has it.
|
|
44
|
+
* `os` is `macos` when it is left out, a universal host; a `linux` host is for one `arch`.
|
|
40
45
|
* `inputs` is the key of what the host was built from (native/scripts/prebuilt-host-cache.mjs),
|
|
41
46
|
* which the next release's make-prebuilt.mjs --reuse compares with its own
|
|
42
47
|
* @typedef {{ version: number, hosts: PrebuiltHost[] }} PrebuiltManifest
|
|
@@ -44,26 +49,86 @@ export const FLAVOURS = /** @type {const} */ (['debug', 'release']);
|
|
|
44
49
|
*/
|
|
45
50
|
|
|
46
51
|
/**
|
|
47
|
-
* The
|
|
48
|
-
*
|
|
52
|
+
* The OS and, for Linux, the architecture a prebuilt host is for. A macOS host is universal.
|
|
53
|
+
*
|
|
54
|
+
* @typedef {{ os?: HostOs, arch?: 'x64' | 'arm64' }} HostPlatform
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The prebuilt hosts each release publishes: both flavours, for macOS (universal) and for Linux on
|
|
59
|
+
* x64 and arm64.
|
|
60
|
+
*
|
|
61
|
+
* @type {readonly (HostPlatform & { flavour: Flavour })[]}
|
|
62
|
+
*/
|
|
63
|
+
export const RELEASE_HOSTS = /** @type {const} */ ([
|
|
64
|
+
{ os: 'macos' },
|
|
65
|
+
{ os: 'linux', arch: 'x64' },
|
|
66
|
+
{ os: 'linux', arch: 'arm64' },
|
|
67
|
+
]).flatMap((platform) => FLAVOURS.map((flavour) => ({ ...platform, flavour })));
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The archive's file name for a release of this package, a React Native version, a flavour and a
|
|
71
|
+
* platform: `macos-universal`, or `linux-<arch>`. The release host's name has no flavour in it.
|
|
49
72
|
*
|
|
50
73
|
* @param {string} desktopVersion
|
|
51
74
|
* @param {string} reactNative
|
|
52
75
|
* @param {Flavour} [flavour]
|
|
76
|
+
* @param {HostPlatform} [platform]
|
|
53
77
|
*/
|
|
54
|
-
export function prebuiltName(desktopVersion, reactNative, flavour = 'release') {
|
|
78
|
+
export function prebuiltName(desktopVersion, reactNative, flavour = 'release', platform = {}) {
|
|
55
79
|
const suffix = flavour === 'release' ? '' : `-${flavour}`;
|
|
56
|
-
return `ng-native-desktop-host-${desktopVersion}-rn-${reactNative}
|
|
80
|
+
return `ng-native-desktop-host-${desktopVersion}-rn-${reactNative}-${platformName(platform)}${suffix}.tar.gz`;
|
|
57
81
|
}
|
|
58
82
|
|
|
59
83
|
/**
|
|
60
84
|
* The file `make-prebuilt.mjs` writes a host's manifest entry to, beside its archive: one per
|
|
61
|
-
* flavour, so
|
|
85
|
+
* flavour and platform, so every build of a release can share a folder. A macOS entry's name has
|
|
86
|
+
* no platform in it.
|
|
62
87
|
*
|
|
63
88
|
* @param {Flavour} flavour
|
|
89
|
+
* @param {HostPlatform} [platform]
|
|
90
|
+
*/
|
|
91
|
+
export function entryName(flavour, platform = {}) {
|
|
92
|
+
const os = platform.os ?? 'macos';
|
|
93
|
+
return os === 'macos'
|
|
94
|
+
? `prebuilt-host-${flavour}.json`
|
|
95
|
+
: `prebuilt-host-${platformName(platform)}-${flavour}.json`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* `macos-universal`, or `linux-<arch>`.
|
|
100
|
+
*
|
|
101
|
+
* @param {HostPlatform} platform
|
|
64
102
|
*/
|
|
65
|
-
|
|
66
|
-
return
|
|
103
|
+
function platformName({ os = 'macos', arch }) {
|
|
104
|
+
if (os === 'macos') return 'macos-universal';
|
|
105
|
+
if (arch !== 'x64' && arch !== 'arm64') {
|
|
106
|
+
throw new Error(`A Linux prebuilt host is for x64 or arm64, not ${arch}.`);
|
|
107
|
+
}
|
|
108
|
+
return `linux-${arch}`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* `manifest` with the entry of each host a release publishes (`RELEASE_HOSTS`), read by
|
|
113
|
+
* `readEntry` from its `entryName`. Throws when one is missing or is not the host its name says,
|
|
114
|
+
* so no release ships without it.
|
|
115
|
+
*
|
|
116
|
+
* @param {PrebuiltManifest} manifest
|
|
117
|
+
* @param {(name: string) => string} readEntry the entry file's text
|
|
118
|
+
* @returns {PrebuiltManifest}
|
|
119
|
+
*/
|
|
120
|
+
export function withReleaseHosts(manifest, readEntry) {
|
|
121
|
+
let updated = manifest;
|
|
122
|
+
for (const slot of RELEASE_HOSTS) {
|
|
123
|
+
const name = entryName(slot.flavour, slot);
|
|
124
|
+
/** @type {PrebuiltHost} */
|
|
125
|
+
const host = JSON.parse(readEntry(name));
|
|
126
|
+
if (flavourOf(host) !== slot.flavour || osOf(host) !== slot.os || host.arch !== slot.arch) {
|
|
127
|
+
throw new Error(`${name} is not the ${platformName(slot)} ${slot.flavour} host.`);
|
|
128
|
+
}
|
|
129
|
+
updated = withHost(updated, host);
|
|
130
|
+
}
|
|
131
|
+
return updated;
|
|
67
132
|
}
|
|
68
133
|
|
|
69
134
|
/**
|
|
@@ -76,6 +141,41 @@ export function flavourOf(host) {
|
|
|
76
141
|
return host.flavour ?? 'release';
|
|
77
142
|
}
|
|
78
143
|
|
|
144
|
+
/**
|
|
145
|
+
* The OS a host is for: `macos` when its entry names none.
|
|
146
|
+
*
|
|
147
|
+
* @param {PrebuiltHost} host
|
|
148
|
+
* @returns {HostOs}
|
|
149
|
+
*/
|
|
150
|
+
function osOf(host) {
|
|
151
|
+
return host.os ?? 'macos';
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The host's executable in its archive and build folder: `appkit/ngn-macos` or `gtk/ngn-linux`.
|
|
156
|
+
*
|
|
157
|
+
* @param {PrebuiltHost} host
|
|
158
|
+
*/
|
|
159
|
+
export function executableOf(host) {
|
|
160
|
+
return osOf(host) === 'linux' ? path.join('gtk', 'ngn-linux') : path.join('appkit', 'ngn-macos');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Whether two entries are for the same React Native version, flavour, OS and architecture, so one
|
|
165
|
+
* replaces the other.
|
|
166
|
+
*
|
|
167
|
+
* @param {PrebuiltHost} a
|
|
168
|
+
* @param {PrebuiltHost} b
|
|
169
|
+
*/
|
|
170
|
+
function sameSlot(a, b) {
|
|
171
|
+
return (
|
|
172
|
+
a.reactNative === b.reactNative &&
|
|
173
|
+
flavourOf(a) === flavourOf(b) &&
|
|
174
|
+
osOf(a) === osOf(b) &&
|
|
175
|
+
a.arch === b.arch
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
79
179
|
/**
|
|
80
180
|
* The manifest in `text`, or an empty one for text that is not a manifest of this version.
|
|
81
181
|
*
|
|
@@ -93,16 +193,15 @@ export function readManifest(text) {
|
|
|
93
193
|
}
|
|
94
194
|
|
|
95
195
|
/**
|
|
96
|
-
* `manifest` with `host` in it, in place of the one for the same React Native version
|
|
196
|
+
* `manifest` with `host` in it, in place of the one for the same React Native version, flavour, OS
|
|
197
|
+
* and architecture.
|
|
97
198
|
*
|
|
98
199
|
* @param {PrebuiltManifest} manifest
|
|
99
200
|
* @param {PrebuiltHost} host
|
|
100
201
|
* @returns {PrebuiltManifest}
|
|
101
202
|
*/
|
|
102
203
|
export function withHost(manifest, host) {
|
|
103
|
-
const hosts = manifest.hosts.filter(
|
|
104
|
-
(each) => each.reactNative !== host.reactNative || flavourOf(each) !== flavourOf(host),
|
|
105
|
-
);
|
|
204
|
+
const hosts = manifest.hosts.filter((each) => !sameSlot(each, host));
|
|
106
205
|
return { version: MANIFEST_VERSION, hosts: [...hosts, host] };
|
|
107
206
|
}
|
|
108
207
|
|
|
@@ -146,7 +245,7 @@ export function publishPrebuilt({ out, archive, name, host, manifest }, { wait =
|
|
|
146
245
|
throw new Error(`${target} is already published. Remove it first to publish another build.`);
|
|
147
246
|
}
|
|
148
247
|
renameSync(archive, target);
|
|
149
|
-
replace(path.join(out, entryName(flavourOf(host))), `${JSON.stringify(host, null, 2)}\n`);
|
|
248
|
+
replace(path.join(out, entryName(flavourOf(host), host)), `${JSON.stringify(host, null, 2)}\n`);
|
|
150
249
|
if (manifest) {
|
|
151
250
|
const updated = withHost(readManifest(readFileSync(manifest, 'utf8')), host);
|
|
152
251
|
replace(manifest, `${JSON.stringify(updated, null, 2)}\n`);
|
|
@@ -181,24 +280,46 @@ function takeLock(lock, give) {
|
|
|
181
280
|
}
|
|
182
281
|
}
|
|
183
282
|
|
|
283
|
+
/**
|
|
284
|
+
* The manifest's host for a React Native version, flavour and platform (a Linux one for its
|
|
285
|
+
* architecture), or undefined.
|
|
286
|
+
*
|
|
287
|
+
* @param {PrebuiltManifest} manifest
|
|
288
|
+
* @param {{ reactNative: string, flavour: Flavour } & HostPlatform} slot
|
|
289
|
+
*/
|
|
290
|
+
export function findHost(manifest, { reactNative, flavour, os = 'macos', arch }) {
|
|
291
|
+
return manifest.hosts.find(
|
|
292
|
+
(each) =>
|
|
293
|
+
each.reactNative === reactNative &&
|
|
294
|
+
flavourOf(each) === flavour &&
|
|
295
|
+
osOf(each) === os &&
|
|
296
|
+
(os === 'macos' || each.arch === arch),
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
184
300
|
/**
|
|
185
301
|
* The prebuilt host an app can run on, or why it builds its own: one is used only for the app's
|
|
186
302
|
* React Native version and the flavour asked for, when the app links no native desktop code, and
|
|
187
303
|
* when each host library it has is the version the host was built with and is not denied.
|
|
188
304
|
*
|
|
189
305
|
* @param {PrebuiltManifest} manifest
|
|
190
|
-
* @param {{ reactNative: string, flavour: Flavour, linked: number, libraries: Record<string, string | null>, deny: readonly string[], env: Record<string, string | undefined
|
|
306
|
+
* @param {{ reactNative: string, flavour: Flavour, linked: number, libraries: Record<string, string | null>, deny: readonly string[], env: Record<string, string | undefined>, os?: HostOs, arch?: 'x64' | 'arm64' }} app
|
|
191
307
|
* `flavour` is `debug` for a dev run and `release` for a packaged app; `libraries` holds each
|
|
192
|
-
* host library's installed version, or null where the app lacks it
|
|
308
|
+
* host library's installed version, or null where the app lacks it; `os` is `macos` unless it
|
|
309
|
+
* says, and `arch` the architecture a Linux host is for
|
|
193
310
|
* @returns {{ host: PrebuiltHost } | { reason: string }}
|
|
194
311
|
*/
|
|
195
|
-
export function choosePrebuilt(
|
|
312
|
+
export function choosePrebuilt(
|
|
313
|
+
manifest,
|
|
314
|
+
{ reactNative, flavour, linked, libraries, deny, env, os = 'macos', arch },
|
|
315
|
+
) {
|
|
196
316
|
if (env['NGN_DESKTOP_FROM_SOURCE'] === '1') return { reason: 'NGN_DESKTOP_FROM_SOURCE=1' };
|
|
197
317
|
if (linked > 0) return { reason: 'the app links native desktop code' };
|
|
198
|
-
const host = manifest
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
318
|
+
const host = findHost(manifest, { reactNative, flavour, os, arch });
|
|
319
|
+
if (!host) {
|
|
320
|
+
const what = os === 'macos' ? flavour : `${flavour} Linux ${arch}`;
|
|
321
|
+
return { reason: `no prebuilt ${what} host for React Native ${reactNative}` };
|
|
322
|
+
}
|
|
202
323
|
for (const name of Object.keys(host.libraries)) {
|
|
203
324
|
if (deny.includes(name)) return { reason: `${name} is denied, and the prebuilt host has it` };
|
|
204
325
|
}
|
|
@@ -232,7 +353,7 @@ export function fetchPrebuilt(sys, host, cache) {
|
|
|
232
353
|
);
|
|
233
354
|
}
|
|
234
355
|
const dir = path.join(cache, 'prebuilt', host.sha256.slice(0, 16));
|
|
235
|
-
if (sys.exists(path.join(dir,
|
|
356
|
+
if (sys.exists(path.join(dir, executableOf(host)))) return dir;
|
|
236
357
|
const own = `${dir}.${process.pid}-${randomBytes(4).toString('hex')}`;
|
|
237
358
|
const archive = `${own}.tar.gz`;
|
|
238
359
|
const unpacked = `${own}.partial`;
|
|
@@ -271,15 +392,15 @@ export function fetchPrebuilt(sys, host, cache) {
|
|
|
271
392
|
sys.writeFile(path.join(unpacked, '.sha256'), `${sha256}\n`);
|
|
272
393
|
const tar = sys.run('tar', ['-xzf', archive, '-C', unpacked], { capture: true });
|
|
273
394
|
sys.remove(archive);
|
|
274
|
-
if (tar.status !== 0 || !sys.exists(path.join(unpacked,
|
|
395
|
+
if (tar.status !== 0 || !sys.exists(path.join(unpacked, executableOf(host)))) {
|
|
275
396
|
sys.remove(unpacked);
|
|
276
397
|
throw new Error(
|
|
277
|
-
`The prebuilt desktop host from ${host.url} did not unpack to
|
|
398
|
+
`The prebuilt desktop host from ${host.url} did not unpack to ${executableOf(host)}.`,
|
|
278
399
|
);
|
|
279
400
|
}
|
|
280
401
|
// Published by one atomic rename, which fails rather than replace a folder that holds a host,
|
|
281
402
|
// so a host another run has published is never deleted under it.
|
|
282
|
-
const binary = path.join(dir,
|
|
403
|
+
const binary = path.join(dir, executableOf(host));
|
|
283
404
|
try {
|
|
284
405
|
if (!sys.exists(binary)) sys.rename(unpacked, dir);
|
|
285
406
|
} catch (error) {
|
package/bin/toolchain.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The tools a from-source build of the desktop host needs, checked before it starts so a missing or
|
|
3
|
-
* old one stops it with the line that fixes it, not a compiler error minutes in
|
|
3
|
+
* old one stops it with the line that fixes it, not a compiler error minutes in: Xcode's tools,
|
|
4
|
+
* CMake and Ninja on a Mac; on Linux clang, lld, CMake, Ninja, the tools the fetch and build
|
|
5
|
+
* scripts call, and the libraries the GTK host links, found through pkg-config.
|
|
4
6
|
*/
|
|
5
7
|
import { UsageError } from './host.mjs';
|
|
6
8
|
|
|
@@ -14,6 +16,21 @@ export const TOOLCHAIN_MINIMUMS = /** @type {const} */ ({
|
|
|
14
16
|
ninja: '1.10',
|
|
15
17
|
});
|
|
16
18
|
|
|
19
|
+
/**
|
|
20
|
+
* The oldest version of each library the GTK host links that has a floor, as `native/gtk` and
|
|
21
|
+
* `native/cmake/curl.cmake` ask pkg-config for it.
|
|
22
|
+
*/
|
|
23
|
+
export const LINUX_LIBRARY_MINIMUMS = /** @type {Readonly<Record<string, string>>} */ ({
|
|
24
|
+
gtk4: '4.10',
|
|
25
|
+
'libadwaita-1': '1.4',
|
|
26
|
+
'libsecret-1': '0.20',
|
|
27
|
+
openssl: '3.0',
|
|
28
|
+
'gstreamer-1.0': '1.22',
|
|
29
|
+
'gstreamer-app-1.0': '1.22',
|
|
30
|
+
'gstreamer-video-1.0': '1.22',
|
|
31
|
+
'gstreamer-pbutils-1.0': '1.22',
|
|
32
|
+
});
|
|
33
|
+
|
|
17
34
|
/**
|
|
18
35
|
* How long the first build of the host for a React Native version takes on an Apple silicon Mac,
|
|
19
36
|
* measured cold: React Native and Hermes compile from source.
|
|
@@ -23,8 +40,13 @@ export const FIRST_BUILD_NOTE =
|
|
|
23
40
|
'Native and Hermes compile, which takes about 4 minutes on an Apple silicon Mac (about 6 for a ' +
|
|
24
41
|
'universal release build). Later runs reuse it.';
|
|
25
42
|
|
|
43
|
+
/** The same note for the GTK host, which compiles ICU and libcurl as well. */
|
|
44
|
+
export const LINUX_FIRST_BUILD_NOTE =
|
|
45
|
+
'Building the desktop host from source for the first time for this React Native version: React ' +
|
|
46
|
+
'Native, Hermes, ICU and libcurl compile, which takes many minutes. Later runs reuse it.';
|
|
47
|
+
|
|
26
48
|
/**
|
|
27
|
-
* @typedef {{ run(command: string, args: string[], options?: { capture?: boolean }): { status: number, stdout: string } }} ToolRunner
|
|
49
|
+
* @typedef {{ run(command: string, args: string[], options?: { capture?: boolean, quiet?: boolean }): { status: number, stdout: string }, readFile?(file: string): string }} ToolRunner
|
|
28
50
|
*/
|
|
29
51
|
|
|
30
52
|
/**
|
|
@@ -40,7 +62,8 @@ export const FIRST_BUILD_NOTE =
|
|
|
40
62
|
function probe(sys, command, args) {
|
|
41
63
|
const line = [command, ...args].join(' ');
|
|
42
64
|
try {
|
|
43
|
-
|
|
65
|
+
// Quiet: unzip answers --version with its usage on stderr, which is no problem to report.
|
|
66
|
+
const result = sys.run(command, args, { capture: true, quiet: true });
|
|
44
67
|
if (result.status === 0) return { stdout: result.stdout };
|
|
45
68
|
return {
|
|
46
69
|
failed: `${line} failed (status ${result.status})`,
|
|
@@ -72,26 +95,237 @@ export function atLeast(version, minimum) {
|
|
|
72
95
|
}
|
|
73
96
|
|
|
74
97
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
98
|
+
* The commands a problem line names to install, reinstall or update a package.
|
|
99
|
+
*
|
|
100
|
+
* @typedef {{ install(pkg: Package): string, reinstall(pkg: Package): string, upgrade(pkg: Package): string }} Installer
|
|
101
|
+
* @typedef {{ brew?: string, apt: string, dnf: string }} Package
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/** @type {Installer} */
|
|
105
|
+
const HOMEBREW = {
|
|
106
|
+
install: (pkg) => `brew install ${pkg.brew}`,
|
|
107
|
+
reinstall: (pkg) => `brew reinstall ${pkg.brew}`,
|
|
108
|
+
upgrade: (pkg) => `brew upgrade ${pkg.brew}`,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/** CMake and Ninja, which every host builds with, and their packages. */
|
|
112
|
+
const BUILD_TOOLS = /** @type {const} */ ([
|
|
113
|
+
{ tool: 'cmake', name: 'CMake', pkg: { brew: 'cmake', apt: 'cmake', dnf: 'cmake' } },
|
|
114
|
+
{ tool: 'ninja', name: 'Ninja', pkg: { brew: 'ninja', apt: 'ninja-build', dnf: 'ninja-build' } },
|
|
115
|
+
]);
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Each other tool the Linux build runs, by its command, with its package in Debian's and Fedora's
|
|
119
|
+
* families. `shasum` is Perl's, which the build scripts key their folders with.
|
|
120
|
+
*
|
|
121
|
+
* @type {readonly { command: string, name: string, pkg: Package }[]}
|
|
122
|
+
*/
|
|
123
|
+
export const LINUX_TOOLS = [
|
|
124
|
+
{ command: 'clang', name: 'clang', pkg: { apt: 'clang', dnf: 'clang' } },
|
|
125
|
+
{ command: 'clang++', name: 'clang++', pkg: { apt: 'clang', dnf: 'clang' } },
|
|
126
|
+
{ command: 'ld.lld', name: 'lld', pkg: { apt: 'lld', dnf: 'lld' } },
|
|
127
|
+
{ command: 'git', name: 'Git', pkg: { apt: 'git', dnf: 'git' } },
|
|
128
|
+
{ command: 'curl', name: 'curl', pkg: { apt: 'curl', dnf: 'curl' } },
|
|
129
|
+
{ command: 'unzip', name: 'unzip', pkg: { apt: 'unzip', dnf: 'unzip' } },
|
|
130
|
+
{ command: 'xz', name: 'xz', pkg: { apt: 'xz-utils', dnf: 'xz' } },
|
|
131
|
+
{ command: 'perl', name: 'Perl', pkg: { apt: 'perl', dnf: 'perl' } },
|
|
132
|
+
{ command: 'shasum', name: 'shasum', pkg: { apt: 'perl', dnf: 'perl-Digest-SHA' } },
|
|
133
|
+
{ command: 'python3', name: 'Python 3', pkg: { apt: 'python3', dnf: 'python3' } },
|
|
134
|
+
{
|
|
135
|
+
command: 'pkg-config',
|
|
136
|
+
name: 'pkg-config',
|
|
137
|
+
pkg: { apt: 'pkg-config', dnf: 'pkgconf-pkg-config' },
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Each library the GTK host links, by its pkg-config name, with its development package.
|
|
143
|
+
*
|
|
144
|
+
* @type {readonly { module: string, pkg: Package }[]}
|
|
145
|
+
*/
|
|
146
|
+
export const LINUX_LIBRARIES = [
|
|
147
|
+
{ module: 'gtk4', pkg: { apt: 'libgtk-4-dev', dnf: 'gtk4-devel' } },
|
|
148
|
+
{ module: 'libadwaita-1', pkg: { apt: 'libadwaita-1-dev', dnf: 'libadwaita-devel' } },
|
|
149
|
+
{ module: 'pangocairo', pkg: { apt: 'libpango1.0-dev', dnf: 'pango-devel' } },
|
|
150
|
+
{ module: 'gio-unix-2.0', pkg: { apt: 'libglib2.0-dev', dnf: 'glib2-devel' } },
|
|
151
|
+
{ module: 'x11', pkg: { apt: 'libx11-dev', dnf: 'libX11-devel' } },
|
|
152
|
+
{ module: 'libsecret-1', pkg: { apt: 'libsecret-1-dev', dnf: 'libsecret-devel' } },
|
|
153
|
+
{ module: 'fontconfig', pkg: { apt: 'libfontconfig-dev', dnf: 'fontconfig-devel' } },
|
|
154
|
+
{ module: 'pangoft2', pkg: { apt: 'libpango1.0-dev', dnf: 'pango-devel' } },
|
|
155
|
+
{ module: 'openssl', pkg: { apt: 'libssl-dev', dnf: 'openssl-devel' } },
|
|
156
|
+
{ module: 'libnghttp2', pkg: { apt: 'libnghttp2-dev', dnf: 'libnghttp2-devel' } },
|
|
157
|
+
{ module: 'zlib', pkg: { apt: 'zlib1g-dev', dnf: 'zlib-devel' } },
|
|
158
|
+
{ module: 'sqlite3', pkg: { apt: 'libsqlite3-dev', dnf: 'sqlite-devel' } },
|
|
159
|
+
{ module: 'gstreamer-1.0', pkg: { apt: 'libgstreamer1.0-dev', dnf: 'gstreamer1-devel' } },
|
|
160
|
+
...['gstreamer-app-1.0', 'gstreamer-video-1.0', 'gstreamer-pbutils-1.0'].map((module) => ({
|
|
161
|
+
module,
|
|
162
|
+
pkg: { apt: 'libgstreamer-plugins-base1.0-dev', dnf: 'gstreamer1-plugins-base-devel' },
|
|
163
|
+
})),
|
|
164
|
+
];
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The package family of a Linux, from `/etc/os-release`'s `ID` and `ID_LIKE`: Debian's (Debian,
|
|
168
|
+
* Ubuntu) or Fedora's (Fedora, RHEL and its rebuilds), or null for another. `el` is true on RHEL and
|
|
169
|
+
* its rebuilds, whose CRB repository has Ninja and the GTK headers.
|
|
170
|
+
*
|
|
171
|
+
* @param {string} osRelease the file's text
|
|
172
|
+
* @returns {{ family: 'apt' | 'dnf', el: boolean } | null}
|
|
173
|
+
*/
|
|
174
|
+
export function linuxFamily(osRelease) {
|
|
175
|
+
/** @param {string} key */
|
|
176
|
+
const value = (key) =>
|
|
177
|
+
osRelease.match(new RegExp(`^${key}=["']?([^"'\\n]*)`, 'm'))?.[1]?.toLowerCase() ?? '';
|
|
178
|
+
const ids = [value('ID'), ...value('ID_LIKE').split(/\s+/)].filter(Boolean);
|
|
179
|
+
if (ids.some((id) => id === 'debian' || id === 'ubuntu')) return { family: 'apt', el: false };
|
|
180
|
+
if (ids.some((id) => ['fedora', 'rhel', 'centos'].includes(id))) {
|
|
181
|
+
return { family: 'dnf', el: ids.includes('rhel') || ids.includes('centos') };
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* The install commands for a Linux family, or, for a family not known, both families' packages.
|
|
188
|
+
*
|
|
189
|
+
* @param {{ family: 'apt' | 'dnf' } | null} found
|
|
190
|
+
* @returns {Installer}
|
|
191
|
+
*/
|
|
192
|
+
function linuxInstaller(found) {
|
|
193
|
+
if (found?.family === 'apt') {
|
|
194
|
+
return {
|
|
195
|
+
install: (pkg) => `sudo apt install ${pkg.apt}`,
|
|
196
|
+
reinstall: (pkg) => `sudo apt install --reinstall ${pkg.apt}`,
|
|
197
|
+
upgrade: (pkg) => `sudo apt install --only-upgrade ${pkg.apt}`,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
if (found?.family === 'dnf') {
|
|
201
|
+
return {
|
|
202
|
+
install: (pkg) => `sudo dnf install ${pkg.dnf}`,
|
|
203
|
+
reinstall: (pkg) => `sudo dnf reinstall ${pkg.dnf}`,
|
|
204
|
+
upgrade: (pkg) => `sudo dnf upgrade ${pkg.dnf}`,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
/** @param {string} verb @param {Package} pkg */
|
|
208
|
+
const both = (verb, pkg) =>
|
|
209
|
+
`${verb} ${pkg.apt} on Debian or Ubuntu, ${pkg.dnf} on Fedora or RHEL, or its equivalent`;
|
|
210
|
+
return {
|
|
211
|
+
install: (pkg) => both('install', pkg),
|
|
212
|
+
reinstall: (pkg) => both('reinstall', pkg),
|
|
213
|
+
upgrade: (pkg) => both('update', pkg),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* What is missing or too old for a from-source build of the host for `os`, each with the line that
|
|
219
|
+
* fixes it. Empty when the build can start.
|
|
77
220
|
*
|
|
78
221
|
* @param {ToolRunner} sys
|
|
222
|
+
* @param {'macos' | 'linux'} [os]
|
|
79
223
|
* @returns {string[]}
|
|
80
224
|
*/
|
|
81
|
-
export function toolchainProblems(sys) {
|
|
225
|
+
export function toolchainProblems(sys, os = 'macos') {
|
|
226
|
+
if (os === 'linux') return linuxProblems(sys);
|
|
82
227
|
const developer = developerToolsProblem(sys);
|
|
83
228
|
return [
|
|
84
229
|
...(developer === null ? [] : [developer]),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
['ninja', 'Ninja'],
|
|
88
|
-
]).flatMap(([tool, name]) => {
|
|
89
|
-
const problem = buildToolProblem(sys, tool, name);
|
|
230
|
+
...BUILD_TOOLS.flatMap(({ tool, name, pkg }) => {
|
|
231
|
+
const problem = buildToolProblem(sys, tool, name, HOMEBREW, pkg);
|
|
90
232
|
return problem === null ? [] : [problem];
|
|
91
233
|
}),
|
|
92
234
|
];
|
|
93
235
|
}
|
|
94
236
|
|
|
237
|
+
/**
|
|
238
|
+
* What is wrong with the Linux toolchain: CMake or Ninja missing or too old, each other tool
|
|
239
|
+
* missing or failing to run, and each library pkg-config does not find or finds too old.
|
|
240
|
+
*
|
|
241
|
+
* @param {ToolRunner} sys
|
|
242
|
+
* @returns {string[]}
|
|
243
|
+
*/
|
|
244
|
+
function linuxProblems(sys) {
|
|
245
|
+
const found = linuxFamily(osRelease(sys));
|
|
246
|
+
const installer = linuxInstaller(found);
|
|
247
|
+
const problems = BUILD_TOOLS.flatMap(({ tool, name, pkg }) => {
|
|
248
|
+
const problem = buildToolProblem(sys, tool, name, installer, pkg);
|
|
249
|
+
return problem === null ? [] : [problem];
|
|
250
|
+
});
|
|
251
|
+
const tools = LINUX_TOOLS.flatMap((tool) => {
|
|
252
|
+
const problem = linuxToolProblem(sys, tool, installer);
|
|
253
|
+
return problem === null ? [] : [{ command: tool.command, problem }];
|
|
254
|
+
});
|
|
255
|
+
problems.push(...tools.map((each) => each.problem));
|
|
256
|
+
// Without pkg-config every library would read as missing.
|
|
257
|
+
if (!tools.some((each) => each.command === 'pkg-config')) {
|
|
258
|
+
for (const library of LINUX_LIBRARIES) {
|
|
259
|
+
const problem = libraryProblem(sys, library, installer);
|
|
260
|
+
if (problem !== null) problems.push(problem);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (problems.length > 0 && found?.el) {
|
|
264
|
+
problems.push(
|
|
265
|
+
'On RHEL and its rebuilds, Ninja and the GTK and libadwaita headers are in the CRB ' +
|
|
266
|
+
'repository: enable it first with sudo dnf config-manager --set-enabled crb',
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
return problems;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* `/etc/os-release`'s text, or nothing where it cannot be read, so both families' packages are
|
|
274
|
+
* named.
|
|
275
|
+
*
|
|
276
|
+
* @param {ToolRunner} sys
|
|
277
|
+
*/
|
|
278
|
+
function osRelease(sys) {
|
|
279
|
+
try {
|
|
280
|
+
return sys.readFile?.('/etc/os-release') ?? '';
|
|
281
|
+
} catch {
|
|
282
|
+
return '';
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* What is wrong with one tool the Linux build runs, or null. Being there and running is enough:
|
|
288
|
+
* unzip and shasum print no version for --version, and unzip exits nonzero.
|
|
289
|
+
*
|
|
290
|
+
* @param {ToolRunner} sys
|
|
291
|
+
* @param {{ command: string, name: string, pkg: Package }} tool
|
|
292
|
+
* @param {Installer} installer
|
|
293
|
+
*/
|
|
294
|
+
function linuxToolProblem(sys, { command, name, pkg }, installer) {
|
|
295
|
+
const text = probe(sys, command, ['--version']);
|
|
296
|
+
if ('missing' in text) return `${name} is not installed. Install it: ${installer.install(pkg)}`;
|
|
297
|
+
if ('failed' in text && !text.exited) {
|
|
298
|
+
return `${name} is installed but ${text.failed}. Check it runs, or reinstall it: ${installer.reinstall(pkg)}`;
|
|
299
|
+
}
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* What is wrong with one library the GTK host links, or null.
|
|
305
|
+
*
|
|
306
|
+
* @param {ToolRunner} sys
|
|
307
|
+
* @param {{ module: string, pkg: Package }} library
|
|
308
|
+
* @param {Installer} installer
|
|
309
|
+
*/
|
|
310
|
+
function libraryProblem(sys, { module, pkg }, installer) {
|
|
311
|
+
const text = probe(sys, 'pkg-config', ['--modversion', module]);
|
|
312
|
+
if (!('stdout' in text)) {
|
|
313
|
+
return `pkg-config finds no ${module}. Install its headers: ${installer.install(pkg)}`;
|
|
314
|
+
}
|
|
315
|
+
const minimum = LINUX_LIBRARY_MINIMUMS[module];
|
|
316
|
+
const version = text.stdout.trim().match(/^\d+(?:\.\d+)*/)?.[0];
|
|
317
|
+
if (!version) {
|
|
318
|
+
return `pkg-config printed no version for ${module}. Reinstall its headers: ${installer.reinstall(pkg)}`;
|
|
319
|
+
}
|
|
320
|
+
if (minimum && !atLeast(version, minimum)) {
|
|
321
|
+
return (
|
|
322
|
+
`${module} ${version} is older than ${minimum}, the oldest the GTK host builds with. ` +
|
|
323
|
+
`Update it (${installer.upgrade(pkg)}), or build on a newer distribution.`
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
|
|
95
329
|
/**
|
|
96
330
|
* What is wrong with Xcode or its Command Line Tools and their swiftc, or null.
|
|
97
331
|
*
|
|
@@ -156,20 +390,23 @@ function swiftProblem(sys) {
|
|
|
156
390
|
* @param {ToolRunner} sys
|
|
157
391
|
* @param {'cmake' | 'ninja'} tool
|
|
158
392
|
* @param {string} name
|
|
393
|
+
* @param {Installer} installer
|
|
394
|
+
* @param {Package} pkg
|
|
159
395
|
*/
|
|
160
|
-
function buildToolProblem(sys, tool, name) {
|
|
396
|
+
function buildToolProblem(sys, tool, name, installer, pkg) {
|
|
397
|
+
const { install, reinstall, upgrade } = installer;
|
|
161
398
|
const text = probe(sys, tool, ['--version']);
|
|
162
|
-
if ('missing' in text) return `${name} is not installed. Install it:
|
|
399
|
+
if ('missing' in text) return `${name} is not installed. Install it: ${install(pkg)}`;
|
|
163
400
|
if ('failed' in text) {
|
|
164
|
-
return `${name} is installed but ${text.failed}. Check it runs, or reinstall it:
|
|
401
|
+
return `${name} is installed but ${text.failed}. Check it runs, or reinstall it: ${reinstall(pkg)}`;
|
|
165
402
|
}
|
|
166
403
|
const version = text.stdout.match(/(\d+\.\d+(?:\.\d+)?)/)?.[1];
|
|
167
404
|
const minimum = TOOLCHAIN_MINIMUMS[tool];
|
|
168
405
|
if (!version) {
|
|
169
|
-
return `${name} printed no version for ${tool} --version. Reinstall it:
|
|
406
|
+
return `${name} printed no version for ${tool} --version. Reinstall it: ${reinstall(pkg)}`;
|
|
170
407
|
}
|
|
171
408
|
if (!atLeast(version, minimum)) {
|
|
172
|
-
return `${name} ${version} is older than ${minimum}. Update it:
|
|
409
|
+
return `${name} ${version} is older than ${minimum}. Update it: ${upgrade(pkg)}`;
|
|
173
410
|
}
|
|
174
411
|
return null;
|
|
175
412
|
}
|
|
@@ -178,13 +415,15 @@ function buildToolProblem(sys, tool, name) {
|
|
|
178
415
|
* Stops with every problem `toolchainProblems` finds, before anything builds.
|
|
179
416
|
*
|
|
180
417
|
* @param {ToolRunner} sys
|
|
418
|
+
* @param {'macos' | 'linux'} [os]
|
|
181
419
|
*/
|
|
182
|
-
export function checkToolchain(sys) {
|
|
183
|
-
const problems = toolchainProblems(sys);
|
|
420
|
+
export function checkToolchain(sys, os = 'macos') {
|
|
421
|
+
const problems = toolchainProblems(sys, os);
|
|
184
422
|
if (problems.length > 0) {
|
|
423
|
+
const where = os === 'linux' ? 'this machine' : 'this Mac';
|
|
185
424
|
throw new UsageError(
|
|
186
425
|
[
|
|
187
|
-
|
|
426
|
+
`The desktop host cannot be built from source on ${where}:`,
|
|
188
427
|
...problems.map((p) => `- ${p}`),
|
|
189
428
|
].join('\n'),
|
|
190
429
|
);
|