Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using Eval to run Lime tools. #1615

Merged
merged 2 commits into from
Apr 6, 2023
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
Binary file modified run.n
Binary file not shown.
44 changes: 11 additions & 33 deletions src/lime/tools/HXProject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -376,38 +376,18 @@ class HXProject extends Script

var tempDirectory = System.getTemporaryDirectory();
var classFile = Path.combine(tempDirectory, name + ".hx");
var nekoOutput = Path.combine(tempDirectory, name + ".n");

System.copyFile(path, classFile);

#if lime
var args = [
name,
"-main",
"lime.tools.HXProject",
"-cp",
tempDirectory,
"-neko",
nekoOutput,
"-cp",
Path.combine(Haxelib.getPath(new Haxelib("hxp")), "src"),
"-lib",
"lime",
"-lib",
"hxp"
];
#else
var args = [
name,
"--interp",
"-main",
"lime.tools.HXProject",
"-cp",
tempDirectory,
"-cp",
Path.combine(Haxelib.getPath(new Haxelib("hxp")), "src")
#if lime
"-lib", "lime",
"-lib", "hxp",
#end
"-cp", tempDirectory,
"-cp", Path.combine(Haxelib.getPath(new Haxelib("hxp")), "src")
];
#end
var input = File.read(classFile, false);
var tag = "@:compiler(";

Expand All @@ -430,10 +410,6 @@ class HXProject extends Script
var cacheDryRun = System.dryRun;
System.dryRun = false;

#if lime
System.runCommand("", "haxe", args);
#end

var inputFile = Path.combine(tempDirectory, "input.dat");
var outputFile = Path.combine(tempDirectory, "output.dat");

Expand All @@ -457,10 +433,12 @@ class HXProject extends Script

try
{
#if lime
System.runCommand("", "neko", [FileSystem.fullPath(nekoOutput), inputFile, outputFile]);
#if (lime && !eval)
var nekoOutput = FileSystem.fullPath(Path.combine(tempDirectory, name + ".n"));
System.runCommand("", "haxe", args.concat(["--main", "lime.tools.HXProject", "-neko", nekoOutput]));
System.runCommand("", "neko", [nekoOutput, inputFile, outputFile]);
#else
System.runCommand("", "haxe", args.concat(["--", inputFile, outputFile]));
System.runCommand("", "haxe", args.concat(["--run", "lime.tools.HXProject", inputFile, outputFile]));
#end
}
catch (e:Dynamic)
Expand Down
17 changes: 17 additions & 0 deletions tools/RunScript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,23 @@ class RunScript
}
}

if (args.indexOf("-eval") >= 0)
{
args.remove("-eval");
Log.info("Experimental: executing `lime " + args.slice(0, args.length - 1).join(" ")
+ "` using Eval (https://haxe.org/blog/eval/)");

var args = [
"-D", "lime",
"-cp", "tools",
"-cp", "tools/platforms",
"-cp", "src",
"-lib", "format",
"-lib", "hxp",
"--run", "CommandLineTools"].concat(args);
Sys.exit(runCommand("", "haxe", args));
}

if (!FileSystem.exists("tools/tools.n") || args.indexOf("-rebuild") > -1)
{
rebuildTools();
Expand Down