Skip to content

Commit 61f61dd

Browse files
authored
Consistent use of build_dir name in ports. NFC (#17855)
This used to represent a location where the source was copied to but these days its just a build directory. I'm planning some followups to avoid cleaning out this directory more often than we need to.
1 parent f5a1916 commit 61f61dd

File tree

14 files changed

+31
-34
lines changed

14 files changed

+31
-34
lines changed

tools/ports/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,14 @@ def build_port(src_dir, output_path, build_dir, includes=[], flags=[], exclude_f
125125
for include in includes:
126126
cflags.append('-I' + include)
127127

128-
if build_dir:
129-
if not os.path.exists(build_dir):
130-
os.makedirs(build_dir)
131-
build_dir = src_dir
132128
commands = []
133129
objects = []
134130
for src in srcs:
135131
relpath = os.path.relpath(src, src_dir)
136132
obj = os.path.join(build_dir, relpath) + '.o'
133+
dirname = os.path.dirname(obj)
134+
if not os.path.exists(dirname):
135+
os.makedirs(dirname)
137136
commands.append([shared.EMCC, '-c', src, '-o', obj] + cflags)
138137
objects.append(obj)
139138

tools/ports/bullet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def create(final):
2222
logging.info('building port: bullet')
2323

2424
source_path = os.path.join(ports.get_dir(), 'bullet', 'Bullet-' + TAG)
25-
dest_path = ports.clear_project_build('bullet')
2625
src_path = os.path.join(source_path, 'bullet', 'src')
2726

2827
dest_include_path = ports.get_include_dir('bullet')
@@ -46,7 +45,8 @@ def create(final):
4645
'-std=gnu++14'
4746
]
4847

49-
ports.build_port(src_path, final, dest_path, includes=includes, flags=flags, exclude_dirs=['MiniCL'])
48+
build_dir = ports.clear_project_build('bullet')
49+
ports.build_port(src_path, final, build_dir, includes=includes, flags=flags, exclude_dirs=['MiniCL'])
5050

5151
return [shared.Cache.get_lib('libbullet.a', create)]
5252

tools/ports/bzip2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def create(final):
2525
'blocksort.c', 'compress.c', 'decompress.c', 'huffman.c',
2626
'randtable.c', 'bzlib.c', 'crctable.c',
2727
]
28-
dest_path = ports.clear_project_build('bzip2')
29-
ports.build_port(source_path, final, dest_path, srcs=srcs)
28+
build_dir = ports.clear_project_build('bzip2')
29+
ports.build_port(source_path, final, build_dir, srcs=srcs)
3030

3131
return [shared.Cache.get_lib('libbz2.a', create, what='port')]
3232

tools/ports/freetype.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def create(final):
9191
'-pthread'
9292
]
9393

94-
dest_path = ports.clear_project_build('freetype')
95-
ports.build_port(source_path, final, dest_path, flags=flags, srcs=srcs)
94+
build_dir = ports.clear_project_build('freetype')
95+
ports.build_port(source_path, final, build_dir, flags=flags, srcs=srcs)
9696

9797
return [shared.Cache.get_lib('libfreetype.a', create, what='port')]
9898

tools/ports/giflib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ def get(ports, settings, shared):
2020
def create(final):
2121
logging.info('building port: giflib')
2222
source_path = os.path.join(ports.get_dir(), 'giflib', f'giflib-{VERSION}')
23-
dest_path = ports.clear_project_build('giflib')
2423
ports.install_headers(source_path)
25-
ports.build_port(source_path, final, dest_path)
24+
build_dir = ports.clear_project_build('giflib')
25+
ports.build_port(source_path, final, build_dir)
2626

2727
return [shared.Cache.get_lib('libgif.a', create, what='port')]
2828

tools/ports/icu.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def get(ports, settings, shared):
2929
url = 'https://github.com/unicode-org/icu/releases/download/%s/icu4c-%s-src.zip' % (TAG, VERSION)
3030
ports.fetch_project('icu', url, 'icu', sha512hash=HASH)
3131
icu_source_path = None
32-
dest_path = None
32+
build_dir = None
3333

