Migrate some logic from SConstruct into site_scons to simplify top level SConstruct
authorWilliam Deegan <bill@baddogconsulting.com>
Tue, 3 Oct 2017 00:09:10 +0000 (17:09 -0700)
committerWilliam Deegan <bill@baddogconsulting.com>
Tue, 3 Oct 2017 00:09:10 +0000 (17:09 -0700)
SConstruct
site_scons/SConsRevision.py [new file with mode: 0644]
site_scons/site_init.py [new file with mode: 0644]

index 065ba2dd9d566e3d4d6ac6aad0ec43ca15751380..f26cafe8ce2bfd109581a64be59855bc64b9221d 100644 (file)
@@ -362,46 +362,6 @@ except ImportError:
         unzipit = "$UNZIP $UNZIPFLAGS $SOURCES"
 
 
-def SCons_revision(target, source, env):
-    """Interpolate specific values from the environment into a file.
-
-    This is used to copy files into a tree that gets packaged up
-    into the source file package.
-    """
-    t = str(target[0])
-    s = source[0].rstr()
-
-    try:
-        with open(s, 'r') as fp:
-            contents = fp.read()
-
-
-        # Note:  We construct the __*__ substitution strings here
-        # so that they don't get replaced when this file gets
-        # copied into the tree for packaging.
-        contents = contents.replace('__BUILD'     + '__', env['BUILD'])
-        contents = contents.replace('__BUILDSYS'  + '__', env['BUILDSYS'])
-        contents = contents.replace('__COPYRIGHT' + '__', env['COPYRIGHT'])
-        contents = contents.replace('__DATE'      + '__', env['DATE'])
-        contents = contents.replace('__DEB_DATE'  + '__', env['DEB_DATE'])
-
-        contents = contents.replace('__DEVELOPER' + '__', env['DEVELOPER'])
-        contents = contents.replace('__FILE'      + '__', str(source[0]).replace('\\', '/'))
-        contents = contents.replace('__MONTH_YEAR'+ '__', env['MONTH_YEAR'])
-        contents = contents.replace('__REVISION'  + '__', env['REVISION'])
-        contents = contents.replace('__VERSION'   + '__', env['VERSION'])
-        contents = contents.replace('__NULL'      + '__', '')
-        open(t, 'w').write(contents)
-    except UnicodeDecodeError as e:
-        print("Error decoding file:%s just copying no revision edit")
-        with open(s, 'rb') as fp:
-            contents = fp.read()
-            open(t, 'wb').write(contents)
-
-
-    os.chmod(t, os.stat(s)[0])
-
-
 revaction = SCons_revision
 revbuilder = Builder(action = Action(SCons_revision,
                                      varlist=['COPYRIGHT', 'VERSION']))
diff --git a/site_scons/SConsRevision.py b/site_scons/SConsRevision.py
new file mode 100644 (file)
index 0000000..11de670
--- /dev/null
@@ -0,0 +1,40 @@
+import os
+
+def SCons_revision(target, source, env):
+    """Interpolate specific values from the environment into a file.
+
+    This is used to copy files into a tree that gets packaged up
+    into the source file package.
+    """
+    t = str(target[0])
+    s = source[0].rstr()
+
+    try:
+        with open(s, 'r') as fp:
+            contents = fp.read()
+
+
+        # Note:  We construct the __*__ substitution strings here
+        # so that they don't get replaced when this file gets
+        # copied into the tree for packaging.
+        contents = contents.replace('__BUILD'     + '__', env['BUILD'])
+        contents = contents.replace('__BUILDSYS'  + '__', env['BUILDSYS'])
+        contents = contents.replace('__COPYRIGHT' + '__', env['COPYRIGHT'])
+        contents = contents.replace('__DATE'      + '__', env['DATE'])
+        contents = contents.replace('__DEB_DATE'  + '__', env['DEB_DATE'])
+
+        contents = contents.replace('__DEVELOPER' + '__', env['DEVELOPER'])
+        contents = contents.replace('__FILE'      + '__', str(source[0]).replace('\\', '/'))
+        contents = contents.replace('__MONTH_YEAR'+ '__', env['MONTH_YEAR'])
+        contents = contents.replace('__REVISION'  + '__', env['REVISION'])
+        contents = contents.replace('__VERSION'   + '__', env['VERSION'])
+        contents = contents.replace('__NULL'      + '__', '')
+        open(t, 'w').write(contents)
+    except UnicodeDecodeError as e:
+        print("Error decoding file:%s just copying no revision edit")
+        with open(s, 'rb') as fp:
+            contents = fp.read()
+            open(t, 'wb').write(contents)
+
+
+    os.chmod(t, os.stat(s)[0])
\ No newline at end of file
diff --git a/site_scons/site_init.py b/site_scons/site_init.py
new file mode 100644 (file)
index 0000000..8e07907
--- /dev/null
@@ -0,0 +1 @@
+from SConsRevision import SCons_revision
\ No newline at end of file