@hot-updater/android-helper 1.2.0-rc.47 → 1.2.0-rc.49

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/dist/index.cjs CHANGED
@@ -105,13 +105,34 @@ const formatCommand = (words, width = 74) => {
105
105
  * The init script every Windows build runs with. ninja 1.10.2, which the
106
106
  * Android SDK's CMake 3.22.1 ships, can't reach a path over MAX_PATH (260
107
107
  * characters), and React Native's codegen object paths, which repeat the
108
- * project's path, pass it. At 250, CMake's own default on Windows, CMake
109
- * hashes the long part of an object's name. Only the names of objects
110
- * under `.cxx` change, never what they compile to. A module whose CMake
111
- * arguments set CMAKE_OBJECT_PATH_MAX, in its default config, a build type
112
- * or a flavor, keeps its own.
108
+ * project's path, pass it. At 259, CMake hashes the long part of an object's
109
+ * name so the whole path stays within it; at 250, an object directory of
110
+ * 179 characters left no room for the hash and a 40-character file name.
111
+ * Only the names of objects under `.cxx` change, never what they compile
112
+ * to.
113
+ *
114
+ * Expo's root project plugin (expo-modules-autolinking 58,
115
+ * `ExpoRootProjectPlugin.kt` `setDefaultCmakeObjectPathMax`) gives every
116
+ * module `-DCMAKE_OBJECT_PATH_MAX` from the `expo.android.cmakeObjectPathMax`
117
+ * property, 1024 when unset, which it reads with `findProperty` as a string
118
+ * when it applies. So the script sets that property on the root project
119
+ * first, unless gradle.properties, the user's, `-P` or the environment set
120
+ * it. Their value stands, `0` included, which turns Expo's limit off and
121
+ * leaves CMake's own: then no module gets one from this script either. A
122
+ * module whose own CMake arguments set CMAKE_OBJECT_PATH_MAX, in its default
123
+ * config, a build type or a flavor, keeps its own.
113
124
  */
