Unify PlatformTarget.watch().

The implementation was copy-pasted, so it makes more sense to have only a single copy. `HTML5Platform` added a comment about possible future changes, so I kept that. Future changes will still be possible by overriding the function.
This commit is contained in:
Joseph Cloutier
2025-08-31 22:30:05 -04:00
parent 6ed53a9b92
commit 057a2a4f5e
12 changed files with 37 additions and 123 deletions

View File

@@ -392,4 +392,6 @@ class AIRPlatform extends FlashPlatform
}
@ignore public override function rebuild():Void {}
@ignore public override function watch():Void {}
}

View File

@@ -300,7 +300,7 @@ class AndroidPlatform extends PlatformTarget
}
}
private function getDisplayHXML():HXML
private override function getDisplayHXML():HXML
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";
@@ -630,19 +630,4 @@ class AndroidPlatform extends PlatformTarget
copyProjectAssets(destination, sourceSet + "/assets/");
}
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);
}
}

View File

@@ -175,7 +175,7 @@ class FlashPlatform extends PlatformTarget
return context;
}
private function getDisplayHXML():HXML
private override function getDisplayHXML():HXML
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";
@@ -333,20 +333,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 {}

View File

@@ -209,7 +209,7 @@ class HTML5Platform extends PlatformTarget
}
}
private function getDisplayHXML():HXML
private override function getDisplayHXML():HXML
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";
@@ -583,17 +583,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 {}

View File

@@ -446,7 +446,7 @@ class IOSPlatform extends PlatformTarget
return context;
}
private function getDisplayHXML():HXML
private override function getDisplayHXML():HXML
{
var path = targetDirectory + "/" + project.app.file + "/haxe/Build.hxml";
@@ -873,20 +873,6 @@ class IOSPlatform extends PlatformTarget
context.HAS_LAUNCH_IMAGE = has_launch_image;
}*/
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 {}

View File

@@ -428,7 +428,7 @@ class LinuxPlatform extends PlatformTarget
return context;
}
private function getDisplayHXML():HXML
private override function getDisplayHXML():HXML
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";
@@ -598,21 +598,6 @@ class LinuxPlatform extends PlatformTarget
copyProjectAssets(applicationDirectory);
}
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 {}
@ignore public override function trace():Void {}

View File

@@ -397,7 +397,7 @@ class MacPlatform extends PlatformTarget
return context;
}
private function getDisplayHXML():HXML
private override function getDisplayHXML():HXML
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";
@@ -576,21 +576,6 @@ class MacPlatform extends PlatformTarget
copyProjectAssets(targetDirectory, contentDirectory);
}
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 {}
@ignore public override function trace():Void {}

View File

@@ -357,7 +357,7 @@ class TVOSPlatform extends PlatformTarget
return context;
}
private function getDisplayHXML():HXML
private override function getDisplayHXML():HXML
{
var path = targetDirectory + "/" + project.app.file + "/haxe/Build.hxml";
@@ -644,20 +644,6 @@ class TVOSPlatform extends PlatformTarget
context.HAS_LAUNCH_IMAGE = has_launch_image;
}*/
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 {}

View File

@@ -261,4 +261,6 @@ class TizenPlatform extends PlatformTarget
@ignore public override function install():Void {}
@ignore public override function uninstall():Void {}
@ignore public override function watch():Void {}
}

View File

@@ -355,7 +355,7 @@ class WebAssemblyPlatform extends PlatformTarget
}
}
private function getDisplayHXML():HXML
private override function getDisplayHXML():HXML
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";
@@ -484,4 +484,6 @@ class WebAssemblyPlatform extends PlatformTarget
@ignore public override function trace():Void {}
@ignore public override function uninstall():Void {}
@ignore public override function watch():Void {}
}

View File

@@ -726,7 +726,7 @@ class WindowsPlatform extends PlatformTarget
return context;
}
private function getDisplayHXML():HXML
private override function getDisplayHXML():HXML
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";
@@ -1235,21 +1235,6 @@ class WindowsPlatform 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 {}
override public function install():Void
{