This is an automated email from the ASF dual-hosted git repository.

janpio pushed a commit to branch janpio-rework_MSBuildTools
in repository https://gitbox.apache.org/repos/asf/cordova-windows.git

commit 2bed15493bd5458a850e6b8f0068e5d9f365f8f8
Author: Jan Piotrowski <piotrow...@gmail.com>
AuthorDate: Tue Feb 13 18:29:12 2018 +0100

    move getLatestMSBuild over to MSBuildTools
---
 template/cordova/lib/MSBuildTools.js | 28 ++++++++++++++++++++++++++++
 template/cordova/lib/build.js        | 27 ++-------------------------
 2 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/template/cordova/lib/MSBuildTools.js 
b/template/cordova/lib/MSBuildTools.js
index ada837a..f974872 100644
--- a/template/cordova/lib/MSBuildTools.js
+++ b/template/cordova/lib/MSBuildTools.js
@@ -35,6 +35,7 @@ MSBuildTools.prototype.buildProject = function (projFile, 
buildType, buildarch,
     events.emit('log', '\tConfiguration : ' + buildType);
     events.emit('log', '\tPlatform      : ' + buildarch);
     events.emit('log', '\tBuildflags    : ' + buildFlags);
+    events.emit('log', '\tMSBuildTools  : ' + msbuild.path);
 
     var checkWinSDK = function (target_platform) {
         return require('./check_reqs').isWinSDKPresent(target_platform);
@@ -233,3 +234,30 @@ module.exports.getWillowInstallations = function () {
     });
     return installations;
 };
+
+// gets the latest MSBuild version from a list of versions
+module.exports.getLatestMSBuild = function (allMsBuildVersions) {
+    events.emit('verbose', 'getLatestMSBuild');
+
+    var availableVersions = allMsBuildVersions
+        .filter(function (buildTools) {
+            // Sanitize input - filter out tools w/ invalid versions
+            return Version.tryParse(buildTools.version);
+        }).sort(function (a, b) {
+            // Sort tools list - use parsed Version objects for that
+            // to respect both major and minor versions segments
+            var parsedA = Version.fromString(a.version);
+            var parsedB = Version.fromString(b.version);
+
+            if (parsedA.gt(parsedB)) return -1;
+            if (parsedA.eq(parsedB)) return 0;
+            return 1;
+        });
+
+    console.log('availableVersions', availableVersions);
+
+    if (availableVersions.length > 0) {
+        // After sorting the first item will be the highest version available
+        return availableVersions[0];
+    }
+};
diff --git a/template/cordova/lib/build.js b/template/cordova/lib/build.js
index eeaa7e3..9dbaeef 100644
--- a/template/cordova/lib/build.js
+++ b/template/cordova/lib/build.js
@@ -24,7 +24,6 @@ var shell = require('shelljs');
 var utils = require('./utils');
 var prepare = require('./prepare');
 var pckage = require('./package');
-var Version = require('./Version');
 var MSBuildTools = require('./MSBuildTools');
 var AppxManifest = require('./AppxManifest');
 var ConfigParser = require('./ConfigParser');
@@ -305,7 +304,7 @@ function updateManifestWithPublisher (allMsBuildVersions, 
config) {
     if (!config.publisherId) return;
 
     var selectedBuildTargets = getBuildTargets(config.win, config.phone, 
config.projVerOverride, config);
-    var msbuild = getLatestMSBuild(allMsBuildVersions);
+    var msbuild = MSBuildTools.getLatestMSBuild(allMsBuildVersions);
     var myBuildTargets = filterSupportedTargets(selectedBuildTargets, msbuild);
     var manifestFiles = myBuildTargets.map(function (proj) {
         return projFilesToManifests[proj];
@@ -320,7 +319,7 @@ function updateManifestWithPublisher (allMsBuildVersions, 
config) {
 function buildTargets (allMsBuildVersions, config) {
     // filter targets to make sure they are supported on this development 
machine
     var selectedBuildTargets = getBuildTargets(config.win, config.phone, 
config.projVerOverride, config);
-    var msbuild = getLatestMSBuild(allMsBuildVersions);
+    var msbuild = MSBuildTools.getLatestMSBuild(allMsBuildVersions);
     if (!msbuild) {
         return Q.reject(new CordovaError('No valid MSBuild was detected for 
the selected target.'));
     }
@@ -437,28 +436,6 @@ function clearIntermediatesAndGetPackage (bundleTerms, 
config, hasAnyCpu) {
     return pckage.getPackageFileInfo(finalFile);
 }
 
-function getLatestMSBuild (allMsBuildVersions) {
-    var availableVersions = allMsBuildVersions
-        .filter(function (buildTools) {
-            // Sanitize input - filter out tools w/ invalid versions
-            return Version.tryParse(buildTools.version);
-        }).sort(function (a, b) {
-            // Sort tools list - use parsed Version objects for that
-            // to respect both major and minor versions segments
-            var parsedA = Version.fromString(a.version);
-            var parsedB = Version.fromString(b.version);
-
-            if (parsedA.gt(parsedB)) return -1;
-            if (parsedA.eq(parsedB)) return 0;
-            return 1;
-        });
-
-    if (availableVersions.length > 0) {
-        // After sorting the first item will be the highest version available
-        return availableVersions[0];
-    }
-}
-
 // TODO: Fix this so that it outlines supported versions based on version 
criteria:
 // - v14: Windows 8.1, Windows 10
 // - v12: Windows 8.1

-- 
To stop receiving notification emails like this one, please contact
jan...@apache.org.

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org

Reply via email to