pack.js
[gnome.introspection-doc-generator] / pack.js
1 #!/usr/bin/seed
2 //<script type="text/javascript">
3 /**
4  * packer command line
5  * 
6  * -o Output
7  * -O Output debug file here.
8  * -t Translate json file.
9  * -w Cache / working dir.
10  * -f File to read with a list of source paths / or class names.
11  * -C no cleanup (use with -w if you need are using a cache directory.)
12  * -p prefix for translation md5 generator (directory that files are in, and is removed 
13  *    from path when generating an md5 for the translated name.
14  * -a autoBuild - puts target in INPUTDIR/compiled/Core-TIMESTAMP.js and enabled translastion
15  * -m module name used with autoBuild to force a module name.
16  * compresses files listed as arguments and outputs result
17  */
18  
19 File            = imports.File.File;
20 Packer          = imports.JSDOC.Packer.Packer;
21
22
23  
24   
25
26 var args = Array.prototype.slice.call(Seed.argv);
27 args.shift(); //seed
28 args.shift(); // pack.js
29 var cfg = {
30     files : [],
31     target : false,
32     srcfiles : [],
33     autoBuild : false,
34     module : false
35 }
36
37
38 for(var i =0; i < args.length;i++) {
39     if (args[i] == '-o') {
40         cfg.target = args[i+1];
41         i++;
42         continue;
43     }
44     if (args[i] == '-O') {
45         cfg.debugTarget = args[i+1];
46         i++;
47         continue;
48     }
49     if (args[i] == '-t') {
50         cfg.translateJSON = args[i+1];
51         i++;
52         continue;
53     }
54     if (args[i] == '-w') {
55         cfg.tmpDir = args[i+1];
56         i++;
57         continue;
58     }
59     if (args[i] == '-p') {
60         cfg.prefix = args[i+1];
61         i++;
62         continue;
63     }
64  
65     if (args[i] == '-C') {
66         cfg.cleanup = false;
67         continue;
68     }
69     if (args[i] == '-f') {
70         cfg.srcfiles.push(args[i+1]);
71         i++;
72         continue;
73     }
74     if (args[i] == '-m') {
75         cfg.module = args[i+1];
76         i++;
77         continue;
78     }
79     if (args[i] == '-a') {
80         cfg.autoBuild = true
81         continue;
82     }
83     if (args[i] == '-w') {
84         cfg.keepWhite = true
85         continue;
86     }
87     if (cfg.files.indexOf(args[i]) > -1) {
88         continue; // remove dupes.
89     }
90     cfg.files.push(args[i]);
91 }
92 var pack;
93 try {
94     pack = new Packer(cfg)
95 } catch (e) {
96     print("ERROR " + e.toString());
97     throw e;
98 }
99 if (!pack.target) {
100     print(pack.out);
101 }
102
103