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 - keesp 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     module : false
37 }
38
39
40 for(var i =0; i < args.length;i++) {
41     if (args[i] == '-o') {
42         cfg.target = args[i+1];
43         i++;
44         continue;
45     }
46     if (args[i] == '-O') {
47         cfg.debugTarget = args[i+1];
48         i++;
49         continue;
50     }
51     if (args[i] == '-t') {
52         cfg.translateJSON = args[i+1];
53         i++;
54         continue;
55     }
56     if (args[i] == '-w') {
57         cfg.tmpDir = args[i+1];
58         i++;
59         continue;
60     }
61     if (args[i] == '-p') {
62         cfg.prefix = args[i+1];
63         i++;
64         continue;
65     }
66  
67     if (args[i] == '-C') {
68         cfg.cleanup = false;
69         continue;
70     }
71     if (args[i] == '-f') {
72         cfg.srcfiles.push(args[i+1]);
73         i++;
74         continue;
75     }
76     if (args[i] == '-m') {
77         cfg.module = args[i+1];
78         i++;
79         continue;
80     }
81     if (args[i] == '-a') {
82         cfg.autoBuild = true
83         continue;
84     }
85     if (args[i] == '-w') {
86         cfg.keepWhite = true
87         continue;
88     }
89     if (cfg.files.indexOf(args[i]) > -1) {
90         continue; // remove dupes.
91     }
92     cfg.files.push(args[i]);
93 }
94 var pack;
95 try {
96     pack = new Packer(cfg)
97 } catch (e) {
98     print("ERROR " + e.toString());
99     throw e;
100 }
101 if (!pack.target) {
102     print(pack.out);
103 }
104
105