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 \
|
qttools5-dev-tools \
|
||||||
software-properties-common \
|
software-properties-common \
|
||||||
wget \
|
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 && \
|
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 && \
|
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
|
ENV PATH $PATH:/opt/gcc-arm-none-eabi/bin:/opentx/code/radio/util
|
||||||
ARG OPENTX_VERSION_SUFFIX=
|
ARG OPENTX_VERSION_SUFFIX=
|
||||||
ENV OPENTX_VERSION_SUFFIX ${OPENTX_VERSION_SUFFIX}
|
ENV OPENTX_VERSION_SUFFIX ${OPENTX_VERSION_SUFFIX}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
|
import filelock
|
||||||
from fwoptions import *
|
from fwoptions import *
|
||||||
|
|
||||||
# Error codes
|
# Error codes
|
||||||
|
@ -175,15 +176,13 @@ if not language:
|
||||||
command_options["TRANSLATIONS"] = language.upper()
|
command_options["TRANSLATIONS"] = language.upper()
|
||||||
|
|
||||||
filename += "-" + language + ext
|
filename += "-" + language + ext
|
||||||
srcdir = os.path.dirname(os.path.realpath(__file__)) + "/../.."
|
|
||||||
path = os.path.join(directory, filename)
|
path = os.path.join(directory, filename)
|
||||||
outpath = path + ".out"
|
|
||||||
errpath = path + ".err"
|
errpath = path + ".err"
|
||||||
|
|
||||||
if os.path.isfile(errpath):
|
def build_firmware(path):
|
||||||
exit(COMPILATION_ERROR)
|
srcdir = os.path.dirname(os.path.realpath(__file__)) + "/../.."
|
||||||
|
outpath = path + ".out"
|
||||||
|
|
||||||
if not os.path.isfile(path):
|
|
||||||
# Launch CMake
|
# Launch CMake
|
||||||
cmd = ["cmake"]
|
cmd = ["cmake"]
|
||||||
for opt, value in command_options.items():
|
for opt, value in command_options.items():
|
||||||
|
@ -219,9 +218,20 @@ if not os.path.isfile(path):
|
||||||
if size > maxsize:
|
if size > maxsize:
|
||||||
exit(FIRMWARE_SIZE_TOO_BIG)
|
exit(FIRMWARE_SIZE_TOO_BIG)
|
||||||
|
|
||||||
|
|
||||||
# Copy binary to the binaries directory
|
# Copy binary to the binaries directory
|
||||||
shutil.move(target, path)
|
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
|
print filename
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue