| Index: compile |
| =================================================================== |
| --- a/compile |
| +++ b/compile |
| @@ -10,124 +10,16 @@ |
| # Adblock Plus is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| # GNU General Public License for more details. |
| # |
| # You should have received a copy of the GNU General Public License |
| # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| -import argparse |
| -import os |
| -import subprocess |
| -import sys |
| - |
| -BASE_DIR = os.path.dirname(__file__) |
| -SOURCE_DIR = os.path.join(BASE_DIR, 'compiled') |
| -JS_LIBRARY = os.path.join(SOURCE_DIR, 'library.js') |
| -BINDINGS_GENERATOR = os.path.join(SOURCE_DIR, 'bindings.cpp.js') |
| -BINDINGS_OUTPUT = os.path.join(SOURCE_DIR, 'bindings.js') |
| -COMPILER_OUTPUT = os.path.join(BASE_DIR, 'lib', 'compiled.js') |
| -GENERATION_PARAMS = { |
| - 'SHELL_FILE': "'{}'".format(os.path.abspath(os.path.join(SOURCE_DIR, |
| - 'shell.js'))), |
| - 'ASM_JS': 2, # "almost asm" |
| - 'TOTAL_MEMORY': 16*1024*1024, |
| - 'TOTAL_STACK': 1*1024*1024, |
| - 'ALLOW_MEMORY_GROWTH': 1, |
| - 'NO_EXIT_RUNTIME': 1, |
| - 'NO_DYNAMIC_EXECUTION': 1, |
| - 'NO_FILESYSTEM': 1, |
| - 'INVOKE_RUN': 0, |
| - 'TEXTDECODER': 0, |
| - 'EXPORTED_RUNTIME_METHODS': ['cwrap', 'ccall', 'stringToAscii'], |
| -} |
| -DEFINES = [] |
| -ADDITIONAL_PARAMS = ['-O3', '-m32', '-std=c++1z', '--memory-init-file', '0', |
| - '--emit-symbol-map', '-Wall', '-Werror', '-fno-exceptions', |
| - '-fno-rtti', '--js-library', JS_LIBRARY] |
| - |
| - |
| -def get_source_files(phase): |
| - for (path, dirs, files) in os.walk(SOURCE_DIR): |
| - for f in files: |
| - if os.path.splitext(f)[1] != '.cpp': |
| - continue |
| - if ( |
| - phase != 'bindings' and |
| - os.path.basename(path) == 'bindings' and |
| - not f.startswith('runtime_') |
| - ): |
| - continue |
| - yield os.path.join(path, f) |
| - |
| -def getenv(emscripten_config): |
| - scope = {} |
| - execfile(emscripten_config, scope, scope) |
| - env = os.environ.copy() |
| - env.update({ |
| - 'EM_CONFIG': emscripten_config, |
| - 'EMSCRIPTEN': scope['EMSCRIPTEN_ROOT'], |
| - 'PYTHON': scope.get('PYTHON', sys.executable), |
| - 'NODE_JS': scope.get('NODE_JS', 'node'), |
| - }) |
| - return env |
| - |
| -def generate_bindings(env): |
| - params = [ |
| - env['PYTHON'], os.path.join(env['EMSCRIPTEN'], 'emcc'), |
| - '-o', BINDINGS_GENERATOR, '-std=c++1z', '--js-library', JS_LIBRARY, |
| - '--js-library', os.path.join(SOURCE_DIR, 'bindings', 'library.js'), |
| - ] + list(get_source_files('bindings')) |
| - subprocess.check_call(params, env=env) |
| - |
| - with open(BINDINGS_OUTPUT, 'w') as file: |
| - subprocess.check_call([env['NODE_JS'], BINDINGS_GENERATOR], |
| - stdout=file) |
| - |
| +print "This script is deprecated.\n" |
| +print "Please use meson:" |
| +print "\tmeson build" |
| +print "then:" |
| +print "\tninja -C build" |
|
Wladimir Palant
2017/12/14 10:57:01
Is there a point in having this? It's not like we
hub
2017/12/15 17:44:55
habits. I'll just remove compile.
|
| -def run_compiler(env, debug=False, tracing=False): |
| - params = [ |
| - env['PYTHON'], os.path.join(env['EMSCRIPTEN'], 'emcc'), |
| - '-o', COMPILER_OUTPUT, |
| - '--post-js', BINDINGS_OUTPUT, |
| - ] |
| - # Order matters. We sort source files so that we always get the same |
| - # results for the same source code. |
| - params.extend(sorted(get_source_files('compile'))) |
| - params.extend('-D' + flag for flag in DEFINES) |
| - for key, value in GENERATION_PARAMS.iteritems(): |
| - params.extend(['-s', '{}={}'.format(key, str(value))]) |
| - if debug: |
| - params.append('-DDEBUG') |
| - params.append('-g3') |
| - if tracing: |
| - params.append('--tracing') |
| - params.extend(ADDITIONAL_PARAMS) |
| - subprocess.check_call(params, env=env) |
| - |
| - |
| -if __name__ == '__main__': |
| - parser = argparse.ArgumentParser( |
| - description='Compile Emscripten-based C++ code to JavaScript' |
| - ) |
| - parser.add_argument( |
| - '--emscripten-config', |
| - metavar='DIR', |
| - default=os.path.expanduser('~/.emscripten'), |
| - help='Emscripten installation directory' |
| - ) |
| - parser.add_argument( |
| - '-d', '--debug', |
| - action='store_true', |
| - help='Disable code minification' |
| - ) |
| - parser.add_argument( |
| - '-t', '--tracing', |
| - action='store_true', |
| - help='Enable memory tracing' |
| - ) |
| - args = parser.parse_args() |
| - |
| - env = getenv(args.emscripten_config) |
| - generate_bindings(env) |
| - run_compiler(env, debug=args.debug, tracing=args.tracing) |
| +exit(1) |