30 lines
863 B
Haxe
Executable File
30 lines
863 B
Haxe
Executable File
package haxework.gui.build;
|
|
#if macro
|
|
|
|
import haxe.macro.Context;
|
|
import haxe.macro.Expr.Constant;
|
|
import haxe.macro.Expr.ExprDef;
|
|
|
|
class BuilderUtil {
|
|
|
|
public static function loadFile(path:String, json:Bool = true) {
|
|
Context.registerModuleDependency(Context.getLocalModule(), path);
|
|
var content = sys.io.File.getContent(path);
|
|
Context.parse(content, Context.makePosition({min:0, max:0, file:path}));
|
|
return json ? PositionJsonParser.parse(content) : content;
|
|
}
|
|
|
|
public static function getMeta(key:String):Array<String> {
|
|
var c = Context.getLocalClass().get();
|
|
for (meta in c.meta.get()) {
|
|
if (meta.name == key) {
|
|
return meta.params.map(function(param) return switch(param.expr) {
|
|
case ExprDef.EConst(Constant.CString(value)): value;
|
|
case _: null;
|
|
});
|
|
}
|
|
}
|
|
return [];
|
|
}
|
|
}
|
|
#end |