I don’t quite understand how this module works. In Flash,
the code obfuscation software would take the SWF file and create a version of the SWF with the obfuscated code.
When I installed the package in a simple test example and compiled
for the HTML5 version I got errors like this:
Ah, I see what’s going on. The obfuscator works when run using bob.jar from the project root, but when run from the unpack folder of the editor it obviously can’t find the prometheus.lua config file.
Attempting to use this on our game, there were a few problems obfuscating narrator by @astrochili
e.g
in test/runtime/jumping.lua line 18: local paragraphs = story:continue()
unexpected token <Keyword> “continue”, expected <Identifier>
and narrator/narrator/parser.lua line 56: local address = id * ('.' * id) ^ -2
Parsing Error at Position 56:36, Unexpected Token “-”. Expected a Expression!
The first I thought wouldn’t occur given that the configuration file specifies LuaVersion = “Lua51”, and the second (and others) are presumably also errors, if we assume the code is valid Lua.
Is there any easy way to temporary disable this plugin instead of removing it from game.project? Removing then adding is quite annoying, I must copy the dependency url for backup. Sometimes I just want to have a quick build for Android testing but I’m not happy to remove it, reopen the editor.
Is there anything I can add to prometheus.lua to make it disabled?
Good question! I’m not sure if if the obfuscated code for a file is the same every time or if there is some randomness to them. You would have to try yourself and check the checksum of the file between attempts (or do a simple file comparison).
Also ,i use fork of extension. It much easy to work with not minified code in development.
@britzl is it possible to read here game.project? mb it is not hard to add game.project-> prometheus → enable = 1 flag?
@Override
public String obfuscate(String input, String path, String buildVariant) throws Exception {
if(buildVariant.equals(Bob.VARIANT_RELEASE)) {
try {
Bob.initLua();
unpackPrometheusSource();
File inputFile = writeToTempFile(input);
File outputFile = createTempFile();
// command line arguments to launch prometheus
List<String> options = new ArrayList<String>();
options.add(Bob.getExe(Platform.getHostPlatform(), "luajit-64"));
options.add(getCliPath().toString());
options.add("--config");
options.add("prometheus.lua");
options.add("--out");
options.add(outputFile.getAbsolutePath());
options.add(inputFile.getAbsolutePath());
// launch the process
ProcessBuilder pb = new ProcessBuilder(options).redirectErrorStream(true);
java.util.Map<String, String> env = pb.environment();
env.put("LUA_PATH", Bob.getPath("share/luajit/") + "/?.lua");
Process p = pb.start();
int ret = p.waitFor();
// get all of the output from the process
InputStream is = p.getInputStream();
byte[] output_bytes = new byte[is.available()];
is.read(output_bytes);
is.close();
if (ret != 0) {
System.err.println(new String(output_bytes));
throw new Exception("Unable to run prometheus, return code: " + ret);
}
return readFile(outputFile);
} catch (Exception e) {
e.printStackTrace();
throw new Exception("Unable to run prometheus, ", e);
}
}else{
return input;
}
}
Another way is to use different settings files for building with bob. E.g. “–settings release.ini” which uses the complete list of dependencies (e.g. prometheus)