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