allow -D frontend for cases where hxnodejs is accidentally included
This commit is contained in:
@@ -136,7 +136,7 @@ class AsyncEmbeddedScript2 {
|
|||||||
interp = new ObjectInterp2(this);
|
interp = new ObjectInterp2(this);
|
||||||
kiss.KissInterp.prepare(interp);
|
kiss.KissInterp.prepare(interp);
|
||||||
if (hscriptInstructionFile().length > 0) {
|
if (hscriptInstructionFile().length > 0) {
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
var cacheJson:haxe.DynamicAccess<String> = haxe.Json.parse(sys.io.File.getContent(hscriptInstructionFile()));
|
var cacheJson:haxe.DynamicAccess<String> = haxe.Json.parse(sys.io.File.getContent(hscriptInstructionFile()));
|
||||||
for (key => value in cacheJson) {
|
for (key => value in cacheJson) {
|
||||||
hscriptInstructions[Std.parseInt(key)] = value;
|
hscriptInstructions[Std.parseInt(key)] = value;
|
||||||
@@ -311,7 +311,7 @@ class AsyncEmbeddedScript2 {
|
|||||||
Prelude.printStr(e.message);
|
Prelude.printStr(e.message);
|
||||||
if (onError != null) {
|
if (onError != null) {
|
||||||
onError(e, () -> {
|
onError(e, () -> {
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
Sys.exit(1);
|
Sys.exit(1);
|
||||||
#end
|
#end
|
||||||
throw e;
|
throw e;
|
||||||
@@ -321,7 +321,7 @@ class AsyncEmbeddedScript2 {
|
|||||||
()->{trace("no-op cc");};
|
()->{trace("no-op cc");};
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
Sys.exit(1);
|
Sys.exit(1);
|
||||||
#end
|
#end
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class FuzzyMapTools {
|
|||||||
|
|
||||||
@:allow(kiss.FuzzyMap)
|
@:allow(kiss.FuzzyMap)
|
||||||
static function onMatchMade(m:StringMap<Dynamic>, key:String, value:Dynamic) {
|
static function onMatchMade(m:StringMap<Dynamic>, key:String, value:Dynamic) {
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
if (serializingMaps.exists(m)) {
|
if (serializingMaps.exists(m)) {
|
||||||
var info = serializingMaps[m];
|
var info = serializingMaps[m];
|
||||||
info.matches[key] = value;
|
info.matches[key] = value;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class KissInterp extends Interp {
|
|||||||
interp.variables.set("FuzzyMapTools", FuzzyMapTools);
|
interp.variables.set("FuzzyMapTools", FuzzyMapTools);
|
||||||
interp.variables.set("StringTools", StringTools);
|
interp.variables.set("StringTools", StringTools);
|
||||||
interp.variables.set("Path", haxe.io.Path);
|
interp.variables.set("Path", haxe.io.Path);
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
interp.variables.set("Sys", Sys);
|
interp.variables.set("Sys", Sys);
|
||||||
interp.variables.set("FileSystem", sys.FileSystem);
|
interp.variables.set("FileSystem", sys.FileSystem);
|
||||||
interp.variables.set("File", sys.io.File);
|
interp.variables.set("File", sys.io.File);
|
||||||
@@ -65,14 +65,14 @@ class KissInterp extends Interp {
|
|||||||
public var cacheConvertedHScript = false;
|
public var cacheConvertedHScript = false;
|
||||||
|
|
||||||
public function evalKiss(kissStr:String):Dynamic {
|
public function evalKiss(kissStr:String):Dynamic {
|
||||||
#if !(sys || hxnodejs)
|
#if !((sys || hxnodejs) && !frontend)
|
||||||
if (cacheConvertedHScript) {
|
if (cacheConvertedHScript) {
|
||||||
throw "Cannot used cacheConvertedHScript on a non-sys target";
|
throw "Cannot used cacheConvertedHScript on a non-sys target";
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|
||||||
var convert =
|
var convert =
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
if (cacheConvertedHScript) {
|
if (cacheConvertedHScript) {
|
||||||
Prelude.cachedConvertToHScript;
|
Prelude.cachedConvertToHScript;
|
||||||
} else
|
} else
|
||||||
@@ -157,7 +157,7 @@ class KissInterp extends Interp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kiss.Prelude.print(varDump);
|
kiss.Prelude.print(varDump);
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
sys.io.File.saveContent(file, varDump);
|
sys.io.File.saveContent(file, varDump);
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ import haxe.DynamicAccess;
|
|||||||
#if js
|
#if js
|
||||||
import js.lib.Promise;
|
import js.lib.Promise;
|
||||||
#end
|
#end
|
||||||
#if (!macro && hxnodejs)
|
#if (!macro && hxnodejs && !frontend)
|
||||||
import js.node.ChildProcess;
|
import js.node.ChildProcess;
|
||||||
import js.node.Buffer;
|
import js.node.Buffer;
|
||||||
#elseif sys
|
#elseif sys
|
||||||
import sys.io.Process;
|
import sys.io.Process;
|
||||||
#end
|
#end
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
import sys.FileSystem;
|
import sys.FileSystem;
|
||||||
import sys.io.File;
|
import sys.io.File;
|
||||||
#end
|
#end
|
||||||
@@ -477,7 +477,7 @@ class Prelude {
|
|||||||
} else {
|
} else {
|
||||||
var ret = Reflect.callMethod(caller, func, args);
|
var ret = Reflect.callMethod(caller, func, args);
|
||||||
argMap[argString] = ret;
|
argMap[argString] = ret;
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
if (jsonFile != null) {
|
if (jsonFile != null) {
|
||||||
File.saveContent(jsonFile, Json.stringify(argMap));
|
File.saveContent(jsonFile, Json.stringify(argMap));
|
||||||
}
|
}
|
||||||
@@ -489,7 +489,7 @@ class Prelude {
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
public static function fsMemoize(func:Function, funcName:String, cacheDirectory = "", ?caller:Dynamic):Function {
|
public static function fsMemoize(func:Function, funcName:String, cacheDirectory = "", ?caller:Dynamic):Function {
|
||||||
var fileName = '${funcName}.memoized';
|
var fileName = '${funcName}.memoized';
|
||||||
if (cacheDirectory.length > 0) {
|
if (cacheDirectory.length > 0) {
|
||||||
@@ -506,7 +506,7 @@ class Prelude {
|
|||||||
#end
|
#end
|
||||||
|
|
||||||
public static function _printStr(s:String) {
|
public static function _printStr(s:String) {
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || nodejs) && !frontend)
|
||||||
Sys.println(s);
|
Sys.println(s);
|
||||||
#else
|
#else
|
||||||
trace(s);
|
trace(s);
|
||||||
@@ -614,7 +614,7 @@ class Prelude {
|
|||||||
|
|
||||||
public static function walkDirectory(basePath, directory, processFile:(String) -> Void, ?filterFolderBefore:(String) -> Bool,
|
public static function walkDirectory(basePath, directory, processFile:(String) -> Void, ?filterFolderBefore:(String) -> Bool,
|
||||||
?processFolderAfter:(String) -> Void) {
|
?processFolderAfter:(String) -> Void) {
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
for (fileOrFolder in FileSystem.readDirectory(joinPath(basePath, directory))) {
|
for (fileOrFolder in FileSystem.readDirectory(joinPath(basePath, directory))) {
|
||||||
switch (fileOrFolder) {
|
switch (fileOrFolder) {
|
||||||
case folder if (FileSystem.isDirectory(joinPath(basePath, directory, folder))):
|
case folder if (FileSystem.isDirectory(joinPath(basePath, directory, folder))):
|
||||||
@@ -638,7 +638,7 @@ class Prelude {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function purgeDirectory(directory) {
|
public static function purgeDirectory(directory) {
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
walkDirectory("", directory, FileSystem.deleteFile, null, FileSystem.deleteDirectory);
|
walkDirectory("", directory, FileSystem.deleteFile, null, FileSystem.deleteDirectory);
|
||||||
FileSystem.deleteDirectory(directory);
|
FileSystem.deleteDirectory(directory);
|
||||||
#else
|
#else
|
||||||
@@ -656,7 +656,7 @@ class Prelude {
|
|||||||
public static function convertToHScript(kissStr:String):String {
|
public static function convertToHScript(kissStr:String):String {
|
||||||
var unsupportedMessage = "Can't convert Kiss to HScript on this target.";
|
var unsupportedMessage = "Can't convert Kiss to HScript on this target.";
|
||||||
|
|
||||||
#if (!sys && !hxnodejs)
|
#if ((!sys && !hxnodejs) || frontend)
|
||||||
throw unsupportedMessage;
|
throw unsupportedMessage;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -675,7 +675,7 @@ class Prelude {
|
|||||||
#if macro
|
#if macro
|
||||||
return Kiss.measure("Prelude.convertToHScript", () -> {
|
return Kiss.measure("Prelude.convertToHScript", () -> {
|
||||||
#end
|
#end
|
||||||
#if (!macro && hxnodejs)
|
#if (!macro && hxnodejs && !frontend)
|
||||||
var hscript = try {
|
var hscript = try {
|
||||||
assertProcess("haxe", [buildHxml, "convert", "--all", "--hscript"], kissStr.split('\n'), true, cwd);
|
assertProcess("haxe", [buildHxml, "convert", "--all", "--hscript"], kissStr.split('\n'), true, cwd);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -725,7 +725,7 @@ class Prelude {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
public static function userHome() {
|
public static function userHome() {
|
||||||
var msysHome = Sys.getEnv("MSYSHOME");
|
var msysHome = Sys.getEnv("MSYSHOME");
|
||||||
var home = Sys.getEnv("HOME");
|
var home = Sys.getEnv("HOME");
|
||||||
@@ -750,7 +750,7 @@ class Prelude {
|
|||||||
CSharp;
|
CSharp;
|
||||||
#elseif interp
|
#elseif interp
|
||||||
Haxe;
|
Haxe;
|
||||||
#elseif hxnodejs
|
#elseif (hxnodejs && !frontend)
|
||||||
NodeJS;
|
NodeJS;
|
||||||
#elseif js
|
#elseif js
|
||||||
JavaScript;
|
JavaScript;
|
||||||
@@ -852,7 +852,7 @@ class Prelude {
|
|||||||
handleError('process $command $args failed: $e');
|
handleError('process $command $args failed: $e');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
#elseif hxnodejs
|
#elseif (hxnodejs && !frontend)
|
||||||
var p = if (inputLines != null) {
|
var p = if (inputLines != null) {
|
||||||
ChildProcess.spawnSync(command, args, {input: inputLines.join("\n"), cwd: cwd});
|
ChildProcess.spawnSync(command, args, {input: inputLines.join("\n"), cwd: cwd});
|
||||||
} else {
|
} else {
|
||||||
@@ -885,7 +885,7 @@ class Prelude {
|
|||||||
static var shellCount = 0;
|
static var shellCount = 0;
|
||||||
|
|
||||||
public static function shellExecute(script:String, shell:String) {
|
public static function shellExecute(script:String, shell:String) {
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
if (shell.length == 0) {
|
if (shell.length == 0) {
|
||||||
shell = if (Sys.systemName() == "Windows") "cmd /c" else "bash";
|
shell = if (Sys.systemName() == "Windows") "cmd /c" else "bash";
|
||||||
}
|
}
|
||||||
@@ -924,7 +924,7 @@ class Prelude {
|
|||||||
return Lambda.filter(l, p);
|
return Lambda.filter(l, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (sys || hxnodejs)
|
#if ((sys || hxnodejs) && !frontend)
|
||||||
public static function readDirectory(dir:String) {
|
public static function readDirectory(dir:String) {
|
||||||
return [for (file in FileSystem.readDirectory(dir)) {
|
return [for (file in FileSystem.readDirectory(dir)) {
|
||||||
joinPath(dir, file);
|
joinPath(dir, file);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package kiss;
|
package kiss;
|
||||||
|
|
||||||
#if (sys || hxnodejs)
|
#if (macro || ((sys || hxnodejs) && !frontend))
|
||||||
import sys.io.File;
|
import sys.io.File;
|
||||||
#end
|
#end
|
||||||
import haxe.ds.Option;
|
import haxe.ds.Option;
|
||||||
@@ -44,7 +44,7 @@ class Stream {
|
|||||||
|
|
||||||
public var startOfLine = true;
|
public var startOfLine = true;
|
||||||
|
|
||||||
#if (sys || hxnodejs)
|
#if (macro || ((sys || hxnodejs) && !frontend))
|
||||||
public static function fromFile(file:String) {
|
public static function fromFile(file:String) {
|
||||||
return new Stream(file, File.getContent(file));
|
return new Stream(file, File.getContent(file));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user