1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-13 03:19:53 +03:00

[Build] Filelock added to avoid to compile the same firmware many tim… (#4333)

* [Build] Filelock added to avoid to compile the same firmware many times simultaneously
This commit is contained in:
Bertrand Songis 2017-01-30 09:16:18 +01:00 committed by Damjan Adamic
parent cc8de81128
commit 11c20a5c2c
2 changed files with 20 additions and 8 deletions

View file

@ -4,6 +4,7 @@ import os
import sys
import subprocess
import shutil
import filelock
from fwoptions import *
# Error codes
@ -175,15 +176,13 @@ if not language:
command_options["TRANSLATIONS"] = language.upper()
filename += "-" + language + ext
srcdir = os.path.dirname(os.path.realpath(__file__)) + "/../.."
path = os.path.join(directory, filename)
outpath = path + ".out"
errpath = path + ".err"
if os.path.isfile(errpath):
exit(COMPILATION_ERROR)
def build_firmware(path):
srcdir = os.path.dirname(os.path.realpath(__file__)) + "/../.."
outpath = path + ".out"
if not os.path.isfile(path):
# Launch CMake
cmd = ["cmake"]
for opt, value in command_options.items():
@ -219,9 +218,20 @@ if not os.path.isfile(path):
if size > maxsize:
exit(FIRMWARE_SIZE_TOO_BIG)
# Copy binary to the binaries directory
shutil.move(target, path)
if os.path.isfile(errpath):
exit(COMPILATION_ERROR)
lockpath = path + ".lock"
lock = filelock.FileLock(lockpath)
try:
with lock.acquire(timeout = 60*60):
if not os.path.isfile(path):
build_firmware(path)
except filelock.Timeout:
exit(COMPILATION_ERROR)
print filename
exit(0)