Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 72 additions & 2 deletions src/lime/tools/PlatformTarget.hx
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,17 @@ class PlatformTarget
}
}

// Command implementations

@ignore public function build():Void {}

@ignore public function clean():Void {}
public function clean():Void
{
if (FileSystem.exists(targetDirectory))
{
System.removeDirectory(targetDirectory);
}
}

@ignore public function deploy():Void {}

Expand All @@ -171,7 +179,69 @@ class PlatformTarget

@ignore public function update():Void {}

@ignore public function watch():Void {}
public function watch():Void
{
var hxml = getDisplayHXML();
if (hxml == null)
{
return;
}

var dirs = hxml.getClassPaths(true);

var outputPath = Path.combine(Sys.getCwd(), project.app.path);
dirs = dirs.filter(function(dir)
{
return (!Path.startsWith(dir, outputPath));
});

var command = ProjectHelper.getCurrentCommand();
System.watch(command, dirs);
}

// Common functionality used by subclasses

private function copyProjectAssets(outputDirectory:String, assetDirectory:String = null)
{
if (assetDirectory == null)
{
assetDirectory = outputDirectory;
}
else if (!StringTools.startsWith(assetDirectory, targetDirectory))
{
assetDirectory = Path.combine(outputDirectory, assetDirectory);
}

var embedDirectory = Path.combine(targetDirectory, "obj/tmp");

for (asset in project.assets)
{
if (asset.type == AssetType.TEMPLATE)
{
var path = Path.combine(outputDirectory, asset.targetPath);
System.mkdir(Path.directory(path));
AssetHelper.copyAsset(asset, path, project.templateContext);
}
else if (asset.embed == true)
{
if (asset.sourcePath == "")
{
var path = Path.combine(embedDirectory, asset.targetPath);
System.mkdir(Path.directory(path));
AssetHelper.copyAsset(asset, path);
asset.sourcePath = path;
}
}
else
{
var path = Path.combine(assetDirectory, asset.targetPath);
System.mkdir(Path.directory(path));
AssetHelper.copyAssetIfNewer(asset, path);
}
}
}

private function getDisplayHXML():HXML { return null; }

// Functions to track and delete stale files

Expand Down
10 changes: 2 additions & 8 deletions tools/platforms/AIRPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,6 @@ class AIRPlatform extends FlashPlatform
}
}

public override function clean():Void
{
if (FileSystem.exists(targetDirectory))
{
System.removeDirectory(targetDirectory);
}
}

public override function deploy():Void
{
if (targetFlags.exists("gdrive") || targetFlags.exists("zip"))
Expand Down Expand Up @@ -395,4 +387,6 @@ class AIRPlatform extends FlashPlatform
}

@ignore public override function rebuild():Void {}

@ignore public override function watch():Void {}
}
72 changes: 4 additions & 68 deletions tools/platforms/AndroidPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,6 @@ class AndroidPlatform extends PlatformTarget
AndroidHelper.build(project, destination);
}

public override function clean():Void
{
if (FileSystem.exists(targetDirectory))
{
System.removeDirectory(targetDirectory);
}
}

public override function deploy():Void
{
DeploymentHelper.deploy(project, targetFlags, targetDirectory, "Android");
Expand Down Expand Up @@ -301,7 +293,7 @@ class AndroidPlatform extends PlatformTarget
}
}

private function getDisplayHXML():HXML
private override function getDisplayHXML():HXML
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";

Expand Down Expand Up @@ -409,17 +401,6 @@ class AndroidPlatform extends PlatformTarget

// project = project.clone ();

for (asset in project.assets)
{
if (asset.embed && asset.sourcePath == "")
{
var path = Path.combine(targetDirectory + "/obj/tmp", asset.targetPath);
System.mkdir(Path.directory(path));
AssetHelper.copyAsset(asset, path);
asset.sourcePath = path;
}
}

// initialize (project);

var destination = targetDirectory + "/bin";
Expand All @@ -430,36 +411,6 @@ class AndroidPlatform extends PlatformTarget
System.mkdir(sourceSet + "/res/drawable-hdpi/");
System.mkdir(sourceSet + "/res/drawable-xhdpi/");

for (asset in project.assets)
{
if (asset.type != AssetType.TEMPLATE)
{
var targetPath = "";

switch (asset.type)
{
default:
// case SOUND, MUSIC:

// var extension = Path.extension (asset.sourcePath);
// asset.flatName += ((extension != "") ? "." + extension : "");

// asset.resourceName = asset.flatName;
targetPath = Path.combine(sourceSet + "/assets/", asset.resourceName);

// asset.resourceName = asset.id;
// targetPath = sourceSet + "/res/raw/" + asset.flatName + "." + Path.extension (asset.targetPath);

// default:

// asset.resourceName = asset.flatName;
// targetPath = sourceSet + "/assets/" + asset.resourceName;
}

AssetHelper.copyAssetIfNewer(asset, targetPath);
}
}

if (project.targetFlags.exists("xml"))
{
project.haxeflags.push("-xml " + targetDirectory + "/types.xml");
Expand Down Expand Up @@ -667,27 +618,12 @@ class AndroidPlatform extends PlatformTarget

for (asset in project.assets)
{
if (asset.type == AssetType.TEMPLATE)
if (asset.type != AssetType.TEMPLATE)
{
var targetPath = Path.combine(destination, asset.targetPath);
System.mkdir(Path.directory(targetPath));
AssetHelper.copyAsset(asset, targetPath, context);
asset.targetPath = asset.resourceName;
}
}
}

public override function watch():Void
{
var hxml = getDisplayHXML();
var dirs = hxml.getClassPaths(true);

var outputPath = Path.combine(Sys.getCwd(), project.app.path);
dirs = dirs.filter(function(dir)
{
return (!Path.startsWith(dir, outputPath));
});

var command = ProjectHelper.getCurrentCommand();
System.watch(command, dirs);
copyProjectAssets(destination, sourceSet + "/assets/");
}
}
26 changes: 1 addition & 25 deletions tools/platforms/FlashPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,6 @@ class FlashPlatform extends PlatformTarget
System.runCommand("", "haxe", [targetDirectory + "/haxe/" + buildType + ".hxml"]);
}

public override function clean():Void
{
var targetPath = targetDirectory + "";

if (FileSystem.exists(targetPath))
{
System.removeDirectory(targetPath);
}
}

public override function deploy():Void
{
DeploymentHelper.deploy(project, targetFlags, targetDirectory, "Flash");
Expand Down Expand Up @@ -175,7 +165,7 @@ class FlashPlatform extends PlatformTarget
return context;
}

private function getDisplayHXML():HXML
private override function getDisplayHXML():HXML
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";

Expand Down Expand Up @@ -336,20 +326,6 @@ class FlashPlatform extends PlatformTarget
}

}*/
public override function watch():Void
{
var hxml = getDisplayHXML();
var dirs = hxml.getClassPaths(true);

var outputPath = Path.combine(Sys.getCwd(), project.app.path);
dirs = dirs.filter(function(dir)
{
return (!Path.startsWith(dir, outputPath));
});

var command = ProjectHelper.getCurrentCommand();
System.watch(command, dirs);
}

@ignore public override function install():Void {}

Expand Down
22 changes: 2 additions & 20 deletions tools/platforms/HTML5Platform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,6 @@ class HTML5Platform extends PlatformTarget
}
}

public override function clean():Void
{
if (FileSystem.exists(targetDirectory))
{
System.removeDirectory(targetDirectory);
}
}

public override function deploy():Void
{
var name = "HTML5";
Expand All @@ -209,7 +201,7 @@ class HTML5Platform extends PlatformTarget
}
}

private function getDisplayHXML():HXML
private override function getDisplayHXML():HXML
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";

Expand Down Expand Up @@ -583,17 +575,7 @@ class HTML5Platform extends PlatformTarget
{
// TODO: Use a custom live reload HTTP server for test/run instead

var hxml = getDisplayHXML();
var dirs = hxml.getClassPaths(true);

var outputPath = Path.combine(Sys.getCwd(), project.app.path);
dirs = dirs.filter(function(dir)
{
return (!Path.startsWith(dir, outputPath));
});

var command = ProjectHelper.getCurrentCommand();
System.watch(command, dirs);
super.watch();
}

@ignore public override function install():Void {}
Expand Down
Loading