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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2817f7c  CB-13877 First MSBuildTools.js work: Debug output, move 
misplaced method, comments (#255)
2817f7c is described below

commit 2817f7c084e8d6330f4cb316735a53136a108fed
Author: Jan Piotrowski <piotrowski+git...@gmail.com>
AuthorDate: Wed Feb 14 16:37:23 2018 +0100

    CB-13877 First MSBuildTools.js work: Debug output, move misplaced method, 
comments (#255)
    
    * notes on method usage
    
    * move getLatestMSBuild over to MSBuildTools
    
    * output path to used MSBuildTools in during build
---
 template/cordova/lib/MSBuildTools.js | 34 +++++++++++++++++++++++++++++++++-
 template/cordova/lib/build.js        | 27 ++-------------------------
 2 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/template/cordova/lib/MSBuildTools.js 
b/template/cordova/lib/MSBuildTools.js
index 7710372..eb9d7f0 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  : ' + this.path);
 
     var checkWinSDK = function (target_platform) {
         return require('./check_reqs').isWinSDKPresent(target_platform);
@@ -70,6 +71,7 @@ MSBuildTools.prototype.buildProject = function (projFile, 
buildType, buildarch,
 };
 
 // returns full path to msbuild tools required to build the project and tools 
version
+// check_reqs.js -> run()
 module.exports.findAvailableVersion = function () {
     var versions = ['15.0', '14.0', '12.0', '4.0'];
 
@@ -92,6 +94,8 @@ function findAllAvailableVersionsFallBack () {
     });
 }
 
+// build.js -> run()
+// check_reqs.js -> checkMSBuild()
 module.exports.findAllAvailableVersions = function () {
     // CB-11548 use VSINSTALLDIR environment if defined to find MSBuild. If 
VSINSTALLDIR
     // is not specified or doesn't contain the MSBuild path we are looking for 
- fall back
@@ -155,7 +159,8 @@ function checkMSBuildVersion (version) {
         });
 }
 
-/// returns an array of available UAP Versions
+// returns an array of available UAP Versions
+// prepare.js
 module.exports.getAvailableUAPVersions = function () {
     var programFilesFolder = process.env['ProgramFiles(x86)'] || 
process.env['ProgramFiles'];
     // No Program Files folder found, so we won't be able to find UAP SDK
@@ -229,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 2683a1f..3006972 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');
@@ -308,7 +307,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];
@@ -323,7 +322,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.'));
     }
@@ -440,28 +439,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