Skip to content

Commit 32f286d

Browse files
authored
edgetx: 2.7.2 -> 2.11.0-rc3, expand build for all targets (#398715)
2 parents ec9ef36 + a5b9b78 commit 32f286d

File tree

5 files changed

+267
-77
lines changed

5 files changed

+267
-77
lines changed

pkgs/applications/misc/edgetx/default.nix

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
diff --git a/radio/util/find_clang.py b/radio/util/find_clang.py
2+
index d9cdbb083..f78f87717 100644
3+
--- a/radio/util/find_clang.py
4+
+++ b/radio/util/find_clang.py
5+
@@ -59,6 +59,7 @@ def getBuiltinHeaderPath(library_path):
6+
return None
7+
8+
def findLibClang():
9+
+ return "@libclang@"
10+
if sys.platform == "darwin":
11+
knownPaths = [
12+
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib",
13+
diff --git a/radio/util/generate_datacopy.py b/radio/util/generate_datacopy.py
14+
index a92b0c3e2..6385b2ff6 100755
15+
--- a/radio/util/generate_datacopy.py
16+
+++ b/radio/util/generate_datacopy.py
17+
@@ -5,7 +5,8 @@ import sys
18+
import clang.cindex
19+
import time
20+
import os
21+
-
22+
+from pathlib import Path
23+
+import re
24+
25+
structs = []
26+
extrastructs = []
27+
@@ -102,6 +103,11 @@ def main():
28+
if find_clang.builtin_hdr_path:
29+
args.append("-I" + find_clang.builtin_hdr_path)
30+
31+
+ args.append("-resource-dir")
32+
+ args.append("@resourceDir@")
33+
+ for path in ["@libc-cflags@", "@libcxx-cflags@"]:
34+
+ args.extend([flag.strip() for flag in re.split(r'\s+', Path(path).read_text()) if flag.strip()])
35+
+
36+
translation_unit = index.parse(sys.argv[1], args)
37+
38+
if translation_unit.diagnostics:

pkgs/by-name/ed/edgetx/package.nix

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
{
2+
lib,
3+
stdenv,
4+
fetchFromGitHub,
5+
python3,
6+
cmake,
7+
ninja,
8+
libsForQt5,
9+
SDL2,
10+
fox_1_6,
11+
replaceVars,
12+
llvmPackages,
13+
dfu-util,
14+
gtest,
15+
miniz,
16+
yaml-cpp,
17+
# List of targets to build simulators for
18+
targetsToBuild ? import ./targets.nix,
19+
}:
20+
21+
let
22+
# Keep in sync with `cmake/FetchMaxLibQt.cmake`.
23+
maxlibqt = fetchFromGitHub {
24+
owner = "edgetx";
25+
repo = "maxLibQt";
26+
rev = "ac1988ffd005cd15a8449b92150ce6c08574a4f1";
27+
hash = "sha256-u8e4qseU0+BJyZkV0JE4sUiXaFeIYvadkMTGXXiE2Kg=";
28+
};
29+
30+
pythonEnv = python3.withPackages (
31+
pyPkgs: with pyPkgs; [
32+
pillow
33+
lz4
34+
jinja2
35+
libclang
36+
]
37+
);
38+
in
39+
40+
stdenv.mkDerivation (finalAttrs: {
41+
pname = "edgetx";
42+
version = "2.11.0-rc3";
43+
44+
src = fetchFromGitHub {
45+
owner = "EdgeTX";
46+
repo = "edgetx";
47+
tag = "v${finalAttrs.version}";
48+
fetchSubmodules = true;
49+
hash = "sha256-ipiGkc+R7/itmnRRrlrc4iXn+fLWm4OKc227NfevFhI=";
50+
};
51+
52+
nativeBuildInputs = [
53+
cmake
54+
ninja
55+
pythonEnv
56+
libsForQt5.qttools
57+
libsForQt5.wrapQtAppsHook
58+
];
59+
60+
buildInputs = [
61+
libsForQt5.qtbase
62+
libsForQt5.qtmultimedia
63+
libsForQt5.qtserialport
64+
SDL2
65+
fox_1_6
66+
];
67+
68+
patches = [
69+
(replaceVars ./0001-libclang-paths.patch (
70+
let
71+
llvmMajor = lib.versions.major llvmPackages.llvm.version;
72+
in
73+
{
74+
resourceDir = "${llvmPackages.clang.cc.lib}/lib/clang/${llvmMajor}";
75+
libclang = "${lib.getLib llvmPackages.libclang}/lib/libclang.so";
76+
libc-cflags = "${llvmPackages.clang}/nix-support/libc-cflags";
77+
libcxx-cflags = "${llvmPackages.clang}/nix-support/libcxx-cxxflags";
78+
}
79+
))
80+
];
81+
82+
postPatch = ''
83+
sed -i companion/src/burnconfigdialog.cpp \
84+
-e 's|/usr/.*bin/dfu-util|${dfu-util}/bin/dfu-util|'
85+
patchShebangs companion/util radio/util
86+
'';
87+
88+
cmakeFlags = [
89+
# Unvendoring these libraries is infeasible. At least lets reuse the same sources.
90+
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_GOOGLETEST" "${gtest.src}")
91+
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_MINIZ" "${miniz.src}")
92+
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_YAML-CPP" "${yaml-cpp.src}")
93+
# Custom library https://github.com/edgetx/maxLibQt.
94+
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_MAXLIBQT" "${maxlibqt}")
95+
(lib.cmakeFeature "DFU_UTIL_ROOT_DIR" "${lib.getBin dfu-util}/bin")
96+
# Superbuild machinery is only getting in the way.
97+
(lib.cmakeBool "EdgeTX_SUPERBUILD" false)
98+
# COMMON_OPTIONS from tools/build-companion.sh.
99+
(lib.cmakeBool "GVARS" true)
100+
(lib.cmakeBool "HELI" true)
101+
(lib.cmakeBool "LUA" true)
102+
# Build companion and not the firmware.
103+
(lib.cmakeBool "NATIVE_BUILD" true)
104+
# file RPATH_CHANGE could not write new RPATH.
105+
(lib.cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
106+
];
107+
108+
env = {
109+
EDGETX_VERSION_SUFFIX = "nixpkgs";
110+
};
111+
112+
dontUseCmakeConfigure = true;
113+
# We invoke cmakeConfigurePhase multiple times, but only need this once.
114+
dontFixCmake = true;
115+
inherit targetsToBuild;
116+
__structuredAttrs = true; # To pass targetsToBuild as an array.
117+
118+
configurePhase = ''
119+
runHook preConfigure
120+
prependToVar cmakeFlags "-GNinja"
121+
fixCmakeFiles .
122+
runHook postConfigure
123+
'';
124+
125+
buildPhase = ''
126+
runHook preBuild
127+
128+
cmakeCommonFlags="$''\{cmakeFlags[@]}"
129+
# This is the most sensible way to convert target name -> cmake options
130+
# aside from manually extracting bash variables from upstream's CI scripts
131+
# and converting that to nix expressions. Let's hope upstream doesn't break
132+
# this file too often.
133+
source $src/tools/build-common.sh
134+
135+
# Yes, this is really how upstream expects packaging to look like ¯\_(ツ)_/¯.
136+
# https://github.com/EdgeTX/edgetx/wiki/Build-Instructions-under-Ubuntu-20.04#building-companion-simulator-and-radio-simulator-libraries
137+
for plugin in "$''\{targetsToBuild[@]''\}"
138+
do
139+
# Variable modified by `get_target_build_options` from build-common.sh.
140+
local BUILD_OPTIONS=""
141+
get_target_build_options "$plugin"
142+
# With each invocation of `cmakeConfigurePhase` `cmakeFlags` gets
143+
# prepended to, so it has to be reset.
144+
cmakeFlags=()
145+
appendToVar cmakeFlags $cmakeCommonFlags $BUILD_OPTIONS
146+
pushd .
147+
cmakeConfigurePhase
148+
ninjaFlags=("libsimulator")
149+
ninjaBuildPhase
150+
rm CMakeCache.txt
151+
popd
152+
done
153+
154+
cmakeConfigurePhase
155+
ninjaFlags=()
156+
ninjaBuildPhase
157+
158+
runHook postBuild
159+
'';
160+
161+
meta = {
162+
description = "EdgeTX Companion transmitter support software";
163+
longDescription = ''
164+
EdgeTX Companion is used for many different tasks like loading EdgeTX
165+
firmware to the radio, backing up model settings, editing settings and
166+
running radio simulators.
167+
'';
168+
mainProgram = "companion" + lib.concatStrings (lib.take 2 (lib.splitVersion finalAttrs.version));
169+
homepage = "https://edgetx.org/";
170+
license = lib.licenses.gpl2Only;
171+
platforms = [
172+
"i686-linux"
173+
"x86_64-linux"
174+
"aarch64-linux"
175+
];
176+
maintainers = with lib.maintainers; [
177+
elitak
178+
lopsided98
179+
wucke13
180+
xokdvium
181+
];
182+
};
183+
})

pkgs/by-name/ed/edgetx/targets.nix

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Keep in sync with tools/build-companion.sh
2+
[
3+
"x9lite"
4+
"x9lites"
5+
"x7"
6+
"x7access"
7+
"t8"
8+
"t12"
9+
"t12max"
10+
"tx12"
11+
"tx12mk2"
12+
"zorro"
13+
"commando8"
14+
"boxer"
15+
"pocket"
16+
"mt12"
17+
"gx12"
18+
"tlite"
19+
"tpro"
20+
"tprov2"
21+
"tpros"
22+
"bumblebee"
23+
"lr3pro"
24+
"t14"
25+
"x9d"
26+
"x9dp"
27+
"x9dp2019"
28+
"x9e"
29+
"xlite"
30+
"xlites"
31+
"nv14"
32+
"el18"
33+
"pl18"
34+
"pl18ev"
35+
"x10"
36+
"x10express"
37+
"x12s"
38+
"t15"
39+
"t16"
40+
"t18"
41+
"t20"
42+
"t20v2"
43+
"tx16s"
44+
"f16"
45+
"v16"
46+
]

pkgs/top-level/all-packages.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15152,8 +15152,6 @@ with pkgs;
1515215152
mopidy-ytmusic
1515315153
;
1515415154

15155-
edgetx = libsForQt5.callPackage ../applications/misc/edgetx { };
15156-
1515715155
mpg123 = callPackage ../applications/audio/mpg123 {
1515815156
inherit (darwin.apple_sdk.frameworks) AudioUnit AudioToolbox;
1515915157
jack = libjack2;

0 commit comments

Comments
 (0)