|
@@ -1,5 +1,5 @@
|
|
class Generator {
|
|
class Generator {
|
|
-
|
|
|
|
|
|
+
|
|
static function compile() {
|
|
static function compile() {
|
|
var errored = [];
|
|
var errored = [];
|
|
Sys.setCwd("build");
|
|
Sys.setCwd("build");
|
|
@@ -30,41 +30,41 @@ class Generator {
|
|
}
|
|
}
|
|
Sys.println("DONE");
|
|
Sys.println("DONE");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
#if hscript
|
|
#if hscript
|
|
static function generateProjects() {
|
|
static function generateProjects() {
|
|
-
|
|
|
|
|
|
+
|
|
var templates = [];
|
|
var templates = [];
|
|
for( f in sys.FileSystem.readDirectory("templates") )
|
|
for( f in sys.FileSystem.readDirectory("templates") )
|
|
templates.push({ file : f, data : sys.io.File.getContent("templates/" + f) });
|
|
templates.push({ file : f, data : sys.io.File.getContent("templates/" + f) });
|
|
-
|
|
|
|
|
|
+
|
|
try sys.FileSystem.createDirectory("build") catch( e : Dynamic ) {};
|
|
try sys.FileSystem.createDirectory("build") catch( e : Dynamic ) {};
|
|
sys.io.File.saveContent("build/README.txt","This directory is automatically generated by samples/Script.hx using samples/templates");
|
|
sys.io.File.saveContent("build/README.txt","This directory is automatically generated by samples/Script.hx using samples/templates");
|
|
-
|
|
|
|
|
|
+
|
|
for( f in sys.FileSystem.readDirectory(".") ) {
|
|
for( f in sys.FileSystem.readDirectory(".") ) {
|
|
-
|
|
|
|
|
|
+
|
|
if( sys.FileSystem.isDirectory(f) || !StringTools.endsWith(f,".hx") )
|
|
if( sys.FileSystem.isDirectory(f) || !StringTools.endsWith(f,".hx") )
|
|
continue;
|
|
continue;
|
|
-
|
|
|
|
|
|
+
|
|
var title = f.split(".").shift();
|
|
var title = f.split(".").shift();
|
|
-
|
|
|
|
- if( title == "Generator" ) continue;
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ if( title == "Generator" || title == "SampleApp" ) continue;
|
|
|
|
+
|
|
var name = title.charAt(0).toLowerCase() + title.substr(1);
|
|
var name = title.charAt(0).toLowerCase() + title.substr(1);
|
|
var params = [];
|
|
var params = [];
|
|
if( sys.FileSystem.exists(name+"_res") )
|
|
if( sys.FileSystem.exists(name+"_res") )
|
|
params.push("-D resourcesPath=../../"+name+"_res");
|
|
params.push("-D resourcesPath=../../"+name+"_res");
|
|
-
|
|
|
|
|
|
+
|
|
var content = sys.io.File.getContent(f);
|
|
var content = sys.io.File.getContent(f);
|
|
~/\/\/PARAM=(.*)/g.map(content,function(r) { params.push(StringTools.trim(r.matched(1))); return ""; });
|
|
~/\/\/PARAM=(.*)/g.map(content,function(r) { params.push(StringTools.trim(r.matched(1))); return ""; });
|
|
-
|
|
|
|
|
|
+
|
|
var context = {
|
|
var context = {
|
|
main : title,
|
|
main : title,
|
|
name : name,
|
|
name : name,
|
|
params : params.join("\n"),
|
|
params : params.join("\n"),
|
|
StringTools : StringTools,
|
|
StringTools : StringTools,
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
try sys.FileSystem.createDirectory("build/"+name) catch( e : Dynamic ) {};
|
|
try sys.FileSystem.createDirectory("build/"+name) catch( e : Dynamic ) {};
|
|
#if !silent
|
|
#if !silent
|
|
Sys.println(name);
|
|
Sys.println(name);
|
|
@@ -83,6 +83,6 @@ class Generator {
|
|
sys.io.File.saveContent("build/" + name + "/" + file, data);
|
|
sys.io.File.saveContent("build/" + name + "/" + file, data);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
#end
|
|
#end
|
|
}
|
|
}
|