Libraryless. Click here for Pure Java version (11552L/72K/231K).
1 | !7 |
2 | |
3 | sbool verbose = true; |
4 | |
5 | p {
|
6 | makeAndroid("Compiler bot with caching!");
|
7 | } |
8 | |
9 | static synchronized S answer(S s) {
|
10 | new Matches m; |
11 | if (match3("Please compile this JavaX snippet: *", s, m)) {
|
12 | S snippetID = unquote(m.m[0]); |
13 | S transpiledSrc = getServerTranspiled(snippetID); |
14 | int i = transpiledSrc.indexOf('\n');
|
15 | String libs = transpiledSrc.substring(0, Math.max(0, i)); |
16 | print("Compiling snippet: " + snippetID + ". Libs: " + libs);
|
17 | transpiledSrc = transpiledSrc.substring(i+1); |
18 | return compile(transpiledSrc, libs); |
19 | } |
20 | |
21 | if "Please compile this Java text: *" |
22 | ret compile($1, ""); |
23 | |
24 | if "Please compile this Java text: * with libraries *" |
25 | ret compile($1, $2); |
26 | |
27 | if (match3("Please compile this Java text: * for java version *", s, m)) {
|
28 | String src = unquote(m.m[0]); |
29 | String target = unquote(m.m[1]); |
30 | return compile(src, "", target); |
31 | } |
32 | |
33 | return null; |
34 | } |
35 | |
36 | static synchronized S compile(S src, S libs) {
|
37 | return compile(src, libs, null); |
38 | } |
39 | |
40 | static synchronized S compile(S src, S dehlibs, S javaTarget) {
|
41 | if (verbose) |
42 | print("Compiling " + l(src) + " chars");
|
43 | S md5 = md5(src); |
44 | File jar = getJarFile(md5); |
45 | if (jar == null || jar.length() <= 22) {
|
46 | // have to compile |
47 | |
48 | try {
|
49 | javaCompileToJar(src, dehlibs, jar); |
50 | } catch e {
|
51 | ret e.getMessage(); |
52 | } |
53 | } else {
|
54 | print("Getting classes from cache (" + jar.getAbsolutePath() + ", " + jar.length() + " bytes)");
|
55 | touchFile(jar); // so we can find the unused ones easier |
56 | } |
57 | |
58 | return "ok, " + quote(jar.getAbsolutePath()); |
59 | } |
60 | |
61 | static File getJarFile(S md5) {
|
62 | assertTrue(isMD5(md5)); |
63 | ret new File(getCacheProgramDir(), md5 + ".jar"); |
64 | } |
Began life as a copy of #1001155
download show line numbers debug dex old transpilations
Travelled to 22 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gmoysmmjifsf, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xprdwmaupziu
No comments. add comment
| Snippet ID: | #1002203 |
| Snippet name: | Compiler Bot with dedicated .jar cache (LIVE at bots.tinybrain.de) |
| Eternal ID of this version: | #1002203/2 |
| Text MD5: | bfcbe726b1e3f56ea6d46dd582562b48 |
| Transpilation MD5: | 287d0841d6c54627893590e25f0e5b4c |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-10-24 13:17:40 |
| Source code size: | 1743 bytes / 64 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1025 / 3671 |
| Version history: | 1 change(s) |
| Referenced in: | [show references] |