зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1635229 - output relative paths in XPIDL-generated source files; r=asuth,glandium,mccr8
We currently generate absolute paths in all of our XPIDL-generated source files, which is not so great for several reasons (deterministic generation of files across machines, Searchfox analysis logic, shared compilation caches, etc.). Let's generate paths that still indicate where you should be looking, but are identical across compilations, objdirs, etc. Differential Revision: https://phabricator.services.mozilla.com/D73747
This commit is contained in:
Родитель
df9c735cbe
Коммит
c2d1969d66
|
@ -22,6 +22,7 @@ from xpidl.rust_macros import print_rust_macros_bindings
|
|||
from xpidl.xpidl import IDLParser
|
||||
|
||||
from mozbuild.makeutil import Makefile
|
||||
from mozpack import path as mozpath
|
||||
from mozbuild.pythonutil import iter_modules_in_path
|
||||
from mozbuild.util import FileAvoidWrite
|
||||
|
||||
|
@ -59,14 +60,24 @@ def process(input_dirs, inc_paths, bindings_conf, cache_dir, header_dir,
|
|||
|
||||
rule.add_dependencies(six.ensure_text(s) for s in idl.deps)
|
||||
|
||||
# The print_* functions don't actually do anything with the
|
||||
# passed-in path other than writing it into the file to let people
|
||||
# know where the original source was. This script receives
|
||||
# absolute paths, which are not so great to embed in header files
|
||||
# (they mess with deterministic generation of files on different
|
||||
# machines, Searchfox logic, shared compilation caches, etc.), so
|
||||
# we pass in fake paths that are the same across compilations, but
|
||||
# should still enable people to figure out where to go.
|
||||
relpath = mozpath.relpath(path, topsrcdir)
|
||||
|
||||
with FileAvoidWrite(header_path) as fh:
|
||||
print_header(idl, fh, path)
|
||||
print_header(idl, fh, path, relpath)
|
||||
|
||||
with FileAvoidWrite(rs_rt_path) as fh:
|
||||
print_rust_bindings(idl, fh, path)
|
||||
print_rust_bindings(idl, fh, relpath)
|
||||
|
||||
with FileAvoidWrite(rs_bt_path) as fh:
|
||||
print_rust_macros_bindings(idl, fh, path)
|
||||
print_rust_macros_bindings(idl, fh, relpath)
|
||||
|
||||
# NOTE: We don't use FileAvoidWrite here as we may re-run this code due to a
|
||||
# number of different changes in the code, which may not cause the .xpt
|
||||
|
|
|
@ -209,7 +209,7 @@ def paramlistNames(m):
|
|||
|
||||
|
||||
header = """/*
|
||||
* DO NOT EDIT. THIS FILE IS GENERATED FROM %(filename)s
|
||||
* DO NOT EDIT. THIS FILE IS GENERATED FROM $SRCDIR/%(relpath)s
|
||||
*/
|
||||
|
||||
#ifndef __gen_%(basename)s_h__
|
||||
|
@ -256,8 +256,8 @@ def idl_basename(f):
|
|||
return os.path.basename(f).rpartition('.')[0]
|
||||
|
||||
|
||||
def print_header(idl, fd, filename):
|
||||
fd.write(header % {'filename': filename,
|
||||
def print_header(idl, fd, filename, relpath):
|
||||
fd.write(header % {'relpath': relpath,
|
||||
'basename': idl_basename(filename)})
|
||||
|
||||
foundinc = False
|
||||
|
|
|
@ -284,7 +284,7 @@ def attrAsWrapper(iface, m, getter):
|
|||
|
||||
header = """\
|
||||
//
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED FROM %(filename)s
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED FROM $SRCDIR/%(relpath)s
|
||||
//
|
||||
|
||||
"""
|
||||
|
@ -295,10 +295,10 @@ def idl_basename(f):
|
|||
return os.path.splitext(os.path.basename(f))[0]
|
||||
|
||||
|
||||
def print_rust_bindings(idl, fd, filename):
|
||||
def print_rust_bindings(idl, fd, relpath):
|
||||
fd = AutoIndent(fd)
|
||||
|
||||
fd.write(header % {'filename': filename})
|
||||
fd.write(header % {'relpath': relpath})
|
||||
|
||||
# All of the idl files will be included into the same rust module, as we
|
||||
# can't do forward declarations. Because of this, we want to ignore all
|
||||
|
|
|
@ -84,16 +84,16 @@ def write_interface(iface, fd):
|
|||
|
||||
header = """\
|
||||
//
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED FROM %(filename)s
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED FROM $SRCDIR/%(relpath)s
|
||||
//
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def print_rust_macros_bindings(idl, fd, filename):
|
||||
def print_rust_macros_bindings(idl, fd, relpath):
|
||||
fd = rust.AutoIndent(fd)
|
||||
|
||||
fd.write(header % {'filename': filename})
|
||||
fd.write(header % {'relpath': relpath})
|
||||
fd.write("{static D: &'static [Interface] = &[\n")
|
||||
|
||||
for p in idl.productions:
|
||||
|
|
Загрузка…
Ссылка в новой задаче