mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1220731 - Refactor embedjs script for use from moz.build rather than makefiles r=shu r=glandium
This commit is contained in:
parent
b2a514cf5b
commit
441b24da04
@ -504,10 +504,8 @@ endif
|
|||||||
|
|
||||||
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
|
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
|
||||||
OUTOPTION = -Fo# eol
|
OUTOPTION = -Fo# eol
|
||||||
PREPROCESS_OPTION = -P -Fi# eol
|
|
||||||
else
|
else
|
||||||
OUTOPTION = -o # eol
|
OUTOPTION = -o # eol
|
||||||
PREPROCESS_OPTION = -E -o #eol
|
|
||||||
endif # WINNT && !GNU_CC
|
endif # WINNT && !GNU_CC
|
||||||
|
|
||||||
ifneq (,$(filter ml%,$(AS)))
|
ifneq (,$(filter ml%,$(AS)))
|
||||||
|
12
configure.in
12
configure.in
@ -9144,6 +9144,18 @@ HAVE_SYS_VFS_H
|
|||||||
HAVE_SYS_MOUNT_H
|
HAVE_SYS_MOUNT_H
|
||||||
"
|
"
|
||||||
|
|
||||||
|
dnl ========================================================
|
||||||
|
dnl Determine options to use for running the preprocessor.
|
||||||
|
dnl ========================================================
|
||||||
|
|
||||||
|
if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT"; then
|
||||||
|
PREPROCESS_OPTION="-P -Fi"
|
||||||
|
else
|
||||||
|
PREPROCESS_OPTION="-E -o "
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_SUBST(PREPROCESS_OPTION)
|
||||||
|
|
||||||
dnl ========================================================
|
dnl ========================================================
|
||||||
dnl ICU Support
|
dnl ICU Support
|
||||||
dnl ========================================================
|
dnl ========================================================
|
||||||
|
@ -277,47 +277,6 @@ $(CURDIR)/javascript-trace.h: $(srcdir)/devtools/javascript-trace.d
|
|||||||
$(addsuffix .$(OBJ_SUFFIX),Probes jsinterp jsobj): $(CURDIR)/javascript-trace.h
|
$(addsuffix .$(OBJ_SUFFIX),Probes jsinterp jsobj): $(CURDIR)/javascript-trace.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Prepare self-hosted JS code for embedding
|
|
||||||
export:: selfhosting
|
|
||||||
selfhosting:: selfhosted.out.h
|
|
||||||
|
|
||||||
selfhosting_srcs := \
|
|
||||||
$(srcdir)/builtin/Utilities.js \
|
|
||||||
$(srcdir)/builtin/Array.js \
|
|
||||||
$(srcdir)/builtin/Date.js \
|
|
||||||
$(srcdir)/builtin/Error.js \
|
|
||||||
$(srcdir)/builtin/Generator.js \
|
|
||||||
$(srcdir)/builtin/Intl.js \
|
|
||||||
$(srcdir)/builtin/IntlData.js \
|
|
||||||
$(srcdir)/builtin/Iterator.js \
|
|
||||||
$(srcdir)/builtin/Map.js \
|
|
||||||
$(srcdir)/builtin/Module.js \
|
|
||||||
$(srcdir)/builtin/Number.js \
|
|
||||||
$(srcdir)/builtin/Object.js \
|
|
||||||
$(srcdir)/builtin/Reflect.js \
|
|
||||||
$(srcdir)/builtin/RegExp.js \
|
|
||||||
$(srcdir)/builtin/String.js \
|
|
||||||
$(srcdir)/builtin/Set.js \
|
|
||||||
$(srcdir)/builtin/TypedArray.js \
|
|
||||||
$(srcdir)/builtin/TypedObject.js \
|
|
||||||
$(srcdir)/builtin/WeakSet.js \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
selfhosted_out_h_deps := \
|
|
||||||
$(selfhosting_srcs) \
|
|
||||||
$(srcdir)/js.msg \
|
|
||||||
$(srcdir)/builtin/embedjs.py \
|
|
||||||
$(srcdir)/builtin/TypedObjectConstants.h \
|
|
||||||
$(srcdir)/builtin/SelfHostingDefines.h \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
SELFHOSTED_DEFINES += $(DEFINES) $(ACDEFINES) $(MOZ_DEBUG_DEFINES)
|
|
||||||
|
|
||||||
selfhosted.out.h: $(selfhosted_out_h_deps)
|
|
||||||
$(PYTHON) $(srcdir)/builtin/embedjs.py $(SELFHOSTED_DEFINES) \
|
|
||||||
-c '$(CCC)' -p '$(PREPROCESS_OPTION)' -m $(srcdir)/js.msg \
|
|
||||||
-o $@ $(selfhosting_srcs)
|
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
# Generating source package tarballs
|
# Generating source package tarballs
|
||||||
# (only possible when tar is found)
|
# (only possible when tar is found)
|
||||||
|
@ -37,10 +37,10 @@
|
|||||||
# It uses the C preprocessor to process its inputs.
|
# It uses the C preprocessor to process its inputs.
|
||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
import re, sys, os, fileinput, subprocess
|
import re, sys, os, subprocess
|
||||||
import shlex
|
import shlex
|
||||||
import which
|
import which
|
||||||
from optparse import OptionParser
|
import buildconfig
|
||||||
|
|
||||||
def ToCAsciiArray(lines):
|
def ToCAsciiArray(lines):
|
||||||
result = []
|
result = []
|
||||||
@ -85,19 +85,17 @@ def embed(cxx, preprocessorOption, msgs, sources, c_out, js_out, env):
|
|||||||
processed = '\n'.join([line for line in preprocessed.splitlines() if \
|
processed = '\n'.join([line for line in preprocessed.splitlines() if \
|
||||||
(line.strip() and not line.startswith('#'))])
|
(line.strip() and not line.startswith('#'))])
|
||||||
|
|
||||||
with open(js_out, 'w') as output:
|
js_out.write(processed)
|
||||||
output.write(processed)
|
import zlib
|
||||||
with open(c_out, 'w') as output:
|
compressed = zlib.compress(processed)
|
||||||
import zlib
|
data = ToCArray(compressed)
|
||||||
compressed = zlib.compress(processed)
|
c_out.write(HEADER_TEMPLATE % {
|
||||||
data = ToCArray(compressed)
|
'sources_type': 'unsigned char',
|
||||||
output.write(HEADER_TEMPLATE % {
|
'sources_data': data,
|
||||||
'sources_type': 'unsigned char',
|
'sources_name': 'compressedSources',
|
||||||
'sources_data': data,
|
'compressed_total_length': len(compressed),
|
||||||
'sources_name': 'compressedSources',
|
'raw_total_length': len(processed)
|
||||||
'compressed_total_length': len(compressed),
|
})
|
||||||
'raw_total_length': len(processed)
|
|
||||||
})
|
|
||||||
|
|
||||||
def preprocess(cxx, preprocessorOption, source, args = []):
|
def preprocess(cxx, preprocessorOption, source, args = []):
|
||||||
if (not os.path.exists(cxx[0])):
|
if (not os.path.exists(cxx[0])):
|
||||||
@ -131,32 +129,27 @@ def messages(jsmsg):
|
|||||||
assert not line.strip().startswith("MSG_DEF")
|
assert not line.strip().startswith("MSG_DEF")
|
||||||
return '\n'.join(defines)
|
return '\n'.join(defines)
|
||||||
|
|
||||||
def main():
|
def get_config_defines(buildconfig):
|
||||||
env = {}
|
# Collect defines equivalent to ACDEFINES and add MOZ_DEBUG_DEFINES.
|
||||||
def define_env(option, opt, value, parser):
|
env = {key: value for key, value in buildconfig.defines.iteritems()
|
||||||
pair = value.split('=', 1)
|
if key not in buildconfig.non_global_defines}
|
||||||
|
for value in buildconfig.substs['MOZ_DEBUG_DEFINES'].split():
|
||||||
|
assert value[:2] == "-D"
|
||||||
|
pair = value[2:].split('=', 1)
|
||||||
if len(pair) == 1:
|
if len(pair) == 1:
|
||||||
pair.append(1)
|
pair.append(1)
|
||||||
env[pair[0]] = pair[1]
|
env[pair[0]] = pair[1]
|
||||||
p = OptionParser(usage="%prog [options] file")
|
return env
|
||||||
p.add_option('-D', action='callback', callback=define_env, type="string",
|
|
||||||
metavar='var=[val]', help='Define a variable')
|
|
||||||
p.add_option('-m', type='string', metavar='jsmsg', default='../js.msg',
|
|
||||||
help='js.msg file')
|
|
||||||
p.add_option('-c', type='string', metavar='cxx', help='Path to C++ compiler')
|
|
||||||
p.add_option('-p', type='string', dest='p', metavar='cxxoption',
|
|
||||||
help='Argument to compiler for preprocessing into an output file')
|
|
||||||
p.add_option('-o', type='string', metavar='filename', default='selfhosted.out.h',
|
|
||||||
help='C array header file')
|
|
||||||
p.add_option('-s', type='string', metavar='jsfilename', default='selfhosted.js',
|
|
||||||
help='Combined postprocessed JS file')
|
|
||||||
(options, sources) = p.parse_args()
|
|
||||||
if not (options.p and sources):
|
|
||||||
p.print_help()
|
|
||||||
sys.exit(1)
|
|
||||||
cxx = shlex.split(options.c)
|
|
||||||
msgs = messages(options.m)
|
|
||||||
embed(cxx, options.p, msgs, sources, options.o, options.s, env)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def generate_selfhosted(c_out, msg_file, *inputs):
|
||||||
main()
|
# Called from moz.build to embed selfhosted JS.
|
||||||
|
deps = [path for path in inputs if path.endswith(".h")]
|
||||||
|
sources = [path for path in inputs if path.endswith(".js")]
|
||||||
|
assert len(deps) + len(sources) == len(inputs)
|
||||||
|
cxx = shlex.split(buildconfig.substs['CXX'])
|
||||||
|
cxx_option = buildconfig.substs['PREPROCESS_OPTION']
|
||||||
|
env = get_config_defines(buildconfig)
|
||||||
|
js_path = re.sub(r"\.out\.h$", "", c_out.name) + ".js"
|
||||||
|
msgs = messages(msg_file)
|
||||||
|
with open(js_path, 'w') as js_out:
|
||||||
|
embed(cxx, cxx_option, msgs, sources, c_out, js_out, env)
|
||||||
|
@ -3810,6 +3810,17 @@ if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
|
|||||||
AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
|
AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dnl ========================================================
|
||||||
|
dnl Determine options to use for running the preprocessor.
|
||||||
|
dnl ========================================================
|
||||||
|
|
||||||
|
if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT"; then
|
||||||
|
PREPROCESS_OPTION="-P -Fi"
|
||||||
|
else
|
||||||
|
PREPROCESS_OPTION="-E -o "
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_SUBST(PREPROCESS_OPTION)
|
||||||
|
|
||||||
dnl ========================================================
|
dnl ========================================================
|
||||||
dnl ECMAScript Internationalization API Support (uses ICU)
|
dnl ECMAScript Internationalization API Support (uses ICU)
|
||||||
|
@ -669,3 +669,32 @@ if not CONFIG['GNU_CXX']:
|
|||||||
NO_EXPAND_LIBS = True
|
NO_EXPAND_LIBS = True
|
||||||
|
|
||||||
DIST_INSTALL = True
|
DIST_INSTALL = True
|
||||||
|
|
||||||
|
# Prepare self-hosted JS code for embedding
|
||||||
|
GENERATED_FILES += ['selfhosted.out.h']
|
||||||
|
selfhosted = GENERATED_FILES['selfhosted.out.h']
|
||||||
|
selfhosted.script = 'builtin/embedjs.py:generate_selfhosted'
|
||||||
|
selfhosted.inputs = [
|
||||||
|
'js.msg',
|
||||||
|
'builtin/TypedObjectConstants.h',
|
||||||
|
'builtin/SelfHostingDefines.h',
|
||||||
|
'builtin/Utilities.js',
|
||||||
|
'builtin/Array.js',
|
||||||
|
'builtin/Date.js',
|
||||||
|
'builtin/Error.js',
|
||||||
|
'builtin/Generator.js',
|
||||||
|
'builtin/Intl.js',
|
||||||
|
'builtin/IntlData.js',
|
||||||
|
'builtin/Iterator.js',
|
||||||
|
'builtin/Map.js',
|
||||||
|
'builtin/Module.js',
|
||||||
|
'builtin/Number.js',
|
||||||
|
'builtin/Object.js',
|
||||||
|
'builtin/Reflect.js',
|
||||||
|
'builtin/RegExp.js',
|
||||||
|
'builtin/String.js',
|
||||||
|
'builtin/Set.js',
|
||||||
|
'builtin/TypedArray.js',
|
||||||
|
'builtin/TypedObject.js',
|
||||||
|
'builtin/WeakSet.js'
|
||||||
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user