diff --git a/src/lime/tools/HXProject.hx b/src/lime/tools/HXProject.hx index 9dd9fb7bb..9c1d38084 100644 --- a/src/lime/tools/HXProject.hx +++ b/src/lime/tools/HXProject.hx @@ -60,6 +60,7 @@ class HXProject extends Script public var templatePaths:Array; @:isVar public var window(get, set):WindowData; public var windows:Array; + public var projectFilePath:String; private var needRerun:Bool; @@ -740,6 +741,11 @@ class HXProject extends Script launchStoryboard.merge(project.launchStoryboard); } + if (projectFilePath == null) + { + projectFilePath = project.projectFilePath; + } + languages = ArrayTools.concatUnique(languages, project.languages, true); libraries = ArrayTools.concatUnique(libraries, project.libraries, true); diff --git a/tools/CommandLineTools.hx b/tools/CommandLineTools.hx index d6248e174..f28d71fc1 100644 --- a/tools/CommandLineTools.hx +++ b/tools/CommandLineTools.hx @@ -1720,6 +1720,11 @@ class CommandLineTools return null; } } + + if (project != null) + { + project.projectFilePath = projectFile; + } } if (project != null && project.needRerun && !project.targetFlags.exists("norerun")) diff --git a/tools/platforms/AndroidPlatform.hx b/tools/platforms/AndroidPlatform.hx index 2509e2b89..407e4461f 100644 --- a/tools/platforms/AndroidPlatform.hx +++ b/tools/platforms/AndroidPlatform.hx @@ -294,7 +294,12 @@ class AndroidPlatform extends PlatformTarget { var path = targetDirectory + "/haxe/" + buildType + ".hxml"; - if (FileSystem.exists(path)) + // try to use the existing .hxml file. however, if the project file was + // modified more recently than the .hxml, then the .hxml cannot be + // considered valid anymore. it may cause errors in editors like vscode. + if (FileSystem.exists(path) + && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); } diff --git a/tools/platforms/FlashPlatform.hx b/tools/platforms/FlashPlatform.hx index 19b4812d5..21828d2a3 100644 --- a/tools/platforms/FlashPlatform.hx +++ b/tools/platforms/FlashPlatform.hx @@ -174,7 +174,12 @@ class FlashPlatform extends PlatformTarget { var path = targetDirectory + "/haxe/" + buildType + ".hxml"; - if (FileSystem.exists(path)) + // try to use the existing .hxml file. however, if the project file was + // modified more recently than the .hxml, then the .hxml cannot be + // considered valid anymore. it may cause errors in editors like vscode. + if (FileSystem.exists(path) + && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); } diff --git a/tools/platforms/HTML5Platform.hx b/tools/platforms/HTML5Platform.hx index 97198ebf4..94d8a45f2 100644 --- a/tools/platforms/HTML5Platform.hx +++ b/tools/platforms/HTML5Platform.hx @@ -213,7 +213,12 @@ class HTML5Platform extends PlatformTarget { var path = targetDirectory + "/haxe/" + buildType + ".hxml"; - if (FileSystem.exists(path)) + // try to use the existing .hxml file. however, if the project file was + // modified more recently than the .hxml, then the .hxml cannot be + // considered valid anymore. it may cause errors in editors like vscode. + if (FileSystem.exists(path) + && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); } diff --git a/tools/platforms/IOSPlatform.hx b/tools/platforms/IOSPlatform.hx index e03754c3a..33197d9a3 100644 --- a/tools/platforms/IOSPlatform.hx +++ b/tools/platforms/IOSPlatform.hx @@ -456,7 +456,12 @@ class IOSPlatform extends PlatformTarget { var path = targetDirectory + "/" + project.app.file + "/haxe/Build.hxml"; - if (FileSystem.exists(path)) + // try to use the existing .hxml file. however, if the project file was + // modified more recently than the .hxml, then the .hxml cannot be + // considered valid anymore. it may cause errors in editors like vscode. + if (FileSystem.exists(path) + && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); } diff --git a/tools/platforms/LinuxPlatform.hx b/tools/platforms/LinuxPlatform.hx index d032080f1..4ee5a9161 100644 --- a/tools/platforms/LinuxPlatform.hx +++ b/tools/platforms/LinuxPlatform.hx @@ -362,7 +362,12 @@ class LinuxPlatform extends PlatformTarget { var path = targetDirectory + "/haxe/" + buildType + ".hxml"; - if (FileSystem.exists(path)) + // try to use the existing .hxml file. however, if the project file was + // modified more recently than the .hxml, then the .hxml cannot be + // considered valid anymore. it may cause errors in editors like vscode. + if (FileSystem.exists(path) + && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); } diff --git a/tools/platforms/MacPlatform.hx b/tools/platforms/MacPlatform.hx index 4f80be65a..2545bdc43 100644 --- a/tools/platforms/MacPlatform.hx +++ b/tools/platforms/MacPlatform.hx @@ -341,7 +341,12 @@ class MacPlatform extends PlatformTarget { var path = targetDirectory + "/haxe/" + buildType + ".hxml"; - if (FileSystem.exists(path)) + // try to use the existing .hxml file. however, if the project file was + // modified more recently than the .hxml, then the .hxml cannot be + // considered valid anymore. it may cause errors in editors like vscode. + if (FileSystem.exists(path) + && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); } diff --git a/tools/platforms/TVOSPlatform.hx b/tools/platforms/TVOSPlatform.hx index 54aae23b7..e0273b3b3 100644 --- a/tools/platforms/TVOSPlatform.hx +++ b/tools/platforms/TVOSPlatform.hx @@ -371,7 +371,12 @@ class TVOSPlatform extends PlatformTarget { var path = targetDirectory + "/" + project.app.file + "/haxe/Build.hxml"; - if (FileSystem.exists(path)) + // try to use the existing .hxml file. however, if the project file was + // modified more recently than the .hxml, then the .hxml cannot be + // considered valid anymore. it may cause errors in editors like vscode. + if (FileSystem.exists(path) + && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); } diff --git a/tools/platforms/WebAssemblyPlatform.hx b/tools/platforms/WebAssemblyPlatform.hx index 69fbdb2f2..a8130365c 100644 --- a/tools/platforms/WebAssemblyPlatform.hx +++ b/tools/platforms/WebAssemblyPlatform.hx @@ -359,7 +359,12 @@ class WebAssemblyPlatform extends PlatformTarget { var path = targetDirectory + "/haxe/" + buildType + ".hxml"; - if (FileSystem.exists(path)) + // try to use the existing .hxml file. however, if the project file was + // modified more recently than the .hxml, then the .hxml cannot be + // considered valid anymore. it may cause errors in editors like vscode. + if (FileSystem.exists(path) + && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); } diff --git a/tools/platforms/WindowsPlatform.hx b/tools/platforms/WindowsPlatform.hx index 46433c6e9..7a754c849 100644 --- a/tools/platforms/WindowsPlatform.hx +++ b/tools/platforms/WindowsPlatform.hx @@ -593,7 +593,12 @@ class WindowsPlatform extends PlatformTarget { var path = targetDirectory + "/haxe/" + buildType + ".hxml"; - if (FileSystem.exists(path)) + // try to use the existing .hxml file. however, if the project file was + // modified more recently than the .hxml, then the .hxml cannot be + // considered valid anymore. it may cause errors in editors like vscode. + if (FileSystem.exists(path) + && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); }