Created
May 29, 2014 20:29
-
-
Save YellowAfterlife/5b449a9b5e7af27a779b to your computer and use it in GitHub Desktop.
Generates typedef redirection files for openfl-bitfive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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