114
125
  const WINDOWS_INIT_SCRIPT = `// Written by hot-updater for one Windows build: object paths within MAX_PATH.
126
+ // Set by the project, a person or the environment, not this script: their
127
+ // value stands, and 0, which turns Expo's limit off, too.
128
+ def expoLimitSetElsewhere = false
129
+ gradle.rootProject { root ->
130
+ if (root.hasProperty('expo.android.cmakeObjectPathMax')) {
131
+ expoLimitSetElsewhere = true
132
+ } else {
133
+ root.ext.set('expo.android.cmakeObjectPathMax', '259')
134
+ }
135
+ }
115
136
  allprojects { project ->
116
137
  ['com.android.application', 'com.android.library'].each { id ->
117
138
  project.plugins.withId(id) {
@@ -120,8 +141,8 @@ allprojects { project ->
120
141
  def own = configs.any { config ->
121
142
  config.externalNativeBuild.cmake.arguments.any { it.startsWith('-DCMAKE_OBJECT_PATH_MAX') }
122
143
  }
123
- if (!own) {
124
- android.defaultConfig.externalNativeBuild.cmake.arguments.add('-DCMAKE_OBJECT_PATH_MAX=250')
144
+ if (!own && !expoLimitSetElsewhere) {
145
+ android.defaultConfig.externalNativeBuild.cmake.arguments.add('-DCMAKE_OBJECT_PATH_MAX=259')
125
146
  }
126
147
  }
127
148
  }
@@ -200,52 +221,49 @@ async function runGradleTasks({ tasks, logPrefix, args, env, androidProjectPath,
200
221
  gradleArgs.push("-x", "lint");
201
222
  if (args.extraParams) gradleArgs.push(...args.extraParams);
202
223
  if ("port" in args && args.port != null) gradleArgs.push(`-PreactNativeDevServerPort=${args.port}`);
203
- const logger = createGradleLogger({ logPrefix });
204
- await logger.start({
205
- title: `Building ${tasks.join(", ")}`,
206
- header: [
207
- ...logHeader,
208
- `Project ${path.default.relative((0, _hot_updater_cli_tools.getCwd)(), androidProjectPath) || "."}`,
209
- `App module ${appModuleName}`,
210
- `Tasks ${tasks.join(", ")}`,
211
- `$ ${formatCommand([path.default.basename(getGradleWrapper(androidProjectPath)), ...gradleArgs])}`,
212
- ""
213
- ]
214
- });
215
- let logFilePath = null;
216
- try {
217
- const [command, prefix] = gradleCommand(androidProjectPath, env);
218
- const [gradleResult, loggingResult] = await withWindowsGradleArgs((platformArgs) => {
219
- const gradle = (0, execa.execa)(command, [
220
- ...prefix,
221
- ...gradleArgs,
222
- ...platformArgs
223
- ], {
224
+ return withWindowsGradleArgs(async (platformArgs) => {
225
+ const finalArgs = [...gradleArgs, ...platformArgs];
226
+ const logger = createGradleLogger({ logPrefix });
227
+ await logger.start({
228
+ title: `Building ${tasks.join(", ")}`,
229
+ header: [
230
+ ...logHeader,
231
+ `Project ${path.default.relative((0, _hot_updater_cli_tools.getCwd)(), androidProjectPath) || "."}`,
232
+ `App module ${appModuleName}`,
233
+ `Tasks ${tasks.join(", ")}`,
234
+ `$ ${formatCommand([path.default.basename(getGradleWrapper(androidProjectPath)), ...finalArgs])}`,
235
+ ""
236
+ ]
237
+ });
238
+ let logFilePath = null;
239
+ try {
240
+ const [command, prefix] = gradleCommand(androidProjectPath, env);
241
+ const gradle = (0, execa.execa)(command, [...prefix, ...finalArgs], {
224
242
  cwd: androidProjectPath,
225
243
  env,
226
244
  all: true,
227
245
  buffer: false
228
246
  });
229
247
  const outputStream = gradle.all ?? gradle.stdout;
230
- return Promise.allSettled([gradle, outputStream ? logger.processStream(outputStream) : void 0]);
231
- });
232
- if (gradleResult.status === "rejected") throw gradleResult.reason;
233
- if (loggingResult.status === "rejected") throw loggingResult.reason;
234
- logger.stop(`Built ${tasks.join(", ")}`);
235
- logFilePath = logger.logFilePath;
236
- } catch (e) {
237
- logger.writeError(e);
238
- const reason = describeFailure(e);
239
- logger.stop(`Build failed · ${reason.replace(/\.$/, "")}`, false);
240
- throw new _hot_updater_cli_tools.BuildFailedError(`Build failed: ${reason}`, {
241
- logPath: logger.logPath,
242
- summary: logger.failureSummary,
243
- cause: e
244
- });
245
- } finally {
246
- await logger.close();
247
- }
248
- return logFilePath;
248
+ const [gradleResult, loggingResult] = await Promise.allSettled([gradle, outputStream ? logger.processStream(outputStream) : void 0]);
249
+ if (gradleResult.status === "rejected") throw gradleResult.reason;
250
+ if (loggingResult.status === "rejected") throw loggingResult.reason;
251
+ logger.stop(`Built ${tasks.join(", ")}`);
252
+ logFilePath = logger.logFilePath;
253
+ } catch (e) {
254
+ logger.writeError(e);
255
+ const reason = describeFailure(e);
256
+ logger.stop(`Build failed · ${reason.replace(/\.$/, "")}`, false);
257
+ throw new _hot_updater_cli_tools.BuildFailedError(`Build failed: ${reason}`, {
258
+ logPath: logger.logPath,
259
+ summary: logger.failureSummary,
260
+ cause: e
261
+ });
262
+ } finally {
263
+ await logger.close();
264
+ }
265
+ return logFilePath;
266
+ });
249
267
  }
250
268
  /**
251
269
  * Find the build output directory and artifact path
package/dist/index.mjs CHANGED
@@ -77,13 +77,34 @@ const formatCommand = (words, width = 74) => {
77
77
  * The init script every Windows build runs with. ninja 1.10.2, which the
78
78
  * Android SDK's CMake 3.22.1 ships, can't reach a path over MAX_PATH (260
79
79
  * characters), and React Native's codegen object paths, which repeat the
80
- * project's path, pass it. At 250, CMake's own default on Windows, CMake
81
- * hashes the long part of an object's name. Only the names of objects
82
- * under `.cxx` change, never what they compile to. A module whose CMake
83
- * arguments set CMAKE_OBJECT_PATH_MAX, in its default config, a build type
84
- * or a flavor, keeps its own.
80
+ * project's path, pass it. At 259, CMake hashes the long part of an object's
81
+ * name so the whole path stays within it; at 250, an object directory of
82
+ * 179 characters left no room for the hash and a 40-character file name.
83
+ * Only the names of objects under `.cxx` change, never what they compile
84
+ * to.
85
+ *
86
+ * Expo's root project plugin (expo-modules-autolinking 58,
87
+ * `ExpoRootProjectPlugin.kt` `setDefaultCmakeObjectPathMax`) gives every
88
+ * module `-DCMAKE_OBJECT_PATH_MAX` from the `expo.android.cmakeObjectPathMax`
89
+ * property, 1024 when unset, which it reads with `findProperty` as a string
90
+ * when it applies. So the script sets that property on the root project
91
+ * first, unless gradle.properties, the user's, `-P` or the environment set
92
+ * it. Their value stands, `0` included, which turns Expo's limit off and
93
+ * leaves CMake's own: then no module gets one from this script either. A
94
+ * module whose own CMake arguments set CMAKE_OBJECT_PATH_MAX, in its default
95
+ * config, a build type or a flavor, keeps its own.
85
96
  */
86
97
  const WINDOWS_INIT_SCRIPT = `// Written by hot-updater for one Windows build: object paths within MAX_PATH.
98
+ // Set by the project, a person or the environment, not this script: their
99
+ // value stands, and 0, which turns Expo's limit off, too.
100
+ def expoLimitSetElsewhere = false
101
+ gradle.rootProject { root ->
102
+ if (root.hasProperty('expo.android.cmakeObjectPathMax')) {
103
+ expoLimitSetElsewhere = true
104
+ } else {
105
+ root.ext.set('expo.android.cmakeObjectPathMax', '259')
106
+ }
107
+ }
87
108
  allprojects { project ->
88
109
  ['com.android.application', 'com.android.library'].each { id ->
89
110
  project.plugins.withId(id) {
@@ -92,8 +113,8 @@ allprojects { project ->
92
113
  def own = configs.any { config ->
93
114
  config.externalNativeBuild.cmake.arguments.any { it.startsWith('-DCMAKE_OBJECT_PATH_MAX') }
94
115
  }
95
- if (!own) {
96
- android.defaultConfig.externalNativeBuild.cmake.arguments.add('-DCMAKE_OBJECT_PATH_MAX=250')
116
+ if (!own && !expoLimitSetElsewhere) {
117
+ android.defaultConfig.externalNativeBuild.cmake.arguments.add('-DCMAKE_OBJECT_PATH_MAX=259')
97
118
  }
98
119
  }
99
120
  }
@@ -172,52 +193,49 @@ async function runGradleTasks({ tasks, logPrefix, args, env, androidProjectPath,
172
193
  gradleArgs.push("-x", "lint");
173
194
  if (args.extraParams) gradleArgs.push(...args.extraParams);
174
195
  if ("port" in args && args.port != null) gradleArgs.push(`-PreactNativeDevServerPort=${args.port}`);
175
- const logger = createGradleLogger({ logPrefix });
176
- await logger.start({
177
- title: `Building ${tasks.join(", ")}`,
178
- header: [
179
- ...logHeader,
180
- `Project ${path.relative(getCwd(), androidProjectPath) || "."}`,
181
- `App module ${appModuleName}`,
182
- `Tasks ${tasks.join(", ")}`,
183
- `$ ${formatCommand([path.basename(getGradleWrapper(androidProjectPath)), ...gradleArgs])}`,
184
- ""
185
- ]
186
- });
187
- let logFilePath = null;
188
- try {
189
- const [command, prefix] = gradleCommand(androidProjectPath, env);
190
- const [gradleResult, loggingResult] = await withWindowsGradleArgs((platformArgs) => {
191
- const gradle = execa(command, [
192
- ...prefix,
193
- ...gradleArgs,
194
- ...platformArgs
195
- ], {
196
+ return withWindowsGradleArgs(async (platformArgs) => {
197
+ const finalArgs = [...gradleArgs, ...platformArgs];
198
+ const logger = createGradleLogger({ logPrefix });
199
+ await logger.start({
200
+ title: `Building ${tasks.join(", ")}`,
201
+ header: [
202
+ ...logHeader,
203
+ `Project ${path.relative(getCwd(), androidProjectPath) || "."}`,
204
+ `App module ${appModuleName}`,
205
+ `Tasks ${tasks.join(", ")}`,
206
+ `$ ${formatCommand([path.basename(getGradleWrapper(androidProjectPath)), ...finalArgs])}`,
207
+ ""
208
+ ]
209
+ });
210
+ let logFilePath = null;
211
+ try {
212
+ const [command, prefix] = gradleCommand(androidProjectPath, env);
213
+ const gradle = execa(command, [...prefix, ...finalArgs], {
196
214
  cwd: androidProjectPath,
197
215
  env,
198
216
  all: true,
199
217
  buffer: false
200
218
  });
201
219
  const outputStream = gradle.all ?? gradle.stdout;
202
- return Promise.allSettled([gradle, outputStream ? logger.processStream(outputStream) : void 0]);
203
- });
204
- if (gradleResult.status === "rejected") throw gradleResult.reason;
205
- if (loggingResult.status === "rejected") throw loggingResult.reason;
206
- logger.stop(`Built ${tasks.join(", ")}`);
207
- logFilePath = logger.logFilePath;
208
- } catch (e) {
209
- logger.writeError(e);
210
- const reason = describeFailure(e);
211
- logger.stop(`Build failed · ${reason.replace(/\.$/, "")}`, false);
212
- throw new BuildFailedError(`Build failed: ${reason}`, {
213
- logPath: logger.logPath,
214
- summary: logger.failureSummary,
215
- cause: e
216
- });
217
- } finally {
218
- await logger.close();
219
- }
220
- return logFilePath;
220
+ const [gradleResult, loggingResult] = await Promise.allSettled([gradle, outputStream ? logger.processStream(outputStream) : void 0]);
221
+ if (gradleResult.status === "rejected") throw gradleResult.reason;
222
+ if (loggingResult.status === "rejected") throw loggingResult.reason;
223
+ logger.stop(`Built ${tasks.join(", ")}`);
224
+ logFilePath = logger.logFilePath;
225
+ } catch (e) {
226
+ logger.writeError(e);
227
+ const reason = describeFailure(e);
228
+ logger.stop(`Build failed · ${reason.replace(/\.$/, "")}`, false);
229
+ throw new BuildFailedError(`Build failed: ${reason}`, {
230
+ logPath: logger.logPath,
231
+ summary: logger.failureSummary,
232
+ cause: e
233
+ });
234
+ } finally {
235
+ await logger.close();
236
+ }
237
+ return logFilePath;
238
+ });
221
239
  }
222
240
  /**
223
241
  * Find the build output directory and artifact path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/android-helper",
3
- "version": "1.2.0-rc.47",
3
+ "version": "1.2.0-rc.49",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -30,9 +30,9 @@
30
30
  "execa": "9.5.2",
31
31
  "fast-xml-parser": "5.7.2",
32
32
  "jszip": "^3.10.1",
33
- "@hot-updater/cli-tools": "1.2.0-rc.47",
34
- "@hot-updater/protocol": "1.2.0-rc.47",
35
- "@hot-updater/plugin-core": "1.2.0-rc.47"
33
+ "@hot-updater/cli-tools": "1.2.0-rc.49",
34
+ "@hot-updater/plugin-core": "1.2.0-rc.49",
35
+ "@hot-updater/protocol": "1.2.0-rc.49"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "^20"