Skip to content

Commit f95ec90

Browse files
committed
Use common build directory for ports and system libs. NFC
Split out from emscripten-core#23924
1 parent 340aa0f commit f95ec90

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

tools/ports/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def erase():
233233

234234
@staticmethod
235235
def get_build_dir():
236-
return cache.get_path('ports-builds')
236+
return system_libs.get_build_dir()
237237

238238
name_cache: Set[str] = set()
239239

tools/ports/sdl2_gfx.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ def needed(settings):
1616

1717

1818
def get(ports, settings, shared):
19-
sdl_build = os.path.join(ports.get_build_dir(), 'sdl2')
20-
assert os.path.exists(sdl_build), 'You must use SDL2 to use SDL2_gfx'
2119
ports.fetch_project('sdl2_gfx', f'https://github.com/svn2github/sdl2_gfx/archive/{TAG}.zip', sha512hash=HASH)
2220

2321
def create(final):
22+
sdl_build = os.path.join(ports.get_build_dir(), 'sdl2')
23+
assert os.path.exists(sdl_build), 'You must use SDL2 to use SDL2_gfx'
24+
2425
source_path = ports.get_dir('sdl2_gfx', 'sdl2_gfx-' + TAG)
2526
ports.build_port(source_path, final, 'sdl2_gfx', exclude_dirs=['test'], flags=['-sUSE_SDL=2'])
2627
ports.install_headers(source_path, target='SDL2')

tools/ports/sdl2_image.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ def get_lib_name(settings):
5252

5353

5454
def get(ports, settings, shared):
55-
sdl_build = os.path.join(ports.get_build_dir(), 'sdl2')
56-
assert os.path.exists(sdl_build), 'You must use SDL2 to use SDL2_image'
5755
ports.fetch_project('sdl2_image', f'https://github.com/libsdl-org/SDL_image/archive/refs/tags/{TAG}.zip', sha512hash=HASH)
5856
libname = get_lib_name(settings)
5957

6058
def create(final):
59+
sdl_build = os.path.join(ports.get_build_dir(), 'sdl2')
60+
assert os.path.exists(sdl_build), 'You must use SDL2 to use SDL2_image'
61+
6162
src_dir = ports.get_dir('sdl2_image', 'SDL_image-' + TAG)
6263
ports.install_headers(src_dir, target='SDL2')
6364
srcs = '''IMG.c IMG_bmp.c IMG_gif.c IMG_jpg.c IMG_lbm.c IMG_pcx.c IMG_png.c IMG_pnm.c IMG_tga.c

tools/ports/sdl2_mixer.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ def get_lib_name(settings):
3636

3737

3838
def get(ports, settings, shared):
39-
sdl_build = os.path.join(ports.get_build_dir(), 'sdl2')
40-
assert os.path.exists(sdl_build), 'You must use SDL2 to use SDL2_mixer'
4139
ports.fetch_project('sdl2_mixer', f'https://github.com/libsdl-org/SDL_mixer/archive/{TAG}.zip', sha512hash=HASH)
4240
libname = get_lib_name(settings)
4341

4442
def create(final):
43+
sdl_build = os.path.join(ports.get_build_dir(), 'sdl2')
44+
assert os.path.exists(sdl_build), 'You must use SDL2 to use SDL2_mixer'
45+
4546
source_path = ports.get_dir('sdl2_mixer', 'SDL_mixer-' + TAG)
4647
flags = [
4748
'-sUSE_SDL=2',

tools/ports/sdl2_net.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ def needed(settings):
1616

1717

1818
def get(ports, settings, shared):
19-
sdl_build = os.path.join(ports.get_build_dir(), 'sdl2')
20-
assert os.path.exists(sdl_build), 'You must use SDL2 to use SDL2_net'
2119
ports.fetch_project('sdl2_net', f'https://github.com/emscripten-ports/SDL2_net/archive/{TAG}.zip', sha512hash=HASH)
2220

2321
def create(final):
22+
sdl_build = os.path.join(ports.get_build_dir(), 'sdl2')
23+
assert os.path.exists(sdl_build), 'You must use SDL2 to use SDL2_net'
24+
2425
src_dir = ports.get_dir('sdl2_net', 'SDL2_net-' + TAG)
2526
ports.install_headers(src_dir, target='SDL2')
2627
excludes = ['chatd.c', 'chat.cpp', 'showinterfaces.c']

tools/system_libs.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ def get_base_cflags(build_dir, force_object_files=False, preprocess=True):
7979
return flags
8080

8181

82+
def get_build_dir():
83+
return cache.get_path('build')
84+
85+
8286
def clean_env():
8387
# building system libraries and ports should be hermetic in that it is not
8488
# affected by things like EMCC_CFLAGS which the user may have set.
@@ -150,7 +154,7 @@ def create_lib(libname, inputs):
150154

151155

152156
def get_top_level_ninja_file():
153-
return os.path.join(cache.get_path('build'), 'build.ninja')
157+
return os.path.join(get_build_dir(), 'build.ninja')
154158

155159

156160
def run_ninja(build_dir):
@@ -552,7 +556,7 @@ def customize_build_cmd(self, cmd, _filename):
552556
def do_build(self, out_filename, generate_only=False):
553557
"""Builds the library and returns the path to the file."""
554558
assert out_filename == self.get_path(absolute=True)
555-
build_dir = os.path.join(cache.get_path('build'), self.get_base_name())
559+
build_dir = os.path.join(get_build_dir(), self.get_base_name())
556560
if USE_NINJA:
557561
self.generate_ninja(build_dir, out_filename)
558562
if not generate_only:

0 commit comments

Comments
 (0)