You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ja...@apache.org on 2018/02/14 19:28:10 UTC

[cordova-windows] branch janpio-msbuild_cleanup created (now 55639d8)

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

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


      at 55639d8  better logging for checkMSBuildVersion future method preparation

This branch includes the following new commits:

     new bd550ef  move method
     new 949a609  temporary logging
     new 8e7087e  clearer comment
     new 933d2f2  move method
     new 6295571  move filterSupportedTargets from build.js to MSBuildTools.js
     new 0b7dd3e  restructure getLatestMSBuild to get the list of available MSBuilds itself restructure usage of MSBuildTools in build.js to that new reality (get builtTargets earlier, get msBuild instead of list, use both to filter buildTargets earlier)
     new c7126a4  now also remove filterSupportedTargets from build.js
     new 3d8bcee  move method
     new cca9e19  fix eslint
     new eaa1a34  Visual Studio 15.5 is a thing the script should know about
     new 55639d8  better logging for checkMSBuildVersion future method preparation

The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


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

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


[cordova-windows] 07/11: now also remove filterSupportedTargets from build.js

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c7126a43279fecc6f66fbb6abd899f35d4747483
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Wed Feb 14 19:26:23 2018 +0100

    now also remove filterSupportedTargets from build.js
---
 template/cordova/lib/build.js | 48 -------------------------------------------
 1 file changed, 48 deletions(-)

diff --git a/template/cordova/lib/build.js b/template/cordova/lib/build.js
index 0b09d32..efbf22b 100644
--- a/template/cordova/lib/build.js
+++ b/template/cordova/lib/build.js
@@ -438,54 +438,6 @@ function clearIntermediatesAndGetPackage (bundleTerms, config, hasAnyCpu) {
     return pckage.getPackageFileInfo(finalFile);
 }
 
-// TODO: Fix this so that it outlines supported versions based on version criteria:
-// - v14: Windows 8.1, Windows 10
-// - v12: Windows 8.1
-function msBuild12TargetsFilter (target) {
-    return target === projFiles.win || target === projFiles.phone;
-}
-
-function msBuild14TargetsFilter (target) {
-    return target === projFiles.win || target === projFiles.phone || target === projFiles.win10;
-}
-
-function msBuild15TargetsFilter (target) {
-    return target === projFiles.win || target === projFiles.phone || target === projFiles.win10;
-}
-
-function filterSupportedTargets (targets, msbuild) {
-    if (!targets || targets.length === 0) {
-        events.emit('warn', 'No build targets specified');
-        return [];
-    }
-
-    var targetFilters = {
-        '12.0': msBuild12TargetsFilter,
-        '14.0': msBuild14TargetsFilter,
-        '15.x': msBuild15TargetsFilter,
-        get: function (version) {
-            // Apart from exact match also try to get filter for version range
-            // so we can find for example targets for version '15.1'
-            return this[version] || this[version.replace(/\.\d+$/, '.x')];
-        }
-    };
-
-    var filter = targetFilters.get(msbuild.version);
-    if (!filter) {
-        events.emit('warn', 'MSBuild v' + msbuild.version + ' is not supported, aborting.');
-        return [];
-    }
-
-    var supportedTargets = targets.filter(filter);
-    // unsupported targets have been detected
-    if (supportedTargets.length !== targets.length) {
-        events.emit('warn', 'Not all desired build targets are compatible with the current build environment. ' +
-            'Please install Visual Studio 2015 for Windows 8.1 and Windows 10, ' +
-            'or Visual Studio 2013 Update 2 for Windows 8.1.');
-    }
-    return supportedTargets;
-}
-
 function cleanIntermediates () {
     var buildPath = path.join(ROOT, 'build');
     if (shell.test('-e', buildPath)) {

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

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


[cordova-windows] 06/11: restructure getLatestMSBuild to get the list of available MSBuilds itself restructure usage of MSBuildTools in build.js to that new reality (get builtTargets earlier, get msBuild instead of list, use both to filter buildTargets earlier)

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0b7dd3e42d7bc8689f0145f1eed2e0196eb84b61
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Wed Feb 14 19:26:04 2018 +0100

    restructure getLatestMSBuild to get the list of available MSBuilds itself
    restructure usage of MSBuildTools in build.js to that new reality (get builtTargets earlier, get msBuild instead of list, use both to filter buildTargets earlier)
---
 template/cordova/lib/MSBuildTools.js | 50 +++++++++++++++++++++---------------
 template/cordova/lib/build.js        | 33 ++++++++++++------------
 2 files changed, 45 insertions(+), 38 deletions(-)

diff --git a/template/cordova/lib/MSBuildTools.js b/template/cordova/lib/MSBuildTools.js
index 80a9fcf..5d9fe2c 100644
--- a/template/cordova/lib/MSBuildTools.js
+++ b/template/cordova/lib/MSBuildTools.js
@@ -211,31 +211,39 @@ module.exports.getAvailableUAPVersions = function () {
 };
 
 // gets the latest MSBuild version from a list of versions
-module.exports.getLatestMSBuild = function (allMsBuildVersions) {
+module.exports.getLatestMSBuild = function () {
     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;
-        });
+    return this.findAllAvailableVersions()
+        .then(function (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;
+                });
+
+            console.log('availableVersions', availableVersions);
+
+            if (availableVersions.length > 0) {
+                // After sorting the first item will be the highest version available
+                msbuild = availableVersions[0];
+                events.emit('verbose', 'Using MSBuild v' + msbuild.version + ' from ' + msbuild.path);
+                return msbuild;
+            }
+    });
+};
 
-    console.log('availableVersions', availableVersions);
 
-    if (availableVersions.length > 0) {
-        // After sorting the first item will be the highest version available
-        return availableVersions[0];
-    }
-};
 var projFiles = {
     phone: 'CordovaApp.Phone.jsproj',
     win: 'CordovaApp.Windows.jsproj',
diff --git a/template/cordova/lib/build.js b/template/cordova/lib/build.js
index 3006972..0b09d32 100644
--- a/template/cordova/lib/build.js
+++ b/template/cordova/lib/build.js
@@ -57,20 +57,30 @@ module.exports.run = function run (buildOptions) {
 
     var buildConfig = parseAndValidateArgs(buildOptions);
 
-    return MSBuildTools.findAllAvailableVersions()
-        .then(function (msbuildTools) {
+    // get build targets
+    var selectedBuildTargets = getBuildTargets(buildConfig.win, buildConfig.phone, buildConfig.projVerOverride, buildConfig);
+
+    return MSBuildTools.getLatestMSBuild() // get latest msbuild tools
+        .then(function (msbuild) {
+
+            // filter targets to make sure they are supported on this development machine
+            var myBuildTargets = msbuild.filterSupportedTargets(selectedBuildTargets);
+
             // Apply build related configs
             prepare.updateBuildConfig(buildConfig);
 
             if (buildConfig.publisherId) {
-                updateManifestWithPublisher(msbuildTools, buildConfig);
+                updateManifestWithPublisher(buildConfig, myBuildTargets);
             }
 
             cleanIntermediates();
-            return buildTargets(msbuildTools, buildConfig);
+            // build!
+            return buildTargets(buildConfig, myBuildTargets, msbuild);
         }).then(function (pkg) {
             events.emit('verbose', ' BUILD OUTPUT: ' + pkg.appx);
             return pkg;
+        }).catch(function (error) {
+            return Q.reject(new CordovaError('No valid MSBuild was detected for the selected target: ' + error, error));
         });
 };
 
@@ -303,12 +313,9 @@ function parseBuildConfig (buildConfigPath, buildType) {
 
 // Note: This function is very narrow and only writes to the app manifest if an update is done.  See CB-9450 for the
 // reasoning of why this is the case.
-function updateManifestWithPublisher (allMsBuildVersions, config) {
+function updateManifestWithPublisher (config, myBuildTargets) {
     if (!config.publisherId) return;
 
-    var selectedBuildTargets = getBuildTargets(config.win, config.phone, config.projVerOverride, config);
-    var msbuild = MSBuildTools.getLatestMSBuild(allMsBuildVersions);
-    var myBuildTargets = filterSupportedTargets(selectedBuildTargets, msbuild);
     var manifestFiles = myBuildTargets.map(function (proj) {
         return projFilesToManifests[proj];
     });
@@ -319,15 +326,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 = MSBuildTools.getLatestMSBuild(allMsBuildVersions);
-    if (!msbuild) {
-        return Q.reject(new CordovaError('No valid MSBuild was detected for the selected target.'));
-    }
-    events.emit('verbose', 'Using MSBuild v' + msbuild.version + ' from ' + msbuild.path);
-    var myBuildTargets = filterSupportedTargets(selectedBuildTargets, msbuild);
+function buildTargets (config, myBuildTargets, msbuild) {
 
     var buildConfigs = [];
     var bundleTerms = '';

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

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


[cordova-windows] 02/11: temporary logging

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 949a60971b7c3f46c259a1550d9103f890ec54a6
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Wed Feb 14 19:11:21 2018 +0100

    temporary logging
---
 template/cordova/lib/MSBuildTools.js | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/template/cordova/lib/MSBuildTools.js b/template/cordova/lib/MSBuildTools.js
index 0444ba3..261aa72 100644
--- a/template/cordova/lib/MSBuildTools.js
+++ b/template/cordova/lib/MSBuildTools.js
@@ -78,6 +78,7 @@ module.exports.findAvailableVersion = function () {
     var versions = ['15.0', '14.0', '12.0', '4.0'];
 
     return Q.all(versions.map(checkMSBuildVersion)).then(function (versions) {
+        console.log('findAvailableVersion', versions);
         // select first msbuild version available, and resolve promise with it
         var msbuildTools = versions[0] || versions[1] || versions[2] || versions[3];
 
@@ -91,6 +92,7 @@ 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
     // to default discovery mechanism.
+    console.log('findAllAvailableVersions');
     if (process.env.VSINSTALLDIR) {
         var msBuildPath = path.join(process.env.VSINSTALLDIR, 'MSBuild/15.0/Bin');
         return module.exports.getMSBuildToolsAt(msBuildPath)
@@ -104,6 +106,8 @@ module.exports.findAllAvailableVersions = function () {
 
 function findAllAvailableVersionsFallBack () {
     var versions = ['15.0', '14.0', '12.0', '4.0'];
+    console.log('findAllAvailableVersionsFALLBACK');
+
     events.emit('verbose', 'Searching for available MSBuild versions...');
 
     return Q.all(versions.map(checkMSBuildVersion)).then(function (unprocessedResults) {
@@ -120,6 +124,7 @@ function findAllAvailableVersionsFallBack () {
  * @returns  Promise<MSBuildTools>  The MSBuildTools instance at specified location
  */
 module.exports.getMSBuildToolsAt = function (location) {
+    console.log('getMSBuildToolsAt', location);
     var msbuildExe = path.resolve(location, 'msbuild');
 
     // TODO: can we account on these params availability and printed version format?
@@ -127,18 +132,31 @@ module.exports.getMSBuildToolsAt = function (location) {
         .then(function (output) {
             // MSBuild prints its' version as 14.0.25123.0, so we pick only first 2 segments
             var version = output.match(/^(\d+\.\d+)/)[1];
+            console.log('return new MSBuildTools', version, location)
             return new MSBuildTools(version, location);
         });
 };
 
 function checkMSBuildVersion (version) {
+    console.log('checkMSBuildVersion', version);
+    
     // first, check if we have a VS 2017+ with such a version
-    var correspondingWillow = module.exports.getWillowInstallations().filter(function (inst) {
+    var willows = module.exports.getWillowInstallations();
+    console.log('willows', willows);
+    var correspondingWillows = willows.filter(function (inst) {
+        console.log('correspondingWillow', inst.version === version);
         return inst.version === version;
-    })[0];
+    });
+    console.log('correspondingWillows', correspondingWillows);
+    var correspondingWillow = correspondingWillows[1];
     if (correspondingWillow) {
+        // TODO adapt for 15.5=>15.0 case
+        version = '15.0';
         var toolsPath = path.join(correspondingWillow.path, 'MSBuild', version, 'Bin');
+        console.log('correspondingWillow:', toolsPath);
         if (shell.test('-e', toolsPath)) {
+            console.log('correspondingWillow:', toolsPath, module.exports.getMSBuildToolsAt(toolsPath));
+            // TODO check for JavaScript folder
             return module.exports.getMSBuildToolsAt(toolsPath);
         }
     }
@@ -146,6 +164,7 @@ function checkMSBuildVersion (version) {
     // older vs versions that were registered in registry
     return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\' + version, '/v', 'MSBuildToolsPath'])
         .then(function (output) {
+            console.log('spawn', output);
             // fetch msbuild path from 'reg' output
             var toolsPath = /MSBuildToolsPath\s+REG_SZ\s+(.*)/i.exec(output);
             if (toolsPath) {
@@ -159,6 +178,7 @@ function checkMSBuildVersion (version) {
                 return new MSBuildTools(version, toolsPath);
             }
         }).catch(function (err) { /* eslint handle-callback-err : 0 */
+            console.log('no reg result', version, err);
             // if 'reg' exits with error, assume that registry key not found
         });
 }

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

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


[cordova-windows] 08/11: move method

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3d8bceed41bde9c4e968106ad565ea454d10cd27
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Wed Feb 14 19:30:31 2018 +0100

    move method
---
 template/cordova/lib/MSBuildTools.js | 51 ++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/template/cordova/lib/MSBuildTools.js b/template/cordova/lib/MSBuildTools.js
index 5d9fe2c..43dcf25 100644
--- a/template/cordova/lib/MSBuildTools.js
+++ b/template/cordova/lib/MSBuildTools.js
@@ -184,31 +184,6 @@ function checkMSBuildVersion (version) {
         });
 }
 
-// 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
-    if (!programFilesFolder) return [];
-
-    var uapFolderPath = path.join(programFilesFolder, 'Windows Kits', '10', 'Platforms', 'UAP');
-    if (!shell.test('-e', uapFolderPath)) {
-        return []; // No UAP SDK exists on this machine
-    }
-
-    var result = [];
-    shell.ls(uapFolderPath).filter(function (uapDir) {
-        return shell.test('-d', path.join(uapFolderPath, uapDir));
-    }).map(function (folder) {
-        return Version.tryParse(folder);
-    }).forEach(function (version, index) {
-        if (version) {
-            result.push(version);
-        }
-    });
-
-    return result;
-};
 
 // gets the latest MSBuild version from a list of versions
 module.exports.getLatestMSBuild = function () {
@@ -354,3 +329,29 @@ module.exports.getWillowInstallations = function () {
     });
     return installations;
 };
+
+// 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
+    if (!programFilesFolder) return [];
+
+    var uapFolderPath = path.join(programFilesFolder, 'Windows Kits', '10', 'Platforms', 'UAP');
+    if (!shell.test('-e', uapFolderPath)) {
+        return []; // No UAP SDK exists on this machine
+    }
+
+    var result = [];
+    shell.ls(uapFolderPath).filter(function (uapDir) {
+        return shell.test('-d', path.join(uapFolderPath, uapDir));
+    }).map(function (folder) {
+        return Version.tryParse(folder);
+    }).forEach(function (version, index) {
+        if (version) {
+            result.push(version);
+        }
+    });
+
+    return result;
+};
\ No newline at end of file

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

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


[cordova-windows] 09/11: fix eslint

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit cca9e190047aa5ea9cb77725e536a19b8274a65a
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Wed Feb 14 20:00:20 2018 +0100

    fix eslint
---
 template/cordova/lib/MSBuildTools.js | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/template/cordova/lib/MSBuildTools.js b/template/cordova/lib/MSBuildTools.js
index 43dcf25..43fcb6d 100644
--- a/template/cordova/lib/MSBuildTools.js
+++ b/template/cordova/lib/MSBuildTools.js
@@ -90,14 +90,14 @@ module.exports.findAvailableVersion = function () {
 // check_reqs.js -> checkMSBuild()
 module.exports.findAllAvailableVersions = function () {
     console.log('findAllAvailableVersions');
-    // CB-11548 use VSINSTALLDIR environment if defined to find MSBuild. 
+    // CB-11548 use VSINSTALLDIR environment if defined to find MSBuild.
     if (process.env.VSINSTALLDIR) {
         var msBuildPath = path.join(process.env.VSINSTALLDIR, 'MSBuild/15.0/Bin');
         return module.exports.getMSBuildToolsAt(msBuildPath)
             .then(function (msBuildTools) {
                 return [msBuildTools];
             })
-            // If VSINSTALLDIR is not specified or doesn't contain the MSBuild path we are 
+            // If VSINSTALLDIR is not specified or doesn't contain the MSBuild path we are
             // looking for - fall back to default discovery mechanism.
             .catch(findAllAvailableVersionsFallBack);
     }
@@ -133,14 +133,14 @@ module.exports.getMSBuildToolsAt = function (location) {
         .then(function (output) {
             // MSBuild prints its' version as 14.0.25123.0, so we pick only first 2 segments
             var version = output.match(/^(\d+\.\d+)/)[1];
-            console.log('return new MSBuildTools', version, location)
+            console.log('return new MSBuildTools', version, location);
             return new MSBuildTools(version, location);
         });
 };
 
 function checkMSBuildVersion (version) {
     console.log('checkMSBuildVersion', version);
-    
+
     // first, check if we have a VS 2017+ with such a version
     var willows = module.exports.getWillowInstallations();
     console.log('willows', willows);
@@ -211,14 +211,13 @@ module.exports.getLatestMSBuild = function () {
 
             if (availableVersions.length > 0) {
                 // After sorting the first item will be the highest version available
-                msbuild = availableVersions[0];
+                var msbuild = availableVersions[0];
                 events.emit('verbose', 'Using MSBuild v' + msbuild.version + ' from ' + msbuild.path);
                 return msbuild;
             }
-    });
+        });
 };
 
-
 var projFiles = {
     phone: 'CordovaApp.Phone.jsproj',
     win: 'CordovaApp.Windows.jsproj',
@@ -244,7 +243,7 @@ function msBuild155TargetsFilter (target) {
     return target === projFiles.win10;
 }
 
-MSBuildTools.prototype.filterSupportedTargets = function(targets) {
+MSBuildTools.prototype.filterSupportedTargets = function (targets) {
     var msbuild = this;
     console.log('MSBuildTools->filterSupportedTargets', targets, msbuild);
     if (!targets || targets.length === 0) {
@@ -278,7 +277,7 @@ MSBuildTools.prototype.filterSupportedTargets = function(targets) {
             'or Visual Studio 2013 Update 2 for Windows 8.1.');
     }
     return supportedTargets;
-}
+};
 
 /**
  * Lists all VS 2017+ instances dirs in ProgramData
@@ -354,4 +353,4 @@ module.exports.getAvailableUAPVersions = function () {
     });
 
     return result;
-};
\ No newline at end of file
+};

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

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


[cordova-windows] 03/11: clearer comment

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8e7087efb7d9e56fc9d8ff6db1cb657be30fb2e3
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Wed Feb 14 19:15:20 2018 +0100

    clearer comment
---
 template/cordova/lib/MSBuildTools.js | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/template/cordova/lib/MSBuildTools.js b/template/cordova/lib/MSBuildTools.js
index 261aa72..fa4ca38 100644
--- a/template/cordova/lib/MSBuildTools.js
+++ b/template/cordova/lib/MSBuildTools.js
@@ -89,16 +89,17 @@ module.exports.findAvailableVersion = function () {
 // 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
-    // to default discovery mechanism.
     console.log('findAllAvailableVersions');
+    // CB-11548 use VSINSTALLDIR environment if defined to find MSBuild. 
     if (process.env.VSINSTALLDIR) {
         var msBuildPath = path.join(process.env.VSINSTALLDIR, 'MSBuild/15.0/Bin');
         return module.exports.getMSBuildToolsAt(msBuildPath)
             .then(function (msBuildTools) {
                 return [msBuildTools];
-            }).catch(findAllAvailableVersionsFallBack);
+            })
+            // If VSINSTALLDIR is not specified or doesn't contain the MSBuild path we are 
+            // looking for - fall back to default discovery mechanism.
+            .catch(findAllAvailableVersionsFallBack);
     }
 
     return findAllAvailableVersionsFallBack();

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

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


[cordova-windows] 11/11: better logging for checkMSBuildVersion future method preparation

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 55639d8e9a4a4a12e1d3308d479769d690fa81d5
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Wed Feb 14 20:28:00 2018 +0100

    better logging for checkMSBuildVersion
    future method preparation
---
 template/cordova/lib/MSBuildTools.js | 28 +++++++++++++++++++---------
 template/cordova/lib/build.js        |  2 +-
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/template/cordova/lib/MSBuildTools.js b/template/cordova/lib/MSBuildTools.js
index 3cacc3b..cc86d9f 100644
--- a/template/cordova/lib/MSBuildTools.js
+++ b/template/cordova/lib/MSBuildTools.js
@@ -143,22 +143,23 @@ function checkMSBuildVersion (version) {
 
     // first, check if we have a VS 2017+ with such a version
     var willows = module.exports.getWillowInstallations();
-    console.log('willows', willows);
+    //console.log('willows', willows);
     var correspondingWillows = willows.filter(function (inst) {
-        console.log('correspondingWillow', inst.version === version);
+        //console.log('willows.filter', inst.version, version, inst.version === version);
         return inst.version === version;
     });
-    console.log('correspondingWillows', correspondingWillows);
-    var correspondingWillow = correspondingWillows[1];
+    //console.log('correspondingWillows', correspondingWillows);
+    var correspondingWillow = correspondingWillows[0]; // TODO Do not only handle one!
     if (correspondingWillow) {
-        // TODO adapt for 15.5=>15.0 case
         version = '15.0';
         var toolsPath = path.join(correspondingWillow.path, 'MSBuild', version, 'Bin');
-        console.log('correspondingWillow:', toolsPath);
+        console.log('matching VS:', version, toolsPath);
+        console.log('from list of VS installations: ', correspondingWillows);
         if (shell.test('-e', toolsPath)) {
-            console.log('correspondingWillow:', toolsPath, module.exports.getMSBuildToolsAt(toolsPath));
+            var msbuild = module.exports.getMSBuildToolsAt(toolsPath);
+            console.log('selected VS exists:', toolsPath, );
             // TODO check for JavaScript folder
-            return module.exports.getMSBuildToolsAt(toolsPath);
+            return msbuild;
         }
     }
 
@@ -179,11 +180,20 @@ function checkMSBuildVersion (version) {
                 return new MSBuildTools(version, toolsPath);
             }
         }).catch(function (err) { /* eslint handle-callback-err : 0 */
-            console.log('no reg result', version, err);
+            console.log('no registry result for version ' + version);
             // if 'reg' exits with error, assume that registry key not found
         });
+
+    console.log('no msbuild found with version ', version);
 }
 
+module.exports.getLatestMatchingMSBuild = function (selectedBuildTargets) {
+    events.emit('verbose', 'getLatestMatchingMSBuild');
+    console.log('getLatestMatchingMSBuild', selectedBuildTargets);
+    var msbuild = this.getLatestMSBuild();
+    // we don't do anything with selectedBuildTargets yet, but could theoretically nope out if this msbuild doesn't work for that target
+    return msbuild;
+};
 
 // gets the latest MSBuild version from a list of versions
 module.exports.getLatestMSBuild = function () {
diff --git a/template/cordova/lib/build.js b/template/cordova/lib/build.js
index efbf22b..d06c8ec 100644
--- a/template/cordova/lib/build.js
+++ b/template/cordova/lib/build.js
@@ -60,7 +60,7 @@ module.exports.run = function run (buildOptions) {
     // get build targets
     var selectedBuildTargets = getBuildTargets(buildConfig.win, buildConfig.phone, buildConfig.projVerOverride, buildConfig);
 
-    return MSBuildTools.getLatestMSBuild() // get latest msbuild tools
+    return MSBuildTools.getLatestMatchingMSBuild(selectedBuildTargets) // get latest msbuild tools
         .then(function (msbuild) {
 
             // filter targets to make sure they are supported on this development machine

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

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


[cordova-windows] 04/11: move method

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 933d2f23832b80e52be977714d2333fdddfbf0d5
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Wed Feb 14 19:17:05 2018 +0100

    move method
---
 template/cordova/lib/MSBuildTools.js | 54 ++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/template/cordova/lib/MSBuildTools.js b/template/cordova/lib/MSBuildTools.js
index fa4ca38..adb2676 100644
--- a/template/cordova/lib/MSBuildTools.js
+++ b/template/cordova/lib/MSBuildTools.js
@@ -210,6 +210,33 @@ module.exports.getAvailableUAPVersions = function () {
     return result;
 };
 
+// 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];
+    }
+};
+
 /**
  * Lists all VS 2017+ instances dirs in ProgramData
  *
@@ -259,30 +286,3 @@ 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];
-    }
-};

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

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


[cordova-windows] 10/11: Visual Studio 15.5 is a thing the script should know about

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit eaa1a346b2f2b79a04e6d1812dd9ab4c13524702
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Wed Feb 14 20:01:03 2018 +0100

    Visual Studio 15.5 is a thing the script should know about
---
 template/cordova/lib/MSBuildTools.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/template/cordova/lib/MSBuildTools.js b/template/cordova/lib/MSBuildTools.js
index 43fcb6d..3cacc3b 100644
--- a/template/cordova/lib/MSBuildTools.js
+++ b/template/cordova/lib/MSBuildTools.js
@@ -75,12 +75,12 @@ 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'];
+    var versions = ['15.5', '15.0', '14.0', '12.0', '4.0'];
 
     return Q.all(versions.map(checkMSBuildVersion)).then(function (versions) {
         console.log('findAvailableVersion', versions);
         // select first msbuild version available, and resolve promise with it
-        var msbuildTools = versions[0] || versions[1] || versions[2] || versions[3];
+        var msbuildTools = versions[0] || versions[1] || versions[2] || versions[3] || versions[4];
 
         return msbuildTools ? Q.resolve(msbuildTools) : Q.reject('MSBuild tools not found');
     });
@@ -106,9 +106,9 @@ module.exports.findAllAvailableVersions = function () {
 };
 
 function findAllAvailableVersionsFallBack () {
-    var versions = ['15.0', '14.0', '12.0', '4.0'];
     console.log('findAllAvailableVersionsFALLBACK');
 
+    var versions = ['15.5', '15.0', '14.0', '12.0', '4.0'];
     events.emit('verbose', 'Searching for available MSBuild versions...');
 
     return Q.all(versions.map(checkMSBuildVersion)).then(function (unprocessedResults) {

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

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


[cordova-windows] 01/11: move method

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit bd550efdbf3fcac1540401b4672438671c9605a6
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Wed Feb 14 19:09:40 2018 +0100

    move method
---
 template/cordova/lib/MSBuildTools.js | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/template/cordova/lib/MSBuildTools.js b/template/cordova/lib/MSBuildTools.js
index cfbf4e0..0444ba3 100644
--- a/template/cordova/lib/MSBuildTools.js
+++ b/template/cordova/lib/MSBuildTools.js
@@ -85,17 +85,6 @@ module.exports.findAvailableVersion = function () {
     });
 };
 
-function findAllAvailableVersionsFallBack () {
-    var versions = ['15.0', '14.0', '12.0', '4.0'];
-    events.emit('verbose', 'Searching for available MSBuild versions...');
-
-    return Q.all(versions.map(checkMSBuildVersion)).then(function (unprocessedResults) {
-        return unprocessedResults.filter(function (item) {
-            return !!item;
-        });
-    });
-}
-
 // build.js -> run()
 // check_reqs.js -> checkMSBuild()
 module.exports.findAllAvailableVersions = function () {
@@ -113,6 +102,17 @@ module.exports.findAllAvailableVersions = function () {
     return findAllAvailableVersionsFallBack();
 };
 
+function findAllAvailableVersionsFallBack () {
+    var versions = ['15.0', '14.0', '12.0', '4.0'];
+    events.emit('verbose', 'Searching for available MSBuild versions...');
+
+    return Q.all(versions.map(checkMSBuildVersion)).then(function (unprocessedResults) {
+        return unprocessedResults.filter(function (item) {
+            return !!item;
+        });
+    });
+}
+
 /**
  * Gets MSBuildTools instance for user-specified location
  *

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

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


[cordova-windows] 05/11: move filterSupportedTargets from build.js to MSBuildTools.js

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6295571a79e083409e840b1bcfeaa341bdf9f536
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Wed Feb 14 19:19:48 2018 +0100

    move filterSupportedTargets from build.js to MSBuildTools.js
---
 template/cordova/lib/MSBuildTools.js | 60 ++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/template/cordova/lib/MSBuildTools.js b/template/cordova/lib/MSBuildTools.js
index adb2676..80a9fcf 100644
--- a/template/cordova/lib/MSBuildTools.js
+++ b/template/cordova/lib/MSBuildTools.js
@@ -236,6 +236,66 @@ module.exports.getLatestMSBuild = function (allMsBuildVersions) {
         return availableVersions[0];
     }
 };
+var projFiles = {
+    phone: 'CordovaApp.Phone.jsproj',
+    win: 'CordovaApp.Windows.jsproj',
+    win10: 'CordovaApp.Windows10.jsproj'
+};
+
+// TODO: Fix this so that it outlines supported versions based on version criteria:
+// - v14: Windows 8.1, Windows 10
+// - v12: Windows 8.1
+function msBuild12TargetsFilter (target) {
+    return target === projFiles.win || target === projFiles.phone;
+}
+
+function msBuild14TargetsFilter (target) {
+    return target === projFiles.win || target === projFiles.phone || target === projFiles.win10;
+}
+
+function msBuild15TargetsFilter (target) {
+    return target === projFiles.win || target === projFiles.phone || target === projFiles.win10;
+}
+
+function msBuild155TargetsFilter (target) {
+    return target === projFiles.win10;
+}
+
+MSBuildTools.prototype.filterSupportedTargets = function(targets) {
+    var msbuild = this;
+    console.log('MSBuildTools->filterSupportedTargets', targets, msbuild);
+    if (!targets || targets.length === 0) {
+        events.emit('warn', 'No build targets specified');
+        return [];
+    }
+
+    var targetFilters = {
+        '12.0': msBuild12TargetsFilter,
+        '14.0': msBuild14TargetsFilter,
+        '15.x': msBuild15TargetsFilter,
+        '15.5': msBuild155TargetsFilter,
+        get: function (version) {
+            // Apart from exact match also try to get filter for version range
+            // so we can find for example targets for version '15.1'
+            return this[version] || this[version.replace(/\.\d+$/, '.x')];
+        }
+    };
+
+    var filter = targetFilters.get(msbuild.version);
+    if (!filter) {
+        events.emit('warn', 'MSBuild v' + msbuild.version + ' is not supported, aborting.');
+        return [];
+    }
+
+    var supportedTargets = targets.filter(filter);
+    // unsupported targets have been detected
+    if (supportedTargets.length !== targets.length) {
+        events.emit('warn', 'Not all desired build targets are compatible with the current build environment. ' +
+            'Please install Visual Studio 2015 for Windows 8.1 and Windows 10, ' +
+            'or Visual Studio 2013 Update 2 for Windows 8.1.');
+    }
+    return supportedTargets;
+}
 
 /**
  * Lists all VS 2017+ instances dirs in ProgramData

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

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