1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-26 09:45:21 +03:00

Now we will try to build simulators the same way

This commit is contained in:
Bertrand Songis 2016-03-25 22:50:45 +01:00
parent 69fc1b9354
commit 47f083e1c8
2 changed files with 33 additions and 28 deletions

View file

@ -8,15 +8,14 @@ add_definitions(-DSIMU)
remove_definitions(-DCLI) remove_definitions(-DCLI)
if(Qt5Widgets_FOUND) if(Qt5Widgets_FOUND)
string(TOLOWER ${TRANSLATIONS} TRANSLATION_LOWERCASE) set(SIMULATOR_FLAVOUR opentx-${FLAVOUR})
set(SIMULATOR_FLAVOUR opentx-${FLAVOUR}-${TRANSLATION_LOWERCASE})
set(SIMULATOR_TARGET ${SIMULATOR_FLAVOUR}-simulator) set(SIMULATOR_TARGET ${SIMULATOR_FLAVOUR}-simulator)
add_definitions(-DSIMULATOR_FLAVOUR="${SIMULATOR_FLAVOUR}") add_definitions(-DSIMULATOR_FLAVOUR="${SIMULATOR_FLAVOUR}")
include_directories(${COMPANION_SRC_DIRECTORY} ${COMPANION_SRC_DIRECTORY}/simulation) include_directories(${COMPANION_SRC_DIRECTORY} ${COMPANION_SRC_DIRECTORY}/simulation)
add_library(${SIMULATOR_TARGET} SHARED ${SIMU_SRC} opentxsimulator.cpp) add_library(${SIMULATOR_TARGET} SHARED ${SIMU_SRC} opentxsimulator.cpp)
add_dependencies(${SIMULATOR_TARGET} ${FIRMWARE_DEPENDENCIES}) add_dependencies(${SIMULATOR_TARGET} ${FIRMWARE_DEPENDENCIES})
qt5_use_modules(${SIMULATOR_TARGET} Core) qt5_use_modules(${SIMULATOR_TARGET} Core)
add_custom_target(opentx-simulator DEPENDS ${SIMULATOR_TARGET}) add_custom_target(libsimulator DEPENDS ${SIMULATOR_TARGET})
endif() endif()
if(MSVC) if(MSVC)

View file

@ -24,20 +24,18 @@ BOARD_HORUS = 4
BOARD_FAMILY_AVR = 0 BOARD_FAMILY_AVR = 0
BOARD_FAMILY_ARM = 1 BOARD_FAMILY_ARM = 1
if len(sys.argv) != 2: if len(sys.argv) != 3:
exit(INVALID_FIRMWARE) exit(INVALID_FIRMWARE)
srcdir = os.path.dirname(os.path.realpath(__file__)) + "/../.." what = sys.argv[1]
directory, filename = os.path.split(sys.argv[1]) directory, filename = os.path.split(sys.argv[2])
root, ext = os.path.splitext(filename) root, ext = os.path.splitext(filename)
options = root.split("-") options = root.split("-")
if len(options) < 2 or options[0] != "opentx": if len(options) < 2 or options[0] != "opentx":
exit(INVALID_FIRMWARE) exit(INVALID_FIRMWARE)
filename = "opentx-"
optcount = 1 optcount = 1
command_options = {} command_options = {}
if options[optcount] == "9x": if options[optcount] == "9x":
@ -130,7 +128,19 @@ elif options[optcount] == "horus":
else: else:
exit(INVALID_BOARD) exit(INVALID_BOARD)
filename += options[optcount] if what == "firmware":
if board_family == BOARD_FAMILY_ARM:
ext = ".bin"
else:
ext = ".hex"
target = "firmware" + ext
filename = "opentx"
elif what == "libsimulator":
ext = ".so"
target = "libopentx-" + options[optcount] + "-simulator.so"
filename = "libopentx"
filename += "-" + options[optcount]
optcount += 1 optcount += 1
# The firmware options # The firmware options
@ -158,15 +168,9 @@ for key in languages:
if not language: if not language:
exit(INVALID_LANGUAGE) exit(INVALID_LANGUAGE)
command_options["TRANSLATIONS"] = language.upper() command_options["TRANSLATIONS"] = language.upper()
filename += "-" + language
if board_family == BOARD_FAMILY_ARM:
ext = ".bin"
else:
ext = ".hex"
filename += ext
firmware = "firmware" + 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" outpath = path + ".out"
errpath = path + ".err" errpath = path + ".err"
@ -190,8 +194,8 @@ if not os.path.isfile(path):
file(errpath, "w").write(output + error) file(errpath, "w").write(output + error)
exit(COMPILATION_ERROR) exit(COMPILATION_ERROR)
# Launch make firmware # Launch make
cmd = ["make", "firmware"] cmd = ["make", what]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = proc.communicate() output, error = proc.communicate()
if proc.returncode == 0: if proc.returncode == 0:
@ -200,17 +204,19 @@ if not os.path.isfile(path):
file(errpath, "w").write(output + error) file(errpath, "w").write(output + error)
exit(COMPILATION_ERROR) exit(COMPILATION_ERROR)
# Check binary size if what == "firmware":
if board_family == BOARD_FAMILY_ARM: # Check binary size
size = os.stat(firmware).st_size if board_family == BOARD_FAMILY_ARM:
else: size = os.stat(firmware).st_size
size = subprocess.check_output('avr-size -A %s | grep Total | cut -f2- -d " "' % firmware, shell=True) else:
size = int(size.strip()) size = subprocess.check_output('avr-size -A %s | grep Total | cut -f2- -d " "' % firmware, shell=True)
if size > maxsize: size = int(size.strip())
exit(FIRMWARE_SIZE_TOO_BIG) if size > maxsize:
exit(FIRMWARE_SIZE_TOO_BIG)
# Copy binary to the binaries directory # Copy binary to the binaries directory
shutil.copyfile(firmware, path) shutil.copyfile(target, path)
print filename print filename
exit(0) exit(0)