Advertisement
player_03

Useful functions for project.hxp

Aug 24th, 2014
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 2.19 KB | None | 0 0
  1.     private function ndll(name:String):Void {
  2.         var haxelib:Haxelib = null;
  3.         if(name == "std" || name == "regexp" || name == "zlib") {
  4.             haxelib = new Haxelib(config.getString("cpp.buildLibrary", "hxcpp"));
  5.         }
  6.        
  7.         ndlls.push(new NDLL(name, haxelib));
  8.     }
  9.     private function dependencyByPath(path:String):Void {
  10.         dependencies.push(new Dependency("", path));
  11.     }
  12.     private function dependency(name:String, path:String = ""):Void {
  13.         if(name == null) {
  14.             name = "";
  15.         }
  16.         if(path == null) {
  17.             path = "";
  18.         }
  19.         if(target == Platform.IOS && path.length > 0
  20.                 && StringTools.endsWith(name, ".framework")) {
  21.             trace("Warning: Setting both the name and the path of a dependency "
  22.                 + "leads to errors on some platforms. For your safety, and "
  23.                 + "the safety of others, the path will be omitted from the "
  24.                 + name + " dependency.");
  25.             path = "";
  26.         }
  27.        
  28.         dependencies.push(new Dependency(name, path));
  29.     }
  30.     private function templateFile(path:String, ?rename:String):Void {
  31.         assets.push(new Asset(path, rename, AssetType.TEMPLATE));
  32.     }
  33.     private function templateDirectory(sourcePath:String, destPath:String = ""):Void {
  34.         if(command == "build" || command == "test") {
  35.             //Ensure that the source path ends with a "/", and that the
  36.             //destination path does not.
  37.             if(sourcePath.charCodeAt(sourcePath.length - 1) != "/".code
  38.                 && sourcePath.charCodeAt(sourcePath.length - 1) != "\\".code) {
  39.                 sourcePath += "/";
  40.             }
  41.             if(destPath.length > 0 &&
  42.                 (destPath.charCodeAt(destPath.length - 1) == "/".code
  43.                 || destPath.charCodeAt(destPath.length - 1) == "\\".code)) {
  44.                 destPath = destPath.substr(0, destPath.length - 1);
  45.             }
  46.            
  47.             templateDirectoryHelper(sourcePath, destPath, "");
  48.         }
  49.     }
  50.     private function templateDirectoryHelper(baseSourcePath:String, baseDestPath:String, pathAddition:String):Void {
  51.         if(FileSystem.isDirectory(baseSourcePath + pathAddition)) {
  52.             for(item in FileSystem.readDirectory(baseSourcePath + pathAddition)) {
  53.                 templateDirectoryHelper(baseSourcePath, baseDestPath,
  54.                     (pathAddition.length == 0 ? item
  55.                         : pathAddition + "/" + item));
  56.             }
  57.         } else {
  58.             templateFile(baseSourcePath + pathAddition, baseDestPath + pathAddition);
  59.         }
  60.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement