Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@YellowAfterlife
Created May 29, 2014 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YellowAfterlife/5b449a9b5e7af27a779b to your computer and use it in GitHub Desktop.
Save YellowAfterlife/5b449a9b5e7af27a779b to your computer and use it in GitHub Desktop.
Generates typedef redirection files for openfl-bitfive
import haxe.io.Path;
import sys.FileSystem;
import sys.io.File;
class Main {
static function remap(from:String, to:String, pkg:String = "") {
for (file in FileSystem.readDirectory(from)) {
if (FileSystem.isDirectory('$from/$file')) {
if (!FileSystem.exists('$to/$file')) {
FileSystem.createDirectory('$to/$file');
}
remap('$from/$file', '$to/$file', '$pkg.$file');
} else {
var dot = file.lastIndexOf(".");
if (dot < 0 || file.substr(dot) != ".hx") continue;
var name = file.substr(0, dot);
trace('openfl$pkg.$name');
File.saveContent('$to/$file', [
'/// Redirects `openfl$pkg.$name` to `flash$pkg.$name` (OpenFL2 feature)',
'package openfl$pkg;',
'#if js',
'typedef $name = flash$pkg.$name;',
'#end',
''].join("\n"));
}
}
}
static function main() remap(
"C:/haxe/lib/openfl-bitfive/1.5.0/flash",
"C:/haxe/lib/openfl-bitfive/1.5.0/openfl");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment