Diff of /trunk/cforge/cforge/Package/CFORGE/Scripts/build.py [r55] .. [r56]  Maximize  Restore

Switch to side-by-side view

--- a/trunk/cforge/cforge/Package/CFORGE/Scripts/build.py
+++ b/trunk/cforge/cforge/Package/CFORGE/Scripts/build.py
@@ -1,4 +1,5 @@
 import sys, os
+import re
 import zipfile
 import cds_script
 
@@ -37,9 +38,32 @@
 
 
 # Build all packages
+xFoundProject = False
 for root, dirs, files in os.walk(folder):
     for file in files:
+        # btw, check if some libs or projects are to be built
+        if file.endswith(".library") or file.endswith(".project"):
+            xFoundProject = True
         if file == "package.manifest":
+            # Increase Package Version
+            packageManifest = os.path.join(root, file)
+            f = open(packageManifest, 'r')
+            if f:
+                manifest = f.read()
+                version = re.findall(r'<Version>([^<]*)</Version>', manifest)
+                if len(version) == 1:
+                    version = version[0]
+                    version_tuple = version.split('.')
+                    version_tuple[-1] = str(int(version_tuple[-1]) + 1)
+                    new_version = ".".join(version_tuple)
+                    print("Increasing package version number from %s to %s\n" % (version, new_version))
+                    manifest = manifest.replace("<Version>%s</Version>" % version, "<Version>%s</Version>" % new_version)
+                    f.close()
+                    f = open(packageManifest, 'w')
+                    if f:
+                        f.write(manifest)
+                        f.close()
+            # ZIP package
             packageDir = root
             packageName = root + ".package"
             print("Creating package: '%s' -> '%s'" % (packageDir, packageName))
@@ -48,8 +72,7 @@
             zipf.close()
 
 # Export documentation as markdown
-
-scriptname = os.path.join(scriptpath, "action.markdown.py")
-scriptargs = folder
-
-cds_script.RunCodesysWithScript(scriptname, scriptargs, False)+if xFoundProject:
+    scriptname = os.path.join(scriptpath, "action.markdown.py")
+    scriptargs = folder
+    cds_script.RunCodesysWithScript(scriptname, scriptargs, False)