Skip to content

Commit

Permalink
Include exports in codeless legacy builds
Browse files Browse the repository at this point in the history
  • Loading branch information
glasser committed Sep 22, 2015
1 parent a23cc02 commit 2b0e8dd
Showing 1 changed file with 35 additions and 27 deletions.
62 changes: 35 additions & 27 deletions tools/isobuild/isopack.js
Original file line number Diff line number Diff line change
Expand Up @@ -1450,21 +1450,36 @@ _.extend(Isopack.prototype, {
+ JSON.stringify(resource));
}
});
if (jsResourcesForLegacyPrelink.length) {
var prelinkFile, prelinkData, packageVariables;
if (jsResourcesForLegacyPrelink.length === 1 &&
jsResourcesForLegacyPrelink[0].legacyPrelink) {
// Aha! This isopack was actually a legacy isopack in the first
// place! So this source file is already the output of prelink,
// and we don't need to reprocess it.
prelinkFile = jsResourcesForLegacyPrelink[0];
// XXX It's weird that the type of object going in and out of
// linker.prelink is different (so that this prelinkData
// assignment differs from that below), ah well.
prelinkData = prelinkFile.data;
packageVariables =
jsResourcesForLegacyPrelink[0].legacyPrelink.packageVariables;
} else {

var prelinkFile, prelinkData, packageVariables;
if (jsResourcesForLegacyPrelink.length === 1 &&
jsResourcesForLegacyPrelink[0].legacyPrelink) {
// Aha! This isopack was actually a legacy isopack in the first
// place! So this source file is already the output of prelink,
// and we don't need to reprocess it.
prelinkFile = jsResourcesForLegacyPrelink[0];
// XXX It's weird that the type of object going in and out of
// linker.prelink is different (so that this prelinkData
// assignment differs from that below), ah well.
prelinkData = prelinkFile.data;
packageVariables =
jsResourcesForLegacyPrelink[0].legacyPrelink.packageVariables;
} else {
// Determine captured variables, legacy way. First, start with the
// exports. We'll add the package variables after running prelink.
packageVariables = [];
var packageVariableNames = {};
_.each(unibuild.declaredExports, function (symbol) {
if (_.has(packageVariableNames, symbol.name))
return;
packageVariables.push({
name: symbol.name,
export: symbol.testOnly? "tests" : true
});
packageVariableNames[symbol.name] = true;
});

if (jsResourcesForLegacyPrelink.length) {
// Not originally legacy; let's run prelink to make it legacy.
var results = linker.prelink({
inputFiles: jsResourcesForLegacyPrelink,
Expand All @@ -1485,18 +1500,6 @@ _.extend(Isopack.prototype, {
prelinkFile = results.files[0];
prelinkData = new Buffer(prelinkFile.source, 'utf8');

// Determine captured variables, legacy way.
packageVariables = [];
var packageVariableNames = {};
_.each(unibuild.declaredExports, function (symbol) {
if (_.has(packageVariableNames, symbol.name))
return;
packageVariables.push({
name: symbol.name,
export: symbol.testOnly? "tests" : true
});
packageVariableNames[symbol.name] = true;
});
_.each(results.assignedVariables, function (name) {
if (_.has(packageVariableNames, name))
return;
Expand All @@ -1506,7 +1509,9 @@ _.extend(Isopack.prototype, {
packageVariableNames[name] = true;
});
}
}

if (prelinkFile && prelinkData) {
var prelinkResource = {
type: 'prelink',
file: builder.writeToGeneratedFilename(
Expand All @@ -1524,9 +1529,12 @@ _.extend(Isopack.prototype, {
);
}
newResources.push(prelinkResource);
}

if (packageVariables.length) {
unibuildJson.packageVariables = packageVariables;
}

unibuildJson.resources = newResources;
delete unibuildJson.declaredExports;
builder.writeJson(legacyFilename, unibuildJson);
Expand Down

0 comments on commit 2b0e8dd

Please sign in to comment.