Skip to content

Commit 615e689

Browse files
committed
Bug 1407432 - Move system wrapper generation to moz.build; r=froydnj
The make-system-wrappers.py invocation is largely identical to make-stl-wrappers.py, though this script generates wrappers for both the STL headers and every other system header that can be used. Note that the nsprpub script didn't create multiple layers of subdirectories properly, so for example the 'ia64/sys/inline.h' wrapper is now generated properly. Additionally, MOZ_SYSTEM_ICU define was incorrectly using '#ifdef' instead of '#if ... == 1', which causes those unicode headers to have wrappers when they shouldn't. These will show up as differences when comparing the Makefile output to the moz.build output. MozReview-Commit-ID: KvQAawfzXao --HG-- extra : source : 5a967cc85e28e63c283a81e2c76444a76dfbd266
1 parent 523accb commit 615e689

File tree

4 files changed

+1380
-23
lines changed

4 files changed

+1380
-23
lines changed

config/Makefile.in

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,6 @@ endif
3232

3333
include $(topsrcdir)/config/rules.mk
3434

35-
ifdef WRAP_SYSTEM_INCLUDES
36-
export-preqs = \
37-
$(call mkdir_deps,system_wrappers) \
38-
$(NULL)
39-
40-
export:: $(export-preqs)
41-
$(PYTHON) -m mozbuild.action.preprocessor $(DEFINES) $(ACDEFINES) \
42-
-DMOZ_TREE_CAIRO=$(MOZ_TREE_CAIRO) \
43-
-DMOZ_TREE_PIXMAN=$(MOZ_TREE_PIXMAN) \
44-
-DMOZ_SYSTEM_HUNSPELL=$(MOZ_SYSTEM_HUNSPELL) \
45-
-DMOZ_SYSTEM_BZ2=$(MOZ_SYSTEM_BZ2) \
46-
-DMOZ_SYSTEM_ZLIB=$(MOZ_SYSTEM_ZLIB) \
47-
-DMOZ_SYSTEM_PNG=$(MOZ_SYSTEM_PNG) \
48-
-DMOZ_SYSTEM_JPEG=$(MOZ_SYSTEM_JPEG) \
49-
-DMOZ_SYSTEM_LIBEVENT=$(MOZ_SYSTEM_LIBEVENT) \
50-
-DMOZ_SYSTEM_LIBVPX=$(MOZ_SYSTEM_LIBVPX) \
51-
-DMOZ_SYSTEM_ICU=$(MOZ_SYSTEM_ICU) \
52-
$(srcdir)/system-headers $(srcdir)/stl-headers | $(PERL) $(topsrcdir)/nsprpub/config/make-system-wrappers.pl system_wrappers
53-
$(INSTALL) system_wrappers $(DIST)
54-
55-
GARBAGE_DIRS += system_wrappers
56-
endif
57-
5835
GARBAGE += \
5936
$(FINAL_LINK_COMPS) $(FINAL_LINK_LIBS) $(FINAL_LINK_COMP_NAMES) $(srcdir)/*.pyc *.pyc
6037

config/make-system-wrappers.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
from __future__ import print_function
5+
import os
6+
import sys
7+
from mozbuild.util import FileAvoidWrite
8+
9+
header_template = '''#pragma GCC system_header
10+
#pragma GCC visibility push(default)
11+
#include_next <%(header)s>
12+
#pragma GCC visibility pop
13+
'''
14+
15+
16+
# The 'unused' arg is the output file from the file_generate action. We actually
17+
# generate all the files in header_list
18+
def gen_wrappers(unused, outdir, *header_list):
19+
for header in header_list:
20+
with FileAvoidWrite(os.path.join(outdir, header)) as f:
21+
f.write(header_template % {
22+
'header': header,
23+
})

config/moz.build

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,14 @@ if CONFIG['WRAP_STL_INCLUDES']:
6363
stl.script = 'make-stl-wrappers.py:gen_wrappers'
6464
stl.flags = [output_dir, stl_compiler, template_file]
6565
stl.flags.extend(stl_headers)
66+
67+
if CONFIG['WRAP_SYSTEM_INCLUDES']:
68+
include('system-headers.mozbuild')
69+
output_dir = '../dist/system_wrappers'
70+
outputs = tuple(['system-header.sentinel'] + ['%s/%s' % (output_dir, h) for h in stl_headers + system_headers])
71+
GENERATED_FILES += [outputs]
72+
system = GENERATED_FILES[outputs]
73+
system.script = 'make-system-wrappers.py:gen_wrappers'
74+
system.flags = [output_dir]
75+
system.flags.extend(stl_headers)
76+
system.flags.extend(system_headers)

0 commit comments

Comments
 (0)