Created
August 7, 2012 19:47
-
-
Save tynril/3288767 to your computer and use it in GitHub Desktop.
Patch for HXCPP (r561) to enable automatic creation of output folders by the build tool
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
Index: build-tool/BuildTool.hx | |
=================================================================== | |
--- build-tool/BuildTool.hx (revision 561) | |
+++ build-tool/BuildTool.hx (working copy) | |
@@ -234,6 +234,9 @@ | |
{ | |
var ext = inTarget.mExt=="" ? mExt : inTarget.mExt; | |
var file_name = mNamePrefix + inTarget.mOutput + ext; | |
+ if(!createDirRecursive(inTarget.mOutputDir)) { | |
+ throw "Unable to create output directory"; | |
+ } | |
var out_name = inTarget.mOutputDir + file_name; | |
if (isOutOfDate(out_name,inObjs) || isOutOfDate(out_name,inTarget.mDepends)) | |
{ | |
@@ -318,6 +321,25 @@ | |
} | |
return false; | |
} | |
+ function createDirRecursive(dirPath:String) : Bool | |
+ { | |
+ var path = neko.FileSystem.fullPath(dirPath).split("\\").join("/"); | |
+ if(path.charAt(path.length - 1) == "/") | |
+ path = path.substring(0, path.length - 1); | |
+ if(neko.FileSystem.exists(path)) | |
+ return true; | |
+ try { | |
+ neko.FileSystem.createDirectory(path); | |
+ return true; | |
+ } | |
+ catch(e:Dynamic) { | |
+ if(createDirRecursive(path.substring(0, path.lastIndexOf("/")))) { | |
+ neko.FileSystem.createDirectory(path); | |
+ return true; | |
+ } | |
+ return false; | |
+ } | |
+ } | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment