quickjs-zig 1.0.3 → 1.0.4
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/build.mjs +13 -7
- package/package.json +1 -1
package/build.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { execSync } from 'child_process';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
2
3
|
import { writeFileSync, mkdirSync, unlinkSync, existsSync, readdirSync, cpSync, readFileSync, renameSync, statSync, rmSync } from 'fs';
|
|
3
4
|
import path from 'path';
|
|
4
5
|
import os from 'os';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
6
|
|
|
7
7
|
// --- PATH CONFIGURATION ---
|
|
8
8
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -24,6 +24,17 @@ if (!existsSync(USER_PKG_PATH)) {
|
|
|
24
24
|
|
|
25
25
|
const userPackageJson = JSON.parse(readFileSync(USER_PKG_PATH, 'utf8'));
|
|
26
26
|
const customModules = userPackageJson.quickJs?.modules || {};
|
|
27
|
+
|
|
28
|
+
for (const [name, relativePath] of Object.entries(customModules)) {
|
|
29
|
+
const absolutePath = path.resolve(USER_CWD, relativePath);
|
|
30
|
+
if (!existsSync(absolutePath)) {
|
|
31
|
+
console.error(`\n❌ Error: Custom module "${name}" source file not found!`);
|
|
32
|
+
console.error(` Expected path: ${absolutePath}`);
|
|
33
|
+
console.error(` Please check your package.json configuration.`);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
const APP_NAME = userPackageJson.name || 'app';
|
|
28
39
|
|
|
29
40
|
// Optimization flag from package.json
|
|
@@ -211,12 +222,7 @@ targets.forEach(t => {
|
|
|
211
222
|
const TARGET_INPUT_ABS = path.join(PLATFORM_BUILD_DIR, path.basename(INPUT_FILE_RELATIVE));
|
|
212
223
|
|
|
213
224
|
// Dynamic Optimization Flags
|
|
214
|
-
let optFlags = IS_OPTIMIZED ? '-O3 -flto' : '-O2';
|
|
215
|
-
|
|
216
|
-
// -fuse-ld=lld is mandatory for macOS LTO, but causes warnings on other platforms
|
|
217
|
-
if (IS_OPTIMIZED && t.plat === 'darwin') {
|
|
218
|
-
optFlags += ' -fuse-ld=lld';
|
|
219
|
-
}
|
|
225
|
+
let optFlags = IS_OPTIMIZED && 'darwin' !== t.plat ? '-O3 -flto' : '-O2';
|
|
220
226
|
|
|
221
227
|
const cmdBase = `${ZIG_PATH} cc -target ${t.id} -I${QUICKJS_DIR} ${optFlags} ${t.cflags} -Wno-ignored-attributes -DCONFIG_VERSION=\\"${VERSION}\\" ${t.libs} -s`;
|
|
222
228
|
|
package/package.json
CHANGED