Skip to content

Commit a61af54

Browse files
committed
[build] Ignore .git in ninja copy
As part of the build the entire ninja source dir is copied to the build dir and then built. When using git's fsmonitor feature the .git directory contains a socket which causes the copytree to fail. With this change .git is ignored entirely instead. Error: ``` Traceback (most recent call last): ... File "/Users/ksmiley/dev/oss-swift/swift/utils/swift_build_support/swift_build_support/build_script_invocation.py", line 69, in build_ninja ninja_build.build() File "/Users/ksmiley/dev/oss-swift/swift/utils/swift_build_support/swift_build_support/products/ninja.py", line 80, in build shell.copytree(self.source_dir, self.build_dir) File "/Users/ksmiley/dev/oss-swift/swift/utils/swift_build_support/swift_build_support/shell.py", line 193, in copytree shutil.copytree(src, dest) File "/Users/ksmiley/.pyenv/versions/3.10.2/lib/python3.10/shutil.py", line 556, in copytree return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks, File "/Users/ksmiley/.pyenv/versions/3.10.2/lib/python3.10/shutil.py", line 512, in _copytree raise Error(errors) shutil.Error: [('/Users/ksmiley/dev/oss-swift/ninja/.git/fsmonitor--daemon.ipc', '/Users/ksmiley/dev/oss-swift/build/buildbot_osx/ninja-build/.git/fsmonitor--daemon.ipc', "[Errno 102] Operation not supported on socket: '/Users/ksmiley/dev/oss-swift/ninja/.git/fsmonitor--daemon.ipc'")] ```
1 parent 872d4ff commit a61af54

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

utils/swift_build_support/swift_build_support/products/ninja.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def build(self):
7777
# Ninja can only be built in-tree. Copy the source tree to the build
7878
# directory.
7979
shell.rmtree(self.build_dir)
80-
shell.copytree(self.source_dir, self.build_dir)
80+
shell.copytree(self.source_dir, self.build_dir, ignore_pattern=".git")
8181
with shell.pushd(self.build_dir):
8282
shell.call([sys.executable, 'configure.py', '--bootstrap'],
8383
env=env)

utils/swift_build_support/swift_build_support/shell.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,14 @@ def rmtree(path, dry_run=None, echo=True):
183183
shutil.rmtree(path)
184184

185185

186-
def copytree(src, dest, dry_run=None, echo=True):
186+
def copytree(src, dest, dry_run=None, ignore_pattern=None, echo=True):
187187
dry_run = _coerce_dry_run(dry_run)
188188
if dry_run or echo:
189189
_echo_command(dry_run, ['cp', '-r', src, dest])
190190
if dry_run:
191191
return
192-
shutil.copytree(src, dest)
192+
ignore = shutil.ignore_patterns(ignore_pattern) if ignore_pattern else None
193+
shutil.copytree(src, dest, ignore=ignore)
193194

194195

195196
def symlink(source, dest, dry_run=None, echo=True):

0 commit comments

Comments
 (0)