Skip to content

Commit

Permalink
allow -D frontend for cases where hxnodejs is accidentally included
Browse files Browse the repository at this point in the history
  • Loading branch information
NQNStudios committed Nov 30, 2024
1 parent 2212149 commit 0dc4afd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/kiss/AsyncEmbeddedScript2.hx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class AsyncEmbeddedScript2 {
interp = new ObjectInterp2(this);
kiss.KissInterp.prepare(interp);
if (hscriptInstructionFile().length > 0) {
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
var cacheJson:haxe.DynamicAccess<String> = haxe.Json.parse(sys.io.File.getContent(hscriptInstructionFile()));
for (key => value in cacheJson) {
hscriptInstructions[Std.parseInt(key)] = value;
Expand Down Expand Up @@ -311,7 +311,7 @@ class AsyncEmbeddedScript2 {
Prelude.printStr(e.message);
if (onError != null) {
onError(e, () -> {
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
Sys.exit(1);
#end
throw e;
Expand All @@ -321,7 +321,7 @@ class AsyncEmbeddedScript2 {
()->{trace("no-op cc");};
});
} else {
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
Sys.exit(1);
#end
throw e;
Expand Down
2 changes: 1 addition & 1 deletion src/kiss/FuzzyMapTools.hx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class FuzzyMapTools {

@:allow(kiss.FuzzyMap)
static function onMatchMade(m:StringMap<Dynamic>, key:String, value:Dynamic) {
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
if (serializingMaps.exists(m)) {
var info = serializingMaps[m];
info.matches[key] = value;
Expand Down
8 changes: 4 additions & 4 deletions src/kiss/KissInterp.hx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class KissInterp extends Interp {
interp.variables.set("FuzzyMapTools", FuzzyMapTools);
interp.variables.set("StringTools", StringTools);
interp.variables.set("Path", haxe.io.Path);
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
interp.variables.set("Sys", Sys);
interp.variables.set("FileSystem", sys.FileSystem);
interp.variables.set("File", sys.io.File);
Expand Down Expand Up @@ -65,14 +65,14 @@ class KissInterp extends Interp {
public var cacheConvertedHScript = false;

public function evalKiss(kissStr:String):Dynamic {
#if !(sys || hxnodejs)
#if !((sys || hxnodejs) && !frontend)
if (cacheConvertedHScript) {
throw "Cannot used cacheConvertedHScript on a non-sys target";
}
#end

var convert =
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
if (cacheConvertedHScript) {
Prelude.cachedConvertToHScript;
} else
Expand Down Expand Up @@ -157,7 +157,7 @@ class KissInterp extends Interp {
}

kiss.Prelude.print(varDump);
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
sys.io.File.saveContent(file, varDump);
#end
}
Expand Down
28 changes: 14 additions & 14 deletions src/kiss/Prelude.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import haxe.DynamicAccess;
#if js
import js.lib.Promise;
#end
#if (!macro && hxnodejs)
#if (!macro && hxnodejs && !frontend)
import js.node.ChildProcess;
import js.node.Buffer;
#elseif sys
import sys.io.Process;
#end
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
import sys.FileSystem;
import sys.io.File;
#end
Expand Down Expand Up @@ -477,7 +477,7 @@ class Prelude {
} else {
var ret = Reflect.callMethod(caller, func, args);
argMap[argString] = ret;
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
if (jsonFile != null) {
File.saveContent(jsonFile, Json.stringify(argMap));
}
Expand All @@ -489,7 +489,7 @@ class Prelude {
return f;
}

#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
public static function fsMemoize(func:Function, funcName:String, cacheDirectory = "", ?caller:Dynamic):Function {
var fileName = '${funcName}.memoized';
if (cacheDirectory.length > 0) {
Expand All @@ -506,7 +506,7 @@ class Prelude {
#end

public static function _printStr(s:String) {
#if (sys || hxnodejs)
#if ((sys || nodejs) && !frontend)
Sys.println(s);
#else
trace(s);
Expand Down Expand Up @@ -614,7 +614,7 @@ class Prelude {

public static function walkDirectory(basePath, directory, processFile:(String) -> Void, ?filterFolderBefore:(String) -> Bool,
?processFolderAfter:(String) -> Void) {
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
for (fileOrFolder in FileSystem.readDirectory(joinPath(basePath, directory))) {
switch (fileOrFolder) {
case folder if (FileSystem.isDirectory(joinPath(basePath, directory, folder))):
Expand All @@ -638,7 +638,7 @@ class Prelude {
}

public static function purgeDirectory(directory) {
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
walkDirectory("", directory, FileSystem.deleteFile, null, FileSystem.deleteDirectory);
FileSystem.deleteDirectory(directory);
#else
Expand All @@ -656,7 +656,7 @@ class Prelude {
public static function convertToHScript(kissStr:String):String {
var unsupportedMessage = "Can't convert Kiss to HScript on this target.";

#if (!sys && !hxnodejs)
#if ((!sys && !hxnodejs) || frontend)
throw unsupportedMessage;
#else

Expand All @@ -675,7 +675,7 @@ class Prelude {
#if macro
return Kiss.measure("Prelude.convertToHScript", () -> {
#end
#if (!macro && hxnodejs)
#if (!macro && hxnodejs && !frontend)
var hscript = try {
assertProcess("haxe", [buildHxml, "convert", "--all", "--hscript"], kissStr.split('\n'), true, cwd);
} catch (e) {
Expand Down Expand Up @@ -725,7 +725,7 @@ class Prelude {
#end
}

#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
public static function userHome() {
var msysHome = Sys.getEnv("MSYSHOME");
var home = Sys.getEnv("HOME");
Expand All @@ -750,7 +750,7 @@ class Prelude {
CSharp;
#elseif interp
Haxe;
#elseif hxnodejs
#elseif (hxnodejs && !frontend)
NodeJS;
#elseif js
JavaScript;
Expand Down Expand Up @@ -852,7 +852,7 @@ class Prelude {
handleError('process $command $args failed: $e');
return null;
}
#elseif hxnodejs
#elseif (hxnodejs && !frontend)
var p = if (inputLines != null) {
ChildProcess.spawnSync(command, args, {input: inputLines.join("\n"), cwd: cwd});
} else {
Expand Down Expand Up @@ -885,7 +885,7 @@ class Prelude {
static var shellCount = 0;

public static function shellExecute(script:String, shell:String) {
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
if (shell.length == 0) {
shell = if (Sys.systemName() == "Windows") "cmd /c" else "bash";
}
Expand Down Expand Up @@ -924,7 +924,7 @@ class Prelude {
return Lambda.filter(l, p);
}

#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
public static function readDirectory(dir:String) {
return [for (file in FileSystem.readDirectory(dir)) {
joinPath(dir, file);
Expand Down
4 changes: 2 additions & 2 deletions src/kiss/Stream.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kiss;

#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
import sys.io.File;
#end
import haxe.ds.Option;
Expand Down Expand Up @@ -44,7 +44,7 @@ class Stream {

public var startOfLine = true;

#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
public static function fromFile(file:String) {
return new Stream(file, File.getContent(file));
}
Expand Down

0 comments on commit 0dc4afd

Please sign in to comment.