diff --git a/tools/commands-cordova.js b/tools/commands-cordova.js index addad6edec..319faf8d92 100644 --- a/tools/commands-cordova.js +++ b/tools/commands-cordova.js @@ -2909,6 +2909,12 @@ main.registerCommand({ ensureCordovaPlatforms(projectContext); }); + // If this was the first Cordova platform, we may need to rebuild all of the + // local packages to add the web.cordova unibuild to the IsopackCache. + main.captureAndExit("=> Errors while initializing project:", function () { + projectContext.prepareProjectForBuild(); + }); + _.each(platforms, function (platform) { Console.info(platform + ": added platform"); }); @@ -2959,6 +2965,12 @@ main.registerCommand({ var appName = path.basename(projectContext.projectDir); ensureCordovaProject(projectContext, appName); ensureCordovaPlatforms(projectContext); + + // If this was the last Cordova platform, we may need to rebuild all of the + // local packages to remove the web.cordova unibuild from the IsopackCache. + main.captureAndExit("=> Errors while initializing project:", function () { + projectContext.prepareProjectForBuild(); + }); }); main.registerCommand({ diff --git a/tools/commands-packages.js b/tools/commands-packages.js index 8a6a8149b9..5d10be170f 100644 --- a/tools/commands-packages.js +++ b/tools/commands-packages.js @@ -221,7 +221,10 @@ main.registerCommand({ packageMapFilename: path.join(options.packageDir, '.versions'), // We always want to write our '.versions' package map, overriding a // comparison against the value of a release file that doesn't exist. - alwaysWritePackageMap: true + alwaysWritePackageMap: true, + // When we publish, we should always include web.cordova unibuilds, even + // though this temporary directory does not have any cordova platforms + forceIncludeCordovaUnibuild: true }); } else { // We're in an app; let the app be our context, but make sure we don't @@ -229,7 +232,10 @@ main.registerCommand({ // ensure that we can actually build the package and its tests). projectContext = new projectContextModule.ProjectContext({ projectDir: options.appDir, - neverWriteProjectConstraintsFile: true + neverWriteProjectConstraintsFile: true, + // When we publish, we should always include web.cordova unibuilds, even + // if this project does not have any cordova platforms + forceIncludeCordovaUnibuild: true }); } @@ -536,7 +542,10 @@ main.registerCommand({ // Set up the project. var projectContext = new projectContextModule.ProjectContext({ projectDir: tempProjectDir, - explicitlyAddedLocalPackageDirs: [packageDir] + explicitlyAddedLocalPackageDirs: [packageDir], + // When we publish, we should always include web.cordova unibuilds, even + // though this temporary directory does not have any cordova platforms + forceIncludeCordovaUnibuild: true }); // Just get up to initializing the catalog. We're going to mutate the // constraints file a bit before we prepare the build. @@ -735,7 +744,10 @@ main.registerCommand({ var projectContext = new projectContextModule.ProjectContext({ projectDir: tempProjectDir, // won't have a packages dir, that's OK // seriously, we only want checkout packages - ignorePackageDirsEnvVar: true + ignorePackageDirsEnvVar: true, + // When we publish, we should always include web.cordova unibuilds, even + // though this temporary directory does not have any cordova platforms + forceIncludeCordovaUnibuild: true }); // Read metadata and initialize catalog. diff --git a/tools/compiler.js b/tools/compiler.js index c918bb0df8..ad8154c745 100644 --- a/tools/compiler.js +++ b/tools/compiler.js @@ -33,6 +33,7 @@ compiler.compile = function (packageSource, options) { var packageMap = options.packageMap; var isopackCache = options.isopackCache; + var includeCordovaUnibuild = options.includeCordovaUnibuild; var pluginWatchSet = packageSource.pluginWatchSet.clone(); var plugins = {}; @@ -124,6 +125,9 @@ compiler.compile = function (packageSource, options) { }); _.each(packageSource.architectures, function (unibuild) { + if (unibuild.arch === 'web.cordova' && ! includeCordovaUnibuild) + return; + var unibuildResult = compileUnibuild({ isopack: isopk, sourceArch: unibuild, diff --git a/tools/isopack-cache.js b/tools/isopack-cache.js index a2590969fd..f3a0d0b940 100644 --- a/tools/isopack-cache.js +++ b/tools/isopack-cache.js @@ -15,6 +15,12 @@ exports.IsopackCache = function (options) { // cacheDir may be null; in this case, we just don't ever save things to disk. self.cacheDir = options.cacheDir; + // This is a bit of a hack, but basically: we really don't want to spend time + // building web.cordova unibuilds in a project that doesn't have any Cordova + // platforms. (Note that we need to be careful with 'meteor publish' to still + // publish a web.cordova unibuild!) + self._includeCordovaUnibuild = !! options.includeCordovaUnibuild; + // Defines the versions of packages that we build. Must be set. self._packageMap = options.packageMap; @@ -212,7 +218,8 @@ _.extend(exports.IsopackCache.prototype, { var compilerResult = compiler.compile(packageInfo.packageSource, { packageMap: self._packageMap, isopackCache: self, - noLineNumbers: self._noLineNumbers + noLineNumbers: self._noLineNumbers, + includeCordovaUnibuild: self._includeCordovaUnibuild }); // Accept the compiler's result, even if there were errors (since it at // least will have a useful WatchSet and will allow us to keep going and @@ -243,6 +250,14 @@ _.extend(exports.IsopackCache.prototype, { // up to date! if (! isopackBuildInfoJson) return false; + + // If we include Cordova but this Isopack doesn't, or via versa, then we're + // not up to date. + if (self._includeCordovaUnibuild !== + isopackBuildInfoJson.includeCordovaUnibuild) { + return false; + } + // If any of the direct dependencies changed their version or location, we // aren't up to date. if (!self._packageMap.isSupersetOfJSON( diff --git a/tools/isopack.js b/tools/isopack.js index 07cf644793..2628ecf33b 100644 --- a/tools/isopack.js +++ b/tools/isopack.js @@ -766,7 +766,10 @@ _.extend(Isopack.prototype, { // our package.js (because modifications to package.js could add a new // plugin), as well as any files making up plugins in our package. pluginDependencies: self.pluginWatchSet.toJSON(), - pluginProviderPackageMap: options.pluginProviderPackageMap.toJSON() + pluginProviderPackageMap: options.pluginProviderPackageMap.toJSON(), + includeCordovaUnibuild: _.any(self.unibuilds, function (unibuild) { + return unibuild.arch === 'web.cordova'; + }) }; } diff --git a/tools/isopackets.js b/tools/isopackets.js index d0172fee2d..e6c24502cc 100644 --- a/tools/isopackets.js +++ b/tools/isopackets.js @@ -239,6 +239,7 @@ var makeIsopacketBuildContext = function () { // access to versioned packages. context.isopackCache = new isopackCacheModule.IsopackCache({ packageMap: context.packageMap, + includeCordovaUnibuild: false, // When linking JS files, don't include the padding spaces and line number // comments. Since isopackets are loaded as part of possibly very short // 'meteor' tool command invocations, we care more about startup time than diff --git a/tools/project-context.js b/tools/project-context.js index 2e10642d61..48a5197ab1 100644 --- a/tools/project-context.js +++ b/tools/project-context.js @@ -107,6 +107,11 @@ _.extend(exports.ProjectContext.prototype, { // Set when deploying to a previous Galaxy prototype. self._requireControlProgram = options.requireControlProgram; + // Set by publishing commands to ensure that published packages always have + // a web.cordova slice (because we aren't yet smart enough to just default + // to using the web.browser slice instead or make a common 'web' slice). + self._forceIncludeCordovaUnibuild = options.forceIncludeCordovaUnibuild; + // If explicitly specified as null, use no release for constraints. // If specified non-null, should be a release version catalog record. // If not specified, defaults to release.current. @@ -656,6 +661,8 @@ _.extend(exports.ProjectContext.prototype, { self.isopackCache = new isopackCacheModule.IsopackCache({ packageMap: self.packageMap, + includeCordovaUnibuild: (self._forceIncludeCordovaUnibuild + || self.platformList.usesCordova()), cacheDir: self.getProjectLocalDirectory('isopacks'), tropohouse: self.tropohouse, previousIsopackCache: self._previousIsopackCache @@ -1039,6 +1046,11 @@ _.extend(exports.PlatformList.prototype, { exports.PlatformList.DEFAULT_PLATFORMS); }, + usesCordova: function () { + var self = this; + return ! _.isEmpty(self.getCordovaPlatforms()); + }, + getWebArchs: function () { var self = this; var archs = [ "web.browser" ]; diff --git a/tools/selftest.js b/tools/selftest.js index be90012c76..1fc587b90f 100644 --- a/tools/selftest.js +++ b/tools/selftest.js @@ -126,7 +126,8 @@ var setUpBuiltPackageTropohouse = function () { // Make an isopack cache that doesn't automatically save isopacks to disk and // has no access to versioned packages. tropohouseIsopackCache = new isopackCacheModule.IsopackCache({ - packageMap: packageMap + packageMap: packageMap, + includeCordovaUnibuild: true }); doOrThrow(function () { buildmessage.enterJob("building self-test packages", function () {