From 13aaf1dfcf71501ae7fe513ea1c4a7e10c38a1b6 Mon Sep 17 00:00:00 2001
From: Lukas Stadler <lukas.stadler@oracle.com>
Date: Thu, 5 Oct 2017 18:38:55 +0200
Subject: [PATCH] handle symlinks in the lib directory when creating the
 release distribution

---
 mx.fastr/mx_fastr_dists.py | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/mx.fastr/mx_fastr_dists.py b/mx.fastr/mx_fastr_dists.py
index 2915fac0b8..ba79c4b3fe 100644
--- a/mx.fastr/mx_fastr_dists.py
+++ b/mx.fastr/mx_fastr_dists.py
@@ -80,12 +80,31 @@ class ReleaseBuildTask(mx.NativeBuildTask):
         # copy the release directories
         output_dir = self.subject.dir
         fastr_dir = mx_fastr._fastr_suite.dir
-        for d in ['bin', 'include', 'lib', 'library', 'etc', 'share', 'doc']:
+        for d in ['bin', 'include', 'library', 'etc', 'share', 'doc']:
             target_dir = join(output_dir, d)
             if os.path.exists(target_dir):
+                print("delete " + target_dir)
                 shutil.rmtree(target_dir)
+            print("copy from " + join(fastr_dir, d) + " to " + target_dir)
             shutil.copytree(join(fastr_dir, d), target_dir)
 
+        lib_fastr_dir = join(fastr_dir, 'lib')
+        lib_output_dir = join(output_dir, 'lib')
+        if os.path.exists(lib_output_dir):
+            print("delete " + lib_output_dir)
+            shutil.rmtree(lib_output_dir)
+        os.mkdir(lib_output_dir)
+        for f in os.listdir(lib_fastr_dir):
+            source_file = join(lib_fastr_dir, f)
+            target_file = join(lib_output_dir, f)
+            if f != '.DS_Store':
+                if os.path.islink(source_file):
+                    print("copy from " + join(lib_fastr_dir, f) + " to " + target_file)
+                    os.symlink(os.readlink(source_file), target_file)
+                else:
+                    print("copy from " + join(lib_fastr_dir, f) + " to " + target_file)
+                    shutil.copy(source_file, target_file)
+
         # copyrights
         copyrights_dir = join(fastr_dir, 'mx.fastr', 'copyrights')
         with open(join(output_dir, 'COPYRIGHT'), 'w') as outfile:
-- 
GitLab