@agoric/xsnap 0.14.3-u13.0 → 0.14.3-u16.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.
Files changed (137) hide show
  1. package/README.md +3 -3
  2. package/api.js +4 -2
  3. package/build.env +1 -1
  4. package/moddable/modules/data/base64/base64.js +28 -0
  5. package/moddable/modules/data/base64/manifest.json +11 -0
  6. package/moddable/modules/data/base64/modBase64.c +188 -0
  7. package/moddable/modules/data/binaryMessage/BinaryMessage.js +106 -0
  8. package/moddable/modules/data/crc/crc.c +205 -0
  9. package/moddable/modules/data/crc/crc.js +36 -0
  10. package/moddable/modules/data/crc/manifest.json +8 -0
  11. package/moddable/modules/data/hex/hex.js +28 -0
  12. package/moddable/modules/data/hex/manifest.json +11 -0
  13. package/moddable/modules/data/hex/modHex.c +139 -0
  14. package/moddable/modules/data/logical/logical.js +32 -0
  15. package/moddable/modules/data/logical/modLogical.c +98 -0
  16. package/moddable/modules/data/qrcode/manifest.json +9 -0
  17. package/moddable/modules/data/qrcode/qrcode.c +93 -0
  18. package/moddable/modules/data/qrcode/qrcode.js +23 -0
  19. package/moddable/modules/data/qrcode/qrcodegen.c +1025 -0
  20. package/moddable/modules/data/qrcode/qrcodegen.h +267 -0
  21. package/moddable/modules/data/text/decoder/manifest.json +8 -0
  22. package/moddable/modules/data/text/decoder/textdecoder.c +480 -0
  23. package/moddable/modules/data/text/decoder/textdecoder.js +27 -0
  24. package/moddable/modules/data/text/encoder/manifest.json +8 -0
  25. package/moddable/modules/data/text/encoder/textencoder.c +232 -0
  26. package/moddable/modules/data/text/encoder/textencoder.js +24 -0
  27. package/moddable/modules/data/tinyint/tinyint.c +150 -0
  28. package/moddable/modules/data/tinyint/tinyint.js +53 -0
  29. package/moddable/modules/data/url/manifest.json +17 -0
  30. package/moddable/modules/data/url/url.c +1959 -0
  31. package/moddable/modules/data/url/url.js +210 -0
  32. package/moddable/modules/data/wavreader/manifest.json +8 -0
  33. package/moddable/modules/data/wavreader/wavreader.js +128 -0
  34. package/moddable/modules/data/zlib/deflate.c +161 -0
  35. package/moddable/modules/data/zlib/deflate.js +63 -0
  36. package/moddable/modules/data/zlib/inflate.c +145 -0
  37. package/moddable/modules/data/zlib/inflate.js +66 -0
  38. package/moddable/modules/data/zlib/manifest_deflate.json +9 -0
  39. package/moddable/modules/data/zlib/manifest_inflate.json +9 -0
  40. package/moddable/modules/data/zlib/miniz.c +4924 -0
  41. package/moddable/xs/includes/xs.d.ts +73 -0
  42. package/moddable/xs/includes/xs.h +1533 -0
  43. package/moddable/xs/includes/xsmc.h +206 -0
  44. package/moddable/xs/makefiles/lin/makefile +33 -0
  45. package/moddable/xs/makefiles/lin/xsc.mk +118 -0
  46. package/moddable/xs/makefiles/lin/xsid.mk +90 -0
  47. package/moddable/xs/makefiles/lin/xsl.mk +168 -0
  48. package/moddable/xs/makefiles/lin/xst.mk +201 -0
  49. package/moddable/xs/makefiles/mac/makefile +33 -0
  50. package/moddable/xs/makefiles/mac/xsc.mk +130 -0
  51. package/moddable/xs/makefiles/mac/xsid.mk +102 -0
  52. package/moddable/xs/makefiles/mac/xsl.mk +177 -0
  53. package/moddable/xs/makefiles/mac/xst.mk +203 -0
  54. package/moddable/xs/makefiles/mac/xst_no_asan.txt +52 -0
  55. package/moddable/xs/makefiles/win/build.bat +26 -0
  56. package/moddable/xs/makefiles/win/xsc.mak +142 -0
  57. package/moddable/xs/makefiles/win/xsid.mak +113 -0
  58. package/moddable/xs/makefiles/win/xsl.mak +186 -0
  59. package/moddable/xs/makefiles/win/xst.mak +195 -0
  60. package/moddable/xs/platforms/lin_xs.h +99 -0
  61. package/moddable/xs/platforms/mac_xs.h +97 -0
  62. package/moddable/xs/platforms/wasm_xs.h +79 -0
  63. package/moddable/xs/platforms/win_xs.h +104 -0
  64. package/moddable/xs/platforms/xsHost.h +63 -0
  65. package/moddable/xs/platforms/xsPlatform.h +618 -0
  66. package/moddable/xs/sources/xsAPI.c +2555 -0
  67. package/moddable/xs/sources/xsAll.c +294 -0
  68. package/moddable/xs/sources/xsAll.h +2741 -0
  69. package/moddable/xs/sources/xsArguments.c +222 -0
  70. package/moddable/xs/sources/xsArray.c +2657 -0
  71. package/moddable/xs/sources/xsAtomics.c +844 -0
  72. package/moddable/xs/sources/xsBigInt.c +1859 -0
  73. package/moddable/xs/sources/xsBoolean.c +109 -0
  74. package/moddable/xs/sources/xsCode.c +4493 -0
  75. package/moddable/xs/sources/xsCommon.c +1710 -0
  76. package/moddable/xs/sources/xsCommon.h +1142 -0
  77. package/moddable/xs/sources/xsDataView.c +2890 -0
  78. package/moddable/xs/sources/xsDate.c +1541 -0
  79. package/moddable/xs/sources/xsDebug.c +2710 -0
  80. package/moddable/xs/sources/xsDefaults.c +134 -0
  81. package/moddable/xs/sources/xsError.c +353 -0
  82. package/moddable/xs/sources/xsFunction.c +776 -0
  83. package/moddable/xs/sources/xsGenerator.c +865 -0
  84. package/moddable/xs/sources/xsGlobal.c +839 -0
  85. package/moddable/xs/sources/xsJSON.c +1091 -0
  86. package/moddable/xs/sources/xsLexical.c +1969 -0
  87. package/moddable/xs/sources/xsLockdown.c +933 -0
  88. package/moddable/xs/sources/xsMapSet.c +1649 -0
  89. package/moddable/xs/sources/xsMarshall.c +1020 -0
  90. package/moddable/xs/sources/xsMath.c +624 -0
  91. package/moddable/xs/sources/xsMemory.c +1941 -0
  92. package/moddable/xs/sources/xsModule.c +3101 -0
  93. package/moddable/xs/sources/xsNumber.c +560 -0
  94. package/moddable/xs/sources/xsObject.c +1102 -0
  95. package/moddable/xs/sources/xsPlatforms.c +480 -0
  96. package/moddable/xs/sources/xsProfile.c +577 -0
  97. package/moddable/xs/sources/xsPromise.c +1199 -0
  98. package/moddable/xs/sources/xsProperty.c +636 -0
  99. package/moddable/xs/sources/xsProxy.c +1014 -0
  100. package/moddable/xs/sources/xsRegExp.c +1168 -0
  101. package/moddable/xs/sources/xsRun.c +4889 -0
  102. package/moddable/xs/sources/xsScope.c +1293 -0
  103. package/moddable/xs/sources/xsScript.c +288 -0
  104. package/moddable/xs/sources/xsScript.h +1186 -0
  105. package/moddable/xs/sources/xsSnapshot.c +2161 -0
  106. package/moddable/xs/sources/xsSnapshot.h +51 -0
  107. package/moddable/xs/sources/xsSourceMap.c +218 -0
  108. package/moddable/xs/sources/xsString.c +3332 -0
  109. package/moddable/xs/sources/xsSymbol.c +503 -0
  110. package/moddable/xs/sources/xsSyntaxical.c +4193 -0
  111. package/moddable/xs/sources/xsTree.c +1893 -0
  112. package/moddable/xs/sources/xsType.c +1488 -0
  113. package/moddable/xs/sources/xsdtoa.c +6672 -0
  114. package/moddable/xs/sources/xsmc.c +340 -0
  115. package/moddable/xs/sources/xsre.c +7578 -0
  116. package/package.json +39 -22
  117. package/scripts/get_xsnap_version.sh +14 -0
  118. package/scripts/test-package.sh +21 -0
  119. package/src/avaAssertXS.js +6 -2
  120. package/src/avaHandler.cjs +2 -5
  121. package/src/avaXS.js +7 -8
  122. package/src/build.js +161 -28
  123. package/src/replay.js +0 -3
  124. package/src/xsnap.js +105 -91
  125. package/src/xsrepl.js +2 -3
  126. package/xsnap-native/xsnap/makefiles/lin/makefile +10 -0
  127. package/xsnap-native/xsnap/makefiles/lin/xsnap-worker.mk +156 -0
  128. package/xsnap-native/xsnap/makefiles/lin/xsnap.mk +144 -0
  129. package/xsnap-native/xsnap/makefiles/mac/makefile +10 -0
  130. package/xsnap-native/xsnap/makefiles/mac/xsnap-worker.mk +165 -0
  131. package/xsnap-native/xsnap/makefiles/mac/xsnap.mk +153 -0
  132. package/xsnap-native/xsnap/sources/xsnap-worker.c +1008 -0
  133. package/xsnap-native/xsnap/sources/xsnap.c +717 -0
  134. package/xsnap-native/xsnap/sources/xsnap.h +142 -0
  135. package/xsnap-native/xsnap/sources/xsnapPlatform.c +1501 -0
  136. package/xsnap-native/xsnap/sources/xsnapPlatform.h +105 -0
  137. package/CHANGELOG.md +0 -646
package/src/xsnap.js CHANGED
@@ -3,12 +3,12 @@
3
3
 
4
4
  /**
5
5
  * @typedef {typeof import('child_process').spawn} Spawn
6
- * @typedef {import('stream').Writable} Writable
6
+ * @import {Writable} from 'stream'
7
7
  */
8
8
 
9
9
  /**
10
10
  * @template T
11
- * @typedef {import('./defer').Deferred<T>} Deferred
11
+ * @typedef {import('./defer.js').Deferred<T>} Deferred
12
12
  */
13
13
 
14
14
  import { finished } from 'stream/promises';
@@ -55,6 +55,81 @@ function echoCommand(arg) {
55
55
  const safeHintFromDescription = description =>
56
56
  description.replaceAll(/[^a-zA-Z0-9_.-]/g, '-');
57
57
 
58
+ /**
59
+ * @typedef {object} SnapshotLoader
60
+ * @property {string} snapPath
61
+ * where XS can load the snapshot from, either a filesystem path or a string
62
+ * like `@${fileDescriptorNumber}:${readableDescription}`
63
+ * @property {(destStream?: Writable) => Promise<void>} afterSpawn
64
+ * callback for providing a destination stream to which the data should be
65
+ * piped (only relevant for a stream-based loader)
66
+ * @property {() => Promise<void>} cleanup
67
+ * callback to free resources when the loader is no longer needed
68
+ */
69
+
70
+ /**
71
+ * @callback MakeSnapshotLoader
72
+ * @param {AsyncIterable<Uint8Array>} sourceBytes
73
+ * @param {string} description
74
+ * @param {{fs: Pick<typeof import('fs/promises'), 'open' | 'unlink'>, ptmpName: (opts: import('tmp').TmpNameOptions) => Promise<string>}} ioPowers
75
+ * @returns {Promise<SnapshotLoader>}
76
+ */
77
+
78
+ /** @type {MakeSnapshotLoader} */
79
+ const makeSnapshotLoaderWithFS = async (
80
+ sourceBytes,
81
+ description,
82
+ { fs, ptmpName },
83
+ ) => {
84
+ const snapPath = await ptmpName({
85
+ template: `load-snapshot-${safeHintFromDescription(description)}-XXXXXX.xss`,
86
+ });
87
+
88
+ const afterSpawn = async () => {};
89
+ const cleanup = async () => fs.unlink(snapPath);
90
+
91
+ try {
92
+ const tmpSnap = await fs.open(snapPath, 'w');
93
+ // @ts-expect-error incorrect typings; writeFile does support AsyncIterable
94
+ await tmpSnap.writeFile(sourceBytes);
95
+ await tmpSnap.close();
96
+ } catch (e) {
97
+ await cleanup();
98
+ throw e;
99
+ }
100
+
101
+ return harden({
102
+ snapPath,
103
+ afterSpawn,
104
+ cleanup,
105
+ });
106
+ };
107
+
108
+ /** @type {MakeSnapshotLoader} */
109
+ const makeSnapshotLoaderWithPipe = async (
110
+ sourceBytes,
111
+ description,
112
+ _ioPowers,
113
+ ) => {
114
+ let done = Promise.resolve();
115
+
116
+ const cleanup = async () => done;
117
+
118
+ const afterSpawn = async destStream => {
119
+ const sourceStream = Readable.from(sourceBytes);
120
+ sourceStream.pipe(destStream, { end: false });
121
+
122
+ done = finished(sourceStream);
123
+ void done.catch(noop).then(() => sourceStream.unpipe(destStream));
124
+ };
125
+
126
+ return harden({
127
+ snapPath: `@${SNAPSHOT_LOAD_FD}:${safeHintFromDescription(description)}`,
128
+ afterSpawn,
129
+ cleanup,
130
+ });
131
+ };
132
+
58
133
  /**
59
134
  * @param {XSnapOptions} options
60
135
  *
@@ -86,7 +161,7 @@ export async function xsnap(options) {
86
161
  netstringMaxChunkSize = undefined,
87
162
  parserBufferSize = undefined,
88
163
  snapshotStream,
89
- snapshotDescription = snapshotStream && 'unknown',
164
+ snapshotDescription = 'unknown',
90
165
  snapshotUseFs = false,
91
166
  stdout = 'ignore',
92
167
  stderr = 'ignore',
@@ -97,76 +172,13 @@ export async function xsnap(options) {
97
172
  const platform = {
98
173
  Linux: 'lin',
99
174
  Darwin: 'mac',
100
- Windows_NT: 'win',
175
+ // Windows_NT: 'win', // One can dream.
101
176
  }[os];
102
177
 
103
178
  if (platform === undefined) {
104
179
  throw Error(`xsnap does not support platform ${os}`);
105
180
  }
106
181
 
107
- /** @type {(opts: import('tmp').TmpNameOptions) => Promise<string>} */
108
- const ptmpName = fs.tmpName && promisify(fs.tmpName);
109
-
110
- const makeLoadSnapshotHandlerWithFS = async () => {
111
- assert(snapshotStream);
112
- const snapPath = await ptmpName({
113
- template: `load-snapshot-${safeHintFromDescription(
114
- snapshotDescription,
115
- )}-XXXXXX.xss`,
116
- });
117
-
118
- const afterSpawn = async () => {};
119
- const cleanup = async () => fs.unlink(snapPath);
120
-
121
- try {
122
- // eslint-disable-next-line @jessie.js/no-nested-await
123
- const tmpSnap = await fs.open(snapPath, 'w');
124
- // eslint-disable-next-line @jessie.js/no-nested-await
125
- await tmpSnap.writeFile(
126
- // @ts-expect-error incorrect typings, does support AsyncIterable
127
- snapshotStream,
128
- );
129
- // eslint-disable-next-line @jessie.js/no-nested-await
130
- await tmpSnap.close();
131
- } catch (e) {
132
- // eslint-disable-next-line @jessie.js/no-nested-await
133
- await cleanup();
134
- throw e;
135
- }
136
-
137
- return harden({
138
- snapPath,
139
- afterSpawn,
140
- cleanup,
141
- });
142
- };
143
-
144
- const makeLoadSnapshotHandlerWithPipe = async () => {
145
- let done = Promise.resolve();
146
-
147
- const cleanup = async () => done;
148
-
149
- /** @param {Writable} loadSnapshotsStream */
150
- const afterSpawn = async loadSnapshotsStream => {
151
- assert(snapshotStream);
152
- const destStream = loadSnapshotsStream;
153
-
154
- const sourceStream = Readable.from(snapshotStream);
155
- sourceStream.pipe(destStream, { end: false });
156
-
157
- done = finished(sourceStream);
158
- done.catch(noop).then(() => sourceStream.unpipe(destStream));
159
- };
160
-
161
- return harden({
162
- snapPath: `@${SNAPSHOT_LOAD_FD}:${safeHintFromDescription(
163
- snapshotDescription,
164
- )}`,
165
- afterSpawn,
166
- cleanup,
167
- });
168
- };
169
-
170
182
  let bin = new URL(
171
183
  `../xsnap-native/xsnap/build/bin/${platform}/${
172
184
  debug ? 'debug' : 'release'
@@ -179,15 +191,18 @@ export async function xsnap(options) {
179
191
 
180
192
  assert(!/^-/.test(name), `name '${name}' cannot start with hyphen`);
181
193
 
182
- let loadSnapshotHandler = await (snapshotStream &&
183
- (snapshotUseFs
184
- ? makeLoadSnapshotHandlerWithFS
185
- : makeLoadSnapshotHandlerWithPipe)());
194
+ /** @type {(opts: import('tmp').TmpNameOptions) => Promise<string>} */
195
+ const ptmpName = fs.tmpName && promisify(fs.tmpName);
196
+ const makeSnapshotLoader = snapshotUseFs
197
+ ? makeSnapshotLoaderWithFS
198
+ : makeSnapshotLoaderWithPipe;
199
+ let snapshotLoader = await (snapshotStream &&
200
+ makeSnapshotLoader(snapshotStream, snapshotDescription, { fs, ptmpName }));
186
201
 
187
202
  let args = [name];
188
203
 
189
- if (loadSnapshotHandler) {
190
- args.push('-r', loadSnapshotHandler.snapPath);
204
+ if (snapshotLoader) {
205
+ args.push('-r', snapshotLoader.snapPath);
191
206
  }
192
207
 
193
208
  if (meteringLimit) {
@@ -258,13 +273,13 @@ export async function xsnap(options) {
258
273
  const snapshotSaveStream = xsnapProcessStdio[SNAPSHOT_SAVE_FD];
259
274
  const snapshotLoadStream = xsnapProcessStdio[SNAPSHOT_LOAD_FD];
260
275
 
261
- await loadSnapshotHandler?.afterSpawn(snapshotLoadStream);
276
+ await snapshotLoader?.afterSpawn(snapshotLoadStream);
262
277
 
263
- if (loadSnapshotHandler) {
264
- vatExit.promise.catch(noop).then(() => {
265
- if (loadSnapshotHandler) {
266
- const { cleanup } = loadSnapshotHandler;
267
- loadSnapshotHandler = undefined;
278
+ if (snapshotLoader) {
279
+ void vatExit.promise.catch(noop).then(() => {
280
+ if (snapshotLoader) {
281
+ const { cleanup } = snapshotLoader;
282
+ snapshotLoader = undefined;
268
283
  return cleanup();
269
284
  }
270
285
  });
@@ -286,10 +301,9 @@ export async function xsnap(options) {
286
301
  async function runToIdle() {
287
302
  for await (const _ of forever) {
288
303
  const iteration = await messagesFromXsnap.next(undefined);
289
- if (loadSnapshotHandler) {
290
- const { cleanup } = loadSnapshotHandler;
291
- loadSnapshotHandler = undefined;
292
- // eslint-disable-next-line @jessie.js/no-nested-await
304
+ if (snapshotLoader) {
305
+ const { cleanup } = snapshotLoader;
306
+ snapshotLoader = undefined;
293
307
  await cleanup();
294
308
  }
295
309
  if (iteration.done) {
@@ -328,9 +342,7 @@ export async function xsnap(options) {
328
342
  )}`,
329
343
  );
330
344
  } else if (message[0] === QUERY) {
331
- // eslint-disable-next-line @jessie.js/no-nested-await
332
345
  const commandResult = await handleCommand(message.subarray(1));
333
- // eslint-disable-next-line @jessie.js/no-nested-await
334
346
  await messagesToXsnap.next([QUERY_RESPONSE_BUF, commandResult]);
335
347
  } else {
336
348
  // unrecognized responses also kill the process
@@ -429,6 +441,7 @@ export async function xsnap(options) {
429
441
  let snapshotReadSize = 0;
430
442
  /** @type {number | undefined} */
431
443
  let snapshotSize;
444
+ await null;
432
445
  try {
433
446
  /** @type {string} */
434
447
  let snapPath;
@@ -444,7 +457,6 @@ export async function xsnap(options) {
444
457
 
445
458
  if (snapshotUseFs) {
446
459
  // TODO: Refactor to use tmpFile rather than tmpName.
447
- // eslint-disable-next-line @jessie.js/no-nested-await
448
460
  snapPath = await ptmpName({
449
461
  template: `make-snapshot-${safeHintFromDescription(
450
462
  description,
@@ -461,14 +473,16 @@ export async function xsnap(options) {
461
473
  // then wait for the command response to pipe the file stream into the
462
474
  // output, causing the file read to begin.
463
475
 
464
- // eslint-disable-next-line @jessie.js/no-nested-await
465
476
  const handle = await fs.open(snapPath, 'w+');
466
477
  // @ts-expect-error 'close' event added in Node 15.4
467
478
  handle.on('close', () => {
468
- fs.unlink(snapPath);
479
+ // Safe to ignore the result because we are skipping to to clean up the temp directory.
480
+ void fs.unlink(snapPath);
469
481
  });
470
482
  sourceStream = handle.createReadStream();
471
- finished(output).finally(() => sourceStream.destroy());
483
+ finished(output)
484
+ .finally(() => sourceStream.destroy())
485
+ .catch(noop);
472
486
  } else {
473
487
  sourceStream = snapshotSaveStream;
474
488
  snapPath = `@${SNAPSHOT_SAVE_FD}`;
@@ -477,7 +491,7 @@ export async function xsnap(options) {
477
491
  // ensuring that any previous save stream usage has ended. However we
478
492
  // must start the flow before receiving the command's response or the
479
493
  // xsnap process would block on a full pipe, causing an IPC deadlock.
480
- batonKit.promise.then(maybePipe);
494
+ batonKit.promise.then(maybePipe, noop);
481
495
  }
482
496
 
483
497
  const cleanup = () => {
@@ -522,7 +536,6 @@ export async function xsnap(options) {
522
536
 
523
537
  yield* output;
524
538
  } finally {
525
- // eslint-disable-next-line @jessie.js/no-nested-await
526
539
  await done;
527
540
  (piped && snapshotReadSize === snapshotSize) ||
528
541
  Fail`Snapshot size does not match. saved=${q(snapshotSize)}, read=${q(
@@ -530,6 +543,7 @@ export async function xsnap(options) {
530
543
  )}`;
531
544
  }
532
545
  }
546
+ harden(makeSnapshotInternal);
533
547
 
534
548
  /**
535
549
  * @param {string} [description]
package/src/xsrepl.js CHANGED
@@ -1,13 +1,12 @@
1
1
  /* global process */
2
2
  /* We make exceptions for test code. This is a test utility. */
3
- /* eslint-disable @jessie.js/no-nested-await */
4
3
  /* eslint no-await-in-loop: ["off"] */
5
4
 
6
5
  import '@endo/init';
7
6
 
8
7
  /**
9
8
  * @template T
10
- * @typedef {import('./defer').Deferred<T>} Deferred
9
+ * @typedef {import('./defer.js').Deferred<T>} Deferred
11
10
  */
12
11
  import * as childProcess from 'child_process';
13
12
  import fs from 'fs';
@@ -97,4 +96,4 @@ async function main() {
97
96
  return vat.close();
98
97
  }
99
98
 
100
- main();
99
+ await main().catch(err => console.log(err));
@@ -0,0 +1,10 @@
1
+ .NOTPARALLEL:
2
+
3
+ all: debug release
4
+
5
+ debug:
6
+ make -f xsnap.mk
7
+
8
+ release:
9
+ make GOAL=release -f xsnap.mk
10
+
@@ -0,0 +1,156 @@
1
+ % : %.c
2
+ %.o : %.c
3
+
4
+ GOAL ?= debug
5
+ NAME = xsnap-worker
6
+ ifneq ($(VERBOSE),1)
7
+ MAKEFLAGS += --silent
8
+ endif
9
+
10
+ EXTRA_DEPS =
11
+
12
+ # MODDABLE = $(CURDIR)/../../moddable
13
+ BUILD_DIR = $(CURDIR)/../../build
14
+ TLS_DIR = $(CURDIR)/../../sources
15
+
16
+ # BUILD_DIR = $(MODDABLE)/build
17
+ # TLS_DIR = ../../sources
18
+
19
+ XS_DIR = $(MODDABLE)/xs
20
+
21
+ BIN_DIR = $(BUILD_DIR)/bin/lin/$(GOAL)
22
+ INC_DIR = $(XS_DIR)/includes
23
+ PLT_DIR = $(XS_DIR)/platforms
24
+ SRC_DIR = $(XS_DIR)/sources
25
+ TMP_DIR = $(BUILD_DIR)/tmp/lin/$(GOAL)/$(NAME)
26
+
27
+ C_OPTIONS = \
28
+ -fno-common \
29
+ -DINCLUDE_XSPLATFORM \
30
+ -DXSPLATFORM=\"xsnapPlatform.h\" \
31
+ -DXSNAP_VERSION=\"$(XSNAP_VERSION)\" \
32
+ -DXSNAP_TEST_RECORD=0 \
33
+ -DmxLockdown=1 \
34
+ -DmxMetering=1 \
35
+ -DmxDebug=1 \
36
+ -UmxInstrument \
37
+ -DmxNoConsole=1 \
38
+ -DmxBoundsCheck=1 \
39
+ -DmxParse=1 \
40
+ -DmxRun=1 \
41
+ -DmxSloppy=1 \
42
+ -DmxSnapshot=1 \
43
+ -DmxRegExpUnicodePropertyEscapes=1 \
44
+ -DmxStringNormalize=1 \
45
+ -DmxMinusZero=1 \
46
+ -I$(INC_DIR) \
47
+ -I$(PLT_DIR) \
48
+ -I$(SRC_DIR) \
49
+ -I$(TLS_DIR) \
50
+ -I$(TMP_DIR)
51
+ C_OPTIONS += \
52
+ -Wno-misleading-indentation \
53
+ -Wno-implicit-fallthrough
54
+ ifeq ($(GOAL),debug)
55
+ C_OPTIONS += -g -O0 -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter
56
+ else
57
+ C_OPTIONS += -O3
58
+ endif
59
+
60
+ LIBRARIES = -ldl -lm -lpthread
61
+
62
+ ifeq ($(XSNAP_RANDOM_INIT),1)
63
+ LIBRARIES += -lbsd
64
+ C_OPTIONS += -DmxSnapshotRandomInit
65
+ endif
66
+
67
+ LINK_OPTIONS = -rdynamic
68
+
69
+ OBJECTS = \
70
+ $(TMP_DIR)/xsAll.o \
71
+ $(TMP_DIR)/xsAPI.o \
72
+ $(TMP_DIR)/xsArguments.o \
73
+ $(TMP_DIR)/xsArray.o \
74
+ $(TMP_DIR)/xsAtomics.o \
75
+ $(TMP_DIR)/xsBigInt.o \
76
+ $(TMP_DIR)/xsBoolean.o \
77
+ $(TMP_DIR)/xsCode.o \
78
+ $(TMP_DIR)/xsCommon.o \
79
+ $(TMP_DIR)/xsDataView.o \
80
+ $(TMP_DIR)/xsDate.o \
81
+ $(TMP_DIR)/xsDebug.o \
82
+ $(TMP_DIR)/xsDefaults.o \
83
+ $(TMP_DIR)/xsError.o \
84
+ $(TMP_DIR)/xsFunction.o \
85
+ $(TMP_DIR)/xsGenerator.o \
86
+ $(TMP_DIR)/xsGlobal.o \
87
+ $(TMP_DIR)/xsJSON.o \
88
+ $(TMP_DIR)/xsLexical.o \
89
+ $(TMP_DIR)/xsLockdown.o \
90
+ $(TMP_DIR)/xsMapSet.o \
91
+ $(TMP_DIR)/xsMarshall.o \
92
+ $(TMP_DIR)/xsMath.o \
93
+ $(TMP_DIR)/xsMemory.o \
94
+ $(TMP_DIR)/xsModule.o \
95
+ $(TMP_DIR)/xsNumber.o \
96
+ $(TMP_DIR)/xsObject.o \
97
+ $(TMP_DIR)/xsPlatforms.o \
98
+ $(TMP_DIR)/xsProfile.o \
99
+ $(TMP_DIR)/xsPromise.o \
100
+ $(TMP_DIR)/xsProperty.o \
101
+ $(TMP_DIR)/xsProxy.o \
102
+ $(TMP_DIR)/xsRegExp.o \
103
+ $(TMP_DIR)/xsRun.o \
104
+ $(TMP_DIR)/xsScope.o \
105
+ $(TMP_DIR)/xsScript.o \
106
+ $(TMP_DIR)/xsSnapshot.o \
107
+ $(TMP_DIR)/xsSourceMap.o \
108
+ $(TMP_DIR)/xsString.o \
109
+ $(TMP_DIR)/xsSymbol.o \
110
+ $(TMP_DIR)/xsSyntaxical.o \
111
+ $(TMP_DIR)/xsTree.o \
112
+ $(TMP_DIR)/xsType.o \
113
+ $(TMP_DIR)/xsdtoa.o \
114
+ $(TMP_DIR)/xsre.o \
115
+ $(TMP_DIR)/xsmc.o \
116
+ $(TMP_DIR)/textdecoder.o \
117
+ $(TMP_DIR)/textencoder.o \
118
+ $(TMP_DIR)/modBase64.o \
119
+ $(TMP_DIR)/xsnapPlatform.o \
120
+ $(TMP_DIR)/xsnap-worker.o
121
+
122
+ VPATH += $(SRC_DIR) $(TLS_DIR)
123
+ VPATH += $(MODDABLE)/modules/data/text/decoder
124
+ VPATH += $(MODDABLE)/modules/data/text/encoder
125
+ VPATH += $(MODDABLE)/modules/data/base64
126
+
127
+ build: $(TMP_DIR) $(BIN_DIR) $(BIN_DIR)/$(NAME)
128
+
129
+ $(TMP_DIR):
130
+ mkdir -p $(TMP_DIR)
131
+
132
+ $(BIN_DIR):
133
+ mkdir -p $(BIN_DIR)
134
+
135
+ $(BIN_DIR)/$(NAME): $(OBJECTS)
136
+ @echo "#" $(NAME) $(GOAL) ": cc" $(@F)
137
+ $(CC) $(LINK_OPTIONS) $(OBJECTS) $(LIBRARIES) -o $@
138
+
139
+ $(OBJECTS): $(TLS_DIR)/xsnap.h
140
+ $(OBJECTS): $(TLS_DIR)/xsnapPlatform.h
141
+ $(OBJECTS): $(PLT_DIR)/xsPlatform.h
142
+ $(OBJECTS): $(SRC_DIR)/xsCommon.h
143
+ $(OBJECTS): $(SRC_DIR)/xsAll.h
144
+ $(OBJECTS): $(SRC_DIR)/xsScript.h
145
+ $(OBJECTS): $(SRC_DIR)/xsSnapshot.h
146
+ $(OBJECTS): $(INC_DIR)/xs.h
147
+ $(OBJECTS): $(EXTRA_DEPS)
148
+ $(TMP_DIR)/%.o: %.c
149
+ @echo "#" $(NAME) $(GOAL) ": cc" $(<F)
150
+ $(CC) $< $(C_OPTIONS) -c -o $@
151
+
152
+ clean:
153
+ rm -rf $(BUILD_DIR)/bin/lin/debug/$(NAME)
154
+ rm -rf $(BUILD_DIR)/bin/lin/release/$(NAME)
155
+ rm -rf $(BUILD_DIR)/tmp/lin/debug/$(NAME)
156
+ rm -rf $(BUILD_DIR)/tmp/lin/release/$(NAME)
@@ -0,0 +1,144 @@
1
+ % : %.c
2
+ %.o : %.c
3
+
4
+ GOAL ?= debug
5
+ NAME = xsnap
6
+ ifneq ($(VERBOSE),1)
7
+ MAKEFLAGS += --silent
8
+ endif
9
+
10
+ BUILD_DIR = $(MODDABLE)/build
11
+ TLS_DIR = ../../sources
12
+
13
+ XS_DIR = $(MODDABLE)/xs
14
+
15
+ BIN_DIR = $(BUILD_DIR)/bin/lin/$(GOAL)
16
+ INC_DIR = $(XS_DIR)/includes
17
+ PLT_DIR = $(XS_DIR)/platforms
18
+ SRC_DIR = $(XS_DIR)/sources
19
+ TMP_DIR = $(BUILD_DIR)/tmp/lin/$(GOAL)/$(NAME)
20
+
21
+ C_OPTIONS = \
22
+ -fno-common \
23
+ -DINCLUDE_XSPLATFORM \
24
+ -DXSPLATFORM=\"xsnapPlatform.h\" \
25
+ -DmxLockdown=1 \
26
+ -DmxMetering=1 \
27
+ -DmxParse=1 \
28
+ -DmxProfile=1 \
29
+ -DmxRun=1 \
30
+ -DmxSloppy=1 \
31
+ -DmxSnapshot=1 \
32
+ -DmxRegExpUnicodePropertyEscapes=1 \
33
+ -DmxStringNormalize=1 \
34
+ -DmxMinusZero=1 \
35
+ -I$(INC_DIR) \
36
+ -I$(PLT_DIR) \
37
+ -I$(SRC_DIR) \
38
+ -I$(TLS_DIR) \
39
+ -I$(TMP_DIR)
40
+ C_OPTIONS += \
41
+ -Wno-misleading-indentation \
42
+ -Wno-implicit-fallthrough
43
+ ifeq ($(GOAL),debug)
44
+ C_OPTIONS += -DmxDebug=1 -g -O0 -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter
45
+ else
46
+ C_OPTIONS += -DmxBoundsCheck=1 -O3
47
+ endif
48
+
49
+ LIBRARIES = -ldl -lm -lpthread
50
+
51
+ ifeq ($(XSNAP_RANDOM_INIT),1)
52
+ LIBRARIES += -lbsd
53
+ C_OPTIONS += -DmxSnapshotRandomInit
54
+ endif
55
+
56
+ LINK_OPTIONS = -rdynamic
57
+
58
+ OBJECTS = \
59
+ $(TMP_DIR)/xsAll.o \
60
+ $(TMP_DIR)/xsAPI.o \
61
+ $(TMP_DIR)/xsArguments.o \
62
+ $(TMP_DIR)/xsArray.o \
63
+ $(TMP_DIR)/xsAtomics.o \
64
+ $(TMP_DIR)/xsBigInt.o \
65
+ $(TMP_DIR)/xsBoolean.o \
66
+ $(TMP_DIR)/xsCode.o \
67
+ $(TMP_DIR)/xsCommon.o \
68
+ $(TMP_DIR)/xsDataView.o \
69
+ $(TMP_DIR)/xsDate.o \
70
+ $(TMP_DIR)/xsDebug.o \
71
+ $(TMP_DIR)/xsDefaults.o \
72
+ $(TMP_DIR)/xsError.o \
73
+ $(TMP_DIR)/xsFunction.o \
74
+ $(TMP_DIR)/xsGenerator.o \
75
+ $(TMP_DIR)/xsGlobal.o \
76
+ $(TMP_DIR)/xsJSON.o \
77
+ $(TMP_DIR)/xsLexical.o \
78
+ $(TMP_DIR)/xsLockdown.o \
79
+ $(TMP_DIR)/xsMapSet.o \
80
+ $(TMP_DIR)/xsMarshall.o \
81
+ $(TMP_DIR)/xsMath.o \
82
+ $(TMP_DIR)/xsMemory.o \
83
+ $(TMP_DIR)/xsModule.o \
84
+ $(TMP_DIR)/xsNumber.o \
85
+ $(TMP_DIR)/xsObject.o \
86
+ $(TMP_DIR)/xsPlatforms.o \
87
+ $(TMP_DIR)/xsProfile.o \
88
+ $(TMP_DIR)/xsPromise.o \
89
+ $(TMP_DIR)/xsProperty.o \
90
+ $(TMP_DIR)/xsProxy.o \
91
+ $(TMP_DIR)/xsRegExp.o \
92
+ $(TMP_DIR)/xsRun.o \
93
+ $(TMP_DIR)/xsScope.o \
94
+ $(TMP_DIR)/xsScript.o \
95
+ $(TMP_DIR)/xsSnapshot.o \
96
+ $(TMP_DIR)/xsSourceMap.o \
97
+ $(TMP_DIR)/xsString.o \
98
+ $(TMP_DIR)/xsSymbol.o \
99
+ $(TMP_DIR)/xsSyntaxical.o \
100
+ $(TMP_DIR)/xsTree.o \
101
+ $(TMP_DIR)/xsType.o \
102
+ $(TMP_DIR)/xsdtoa.o \
103
+ $(TMP_DIR)/xsre.o \
104
+ $(TMP_DIR)/xsmc.o \
105
+ $(TMP_DIR)/textdecoder.o \
106
+ $(TMP_DIR)/textencoder.o \
107
+ $(TMP_DIR)/modBase64.o \
108
+ $(TMP_DIR)/xsnapPlatform.o \
109
+ $(TMP_DIR)/xsnap.o
110
+
111
+ VPATH += $(SRC_DIR) $(TLS_DIR)
112
+ VPATH += $(MODDABLE)/modules/data/text/decoder
113
+ VPATH += $(MODDABLE)/modules/data/text/encoder
114
+ VPATH += $(MODDABLE)/modules/data/base64
115
+
116
+ build: $(TMP_DIR) $(BIN_DIR) $(BIN_DIR)/$(NAME)
117
+
118
+ $(TMP_DIR):
119
+ mkdir -p $(TMP_DIR)
120
+
121
+ $(BIN_DIR):
122
+ mkdir -p $(BIN_DIR)
123
+
124
+ $(BIN_DIR)/$(NAME): $(OBJECTS)
125
+ @echo "#" $(NAME) $(GOAL) ": cc" $(@F)
126
+ $(CC) $(LINK_OPTIONS) $(OBJECTS) $(LIBRARIES) -o $@
127
+
128
+ $(OBJECTS): $(TLS_DIR)/xsnap.h
129
+ $(OBJECTS): $(TLS_DIR)/xsnapPlatform.h
130
+ $(OBJECTS): $(PLT_DIR)/xsPlatform.h
131
+ $(OBJECTS): $(SRC_DIR)/xsCommon.h
132
+ $(OBJECTS): $(SRC_DIR)/xsAll.h
133
+ $(OBJECTS): $(SRC_DIR)/xsScript.h
134
+ $(OBJECTS): $(SRC_DIR)/xsSnapshot.h
135
+ $(OBJECTS): $(INC_DIR)/xs.h
136
+ $(TMP_DIR)/%.o: %.c
137
+ @echo "#" $(NAME) $(GOAL) ": cc" $(<F)
138
+ $(CC) $< $(C_OPTIONS) -c -o $@
139
+
140
+ clean:
141
+ rm -rf $(BUILD_DIR)/bin/lin/debug/$(NAME)
142
+ rm -rf $(BUILD_DIR)/bin/lin/release/$(NAME)
143
+ rm -rf $(BUILD_DIR)/tmp/lin/debug/$(NAME)
144
+ rm -rf $(BUILD_DIR)/tmp/lin/release/$(NAME)
@@ -0,0 +1,10 @@
1
+ .NOTPARALLEL:
2
+
3
+ all: debug release
4
+
5
+ debug:
6
+ make -f xsnap.mk
7
+
8
+ release:
9
+ make GOAL=release -f xsnap.mk
10
+