Skip to content

Commit 114ba7d

Browse files
committed
Use common include directory for all ports
We already use a common "lib" directory to install al the libs. This change simply installs headers in the same common "sysroot". This makes the ports install more like normall "make install" scripts would. The only port I didn't include here was cocos2d because it seemed a little overwhelming.
1 parent 89d369b commit 114ba7d

File tree

19 files changed

+138
-59
lines changed

19 files changed

+138
-59
lines changed

embuilder.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
from tools import shared
1919
from tools.system_libs import Library
2020

21-
C_BARE = '''
22-
int main() {}
23-
'''
21+
C_BARE = 'int main() {}'
2422

2523
SYSTEM_LIBRARIES = Library.get_all_variations()
2624
SYSTEM_TASKS = list(SYSTEM_LIBRARIES.keys())
@@ -125,8 +123,8 @@ def build(src, result_libs, args=[]):
125123
shared.exit_with_error('not seeing that requested library %s has been built because file %s does not exist' % (lib, shared.Cache.get_path(lib)))
126124

127125

128-
def build_port(port_name, lib_name, params):
129-
build(C_BARE, [lib_name] if lib_name else [], params)
126+
def build_port(port_name, lib_name, params, extra_source=''):
127+
build(extra_source + '\n' + C_BARE, [lib_name] if lib_name else [], params)
130128

131129

132130
def main():
@@ -215,7 +213,7 @@ def main():
215213
elif what == 'native_optimizer':
216214
build(C_BARE, ['optimizer.2.exe'], ['-O2', '-s', 'WASM=0'])
217215
elif what == 'icu':
218-
build_port('icu', libname('libicuuc'), ['-s', 'USE_ICU=1'])
216+
build_port('icu', libname('libicuuc'), ['-s', 'USE_ICU=1'], '#include "unicode/ustring.h"')
219217
elif what == 'zlib':
220218
build_port('zlib', 'libz.a', ['-s', 'USE_ZLIB=1'])
221219
elif what == 'bzip2':

tools/ports/boost_headers.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,25 @@ def create():
2525

2626
# includes
2727
source_path_include = os.path.join(ports.get_dir(), 'boost_headers', 'boost')
28-
dest_path_include = os.path.join(ports.get_build_dir(), 'boost_headers', 'boost')
28+
dest_path_include = os.path.join(ports.get_include_dir(), 'boost')
29+
shared.try_delete(dest_path_include)
2930
shutil.copytree(source_path_include, dest_path_include)
3031

3132
# write out a dummy cpp file, to create an empty library
3233
# this is needed as emscripted ports expect this, even if it is not used
33-
open(os.path.join(ports.get_build_dir(), 'boost_headers', 'dummy.cpp'), 'w').write('static void dummy() {}')
34+
dummy_file = os.path.join(ports.get_build_dir(), 'boost_headers', 'dummy.cpp')
35+
shared.safe_ensure_dirs(os.path.dirname(dummy_file))
36+
with open(dummy_file, 'w') as f:
37+
f.write('static void dummy() {}')
3438

3539
commands = []
3640
o_s = []
37-
o = os.path.join(ports.get_build_dir(), 'boost_headers', 'dummy.cpp.o')
38-
command = [shared.PYTHON, shared.EMCC, '-c', os.path.join(ports.get_build_dir(), 'boost_headers', 'dummy.cpp'), '-o', o]
41+
obj = dummy_file + '.o'
42+
command = [shared.PYTHON, shared.EMCC, '-c', dummy_file, '-o', obj]
3943
commands.append(command)
4044
ports.run_commands(commands)
4145
final = os.path.join(ports.get_build_dir(), 'boost_headers', libname)
42-
o_s.append(o)
46+
o_s.append(obj)
4347
ports.create_lib(final, o_s)
4448
return final
4549

@@ -53,7 +57,7 @@ def clear(ports, shared):
5357
def process_args(ports, args, settings, shared):
5458
if settings.USE_BOOST_HEADERS == 1:
5559
get(ports, settings, shared)
56-
args += ['-Xclang', '-isystem' + os.path.join(ports.get_build_dir(), 'boost_headers'), '-DBOOST_ALL_NO_LIB']
60+
args += ['-DBOOST_ALL_NO_LIB']
5761
return args
5862

5963

tools/ports/bullet.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,20 @@ def create():
2626

2727
shutil.rmtree(dest_path, ignore_errors=True)
2828
shutil.copytree(source_path, dest_path)
29-
3029
src_path = os.path.join(dest_path, 'bullet', 'src')
30+
src_path = os.path.join(dest_path, 'bullet', 'src')
31+
32+
dest_include_path = os.path.join(ports.get_include_dir(), 'bullet')
33+
for base, dirs, files in os.walk(src_path):
34+
for f in files:
35+
if os.path.splitext(f)[1] != '.h':
36+
continue
37+
fullpath = os.path.join(base, f)
38+
relpath = os.path.relpath(fullpath, src_path)
39+
target = os.path.join(dest_include_path, relpath)
40+
shared.safe_ensure_dirs(os.path.dirname(target))
41+
shutil.copyfile(fullpath, target)
42+
3143
includes = []
3244
for root, dirs, files in os.walk(src_path, topdown=False):
3345
for dir in dirs:
@@ -47,7 +59,7 @@ def clear(ports, shared):
4759
def process_args(ports, args, settings, shared):
4860
if settings.USE_BULLET == 1:
4961
get(ports, settings, shared)
50-
args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'bullet', 'bullet', 'src')]
62+
args += ['-I' + os.path.join(ports.get_include_dir(), 'bullet')]
5163
return args
5264

5365

tools/ports/bzip2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def create():
4343

4444
final = os.path.join(ports.get_build_dir(), 'bzip2', 'libbz2.a')
4545
ports.create_lib(final, o_s)
46+
ports.install_headers(source_path)
4647
return final
4748

4849
return [shared.Cache.get('libbz2.a', create, what='port')]
@@ -55,7 +56,6 @@ def clear(ports, shared):
5556
def process_args(ports, args, settings, shared):
5657
if settings.USE_BZIP2 == 1:
5758
get(ports, settings, shared)
58-
args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'bzip2')]
5959
return args
6060

6161

tools/ports/freetype.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ def create():
103103
ports.run_commands(commands)
104104
final = os.path.join(ports.get_build_dir(), 'freetype', 'libfreetype.a')
105105
shared.try_delete(final)
106-
Popen([shared.LLVM_AR, 'rc', final] + o_s).communicate()
107-
assert os.path.exists(final)
106+
shared.run_process([shared.LLVM_AR, 'rc', final] + o_s)
107+
108+
ports.install_header_dir(os.path.join(dest_path, 'include'),
109+
target=os.path.join('freetype2', 'freetype'))
108110
return final
109111

110112
return [shared.Cache.get('libfreetype.a', create, what='port')]
@@ -117,7 +119,8 @@ def clear(ports, shared):
117119
def process_args(ports, args, settings, shared):
118120
if settings.USE_FREETYPE == 1:
119121
get(ports, settings, shared)
120-
args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'freetype/include')]
122+
args += ['-I' + os.path.join(ports.get_include_dir(), 'freetype2', 'freetype')]
123+
121124
return args
122125

123126

tools/ports/harfbuzz.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ def create():
2424
source_path = os.path.join(ports.get_dir(), 'harfbuzz', 'harfbuzz-' + TAG)
2525
dest_path = os.path.join(ports.get_build_dir(), 'harfbuzz')
2626

27-
freetype_dir = os.path.join(ports.get_build_dir(), 'freetype')
28-
freetype_lib = os.path.join(freetype_dir, 'libfreetype.a')
29-
freetype_include = os.path.join(freetype_dir, 'include')
27+
freetype_lib = shared.Cache.get_path('libfreetype.a')
28+
freetype_include = os.path.join(ports.get_include_dir(), 'freetype2', 'freetype')
3029
freetype_include_dirs = freetype_include + ';' + os.path.join(freetype_include, 'config')
3130

