4 -- in theory this code can be used as a library... but this is the standard command line version...
7 valac --vapidir=/usr/share/vala/vapi
8 --vapidir=/usr/share/vala/vapi
9 --vapidir=/usr/share/vala-0.30/vapi
11 JSDOC/Lang.vala JSDOC/TextStream.vala JSDOC/TokenReader.vala JSDOC/Token.vala JSDOC/TokenStream.vala JSDOC/Packer.vala
12 JSDOC/Collapse.vala JSDOC/ScopeParser.vala JSDOC/Scope.vala JSDOC/Identifier.vala JSDOC/CompressWhite.vala
13 JSDOC/PackerRun.vala --pkg glib-2.0 --pkg gee-1.0 --pkg gio-2.0 --pkg posix -o /tmp/jspack --target-glib=2.32 -X -lm
20 // --------------- <<<<<<< <MAIN HERE....
23 class PackerRun : Object
25 class PackerRun : Application
28 public string opt_target = null;
29 public string opt_debug_target = null;
30 // public string opt_tmpdir = null;
31 private string opt_basedir = null;
34 * @cfg baseDir -- prefix the files listed in indexfiles with this.
37 public string opt_real_basedir = null; // USE this one it's calcuated based on current path..
39 public string opt_doc_target = null;
40 public string opt_doc_template_dir = null;
41 public bool opt_doc_include_private = false;
43 [CCode (array_length = false, array_null_terminated = true)]
44 private string[]? opt_files = null;
45 [CCode (array_length = false, array_null_terminated = true)]
46 private string[]? opt_files_from = null;
49 public bool opt_debug = false;
52 * @cfg {Boolean} opt_skip_scope (optional) skip Scope parsing and replacement.
53 * usefull for debugging...
55 public bool opt_skip_scope = false;
58 * @cfg {Boolean} opt_keep_whitespace (optional) do not remove white space in output.
59 * usefull for debugging compressed files.
62 public bool opt_keep_whitespace = false;
65 * @cfg {Boolean} opt_dump_tokens (optional) read the first file and dump the tokens.
66 * usefull for debugging...
69 public bool opt_dump_tokens = false;
73 * @cfg {Boolean} opt_clean_cache (optional) clean up temp files after done -
74 * Defaults to false if you set tmpDir, otherwise true.
77 public bool opt_clean_cache = true;
79 // not actually an option yet..
81 public string opt_doc_ext = "html";
84 public OptionEntry[] options;
90 application_id: "org.roojs.jsdoc.packerrun",
91 flags: ApplicationFlags.HANDLES_COMMAND_LINE
96 { "jsfile", 'f', 0, OptionArg.FILENAME_ARRAY, ref opt_files ,"add a file to compile", null },
97 { "target", 't', 0, OptionArg.STRING, ref opt_target, "Target File to write (eg. roojs.js)", null },
98 { "debug-target", 'T', 0, OptionArg.STRING, ref opt_debug_target, "Target File to write debug code (eg. roojs-debug.js)", null },
99 //{ "tmpdir", 'm', 0, OptionArg.STRING, ref opt_tmpdir, "Temporary Directory to use (defaults to /tmp)", null },
100 { "basedir", 'b', 0, OptionArg.STRING, ref opt_basedir, "Base directory (where the files listed in index files are located.)", null },
102 { "index-files", 'i', 0, OptionArg.FILENAME_ARRAY, ref opt_files_from ,"files that contain listing of files to compile", null },
103 { "keep-whitespace", 'w', 0, OptionArg.NONE, ref opt_keep_whitespace, "Keep whitespace", null },
104 { "skip-scope", 's', 0, OptionArg.NONE, ref opt_skip_scope, "Skip scope parsing and variable replacement", null },
105 { "debug", 0, 0, OptionArg.NONE, ref opt_debug, "Show debug messages", null },
106 { "dump-tokens", 'k', 0, OptionArg.NONE, ref opt_dump_tokens, "Dump the tokens from a file", null },
107 { "clean-cache", 'c', 0, OptionArg.NONE, ref opt_clean_cache, "Clean up the cache after running (slower)", null },
109 // fixme -- keepwhite.. cleanup
111 // documentation options
112 // usage: roojspacker --basedir roojs1 \
113 // --doc-target roojs1/docs \
114 // --index-files roojs1/buildSDK/dependancy_core.txt \
115 // --index-files roojs1/buildSDK/dependancy_ui.txt \
116 // --index-files roojs1/buildSDK/dependancy_bootstrap.txt \
117 // --doc-template-dir\
120 { "doc-target", 'd', 0, OptionArg.STRING, ref opt_doc_target, "Documentation Directory target", null },
121 { "doc-template-dir", 'p', 0, OptionArg.STRING, ref opt_doc_template_dir, "Documentation Directory target", null },
122 { "doc-private", 'p', 0, OptionArg.NONE, ref opt_doc_include_private, "Document Private functions", null },
133 // what's required...
135 GLib.Log.set_handler(null,
136 GLib.LogLevelFlags.LEVEL_DEBUG | GLib.LogLevelFlags.LEVEL_WARNING,
138 print("%s: %s\n", dom, msg);
147 // set the base directory...
148 var curdir = Environment.get_current_dir() + Path.DIR_SEPARATOR_S;
149 if (opt_basedir == null) {
151 opt_real_basedir = curdir;
152 } else if (opt_basedir[0] == '/') {
153 opt_real_basedir = opt_basedir;
155 opt_real_basedir = curdir + opt_basedir;
158 if (opt_real_basedir [opt_real_basedir .length-1].to_string() != Path.DIR_SEPARATOR_S) {
159 opt_real_basedir += Path.DIR_SEPARATOR_S;
162 GLib.debug("real_base_dir = '%s' : opt_basedir ='%s'\n", opt_real_basedir , opt_basedir);
165 if (opt_files == null && opt_files_from == null) {
166 GLib.error("You must list some files with -f or -i to compile - see --help for more details");
167 GLib.Process.exit(1);
171 // now run the Packer...
172 var p = new Packer( this );
175 if (opt_files != null) {
177 foreach (var f in opt_files) {
178 GLib.debug("Adding File %s", f);
182 if (opt_files_from != null) {
184 foreach (var f in opt_files_from) {
185 GLib.debug("Adding File %s", f);
186 p.loadSourceIndex(f);
190 var run_pack = false;
191 if (opt_target != null || opt_debug_target != null || opt_dump_tokens) {
193 p.pack( opt_target == null ? "" : opt_target ,
194 opt_debug_target == null ? "" : opt_debug_target );
196 if (p.outstr.length > 0 ) {
197 stdout.printf ("%s", p.outstr);
200 if (opt_doc_target != null) {
201 //var d = new DocBuilder(p);