mirror of
https://github.com/opentx/opentx.git
synced 2025-07-13 11:29:51 +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:
parent
cc8de81128
commit
11c20a5c2c
2 changed files with 20 additions and 8 deletions
|
@ -20,7 +20,10 @@ RUN apt-get update && \
|
|||
qttools5-dev-tools \
|
||||
software-properties-common \
|
||||
wget \
|
||||
zip
|
||||
zip \
|
||||
python-pip
|
||||
|
||||
RUN python -m pip install filelock
|
||||
|
||||
RUN wget -q https://launchpad.net/gcc-arm-embedded/4.7/4.7-2013-q3-update/+download/gcc-arm-none-eabi-4_7-2013q3-20130916-linux.tar.bz2 && \
|
||||
tar xjf gcc-arm-none-eabi-4_7-2013q3-20130916-linux.tar.bz2 && \
|
||||
|
@ -37,4 +40,3 @@ VOLUME ["/opentx"]
|
|||
ENV PATH $PATH:/opt/gcc-arm-none-eabi/bin:/opentx/code/radio/util
|
||||
ARG OPENTX_VERSION_SUFFIX=
|
||||
ENV OPENTX_VERSION_SUFFIX ${OPENTX_VERSION_SUFFIX}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue