From e737ef4cfe00285c7569cb197989107df9519ebe Mon Sep 17 00:00:00 2001 From: David Glasser Date: Wed, 12 Nov 2014 13:58:25 -0800 Subject: [PATCH] download correct arch of packages in bundle --- tools/commands.js | 21 ++++++++++++++++++--- tools/main.js | 4 +++- tools/project-context.js | 14 ++++++++++++-- tools/tropohouse.js | 4 ++-- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/tools/commands.js b/tools/commands.js index cd835a4c08..4609c1c04d 100644 --- a/tools/commands.js +++ b/tools/commands.js @@ -26,6 +26,7 @@ var cordova = require('./commands-cordova.js'); var commandsPackages = require('./commands-packages.js'); var execFileSync = require('./utils.js').execFileSync; var Console = require('./console.js').Console; +var projectContextModule = require('./project-context.js'); // The architecture used by Galaxy servers; it's the architecture used // by 'meteor deploy'. @@ -685,8 +686,7 @@ main.registerCommand(_.extend({ name: 'build' }, buildCommands), // doesn't output a directory with all builds but rather only one tarball with // server/client programs. // XXX COMPAT WITH 0.9.1.1 -main.registerCommand(_.extend({ name: 'bundle', hidden: true, - prepareProjectContext: true +main.registerCommand(_.extend({ name: 'bundle', hidden: true }, buildCommands), function (options) { @@ -719,6 +719,21 @@ var buildCommand = function (options) { // XXX #3006: We need to have downloaded packages for options.architecture AND // archinfo.host()! + var projectContext = new projectContextModule.ProjectContext({ + projectDir: options.appDir, + tropohouse: tropohouse.default, + serverArchitectures: _.uniq([bundleArch, archinfo.host()]) + }); + + var messages = buildmessage.capture(function () { + projectContext.prepareProjectForBuild(); + }); + if (messages.hasMessages()) { + Console.error("=> Errors while initializing project:"); + Console.printMessages(messages); + return 1; + } + // options['mobile-settings'] is used to set the initial value of // `Meteor.settings` on mobile apps. Pass it on to options.settings, // which is used in this command. @@ -808,7 +823,7 @@ var buildCommand = function (options) { var bundler = require(path.join(__dirname, 'bundler.js')); var bundleResult = bundler.bundle({ - projectContext: options.projectContext, + projectContext: projectContext, includeDebug: !! options.debug, outputPath: bundlePath, buildOptions: { diff --git a/tools/main.js b/tools/main.js index 0277cb8f31..5139e8da52 100644 --- a/tools/main.js +++ b/tools/main.js @@ -1191,7 +1191,9 @@ commandName + ": You're not in a Meteor project directory.\n" + process.exit(1); } - if (!command.catalogRefresh.doesNotUsePackages) { + // XXX #3006 this should go away, with catalog.complete. + if (! command.newfangledProject && + ! command.catalogRefresh.doesNotUsePackages) { // OK, now it's finally time to set up the complete catalog. Only after this // can we use the build system (other than to make and load isopackets). diff --git a/tools/project-context.js b/tools/project-context.js index 7741eb1b64..b0d130c37c 100644 --- a/tools/project-context.js +++ b/tools/project-context.js @@ -1,6 +1,7 @@ var _ = require('underscore'); var path = require('path'); +var archinfo = require('./archinfo.js'); var buildmessage = require('./buildmessage.js'); var catalog = require('./catalog.js'); var catalogLocal = require('./catalog-local.js'); @@ -13,6 +14,8 @@ var packageMap = require('./package-map.js'); var utils = require('./utils.js'); var watch = require('./watch.js'); +// This class follows the standard protocol where names beginning with _ should +// not be externally accessed. exports.ProjectContext = function (options) { var self = this; if (!options.projectDir) @@ -23,6 +26,11 @@ exports.ProjectContext = function (options) { self.projectDir = options.projectDir; self.tropohouse = options.tropohouse; + self._serverArchitectures = options.serverArchitectures || []; + // We always need to download host versions of packages, at least for plugins. + self._serverArchitectures.push(archinfo.host()); + self._serverArchitectures = _.uniq(self._serverArchitectures); + // A WatchSet for all the files read by this class (eg .meteor/packages, etc). self.projectWatchSet = new watch.WatchSet; @@ -31,7 +39,7 @@ exports.ProjectContext = function (options) { self.isopackCache = null; // XXX #3006: Things we're leaving off for now: - // - constraints, combinedConstraints + // - combinedConstraints // - cordovaPlugins, platforms // - appId // - muted (???) @@ -196,7 +204,9 @@ _.extend(exports.ProjectContext.prototype, { throw Error("which packages to download?"); // XXX #3006 This downloads archinfo.host packages. How about // for deploy? - self.tropohouse.downloadPackagesMissingFromMap(self.packageMap); + self.tropohouse.downloadPackagesMissingFromMap(self.packageMap, { + serverArchitectures: self._serverArchitectures + }); }, _buildLocalPackages: function () { diff --git a/tools/tropohouse.js b/tools/tropohouse.js index 85c8cbe989..4a7927e006 100644 --- a/tools/tropohouse.js +++ b/tools/tropohouse.js @@ -381,7 +381,7 @@ _.extend(exports.Tropohouse.prototype, { var self = this; buildmessage.assertInCapture(); options = options || {}; - var serverArch = options.serverArch || archinfo.host(); + var serverArchs = options.serverArchitectures || [archinfo.host()]; var downloadCallbacks = {}; buildmessage.enterJob('checking package versions', function () { @@ -393,7 +393,7 @@ _.extend(exports.Tropohouse.prototype, { returnDownloadCallback: true, packageName: packageName, version: info.version, - architectures: [serverArch], + architectures: serverArchs, // Don't let tropohouse talk to the catalog, since there's no point. definitelyNotLocal: true });