New front end! To complement the webification of my puzzles via Java

applets, here's an alternative webification in Javascript, using
Emscripten in asm.js mode (so that as browsers incorporate asm.js
optimisation, the game generation should run really fast).

[originally from svn r9781]
This commit is contained in:
Simon Tatham
2013-03-30 20:16:21 +00:00
parent e2c84a5fd2
commit 49fba922ea
8 changed files with 1936 additions and 1 deletions

View File

@ -287,7 +287,7 @@ sub mfval($) {
# Returns true if the argument is a known makefile type. Otherwise,
# prints a warning and returns false;
if (grep { $type eq $_ }
("vc","vcproj","cygwin","borland","lcc","gtk","mpw","nestedvm","osx","wce","gnustep")) {
("vc","vcproj","cygwin","borland","lcc","gtk","mpw","nestedvm","osx","wce","gnustep","emcc")) {
return 1;
}
warn "$.:unknown makefile type '$type'\n";
@ -1589,3 +1589,59 @@ if (defined $makefiles{'gnustep'}) {
"\trm -rf *.app\n";
select STDOUT; close OUT;
}
if (defined $makefiles{'emcc'}) {
$mftyp = 'emcc';
$dirpfx = &dirpfx($makefiles{'emcc'}, "/");
##-- Makefile for building Javascript puzzles via Emscripten
open OUT, ">$makefiles{'emcc'}"; select OUT;
print
"# Makefile for $project_name using Emscripten. Requires GNU make.\n".
"#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
"# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
# emcc command line option is -D not /D
($_ = $help) =~ s/=\/D/=-D/gs;
print $_;
print
"\n".
"# This can be set on the command line to point at the emcc command,\n".
"# if it is not on your PATH.\n".
"EMCC = emcc\n".
"\n".
&splitline("CFLAGS = -DSLOW_SYSTEM " .
(join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
"\n";
$output_js_files = join "", map { " \$(OUTPREFIX)$_.js" } &progrealnames("X");
print &splitline("all:" . $output_js_files);
print "\n\n";
foreach $p (&prognames("X")) {
($prog, $type) = split ",", $p;
$objstr = &objects($p, "X.o", undef, undef);
$objstr =~ s/gtk\.o/emcc\.o/g;
print &splitline("\$(OUTPREFIX)" . $prog . ".js: " . $objstr . " emccpre.js emcclib.js emccx.json"), "\n";
print "\t\$(EMCC) -o \$(OUTPREFIX)".$prog.".js ".
"-O2 ".
"-s ASM_JS=1 ".
"--pre-js emccpre.js ".
"--js-library emcclib.js ".
"-s EXPORTED_FUNCTIONS=\"`sed 's://.*::' emccx.json | tr -d ' \\n'`\" " . $objstr . "\n\n";
}
foreach $d (&deps("X.o", undef, $dirpfx, "/")) {
$oobjs = $d->{obj};
$ddeps= join " ", @{$d->{deps}};
$oobjs =~ s/gtk/emcc/g;
$ddeps =~ s/gtk/emcc/g;
print &splitline(sprintf("%s: %s", $oobjs, $ddeps)),
"\n";
$deflist = join "", map { " -D$_" } @{$d->{defs}};
print "\t\$(EMCC) \$(CFLAGS) \$(XFLAGS)$deflist" .
" -c \$< -o \$\@\n";
}
print "\n";
print $makefile_extra{'emcc'} || "";
print "\nclean:\n".
"\trm -rf *.o $output_js_files\n";
select STDOUT; close OUT;
}