Skip to content
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

Make NativeTARDistribution usable #87

Merged
merged 4 commits into from
Mar 17, 2016
Merged
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
27 changes: 22 additions & 5 deletions mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,9 +1096,11 @@ def cleanForbidden(self):
path: suite-local path to where the tar file will be placed
"""
class NativeTARDistribution(Distribution):
def __init__(self, suite, name, deps, path, excludedLibs, platformDependent, theLicense):
def __init__(self, suite, name, deps, path, excludedLibs, platformDependent, theLicense, relpath, output):
Distribution.__init__(self, suite, name, deps, excludedLibs, platformDependent, theLicense)
self.path = _make_absolute(path, suite.dir)
self.relpath = relpath
self.output = output

def make_archive(self):
directory = dirname(self.path)
Expand All @@ -1108,8 +1110,13 @@ def make_archive(self):
for d in self.archived_deps():
if not d.isNativeProject():
abort('Unsupported dependency for native distribution {}: {}'.format(self.name, d.name))
output = d.getOutput()
output = join(self.suite.dir, output) if output else None
for r in d.getResults():
filename = basename(r)
if output and self.relpath:
filename = os.path.relpath(r, output)
else:
filename = basename(r)
assert filename not in files, filename
# Make debug-info files optional for distribution
if is_debug_lib_file(r) and not os.path.exists(r):
Expand All @@ -1134,9 +1141,17 @@ def localExtension(self):
def postPull(self, f):
assert f.endswith('.gz')
logv('Uncompressing {}...'.format(f))
tarfilename = None
with gzip.open(f, 'rb') as gz, open(f[:-len('.gz')], 'wb') as tar:
shutil.copyfileobj(gz, tar)
tarfilename = tar.name
os.remove(f)
if self.output:
output = join(self.suite.dir, self.output)
assert tarfilename
with tarfile.open(tarfilename, 'r:') as tar:
logv('Extracting {} to {}'.format(tarfilename, output))
tar.extractall(output)

def prePush(self, f):
tgz = f + '.gz'
Expand Down Expand Up @@ -5304,7 +5319,9 @@ def _load_distribution(self, name, attrs):
platformDependent = bool(os_arch)
if native:
path = attrs.pop('path')
d = NativeTARDistribution(self, name, deps, path, exclLibs, platformDependent, theLicense)
relpath = attrs.pop('relpath', False)
output = attrs.pop('output', None)
d = NativeTARDistribution(self, name, deps, path, exclLibs, platformDependent, theLicense, relpath, output)
else:
defaultPath = join(self.get_output_root(), 'dists', _map_to_maven_dist_name(name) + '.jar')
defaultSourcesPath = join(self.get_output_root(), 'dists', _map_to_maven_dist_name(name) + '.src.zip')
Expand Down Expand Up @@ -5745,7 +5762,7 @@ def _load_projects(self):
native = attrs.pop('native', False)
if native:
output = attrs.pop('output', None)
results = Suite._pop_list(attrs, 'output', context)
results = Suite._pop_list(attrs, 'results', context)
p = NativeProject(self, name, subDir, srcDirs, deps, workingSets, results, output, d, theLicense=theLicense)
else:
javaCompliance = attrs.pop('javaCompliance', None)
Expand Down Expand Up @@ -12877,7 +12894,7 @@ def alarm_handler(signum, frame):
# no need to show the stack trace when the user presses CTRL-C
abort(1)

version = VersionSpec("5.14.0")
version = VersionSpec("5.14.2")

currentUmask = None

Expand Down