3231
configure_args = [
@@ -45,6 +44,9 @@ def create():
4544

4645
shared.Building.configure(configure_args)
4746
shared.Building.make(['make', '-j%d' % shared.Building.get_num_cores(), '-C' + dest_path, 'install'])
47+
48+
ports.install_header_dir(os.path.join(dest_path, 'include', 'harfbuzz'))
49+
4850
return os.path.join(dest_path, 'libharfbuzz.a')
4951

5052
return [shared.Cache.get('libharfbuzz' + ('-mt' if settings.USE_PTHREADS else '') + '.a', create, what='port')]
@@ -62,7 +64,7 @@ def process_dependencies(settings):
6264
def process_args(ports, args, settings, shared):
6365
if settings.USE_HARFBUZZ == 1:
6466
get(ports, settings, shared)
65-
args += ['-Xclang', '-isystem' + os.path.join(ports.get_build_dir(), 'harfbuzz', 'include', 'harfbuzz')]
67+
args += ['-I' + os.path.join(ports.get_build_dir(), 'harfbuzz', 'include', 'harfbuzz')]
6668
return args
6769

6870

tools/ports/icu.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def create():
2929

3030
final = os.path.join(dest_path, libname)
3131
ports.build_port(os.path.join(dest_path, 'icu4c', 'source', 'common'), final, [os.path.join(dest_path, 'icu4c', 'source', 'common')], ['--std=c++11', '-DU_COMMON_IMPLEMENTATION=1'])
32+
33+
ports.install_header_dir(os.path.join(dest_path, 'icu4c', 'source', 'common', 'unicode'))
3234
return final
3335

3436
return [shared.Cache.get(libname, create)]
@@ -41,7 +43,6 @@ def clear(ports, shared):
4143
def process_args(ports, args, settings, shared):
4244
if settings.USE_ICU == 1:
4345
get(ports, settings, shared)
44-
args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'icu', 'icu4c', 'source', 'common')]
4546
return args
4647

4748

tools/ports/libjpeg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def create():
2929
shutil.copytree(source_path, dest_path)
3030

3131
open(os.path.join(dest_path, 'jconfig.h'), 'w').write(jconfig_h)
32+
ports.install_headers(dest_path)
3233

3334
final = os.path.join(ports.get_build_dir(), 'libjpeg', libname)
3435
ports.build_port(
@@ -51,7 +52,6 @@ def clear(ports, shared):
5152
def process_args(ports, args, settings, shared):
5253
if settings.USE_LIBJPEG == 1:
5354
get(ports, settings, shared)
54-
args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'libjpeg')]
5555
return args
5656

5757

tools/ports/libpng.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def create():
2929
shutil.copytree(source_path, dest_path)
3030

3131
open(os.path.join(dest_path, 'pnglibconf.h'), 'w').write(pnglibconf_h)
32+
ports.install_headers(dest_path)
3233

3334
final = os.path.join(ports.get_build_dir(), 'libpng', libname)
3435
ports.build_port(dest_path, final, flags=['-s', 'USE_ZLIB=1'], exclude_files=['pngtest'], exclude_dirs=['scripts', 'contrib'])
@@ -49,7 +50,6 @@ def process_dependencies(settings):
4950
def process_args(ports, args, settings, shared):
5051
if settings.USE_LIBPNG == 1:
5152
get(ports, settings, shared)
52-
args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'libpng')]
5353
return args
5454

5555

tools/ports/ogg.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ def create():
3030

3131
open(os.path.join(dest_path, 'include', 'ogg', 'config_types.h'), 'w').write(config_types_h)
3232

33+
header_dir = os.path.join(ports.get_include_dir(), 'ogg')
34+
shutil.rmtree(header_dir, ignore_errors=True)
35+
shutil.copytree(os.path.join(dest_path, 'include', 'ogg'), header_dir)
36+
3337
final = os.path.join(dest_path, libname)
34-
ports.build_port(os.path.join(dest_path, 'src'), final, [os.path.join(dest_path, 'include')])
38+
ports.build_port(os.path.join(dest_path, 'src'), final)
3539
return final
3640

3741
return [shared.Cache.get(libname, create)]
@@ -44,7 +48,6 @@ def clear(ports, shared):
4448
def process_args(ports, args, settings, shared):
4549
if settings.USE_OGG == 1:
4650
get(ports, settings, shared)
47-
args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'ogg', 'include')]
4851
return args
4952

5053

0 commit comments

Comments
 (0)