[Scummvm-git-logs] scummvm master -> be35c553f0274d7a84562cf52d0d3a686fe9bb2a

sev- sev at scummvm.org
Tue Jul 27 18:33:31 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
be35c553f0 SYMBIAN: Fix race condition.


Commit: be35c553f0274d7a84562cf52d0d3a686fe9bb2a
    https://github.com/scummvm/scummvm/commit/be35c553f0274d7a84562cf52d0d3a686fe9bb2a
Author: Fiodar Stryzhniou (fedor_qd at mail.ru)
Date: 2021-07-27T20:33:28+02:00

Commit Message:
SYMBIAN: Fix race condition.
Add cleanup from results previous build before new start.
Code style fixes from #3170.
Forced CPU usage.

Changed paths:
    backends/platform/symbian/symbian_builder/build_apps.py
    backends/platform/symbian/symbian_builder/piper.py


diff --git a/backends/platform/symbian/symbian_builder/build_apps.py b/backends/platform/symbian/symbian_builder/build_apps.py
index a73e463495..706b6df453 100644
--- a/backends/platform/symbian/symbian_builder/build_apps.py
+++ b/backends/platform/symbian/symbian_builder/build_apps.py
@@ -26,14 +26,13 @@ import multiprocessing as mp
 
 from common_names import *
 
-#workaround for "threading bug in strptime"
-#see - https://stackoverflow.com/questions/32245560/module-object-has-no-attribute-strptime-with-several-threads-python/46401422
+# Workaround for "threading bug in strptime"
+# See - https://stackoverflow.com/questions/32245560/module-object-has-no-attribute-strptime-with-several-threads-python/46401422
 import _strptime
 
 prj_template = "PRJ_MMPFILES\n%s"
 prj_path = "paralell_build"
 
-
 def thread_func(q, plats):
    while True:
       fileName = q.get()
@@ -48,20 +47,21 @@ def thread_func(q, plats):
             pass
          else:
             raise
-
       fname = os.path.join(plats, fileName)
       fname = os.path.join("..", fname)
       fname = os.path.join("..", fname)
-      fname = os.path.join("..", fname) # point to mmp file in port specific folder
+      fname = os.path.join("..", fname) # Point to mmp file in port specific folder.
       tmp = os.path.join(pth, "bld.inf")
       SafeWriteFile(tmp, prj_template %fname)
 
-
-      #Needed because datetime.now() returns the same time for every call
-      start = time.strftime("%H:%M:%S")
-
       cmd = subprocess.Popen('bldmake bldfiles', stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=pth, shell=True)
       out, err = cmd.communicate()
+      # Clean build directory from previous build.
+      cmd = subprocess.Popen('abld reallyclean gcce urel', cwd=pth, shell=True)
+      cmd.communicate()
+
+      # Needed because datetime.now() returns the same time for every call.
+      start = time.strftime("%H:%M:%S")
       cmd1 = subprocess.Popen('abld build gcce urel', stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=pth, shell=True)
       out1, err1 = cmd1.communicate()
 
@@ -72,25 +72,31 @@ def thread_func(q, plats):
 
       out = out + out1
       err = err + err1
-      # I hope it correctly stores logs in parallel tasks
-      # after cmd.communicate() we have ugly 'crcrlf' line endings
+      # I hope it correctly stores logs in parallel tasks.
+      # After cmd.communicate() we have ugly 'crcrlf' line endings.
       AppendToFile(build_log, out.replace(u"\r", u""))
       AppendToFile(build_err, err.replace(u"\r", u""))
-      AppendToFile(build_time, "Engine %s build time: %s.\n" %(fileName, str(diff)) )
+      AppendToFile(build_time, "Target %s build time: %s.\n" %(fileName, str(diff)) )
+      print "Target %s done!" %fileName
 
 def build_apps(plats):
    q = Queue.Queue()
+   t_count = mp.cpu_count() + 2
+   if t_count > q.qsize():
+      t_count = q.qsize()
    fileNames = os.listdir(plats)
    fileNames = [x for x in fileNames if ".mmp" in x]
 
    for fileName in fileNames:
       q.put(fileName)
