Remove deprecated --split option.
This commit is contained in:
Родитель
050eab8141
Коммит
463e856f9e
28
emcc
28
emcc
|
@ -415,7 +415,6 @@ try:
|
|||
js_transform = None
|
||||
pre_js = ''
|
||||
post_js = ''
|
||||
split_js_file = None
|
||||
preload_files = []
|
||||
embed_files = []
|
||||
exclude_files = []
|
||||
|
@ -534,11 +533,6 @@ try:
|
|||
debug_level = max(1, debug_level)
|
||||
newargs[i] = ''
|
||||
newargs[i+1] = ''
|
||||
elif newargs[i].startswith('--split'):
|
||||
check_bad_eq(newargs[i])
|
||||
split_js_file = int(newargs[i+1])
|
||||
newargs[i] = ''
|
||||
newargs[i+1] = ''
|
||||
elif newargs[i].startswith('-g'):
|
||||
requested_level = newargs[i][2:] or '3'
|
||||
debug_level = validate_arg_level(requested_level, 4, 'Invalid debug level: ' + newargs[i])
|
||||
|
@ -718,9 +712,6 @@ try:
|
|||
newargs[i] = newargs[i+1] = ''
|
||||
newargs = [arg for arg in newargs if arg is not '']
|
||||
|
||||
if split_js_file:
|
||||
settings_changes.append("PRINT_SPLIT_FILE_MARKER=1")
|
||||
|
||||
# Find input files
|
||||
|
||||
# These three arrays are used to store arguments of different types for
|
||||
|
@ -902,7 +893,6 @@ try:
|
|||
assert shared.Settings.PGO == 0, 'pgo not supported in fastcomp'
|
||||
assert shared.Settings.USE_TYPED_ARRAYS == 2, 'altering USE_TYPED_ARRAYS is not supported'
|
||||
assert shared.Settings.QUANTUM_SIZE == 4, 'altering the QUANTUM_SIZE is not supported'
|
||||
assert not split_js_file, '--split-js is deprecated and not supported in fastcomp'
|
||||
assert shared.Settings.INIT_HEAP == 0, 'HEAP_INIT is not supported in fastcomp (and should never be needed except for debugging)'
|
||||
except Exception, e:
|
||||
logging.error('Compiler settings are incompatible with fastcomp. You can fall back to the older compiler core, although that is not recommended, see http://kripken.github.io/emscripten-site/docs/building_from_source/LLVM-Backend.html')
|
||||
|
@ -1755,18 +1745,14 @@ try {
|
|||
|
||||
html.close()
|
||||
else:
|
||||
if split_js_file:
|
||||
from tools.split import split_javascript_file
|
||||
split_javascript_file(final, unsuffixed(target), split_js_file)
|
||||
if debug_level >= 4: generate_source_map(target)
|
||||
if proxy_to_worker:
|
||||
worker_target_basename = target_basename + '.worker'
|
||||
open(target, 'w').write(open(shared.path_from_root('src', 'webGLClient.js')).read() + '\n' + open(shared.path_from_root('src', 'proxyClient.js')).read().replace('{{{ filename }}}', shared.Settings.PROXY_TO_WORKER_FILENAME or worker_target_basename).replace('{{{ IDBStore.js }}}', open(shared.path_from_root('src', 'IDBStore.js')).read()))
|
||||
shutil.move(final, target[:-3] + '.worker.js')
|
||||
else:
|
||||
if debug_level >= 4: generate_source_map(target)
|
||||
if proxy_to_worker:
|
||||
worker_target_basename = target_basename + '.worker'
|
||||
open(target, 'w').write(open(shared.path_from_root('src', 'webGLClient.js')).read() + '\n' + open(shared.path_from_root('src', 'proxyClient.js')).read().replace('{{{ filename }}}', shared.Settings.PROXY_TO_WORKER_FILENAME or worker_target_basename).replace('{{{ IDBStore.js }}}', open(shared.path_from_root('src', 'IDBStore.js')).read()))
|
||||
shutil.move(final, target[:-3] + '.worker.js')
|
||||
else:
|
||||
# copy final JS to output normally
|
||||
shutil.move(final, target)
|
||||
# copy final JS to output normally
|
||||
shutil.move(final, target)
|
||||
|
||||
log_time('final emitting')
|
||||
|
||||
|
|
|
@ -372,28 +372,6 @@ Options that are modified or new in *emcc* are listed below:
|
|||
example, "<cmd>" of **python processor.py** will cause a Python
|
||||
script to be run.
|
||||
|
||||
"--split <size>"
|
||||
Splits the resulting JavaScript file into pieces to ease debugging.
|
||||
|
||||
Warning: This option is deprecated (modern JavaScript debuggers
|
||||
should work even on large files).
|
||||
|
||||
This option only works if JavaScript is generated ("target -o
|
||||
<name>.js"). Files with function declarations must be loaded before
|
||||
main file upon execution.
|
||||
|
||||
* Without the "-g" option this creates files with function
|
||||
declarations up to the given size with the suffix
|
||||
**_functions.partxxx.js** and a main file with the suffix
|
||||
**.js**.
|
||||
|
||||
* With the "-g" option this recreates the directory structure
|
||||
of the C source files and stores function declarations in
|
||||
their respective C files with the suffix ".js". If such a file
|
||||
exceeds the given size, files with the suffix ".partxxx.js"
|
||||
are created. The main file resides in the base directory and
|
||||
has the suffix ".js".
|
||||
|
||||
"--bind"
|
||||
Compiles the source code using the *Embind* bindings to connect
|
||||
C/C++ and JavaScript.
|
||||
|
|
|
@ -316,17 +316,6 @@ Options that are modified or new in *emcc* are listed below:
|
|||
|
||||
``<cmd>`` is interpreted as a space-separated list of arguments, for example, ``<cmd>`` of **python processor.py** will cause a Python script to be run.
|
||||
|
||||
``--split <size>``
|
||||
Splits the resulting JavaScript file into pieces to ease debugging.
|
||||
|
||||
.. warning:: This option is deprecated (modern JavaScript debuggers should work even on large files).
|
||||
|
||||
This option only works if JavaScript is generated (``target -o <name>.js``). Files with function declarations must be loaded before main file upon execution.
|
||||
|
||||
- Without the ``-g`` option this creates files with function declarations up to the given size with the suffix **_functions.partxxx.js** and a main file with the suffix **.js**.
|
||||
- With the ``-g`` option this recreates the directory structure of the C source files and stores function declarations in their respective C files with the suffix ".js". If such a file exceeds the given size, files with the suffix ".partxxx.js" are created. The main file resides in the base directory and has the suffix ".js".
|
||||
|
||||
|
||||
.. _emcc-bind:
|
||||
|
||||
``--bind``
|
||||
|
|
|
@ -351,8 +351,6 @@ var SHELL_FILE = 0; // set this to a string to override the shell file used
|
|||
|
||||
var SHOW_LABELS = 0; // Show labels in the generated code
|
||||
|
||||
var PRINT_SPLIT_FILE_MARKER = 0; // Prints markers in Javascript generation to split the file later on. See emcc --split option.
|
||||
|
||||
var RELOCATABLE = 0; // If set to 1, we emit relocatable code from the LLVM backend; both
|
||||
// globals and function pointers are all offset (by gb and fp, respectively)
|
||||
|
||||
|
|
|
@ -124,193 +124,6 @@ If manually bisecting:
|
|||
finally:
|
||||
os.chdir(cwd)
|
||||
|
||||
# TODO: test only worked in non-fastcomp
|
||||
def test_split(self):
|
||||
return self.skip('non-fastcomp is deprecated and fails in 3.5')
|
||||
# test HTML generation.
|
||||
self.reftest(path_from_root('tests', 'htmltest.png'))
|
||||
output = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_sdl.cpp'), '-o', 'something.js', '--split', '100', '--pre-js', 'reftest.js']).communicate()
|
||||
assert os.path.exists(os.path.join(self.get_dir(), 'something.js')), 'must be main js file'
|
||||
assert os.path.exists(os.path.join(self.get_dir(), 'something_functions.js')), 'must be functions js file'
|
||||
assert os.path.exists(os.path.join(self.get_dir(), 'something.include.html')), 'must be js include file'
|
||||
|
||||
open(os.path.join(self.get_dir(), 'something.html'), 'w').write('''
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Emscripten-Generated Code</title>
|
||||
<style>
|
||||
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
|
||||
canvas.emscripten { border: 1px solid black; }
|
||||
textarea.emscripten { font-family: monospace; width: 80%; }
|
||||
div.emscripten { text-align: center; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<hr/>
|
||||
<div class="emscripten" id="status">Downloading...</div>
|
||||
<div class="emscripten">
|
||||
<progress value="0" max="100" id="progress" hidden=1></progress>
|
||||
</div>
|
||||
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
||||
<hr/>
|
||||
<div class="emscripten"><input type="button" value="fullscreen" onclick="Module.requestFullScreen()"></div>
|
||||
<hr/>
|
||||
<textarea class="emscripten" id="output" rows="8"></textarea>
|
||||
<hr>
|
||||
<script type='text/javascript'>
|
||||
// connect to canvas
|
||||
var Module = {
|
||||
preRun: [],
|
||||
postRun: [],
|
||||
print: (function() {
|
||||
var element = document.getElementById('output');
|
||||
element.value = ''; // clear browser cache
|
||||
return function(text) {
|
||||
// These replacements are necessary if you render to raw HTML
|
||||
//text = text.replace(/&/g, "&");
|
||||
//text = text.replace(/</g, "<");
|
||||
//text = text.replace(/>/g, ">");
|
||||
//text = text.replace('\\n', '<br>', 'g');
|
||||
element.value += text + "\\n";
|
||||
element.scrollTop = element.scrollHeight; // focus on bottom
|
||||
};
|
||||
})(),
|
||||
printErr: function(text) {
|
||||
if (0) { // XXX disabled for safety typeof dump == 'function') {
|
||||
dump(text + '\\n'); // fast, straight to the real console
|
||||
} else {
|
||||
console.log(text);
|
||||
}
|
||||
},
|
||||
canvas: document.getElementById('canvas'),
|
||||
setStatus: function(text) {
|
||||
if (Module.setStatus.interval) clearInterval(Module.setStatus.interval);
|
||||
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
|
||||
var statusElement = document.getElementById('status');
|
||||
var progressElement = document.getElementById('progress');
|
||||
if (m) {
|
||||
text = m[1];
|
||||
progressElement.value = parseInt(m[2])*100;
|
||||
progressElement.max = parseInt(m[4])*100;
|
||||
progressElement.hidden = false;
|
||||
} else {
|
||||
progressElement.value = null;
|
||||
progressElement.max = null;
|
||||
progressElement.hidden = true;
|
||||
}
|
||||
statusElement.innerHTML = text;
|
||||
},
|
||||
totalDependencies: 0,
|
||||
monitorRunDependencies: function(left) {
|
||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
|
||||
}
|
||||
};
|
||||
Module.setStatus('Downloading...');
|
||||
</script>''' + open(os.path.join(self.get_dir(), 'something.include.html')).read() + '''
|
||||
</body>
|
||||
</html>
|
||||
''')
|
||||
|
||||
self.run_browser('something.html', 'You should see "hello, world!" and a colored cube.', '/report_result?0')
|
||||
|
||||
# TODO: test only worked in non-fastcomp
|
||||
def test_split_in_source_filenames(self):
|
||||
return self.skip('non-fastcomp is deprecated and fails in 3.5')
|
||||
self.reftest(path_from_root('tests', 'htmltest.png'))
|
||||
output = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_sdl.cpp'), '-o', 'something.js', '-g', '--split', '100', '--pre-js', 'reftest.js']).communicate()
|
||||
assert os.path.exists(os.path.join(self.get_dir(), 'something.js')), 'must be main js file'
|
||||
assert os.path.exists(os.path.join(self.get_dir(), 'something', 'hello_world_sdl.cpp.js')), 'must be functions js file'
|
||||
assert os.path.exists(os.path.join(self.get_dir(), 'something.include.html')), 'must be js include file'
|
||||
|
||||
open(os.path.join(self.get_dir(), 'something.html'), 'w').write('''
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Emscripten-Generated Code</title>
|
||||
<style>
|
||||
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
|
||||
canvas.emscripten { border: 1px solid black; }
|
||||
textarea.emscripten { font-family: monospace; width: 80%; }
|
||||
div.emscripten { text-align: center; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<hr/>
|
||||
<div class="emscripten" id="status">Downloading...</div>
|
||||
<div class="emscripten">
|
||||
<progress value="0" max="100" id="progress" hidden=1></progress>
|
||||
</div>
|
||||
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
||||
<hr/>
|
||||
<div class="emscripten"><input type="button" value="fullscreen" onclick="Module.requestFullScreen()"></div>
|
||||
<hr/>
|
||||
<textarea class="emscripten" id="output" rows="8"></textarea>
|
||||
<hr>
|
||||
<script type='text/javascript'>
|
||||
// connect to canvas
|
||||
var Module = {
|
||||
preRun: [],
|
||||
postRun: [],
|
||||
print: (function() {
|
||||
var element = document.getElementById('output');
|
||||
element.value = ''; // clear browser cache
|
||||
return function(text) {
|
||||
// These replacements are necessary if you render to raw HTML
|
||||
//text = text.replace(/&/g, "&");
|
||||
//text = text.replace(/</g, "<");
|
||||
//text = text.replace(/>/g, ">");
|
||||
//text = text.replace('\\n', '<br>', 'g');
|
||||
element.value += text + "\\n";
|
||||
element.scrollTop = element.scrollHeight; // focus on bottom
|
||||
};
|
||||
})(),
|
||||
printErr: function(text) {
|
||||
if (0) { // XXX disabled for safety typeof dump == 'function') {
|
||||
dump(text + '\\n'); // fast, straight to the real console
|
||||
} else {
|
||||
console.log(text);
|
||||
}
|
||||
},
|
||||
canvas: document.getElementById('canvas'),
|
||||
setStatus: function(text) {
|
||||
if (Module.setStatus.interval) clearInterval(Module.setStatus.interval);
|
||||
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
|
||||
var statusElement = document.getElementById('status');
|
||||
var progressElement = document.getElementById('progress');
|
||||
if (m) {
|
||||
text = m[1];
|
||||
progressElement.value = parseInt(m[2])*100;
|
||||
progressElement.max = parseInt(m[4])*100;
|
||||
progressElement.hidden = false;
|
||||
} else {
|
||||
progressElement.value = null;
|
||||
progressElement.max = null;
|
||||
progressElement.hidden = true;
|
||||
}
|
||||
statusElement.innerHTML = text;
|
||||
},
|
||||
totalDependencies: 0,
|
||||
monitorRunDependencies: function(left) {
|
||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
|
||||
}
|
||||
};
|
||||
Module.setStatus('Downloading...');
|
||||
</script>''' + open(os.path.join(self.get_dir(), 'something.include.html')).read() + '''
|
||||
</body>
|
||||
</html>
|
||||
''')
|
||||
|
||||
self.run_browser('something.html', 'You should see "hello, world!" and a colored cube.', '/report_result?0')
|
||||
|
||||
def test_compression(self):
|
||||
open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(r'''
|
||||
#include <stdio.h>
|
||||
|
|
105
tools/split.py
105
tools/split.py
|
@ -1,105 +0,0 @@
|
|||
import sys
|
||||
import os
|
||||
from sets import Set
|
||||
|
||||
def split_javascript_file(input_filename, output_filename_prefix, max_part_size_in_bytes):
|
||||
|
||||
try:
|
||||
# Javascript main file. On execution, this file needs to be loaded at last (!)
|
||||
output_main_filename = output_filename_prefix + ".js"
|
||||
output_main_file = open(output_main_filename,'w')
|
||||
# File with HTML script tags to load the Javascript files in HTML later on
|
||||
output_html_include_file = open(output_filename_prefix + ".include.html",'w')
|
||||
|
||||
# Variable will contain the source of a Javascript function if we find one during parsing
|
||||
js_function = None
|
||||
|
||||
# Dictionary with lower case source file as key and a tupel of case sensitive source file name (first encountered case wins)
|
||||
# and an array of functions associated to that source file as value
|
||||
function_buckets = {};
|
||||
|
||||
output_part_file = None
|
||||
|
||||
# Locate names of all the source files (.c/.cpp) that produced output to the .js file.
|
||||
source_files = Set()
|
||||
for line in open(input_filename,'r'):
|
||||
if line.startswith("//FUNCTION_END_MARKER_OF_SOURCE_FILE_"):
|
||||
associated_source_file_base = line[len("//FUNCTION_END_MARKER_OF_SOURCE_FILE_"):len(line)-1]
|
||||
if not associated_source_file_base == "NO_SOURCE":
|
||||
source_files.add(os.path.dirname(os.path.abspath(os.path.realpath(associated_source_file_base))))
|
||||
|
||||
common_source_file_prefix = os.path.commonprefix(list(source_files))
|
||||
|
||||
# Iterate over Javascript source; write main file; parse function declarations.
|
||||
input_file = open(input_filename,'r')
|
||||
for line in input_file:
|
||||
if line == "//FUNCTION_BEGIN_MARKER\n":
|
||||
js_function = "//Func\n"
|
||||
elif line.startswith("//FUNCTION_END_MARKER_OF_SOURCE_FILE_"):
|
||||
# At the end of the function marker we get the source file that is associated to that function.
|
||||
associated_source_file_base = line[len("//FUNCTION_END_MARKER_OF_SOURCE_FILE_"):len(line)-1]
|
||||
|
||||
if associated_source_file_base == "NO_SOURCE":
|
||||
# Functions without associated source file are stored in a file in the base directory
|
||||
associated_source_file_base = output_filename_prefix + "_functions";
|
||||
else:
|
||||
# Functions with a known associated source file are stored in a file in the directory `output_filename_prefix`
|
||||
associated_source_file_base = os.path.join(output_filename_prefix, os.path.relpath(os.path.abspath(os.path.realpath(associated_source_file_base)), common_source_file_prefix))
|
||||
|
||||
associated_source_file_base_lower = associated_source_file_base.lower()
|
||||
|
||||
# Add the function to its respective file
|
||||
if associated_source_file_base_lower not in function_buckets:
|
||||
function_buckets[associated_source_file_base_lower] = [associated_source_file_base, []]
|
||||
function_buckets[associated_source_file_base_lower][1] += [js_function]
|
||||
|
||||
# Clear the function read cache
|
||||
js_function = None
|
||||
else:
|
||||
if js_function is None:
|
||||
output_main_file.write(line)
|
||||
else:
|
||||
js_function += line
|
||||
|
||||
# Iterate over all function buckets and write their functions to the associated files
|
||||
# An associated file is split into chunks of `max_part_size_in_bytes`
|
||||
for associated_source_file_base in function_buckets:
|
||||
# At first we try to name the Javascript source file to match the assoicated source file + `.js`
|
||||
js_source_file = function_buckets[associated_source_file_base][0] + ".js"
|
||||
|
||||
# Check if the directory of the Javascript source file exists
|
||||
js_source_dir = os.path.dirname(js_source_file)
|
||||
if len(js_source_dir) > 0 and not os.path.exists(js_source_dir):
|
||||
os.makedirs(js_source_dir)
|
||||
|
||||
output_part_file_counter = 0
|
||||
output_part_file = None
|
||||
for js_function in function_buckets[associated_source_file_base][1]:
|
||||
if output_part_file is None:
|
||||
output_html_include_file.write("<script type=\"text/javascript\" src=\"" + js_source_file.replace('\\', '/') + "\"></script>")
|
||||
output_part_file = open(js_source_file,'w')
|
||||
|
||||
output_part_file.write(js_function)
|
||||
|
||||
if output_part_file is not None and output_part_file.tell() > max_part_size_in_bytes:
|
||||
output_part_file.close()
|
||||
output_part_file = None
|
||||
output_part_file_counter += 1
|
||||
js_source_file = function_buckets[associated_source_file_base][0] + ".part" + str(output_part_file_counter) + ".js"
|
||||
|
||||
if output_part_file is not None:
|
||||
output_part_file.close()
|
||||
output_part_file = None
|
||||
|
||||
# Write the main Javascript file at last to the HTML includes because this file contains the code to start
|
||||
# the execution of the generated Emscripten application and requires all the extracted functions.
|
||||
output_html_include_file.write("<script type=\"text/javascript\" src=\"" + output_main_filename.replace('\\', '/') + "\"></script>")
|
||||
|
||||
except Exception, e:
|
||||
print >> sys.stderr, 'error: Splitting of Emscripten generated Javascript failed: %s' % str(e)
|
||||
|
||||
finally:
|
||||
if input_file is not None: input_file.close()
|
||||
if output_main_file is not None: output_main_file.close()
|
||||
if output_part_file is not None: output_part_file.close()
|
||||
if output_html_include_file is not None: output_html_include_file.close()
|
Загрузка…
Ссылка в новой задаче