You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/06/06 23:02:31 UTC

git commit: Adds support for target architectures to build command

Repository: cordova-wp8
Updated Branches:
  refs/heads/master 1bd7f196d -> 351ff3e74


Adds support for target architectures to build command


Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/351ff3e7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/351ff3e7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/351ff3e7

Branch: refs/heads/master
Commit: 351ff3e74b07e4d380a244cfb443e51257c7edb7
Parents: 1bd7f19
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Fri Jun 6 10:45:08 2014 +0400
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Fri Jun 6 16:37:32 2014 +0400

----------------------------------------------------------------------
 wp8/template/CordovaWP8AppProj.csproj |  20 +++
 wp8/template/CordovaWP8Solution.sln   |  24 +++-
 wp8/template/cordova/lib/build.js     | 198 ++++++++++++++++-------------
 3 files changed, 153 insertions(+), 89 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/351ff3e7/wp8/template/CordovaWP8AppProj.csproj
----------------------------------------------------------------------
diff --git a/wp8/template/CordovaWP8AppProj.csproj b/wp8/template/CordovaWP8AppProj.csproj
index d1ebc9d..a58200f 100644
--- a/wp8/template/CordovaWP8AppProj.csproj
+++ b/wp8/template/CordovaWP8AppProj.csproj
@@ -119,6 +119,26 @@
     <CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
     <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
+    <NoStdLib>true</NoStdLib>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <OutputPath>bin\x64\Release\</OutputPath>
+    <DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
+    <Optimize>true</Optimize>
+    <NoStdLib>true</NoStdLib>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
   <ItemGroup>
     <Compile Include="App.xaml.cs">
       <DependentUpon>App.xaml</DependentUpon>

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/351ff3e7/wp8/template/CordovaWP8Solution.sln
----------------------------------------------------------------------
diff --git a/wp8/template/CordovaWP8Solution.sln b/wp8/template/CordovaWP8Solution.sln
index 707a369..67b1b62 100644
--- a/wp8/template/CordovaWP8Solution.sln
+++ b/wp8/template/CordovaWP8Solution.sln
@@ -25,22 +25,38 @@ Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Debug|ARM = Debug|ARM
+		Debug|x64 = Debug|x64
 		Debug|x86 = Debug|x86
 		Release|Any CPU = Release|Any CPU
 		Release|ARM = Release|ARM
+		Release|x64 = Release|x64
 		Release|x86 = Release|x86
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
-		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|ARM.ActiveCfg = Debug|Any CPU
-		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|ARM.ActiveCfg = Debug|ARM
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|ARM.Build.0 = Debug|ARM
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|ARM.Deploy.0 = Debug|ARM
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|x64.ActiveCfg = Debug|x64
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|x64.Build.0 = Debug|x64
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|x64.Deploy.0 = Debug|x64
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|x86.ActiveCfg = Debug|x64
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|x86.Build.0 = Debug|x64
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|x86.Deploy.0 = Debug|x64
 		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|Any CPU.Build.0 = Release|Any CPU
 		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|Any CPU.Deploy.0 = Release|Any CPU
-		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|ARM.ActiveCfg = Release|Any CPU
-		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|x86.ActiveCfg = Release|Any CPU
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|ARM.ActiveCfg = Release|ARM
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|ARM.Build.0 = Release|ARM
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|ARM.Deploy.0 = Release|ARM
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|x64.ActiveCfg = Release|x64
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|x64.Build.0 = Release|x64
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|x64.Deploy.0 = Release|x64
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|x86.ActiveCfg = Release|x86
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|x86.Build.0 = Release|x86
+		{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|x86.Deploy.0 = Release|x86
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/351ff3e7/wp8/template/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/lib/build.js b/wp8/template/cordova/lib/build.js
index b250762..27ce323 100644
--- a/wp8/template/cordova/lib/build.js
+++ b/wp8/template/cordova/lib/build.js
@@ -25,6 +25,11 @@ var procEnv = wscript_shell.Environment("Process");
 var procArchitecture = procEnv("PROCESSOR_ARCHITECTURE").toLowerCase();
 var is64Mode = procArchitecture && procArchitecture != 'x86';
 
+// build type. Possible values: "debug", "release"
+var buildType = null,
+// list of build architectures. list of strings
+buildArchs = null;
+
 var args = WScript.Arguments;
 
 // working dir
@@ -33,14 +38,17 @@ var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\build.js').join('');
 // help/usage function
 function Usage() {
     Log("");
-    Log("Usage: build [ --debug | --release ]");
+    Log("Usage: build [ --debug | --release ] [--archs=\"<list of architectures...>\"]");
     Log("    --help    : Displays this dialog.");
     Log("    --debug   : Cleans and builds project in debug mode.");
     Log("    --release : Cleans and builds project in release mode.");
+    Log("    --release : Cleans and builds project in release mode.");
+    Log("    --archs   : Builds project binaries for specific chip architectures.");
     Log("examples:");
     Log("    build ");
     Log("    build --debug");
     Log("    build --release");
+    Log("    build --release --archs=\"arm x86\"");
     Log("");
 }
 
@@ -127,88 +135,119 @@ function getMSBuildToolsPath() {
     WScript.Quit(2);
 }
 
-// builds the project and .xap in release mode
-function build_xap_release(path) {
+// builds the project and .xap with buildtype and architectures specified
+function build_xap(path, buildtype, buildarchs) {
+
+    // check if file xap was created for specified buldtype and architecture
+    // raises error if xap not found
+    function checkForXap (path, mode, arch) {
+        var buildFolder = arch.toLowerCase() == 'any cpu' ? path + '\\Bin\\' + mode : path + '\\Bin\\' + arch + '\\' + mode;
+        Log('Checking for .xap in: ' + buildFolder);
+        if (fso.FolderExists(buildFolder)) {
+            var out_folder = fso.GetFolder(buildFolder);
+            var out_files = new Enumerator(out_folder.Files);
+            for (;!out_files.atEnd(); out_files.moveNext()) {
+                if (fso.GetExtensionName(out_files.item()) == 'xap') {
+                    Log("BUILD SUCCESS.\n");
+                    return;
+                }
+            }
+        }
+        Log('ERROR: MSBuild failed to create .xap when building cordova-wp8 for release.', true);
+        WScript.Quit(2);
+    }
 
-    exec_verbose('%comspec% /c "' + path + '\\cordova\\clean"');
+    if (!buildtype) {
+        Log("WARNING: [ --debug | --release ] not specified, defaulting to debug...");
+        buildtype = "debug";
+    }
 
-    Log("Building Cordova-WP8 Project:");
-    Log("\tConfiguration : Release");
-    Log("\tDirectory : " + path);
+    if (!buildarchs) {
+        Log("WARNING: target architecture not specified, defaulting to AnyCPU...");
+        buildarchs = ["Any CPU"];
+    }
 
-    wscript_shell.CurrentDirectory = path;
+    exec_verbose('%comspec% /c "' + path + '\\cordova\\clean"');
     
     var MSBuildToolsPath = getMSBuildToolsPath();
     Log("\tMSBuildToolsPath: " + MSBuildToolsPath);
 
-    var buildCommand = escapePath(MSBuildToolsPath + 'msbuild') + ' ' + escapePath(get_solution_name(path)) +
-            ' /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Release';
-        
-    // hack to get rid of 'Access is denied.' error when running the shell w/ access to C:\path..
-    buildCommand = 'cmd /c "' + buildCommand + '"';
-        
-    Log("buildCommand = " + buildCommand);
+    for (var i = 0; i < buildarchs.length; i++) {
+        var buildarch = buildarchs[i];
 
-    if (exec_verbose(buildCommand) != 0) {
-        // msbuild failed
-        WScript.Quit(2);
-    }
+        Log("Building Cordova-WP8 Project:");
+        Log("\tConfiguration : " + buildtype);
+        Log("\tPlatform      : " + buildarch);
+        Log("\tDirectory     : " + path);
 
-    // check if file xap was created
-    if (fso.FolderExists(path + '\\Bin\\Release')) {
-        var out_folder = fso.GetFolder(path + '\\Bin\\Release');
-        var out_files = new Enumerator(out_folder.Files);
-        for (;!out_files.atEnd(); out_files.moveNext()) {
-            if (fso.GetExtensionName(out_files.item()) == 'xap') {
-                Log("BUILD SUCCESS.");
-                return;
-            }
-        }
-    }
-    Log('ERROR: MSBuild failed to create .xap when building cordova-wp8 for release.', true);
-    WScript.Quit(2);
-}
-
-// builds the project and .xap in debug mode
-function build_xap_debug(path) {
+        wscript_shell.CurrentDirectory = path;
 
-    exec_verbose('%comspec% /c "' + path + '\\cordova\\clean"');
+        var buildCommand = escapePath(MSBuildToolsPath + 'msbuild') +
+                ' ' + escapePath(get_solution_name(path)) +
+                ' /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal' +
+                ' /nologo' +
+                ' /p:Configuration=' + buildtype +
+                ' /p:Platform="' + buildarch + '"';
 
-    Log("Building Cordova-WP8 Project:");
-    Log("\tConfiguration : Debug");
-    Log("\tDirectory : " + path);
+        // hack to get rid of 'Access is denied.' error when running the shell w/ access to C:\path..
+        buildCommand = '%comspec% /c "' + buildCommand + '"';
 
-    wscript_shell.CurrentDirectory = path;
+        Log("buildCommand = " + buildCommand);
 
-    var MSBuildToolsPath = getMSBuildToolsPath();
-    Log("\tMSBuildToolsPath: " + MSBuildToolsPath);
+        if (exec_verbose(buildCommand) !== 0) {
+            // msbuild failed
+            WScript.Quit(2);
+        }
 
-    var buildCommand = escapePath(MSBuildToolsPath + 'msbuild') + ' ' + escapePath(get_solution_name(path)) +
-            ' /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Debug';
+        checkForXap(path, buildtype, buildarch);
+    }
 
-    // hack to get rid of 'Access is denied.' error when running the shell w/ access to C:\path..
-    buildCommand = '%comspec% /c "' + buildCommand + '"';
+    Log("WP8 builds successfully completed.");
+}
 
-    Log("buildCommand = " + buildCommand);
+// parses script args and set global variables for build
+// throws error if unknown argument specified.
+function parseArgs () {
 
-    if (exec_verbose(buildCommand) != 0) {
-        // msbuild failed
-        WScript.Quit(2);
+    // return build type, specified by input string, or null, if not build type parameter
+    function getBuildType (arg) {
+        arg = arg.toLowerCase();
+        if (arg == "--debug" || arg == "-d") {
+            return "debug";
+        }
+        else if (arg == "--release" || arg == "-r") {
+            return "release";
+        }
+        return null;
     }
 
-    // check if file xap was created
-    if (fso.FolderExists(path + '\\Bin\\Debug')) {
-        var out_folder = fso.GetFolder(path + '\\Bin\\Debug');
-        var out_files = new Enumerator(out_folder.Files);
-        for (;!out_files.atEnd(); out_files.moveNext()) {
-            if (fso.GetExtensionName(out_files.item()) == 'xap') {
-                Log("BUILD SUCCESS.");
-                return;
+    // returns build architectures list, specified by input string
+    // or null if nothing specified, or not --archs parameter
+    function getBuildArchs (arg) {
+        arg = arg.toLowerCase();
+        var archs = /--archs=(.+)/.exec(arg);
+        if (archs) {
+            // if architectures list contains commas, suppose that is comma delimited
+            if (archs[1].indexOf(',') != -1){
+                return archs[1].split(',');
             }
+            // else space delimited
+            return archs[1].split(/\s/);
+        }
+        return null;
+    }
+
+    for (var i = 0; i < args.Length; i++) {
+        if (getBuildType(args(i))) {
+            buildType = getBuildType(args(i));
+        } else if (getBuildArchs(args(i))) {
+            buildArchs = getBuildArchs(args(i));
+        } else {
+            Log("Error: \"" + args(i) + "\" is not recognized as a build option", true);
+            Usage();
+            WScript.Quit(2);
         }
     }
-    Log('ERROR: MSBuild failed to create .xap when building cordova-wp8 for debugging.', true);
-    WScript.Quit(2);
 }
 
 
@@ -221,32 +260,21 @@ if (args.Count() > 0) {
         Usage();
         WScript.Quit(2);
     }
-    else if (fso.FolderExists(ROOT)) {
-        if (!is_cordova_project(ROOT)) {
-            Log('Error: .csproj file not found in ' + ROOT, true);
-            Log('could not build project.', true);
-            WScript.Quit(2);
-        }
-
-        if (args(0) == "--debug" || args(0) == "-d") {
-            build_xap_debug(ROOT);
-        }
-        else if (args(0) == "--release" || args(0) == "-r") {
-            build_xap_release(ROOT);
-        }
-        else {
-            Log("Error: \"" + args(0) + "\" is not recognized as a build option", true);
-            Usage();
-            WScript.Quit(2);
-        }
-    }
-    else {
+    // Handle project errors
+    else if (!fso.FolderExists(ROOT)) {
         Log("Error: Project directory not found,", true);
         Usage();
         WScript.Quit(2);
     }
+    else if (!is_cordova_project(ROOT)) {
+        Log('Error: .csproj file not found in ' + ROOT, true);
+        Log('could not build project.', true);
+        WScript.Quit(2);
+    }
+    // Parse arguments
+    else {
+        parseArgs();
+    }
 }
-else {
-    Log("WARNING: [ --debug | --release ] not specified, defaulting to debug...");
-    build_xap_debug(ROOT);
-}
+
+build_xap(ROOT, buildType, buildArchs);
\ No newline at end of file