Skip to content

[Build System: build-script] Remove the tar module from swift_build_support. #29468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ from swift_build_support.swift_build_support import (
diagnostics,
products,
shell,
tar,
targets,
workspace
)
Expand Down Expand Up @@ -89,6 +88,25 @@ def print_xcodebuild_versions(file=sys.stdout):
file.flush()


def tar(source, destination):
"""
Create a gzip archive of the file at 'source' at the given
'destination' path.
"""
# We do not use `tarfile` here because:
# - We wish to support LZMA2 compression while also supporting Python 2.7.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure we've never used this for LZMA2 compression, thus we should just use the builtin tarfile library. I'll do that in a follow-up PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The builtin tarfile module supports lzma as well I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only for Python 3.2 (or 3.3) and beyond. Python 2.7 supports gzip however, which appears to be all we use for the time being.

# - We wish to explicitly set the owner and group of the archive.
args = ['tar', '-c', '-z', '-f', destination]

if platform.system() != 'Darwin' and platform.system() != 'Windows':
args += ['--owner=0', '--group=0']

# Discard stderr output such as 'tar: Failed to open ...'. We'll detect
# these cases using the exit code, which should cause 'shell.call' to
# raise.
shell.call(args + [source], stderr=shell.DEVNULL)


class BuildScriptInvocation(object):

"""Represent a single build script invocation."""
Expand Down Expand Up @@ -1169,8 +1187,8 @@ def main_normal():
# run `tar` without the leading '/' (we remove it ourselves to keep
# `tar` from emitting a warning).
with shell.pushd(args.install_symroot):
tar.tar(source=prefix.lstrip('/'),
destination=args.symbols_package)
tar(source=prefix.lstrip('/'),
destination=args.symbols_package)

return 0

Expand Down
34 changes: 0 additions & 34 deletions utils/swift_build_support/swift_build_support/tar.py

This file was deleted.

72 changes: 0 additions & 72 deletions utils/swift_build_support/tests/test_tar.py

This file was deleted.