diff mbox

[Branch,~glmark2-dev/glmark2/trunk] Rev 127: Add custom dist command to the build system that preserves symbolic links.

Message ID 20110818222014.7391.65596.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

alexandros.frantzis@linaro.org Aug. 18, 2011, 10:20 p.m. UTC
------------------------------------------------------------
revno: 127
tags: 2011.08
committer: Alexandros Frantzis <alexandros.frantzis@linaro.org>
branch nick: trunk
timestamp: Fri 2011-08-19 00:31:25 +0300
message:
  Add custom dist command to the build system that preserves symbolic links.
modified:
  wscript


--
lp:glmark2
https://code.launchpad.net/~glmark2-dev/glmark2/trunk

You are subscribed to branch lp:glmark2.
To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'wscript'
--- wscript	2011-08-18 15:36:14 +0000
+++ wscript	2011-08-18 21:31:25 +0000
@@ -3,6 +3,7 @@ 
 import os
 import Options
 import Scripting
+from waflib import Context
 
 out = 'build'
 top = '.'
@@ -94,5 +95,42 @@ 
     ctx.recurse('data')
     ctx.recurse('doc')
 
-def dist(ctx):
-    ctx.algo = 'tar.gz'
+class Glmark2Dist(Context.Context):
+    """ Custom dist command that preserves symbolic links"""
+
+    cmd = "dist"
+
+    def execute(self):
+        self.recurse([os.path.dirname(Context.g_module.root_path)])
+        self.archive()
+
+    def get_files(self):
+        import fnmatch
+        files = []
+        excludes = ['*.bzr', '*~', './.*waf*', './build*', '*.swp', '*glmark2-*.tar.gz']
+        for (dirpath, dirnames, filenames) in os.walk(top):
+            names_to_remove = []
+            names = dirnames + filenames
+            for n in names:
+                for exclude in excludes:
+                    if fnmatch.fnmatch(os.path.join(dirpath, n), exclude):
+                        names_to_remove.append(n)
+                        break
+
+            for d in names_to_remove:
+                if d in dirnames:
+                    dirnames.remove(d)
+                if d in filenames:
+                    filenames.remove(d)
+
+            files.extend([os.path.join(dirpath, d) for d in dirnames])
+            files.extend([os.path.join(dirpath, f) for f in filenames])
+
+        return files
+
+    def archive(self):
+        import tarfile
+        tar = tarfile.open(APPNAME + '-' + VERSION + '.tar.gz', 'w:gz')
+        for f in self.get_files():
+            tar.add(f, arcname = APPNAME + '-' + VERSION + '/' + f, recursive = False)
+        tar.close()