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  * -w keepWhite - keeps the white space in the output files.
15  * -a autoBuild - puts target in INPUTDIR/compiled/Core-TIMESTAMP.js and enabled translastion
16  * 
17  * -m module name used with autoBuild to force a module name.
18  * compresses files listed as arguments and outputs result
19  */
20  
21 File            = imports.File.File;
22 Packer          = imports.JSDOC.Packer.Packer;
23
24
25  
26   
27
28 var args = Array.prototype.slice.call(Seed.argv);
29 args.shift(); //seed
30 args.shift(); // pack.js
31 var cfg = {
32     files : [],
33     target : false,
34     srcfiles : [],
35     autoBuild : false
36 }
37
38
39 for(var i =0; i < args.length;i++) {
40     if (args[i] == '-o') {
41         cfg.target = args[i+1];
42         i++;
43         continue;
44     }
45     if (args[i] == '-O') {
46         cfg.debugTarget = args[i+1];
47         i++;
48         continue;
49     }
50     if (args[i] == '-t') {
51         cfg.translateJSON = args[i+1];
52         i++;
53         continue;
54     }
55     if (args[i] == '-w') {
56         cfg.tmpDir = args[i+1];
57         i++;
58         continue;
59     }
60     if (args[i] == '-p') {
61         cfg.prefix = args[i+1];
62         i++;
63         continue;
64     }
65  
66     if (args[i] == '-C') {
67         cfg.cleanup = false;
68         continue;
69     }
70     if (args[i] == '-f') {
71         cfg.srcfiles.push(args[i+1]);
72         i++;
73         continue;
74     }
75     if (args[i] == '-m') {
76         cfg.module = args[i+1];
77         i++;
78         continue;
79     }
80     if (args[i] == '-a') {
81         cfg.autoBuild = true
82         continue;
83     }
84     if (args[i] == '-w') {
85         cfg.keepWhite = true
86         continue;
87     }
88     if (cfg.files.indexOf(args[i]) > -1) {
89         continue; // remove dupes.
90     }
91     cfg.files.push(args[i]);
92 }
93 var pack;
94 try {
95     pack = new Packer(cfg)
96 } catch (e) {
97     print("ERROR " + e.toString());
98     throw e;
99 }
100 if (!pack.target) {
101     print(pack.out);
102 }
103
104