From 8684c2afbe2d50345287b9aaaddf7f492aeeea46 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Thu, 9 Jul 2015 14:51:14 -0700 Subject: [PATCH] use getActivePluginPackages more --- tools/compiler-plugin.js | 30 ++------------------ tools/compiler.js | 61 ++++++++++++++++++---------------------- 2 files changed, 31 insertions(+), 60 deletions(-) diff --git a/tools/compiler-plugin.js b/tools/compiler-plugin.js index 6a7f8dabc3..da91d0245b 100644 --- a/tools/compiler-plugin.js +++ b/tools/compiler-plugin.js @@ -437,34 +437,10 @@ _.extend(PackageSourceBatch.prototype, { _getSourceProcessorSet: function () { var self = this; var isopack = self.unibuild.pkg; - // Packages always get plugins from themselves. - var activePluginPackages = [isopack]; - - // We don't use plugins from weak dependencies, because the ability to build - // a certain type of file shouldn't depend on whether or not some unrelated - // package in the target has a dependency. And we skip unordered - // dependencies, because it's not going to work to have circular build-time - // dependencies. - // - // eachUsedUnibuild takes care of pulling in implied dependencies for us - // (eg, templating from standard-app-packages). - // - // We pass archinfo.host here, not self.arch, because it may be more - // specific, and because plugins always have to run on the host - // architecture. - compiler.eachUsedUnibuild({ - dependencies: self.unibuild.uses, - arch: archinfo.host(), - isopackCache: self.processor.isopackCache, - skipUnordered: true - }, function (otherUnibuild) { - if (! _.isEmpty(otherUnibuild.pkg.plugins)) { - activePluginPackages.push(otherUnibuild.pkg); - } + const activePluginPackages = compiler.getActivePluginPackages(isopack, { + uses: self.unibuild.uses, + isopackCache: self.processor.isopackCache }); - - activePluginPackages = _.uniq(activePluginPackages); - const sourceProcessorSet = new buildPluginModule.SourceProcessorSet( isopack.displayName(), { hardcodeJs: true }); diff --git a/tools/compiler.js b/tools/compiler.js index 674c2a414e..df02cbe591 100644 --- a/tools/compiler.js +++ b/tools/compiler.js @@ -191,7 +191,7 @@ compiler.getMinifiers = function (packageSource, options) { _.each(packageSource.architectures, function (architecture) { var activePluginPackages = getActivePluginPackages(options.isopack, { isopackCache: options.isopackCache, - sourceArch: architecture + uses: architecture.uses }); _.each(activePluginPackages, function (otherPkg) { @@ -221,7 +221,10 @@ compiler.getMinifiers = function (packageSource, options) { var lintUnibuild = function ({isopack, isopackCache, sourceArch}) { var activePluginPackages = getActivePluginPackages( - isopack, {sourceArch, isopackCache}); + isopack, { + isopackCache, + uses: sourceArch.uses + }); const sourceProcessorSet = new SourceProcessorSet( isopack.displayName, { allowConflicts: true }); @@ -229,7 +232,6 @@ var lintUnibuild = function ({isopack, isopackCache, sourceArch}) { _.each(activePluginPackages, function (otherPkg) { otherPkg.ensurePluginsInitialized(); - if (isopack.name === null) sourceProcessorSet.merge(otherPkg.sourceProcessors.linter); }); @@ -267,34 +269,17 @@ var compileUnibuild = function (options) { var isApp = ! inputSourceArch.pkg.name; var resources = []; var pluginProviderPackageNames = {}; - // The current package always is a plugin provider. (This also means we no - // longer need a buildOfPath entry in buildinfo.json.) - pluginProviderPackageNames[isopk.name] = true; var watchSet = inputSourceArch.watchSet.clone(); - compiler.eachUsedUnibuild({ - dependencies: inputSourceArch.uses, - arch: archinfo.host(), - isopackCache: isopackCache, - skipUnordered: true - // implicitly skip weak deps by not specifying acceptableWeakPackages option - }, function (unibuild) { - if (unibuild.pkg.name === isopk.name) - return; - pluginProviderPackageNames[unibuild.pkg.name] = true; - // If other package is built from source, then we need to rebuild this - // package if any file in the other package that could define a plugin - // changes. - watchSet.merge(unibuild.pkg.pluginWatchSet); - - if (_.isEmpty(unibuild.pkg.plugins)) - return; - }); - // *** Determine and load active plugins var activePluginPackages = getActivePluginPackages(isopk, { - sourceArch: inputSourceArch, - isopackCache: isopackCache + uses: inputSourceArch.uses, + isopackCache: isopackCache, + // If other package is built from source, then we need to rebuild this + // package if any file in the other package that could define a plugin + // changes. getActivePluginPackages will add entries to this WatchSet. + pluginProviderWatchSet: watchSet, + pluginProviderPackageNames }); // *** Assemble the list of source file handlers from the plugins @@ -602,10 +587,12 @@ function runLinters({inputSourceArch, isopackCache, sourceItems, // takes an isopack and returns a list of packages isopack depends on, // containing at least one plugin -var getActivePluginPackages = function (isopk, options) { - var inputSourceArch = options.sourceArch; - var isopackCache = options.isopackCache; - +export function getActivePluginPackages(isopk, { + uses, + isopackCache, + pluginProviderPackageNames, + pluginProviderWatchSet +}) { // XXX we used to include our own plugins only if we were the // "use" role. now we include them everywhere because we don't have // a special "use" role anymore. it's not totally clear to me what @@ -617,6 +604,8 @@ var getActivePluginPackages = function (isopk, options) { // the implies field is on the target unibuild, but we really only care // about packages.) var activePluginPackages = [isopk]; + if (pluginProviderPackageNames) + pluginProviderPackageNames[isopk.name] = true; // We don't use plugins from weak dependencies, because the ability // to compile a certain type of file shouldn't depend on whether or @@ -630,7 +619,7 @@ var getActivePluginPackages = function (isopk, options) { // We pass archinfo.host here, not self.arch, because it may be more specific, // and because plugins always have to run on the host architecture. compiler.eachUsedUnibuild({ - dependencies: inputSourceArch.uses, + dependencies: uses, arch: archinfo.host(), isopackCache: isopackCache, skipUnordered: true @@ -638,6 +627,12 @@ var getActivePluginPackages = function (isopk, options) { }, function (unibuild) { if (unibuild.pkg.name === isopk.name) return; + if (pluginProviderPackageNames) { + pluginProviderPackageNames[unibuild.pkg.name] = true; + } + if (pluginProviderWatchSet) { + pluginProviderWatchSet.merge(unibuild.pkg.pluginWatchSet); + } if (_.isEmpty(unibuild.pkg.plugins)) return; activePluginPackages.push(unibuild.pkg); @@ -645,7 +640,7 @@ var getActivePluginPackages = function (isopk, options) { activePluginPackages = _.uniq(activePluginPackages); return activePluginPackages; -}; +} // Iterates over each in options.dependencies as well as unibuilds implied by // them. The packages in question need to already be built and in