From 10636f6eac5dfa6b99d13da3de520d11ccde8375 Mon Sep 17 00:00:00 2001 From: Dmitry Matveev Date: Thu, 27 Apr 2017 00:09:40 +0300 Subject: [PATCH 1/3] Fix intellijinit for sulong on windows --- mx.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mx.py b/mx.py index 4a665e0e..d6e2dffb 100755 --- a/mx.py +++ b/mx.py @@ -120,6 +120,12 @@ def __exit__(self, tpe, value, traceback): currently_loading_suite = DynamicVar(None) +def safe_relpath(path, start): + """Return a relative version of a path if possible. Otherwise just return path""" + try: + return os.path.relpath(path, start) + except ValueError: + return path # Support for Python 2.6 def check_output(*popenargs, **kwargs): @@ -12940,9 +12946,9 @@ def make_library(name, path, source_path): for library in libraries: sourcePath = None if library.isLibrary(): - path = os.path.relpath(library.get_path(True), s.dir) + path = safe_relpath(library.get_path(True), s.dir) if library.sourcePath: - sourcePath = os.path.relpath(library.get_source_path(True), s.dir) + sourcePath = safe_relpath(library.get_source_path(True), s.dir) elif library.isMavenProject(): path = os.path.relpath(library.get_path(True), s.dir) sourcePath = os.path.relpath(library.get_source_path(True), s.dir) @@ -12986,7 +12992,7 @@ def make_library(name, path, source_path): for apDep in processors: def processApDep(dep, edge): if dep.isLibrary() or dep.isJARDistribution(): - compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + os.path.relpath(dep.path, s.dir)}) + compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + safe_relpath(dep.path, s.dir)}) elif dep.isProject(): compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + os.path.relpath(dep.output_dir(), s.dir)}) apDep.walk_deps(visit=processApDep) From affc3e62b3b52f4fd9f08043604625a378432da8 Mon Sep 17 00:00:00 2001 From: Dmitry Matveev Date: Thu, 27 Apr 2017 00:17:57 +0300 Subject: [PATCH 2/3] more safety --- mx.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mx.py b/mx.py index d6e2dffb..790e1c5b 100755 --- a/mx.py +++ b/mx.py @@ -5666,7 +5666,7 @@ def _maven_deploy_dists(dists, versionGetter, repository_id, url, settingsXml, d for filename in filenames: emptyJavadoc = False src = join(dirpath, filename) - dst = os.path.relpath(src, javadocDir) + dst = safe_relpath(src, javadocDir) arc.write(src, dst) shutil.rmtree(tmpDir) if emptyJavadoc: @@ -12950,12 +12950,12 @@ def make_library(name, path, source_path): if library.sourcePath: sourcePath = safe_relpath(library.get_source_path(True), s.dir) elif library.isMavenProject(): - path = os.path.relpath(library.get_path(True), s.dir) - sourcePath = os.path.relpath(library.get_source_path(True), s.dir) + path = safe_relpath(library.get_path(True), s.dir) + sourcePath = safe_relpath(library.get_source_path(True), s.dir) elif library.isJARDistribution(): - path = os.path.relpath(library.path, s.dir) + path = safe_relpath(library.path, s.dir) if library.sourcesPath: - sourcePath = os.path.relpath(library.sourcesPath, s.dir) + sourcePath = safe_relpath(library.sourcesPath, s.dir) else: abort('Dependency not supported: {} ({})'.format(library.name, library.__class__.__name__)) make_library(library.name, path, sourcePath) From 7b38c3d152480acf50fb736bc358b7e78abbd305 Mon Sep 17 00:00:00 2001 From: Dmitry Matveev Date: Thu, 27 Apr 2017 00:33:08 +0300 Subject: [PATCH 3/3] more safety --- mx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mx.py b/mx.py index 790e1c5b..feab1f48 100755 --- a/mx.py +++ b/mx.py @@ -12994,7 +12994,7 @@ def processApDep(dep, edge): if dep.isLibrary() or dep.isJARDistribution(): compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + safe_relpath(dep.path, s.dir)}) elif dep.isProject(): - compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + os.path.relpath(dep.output_dir(), s.dir)}) + compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + safe_relpath(dep.output_dir(), s.dir)}) apDep.walk_deps(visit=processApDep) compilerXml.close('processorPath') for module in modules: