Bug 508721 - fixing a bug in argument passing in WinCE build tools, r=blassey
authorAlex Pakhotin <alexp@mozilla.com>
Thu, 10 Sep 2009 14:32:32 -0700
changeset 32378 613cf52be14d539ba7139d728ac0d798710aea9b
parent 32377 709036ca57686bfc9fd5a0d19fe52cca5dacd35a
child 32379 4448e1b581b768df0d1ed56df71a0e58a8b71add
push idunknown
push userunknown
push dateunknown
reviewersblassey
bugs508721
milestone1.9.3a1pre
Bug 508721 - fixing a bug in argument passing in WinCE build tools, r=blassey
build/wince/tools/arm-wince-as.c
build/wince/tools/toolspath.c
build/wince/tools/toolspath.h
--- a/build/wince/tools/arm-wince-as.c
+++ b/build/wince/tools/arm-wince-as.c
@@ -2,14 +2,16 @@
 
 int 
 main(int argc, char **argv)
 {  
   char* args[1000];
   int i = 0;
   
   args[i++] = ASM_PATH;
-  args[i++] = "-I\"" WCE_INC "\""; 
+
+  // armasm.exe requires a space between -I and the path. See bug 508721
+  args[i++] = "-I \"" WCE_INC "\""; 
 
   i += argpath_conv(&argv[1], &args[i]);
 
   return run(args);
 }
--- a/build/wince/tools/toolspath.c
+++ b/build/wince/tools/toolspath.c
@@ -183,53 +183,58 @@ void dumpargs(char** args)
 
 DWORD run(char** args)
 {
 
  DWORD exitCode;
  STARTUPINFO si;
  PROCESS_INFORMATION pi;
 
- char theArgs[1024*32] = {'\0'};
+ char theCmdLine[1024*32] = {'\0'};
 
  int totalLen = 0;
  int i, j;
 
 
  // Clear any link env variable that might get us tangled up
  _putenv("LINK=");
  _putenv("LIBPATH=");
  _putenv("CC=");
 
  _putenv("INCLUDE=" SHUNT_INC ";" WM_SDK_INC ";" OGLES_SDK_INC ";" WCE_INC);
  _putenv("LIB=" WCE_LIB ";" OGLES_SDK_LIB ";" WCE_CRT);
 
- for (j=1; args[j]; j++)
- {
-   int len = strlen(args[j]);
-   strcat(&theArgs[totalLen], args[j]);
-   totalLen += len;
-
-   strcat(&theArgs[totalLen], " ");
-   totalLen++;
- }
-
  i = strlen(args[0]);
  for (j=0; j<i; j++)
  {
    if (args[0][j] == '/')
      args[0][j] = '\\';
  }
 
+ for (j=0; args[j]; j++)
+ {
+   int len = strlen(args[j]);
+   strcat(&theCmdLine[totalLen], args[j]);
+   totalLen += len;
+
+   strcat(&theCmdLine[totalLen], " ");
+   totalLen++;
+ }
+
  ZeroMemory( &si, sizeof(si) );
  si.cb = sizeof(si);
  ZeroMemory( &pi, sizeof(pi));
 
- CreateProcess(args[0],
-               theArgs,
+ // See bug 508721.
+ // lpApplicationName (first parameter) when provided conflicts with
+ // the first token in the lpCommandLine (second parameter).
+ // So we pass the whole command line including the EXE in lpCommandLine.
+ // See http://support.microsoft.com/kb/175986 for more info.
+ CreateProcess(NULL,
+               theCmdLine,
                NULL,
                NULL,
                0,
                0,
                NULL,
                NULL,
                &si,              // Pointer to STARTUPINFO structure.
                &pi);
--- a/build/wince/tools/toolspath.h
+++ b/build/wince/tools/toolspath.h
@@ -20,21 +20,21 @@
 #ifndef SHUNT_LIB
 #define SHUNT_LIB ""
 #endif
 
 #ifndef SHUNT_INC
 #define SHUNT_INC TOPSRCDIR "/build/wince/shunt/include/"
 #endif
 
-#define ASM_PATH  WCE_BIN "armasm.exe"
-#define CL_PATH   WCE_BIN "cl.exe"
-#define LIB_PATH  WCE_BIN "lib.exe"
-#define LINK_PATH WCE_BIN "link.exe"
-#define RC_PATH   WCE_RC_BIN "rc.exe"
+#define ASM_PATH  "\"" WCE_BIN "armasm.exe\""
+#define CL_PATH   "\"" WCE_BIN "cl.exe\""
+#define LIB_PATH  "\"" WCE_BIN "lib.exe\""
+#define LINK_PATH "\"" WCE_BIN "link.exe\""
+#define RC_PATH   "\"" WCE_RC_BIN "rc.exe\""
 
 #define MAX_NOLEAK_BUFFERS 1000
 char noleak_buffers[MAX_NOLEAK_BUFFERS][1024];
 static int next_buffer = 0;
 int argpath_conv(char **args_in, char **args_out);
 void dumpargs(char** args);
 DWORD run(char** args);