Skip to content

Commit 7c52107

Browse files
authored
Fix racy behaviour in Ports.install_header_dir. NFC (#22225)
This change reduces to usage of install_header_dir to just the ports that need it, and updates it to use `maybe_copy` which avoids touching files that are already up-to-date. Fixes: #22224
1 parent 3905550 commit 7c52107

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

tools/ports/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ def get_include_dir(*parts):
153153

154154
@staticmethod
155155
def install_header_dir(src_dir, target=None):
156+
"""Like install_headers but recusively copied all files in a directory"""
156157
if not target:
157158
target = os.path.basename(src_dir)
158159
dest = Ports.get_include_dir(target)
159-
utils.delete_dir(dest)
160160
logger.debug(f'installing headers: {dest}')
161-
shutil.copytree(src_dir, dest)
161+
shutil.copytree(src_dir, dest, dirs_exist_ok=True, copy_function=maybe_copy)
162162

163163
@staticmethod
164164
def install_headers(src_dir, pattern='*.h', target=None):

tools/ports/ogg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def get(ports, settings, shared):
1919
def create(final):
2020
source_path = os.path.join(ports.get_dir(), 'ogg', 'Ogg-' + TAG)
2121
ports.write_file(os.path.join(source_path, 'include', 'ogg', 'config_types.h'), config_types_h)
22-
ports.install_header_dir(os.path.join(source_path, 'include', 'ogg'), 'ogg')
22+
ports.install_headers(os.path.join(source_path, 'include', 'ogg'), target='ogg')
2323
ports.build_port(os.path.join(source_path, 'src'), final, 'ogg')
2424

2525
return [shared.cache.get_lib('libogg.a', create)]

tools/ports/vorbis.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
source_path = os.path.join(ports.get_dir(), 'vorbis', 'Vorbis-' + TAG)
23-
ports.install_header_dir(os.path.join(source_path, 'include', 'vorbis'))
23+
ports.install_headers(os.path.join(source_path, 'include', 'vorbis'), target='vorbis')
2424
ports.build_port(os.path.join(source_path, 'lib'), final, 'vorbis',
2525
flags=['-sUSE_OGG'],
2626
exclude_files=['psytune', 'barkmel', 'tone', 'misc'])

0 commit comments

Comments
 (0)