Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
experimental option --no-bytecode for cross-cpu packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
igorklopov committed Jun 23, 2017
1 parent 99fc006 commit a216876
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
24 changes: 16 additions & 8 deletions lib/index.js
Expand Up @@ -116,10 +116,11 @@ async function needViaCache (target) {

export async function exec (argv2) { // eslint-disable-line complexity
const argv = minimist(argv2, {
boolean: [ 'b', 'build', 'd', 'debug', 'h', 'help',
'v', 'version' ],
boolean: [ 'b', 'build', 'bytecode', 'd', 'debug',
'h', 'help', 'v', 'version' ],
string: [ '_', 'c', 'config', 'o', 'options', 'output',
'outdir', 'out-dir', 'out-path', 't', 'target', 'targets' ]
'outdir', 'out-dir', 'out-path', 't', 'target', 'targets' ],
default: { bytecode: true }
});

if (argv.h || argv.help) {
Expand Down Expand Up @@ -262,6 +263,7 @@ export async function exec (argv2) { // eslint-disable-line complexity
// targets

const sTargets = argv.t || argv.target || argv.targets || '';

if (typeof sTargets !== 'string') {
throw wasReported(`Something is wrong near ${JSON.stringify(sTargets)}`);
}
Expand Down Expand Up @@ -335,12 +337,16 @@ export async function exec (argv2) { // eslint-disable-line complexity

// fetch targets

const { bytecode } = argv;

for (const target of targets) {
target.forceBuild = forceBuild;
await needWithDryRun(target);
const f = target.fabricator = fabricatorForTarget(target);
f.forceBuild = forceBuild;
await needWithDryRun(f);
if (bytecode) {
await needWithDryRun(f);
}
}

if (dryRunResults.fetched && !dryRunResults.built) {
Expand All @@ -350,9 +356,11 @@ export async function exec (argv2) { // eslint-disable-line complexity
for (const target of targets) {
target.binaryPath = await needViaCache(target);
const f = target.fabricator;
f.binaryPath = await needViaCache(f);
if (f.platform !== 'win') {
await plusx(f.binaryPath);
if (bytecode) {
f.binaryPath = await needViaCache(f);
if (f.platform !== 'win') {
await plusx(f.binaryPath);
}
}
}

Expand Down Expand Up @@ -385,7 +393,7 @@ export async function exec (argv2) { // eslint-disable-line complexity
entrypoint = refineResult.entrypoint;
records = refineResult.records;

const backpack = await packer({ records, entrypoint });
const backpack = await packer({ records, entrypoint, bytecode });

log.debug('Targets:', JSON.stringify(targets));

Expand Down
24 changes: 14 additions & 10 deletions lib/packer.js
Expand Up @@ -32,7 +32,7 @@ function hasAnyStore (record) {
return false;
}

export default async function ({ records, entrypoint }) {
export default async function ({ records, entrypoint, bytecode }) {
const stripes = [];

for (const snap in records) {
Expand All @@ -48,16 +48,20 @@ export default async function ({ records, entrypoint }) {

if (store === STORE_BLOB ||
store === STORE_CONTENT) {
if (record.body === undefined) {
stripes.push({ snap, store, file });
} else
if (Buffer.isBuffer(record.body)) {
stripes.push({ snap, store, buffer: record.body });
} else
if (typeof record.body === 'string') {
stripes.push({ snap, store, buffer: Buffer.from(record.body) });
if (store === STORE_BLOB && !bytecode) {
// bytecode===false suppresses any STORE_BLOB
} else {
assert(false, 'packer: bad STORE_BLOB/STORE_CONTENT');
if (record.body === undefined) {
stripes.push({ snap, store, file });
} else
if (Buffer.isBuffer(record.body)) {
stripes.push({ snap, store, buffer: record.body });
} else
if (typeof record.body === 'string') {
stripes.push({ snap, store, buffer: Buffer.from(record.body) });
} else {
assert(false, 'packer: bad STORE_BLOB/STORE_CONTENT');
}
}
} else
if (store === STORE_LINKS) {
Expand Down

0 comments on commit a216876

Please sign in to comment.