mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Don't compile web.cordova unibuilds unless needed
Specifically, we only compile them if there's a cordova platform in the current project, or if we are publishing the package. (Ideally, we wouldn't require every published package to have web.browser and web.cordova unibuilds --- we'd just publish a 'web' unibuild unless there's actually a difference between the two. But we are not there yet.) This adds an extra flag to isopack-buildinfo.json, so that we know to rebuild all the isopacks when we add the first cordova platform (or remove the last cordova platform). The implementation around publish is a little clunky; if you're in a non-Cordova app and run meteor publish, it will rebuild all the packages with web.cordova, and the next time you prepare the app it will rebuild them again without it. It does work though. Fixes #3274.
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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';
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" ];
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user