diff --git a/src/net/pickhaxe/tools/commands/Setup.hx b/src/net/pickhaxe/tools/commands/Setup.hx index 88e05fe..611f228 100644 --- a/src/net/pickhaxe/tools/commands/Setup.hx +++ b/src/net/pickhaxe/tools/commands/Setup.hx @@ -78,9 +78,18 @@ class Setup implements ICommand function setupMac():Void { - // TODO: Implement this. - // https://github.com/openfl/lime/blob/develop/tools/utils/PlatformSetup.hx#L824 - CLI.print('Sorry, this command is not supported on your platform.'); + var haxePathEnv:String = Sys.getEnv('HAXEPATH') ?? '/usr/local/bin'; + var haxePath:Path = new Path(haxePathEnv); + + try + { + var source:Path = IO.libraryDir().joinPaths('templates/bin/${Constants.LIBRARY_ID}.sh'); + var target:Path = haxePath.joinPaths('${Constants.LIBRARY_ID}'); + + IO.copyFileUnix(source, target); + IO.updatePermissions(target); + } + catch (e:Dynamic) {} } function setupLinux():Void diff --git a/src/net/pickhaxe/tools/util/IO.hx b/src/net/pickhaxe/tools/util/IO.hx index 25959cb..1a1c2a6 100644 --- a/src/net/pickhaxe/tools/util/IO.hx +++ b/src/net/pickhaxe/tools/util/IO.hx @@ -282,6 +282,26 @@ class IO sys.io.File.copy(source.toString(), dest.toString()); } + /** + * Copy a file from one location to another + * , requesting administrative access. + * @param source The path to the file to copy. + * @param dest The path to copy the file to. + */ + public static function copyFileUnix(source:Path, dest:Path):Void + { + Sys.command("sudo", ["cp", source.toString(), dest.toString()]); + } + + /* + * Update permissions for file to not require administration access. (Unix only) + * @param path The path to the file to update permissions for. + */ + public static function updatePermissions(path:Path):Void + { + Sys.command("sudo", ["chmod", "+x", path.toString()]); + } + /** * Clean up a path and convert it to a Path object. * @param input The path to clean up.