Dockerfile commited
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
# An Debian image for compiling OpenTX 2.2
|
||||||
|
|
||||||
|
FROM debian:jessie
|
||||||
|
MAINTAINER bsongis
|
||||||
|
|
||||||
|
RUN apt-get update &&
|
||||||
|
apt-get install -y software-properties-common wget lib32z1 lib32ncurses5 git cmake gcc avr-libc build-essential libfox-1.6-dev python-qt4
|
||||||
|
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 &&
|
||||||
|
mv gcc-arm-none-eabi-4_7-2013q3 /opt/gcc-arm-none-eabi
|
||||||
|
ENV PATH $PATH:/opt/gcc-arm-none-eabi/bin
|
||||||
|
|
||||||
|
ADD http://ftp.de.debian.org/debian/pool/main/g/gcc-avr/gcc-avr_4.7.2-2_amd64.deb gcc-avr_4.7.2-2_amd64.deb
|
||||||
|
ADD http://ftp.de.debian.org/debian/pool/main/m/mpclib/libmpc2_0.9-4_amd64.deb libmpc2_0.9-4_amd64.deb
|
||||||
|
RUN dpkg -i gcc-avr_4.7.2-2_amd64.deb libmpc2_0.9-4_amd64.deb
|
||||||
|
|
||||||
|
VOLUME ["/opentx"]
|
||||||
|
ENTRYPOINT ["python", "/opentx/code/radio/util/build.py"]
|
||||||
+39
-16
@@ -2,8 +2,17 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import subprocess
|
||||||
|
import shutil
|
||||||
from fwoptions import *
|
from fwoptions import *
|
||||||
|
|
||||||
|
# Error codes
|
||||||
|
INVALID_FIRMWARE = -1
|
||||||
|
UNKNOWN_BOARD = -2
|
||||||
|
INVALID_LANGUAGE = -3
|
||||||
|
COMPILATION_ERROR = -4
|
||||||
|
FIRMWARE_SIZE_TOO_BIG = -5
|
||||||
|
|
||||||
# Board types
|
# Board types
|
||||||
BOARD_9X = 0
|
BOARD_9X = 0
|
||||||
BOARD_GRUVIN9X = 1
|
BOARD_GRUVIN9X = 1
|
||||||
@@ -15,13 +24,16 @@ BOARD_HORUS = 4
|
|||||||
BOARD_FAMILY_AVR = 0
|
BOARD_FAMILY_AVR = 0
|
||||||
BOARD_FAMILY_ARM = 1
|
BOARD_FAMILY_ARM = 1
|
||||||
|
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
exit(INVALID_FIRMWARE)
|
||||||
|
|
||||||
srcdir = os.path.dirname(os.path.realpath(__file__)) + "/../.."
|
srcdir = os.path.dirname(os.path.realpath(__file__)) + "/../.."
|
||||||
filename = sys.argv[1]
|
filename = sys.argv[1]
|
||||||
root, ext = os.path.splitext(filename)
|
root, ext = os.path.splitext(filename)
|
||||||
options = root.split("-")
|
options = root.split("-")
|
||||||
|
|
||||||
if options[0] != "opentx":
|
if len(options) < 2 or options[0] != "opentx":
|
||||||
sys.exit("Invalid firmware");
|
exit(INVALID_FIRMWARE)
|
||||||
|
|
||||||
filename = "opentx-"
|
filename = "opentx-"
|
||||||
optcount = 1
|
optcount = 1
|
||||||
@@ -116,7 +128,7 @@ elif options[optcount] == "horus":
|
|||||||
board = BOARD_HORUS
|
board = BOARD_HORUS
|
||||||
board_family = BOARD_FAMILY_ARM
|
board_family = BOARD_FAMILY_ARM
|
||||||
else:
|
else:
|
||||||
sys.exit("Unknown board")
|
exit(UNKNOWN_BOARD)
|
||||||
|
|
||||||
filename += options[optcount]
|
filename += options[optcount]
|
||||||
optcount += 1
|
optcount += 1
|
||||||
@@ -144,7 +156,7 @@ for key in languages:
|
|||||||
if key == options[-1]:
|
if key == options[-1]:
|
||||||
language = key
|
language = key
|
||||||
if not language:
|
if not language:
|
||||||
sys.exit("Invalid language")
|
exit(INVALID_LANGUAGE)
|
||||||
command_options["TRANSLATIONS"] = language.upper()
|
command_options["TRANSLATIONS"] = language.upper()
|
||||||
filename += "-" + language
|
filename += "-" + language
|
||||||
|
|
||||||
@@ -156,24 +168,35 @@ filename += ext
|
|||||||
firmware = "firmware" + ext
|
firmware = "firmware" + ext
|
||||||
|
|
||||||
# Launch CMake
|
# Launch CMake
|
||||||
cmd = "cmake"
|
cmd = ["cmake"]
|
||||||
for opt, value in command_options.items():
|
for opt, value in command_options.items():
|
||||||
cmd += " -D%s=%s" % (opt, value)
|
cmd.append("-D%s=%s" % (opt, value))
|
||||||
cmd += " " + srcdir
|
|
||||||
if "OPENTX_VERSION_SUFFIX" in os.environ:
|
if "OPENTX_VERSION_SUFFIX" in os.environ:
|
||||||
cmd += ' -DVERSION_SUFFIX="%s"' % os.environ["OPENTX_VERSION_SUFFIX"]
|
cmd.append('-DVERSION_SUFFIX="%s"' % os.environ["OPENTX_VERSION_SUFFIX"])
|
||||||
print cmd
|
cmd.append(srcdir)
|
||||||
os.system(cmd)
|
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
output, error = proc.communicate()
|
||||||
|
if proc.returncode != 0:
|
||||||
|
file("%s.err" % filename, "w").write(output + error)
|
||||||
|
exit(COMPILATION_ERROR)
|
||||||
|
|
||||||
# Launch make firmware
|
# Launch make firmware
|
||||||
cmd = "make firmware"
|
cmd = ["make", "firmware"]
|
||||||
os.system(cmd)
|
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
output, error = proc.communicate()
|
||||||
|
if proc.returncode != 0:
|
||||||
|
file("%s.err" % filename, "w").write(output + error)
|
||||||
|
exit(COMPILATION_ERROR)
|
||||||
|
|
||||||
# Check binary size
|
# Check binary size
|
||||||
if board_family == BOARD_FAMILY_ARM:
|
if board_family == BOARD_FAMILY_ARM:
|
||||||
size = os.stat(firmware).st_size
|
size = os.stat(firmware).st_size
|
||||||
else:
|
else:
|
||||||
os.system("avr-size -A %s | grep Total | cut -f2- -d \" \" > ./size" % firmware)
|
size = subprocess.check_output('avr-size -A %s | grep Total | cut -f2- -d " "' % firmware, shell=True)
|
||||||
size = file("./size").read().strip()
|
size = int(size.strip())
|
||||||
if int(size) > maxsize:
|
if size > maxsize:
|
||||||
exit("Invalid size")
|
exit(FIRMWARE_SIZE_TOO_BIG)
|
||||||
|
|
||||||
|
# Copy binary to the binaries directory
|
||||||
|
shutil.copyfile(firmware, filename)
|
||||||
|
print filename
|
||||||
|
|||||||
Reference in New Issue
Block a user