Macros.hx 686 B

123456789101112131415161718192021222324252627
  1. package hide.tools;
  2. import haxe.macro.Expr;
  3. import haxe.macro.Context;
  4. import haxe.macro.Type;
  5. using haxe.macro.ExprTools;
  6. class Macros {
  7. public static macro function include( packages : Array<String> ) {
  8. includeShaderSources();
  9. for( p in packages )
  10. haxe.macro.Compiler.include(p);
  11. return macro null;
  12. }
  13. #if macro
  14. static function includeShaderSources() {
  15. var path = Context.resolvePath("h3d/shader/BaseMesh.hx");
  16. var dir = new haxe.io.Path(path).dir;
  17. for( f in sys.FileSystem.readDirectory(dir) )
  18. if( StringTools.endsWith(f,".hx") )
  19. Context.addResource("shader/" + f.substr(0, -3), sys.io.File.getBytes(dir + "/" + f));
  20. }
  21. #end
  22. }