Bug 620931 part 6 - Add a -a option to xpcshell to set an application directory. r=bsmedberg
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 06 May 2011 10:40:51 +0200
changeset 69784 5a4b358de96f0fd0d62de0af56eade1747159eed
parent 69783 c744de96a1336d0296c9c25a9c7116fd36dfc0e4
child 69785 dec16a247230a9117fcbc4c8b5ada8bf2677643b
push id99
push usereakhgari@mozilla.com
push dateTue, 24 May 2011 18:03:59 +0000
treeherdermozilla-aurora@26d6981b3d6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs620931
milestone6.0a1
Bug 620931 part 6 - Add a -a option to xpcshell to set an application directory. r=bsmedberg
js/src/xpconnect/shell/xpcshell.cpp
--- a/js/src/xpconnect/shell/xpcshell.cpp
+++ b/js/src/xpconnect/shell/xpcshell.cpp
@@ -1145,17 +1145,17 @@ Process(JSContext *cx, JSObject *obj, co
     if (file != stdin)
         fclose(file);
 }
 
 static int
 usage(void)
 {
     fprintf(gErrFile, "%s\n", JS_GetImplementationVersion());
-    fprintf(gErrFile, "usage: xpcshell [-g gredir] [-r manifest]... [-PsSwWxCij] [-v version] [-f scriptfile] [-e script] [scriptfile] [scriptarg...]\n");
+    fprintf(gErrFile, "usage: xpcshell [-g gredir] [-a appdir] [-r manifest]... [-PsSwWxCij] [-v version] [-f scriptfile] [-e script] [scriptfile] [scriptarg...]\n");
     return 2;
 }
 
 extern JSClass global_class;
 
 static int
 ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
 {
@@ -1805,16 +1805,33 @@ main(int argc, char **argv, char **envp)
         if (!dirprovider.SetGREDir(argv[2])) {
             printf("SetGREDir failed.\n");
             return 1;
         }
         argc -= 2;
         argv += 2;
     }
 
+    if (argc > 1 && !strcmp(argv[1], "-a")) {
+        if (argc < 3)
+            return usage();
+
+        nsCOMPtr<nsILocalFile> dir;
+        rv = XRE_GetFileFromPath(argv[2], getter_AddRefs(dir));
+        if (NS_SUCCEEDED(rv)) {
+            appDir = do_QueryInterface(dir, &rv);
+        }
+        if (NS_FAILED(rv)) {
+            printf("Couldn't use given appdir.\n");
+            return 1;
+        }
+        argc -= 2;
+        argv += 2;
+    }
+
     while (argc > 1 && !strcmp(argv[1], "-r")) {
         if (argc < 3)
             return usage();
 
         nsCOMPtr<nsILocalFile> lf;
         rv = XRE_GetFileFromPath(argv[2], getter_AddRefs(lf));
         if (NS_FAILED(rv)) {
             printf("Couldn't get manifest file.\n");