diff options
author | Jakub Jirutka <jakub@jirutka.cz> | 2017-03-30 00:44:07 +0200 |
---|---|---|
committer | Jakub Jirutka <jakub@jirutka.cz> | 2017-03-31 12:58:10 +0200 |
commit | a0a7e548470fb9aacbcf101c370e431b32704294 (patch) | |
tree | e500d7bc15ba658e4ed9895de11a6b936db6cd13 /testing | |
parent | 5dc3bb2b38d3e0793437bc6027f433f7e76414d1 (diff) | |
download | aports-a0a7e548470fb9aacbcf101c370e431b32704294.tar.bz2 aports-a0a7e548470fb9aacbcf101c370e431b32704294.tar.xz |
testing/emscripten: new aport
https://kripken.github.io/emscripten-site/
An LLVM-to-JavaScript Compiler
Diffstat (limited to 'testing')
-rw-r--r-- | testing/emscripten/APKBUILD | 96 | ||||
-rw-r--r-- | testing/emscripten/add-system-level-config.patch | 85 | ||||
-rw-r--r-- | testing/emscripten/emscripten.cfg | 17 | ||||
-rw-r--r-- | testing/emscripten/fix-python-shebang.patch | 104 | ||||
-rw-r--r-- | testing/emscripten/move-emcc-txt.patch | 12 | ||||
-rw-r--r-- | testing/emscripten/settings_template-paths.patch | 36 |
6 files changed, 350 insertions, 0 deletions
diff --git a/testing/emscripten/APKBUILD b/testing/emscripten/APKBUILD new file mode 100644 index 0000000000..60b80333a4 --- /dev/null +++ b/testing/emscripten/APKBUILD @@ -0,0 +1,96 @@ +# Contributor: Jakub Jirutka <jakub@jirutka.cz> +# Maintainer: Jakub Jirutka <jakub@jirutka.cz> + +# Note: This software is total mess and it seems to be nearly impossible to +# create a clean distribution package. +pkgname=emscripten +# Keep with sync with pkg emscrypten-fastcomp! +pkgver=1.37.9 +pkgrel=0 +pkgdesc="An LLVM-to-JavaScript Compiler" +url="https://kripken.github.io/emscripten-site/" +arch="all" +license="MIT UOI-NCSA" +depends="$pkgname-optimizer=$pkgver-r$pkgrel emscripten-fastcomp>=$pkgver + nodejs python2" +makedepends="cmake clang" +subpackages="$pkgname-optimizer" +source="$pkgname-$pkgver.tar.gz::https://github.com/kripken/$pkgname/archive/$pkgver.tar.gz + fix-python-shebang.patch + settings_template-paths.patch + add-system-level-config.patch + move-emcc-txt.patch + emscripten.cfg" +builddir="$srcdir/$pkgname-$pkgver" + +build() { + cd "$builddir"/tools/optimizer + + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ + -DCMAKE_C_FLAGS="$CFLAGS" \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_VERBOSE_MAKEFILE=ON + make +} + +check() { + cd "$builddir" + + sed "s|/usr/share/emscripten|$builddir|" "$srcdir"/emscripten.cfg \ + > tests/.emscripten + + ./emcc --em-config tests/.emscripten \ + --cache "$srcdir"/.cache \ + -o tests/hello_world.js tests/hello_world.c + node tests/hello_world.js +} + +package() { + local destdir="$pkgdir/usr/share/$pkgname" + local name + + mkdir -p "$destdir" + cp -r "$builddir"/* "$destdir"/ + + cd "$destdir" + + # This is read from emcc.py for --help. + cp site/build/text/docs/tools_reference/emcc.txt . + + find . -name "*.bat" -delete + rm -r docs # there are only few PDFs and TeX sources + rm -r media # media for website + rm -r site # a website (?) + rm -r tests # looks more like a dump of random sources than decent tests + rm -r third_party # bundled stuff + rm -r tools/optimizer # we've already built it + rm AUTHORS LICENSE *.md *.markdown package.json + rm system/lib/build_cxx_natively.sh + + mkdir -p "$pkgdir"/usr/bin + for name in em++ em-config emar embuilder.py emcc emcmake \ + emconfigure emlink.py emmake emrun emscons + do + ln -s ../share/$pkgname/$name "$pkgdir"/usr/bin/$name + done + + install -D -m 644 "$srcdir"/emscripten.cfg "$pkgdir"/etc/emscripten.cfg +} + +optimizer() { + pkgdesc="Emscripten's optimizer for asm.js code" + depends="" + + install -D -m 755 "$builddir"/tools/optimizer/optimizer \ + "$subpkgdir"/usr/bin/emoptimizer +} + +sha512sums="0efd9035d3dce0726025b5b8e30129885eef30f915c502b8957150e4ffc11fd0e9a2b605854cdf69ca3eb05e5102bf34341b7edd2116f5fa29fd170a28e7f07f emscripten-1.37.9.tar.gz +a61e172ced6b72adb53a840255a9753905a0c7a1c9f8965345781b9cdcc8a596c4dc88f036e91bd5c05d8b3eb2908bbb7d991c4e1abcf35a46be67b9765e546a fix-python-shebang.patch +ec0dc4a5c562fb85d861c37f5b3168351921dfd7865754ff117f757f15c45ec4474c56b71cd6f50beed71d91a270f3c7ad9d27db205be8eb6637b72b0c9fca8a settings_template-paths.patch +10a7a545f468a5f71fdf1cca0e0be983db5d21387202b851bd11f811c2a0a74f4e4c8733ae9ff933df4ea49c3f5e8e4e16fc3651bc98bb8c37a0828bb29eca7e add-system-level-config.patch +6613ef4cf41bcf0ecc13a0415cdc847f4ec112f07dd19573000ea6a9a6f2360aee6b2db01f822d117d5022dc58b2421be89fe3421c46fd6857737d07ce489c1e move-emcc-txt.patch +e485c974c465fc60ff0c81ba0a7e2c68bd2f653fff6861007d4ce29dd20c7163ba63ac1a3c449b870a8fa4642ad3ef1c8d1e6380add2db58f65553b58f626c9e emscripten.cfg" diff --git a/testing/emscripten/add-system-level-config.patch b/testing/emscripten/add-system-level-config.patch new file mode 100644 index 0000000000..b57860941c --- /dev/null +++ b/testing/emscripten/add-system-level-config.patch @@ -0,0 +1,85 @@ +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Wed, 29 Mar 2017 22:02:00 +0200 +Subject: [PATCH] Add system-level config /etc/emscripten.cfg + +If ~/.emscripten does not exist and /etc/emscripten.cfg do exist, then +/etc/emscripten.cfg will be used. + +--- a/emscripten.py ++++ b/emscripten.py +@@ -1791,7 +1791,7 @@ + help='Where to write the output; defaults to stdout.') + parser.add_option('-c', '--compiler', + default=None, +- help='Which JS engine to use to run the compiler; defaults to the one in ~/.emscripten.') ++ help='Which JS engine to use to run the compiler; defaults to the one in ~/.emscripten or /etc/emscripten.cfg.') + parser.add_option('-s', '--setting', + dest='settings', + default=[], + +--- a/tools/file_packager.py ++++ b/tools/file_packager.py +@@ -24,8 +24,8 @@ + it knows that closure is not run. + + --crunch=X Will compress dxt files to crn with quality level X. The crunch commandline tool must be present +- and CRUNCH should be defined in ~/.emscripten that points to it. JS crunch decompressing code will +- be added to convert the crn to dds in the browser. ++ and CRUNCH should be defined in ~/.emscripten or /etc/emscripten.cfg that points to it. JS crunch ++ decompressing code will be added to convert the crn to dds in the browser. + crunch-worker.js will be generated in the current directory. You should include that file when + packaging your site. + DDS files will not be crunched if the .crn is more recent than the .dds. This prevents a lot of +--- a/tools/scons/site_scons/site_tools/emscripten/emscripten.py ++++ b/tools/scons/site_scons/site_tools/emscripten/emscripten.py +@@ -10,6 +10,8 @@ + EM_CONFIG = os.environ.get('EM_CONFIG') + if not EM_CONFIG: + EM_CONFIG = os.path.expanduser('~/.emscripten') ++ if not os.path.exists(EM_CONFIG) and os.path.exists('/etc/emscripten.cfg'): ++ EM_CONFIG = '/etc/emscripten.cfg' + + if emscripten_path is None: + +--- a/tools/shared.py ++++ b/tools/shared.py +@@ -209,7 +209,10 @@ + EM_CONFIG = EM_CONFIG.replace(';', '\n') + '\n' + + if not EM_CONFIG: +- EM_CONFIG = '~/.emscripten' ++ if not os.path.exists(os.path.expanduser('~/.emscripten')) and os.path.exists('/etc/emscripten.cfg'): ++ EM_CONFIG = '/etc/emscripten.cfg' ++ else: ++ EM_CONFIG = '~/.emscripten' + if '\n' in EM_CONFIG: + CONFIG_FILE = None + logging.debug('EM_CONFIG is specified inline without a file') +@@ -271,7 +274,7 @@ + # without a file, this hints to "default" location at ~/.emscripten) + def hint_config_file_location(): + if CONFIG_FILE: return CONFIG_FILE +- else: return '~/.emscripten' ++ else: return '~/.emscripten' if os.path.exists(os.path.expanduser('~/.emscripten')) else '/etc/emscripten.cfg' + + def listify(x): + if type(x) is not list: return [x] +@@ -515,6 +515,8 @@ + sanity_file = CONFIG_FILE + '_sanity' + if get_llvm_target() == WASM_TARGET: + sanity_file += '_wasm' ++ if not os.access(os.path.dirname(sanity_file), os.W_OK): ++ sanity_file = os.path.join('/var/tmp', os.path.basename(sanity_file)) + if os.path.exists(sanity_file): + try: + sanity_mtime = os.stat(sanity_file).st_mtime +@@ -580,7 +580,8 @@ + + if not force: + # Only create/update this file if the sanity check succeeded, i.e., we got here +- f = open(sanity_file, 'w') ++ f = open(sanity_file, 'w+') + f.write(generate_sanity()) ++ os.chmod(sanity_file, 0o666) + f.close() + diff --git a/testing/emscripten/emscripten.cfg b/testing/emscripten/emscripten.cfg new file mode 100644 index 0000000000..495334a771 --- /dev/null +++ b/testing/emscripten/emscripten.cfg @@ -0,0 +1,17 @@ +import os + +EMSCRIPTEN_ROOT = '/usr/share/emscripten' +LLVM_ROOT = '/usr/lib/emscripten-fastcomp/bin' +BINARYEN_ROOT = os.getenv('BINARYEN', '') + +CLOSURE_COMPILER = os.getenv('CLOSURE', '/usr/bin/closure-compiler') +CRUNCH = os.getenv('CRUNCH', 'crunch') +EMSCRIPTEN_NATIVE_OPTIMIZER = '/usr/bin/emoptimizer' +JAVA = os.path.join(os.getenv('JAVA_HOME', '/usr/lib/jvm/default-jvm'), 'bin/java') +NODE_JS = os.getenv('NODE', 'node') +PYTHON = '/usr/bin/python2' + +TEMP_DIR = '/tmp' + +COMPILER_ENGINE = NODE_JS +JS_ENGINES = [NODE_JS] diff --git a/testing/emscripten/fix-python-shebang.patch b/testing/emscripten/fix-python-shebang.patch new file mode 100644 index 0000000000..4cb0c3d6a8 --- /dev/null +++ b/testing/emscripten/fix-python-shebang.patch @@ -0,0 +1,104 @@ +--- a/em++ ++++ b/em++ +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python2 + + # This script should work in python 2 *or* 3. It loads emcc.py, which needs python 2. + # It also tells emcc.py that we want C++ and not C by default +--- a/em++.py ++++ b/em++.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python2 + + # This script should work in python 2 *or* 3. It loads emcc.py, which needs python 2. + # It also tells emcc.py that we want C++ and not C by default +--- a/emar ++++ b/emar +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python2 + + # This script should work in python 2 *or* 3. It loads emar.py, which needs python 2. + +--- a/emcc ++++ b/emcc +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python2 + + # This script should work in python 2 *or* 3. It loads emcc.py, which needs python 2. + +--- a/emcmake ++++ b/emcmake +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python2 + + # This script should work in python 2 *or* 3. It loads emcmake.py, which needs python 2. + +--- a/emconfigure ++++ b/emconfigure +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python2 + + # This script should work in python 2 *or* 3. It loads emconfigure.py, which needs python 2. + +--- a/emmake ++++ b/emmake +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python2 + + # This script should work in python 2 *or* 3. It loads emmake.py, which needs python 2. + +--- a/emranlib ++++ b/emranlib +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python2 + + ''' + emcc - ranlib helper script +--- a/emrun ++++ b/emrun +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python2 + + # emrun: Implements machinery that allows running a .html page as if it was a standard executable file. + # Usage: emrun <options> filename.html <args to program> +--- a/system/bin/sdl-config ++++ b/system/bin/sdl-config +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python2 + + from __future__ import print_function + import sys +--- a/system/bin/sdl2-config ++++ b/system/bin/sdl2-config +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python2 + + from __future__ import print_function + import sys +--- a/tools/emprofile.py ++++ b/tools/emprofile.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python2 + + import sys, shutil, os, json, tempfile, time + +--- a/tools/ffdb.py ++++ b/tools/ffdb.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python2 + + import socket, json, sys, uuid, datetime, time, logging, cgi, zipfile, os, tempfile, atexit, subprocess, re, base64, struct, imghdr + diff --git a/testing/emscripten/move-emcc-txt.patch b/testing/emscripten/move-emcc-txt.patch new file mode 100644 index 0000000000..8875288310 --- /dev/null +++ b/testing/emscripten/move-emcc-txt.patch @@ -0,0 +1,12 @@ +emcc.txt is read from emcc.py for --help. Move it to more reasonable location. +--- a/emcc.py ++++ b/emcc.py +@@ -153,7 +153,7 @@ + + emcc: supported targets: llvm bitcode, javascript, NOT elf + (autoconf likes to see elf above to enable shared object support) +-''' % (open(shared.path_from_root('site', 'build', 'text', 'docs', 'tools_reference', 'emcc.txt')).read()) ++''' % (open(shared.path_from_root('emcc.txt')).read()) + exit(0) + + elif sys.argv[1] == '--version': diff --git a/testing/emscripten/settings_template-paths.patch b/testing/emscripten/settings_template-paths.patch new file mode 100644 index 0000000000..2407f23e3a --- /dev/null +++ b/testing/emscripten/settings_template-paths.patch @@ -0,0 +1,36 @@ +--- a/tools/settings_template_readonly.py ++++ b/tools/settings_template_readonly.py +@@ -7,19 +7,18 @@ + import os + + # this helps projects using emscripten find it +-EMSCRIPTEN_ROOT = os.path.expanduser(os.getenv('EMSCRIPTEN') or '{{{ EMSCRIPTEN_ROOT }}}') # directory +-LLVM_ROOT = os.path.expanduser(os.getenv('LLVM') or '{{{ LLVM_ROOT }}}') # directory ++EMSCRIPTEN_ROOT = os.path.expanduser(os.getenv('EMSCRIPTEN') or '/usr/share/emscripten') # directory ++LLVM_ROOT = os.path.expanduser(os.getenv('LLVM') or '/usr/lib/emscripten-fastcomp/bin') # directory + BINARYEN_ROOT = os.path.expanduser(os.getenv('BINARYEN') or '{{{ BINARYEN_ROOT }}}') # directory + + # If not specified, defaults to sys.executable. +-#PYTHON = 'python' ++PYTHON = 'python2' + +-# Add this if you have manually built the JS optimizer executable (in Emscripten/tools/optimizer) and want to run it from a custom location. + # Alternatively, you can set this as the environment variable EMSCRIPTEN_NATIVE_OPTIMIZER. +-# EMSCRIPTEN_NATIVE_OPTIMIZER='/path/to/custom/optimizer(.exe)' ++EMSCRIPTEN_NATIVE_OPTIMIZER='/usr/bin/emoptimizer' + + # See below for notes on which JS engine(s) you need +-NODE_JS = os.path.expanduser(os.getenv('NODE') or '{{{ NODE }}}') # executable ++NODE_JS = os.path.expanduser(os.getenv('NODE') or '/usr/bin/node') # executable + SPIDERMONKEY_ENGINE = [os.path.expanduser(os.getenv('SPIDERMONKEY') or 'js')] # executable + V8_ENGINE = os.path.expanduser(os.getenv('V8') or 'd8') # executable + +@@ -29,7 +28,7 @@ + + CRUNCH = os.path.expanduser(os.getenv('CRUNCH') or 'crunch') # executable + +-#CLOSURE_COMPILER = '..' # define this to not use the bundled version ++CLOSURE_COMPILER = '/usr/bin/closure-compiler' # define this to not use the bundled version + + ######################################################################################################## + |