-   print q.qsize()
-   print "Thread count: %s" %mp.cpu_count()
-   threads = [ threading.Thread(target=thread_func, args=(q, plats)) for i in range(mp.cpu_count()) ]
+   print "Queue size: %s" %q.qsize()
+   print "Thread count: %s" %t_count
+   threads = [threading.Thread(target=thread_func, args=(q, plats)) for i in range(t_count)]
    for thread in threads:
       thread.start()
-      q.put(None)  # one EOF marker for each thread
+      q.put(None)  # One EOF marker for each thread.
+   for thread in threads:
+      thread.join()
 
 if __name__ == "__main__":
    build_apps(plats = "S60v3")
diff --git a/backends/platform/symbian/symbian_builder/piper.py b/backends/platform/symbian/symbian_builder/piper.py
index 0ab6d88b48..46deff73eb 100644
--- a/backends/platform/symbian/symbian_builder/piper.py
+++ b/backends/platform/symbian/symbian_builder/piper.py
@@ -26,7 +26,7 @@ import multiprocessing as mp
 
 from common_names import *
 
-#workaround for "threading bug in strptime"
+# Workaround for "threading bug in strptime"
 #see - https://stackoverflow.com/questions/32245560/module-object-has-no-attribute-strptime-with-several-threads-python/46401422
 import _strptime
 
@@ -50,17 +50,20 @@ def thread_func(q):
 
       fname = os.path.join(mmps, fileName)
       fname = os.path.join("..", fname)
-      fname = os.path.join("..", fname) # point to mmp file in mmp folder
+      fname = os.path.join("..", fname) # Point to mmp file in port specific folder.
       tmp = os.path.join(pth, "bld.inf")
       SafeWriteFile(tmp, prj_template %fname)
 
-      #Needed because datetime.now() returns the same time for every call
-      start = time.strftime("%H:%M:%S")
-
       cmd = subprocess.Popen('bldmake bldfiles', stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=pth, shell=True)
       out, err = cmd.communicate()
       if len(err) > 0:
          print "err: %s\n\n" %err
+      # Clean build directory from previous build.
+      cmd = subprocess.Popen('abld reallyclean gcce urel', stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=pth, shell=True)
+      cmd.communicate()
+
+      # Needed because datetime.now() returns the same time for every call.
+      start = time.strftime("%H:%M:%S")
       cmd = subprocess.Popen('abld build gcce urel', stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=pth, shell=True)
       out1, err1 = cmd.communicate()
 
@@ -71,15 +74,17 @@ def thread_func(q):
 
       out = out + out1
       err = err + err1
-      #After cmd.communicate() we have ugly 'crcrlf' line endings
-      SafeWriteFile(build_log, out.replace(u"\r", u""), mode = 'a')
-      SafeWriteFile(build_err, err.replace(u"\r", u""), mode = 'a')
-      SafeWriteFile(build_time, "Engine %s build time: %s.\n" %(fileName, str(diff)) , mode = 'a')
-
-
+      # After cmd.communicate() we have ugly 'crcrlf' line endings.
+      AppendToFile(build_log, out.replace(u"\r", u""))
+      AppendToFile(build_err, err.replace(u"\r", u""))
+      AppendToFile(build_time, "Engine %s build time: %s.\n" %(fileName, str(diff)) )
+      print "Engine %s done!" %fileName
 
 def build_mmp(try_fix = False):
    q = Queue.Queue()
+   t_count = mp.cpu_count() + 2
+   if t_count > q.qsize():
+      t_count = q.qsize()
    fileNames = os.listdir(mmps)
    fileNames = [x for x in fileNames if ".mmp" in x]
    if try_fix:
@@ -90,12 +95,14 @@ def build_mmp(try_fix = False):
 
    for fileName in fileNames:
       q.put(fileName)
-   print "Queve size: %s" %q.qsize()
-   print "Thread count: %s" %mp.cpu_count()
-   threads = [ threading.Thread(target=thread_func, args=(q, )) for i in range(mp.cpu_count()) ]
+   print "Queue size: %s" %q.qsize()
+   print "Thread count: %s" %t_count
+   threads = [threading.Thread(target=thread_func, args=(q, )) for i in range(t_count)]
    for thread in threads:
       thread.start()
       q.put(None)  # one EOF marker for each thread
+   for thread in threads:
+      thread.join()
 
 
 if __name__ == "__main__":




More information about the Scummvm-git-logs mailing list