Skip to content

Commit

Permalink
feat(xs-vat-worker): locateWorkerBin finds built executable
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Aug 25, 2020
1 parent 29406ad commit aecaeb1
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 10 deletions.
5 changes: 3 additions & 2 deletions packages/SwingSet/src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { importBundle } from '@agoric/import-bundle';
import { initSwingStore } from '@agoric/swing-store-simple';
import { makeMeteringTransformer } from '@agoric/transform-metering';
import { makeTransform } from '@agoric/transform-eventual-send';
import { xsWorkerBin } from '@agoric/xs-vat-worker';
import { locateWorkerBin } from '@agoric/xs-vat-worker';

import { startSubprocessWorker } from './spawnSubprocessWorker';
import { assertKnownOptions } from './assertOptions';
Expand Down Expand Up @@ -322,7 +322,8 @@ export async function buildVatController(
// console.log(`--slog ${JSON.stringify(obj)}`);
}

const startXsWorker = xsWorkerBin
const xsWorkerBin = locateWorkerBin({ resolve: path.resolve });
const startXsWorker = fs.existsSync(xsWorkerBin)
? () => startSubprocessWorker(xsWorkerBin, [])
: undefined;

Expand Down
9 changes: 6 additions & 3 deletions packages/SwingSet/test/workers/test-worker.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import '@agoric/install-ses';
import test from 'ava';
import { xsWorkerBin } from '@agoric/xs-vat-worker/src/locate';
import { resolve } from 'path';
import { existsSync } from 'fs';
import { locateWorkerBin } from '@agoric/xs-vat-worker';
import { loadBasedir, buildVatController } from '../../src/index';

test('xs vat manager', async t => {
if (!xsWorkerBin) {
console.warn('XS vat worker not built; skipping');
const bin = locateWorkerBin({ resolve });
if (!existsSync(bin)) {
console.warn(`XS vat worker ${bin} not built; skipping`);
t.falsy.skip(false);
return;
}
Expand Down
1 change: 0 additions & 1 deletion packages/xs-vat-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"main": "src/locate.js",
"module": "src/locate.js",
"scripts": {
"postinstall": "cp src/locate-undefined.js src/locate.js",
"build:xs-lin": "make -f xs-lin.mk",
"test": "tape -r esm 'test/**/test-*.js'",
"build": "exit 0",
Expand Down
1 change: 0 additions & 1 deletion packages/xs-vat-worker/src/locate-undefined.js

This file was deleted.

15 changes: 15 additions & 0 deletions packages/xs-vat-worker/src/locate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Locate the XS vat worker executable.
*
* Note: executable is not built by default.
* @see the `build:xs-lin` script in package.json
*
* @param {{ resolve: (...string) => string }} filesystem path access
* @returns { string } full path where linux debug executable is built;
* not guaranteed to exist.
*/
export function locateWorkerBin({ resolve }) {
const goal = 'debug'; // ISSUE: support, test release too?
const os = 'lin'; // ISSUE: support, test mac too?
return resolve(__dirname, '../build/bin', os, goal, 'xs-vat-worker');
}
8 changes: 6 additions & 2 deletions packages/xs-vat-worker/test/test-locate.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { resolve } from 'path';

import { test } from 'tape-promise/tape';

import { xsWorkerBin } from '../src/locate';
import { locateWorkerBin } from '../src/locate';

test('locateWorkerBin', t => {
t.ok(!xsWorkerBin || xsWorkerBin.endsWith('xs-vat-worker'));
const bin = locateWorkerBin({ resolve });
t.ok(bin.startsWith('/'));
t.ok(bin.endsWith('/xs-vat-worker'));
t.end();
});
1 change: 0 additions & 1 deletion packages/xs-vat-worker/xs-lin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ ROOT=$(PWD)/../..

$(NODE_MODULES)/.bin/xs-vat-worker: build/bin/lin/debug/xs-vat-worker
cp $< $@
echo "export const xsWorkerBin =\n '$@';" >src/locate.js

build/bin/lin/debug/xs-vat-worker: build $(TOOLS)/mcconfig moddable/xs/platforms/lin_xs_cli.c compartmap.json manifest.json
ROOT=$(ROOT) PATH=$(TOOLS):$$PATH MODDABLE=$(MODDABLE) mcconfig -o build -p x-cli-lin -m -d
Expand Down

0 comments on commit aecaeb1

Please sign in to comment.