mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 904743 - Use makefile creation helper in BindingGen.py, cl.py and xpidl-process.py. r=gps
While at it, fix dependencies generated by BindingGen.py
This commit is contained in:
parent
562cc4815f
commit
069b5d8848
14
build/cl.py
14
build/cl.py
@ -6,6 +6,7 @@ import ctypes
|
||||
import os, os.path
|
||||
import subprocess
|
||||
import sys
|
||||
from mozbuild.makeutil import Makefile
|
||||
|
||||
CL_INCLUDES_PREFIX = os.environ.get("CL_INCLUDES_PREFIX", "Note: including file:")
|
||||
|
||||
@ -63,7 +64,9 @@ def InvokeClWithDependencyGeneration(cmdline):
|
||||
cmdline += ['-showIncludes']
|
||||
cl = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
|
||||
|
||||
deps = set([normcase(source).replace(os.sep, '/')])
|
||||
mk = Makefile()
|
||||
rule = mk.create_rule(target)
|
||||
rule.add_dependencies([normcase(source)])
|
||||
for line in cl.stdout:
|
||||
# cl -showIncludes prefixes every header with "Note: including file:"
|
||||
# and an indentation corresponding to the depth (which we don't need)
|
||||
@ -73,7 +76,7 @@ def InvokeClWithDependencyGeneration(cmdline):
|
||||
# we can assume that anything in a path with spaces is a system
|
||||
# header and throw it away.
|
||||
if ' ' not in dep:
|
||||
deps.add(normcase(dep).replace(os.sep, '/'))
|
||||
rule.add_dependencies([normcase(dep)])
|
||||
else:
|
||||
sys.stdout.write(line) # Make sure we preserve the relevant output
|
||||
# from cl
|
||||
@ -93,12 +96,7 @@ def InvokeClWithDependencyGeneration(cmdline):
|
||||
# die on the next line though, so it's not that much of a loss.
|
||||
|
||||
with open(depstarget, "w") as f:
|
||||
f.write("%s: %s" % (target, source))
|
||||
for dep in sorted(deps):
|
||||
f.write(" \\\n%s" % dep)
|
||||
f.write('\n')
|
||||
for dep in sorted(deps):
|
||||
f.write("%s:\n" % dep)
|
||||
mk.dump(f)
|
||||
|
||||
if __name__ == "__main__":
|
||||
InvokeClWithDependencyGeneration(sys.argv[1:])
|
||||
|
@ -6,6 +6,10 @@ import os
|
||||
import cPickle
|
||||
from Configuration import Configuration
|
||||
from Codegen import CGBindingRoot, replaceFileIfChanged
|
||||
from mozbuild.makeutil import Makefile
|
||||
from mozbuild.pythonutil import iter_modules_in_path
|
||||
from buildconfig import topsrcdir
|
||||
|
||||
|
||||
def generate_binding_files(config, outputprefix, srcprefix, webidlfile):
|
||||
"""
|
||||
@ -18,10 +22,12 @@ def generate_binding_files(config, outputprefix, srcprefix, webidlfile):
|
||||
replaceFileIfChanged(outputprefix + ".h", root.declare())
|
||||
replaceFileIfChanged(outputprefix + ".cpp", root.define())
|
||||
|
||||
with open(depsname, 'wb') as f:
|
||||
# Sort so that our output is stable
|
||||
f.write("\n".join(outputprefix + ": " + os.path.join(srcprefix, x) for
|
||||
x in sorted(root.deps())))
|
||||
mk = Makefile()
|
||||
rule = mk.create_rule([outputprefix + '.h', outputprefix + '.cpp'])
|
||||
rule.add_dependencies(os.path.join(srcprefix, x) for x in root.deps())
|
||||
rule.add_dependencies(iter_modules_in_path(topsrcdir))
|
||||
with open(depsname, 'w') as f:
|
||||
mk.dump(f)
|
||||
|
||||
def main():
|
||||
# Parse arguments.
|
||||
|
@ -6,6 +6,7 @@ import ctypes
|
||||
import os, os.path
|
||||
import subprocess
|
||||
import sys
|
||||
from mozbuild.makeutil import Makefile
|
||||
|
||||
CL_INCLUDES_PREFIX = os.environ.get("CL_INCLUDES_PREFIX", "Note: including file:")
|
||||
|
||||
@ -63,7 +64,9 @@ def InvokeClWithDependencyGeneration(cmdline):
|
||||
cmdline += ['-showIncludes']
|
||||
cl = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
|
||||
|
||||
deps = set([normcase(source).replace(os.sep, '/')])
|
||||
mk = Makefile()
|
||||
rule = mk.create_rule(target)
|
||||
rule.add_dependencies([normcase(source)])
|
||||
for line in cl.stdout:
|
||||
# cl -showIncludes prefixes every header with "Note: including file:"
|
||||
# and an indentation corresponding to the depth (which we don't need)
|
||||
@ -73,7 +76,7 @@ def InvokeClWithDependencyGeneration(cmdline):
|
||||
# we can assume that anything in a path with spaces is a system
|
||||
# header and throw it away.
|
||||
if ' ' not in dep:
|
||||
deps.add(normcase(dep).replace(os.sep, '/'))
|
||||
rule.add_dependencies([normcase(dep)])
|
||||
else:
|
||||
sys.stdout.write(line) # Make sure we preserve the relevant output
|
||||
# from cl
|
||||
@ -93,12 +96,7 @@ def InvokeClWithDependencyGeneration(cmdline):
|
||||
# die on the next line though, so it's not that much of a loss.
|
||||
|
||||
with open(depstarget, "w") as f:
|
||||
f.write("%s: %s" % (target, source))
|
||||
for dep in sorted(deps):
|
||||
f.write(" \\\n%s" % dep)
|
||||
f.write('\n')
|
||||
for dep in sorted(deps):
|
||||
f.write("%s:\n" % dep)
|
||||
mk.dump(f)
|
||||
|
||||
if __name__ == "__main__":
|
||||
InvokeClWithDependencyGeneration(sys.argv[1:])
|
||||
|
@ -13,11 +13,14 @@ import sys
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
from buildconfig import topsrcdir
|
||||
from header import print_header
|
||||
from typelib import write_typelib
|
||||
from xpidl import IDLParser
|
||||
from xpt import xpt_link
|
||||
|
||||
from mozbuild.makeutil import Makefile
|
||||
from mozbuild.pythonutil import iter_modules_in_path
|
||||
from mozbuild.util import FileAvoidWrite
|
||||
|
||||
|
||||
@ -25,17 +28,12 @@ def process(input_dir, cache_dir, header_dir, xpt_dir, deps_dir, module, stems):
|
||||
p = IDLParser(outputdir=cache_dir)
|
||||
|
||||
xpts = {}
|
||||
deps = set()
|
||||
mk = Makefile()
|
||||
rule = mk.create_rule()
|
||||
|
||||
# Write out dependencies for Python modules we import. If this list isn't
|
||||
# up to date, we will not re-process XPIDL files if the processor changes.
|
||||
for imported in ('header', 'typelib', 'xpidl', 'xpt'):
|
||||
path = sys.modules[imported].__file__
|
||||
|
||||
if path.endswith('.pyc'):
|
||||
path = path[0:-1]
|
||||
|
||||
deps.add(path)
|
||||
rule.add_dependencies(iter_modules_in_path(topsrcdir))
|
||||
|
||||
for stem in stems:
|
||||
path = os.path.join(input_dir, '%s.idl' % stem)
|
||||
@ -52,7 +50,7 @@ def process(input_dir, cache_dir, header_dir, xpt_dir, deps_dir, module, stems):
|
||||
xpt.seek(0)
|
||||
xpts[stem] = xpt
|
||||
|
||||
deps |= set(dep.replace('\\', '/') for dep in idl.deps)
|
||||
rule.add_dependencies(idl.deps)
|
||||
|
||||
with FileAvoidWrite(header_path) as fh:
|
||||
print_header(idl, fh, path)
|
||||
@ -61,13 +59,10 @@ def process(input_dir, cache_dir, header_dir, xpt_dir, deps_dir, module, stems):
|
||||
xpt_path = os.path.join(xpt_dir, '%s.xpt' % module)
|
||||
xpt_link(xpts.values()).write(xpt_path)
|
||||
|
||||
rule.add_targets([xpt_path])
|
||||
deps_path = os.path.join(deps_dir, '%s.pp' % module)
|
||||
with FileAvoidWrite(deps_path) as fh:
|
||||
# Need output to be consistent to avoid rewrites.
|
||||
s_deps = sorted(deps)
|
||||
fh.write('%s: %s\n' % (xpt_path, ' '.join(s_deps)))
|
||||
for dep in s_deps:
|
||||
fh.write('%s:\n' % dep)
|
||||
mk.dump(fh)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user