Author: loonycyborg
Date: Thu May 22 15:51:51 2008
New Revision: 26770

URL: http://svn.gna.org/viewcvs/wesnoth?rev=26770&view=rev
Log:
SCons recipe: moved some Install builder methods to separate file.

Added:
    trunk/scons/install.py
Modified:
    trunk/SConstruct

Modified: trunk/SConstruct
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/SConstruct?rev=26770&r1=26769&r2=26770&view=diff
==============================================================================
--- trunk/SConstruct (original)
+++ trunk/SConstruct Thu May 22 15:51:51 2008
@@ -75,7 +75,7 @@
 # Setup
 #
 
-env = Environment(tools=["tar", "gettext"], options = opts, toolpath = 
["scons"])
+env = Environment(tools=["tar", "gettext", "install"], options = opts, 
toolpath = ["scons"])
 if env["PLATFORM"] == "win32":
     env.Tool("mingw")
 else:
@@ -365,61 +365,13 @@
     "Filter out data-tree things that shouldn't be installed."
     return not ".svn" in str(fn) and not "Makefile" in str(fn)
 
+env["copy_filter"] = CopyFilter
+
 for lang in filter(CopyFilter, os.listdir("doc/man")):
      sourcedir = os.path.join("doc/man", lang)
      if os.path.isdir(sourcedir):
           targetdir = os.path.join(mandir, lang, "man6")
           localized_man_dirs[sourcedir] = targetdir
-
-def InstallFilteredHook(target, source, env):
-    if type(target) == type([]):
-        target = target[0]
-    target = str(target)
-    if type(source) == type([]):
-        map(lambda f: InstallFilteredHook(target, f, env), source)
-    elif os.path.isdir(str(source)):
-        if CopyFilter(source):
-            target = os.path.join(target, os.path.basename(str(source))) 
-            if not os.path.exists(target):
-                 if env["verbose"]:
-                      print "Make directory", target
-                 os.makedirs(target)
-            map(lambda f: InstallFilteredHook(target, 
os.path.join(str(source), f), env), os.listdir(str(source)))
-    elif CopyFilter(source):
-        if (env["gui"] == "tiny") and (source.endswith("jpg") or 
source.endswith("png")):
-             image_info = Popen(["identify", "-verbose", source], stdout = 
PIPE).communicate()[0]
-             target = os.path.join(target, os.path.basename(source))
-             if "Alpha: " in image_info:
-                 command = "convert -filter point -resize %s %s %s"
-             else:
-                 command = "convert -resize %s %s %s"
-             for (large, small) in (("1024x768","320x240"),
-                                    ("640x480","240x180"),
-                                    ("205x205","80x80")):
-                if ("Geometry: " + large) in image_info:
-                    command = command % (small, source, target)
-                    break
-             else:
-                    command = command % ("50%", source, target)
-             if env["verbose"]:
-                print command
-             call(Split(command))
-             return None
-        # Just copy non-images, and images if tinygui is off
-        if env["verbose"]:
-             print "cp %s %s" % (str(source), target)
-        shutil.copy2(str(source), target)
-    return None
-env.Append(BUILDERS={'InstallFiltered':Builder(action=InstallFilteredHook)})
-
-def InstallWithSuffix(env, target, source):
-    if not source:
-        return source
-    return env.InstallAs(os.path.join(target, source[0].name + 
env["program_suffix"]), source)
-
-#env.AddMethod(InstallWithSuffix)
-from SCons.Script.SConscript import SConsEnvironment
-SConsEnvironment.InstallWithSuffix = InstallWithSuffix
 
 def InstallLocalizedManPage(alias, page, env):
     actions = []

Added: trunk/scons/install.py
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/scons/install.py?rev=26770&view=auto
==============================================================================
--- trunk/scons/install.py (added)
+++ trunk/scons/install.py Thu May 22 15:51:51 2008
@@ -1,0 +1,60 @@
+# vi: syntax=python:et:ts=4
+from SCons.Script import *
+import shutil, os
+from subprocess import call
+
+def InstallFilteredHook(target, source, env):
+    CopyFilter = env["copy_filter"]
+    if type(target) == type([]):
+        target = target[0]
+    target = str(target)
+    if type(source) == type([]):
+        map(lambda f: InstallFilteredHook(target, f, env), source)
+    elif os.path.isdir(str(source)):
+        if CopyFilter(source):
+            target = os.path.join(target, os.path.basename(str(source))) 
+            if not os.path.exists(target):
+                 if env["verbose"]:
+                      print "Make directory", target
+                 os.makedirs(target)
+            map(lambda f: InstallFilteredHook(target, 
os.path.join(str(source), f), env), os.listdir(str(source)))
+    elif CopyFilter(source):
+        if (env["gui"] == "tiny") and (source.endswith("jpg") or 
source.endswith("png")):
+             image_info = Popen(["identify", "-verbose", source], stdout = 
PIPE).communicate()[0]
+             target = os.path.join(target, os.path.basename(source))
+             if "Alpha: " in image_info:
+                 command = "convert -filter point -resize %s %s %s"
+             else:
+                 command = "convert -resize %s %s %s"
+             for (large, small) in (("1024x768","320x240"),
+                                    ("640x480","240x180"),
+                                    ("205x205","80x80")):
+                if ("Geometry: " + large) in image_info:
+                    command = command % (small, source, target)
+                    break
+             else:
+                    command = command % ("50%", source, target)
+             if env["verbose"]:
+                print command
+             call(Split(command))
+             return None
+        # Just copy non-images, and images if tinygui is off
+        if env["verbose"]:
+             print "cp %s %s" % (str(source), target)
+        shutil.copy2(str(source), target)
+    return None
+
+def InstallWithSuffix(env, target, source):
+    if not source:
+        return source
+    return env.InstallAs(os.path.join(target, source[0].name + 
env["program_suffix"]), source)
+
+def generate(env):
+    #env.AddMethod(InstallWithSuffix)
+    from SCons.Script.SConscript import SConsEnvironment
+    SConsEnvironment.InstallWithSuffix = InstallWithSuffix
+
+    
env.Append(BUILDERS={'InstallFiltered':Builder(action=InstallFilteredHook)})
+
+def exists():
+    return True


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to