Skip to content

Commit

Permalink
Merge pull request #9122 from Agoric/kriskowal-revert-expedite-xsnap-…
Browse files Browse the repository at this point in the history
…build

fix(xsnap): Revert failed attempt to expedite xsnap builds
  • Loading branch information
mergify[bot] committed Mar 20, 2024
2 parents b047af2 + e37d357 commit 2a16ddd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 92 deletions.
13 changes: 3 additions & 10 deletions packages/xsnap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"scripts": {
"repl": "node src/xsrepl.js",
"build:bin": "if test -d ./test; then node src/build.js; else yarn build:from-env; fi",
"build:env": "if test -d ./test; then node src/build.js --show-env > build.env; fi",
"build:env": "test -d ./test && node src/build.js --show-env > build.env",
"build:from-env": "{ cat build.env; echo node src/build.js; } | xargs env",
"build": "yarn build:bin && yarn build:env",
"postinstall": "node src/build.js",
"postinstall": "yarn build:from-env",
"clean": "rm -rf xsnap-native/xsnap/build",
"lint": "run-s --continue-on-error lint:*",
"lint:js": "eslint 'src/**/*.js' 'test/**/*.js' api.js",
Expand Down Expand Up @@ -50,14 +50,7 @@
"LICENSE*",
"api.js",
"build.env",
"moddable/modules/data",
"moddable/xs/includes",
"moddable/xs/makefiles",
"moddable/xs/platforms/*.h",
"moddable/xs/sources",
"src",
"xsnap-native/xsnap/makefiles",
"xsnap-native/xsnap/sources"
"src"
],
"publishConfig": {
"access": "public"
Expand Down
21 changes: 0 additions & 21 deletions packages/xsnap/scripts/test-package.sh

This file was deleted.

65 changes: 4 additions & 61 deletions packages/xsnap/src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,12 @@ const makeSubmodule = (path, repoUrl, { git }) => {
* rmdirSync: typeof import('fs').rmdirSync,
* readFile: typeof import('fs').promises.readFile,
* },
* os: {
* type: typeof import('os').type,
* }
* }} io
*/
const updateSubmodules = async (args, { env, stdout, spawn, fs }) => {
async function main(args, { env, stdout, spawn, fs, os }) {
const git = makeCLI('git', { spawn });

// When changing/adding entries here, make sure to search the whole project
Expand Down Expand Up @@ -211,22 +214,7 @@ const updateSubmodules = async (args, { env, stdout, spawn, fs }) => {
await submodule.init();
}
}
};

/**
* @param {{
* spawn: typeof import('child_process').spawn,
* fs: {
* existsSync: typeof import('fs').existsSync,
* rmdirSync: typeof import('fs').rmdirSync,
* readFile: typeof import('fs').promises.readFile,
* },
* os: {
* type: typeof import('os').type,
* }
* }} io
*/
const makeXsnap = async ({ spawn, fs, os }) => {
const pjson = await fs.readFile(asset('../package.json'), 'utf-8');
const pkg = JSON.parse(pjson);

Expand All @@ -251,51 +239,6 @@ const makeXsnap = async ({ spawn, fs, os }) => {
},
);
}
};

/**
* @param {string[]} args
* @param {{
* env: Record<string, string | undefined>,
* stdout: typeof process.stdout,
* spawn: typeof import('child_process').spawn,
* fs: {
* existsSync: typeof import('fs').existsSync,
* rmdirSync: typeof import('fs').rmdirSync,
* readFile: typeof import('fs').promises.readFile,
* },
* os: {
* type: typeof import('os').type,
* }
* }} io
*/
async function main(args, { env, stdout, spawn, fs, os }) {
// I solemnly swear I will do no synchronous work followed by a variable
// number turns of the event loop.
await null;

// If this is a working copy of xsnap in a checkout of agoric-sdk, we need to
// either clone or update submodules.
// Otherwise, we are running from an extracted npm tarball in a dependent
// package's node_modules, in which case we should just `make` with the
// `moddable` directory provided by npm.
// This will avoid rebuilding native xsnap in the common case for end users.
//
// | moddable/ | moddable/.git | working copy |
// | --------- | ------------- | ------------ |
// | ABSENT | ABSENT | YES |
// | ABSENT | EXISTS | * |
// | EXISTS | ABSENT | NO |
// | EXISTS | EXISTS | YES |
//
// We short-circuit after a single stat if moddable/.git exists because that
// implies that moddable/ exists.
const isWorkingCopy =
fs.existsSync('moddable/.git') || !fs.existsSync('moddable');
if (isWorkingCopy) {
await updateSubmodules(args, { env, stdout, spawn, fs });
}
await makeXsnap({ spawn, fs, os });
}

const run = () =>
Expand Down

0 comments on commit 2a16ddd

Please sign in to comment.