Skip to content

Commit 1e3dae2

Browse files
authored
Simplify ports by having ports.get_dir take subdirectory arguments. NFC (#22451)
1 parent cea6b82 commit 1e3dae2

24 files changed

+26
-34
lines changed

tools/ports/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ def build_port(src_dir, output_path, port_name, includes=[], flags=[], cxxflags=
221221
return output_path
222222

223223
@staticmethod
224-
def get_dir():
225-
dirname = config.PORTS
224+
def get_dir(*parts):
225+
dirname = os.path.join(config.PORTS, *parts)
226226
shared.safe_ensure_dirs(dirname)
227227
return dirname
228228

@@ -240,7 +240,7 @@ def get_build_dir():
240240
@staticmethod
241241
def fetch_project(name, url, sha512hash=None):
242242
# To compute the sha512 hash, run `curl URL | sha512sum`.
243-
fullname = os.path.join(Ports.get_dir(), name)
243+
fullname = Ports.get_dir(name)
244244

245245
if name not in Ports.name_cache: # only mention each port once in log
246246
logger.debug(f'including port: {name}')

tools/ports/boost_headers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(ports, settings, shared):
2020

2121
def create(final):
2222
# includes
23-
source_path = os.path.join(ports.get_dir(), 'boost_headers')
23+
source_path = ports.get_dir('boost_headers')
2424
source_path_include = os.path.join(source_path, 'boost')
2525
ports.install_header_dir(source_path_include, 'boost')
2626

tools/ports/bullet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def get(ports, settings, shared):
1818
ports.fetch_project('bullet', f'https://github.com/emscripten-ports/bullet/archive/{TAG}.zip', sha512hash=HASH)
1919

2020
def create(final):
21-
source_path = os.path.join(ports.get_dir(), 'bullet', 'Bullet-' + TAG)
21+
source_path = ports.get_dir('bullet', 'Bullet-' + TAG)
2222
src_path = os.path.join(source_path, 'bullet', 'src')
2323

2424
dest_include_path = ports.get_include_dir('bullet')

tools/ports/bzip2.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# University of Illinois/NCSA Open Source License. Both these licenses can be
44
# found in the LICENSE file.
55

6-
import os
7-
86
VERSION = '1.0.6'
97
HASH = '512cbfde5144067f677496452f3335e9368fd5d7564899cb49e77847b9ae7dca598218276637cbf5ec524523be1e8ace4ad36a148ef7f4badf3f6d5a002a4bb2'
108

@@ -17,7 +15,7 @@ def get(ports, settings, shared):
1715
ports.fetch_project('bzip2', f'https://github.com/emscripten-ports/bzip2/archive/{VERSION}.zip', sha512hash=HASH)
1816

1917
def create(final):
20-
source_path = os.path.join(ports.get_dir(), 'bzip2', 'bzip2-' + VERSION)
18+
source_path = ports.get_dir('bzip2', 'bzip2-' + VERSION)
2119
ports.install_headers(source_path)
2220

2321
# build

tools/ports/cocos2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get(ports, settings, shared):
2323
def create(final):
2424
diagnostics.warning('experimental', 'cocos2d: library is experimental, do not expect that it will work out of the box')
2525

26-
cocos2d_src = os.path.join(ports.get_dir(), 'cocos2d')
26+
cocos2d_src = ports.get_dir('cocos2d')
2727
cocos2d_root = os.path.join(cocos2d_src, 'Cocos2d-' + TAG)
2828
cocos2dx_root = os.path.join(cocos2d_root, 'cocos2dx')
2929

tools/ports/freetype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get(ports, settings, shared):
2727
ports.fetch_project('freetype', f'https://github.com/emscripten-ports/FreeType/archive/{TAG}.zip', sha512hash=HASH)
2828

2929
def create(final):
30-
source_path = os.path.join(ports.get_dir(), 'freetype', 'FreeType-' + TAG)
30+
source_path = ports.get_dir('freetype', 'FreeType-' + TAG)
3131
ports.write_file(os.path.join(source_path, 'include/ftconfig.h'), ftconf_h)
3232
ports.install_header_dir(os.path.join(source_path, 'include'),
3333
target=os.path.join('freetype2'))

tools/ports/giflib.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# University of Illinois/NCSA Open Source License. Both these licenses can be
44
# found in the LICENSE file.
55

6-
import os
7-
86
VERSION = '5.2.1'
97
HASH = '4550e53c21cb1191a4581e363fc9d0610da53f7898ca8320f0d3ef6711e76bdda2609c2df15dc94c45e28bff8de441f1227ec2da7ea827cb3c0405af4faa4736'
108

@@ -17,7 +15,7 @@ def get(ports, settings, shared):
1715
ports.fetch_project('giflib', f'https://storage.googleapis.com/webassembly/emscripten-ports/giflib-{VERSION}.tar.gz', sha512hash=HASH)
1816

1917
def create(final):
20-
source_path = os.path.join(ports.get_dir(), 'giflib', f'giflib-{VERSION}')
18+
source_path = ports.get_dir('giflib', f'giflib-{VERSION}')
2119
ports.install_headers(source_path)
2220
exclude_files = [
2321
'giffix.c', 'gifecho.c', 'giffilter.c', 'gifcolor.c', 'gifecho.c', 'gifinto.c',

tools/ports/harfbuzz.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def get(ports, settings, shared):
8282
ports.fetch_project('harfbuzz', f'https://github.com/harfbuzz/harfbuzz/releases/download/{VERSION}/harfbuzz-{VERSION}.tar.xz', sha512hash=HASH)
8383

8484
def create(final):
85-
source_path = os.path.join(ports.get_dir(), 'harfbuzz', 'harfbuzz-' + VERSION)
85+
source_path = ports.get_dir('harfbuzz', 'harfbuzz-' + VERSION)
8686
freetype_include = ports.get_include_dir('freetype2')
8787
ports.install_headers(os.path.join(source_path, 'src'), target='harfbuzz')
8888

tools/ports/icu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get(ports, settings, shared):
3131

3232
def prepare_build():
3333
nonlocal icu_source_path
34-
source_path = os.path.join(ports.get_dir(), 'icu', 'icu') # downloaded icu4c path
34+
source_path = ports.get_dir('icu', 'icu') # downloaded icu4c path
3535
icu_source_path = os.path.join(source_path, 'source')
3636

3737
def build_lib(lib_output, lib_src, other_includes, build_flags):

tools/ports/libjpeg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(ports, settings, shared):
2020
ports.fetch_project('libjpeg', f'https://storage.googleapis.com/webassembly/emscripten-ports/jpegsrc.v{VERSION}.tar.gz', sha512hash=HASH)
2121

2222
def create(final):
23-
source_path = os.path.join(ports.get_dir(), 'libjpeg', f'jpeg-{VERSION}')
23+
source_path = ports.get_dir('libjpeg', f'jpeg-{VERSION}')
2424
ports.write_file(os.path.join(source_path, 'jconfig.h'), jconfig_h)
2525
ports.install_headers(source_path)
2626
excludes = [

0 commit comments

Comments
 (0)