diff --git a/docs/api/build.hx b/docs/api/build.hx index ac751e905..37893baad 100644 --- a/docs/api/build.hx +++ b/docs/api/build.hx @@ -1,4 +1,4 @@ -import hxp.helpers.ProcessHelper; +import hxp.ProcessHelper; import hxp.HXML; import sys.io.File; diff --git a/tools/CommandLineTools.hx b/tools/CommandLineTools.hx index c47d56c3e..b418d20d6 100644 --- a/tools/CommandLineTools.hx +++ b/tools/CommandLineTools.hx @@ -8,8 +8,7 @@ import haxe.Serializer; import haxe.Unserializer; import haxe.io.Path; import haxe.rtti.Meta; -import hxp.helpers.*; -import hxp.project.*; +import hxp.*; import lime.system.CFFI; import sys.io.File; import sys.io.Process; @@ -19,7 +18,7 @@ import utils.CreateTemplate; import utils.JavaExternGenerator; import utils.PlatformSetup; -@:access(hxp.project.HXProject) +@:access(hxp.Project) class CommandLineTools { @@ -34,8 +33,8 @@ class CommandLineTools { private var debug:Bool; private var environment:Map; private var includePaths:Array; - private var overrides:HXProject; - private var project:HXProject; + private var overrides:Project; + private var project:Project; private var projectDefines:Map; private var runFromHaxelib:Bool; private var targetFlags:Map; @@ -58,7 +57,7 @@ class CommandLineTools { userDefines = new Map (); words = new Array (); - overrides = new HXProject (); + overrides = new Project (); overrides.architectures = []; //HaxelibHelper.setOverridePath (new Haxelib ("lime-tools"), PathHelper.combine (HaxelibHelper.getPath (new Haxelib ("lime")), "tools")); @@ -364,23 +363,23 @@ class CommandLineTools { } else { - HXProject._command = command; - HXProject._environment = environment; - HXProject._debug = debug; - HXProject._target = target; - HXProject._targetFlags = targetFlags; - HXProject._userDefines = userDefines; + Project._command = command; + Project._environment = environment; + Project._debug = debug; + Project._target = target; + Project._targetFlags = targetFlags; + Project._userDefines = userDefines; var project = null; if (haxelib != null) { userDefines.set ("rebuild", 1); - project = HXProject.fromHaxelib (haxelib, userDefines); + project = Project.fromHaxelib (haxelib, userDefines); if (project == null) { - project = new HXProject (); + project = new Project (); project.config.set ("project.rebuild.path", PathHelper.combine (HaxelibHelper.getPath (haxelib), "project")); } else { @@ -391,11 +390,11 @@ class CommandLineTools { } else { - //project = HXProject.fromPath (path); + //project = Project.fromPath (path); if (project == null) { - project = new HXProject (); + project = new Project (); if (FileSystem.isDirectory (path)) { @@ -421,7 +420,7 @@ class CommandLineTools { for (haxelib in overrides.haxelibs) { - var includeProject = HXProject.fromHaxelib (haxelib, project.defines); + var includeProject = Project.fromHaxelib (haxelib, project.defines); if (includeProject != null) { @@ -528,7 +527,7 @@ class CommandLineTools { while (true) { var line = StringTools.trim (process.stdout.readLine ()); - trace (line); + if (StringTools.startsWith (line, "-L ")) { path = StringTools.trim (line.substr (2)); @@ -595,7 +594,7 @@ class CommandLineTools { #end - private function buildProject (project:HXProject, command:String = "") { + private function buildProject (project:Project, command:String = "") { if (command == "") { @@ -797,7 +796,7 @@ class CommandLineTools { var sampleExists = false; var defines = new Map (); defines.set ("create", 1); - var project = HXProject.fromHaxelib (new Haxelib (defaultLibrary), defines); + var project = Project.fromHaxelib (new Haxelib (defaultLibrary), defines); for (samplePath in project.samplePaths) { @@ -1340,7 +1339,7 @@ class CommandLineTools { } - private function getBuildNumber (project:HXProject, increment:Bool = true):Void { + private function getBuildNumber (project:Project, increment:Bool = true):Void { var buildNumber = project.meta.buildNumber; @@ -1404,7 +1403,7 @@ class CommandLineTools { } - private function getBuildNumber_GIT (project:HXProject, increment:Bool = true):String { + private function getBuildNumber_GIT (project:Project, increment:Bool = true):String { var cache = LogHelper.mute; LogHelper.mute = true; @@ -1444,7 +1443,7 @@ class CommandLineTools { } - private function getBuildNumber_SVN (project:HXProject, increment:Bool = true):String { + private function getBuildNumber_SVN (project:Project, increment:Bool = true):String { var cache = LogHelper.mute; LogHelper.mute = true; @@ -1508,7 +1507,7 @@ class CommandLineTools { } - private function initializeProject (project:HXProject = null, targetName:String = ""):HXProject { + private function initializeProject (project:Project = null, targetName:String = ""):Project { LogHelper.info ("", LogHelper.accentColor + "Initializing project..." + LogHelper.resetColor); @@ -1729,12 +1728,12 @@ class CommandLineTools { } - HXProject._command = command; - HXProject._debug = debug; - HXProject._environment = environment; - HXProject._target = target; - HXProject._targetFlags = targetFlags; - HXProject._userDefines = userDefines; + Project._command = command; + Project._debug = debug; + Project._environment = environment; + Project._target = target; + Project._targetFlags = targetFlags; + Project._userDefines = userDefines; var config = ConfigHelper.getConfig (); @@ -1854,12 +1853,12 @@ class CommandLineTools { if (project == null) { - HXProject._command = command; - HXProject._debug = debug; - HXProject._environment = environment; - HXProject._target = target; - HXProject._targetFlags = targetFlags; - HXProject._userDefines = userDefines; + Project._command = command; + Project._debug = debug; + Project._environment = environment; + Project._target = target; + Project._targetFlags = targetFlags; + Project._userDefines = userDefines; try { Sys.setCwd (Path.directory (projectFile)); } catch (e:Dynamic) {} @@ -1869,7 +1868,7 @@ class CommandLineTools { } else if (Path.extension (projectFile) == "hxp") { - project = HXProject.fromFile (projectFile, userDefines, includePaths); + project = Project.fromFile (projectFile, userDefines, includePaths); if (project != null) { diff --git a/tools/platforms/AIRPlatform.hx b/tools/platforms/AIRPlatform.hx index 021c50a87..6ce812e74 100644 --- a/tools/platforms/AIRPlatform.hx +++ b/tools/platforms/AIRPlatform.hx @@ -3,8 +3,25 @@ package; import haxe.io.Path; import haxe.Template; +#if (hxp > "1.0.0") +import hxp.AIRHelper; +import hxp.AssetHelper; +import hxp.AssetType; +import hxp.DeploymentHelper; +import hxp.FileHelper; +import hxp.FlashHelper; +import hxp.Icon; +import hxp.IconHelper; +import hxp.LogHelper; +import hxp.PathHelper; +import hxp.Platform; +import hxp.PlatformHelper; +import hxp.PlatformType; +import hxp.Project; +import hxp.ZipHelper; +#else import hxp.project.AssetType; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; import hxp.project.Icon; import hxp.project.Platform; import hxp.project.PlatformType; @@ -18,6 +35,7 @@ import hxp.helpers.PathHelper; import hxp.helpers.PlatformHelper; import hxp.helpers.LogHelper; import hxp.helpers.ZipHelper; +#end import sys.io.File; import sys.FileSystem; @@ -31,7 +49,7 @@ class AIRPlatform extends FlashPlatform { private var targetPlatformType:PlatformType; - public function new (command:String, _project:HXProject, targetFlags:Map) { + public function new (command:String, _project:Project, targetFlags:Map) { super (command, _project, targetFlags); diff --git a/tools/platforms/AndroidPlatform.hx b/tools/platforms/AndroidPlatform.hx index 9884c043c..9c06b6882 100644 --- a/tools/platforms/AndroidPlatform.hx +++ b/tools/platforms/AndroidPlatform.hx @@ -3,6 +3,25 @@ package; import haxe.io.Path; import haxe.Template; +#if (hxp > "1.0.0") +import hxp.AndroidHelper; +import hxp.Architecture; +import hxp.ArrayHelper; +import hxp.AssetHelper; +import hxp.AssetType; +import hxp.CPPHelper; +import hxp.DeploymentHelper; +import hxp.FileHelper; +import hxp.Haxelib; +import hxp.Icon; +import hxp.IconHelper; +import hxp.LogHelper; +import hxp.PathHelper; +import hxp.PlatformTarget; +import hxp.ProcessHelper; +import hxp.Project; +import hxp.WatchHelper; +#else import hxp.helpers.AndroidHelper; import hxp.helpers.ArrayHelper; import hxp.helpers.AssetHelper; @@ -17,9 +36,10 @@ import hxp.helpers.WatchHelper; import hxp.project.Architecture; import hxp.project.AssetType; import hxp.project.Haxelib; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; import hxp.project.Icon; import hxp.project.PlatformTarget; +#end import sys.io.File; import sys.FileSystem; @@ -30,7 +50,7 @@ class AndroidPlatform extends PlatformTarget { private var deviceID:String; - public function new (command:String, _project:HXProject, targetFlags:Map) { + public function new (command:String, _project:Project, targetFlags:Map) { super (command, _project, targetFlags); diff --git a/tools/platforms/EmscriptenPlatform.hx b/tools/platforms/EmscriptenPlatform.hx index a1510adb9..1a4fde4c6 100644 --- a/tools/platforms/EmscriptenPlatform.hx +++ b/tools/platforms/EmscriptenPlatform.hx @@ -4,6 +4,20 @@ package; import haxe.io.Path; import haxe.Json; import haxe.Template; +#if (hxp > "1.0.0") +import hxp.AssetHelper; +import hxp.AssetType; +import hxp.CPPHelper; +import hxp.DeploymentHelper; +import hxp.FileHelper; +import hxp.Haxelib; +import hxp.HTML5Helper; +import hxp.LogHelper; +import hxp.PathHelper; +import hxp.PlatformTarget; +import hxp.ProcessHelper; +import hxp.Project; +#else import hxp.helpers.AssetHelper; import hxp.helpers.CPPHelper; import hxp.helpers.DeploymentHelper; @@ -14,8 +28,9 @@ import hxp.helpers.PathHelper; import hxp.helpers.ProcessHelper; import hxp.project.AssetType; import hxp.project.Haxelib; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; import hxp.project.PlatformTarget; +#end import sys.io.File; import sys.FileSystem; @@ -26,7 +41,7 @@ class EmscriptenPlatform extends PlatformTarget { private var outputFile:String; - public function new (command:String, _project:HXProject, targetFlags:Map) { + public function new (command:String, _project:Project, targetFlags:Map) { super (command, _project, targetFlags); diff --git a/tools/platforms/FlashPlatform.hx b/tools/platforms/FlashPlatform.hx index da636990a..5779852f2 100644 --- a/tools/platforms/FlashPlatform.hx +++ b/tools/platforms/FlashPlatform.hx @@ -4,6 +4,23 @@ package; import haxe.io.Path; import haxe.Json; import haxe.Template; +#if (hxp > "1.0.0") +import hxp.AssetHelper; +import hxp.AssetType; +import hxp.DeploymentHelper; +import hxp.FileHelper; +import hxp.FlashHelper; +import hxp.Haxelib; +import hxp.HTML5Helper; +import hxp.LogHelper; +import hxp.PathHelper; +import hxp.Platform; +import hxp.PlatformHelper; +import hxp.PlatformTarget; +import hxp.ProcessHelper; +import hxp.Project; +import hxp.WatchHelper; +#else import hxp.helpers.AssetHelper; import hxp.helpers.DeploymentHelper; import hxp.helpers.FileHelper; @@ -16,9 +33,10 @@ import hxp.helpers.ProcessHelper; import hxp.helpers.WatchHelper; import hxp.project.AssetType; import hxp.project.Haxelib; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; import hxp.project.Platform; import hxp.project.PlatformTarget; +#end import sys.io.File; import sys.FileSystem; @@ -34,7 +52,7 @@ class FlashPlatform extends PlatformTarget { private var logLength:Int = 0; - public function new (command:String, _project:HXProject, targetFlags:Map) { + public function new (command:String, _project:Project, targetFlags:Map) { super (command, _project, targetFlags); diff --git a/tools/platforms/HTML5Platform.hx b/tools/platforms/HTML5Platform.hx index 9077d3648..fa6625236 100644 --- a/tools/platforms/HTML5Platform.hx +++ b/tools/platforms/HTML5Platform.hx @@ -6,6 +6,23 @@ import haxe.Template; #if lime import lime.text.Font; #end +#if (hxp > "1.0.0") +import hxp.AssetHelper; +import hxp.AssetType; +import hxp.DeploymentHelper; +import hxp.ElectronHelper; +import hxp.FileHelper; +import hxp.HTML5Helper; +import hxp.Icon; +import hxp.IconHelper; +import hxp.LogHelper; +import hxp.ModuleHelper; +import hxp.PathHelper; +import hxp.PlatformTarget; +import hxp.ProcessHelper; +import hxp.Project; +import hxp.WatchHelper; +#else import hxp.helpers.AssetHelper; import hxp.helpers.DeploymentHelper; import hxp.helpers.ElectronHelper; @@ -18,9 +35,10 @@ import hxp.helpers.PathHelper; import hxp.helpers.ProcessHelper; import hxp.helpers.WatchHelper; import hxp.project.AssetType; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; import hxp.project.Icon; import hxp.project.PlatformTarget; +#end import sys.io.File; import sys.FileSystem; @@ -32,7 +50,7 @@ class HTML5Platform extends PlatformTarget { private var outputFile:String; - public function new (command:String, _project:HXProject, targetFlags:Map ) { + public function new (command:String, _project:Project, targetFlags:Map ) { super (command, _project, targetFlags); @@ -145,7 +163,7 @@ class HTML5Platform extends PlatformTarget { } - private function initialize (command:String, project:HXProject):Void { + private function initialize (command:String, project:Project):Void { if (targetFlags.exists ("electron")) { diff --git a/tools/platforms/IOSPlatform.hx b/tools/platforms/IOSPlatform.hx index b9d43b5bd..ac417bda2 100644 --- a/tools/platforms/IOSPlatform.hx +++ b/tools/platforms/IOSPlatform.hx @@ -5,6 +5,31 @@ package; import haxe.io.Path; import haxe.Json; import haxe.Template; +#if (hxp > "1.0.0") +import hxp.Architecture; +import hxp.ArrayHelper; +import hxp.Asset; +import hxp.AssetHelper; +import hxp.AssetType; +import hxp.CPPHelper; +import hxp.DeploymentHelper; +import hxp.FileHelper; +import hxp.Haxelib; +import hxp.Icon; +import hxp.IconHelper; +import hxp.IOSHelper; +import hxp.Keystore; +import hxp.LogHelper; +import hxp.NDLL; +import hxp.PathHelper; +import hxp.Platform; +import hxp.PlatformHelper; +import hxp.PlatformTarget; +import hxp.ProcessHelper; +import hxp.Project; +import hxp.StringHelper; +import hxp.WatchHelper; +#else import hxp.helpers.ArrayHelper; import hxp.helpers.AssetHelper; import hxp.helpers.CPPHelper; @@ -18,19 +43,20 @@ import hxp.helpers.PlatformHelper; import hxp.helpers.ProcessHelper; import hxp.helpers.StringHelper; import hxp.helpers.WatchHelper; -#if lime -import lime.graphics.Image; -#end import hxp.project.Architecture; import hxp.project.Asset; import hxp.project.AssetType; import hxp.project.Haxelib; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; import hxp.project.Icon; import hxp.project.Keystore; import hxp.project.NDLL; import hxp.project.Platform; import hxp.project.PlatformTarget; +#end +#if lime +import lime.graphics.Image; +#end import sys.io.File; import sys.FileSystem; @@ -38,7 +64,7 @@ import sys.FileSystem; class IOSPlatform extends PlatformTarget { - public function new (command:String, _project:HXProject, targetFlags:Map ) { + public function new (command:String, _project:Project, targetFlags:Map ) { super (command, _project, targetFlags); diff --git a/tools/platforms/LinuxPlatform.hx b/tools/platforms/LinuxPlatform.hx index 29fc4b709..97038a38b 100644 --- a/tools/platforms/LinuxPlatform.hx +++ b/tools/platforms/LinuxPlatform.hx @@ -3,6 +3,26 @@ package; import haxe.io.Path; import haxe.Template; +#if (hxp > "1.0.0") +import hxp.Architecture; +import hxp.AssetHelper; +import hxp.AssetType; +import hxp.CPPHelper; +import hxp.DeploymentHelper; +import hxp.FileHelper; +import hxp.Haxelib; +import hxp.JavaHelper; +import hxp.LogHelper; +import hxp.NekoHelper; +import hxp.NodeJSHelper; +import hxp.PathHelper; +import hxp.Platform; +import hxp.PlatformHelper; +import hxp.PlatformTarget; +import hxp.ProcessHelper; +import hxp.Project; +import hxp.WatchHelper; +#else import hxp.helpers.AssetHelper; import hxp.helpers.CPPHelper; import hxp.helpers.DeploymentHelper; @@ -18,9 +38,10 @@ import hxp.helpers.WatchHelper; import hxp.project.AssetType; import hxp.project.Architecture; import hxp.project.Haxelib; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; import hxp.project.Platform; import hxp.project.PlatformTarget; +#end import sys.io.File; import sys.io.Process; import sys.FileSystem; @@ -36,7 +57,7 @@ class LinuxPlatform extends PlatformTarget { private var targetType:String; - public function new (command:String, _project:HXProject, targetFlags:Map ) { + public function new (command:String, _project:Project, targetFlags:Map ) { super (command, _project, targetFlags); diff --git a/tools/platforms/MacPlatform.hx b/tools/platforms/MacPlatform.hx index 333d8278e..f373a60f6 100644 --- a/tools/platforms/MacPlatform.hx +++ b/tools/platforms/MacPlatform.hx @@ -3,6 +3,31 @@ package; import haxe.io.Path; import haxe.Template; +#if (hxp > "1.0.0") +import hxp.Architecture; +import hxp.AssetHelper; +import hxp.AssetType; +import hxp.CPPHelper; +import hxp.CSHelper; +import hxp.DeploymentHelper; +import hxp.FileHelper; +import hxp.GUID; +import hxp.Haxelib; +import hxp.HaxelibHelper; +import hxp.Icon; +import hxp.IconHelper; +import hxp.JavaHelper; +import hxp.LogHelper; +import hxp.NekoHelper; +import hxp.NodeJSHelper; +import hxp.PathHelper; +import hxp.Platform; +import hxp.PlatformHelper; +import hxp.PlatformTarget; +import hxp.ProcessHelper; +import hxp.Project; +import hxp.WatchHelper; +#else import hxp.helpers.AssetHelper; import hxp.helpers.CPPHelper; import hxp.helpers.CSHelper; @@ -22,10 +47,11 @@ import hxp.helpers.WatchHelper; import hxp.project.AssetType; import hxp.project.Architecture; import hxp.project.Haxelib; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; import hxp.project.Icon; import hxp.project.Platform; import hxp.project.PlatformTarget; +#end import sys.io.File; import sys.FileSystem; @@ -41,7 +67,7 @@ class MacPlatform extends PlatformTarget { private var targetType:String; - public function new (command:String, _project:HXProject, targetFlags:Map ) { + public function new (command:String, _project:Project, targetFlags:Map ) { super (command, _project, targetFlags); diff --git a/tools/platforms/TVOSPlatform.hx b/tools/platforms/TVOSPlatform.hx index 901eea0d6..b43e990f0 100644 --- a/tools/platforms/TVOSPlatform.hx +++ b/tools/platforms/TVOSPlatform.hx @@ -5,32 +5,58 @@ package; import haxe.io.Path; import haxe.Json; import haxe.Template; -import hxp.helpers.AssetHelper; +#if (hxp > "1.0.0") +import hxp.Architecture; +import hxp.ArrayHelper; +import hxp.Asset; +import hxp.AssetHelper; +import hxp.AssetType; +import hxp.CPPHelper; +import hxp.DeploymentHelper; +import hxp.FileHelper; +import hxp.Haxelib; +import hxp.Icon; +import hxp.IconHelper; +import hxp.Keystore; +import hxp.LogHelper; +import hxp.NDLL; +import hxp.PathHelper; +import hxp.Platform; +import hxp.PlatformHelper; +import hxp.PlatformTarget; +import hxp.ProcessHelper; +import hxp.Project; +import hxp.StringHelper; +import hxp.TVOSHelper; +import hxp.WatchHelper; +#else import hxp.helpers.ArrayHelper; +import hxp.helpers.AssetHelper; import hxp.helpers.CPPHelper; import hxp.helpers.DeploymentHelper; import hxp.helpers.FileHelper; import hxp.helpers.IconHelper; -import hxp.helpers.TVOSHelper; import hxp.helpers.LogHelper; import hxp.helpers.PathHelper; import hxp.helpers.PlatformHelper; import hxp.helpers.ProcessHelper; import hxp.helpers.StringHelper; +import hxp.helpers.TVOSHelper; import hxp.helpers.WatchHelper; -#if lime -import lime.graphics.Image; -#end import hxp.project.Architecture; import hxp.project.Asset; import hxp.project.AssetType; import hxp.project.Haxelib; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; import hxp.project.Icon; import hxp.project.Keystore; import hxp.project.NDLL; import hxp.project.Platform; import hxp.project.PlatformTarget; +#end +#if lime +import lime.graphics.Image; +#end import sys.io.File; import sys.FileSystem; @@ -38,7 +64,7 @@ import sys.FileSystem; class TVOSPlatform extends PlatformTarget { - public function new (command:String, _project:HXProject, targetFlags:Map ) { + public function new (command:String, _project:Project, targetFlags:Map ) { super (command, _project, targetFlags); diff --git a/tools/platforms/TizenPlatform.hx b/tools/platforms/TizenPlatform.hx index 4da9fb642..05af9d969 100644 --- a/tools/platforms/TizenPlatform.hx +++ b/tools/platforms/TizenPlatform.hx @@ -3,6 +3,20 @@ package; import haxe.io.Path; import haxe.Template; +#if (hxp > "1.0.0") +import hxp.AssetHelper; +import hxp.AssetType; +import hxp.CPPHelper; +import hxp.DeploymentHelper; +import hxp.FileHelper; +import hxp.Icon; +import hxp.IconHelper; +import hxp.PathHelper; +import hxp.PlatformTarget; +import hxp.ProcessHelper; +import hxp.Project; +import hxp.TizenHelper; +#else import hxp.helpers.AssetHelper; import hxp.helpers.CPPHelper; import hxp.helpers.DeploymentHelper; @@ -12,9 +26,10 @@ import hxp.helpers.PathHelper; import hxp.helpers.ProcessHelper; import hxp.helpers.TizenHelper; import hxp.project.AssetType; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; import hxp.project.Icon; import hxp.project.PlatformTarget; +#end import sys.io.File; import sys.FileSystem; @@ -25,7 +40,7 @@ class TizenPlatform extends PlatformTarget { private static var uuid:String = null; - public function new (command:String, _project:HXProject, targetFlags:Map ) { + public function new (command:String, _project:Project, targetFlags:Map ) { super (command, _project, targetFlags); diff --git a/tools/platforms/WindowsPlatform.hx b/tools/platforms/WindowsPlatform.hx index 278280f33..d178d4ee9 100644 --- a/tools/platforms/WindowsPlatform.hx +++ b/tools/platforms/WindowsPlatform.hx @@ -3,6 +3,33 @@ package; import haxe.io.Path; import haxe.Template; +#if (hxp > "1.0.0") +import hxp.Architecture; +import hxp.Asset; +import hxp.AssetHelper; +import hxp.AssetType; +import hxp.CPPHelper; +import hxp.CSHelper; +import hxp.DeploymentHelper; +import hxp.FileHelper; +import hxp.GUID; +import hxp.Haxelib; +import hxp.HTML5Helper; +import hxp.Icon; +import hxp.IconHelper; +import hxp.JavaHelper; +import hxp.LogHelper; +import hxp.ModuleHelper; +import hxp.NekoHelper; +import hxp.NodeJSHelper; +import hxp.PathHelper; +import hxp.Platform; +import hxp.PlatformHelper; +import hxp.PlatformTarget; +import hxp.ProcessHelper; +import hxp.Project; +import hxp.WatchHelper; +#else import hxp.project.Icon; import hxp.helpers.AssetHelper; import hxp.helpers.CPPHelper; @@ -25,9 +52,10 @@ import hxp.project.Architecture; import hxp.project.Asset; import hxp.project.AssetType; import hxp.project.Haxelib; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; import hxp.project.Platform; import hxp.project.PlatformTarget; +#end import sys.io.File; import sys.FileSystem; @@ -42,7 +70,7 @@ class WindowsPlatform extends PlatformTarget { private var outputFile:String; - public function new (command:String, _project:HXProject, targetFlags:Map ) { + public function new (command:String, _project:Project, targetFlags:Map ) { super (command, _project, targetFlags); diff --git a/tools/utils/CreateTemplate.hx b/tools/utils/CreateTemplate.hx index 23e1863fd..459aa2001 100644 --- a/tools/utils/CreateTemplate.hx +++ b/tools/utils/CreateTemplate.hx @@ -1,34 +1,44 @@ package utils; +#if (hxp > "1.0.0") +import hxp.FileHelper; +import hxp.Haxelib; +import hxp.HaxelibHelper; +import hxp.LogHelper; +import hxp.PathHelper; +import hxp.Project; +#else import hxp.helpers.FileHelper; import hxp.helpers.HaxelibHelper; import hxp.helpers.LogHelper; import hxp.helpers.PathHelper; import hxp.project.Haxelib; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; +#end import sys.FileSystem; +@:access(hxp.Project) @:access(hxp.project.HXProject) class CreateTemplate { - - + + public static function createExtension (words:Array, userDefines:Map):Void { - + var title = "SampleExtension"; - + if (words.length > 1) { - + title = words[1]; - + } - + var file = StringTools.replace (title, " ", ""); var extension = StringTools.replace (file, "-", "_"); var className = extension.substr (0, 1).toUpperCase () + extension.substr (1); - + var context:Dynamic = { }; context.file = file; context.extension = extension; @@ -40,458 +50,458 @@ class CreateTemplate { context.META_BUILD_NUMBER = "::META_BUILD_NUMBER::"; context.META_VERSION = "::META_VERSION::"; context.ANDROID_GRADLE_PLUGIN = "::ANDROID_GRADLE_PLUGIN::"; - + PathHelper.mkdir (title); FileHelper.recursiveCopyTemplate ([ HaxelibHelper.getPath (new Haxelib ("lime"), true) + "/templates" ], "extension", title, context); - + if (FileSystem.exists (title + "/Extension.hx")) { - + FileSystem.rename (title + "/Extension.hx", title + "/" + className + ".hx"); - + } - + if (FileSystem.exists (title + "/project/common/Extension.cpp")) { - + FileSystem.rename (title + "/project/common/Extension.cpp", title + "/project/common/" + file + ".cpp"); - + } - + if (FileSystem.exists (title + "/project/include/Extension.h")) { - + FileSystem.rename (title + "/project/include/Extension.h", title + "/project/include/" + file + ".h"); - + } - + if (FileSystem.exists (title + "/dependencies/android/src/main/java/org/haxe/extension/Extension.java")) { - + FileSystem.rename (title + "/dependencies/android/src/main/java/org/haxe/extension/Extension.java", title + "/dependencies/android/src/main/java/org/haxe/extension/" + file + ".java"); - + } - + if (FileSystem.exists (title)) { - + PathHelper.mkdir (title + "/ndll"); PathHelper.mkdir (title + "/ndll/Linux"); PathHelper.mkdir (title + "/ndll/Linux64"); PathHelper.mkdir (title + "/ndll/Mac"); PathHelper.mkdir (title + "/ndll/Mac64"); PathHelper.mkdir (title + "/ndll/Windows"); - + } - + } - - - public static function createProject (words:Array, userDefines:Map, overrides:HXProject):Void { - + + + public static function createProject (words:Array, userDefines:Map, overrides:Project):Void { + var colonIndex = words[0].indexOf (":"); - + var projectName = null; var sampleName = null; var outputName = "SampleProject"; - + if (colonIndex == -1) { - + projectName = words[0]; - + if (words.length > 1) { - + sampleName = words[1]; - + } - + if (words.length > 2) { - + outputName = words[2]; - + } - + } else { - + projectName = words[0].substring (0, colonIndex); sampleName = words[0].substr (colonIndex + 1); - + if (words.length > 1) { - + outputName = words[1]; - + } - + } - + if (projectName == "project") { - + projectName = CommandLineTools.defaultLibrary; - + if (sampleName != null) { - + outputName = sampleName; - + } - + } - + if (projectName == null || projectName == "") { - + projectName = CommandLineTools.defaultLibrary; - + } - + if (projectName != null && projectName != "") { - + var defines = new Map (); defines.set ("create", 1); - var project = HXProject.fromHaxelib (new Haxelib (projectName), defines); - + var project = Project.fromHaxelib (new Haxelib (projectName), defines); + if (project != null) { - + var company = "Company Name"; - + /*if (words.length > 2) { - + company = words[2]; - + }*/ - + var context:Dynamic = { }; - + var name = outputName; //var name = words[1].split (".").pop (); var alphaNumeric = new EReg ("[a-zA-Z0-9]", "g"); var title = ""; var capitalizeNext = true; - + for (i in 0...name.length) { - + if (alphaNumeric.match (name.charAt (i))) { - + if (capitalizeNext) { - + title += name.charAt (i).toUpperCase (); - + } else { - + title += name.charAt (i); - + } - + capitalizeNext = false; - + } else { - + capitalizeNext = true; - + } - + } - + var file = StringTools.replace (title, " ", ""); - + var id = [ "com", "sample", file.toLowerCase () ]; - + /*if (colonIndex != -1 && words.length > 1 || ) { - + var name = words[1]; name = new EReg ("[^a-zA-Z0-9.]", "g").replace (name, ""); id = name.split ("."); - + if (id.length < 3) { - + id = [ "com", "example" ].concat (id); - + } - + }*/ - + var packageName = id.join (".").toLowerCase (); var version = "1.0.0"; - + if (overrides != null) { - + if (overrides.meta.packageName != overrides.defaultMeta.packageName) { - + packageName = overrides.meta.packageName; - + } - + if (overrides.meta.title != overrides.defaultMeta.title) { - + title = overrides.meta.title; - + } - + if (overrides.meta.version != overrides.defaultMeta.version) { - + version = overrides.meta.version; - + } - + if (overrides.meta.company != overrides.defaultMeta.company) { - + company = overrides.meta.company; - + } - + if (overrides.app.file != overrides.defaultApp.file) { - + file = overrides.app.file; - + } - + } - + project.meta.title = title; project.meta.packageName = packageName; project.meta.version = version; project.meta.company = company; project.app.file = file; - + context.title = title; context.packageName = packageName; context.version = version; context.company = company; context.file = file; - + for (define in userDefines.keys ()) { - + Reflect.setField (context, define, userDefines.get (define)); - + } - + var folder = name; - + if (colonIndex > -1) { - + if (words.length > 1) { - + folder = PathHelper.tryFullPath (words[1]); - + } - + } else { - + if (words.length > 2) { - + folder = PathHelper.tryFullPath (words[2]); - + } - + } - + /*if (words.length > 2) { - + folder = PathHelper.tryFullPath (words[2]); - + }*/ - + PathHelper.mkdir (folder); FileHelper.recursiveSmartCopyTemplate (project, "project", folder, context); - + try { - + if (FileSystem.exists (folder + "/Project.hxproj")) { - + if (FileSystem.exists (folder + "/" + title + ".hxproj")) { - + FileSystem.deleteFile (folder + "/" + title + ".hxproj"); - + } - + FileSystem.rename (folder + "/Project.hxproj", folder + "/" + title + ".hxproj"); - + } - + } catch (e:Dynamic) {} - + return; - + } - + } - + LogHelper.error ("Could not find project \"" + projectName + "\""); - + } - - + + public static function createSample (words:Array, userDefines:Map) { - + var colonIndex = words[0].indexOf (":"); - + var projectName = null; var sampleName = null; var outputPath = null; - + if (colonIndex == -1 && words.length > 1) { - + projectName = words[0]; sampleName = words[1]; - + if (words.length > 2) { - + outputPath = words[2]; - + } - + } else { - + projectName = words[0].substring (0, colonIndex); sampleName = words[0].substr (colonIndex + 1); - + if (words.length > 1) { - + outputPath = words[1]; - + } - + } - + if (projectName == null || projectName == "") { - + projectName = CommandLineTools.defaultLibrary; - + } - + if (sampleName == null || sampleName == "") { - + LogHelper.error ("You must specify a sample name to copy when using \"" + CommandLineTools.commandName + " create\""); return; - + } - + var defines = new Map (); defines.set ("create", 1); - var project = HXProject.fromHaxelib (new Haxelib (projectName), defines); - + var project = Project.fromHaxelib (new Haxelib (projectName), defines); + if (project == null && outputPath == null) { - + outputPath = sampleName; sampleName = projectName; projectName = CommandLineTools.defaultLibrary; - project = HXProject.fromHaxelib (new Haxelib (projectName), defines); - + project = Project.fromHaxelib (new Haxelib (projectName), defines); + } - + if (project != null) { - + if (outputPath == null) { - + outputPath = sampleName; - + } - + var samplePaths = project.samplePaths.copy (); samplePaths.reverse (); - + for (samplePath in samplePaths) { - + var sourcePath = PathHelper.combine (samplePath, sampleName); - + if (FileSystem.exists (sourcePath)) { - + PathHelper.mkdir (outputPath); FileHelper.recursiveCopy (sourcePath, PathHelper.tryFullPath (outputPath)); return; - + } - + } - + } - + LogHelper.error ("Could not find sample \"" + sampleName + "\" in project \"" + projectName + "\""); - + } - - + + public static function listSamples (projectName:String, userDefines:Map) { - + var templates = []; - + if (projectName != null && projectName != "") { - + var defines = new Map (); defines.set ("create", 1); - var project = HXProject.fromHaxelib (new Haxelib (projectName), defines); - + var project = Project.fromHaxelib (new Haxelib (projectName), defines); + if (project != null) { - + var samplePaths = project.samplePaths.copy (); - + if (samplePaths.length > 0) { - + samplePaths.reverse (); - + for (samplePath in samplePaths) { - + var path = PathHelper.tryFullPath (samplePath); if (!FileSystem.exists (path)) continue; - + for (name in FileSystem.readDirectory (path)) { - + if (!StringTools.startsWith (name, ".") && FileSystem.isDirectory (path + "/" + name)) { - + templates.push (name); - + } - + } - + } - + } - + /*templates.push ("extension"); - + var projectTemplate = PathHelper.findTemplate (project.templatePaths, "project", false); - + if (projectTemplate != null) { - + templates.push ("project"); - + }*/ - + } - + } - + if (templates.length == 0) { - + projectName = CommandLineTools.defaultLibrary; - + } - + LogHelper.println ("\x1b[1mYou must specify a template when using the 'create' command.\x1b[0m"); LogHelper.println (""); - + if (projectName == CommandLineTools.commandName) { - + LogHelper.println (" " + LogHelper.accentColor + "Usage:\x1b[0m \x1b[1m" + CommandLineTools.commandName + "\x1b[0m create project (directory)"); LogHelper.println (" " + LogHelper.accentColor + "Usage:\x1b[0m \x1b[1m" + CommandLineTools.commandName + "\x1b[0m create extension (directory)"); - + } - + LogHelper.println (" " + LogHelper.accentColor + "Usage:\x1b[0m \x1b[1m" + CommandLineTools.commandName + "\x1b[0m create " + (projectName != CommandLineTools.commandName ? projectName + " " : "") + " (directory)"); - - - + + + if (templates.length > 0) { - + LogHelper.println (""); LogHelper.println (" " + LogHelper.accentColor + "Available samples:\x1b[0m"); LogHelper.println (""); - + for (template in templates) { - + Sys.println (" * " + template); - + } - + } - + Sys.println (""); - + } - - + + } \ No newline at end of file diff --git a/tools/utils/JavaExternGenerator.hx b/tools/utils/JavaExternGenerator.hx index 0309c2f22..794133c8a 100644 --- a/tools/utils/JavaExternGenerator.hx +++ b/tools/utils/JavaExternGenerator.hx @@ -7,9 +7,15 @@ import haxe.io.Input; import haxe.io.Output; import haxe.io.Path; import haxe.zip.Reader; +#if (hxp > "1.0.0") +import hxp.PathHelper; +import hxp.ProcessHelper; +import hxp.Project; +#else import hxp.helpers.PathHelper; import hxp.helpers.ProcessHelper; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; +#end import sys.io.File; import sys.io.Process; import sys.FileSystem; @@ -28,11 +34,11 @@ class JavaExternGenerator private static inline var ACC_INTERFACE = 0x0200; private static inline var ACC_ABSTRACT = 0x0400; private static inline var dollars = "___"; - + private static var base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; private static var fmatch = ~/^\((.*)\)(.*)/; - - private var config:HXProject; + + private var config:Project; private var externPath:String; private var extractedAndroidClasses:Bool; private var extractedAndroidPaths:Array; @@ -46,20 +52,20 @@ class JavaExternGenerator private var parsedTypes:Array; private var parsedIsObj:Array; private var retType:JNIType; - - - public function new(config:HXProject, javaPath:String, externPath:String) + + + public function new(config:Project, javaPath:String, externPath:String) { this.config = config; this.javaPath = javaPath; this.externPath = externPath; - + mProcessed = new Map(); mExactTypes = new Map(); mProcessed.set("java/lang/Object",true); - + var paths = new Array (); - + if (FileSystem.isDirectory (javaPath)) { this.javaPath += "/"; @@ -68,104 +74,104 @@ class JavaExternGenerator else { var path = Path.withoutExtension (javaPath); - + if (Path.extension (javaPath) == "jar") { - + this.javaPath = path + "/"; PathHelper.mkdir (path); ProcessHelper.runCommand (path, "jar", [ "-xvf", FileSystem.fullPath (javaPath) ], false); getPaths(path, "", paths); - + } else { - + this.javaPath = ""; paths = [ path ]; - + } - + } - + for (path in paths) { var type = Path.withoutExtension (path); mProcessed.set(type,true); mExactTypes.set(type,true); } - + mStack = paths; - + while(mStack.length > 0) { var clazz = mStack.pop(); var members = new Map(); generate(clazz, members); } - + for (path in extractedAndroidPaths) { - + if (FileSystem.exists (path)) { removeRecursive (path); } - + } } - - + + private function addType(inName:String, inJavaType:String, inArrayCount:Int) { parsedTypes.push( { name: inName, java: inJavaType, arrayCount: inArrayCount } ); } - - + + private static function debug(s:String) { - + } - - + + private function extractAndroidClasses() { if (!extractedAndroidClasses) { extractedAndroidPaths = []; var platformsDirectory = config.environment.get("ANDROID_SDK") + "/platforms"; - + if (FileSystem.exists (platformsDirectory)) { - + for (path in FileSystem.readDirectory (platformsDirectory)) { - + var directory = platformsDirectory + "/" + path; - + if (path.indexOf ("android-") > -1 && FileSystem.isDirectory (directory)) { - + var androidJAR = directory + "/android.jar"; - + if (FileSystem.exists(androidJAR)) { PathHelper.mkdir (path); extractedAndroidPaths.push (path); ProcessHelper.runCommand (path, "jar", [ "-xvf", androidJAR ], false); } - + } - + } - + } else { - + throw "Could not find Android SDK directory. Check that ANDROID_SDK is defined in ~/.lime/config.xml"; - + } } extractedAndroidClasses = true; } - - + + private function generate(inClass:String, inMembers:Map) { Lib.println(inClass); - + var parts = Path.withoutExtension (inClass).split("/"); var old_type = mCurrentType; mCurrentType = parts.join("."); @@ -174,65 +180,65 @@ class JavaExternGenerator var outputBase = externPath; var dir = outputBase; PathHelper.mkdir(dir); - + for(d in dir_parts) { dir += "/" + d; PathHelper.mkdir(dir); } - + var filename = javaPath + inClass + ".class"; - + if (!FileSystem.exists(filename)) { extractAndroidClasses(); var foundFile = false; - + for (path in extractedAndroidPaths) { - + if (!foundFile) { - + filename = path + "/" + inClass + ".class"; - + if (FileSystem.exists (filename)) { - + foundFile = true; - + } - + } - + } - + if (!foundFile) { - + throw "Could not find class file: \"" + inClass + "\""; - + } } - + var source = File.read(filename, true); var class_name = parts[parts.length - 1].split("$").join(dollars); var old_output = mOutput; mOutput = File.write(dir + "/" + class_name +".hx",true); var old_constants = mConstants; mConstants = new Array(); - + parse(source, inMembers); - + source.close(); mOutput.close(); mOutput = old_output; mCurrentType = old_type; mConstants = old_constants; } - - + + public static function getHaxelib(library:String):String { var proc = new Process("haxelib", ["path", library ]); var result = ""; - + try { while(true) { @@ -244,26 +250,26 @@ class JavaExternGenerator proc.close(); if (result == "") throw ("Could not find haxelib path " + library + " - perhaps you need to install it?"); - + return result; } - - + + private function getPaths(basePath:String, source:String, paths:Array) { var files = FileSystem.readDirectory(basePath + "/" + source); - + for (file in files) { if (file.substr(0, 1) != ".") { var itemSource:String = source + "/" + file; - + if (source == "") { itemSource = file; } - + if (FileSystem.isDirectory(basePath + "/" + itemSource)) { getPaths(basePath, itemSource, paths); @@ -278,8 +284,8 @@ class JavaExternGenerator } } } - - + + private function isJavaObject(inType) { if (inType.arrayCount > 0) @@ -290,8 +296,8 @@ class JavaExternGenerator default: true; } } - - + + private function isPOD(inName:String) { switch(inName) @@ -300,8 +306,8 @@ class JavaExternGenerator } return false; } - - + + private function javaType(inType) { var result = inType.java; @@ -310,29 +316,29 @@ class JavaExternGenerator result += "[]"; return result; } - - + + private function mkdir(inName:String) { if (!FileSystem.exists(inName)) FileSystem.createDirectory(inName); } - - + + private function nmeCallType(inType) { if (isJavaObject(inType)) return "callObjectFunction"; return "callNumericFunction"; } - - + + private function output(str:String) { mOutput.writeString(str); } - - + + private function outputClass(cid:Int, lastOnly:Bool) { var name:String = mConstants[mConstants[cid]]; @@ -344,8 +350,8 @@ class JavaExternGenerator else output(parts.join(".")); } - - + + private function outputFunctionArgs() { output("("); @@ -357,8 +363,8 @@ class JavaExternGenerator } output(")"); } - - + + private function outputPackage(cid:Int) { var name = (mConstants[mConstants[cid]]); @@ -366,8 +372,8 @@ class JavaExternGenerator parts.pop(); output("package " + parts.join(".") + ";\n\n\n"); } - - + + private function outputType(inType:JNIType) { for(i in 0...inType.arrayCount) @@ -376,25 +382,25 @@ class JavaExternGenerator for(i in 0...inType.arrayCount) output(">"); } - - + + private function parse(src:Input, inMembers:Map) { src.bigEndian = true; - + var m0 = src.readByte(); var m1 = src.readByte(); var m2 = src.readByte(); var m3 = src.readByte(); - + debug(StringTools.hex(m0, 2) + StringTools.hex(m1, 2) + StringTools.hex(m2, 2) + StringTools.hex(m3, 2)); debug("Version (min):" + src.readUInt16()); debug("Version (maj):" + StringTools.hex(src.readUInt16(), 4)); - + var ccount = src.readUInt16(); - + debug("mConstants : " + ccount); - + var cid = 1; while (cid < ccount) { @@ -406,72 +412,72 @@ class JavaExternGenerator var str = src.readString(len); //debug("Str:"+str); mConstants[cid] = str; - + case 3: var i = src.readInt32(); //debug("Int32:"+i); mConstants[cid] = i; - + case 4: var f = src.readFloat(); //debug("Float32:"+f); mConstants[cid] = f; - + case 5: var hi = src.readInt32(); var lo = src.readInt32(); //debug("Long - ignore"); mConstants[cid] = { lo: lo, hi: hi }; cid++; - + case 6: var f = src.readDouble(); //debug("Float64:"+f); mConstants[cid] = f; cid++; - + case 7: var cref = src.readUInt16(); //debug("Class ref:" + cref); mConstants[cid] = cref; - + case 8: var sref = src.readUInt16(); //debug("String ref:" + sref); mConstants[cid] = sref; - + case 9,10,11,12: var cref = src.readUInt16(); var type = src.readUInt16(); //debug("Member ref:" + cref + "," + type); mConstants[cid] = { cref: cref, type: type }; - + default: throw("Unknown constant tag:"+tag); } cid++; } - + var access = src.readUInt16(); - + debug("Access: " + access); - + var is_interface = (access & ACC_INTERFACE) > 0; var java_out:Output = null; - + var this_ref = src.readUInt16(); - + debug("This : " + mConstants[mConstants[this_ref]]); - + outputPackage(this_ref); output("class "); outputClass(this_ref, true); - + var super_ref = src.readUInt16(); if (super_ref > 0) { debug("Super : " + mConstants[mConstants[super_ref]]); - + var name = mConstants[mConstants[super_ref]]; if (name == "java/lang/Object") { @@ -486,14 +492,14 @@ class JavaExternGenerator } else debug("Super : None."); - + if (super_ref > 0) generate(mConstants[mConstants[super_ref]], inMembers); - + var intf_count = src.readUInt16(); - + debug("Interfaces:" + intf_count); - + for(i in 0...intf_count) { var i_ref = src.readUInt16(); @@ -506,12 +512,12 @@ class JavaExternGenerator debug("Implements : " + mConstants[mConstants[i_ref]]); */ } - + output("\n{\n"); - + if (super_ref == 0) output(" var __jobject:Dynamic;\n \n"); - + var java_name = ""; if (is_interface) @@ -520,17 +526,17 @@ class JavaExternGenerator var parts = mCurrentType.split("."); var dir_parts = parts.slice(0, parts.length - 1); PathHelper.mkdir(dir); - + for(d in dir_parts) { dir += "/" + d; PathHelper.mkdir(dir); } - + var interface_name = parts[parts.length - 1]; var impl_name = "Haxe" + parts[parts.length - 1].split("$").join(""); java_name = dir_parts.join("/") + "/" + impl_name +".java"; - + java_out = File.write("stubs/" + java_name, true); java_out.writeString("package " + dir_parts.join(".") + ";\n"); java_out.writeString("import org.haxe.lime.Value;\n"); @@ -539,30 +545,30 @@ class JavaExternGenerator java_out.writeString("class " + impl_name + " implements " + interface_name.split("$").join(".") + " {\n"); java_out.writeString(" long __haxeHandle;\n"); java_out.writeString(" public " + impl_name + "(long inHandle) { __haxeHandle=inHandle; }\n"); - + output(" public function new() { __jobject = openfl.utils.JNI.createInterface(this,\"" + dir_parts.join(".") + "." + impl_name + "\", classDef ); }\n \n" ); } - + var field_count = src.readUInt16(); - + debug("Fields:" + field_count); - + var seen = new Map(); - + for (i in 0...field_count) { var access = src.readUInt16(); var name_ref = src.readUInt16(); - + debug(" field : " + mConstants[name_ref]); - + var desc_ref = src.readUInt16(); - + debug(" desc : " + mConstants[desc_ref]); - + var expose = access == (ACC_PUBLIC|ACC_FINAL|ACC_STATIC); var as_string = false; - + if (expose) { var type = toHaxeType(mConstants[desc_ref]).name; @@ -574,24 +580,24 @@ class JavaExternGenerator else expose = false; } - + var att_count = src.readUInt16(); - + for (a in 0...att_count) { readAttribute(src, expose, as_string); } - + if (expose) output(";\n"); } - + var method_count = src.readUInt16(); debug("Method:" + method_count); - + output(" \n"); var constructed = false; - + for (i in 0...method_count) { var access = src.readUInt16(); @@ -600,21 +606,21 @@ class JavaExternGenerator var name_ref = src.readUInt16(); debug(" method: " + mConstants[name_ref]); var desc_ref = src.readUInt16(); - + var func_name = mConstants[name_ref]; var constructor = func_name == ""; - + if (expose) { debug(" desc : " + mConstants[desc_ref]); splitFunctionType(mConstants[desc_ref]); - + var func_key = func_name + " " + mConstants[desc_ref]; if (constructor) { func_name = "_create"; } - + // Method overloading ... var uniq_name = func_name; var do_override = ""; @@ -639,34 +645,34 @@ class JavaExternGenerator seen.set(uniq_name,true); inMembers.set(func_key, uniq_name); } - + if (constructor) is_static = true; - + var ret_full_class = constructor || ((mExactTypes.exists(retType.name) || isPOD(retType.name)) && retType.arrayCount == 0); - + if (constructor) retType = { name: mCurrentType, java: mCurrentType, arrayCount: 0 }; - + var ret_void = (retType.name == "Void" && retType.arrayCount == 0); - + if (is_interface) { java_out.writeString(" @Override public " + javaType(retType) + " " + func_name + "("); - + for (i in 0...parsedTypes.length) { if (i > 0) java_out.writeString(","); java_out.writeString(javaType(parsedTypes[i]) + " arg" + i); } - + java_out.writeString(") {\n"); - + if (parsedTypes.length > 0) java_out.writeString(" Object [] args = new Object[" + parsedTypes.length + "];\n"); else java_out.writeString(" Object [] args = null;\n"); - + for (i in 0...parsedTypes.length) { if (isJavaObject(parsedTypes[i])) @@ -674,20 +680,20 @@ class JavaExternGenerator else java_out.writeString(" args["+ i +"] = new Value(arg" + i + ");\n"); } - + if (!ret_void) java_out.writeString(" return (" + javaType(retType) + ")" ); - + java_out.writeString(" Lime." + nmeCallType(retType) + "(__haxeHandle,\"" + uniq_name + "\",args)"); - + if (!ret_void) java_out.writeString(")"); java_out.writeString(";\n }\n"); - + output(" public function " + uniq_name); outputFunctionArgs(); output(":"); - + if (ret_full_class) outputType(retType); else @@ -698,52 +704,52 @@ class JavaExternGenerator { output(" private static var _" + uniq_name + "_func:Dynamic;\n\n"); output(" public "); - + if (is_static || constructor) output("static "); - + output(do_override + "function " + uniq_name); outputFunctionArgs(); output(":"); - + if (ret_full_class) outputType(retType); else output("Dynamic"); - + output("\n"); output(" {\n"); func_name = "_" + uniq_name + "_func"; output(" if (" + func_name + " == null)\n"); output(" " + func_name + " = openfl.utils.JNI." + (is_static?"createStaticMethod":"createMemberMethod")); output("(\"" + StringTools.replace (mCurrentType, ".", "/") + "\", \"" + mConstants[name_ref] + "\", \"" + mConstants[desc_ref] + "\", true);\n"); - + output(" var a = new Array();\n"); - + if (!is_static) output(" a.push (__jobject);\n"); - + for (i in 0...parsedTypes.length) output(" a.push(arg" + i + ");\n"); - + if (ret_void) output(" "); else if (ret_full_class && !isPOD(retType.name)) output(" return new " + retType.name + "("); else output(" return "); - + output(func_name + "(a)"); - + if (ret_full_class && !isPOD(retType.name)) output(");\n"); else output(";\n"); - + output(" }\n \n \n"); } } - + if (constructor && !constructed) { constructed = true; @@ -764,34 +770,34 @@ class JavaExternGenerator { java_out.writeString("}\n"); java_out.close(); - + PathHelper.mkdir("compiled"); var nme_path = getHaxelib("openfl") + "/__backends/native/templates/android/template/src"; ProcessHelper.runCommand ("", "javac", [ "-classpath", "\"classes/android.jar\";\"" + javaPath.substr (0, javaPath.length -1) + "\"", "-sourcepath", nme_path, "-d", "compiled", "stubs/" + java_name ], true, true, true); - + //Sys.setCwd("compiled"); - + var class_name = java_name.substr(0, java_name.length - 4) + "class"; - + var dx = Sys.getEnv("ANDROID_SDK") + "/platforms/" + extractedAndroidPaths[0] + "/tools/dx"; ProcessHelper.runCommand ("compiled", dx, [ "--dex", "--output=classes.jar", class_name ], true, true, true); - + if (FileSystem.exists ("classes.jar")) { - + var class_def = File.getBytes("classes.jar"); class_def = Compress.run(class_def, 9); var class_str = BaseCode.encode(class_def.toString(), base64); - + output("\n static var classDef = \"" + class_str + "\";\n"); - + } - + } - + output("}"); } - - + + private function parseTypes(type:String, inArrayCount:Int) { if (type == "") return; @@ -822,8 +828,8 @@ class JavaExternGenerator if (type.length > 1) parseTypes(type.substr(1), 0); } - - + + private function processObjectArg(inObj:String, inArrayCount:Int) { if (inObj == "java.lang.CharSequence" || inObj == "java.lang.String") @@ -832,8 +838,8 @@ class JavaExternGenerator return inObj; return "Dynamic /*" + inObj + "*/"; } - - + + private function pushClass(inName:String) { if (!mProcessed.get(inName)) @@ -842,8 +848,8 @@ class JavaExternGenerator mStack.push(inName); } } - - + + private function readAttribute(src:Input, inOutputConst:Bool, asString:Bool) { var name_ref = src.readUInt16(); @@ -851,7 +857,7 @@ class JavaExternGenerator var len = src.readInt32(); var bytes = Bytes.alloc(len); src.readBytes(bytes, 0, len); - + if (inOutputConst && mConstants[name_ref]=="ConstantValue") { var ref = (bytes.get(0) << 8) + bytes.get(1); @@ -861,8 +867,8 @@ class JavaExternGenerator output(" = " + mConstants[ref] ); } } - - + + private function removeRecursive(file) { if (!FileSystem.isDirectory(file)) @@ -874,8 +880,8 @@ class JavaExternGenerator removeRecursive(file + "/" + f); FileSystem.deleteDirectory(file); } - - + + private function splitFunctionType(type:String) { if (!fmatch.match(type)) @@ -886,8 +892,8 @@ class JavaExternGenerator parsedIsObj = []; parseTypes(args, 0); } - - + + private function toHaxeType(inStr:String) { parsedTypes = []; @@ -895,16 +901,16 @@ class JavaExternGenerator parseTypes(inStr, 0); return parsedTypes[0]; } - - + + /*public static function main() { var args = Sys.args(); debug(args.toString()); - + new JavaExternGenerator(args[0], "gen"); }*/ - + } diff --git a/tools/utils/PlatformSetup.hx b/tools/utils/PlatformSetup.hx index 549e5cd48..8ac9d45e5 100644 --- a/tools/utils/PlatformSetup.hx +++ b/tools/utils/PlatformSetup.hx @@ -5,6 +5,20 @@ import haxe.Http; import haxe.io.Eof; import haxe.io.Path; import haxe.zip.Reader; +#if (hxp > "1.0.0") +import hxp.CLIHelper; +import hxp.ConfigHelper; +import hxp.FileHelper; +import hxp.Haxelib; +import hxp.HaxelibHelper; +import hxp.LogHelper; +import hxp.PathHelper; +import hxp.Platform; +import hxp.PlatformHelper; +import hxp.ProcessHelper; +import hxp.Project; +import hxp.Version; +#else import hxp.helpers.CLIHelper; import hxp.helpers.ConfigHelper; import hxp.helpers.FileHelper; @@ -14,17 +28,18 @@ import hxp.helpers.PathHelper; import hxp.helpers.PlatformHelper; import hxp.helpers.ProcessHelper; import hxp.project.Haxelib; -import hxp.project.HXProject; +import hxp.project.HXProject in Project; import hxp.project.Platform; import hxp.project.Version; +#end import sys.io.File; import sys.io.Process; import sys.FileSystem; class PlatformSetup { - - + + private static var appleXcodeURL = "https://developer.apple.com/xcode/download/"; private static var linuxAptPackages = "gcc-multilib g++-multilib"; private static var linuxUbuntuSaucyPackages = "gcc-multilib g++-multilib libxext-dev"; @@ -35,1016 +50,1016 @@ class PlatformSetup { private static var linuxPacman32Packages = "multilib-devel mesa mesa-libgl glu"; private static var linuxPacman64Packages = "multilib-devel lib32-mesa lib32-mesa-libgl lib32-glu"; private static var visualStudioURL = "https://www.visualstudio.com/downloads/"; - + private static var triedSudo:Bool = false; private static var userDefines:Map; private static var targetFlags:Map; private static var setupHaxelibs = new Map (); - - + + private static function createPath (path:String, defaultPath:String = ""):String { - + try { - + if (path == "") { - + PathHelper.mkdir (defaultPath); return defaultPath; - + } else { - + PathHelper.mkdir (path); return path; - + } - + } catch (e:Dynamic) { - + throwPermissionsError (); return ""; - + } - + } - - + + private static function downloadFile (remotePath:String, localPath:String = "", followingLocation:Bool = false):Void { - + if (localPath == "") { - + localPath = Path.withoutDirectory (remotePath); - + } - + if (!followingLocation && FileSystem.exists (localPath)) { - + var answer = CLIHelper.ask ("File found. Install existing file?"); - + if (answer != NO) { - + return; - + } - + } - + var out = File.write (localPath, true); var progress = new Progress (out); var h = new Http (remotePath); - + h.cnxTimeout = 30; - + h.onError = function (e) { progress.close(); FileSystem.deleteFile (localPath); throw e; }; - + if (!followingLocation) { - + LogHelper.println ("Downloading " + localPath + "..."); - + } - + h.customRequest (false, progress); - + if (h.responseHeaders != null && h.responseHeaders.exists ("Location")) { - + var location = h.responseHeaders.get ("Location"); - + if (location != remotePath) { - + downloadFile (location, localPath, true); - + } - + } - + } - - + + private static function extractFile (sourceZIP:String, targetPath:String, ignoreRootFolder:String = ""):Void { - + var extension = Path.extension (sourceZIP); - + if (extension != "zip") { - + var arguments = "xvzf"; - + if (extension == "bz2" || extension == "tbz2") { - + arguments = "xvjf"; - - } - + + } + if (ignoreRootFolder != "") { - + if (ignoreRootFolder == "*") { - + for (file in FileSystem.readDirectory (targetPath)) { - + if (FileSystem.isDirectory (targetPath + "/" + file)) { - + ignoreRootFolder = file; - + } - + } - + } - + ProcessHelper.runCommand ("", "tar", [ arguments, sourceZIP ], false); ProcessHelper.runCommand ("", "cp", [ "-R", ignoreRootFolder + "/.", targetPath ], false); Sys.command ("rm", [ "-r", ignoreRootFolder ]); - + } else { - + ProcessHelper.runCommand ("", "tar", [ arguments, sourceZIP, "-C", targetPath ], false); - + //InstallTool.runCommand (targetPath, "tar", [ arguments, FileSystem.fullPath (sourceZIP) ]); - + } - + Sys.command ("chmod", [ "-R", "755", targetPath ]); - + } else { - + var file = File.read (sourceZIP, true); var entries = Reader.readZip (file); file.close (); - + for (entry in entries) { - + var fileName = entry.fileName; - + if (fileName.charAt (0) != "/" && fileName.charAt (0) != "\\" && fileName.split ("..").length <= 1) { - + var dirs = ~/[\/\\]/g.split(fileName); - + if ((ignoreRootFolder != "" && dirs.length > 1) || ignoreRootFolder == "") { - + if (ignoreRootFolder != "") { - + dirs.shift (); - + } - + var path = ""; var file = dirs.pop (); - + for (d in dirs) { - + path += d; PathHelper.mkdir (targetPath + "/" + path); path += "/"; - + } - + if (file == "") { - + if (path != "") LogHelper.println (" Created " + path); continue; // was just a directory - + } - + path += file; LogHelper.println (" Install " + path); - + var data = Reader.unzip (entry); var f = File.write (targetPath + "/" + path, true); f.write (data); f.close (); - + } - + } - + } - + } - + LogHelper.println ("Done"); - + } - - + + public static function getDefineValue (name:String, description:String):Void { - + var value = ConfigHelper.getConfigValue (name); - + if (value == null && Sys.getEnv (name) != null) { - + value = Sys.getEnv (name); - + } - + var inputValue = unescapePath (CLIHelper.param (LogHelper.accentColor + description + "\x1b[0m \x1b[37;3m[" + (value != null ? value : "") + "]\x1b[0m")); - + if (inputValue != "" && inputValue != value) { - + ConfigHelper.writeConfigValue (name, inputValue); - + } else if (inputValue == Sys.getEnv (inputValue)) { - + ConfigHelper.removeConfigValue (name); - + } - + } - - + + // public static function getDefines (names:Array = null, descriptions:Array = null, ignored:Array = null):Map { - + // var config = CommandLineTools.getLimeConfig (); - + // var defines = null; // var env = Sys.environment (); // var path = ""; - + // if (config != null) { - + // defines = config.environment; - + // for (key in defines.keys ()) { - + // if (defines.get (key) == env.get (key)) { - + // defines.remove (key); - + // } - + // } - + // } else { - + // defines = new Map (); - + // } - + // if (!defines.exists ("LIME_CONFIG")) { - + // var home = ""; - + // if (env.exists ("HOME")) { - + // home = env.get ("HOME"); - + // } else if (env.exists ("USERPROFILE")) { - + // home = env.get ("USERPROFILE"); - + // } else { - + // LogHelper.println ("Warning : No 'HOME' variable set - ~/.lime/config.xml might be missing."); - + // return null; - + // } - + // defines.set ("LIME_CONFIG", home + "/.lime/config.xml"); - + // } - + // if (names == null) { - + // return defines; - + // } - + // var values = new Array (); - + // for (i in 0...names.length) { - + // var name = names[i]; // var description = descriptions[i]; - + // var ignore = ""; - + // if (ignored != null && ignored.length > i) { - + // ignore = ignored[i]; - + // } - + // var value = ""; - + // if (defines.exists (name) && defines.get (name) != ignore) { - + // value = defines.get (name); - + // } else if (env.exists (name)) { - + // value = Sys.getEnv (name); - + // } - + // value = unescapePath (CLIHelper.param ("\x1b[1m" + description + "\x1b[0m \x1b[37;3m[" + value + "]\x1b[0m")); - + // if (value != "") { - + // defines.set (name, value); - + // } else if (value == Sys.getEnv (name)) { - + // defines.remove (name); - + // } - + // } - + // return defines; - + // } - - + + public static function installHaxelib (haxelib:Haxelib):Void { - + var name = haxelib.name; var version = haxelib.version; - + if (version != null && version.indexOf ("*") > -1) { - + var regexp = new EReg ("^.+[0-9]+-[0-9]+-[0-9]+ +[0-9]+:[0-9]+:[0-9]+ +([a-z0-9.-]+) +", "gi"); var output = HaxelibHelper.runProcess ("", [ "info", haxelib.name ]); var lines = output.split ("\n"); - + var versions = new Array (); var ver:Version; - + for (line in lines) { - + if (regexp.match (line)) { - + try { - + ver = regexp.matched (1); versions.push (ver); - + } catch (e:Dynamic) {} - + } - + } - + var match = HaxelibHelper.findMatch (haxelib, versions); - + if (match != null) { - + version = match; - + } else { - + LogHelper.error ("Could not find version \"" + haxelib.version + "\" for haxelib \"" + haxelib.name + "\""); - + } - + } - + var args = [ "install", name ]; - + if (version != null && version != "" && version.indexOf ("*") == -1) { - + args.push (version); - + } - + HaxelibHelper.runCommand ("", args); - + } - - + + private static function link (dir:String, file:String, dest:String):Void { - + Sys.command ("rm -rf " + dest + "/" + file); Sys.command ("ln -s " + "/usr/lib" +"/" + dir + "/" + file + " " + dest + "/" + file); - + } - - + + private static function openURL (url:String):Void { - + if (PlatformHelper.hostPlatform == Platform.WINDOWS) { - + Sys.command ("explorer", [ url ]); - + } else if (PlatformHelper.hostPlatform == Platform.LINUX) { - + ProcessHelper.runCommand ("", "xdg-open", [ url ], false); - + } else { - + ProcessHelper.runCommand ("", "open", [ url ], false); - + } - + } - - + + public static function run (target:String = "", userDefines:Map = null, targetFlags:Map = null) { - + PlatformSetup.userDefines = userDefines; PlatformSetup.targetFlags = targetFlags; - + try { - + if (target == "cpp") { - + switch (PlatformHelper.hostPlatform) { - + case WINDOWS: target = "windows"; case MAC: target = "mac"; case LINUX: target = "linux"; default: - + } - + } - + switch (target) { - + case "air": - + setupAIR (); - + case "android": - + setupAndroid (); - + case "blackberry": - + // setupBlackBerry (); - + case "emscripten", "webassembly", "wasm": - + setupEmscripten (); - + case "html5": - + LogHelper.println ("\x1b[0;3mNo additional configuration is required.\x1b[0m"); //setupHTML5 (); - + case "ios", "iphoneos", "iphonesim": - + if (PlatformHelper.hostPlatform == Platform.MAC) { - + setupIOS (); - + } - + case "linux": - + if (PlatformHelper.hostPlatform == Platform.LINUX) { - + setupLinux (); - + } - + case "mac", "macos": - + if (PlatformHelper.hostPlatform == Platform.MAC) { - + setupMac (); - + } - + case "tizen": - + // setupTizen (); - + case "webos": - + // setupWebOS (); - + case "electron": - + setupElectron (); - + case "windows", "winrt": - + if (PlatformHelper.hostPlatform == Platform.WINDOWS) { - + setupWindows (); - + } - + case "neko", "hl", "cs", "uwp", "winjs", "nodejs", "java": - + LogHelper.println ("\x1b[0;3mNo additional configuration is required.\x1b[0m"); - + case "lime": - + setupLime (); - + case "openfl": - + setupOpenFL (); - + case "tvos", "tvsim": - + if (PlatformHelper.hostPlatform == Platform.MAC) { - + setupIOS (); - + } case "": - + switch (CommandLineTools.defaultLibrary) { - + case "lime": setupLime (); case "openfl": setupOpenFL (); default: setupHaxelib (new Haxelib (CommandLineTools.defaultLibrary)); - + } - + default: - + setupHaxelib (new Haxelib (target)); - + } - + } catch (e:Eof) { - - - + + + } - + } - - + + private static function runInstaller (path:String, message:String = "Waiting for process to complete..."):Void { - + if (PlatformHelper.hostPlatform == Platform.WINDOWS) { - + try { - + LogHelper.println (message); ProcessHelper.runCommand ("", "call", [ path ], false); LogHelper.println ("Done"); - + } catch (e:Dynamic) {} - + } else if (PlatformHelper.hostPlatform == Platform.LINUX) { - + if (Path.extension (path) == "deb") { - + ProcessHelper.runCommand ("", "sudo", [ "dpkg", "-i", "--force-architecture", path ], false); - + } else { - + LogHelper.println (message); Sys.command ("chmod", [ "755", path ]); - + if (path.substr (0, 1) == "/") { - + ProcessHelper.runCommand ("", path, [], false); - + } else { - + ProcessHelper.runCommand ("", "./" + path, [], false); - + } - + LogHelper.println ("Done"); - + } - + } else { - + if (Path.extension (path) == "") { - + LogHelper.println (message); Sys.command ("chmod", [ "755", path ]); ProcessHelper.runCommand ("", path, [], false); LogHelper.println ("Done"); - + } else if (Path.extension (path) == "dmg") { - + var process = new Process("hdiutil", [ "mount", path ]); var ret = process.stdout.readAll().toString(); process.exitCode(); //you need this to wait till the process is closed! process.close(); - + var volumePath = ""; - + if (ret != null && ret != "") { - + volumePath = StringTools.trim (ret.substr (ret.indexOf ("/Volumes"))); - + } - + if (volumePath != "" && FileSystem.exists (volumePath)) { - + var apps = []; var packages = []; var executables = []; - + var files:Array = FileSystem.readDirectory (volumePath); - + for (file in files) { - + switch (Path.extension (file)) { - + case "app": - + apps.push (file); - + case "pkg", "mpkg": - + packages.push (file); - + case "bin": - + executables.push (file); - + } - + } - + var file = ""; - + if (apps.length == 1) { - + file = apps[0]; - + } else if (packages.length == 1) { - + file = packages[0]; - + } else if (executables.length == 1) { - + file = executables[0]; - + } - + if (file != "") { - + LogHelper.println (message); ProcessHelper.runCommand ("", "open", [ "-W", volumePath + "/" + file ], false); LogHelper.println ("Done"); - + } - + try { - + var process = new Process("hdiutil", [ "unmount", path ]); process.exitCode(); //you need this to wait till the process is closed! process.close(); - + } catch (e:Dynamic) { - + } - + if (file == "") { - + ProcessHelper.runCommand ("", "open", [ path ], false); - + } - + } else { - + ProcessHelper.runCommand ("", "open", [ path ], false); - + } - + } else { - + ProcessHelper.runCommand ("", "open", [ path ], false); - + } - + } - + } - - + + public static function setupAIR ():Void { - + LogHelper.println ("\x1b[1mIn order to package SWF applications using Adobe AIR, you must"); LogHelper.println ("download and extract the Adobe AIR SDK."); LogHelper.println (""); - + getDefineValue ("AIR_SDK", "Path to AIR SDK"); - + LogHelper.println (""); LogHelper.println ("Setup complete."); - + } - - + + public static function setupAndroid ():Void { - + LogHelper.println ("\x1b[1mIn order to build applications for Android, you must have recent"); LogHelper.println ("versions of the Android SDK, Android NDK and Java JDK installed."); LogHelper.println (""); LogHelper.println ("You must also install the Android SDK Platform-tools and API 19 using"); LogHelper.println ("the SDK manager from Android Studio.\x1b[0m"); LogHelper.println (""); - + getDefineValue ("ANDROID_SDK", "Path to Android SDK"); getDefineValue ("ANDROID_NDK_ROOT", "Path to Android NDK"); - + if (PlatformHelper.hostPlatform != Platform.MAC) { - + getDefineValue ("JAVA_HOME", "Path to Java JDK"); - + } - + if (ConfigHelper.getConfigValue ("ANDROID_SETUP") == null) { - + ConfigHelper.writeConfigValue ("ANDROID_SETUP", "true"); - + } - + LogHelper.println (""); LogHelper.println ("Setup complete."); - + } - - + + public static function setupElectron ():Void { - + LogHelper.println ("\x1b[1mIn order to run Electron applications, you must download"); LogHelper.println ("and extract the Electron runtime on your system."); LogHelper.println (""); - + getDefineValue ("ELECTRON_PATH", "Path to Electron runtime"); - + LogHelper.println (""); HaxelibHelper.runCommand ("", [ "install", "electron" ], true, true); - + LogHelper.println (""); LogHelper.println ("Setup complete."); - + } - - + + public static function setupEmscripten ():Void { - + LogHelper.println ("\x1b[1mIn order to build for WebAssembly or asm.js, you must download"); LogHelper.println ("and install the Emscripten SDK."); LogHelper.println (""); - + getDefineValue ("EMSCRIPTEN_SDK", "Path to Emscripten SDK"); - + LogHelper.println (""); LogHelper.println ("Setup complete."); - + } - - + + public static function setupHaxelib (haxelib:Haxelib, dependency:Bool = false):Void { - + setupHaxelibs.set (haxelib.name, true); - + var defines = new Map (); defines.set ("setup", 1); - + var basePath = HaxelibHelper.runProcess ("", [ "config" ]); if (basePath != null) { - + basePath = StringTools.trim (basePath.split ("\n")[0]); - + } var lib = HaxelibHelper.getPath (haxelib, false, true); if (lib != null && !StringTools.startsWith (PathHelper.standardize (lib), PathHelper.standardize (basePath))) { - + defines.set ("dev", 1); - + } - - var project = HXProject.fromHaxelib (haxelib, defines, true); - + + var project = Project.fromHaxelib (haxelib, defines, true); + if (project != null && project.haxelibs.length > 0) { - + for (lib in project.haxelibs) { - + if (setupHaxelibs.exists (lib.name)) continue; - + var path = HaxelibHelper.getPath (lib, false, true); - + if (path == null || path == "" || (lib.version != null && lib.version != "")) { - + if (defines.exists ("dev")) { - + LogHelper.error ("Could not find dependency \"" + lib.name + "\" for library \"" + haxelib.name + "\""); - + } - + installHaxelib (lib); - + } else /*if (userDefines.exists ("upgrade"))*/ { - + updateHaxelib (lib); - + } - + setupHaxelib (lib, true); - + } - + } else if (!dependency) { - + //LogHelper.warn ("No setup is required for " + haxelib.name + ", or it is not a valid target"); - + } - + } - - + + public static function setupHTML5 ():Void { - + // var setApacheCordova = false; - + // var defines = getDefines (); // var answer = CLIHelper.ask ("Download and install Apache Cordova?"); - + // if (answer == YES || answer == ALWAYS) { - + // var downloadPath = ""; // var defaultInstallPath = ""; - + // if (PlatformHelper.hostPlatform == Platform.WINDOWS) { - + // defaultInstallPath = "C:\\Development\\Apache Cordova"; - + // } else { - + // defaultInstallPath = "/opt/cordova"; - + // } - + // var path = unescapePath (CLIHelper.param ("Output directory [" + defaultInstallPath + "]")); // path = createPath (path, defaultInstallPath); - + // downloadFile (apacheCordovaPath); // extractFile (Path.withoutDirectory (apacheCordovaPath), path, "*"); - + // var childArchives = []; - + // for (file in FileSystem.readDirectory (path)) { - + // if (Path.extension (file) == "zip") { - + // childArchives.push (file); - + // } - + // } - + // createPath (path + "/lib"); // var libs = [ "android", "bada-wac", "bada", "blackberry", "ios", "mac", "qt", "tizen", "tvos", "webos", "wp7" ]; - + // for (archive in childArchives) { - + // var name = Path.withoutExtension (archive); // name = StringTools.replace (name, "incubator-", ""); // name = StringTools.replace (name, "cordova-", ""); - + // if (name == "blackberry-webworks") { - + // name = "blackberry"; - + // } - + // var basePath = path + "/"; - + // for (lib in libs) { - + // if (name == lib) { - + // basePath += "lib/"; - + // } - + // } - + // createPath (basePath + name); // extractFile (path + "/" + archive, basePath + name); - + // } - + // if (PlatformHelper.hostPlatform != Platform.WINDOWS) { - + // ProcessHelper.runCommand ("", "chmod", [ "-R", "777", path ], false); - + // } - + // setApacheCordova = true; // defines.set ("CORDOVA_PATH", path); // writeConfig (defines.get ("LIME_CONFIG"), defines); // LogHelper.println (""); - + // } - + // var requiredVariables = []; // var requiredVariableDescriptions = []; - + // if (!setApacheCordova) { - + // requiredVariables.push ("CORDOVA_PATH"); // requiredVariableDescriptions.push ("Path to Apache Cordova"); - + // } - + // requiredVariables = requiredVariables.concat ([ "WEBWORKS_SDK", "WEBWORKS_SDK_BBOS", "WEBWORKS_SDK_PLAYBOOK" ]); // requiredVariableDescriptions = requiredVariableDescriptions.concat ([ "Path to WebWorks SDK for BlackBerry 10", "Path to WebWorks SDK for BBOS", "Path to WebWorks SDK for PlayBook" ]); - + // defines = getDefines (requiredVariables, requiredVariableDescriptions); - + // defines.set ("CORDOVA_PATH", unescapePath (defines.get ("CORDOVA_PATH"))); // defines.set ("WEBWORKS_SDK_BBOS", unescapePath (defines.get ("WEBWORKS_SDK_BBOS"))); // defines.set ("WEBWORKS_SDK_PLAYBOOK", unescapePath (defines.get ("WEBWORKS_SDK_PLAYBOOK"))); - + // // temporary hack - + // /*Sys.println (""); // Sys.println ("Setting Apache Cordova install path..."); // ProcessHelper.runCommand (defines.get ("CORDOVA_PATH") + "/lib/ios", "make", [ "install" ], true, true); // Sys.println ("Done.");*/ - + // writeConfig (defines.get ("LIME_CONFIG"), defines); - + // HaxelibHelper.runCommand ("", [ "install", "cordova" ], true, true); - + } - - + + public static function setupIOS ():Void { - + LogHelper.println ("\x1b[1mIn order to build applications for iOS and tvOS, you must have"); LogHelper.println ("Xcode installed. Xcode is available from Apple as a free download.\x1b[0m"); LogHelper.println (""); LogHelper.println ("\x1b[0;3mNo additional configuration is required.\x1b[0m"); LogHelper.println (""); - + var answer = CLIHelper.ask ("Would you like to visit the download page now?"); - + if (answer == YES || answer == ALWAYS) { - + ProcessHelper.openURL (appleXcodeURL); - + } - + } - - + + public static function setupLime ():Void { - + if (!targetFlags.exists ("alias") && !targetFlags.exists ("cli")) { - + setupHaxelib (new Haxelib ("lime")); - + } - + var haxePath = Sys.getEnv ("HAXEPATH"); - + if (PlatformHelper.hostPlatform == Platform.WINDOWS) { - + if (haxePath == null || haxePath == "") { - + haxePath = "C:\\HaxeToolkit\\haxe\\"; - + } - + try { File.copy (HaxelibHelper.getPath (new Haxelib ("lime")) + "\\templates\\\\bin\\lime.exe", haxePath + "\\lime.exe"); } catch (e:Dynamic) {} try { File.copy (HaxelibHelper.getPath (new Haxelib ("lime")) + "\\templates\\\\bin\\lime.sh", haxePath + "\\lime"); } catch (e:Dynamic) {} - + } else { - + if (haxePath == null || haxePath == "") { - + haxePath = "/usr/lib/haxe"; - + } - + var installedCommand = false; var answer = YES; - + if (targetFlags.exists ("y")) { - + Sys.println ("Do you want to install the \"lime\" command? [y/n/a] y"); - + } else { - + answer = CLIHelper.ask ("Do you want to install the \"lime\" command?"); - + } - + if (answer == YES || answer == ALWAYS) { - + try { - + ProcessHelper.runCommand ("", "sudo", [ "cp", "-f", HaxelibHelper.getPath (new Haxelib ("lime")) + "/templates/bin/lime.sh", "/usr/local/bin/lime" ], false); ProcessHelper.runCommand ("", "sudo", [ "chmod", "755", "/usr/local/bin/lime" ], false); installedCommand = true; - + } catch (e:Dynamic) {} - + } - + if (!installedCommand) { - + Sys.println (""); Sys.println ("To finish setup, we recommend you either..."); Sys.println (""); @@ -1054,225 +1069,225 @@ class PlatformSetup { Sys.println ("sudo cp \"" + PathHelper.combine (HaxelibHelper.getPath (new Haxelib ("lime")), "templates/bin/lime.sh") + "\" /usr/local/bin/lime"); Sys.println ("sudo chmod 755 /usr/local/bin/lime"); Sys.println (""); - + } - + } - + if (PlatformHelper.hostPlatform == Platform.MAC) { - + ConfigHelper.writeConfigValue ("MAC_USE_CURRENT_SDK", "1"); - + } - + } - - + + public static function setupLinux ():Void { - + var whichAptGet = ProcessHelper.runProcess ("", "which", ["apt-get"], true, true, true); var hasApt = whichAptGet != null && whichAptGet != ""; - + if (hasApt) { - + // check if this is ubuntu saucy 64bit, which uses different packages. var lsbId = ProcessHelper.runProcess ("", "lsb_release", ["-si"], true, true, true); var lsbRelease = ProcessHelper.runProcess ("", "lsb_release", ["-sr"], true, true, true); var arch = ProcessHelper.runProcess ("", "uname", ["-m"], true, true, true); var isSaucy = lsbId == "Ubuntu\n" && lsbRelease >= "13.10\n" && arch == "x86_64\n"; - + var packages = isSaucy ? linuxUbuntuSaucyPackages : linuxAptPackages; - + var parameters = [ "apt-get", "install" ].concat (packages.split (" ")); ProcessHelper.runCommand ("", "sudo", parameters, false); - + LogHelper.println (""); LogHelper.println ("Setup complete."); return; - + } - + var whichYum = ProcessHelper.runProcess ("", "which", ["yum"], true, true, true); var hasYum = whichYum != null && whichYum != ""; - + if (hasYum) { - + var parameters = [ "yum", "install" ].concat (linuxYumPackages.split (" ")); ProcessHelper.runCommand ("", "sudo", parameters, false); - + LogHelper.println (""); LogHelper.println ("Setup complete."); return; - + } - + var whichDnf = ProcessHelper.runProcess ("", "which", ["dnf"], true, true, true); var hasDnf = whichDnf != null && whichDnf != ""; - + if (hasDnf) { - + var parameters = [ "dnf", "install" ].concat (linuxDnfPackages.split (" ")); ProcessHelper.runCommand ("", "sudo", parameters, false); - + LogHelper.println (""); LogHelper.println ("Setup complete."); return; - + } - + var whichEquo = ProcessHelper.runProcess ("", "which", ["equo"], true,true, true); var hasEquo = whichEquo != null && whichEquo != ""; - + if (hasEquo) { - + // Sabayon docs recommend not using sudo with equo, and instead using a root login shell var parameters = [ "-l", "-c", "equo", "i", "-av" ].concat (linuxEquoPackages.split (" ")); ProcessHelper.runCommand ("", "su", parameters, false); - + LogHelper.println (""); LogHelper.println ("Setup complete."); return; - + } - + var whichEmerge = ProcessHelper.runProcess ("", "which", ["emerge"], true,true, true); var hasEmerge = whichEmerge != null && whichEmerge != ""; - + if (hasEmerge) { - + var parameters = [ "emerge", "-av" ].concat (linuxEmergePackages.split (" ")); ProcessHelper.runCommand ("", "sudo", parameters, false); - + LogHelper.println (""); LogHelper.println ("Setup complete."); return; - + } - + var whichPacman = ProcessHelper.runProcess ("", "which", ["pacman"], true, true, true); var hasPacman = whichPacman != null && whichPacman != ""; - + if (hasPacman) { - + var parameters = [ "pacman", "-S", "--needed" ]; - + if (PlatformHelper.hostArchitecture == X64) { - + parameters = parameters.concat (linuxPacman64Packages.split (" ")); - + } else { - + parameters = parameters.concat (linuxPacman32Packages.split (" ")); - + } - + ProcessHelper.runCommand ("", "sudo", parameters, false); - + LogHelper.println (""); LogHelper.println ("Setup complete."); return; - + } - + LogHelper.println ("Unable to find a supported package manager on your Linux distribution."); LogHelper.println ("Currently apt-get, yum, dnf, equo, emerge, and pacman are supported."); - + Sys.exit (1); - + } - - + + public static function setupMac ():Void { - + LogHelper.println ("\x1b[1mIn order to build native executables for macOS, you must have"); LogHelper.println ("Xcode installed. Xcode is available from Apple as a free download.\x1b[0m"); LogHelper.println (""); LogHelper.println ("\x1b[0;3mNo additional configuration is required.\x1b[0m"); LogHelper.println (""); - + var answer = CLIHelper.ask ("Would you like to visit the download page now?"); - + if (answer == YES || answer == ALWAYS) { - + ProcessHelper.openURL (appleXcodeURL); - + } - + } - - + + public static function setupOpenFL ():Void { - + if (!targetFlags.exists ("alias") && !targetFlags.exists ("cli")) { - + setupHaxelib (new Haxelib ("openfl")); - + } - + var haxePath = Sys.getEnv ("HAXEPATH"); var project = null; - + try { - - project = HXProject.fromHaxelib (new Haxelib ("openfl")); - + + project = Project.fromHaxelib (new Haxelib ("openfl")); + } catch (e:Dynamic) {} - + if (PlatformHelper.hostPlatform == Platform.WINDOWS) { - + if (haxePath == null || haxePath == "") { - + haxePath = "C:\\HaxeToolkit\\haxe\\"; - + } - + try { File.copy (HaxelibHelper.getPath (new Haxelib ("lime")) + "\\templates\\\\bin\\lime.exe", haxePath + "\\lime.exe"); } catch (e:Dynamic) {} try { File.copy (HaxelibHelper.getPath (new Haxelib ("lime")) + "\\templates\\\\bin\\lime.sh", haxePath + "\\lime"); } catch (e:Dynamic) {} - + try { - + FileHelper.copyFileTemplate (project.templatePaths, "bin/openfl.exe", haxePath + "\\openfl.exe"); FileHelper.copyFileTemplate (project.templatePaths, "bin/openfl.sh", haxePath + "\\openfl"); - + } catch (e:Dynamic) {} - + } else { - + if (haxePath == null || haxePath == "") { - + haxePath = "/usr/lib/haxe"; - + } - + var installedCommand = false; var answer = YES; - + if (targetFlags.exists ("y")) { - + Sys.println ("Do you want to install the \"openfl\" command? [y/n/a] y"); - + } else { - + answer = CLIHelper.ask ("Do you want to install the \"openfl\" command?"); - + } - + if (answer == YES || answer == ALWAYS) { - + try { - + ProcessHelper.runCommand ("", "sudo", [ "cp", "-f", HaxelibHelper.getPath (new Haxelib ("lime")) + "/templates/bin/lime.sh", "/usr/local/bin/lime" ], false); ProcessHelper.runCommand ("", "sudo", [ "chmod", "755", "/usr/local/bin/lime" ], false); ProcessHelper.runCommand ("", "sudo", [ "cp", "-f", PathHelper.findTemplate (project.templatePaths, "bin/openfl.sh"), "/usr/local/bin/openfl" ], false); ProcessHelper.runCommand ("", "sudo", [ "chmod", "755", "/usr/local/bin/openfl" ], false); installedCommand = true; - + } catch (e:Dynamic) {} - + } - + if (!installedCommand) { - + Sys.println (""); Sys.println ("To finish setup, we recommend you either..."); Sys.println (""); @@ -1284,22 +1299,22 @@ class PlatformSetup { Sys.println ("sudo cp \"" + PathHelper.findTemplate (project.templatePaths, "bin/openfl.sh") + "\" /usr/local/bin/openfl"); Sys.println ("sudo chmod 755 /usr/local/bin/openfl"); Sys.println (""); - + } - + } - + if (PlatformHelper.hostPlatform == Platform.MAC) { - + ConfigHelper.writeConfigValue ("MAC_USE_CURRENT_SDK", "1"); - + } - + } - - + + public static function setupWindows ():Void { - + LogHelper.println ("\x1b[1mIn order to build native executables for Windows, you must have a"); LogHelper.println ("Visual Studio C++ compiler with \"Windows Desktop\" (Win32) support"); LogHelper.println ("installed. We recommend using Visual Studio Community, which is"); @@ -1307,119 +1322,119 @@ class PlatformSetup { LogHelper.println (""); LogHelper.println ("\x1b[0;3mNo additional configuration is required.\x1b[0m"); LogHelper.println (""); - + var answer = CLIHelper.ask ("Would you like to visit the download page now?"); - + if (answer == YES || answer == ALWAYS) { - + ProcessHelper.openURL (visualStudioURL); - + } - + } - - + + private static function throwPermissionsError () { - + if (PlatformHelper.hostPlatform == Platform.WINDOWS) { - + LogHelper.println ("Unable to access directory. Perhaps you need to run \"setup\" with administrative privileges?"); - + } else { - + LogHelper.println ("Unable to access directory. Perhaps you should run \"setup\" again using \"sudo\""); - + } - + Sys.exit (1); - + } - - + + private static function unescapePath (path:String):String { - + if (path == null) { - + path = ""; - + } - + path = StringTools.replace (path, "\\ ", " "); - + if (PlatformHelper.hostPlatform != Platform.WINDOWS && StringTools.startsWith (path, "~/")) { - + path = Sys.getEnv ("HOME") + "/" + path.substr (2); - + } - + return path; - + } - - + + public static function updateHaxelib (haxelib:Haxelib):Void { - + var basePath = HaxelibHelper.runProcess ("", [ "config" ]); - + if (basePath != null) { - + basePath = StringTools.trim (basePath.split ("\n")[0]); - + } - + var lib = HaxelibHelper.getPath (haxelib, false, true); - + if (StringTools.startsWith (PathHelper.standardize (lib), PathHelper.standardize (basePath))) { - + HaxelibHelper.runCommand ("", [ "update", haxelib.name ]); - + } else { - + var git = PathHelper.combine (lib, ".git"); - + if (FileSystem.exists (git)) { - + LogHelper.info (LogHelper.accentColor + "Updating \"" + haxelib.name + "\"" + LogHelper.resetColor); - + if (PlatformHelper.hostPlatform == Platform.WINDOWS) { - + var path = Sys.getEnv ("PATH"); - + if (path.indexOf ("Git") == -1) { - + Sys.putEnv ("PATH", "C:\\Program Files (x86)\\Git\\bin;" + path); - + } - + } - + ProcessHelper.runCommand (lib, "git", [ "pull" ]); ProcessHelper.runCommand (lib, "git", [ "submodule", "init" ]); ProcessHelper.runCommand (lib, "git", [ "submodule", "update" ]); - + } - + } - + } - - + + } class Progress extends haxe.io.Output { - + var o : haxe.io.Output; var cur : Int; var max : Int; var start : Float; - + public function new(o) { this.o = o; cur = 0; start = haxe.Timer.stamp(); } - + function bytes(n) { cur += n; if( max == null ) @@ -1427,18 +1442,18 @@ class Progress extends haxe.io.Output { else Sys.print(cur+"/"+max+" ("+Std.int((cur*100.0)/max)+"%)\r"); } - + public override function writeByte(c) { o.writeByte(c); bytes(1); } - + public override function writeBytes(s,p,l) { var r = o.writeBytes(s,p,l); bytes(r); return r; } - + public override function close() { super.close(); o.close(); @@ -1446,19 +1461,19 @@ class Progress extends haxe.io.Output { var speed = (cur / time) / 1024; time = Std.int(time * 10) / 10; speed = Std.int(speed * 10) / 10; - + // When the path is a redirect, we don't want to display that the download completed - + if (cur > 400) { - + Sys.print("Download complete : " + cur + " bytes in " + time + "s (" + speed + "KB/s)\n"); - + } - + } - + public override function prepare(m) { max = m; } - + }