瀏覽代碼

use commandline parameters instead of compiler defines

ncannasse 7 年之前
父節點
當前提交
48b66fc717
共有 1 個文件被更改,包括 26 次插入13 次删除
  1. 26 13
      hxd/fmt/pak/Build.hx

+ 26 - 13
hxd/fmt/pak/Build.hx

@@ -98,9 +98,6 @@ class Build {
 
 	function makePak() {
 
-		if( resPath == null ) resPath = "res";
-		if( outPrefix == null ) outPrefix = "res";
-
 		if( !sys.FileSystem.exists(resPath) )
 			throw "'" + resPath + "' resource directory was not found";
 
@@ -149,20 +146,36 @@ class Build {
 	}
 
 	static function main() {
+		var args = Sys.args();
 		try sys.FileSystem.deleteFile("hxd.fmt.pak.Build.n") catch( e : Dynamic ) {};
 		try sys.FileSystem.deleteFile("hxd.fmt.pak.Build.hl") catch( e : Dynamic ) {};
-		var ext = haxe.macro.Compiler.getDefine("excludeExt");
 		var b = new Build();
-		b.excludedExt = ext == null ? [] : ext.split(",");
-		b.resPath = haxe.macro.Compiler.getDefine("resourcesPath");
 		b.compressSounds = true;
-		b.outPrefix = haxe.macro.Compiler.getDefine("outPrefix");
-		#if pakDiff
-		b.pakDiff = true;
-		#end
-		#if !stb_ogg_sound
-		b.compressMP3 = true;
-		#end
+		while( args.length > 0 ) {
+			var f = args.shift();
+			var pos = f.indexOf("=");
+			if( pos > 0 ) {
+				args.unshift(f.substr(pos + 1));
+				f = f.substr(0, pos);
+			}
+			switch( f ) {
+			case "-mp3":
+				b.compressMP3 = false;
+			case "-wav":
+				b.compressSounds = false;
+			case "-diff":
+				b.pakDiff = true;
+			case "-res" if( args.length > 0 ):
+				b.resPath = args.shift();
+			case "-out" if( args.length > 0 ):
+				b.outPrefix = args.shift();
+			case "-exclude" if( args.length > 0 ):
+				for( ext in args.shift().split(",") )
+					b.excludedExt.push(ext);
+			default:
+				throw "Unknown parameter " + f;
+			}
+		}
 		b.makePak();
 	}