3434
def prepare_build():
35-
nonlocal icu_source_path, dest_path
35+
nonlocal icu_source_path, build_dir
3636
source_path = os.path.join(ports.get_dir(), 'icu', 'icu') # downloaded icu4c path
37-
dest_path = ports.clear_project_build('icu') # icu build path
37+
build_dir = ports.clear_project_build('icu') # icu build path
3838
icu_source_path = os.path.join(source_path, 'source')
3939

4040
def build_lib(lib_output, lib_src, other_includes, build_flags):
@@ -59,7 +59,7 @@ def build_lib(lib_output, lib_src, other_includes, build_flags):
5959
if settings.USE_PTHREADS:
6060
additional_build_flags.append('-pthread')
6161

62-
ports.build_port(lib_src, lib_output, dest_path, includes=other_includes, flags=build_flags + additional_build_flags)
62+
ports.build_port(lib_src, lib_output, build_dir, includes=other_includes, flags=build_flags + additional_build_flags)
6363

6464
# creator for libicu_common
6565
def create_libicu_common(lib_output):

tools/ports/libjpeg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ def get(ports, settings, shared):
2424
def create(final):
2525
logging.info('building port: libjpeg')
2626
source_path = os.path.join(ports.get_dir(), 'libjpeg', 'jpeg-9c')
27-
dest_path = ports.clear_project_build('libjpeg')
2827
Path(source_path, 'jconfig.h').write_text(jconfig_h)
2928
ports.install_headers(source_path)
3029
excludes = [
3130
'ansi2knr.c', 'cjpeg.c', 'ckconfig.c', 'djpeg.c', 'example.c',
3231
'jmemansi.c', 'jmemdos.c', 'jmemmac.c', 'jmemname.c',
3332
'jpegtran.c', 'rdjpgcom.c', 'wrjpgcom.c',
3433
]
35-
ports.build_port(source_path, final, dest_path, exclude_files=excludes)
34+
build_dir = ports.clear_project_build('libjpeg')
35+
ports.build_port(source_path, final, build_dir, exclude_files=excludes)
3636

3737
return [shared.Cache.get_lib('libjpeg.a', create, what='port')]
3838

tools/ports/mpg123.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ def create(final):
7575
os.path.join(compat_path, 'compat_str.c'),
7676
]
7777

78-
dest_path = ports.clear_project_build('mpg123')
79-
ports.build_port(source_path, final, dest_path, flags=flags, srcs=srcs)
78+
build_dir = ports.clear_project_build('mpg123')
79+
ports.build_port(source_path, final, build_dir, flags=flags, srcs=srcs)
8080

8181
return [shared.Cache.get_lib('libmpg123.a', create, what='port')]
8282

tools/ports/ogg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def create(final):
2424
source_path = os.path.join(ports.get_dir(), 'ogg', 'Ogg-' + TAG)
2525
Path(source_path, 'include', 'ogg', 'config_types.h').write_text(config_types_h)
2626
ports.install_header_dir(os.path.join(source_path, 'include', 'ogg'), 'ogg')
27-
dest_path = ports.clear_project_build('ogg')
28-
ports.build_port(os.path.join(source_path, 'src'), final, dest_path)
27+
build_dir = ports.clear_project_build('ogg')
28+
ports.build_port(os.path.join(source_path, 'src'), final, build_dir)
2929

3030
return [shared.Cache.get_lib('libogg.a', create)]
3131

tools/ports/sdl2_gfx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def get(ports, settings, shared):
2424
def create(final):
2525
logging.info('building port: sdl2_gfx')
2626
source_path = os.path.join(ports.get_dir(), 'sdl2_gfx', 'sdl2_gfx-' + TAG)
27-
dest_path = ports.clear_project_build('sdl2_gfx')
28-
ports.build_port(source_path, final, dest_path, includes=[dest_path], exclude_dirs=['test'], flags=['-sUSE_SDL=2'])
27+
build_dir = ports.clear_project_build('sdl2_gfx')
28+
ports.build_port(source_path, final, build_dir, exclude_dirs=['test'], flags=['-sUSE_SDL=2'])
2929
ports.install_headers(source_path, target='SDL2')
3030

3131
return [shared.Cache.get_lib('libSDL2_gfx.a', create)]

0 commit comments

Comments
 (0)