-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #324717 from ExpidusOS/fix/flutter-engine
flutterPackages-source: disable old version sources, fix update hashes
- Loading branch information
Showing
14 changed files
with
255 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,48 @@ | ||
{ lib, targetPlatform }: | ||
rec { | ||
os = | ||
if targetPlatform.isLinux then | ||
"linux" | ||
else if targetPlatform.isDarwin then | ||
"macos" | ||
else if targetPlatform.isWindows then | ||
"windows" | ||
else | ||
throw "Unsupported OS \"${targetPlatform.parsed.kernel.name}\""; | ||
{ lib, platform }: | ||
let | ||
self = { | ||
os = | ||
if platform.isLinux then | ||
"linux" | ||
else if platform.isDarwin then | ||
"macos" | ||
else if platform.isWindows then | ||
"windows" | ||
else | ||
throw "Unsupported OS \"${platform.parsed.kernel.name}\""; | ||
|
||
arch = | ||
if targetPlatform.isx86_64 then | ||
"amd64" | ||
else if targetPlatform.isx86 && targetPlatform.is32bit then | ||
"386" | ||
else if targetPlatform.isAarch64 then | ||
"arm64" | ||
else if targetPlatform.isMips && targetPlatform.parsed.cpu.significantByte == "littleEndian" then | ||
"mipsle" | ||
else if targetPlatform.isMips64 then | ||
"mips64${lib.optionalString (targetPlatform.parsed.cpu.significantByte == "littleEndian") "le"}" | ||
else if targetPlatform.isPower64 then | ||
"ppc64${lib.optionalString (targetPlatform.parsed.cpu.significantByte == "littleEndian") "le"}" | ||
else if targetPlatform.isS390x then | ||
"s390x" | ||
else | ||
throw "Unsupported CPU \"${targetPlatform.parsed.cpu.name}\""; | ||
alt-os = if platform.isDarwin then "mac" else self.os; | ||
|
||
alt-arch = | ||
if targetPlatform.isx86_64 then | ||
"x64" | ||
else if targetPlatform.isAarch64 then | ||
"arm64" | ||
else | ||
targetPlatform.parsed.cpu.name; | ||
arch = | ||
if platform.isx86_64 then | ||
"amd64" | ||
else if platform.isx86 && platform.is32bit then | ||
"386" | ||
else if platform.isAarch64 then | ||
"arm64" | ||
else if platform.isMips && platform.parsed.cpu.significantByte == "littleEndian" then | ||
"mipsle" | ||
else if platform.isMips64 then | ||
"mips64${lib.optionalString (platform.parsed.cpu.significantByte == "littleEndian") "le"}" | ||
else if platform.isPower64 then | ||
"ppc64${lib.optionalString (platform.parsed.cpu.significantByte == "littleEndian") "le"}" | ||
else if platform.isS390x then | ||
"s390x" | ||
else if platform.isRiscV64 then | ||
"riscv64" | ||
else | ||
throw "Unsupported CPU \"${platform.parsed.cpu.name}\""; | ||
|
||
platform = "${os}-${arch}"; | ||
alt-platform = "${os}-${alt-arch}"; | ||
} | ||
alt-arch = | ||
if platform.isx86_64 then | ||
"x64" | ||
else if platform.isAarch64 then | ||
"arm64" | ||
else | ||
platform.parsed.cpu.name; | ||
|
||
platform = "${self.os}-${self.arch}"; | ||
alt-platform = "${self.os}-${self.alt-arch}"; | ||
}; | ||
in | ||
self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,11 @@ | |
writeText, | ||
symlinkJoin, | ||
targetPlatform, | ||
hostPlatform, | ||
buildPlatform, | ||
darwin, | ||
clang, | ||
llvm, | ||
tools ? callPackage ./tools.nix { inherit hostPlatform; }, | ||
tools ? callPackage ./tools.nix { inherit buildPlatform; }, | ||
stdenv, | ||
stdenvNoCC, | ||
dart, | ||
|
@@ -33,7 +33,8 @@ | |
gtk3, | ||
pkg-config, | ||
ninja, | ||
python3, | ||
python312, | ||
python39, | ||
git, | ||
version, | ||
flutterVersion, | ||
|
@@ -44,22 +45,27 @@ | |
patches, | ||
url, | ||
runtimeMode ? "release", | ||
isOptimized ? true, | ||
isOptimized ? runtimeMode != "debug", | ||
}: | ||
let | ||
expandSingleDep = | ||
dep: lib.optionals (lib.isDerivation dep) ([ dep ] ++ map (output: dep.${output}) dep.outputs); | ||
|
||
expandDeps = deps: lib.flatten (map expandSingleDep deps); | ||
|
||
constants = callPackage ./constants.nix { inherit targetPlatform; }; | ||
constants = callPackage ./constants.nix { platform = targetPlatform; }; | ||
|
||
python3 = if lib.versionAtLeast flutterVersion "3.20" then python312 else python39; | ||
|
||
src = callPackage ./source.nix { | ||
inherit | ||
tools | ||
flutterVersion | ||
version | ||
hashes | ||
url | ||
targetPlatform | ||
buildPlatform | ||
; | ||
}; | ||
|
||
|
@@ -81,9 +87,11 @@ let | |
]; | ||
}; | ||
|
||
outName = "host_${runtimeMode}${lib.optionalString (!isOptimized) "_unopt --unoptimized"}"; | ||
outName = "host_${runtimeMode}${lib.optionalString (!isOptimized) "_unopt"}"; | ||
|
||
dartPath = "${if (lib.versionAtLeast flutterVersion "3.23") then "flutter/third_party" else "third_party"}/dart"; | ||
dartPath = "${ | ||
if (lib.versionAtLeast flutterVersion "3.23") then "flutter/third_party" else "third_party" | ||
}/dart"; | ||
in | ||
stdenv.mkDerivation (finalAttrs: { | ||
pname = "flutter-engine-${runtimeMode}${lib.optionalString (!isOptimized) "-unopt"}"; | ||
|
@@ -95,7 +103,11 @@ stdenv.mkDerivation (finalAttrs: { | |
dartSdkVersion | ||
src | ||
outName | ||
swiftshader; | ||
swiftshader | ||
; | ||
|
||
setOutputFlags = false; | ||
doStrip = isOptimized; | ||
|
||
toolchain = symlinkJoin { | ||
name = "flutter-engine-toolchain-${version}"; | ||
|
@@ -145,9 +157,14 @@ stdenv.mkDerivation (finalAttrs: { | |
''; | ||
}; | ||
|
||
NIX_CFLAGS_COMPILE = "-I${finalAttrs.toolchain}/include"; | ||
NIX_CFLAGS_COMPILE = [ | ||
"-I${finalAttrs.toolchain}/include" | ||
] ++ lib.optional (!isOptimized) "-U_FORTIFY_SOURCE"; | ||
|
||
nativeCheckInputs = lib.optionals stdenv.isLinux [ xorg.xorgserver openbox ]; | ||
nativeCheckInputs = lib.optionals stdenv.isLinux [ | ||
xorg.xorgserver | ||
openbox | ||
]; | ||
|
||
nativeBuildInputs = | ||
[ | ||
|
@@ -168,10 +185,7 @@ stdenv.mkDerivation (finalAttrs: { | |
|
||
buildInputs = [ gtk3 ]; | ||
|
||
patchtools = [ | ||
"${dartPath}/tools/sdks/dart-sdk/bin/dart" | ||
"flutter/third_party/gn/gn" | ||
]; | ||
patchtools = [ "flutter/third_party/gn/gn" ]; | ||
|
||
dontPatch = true; | ||
|
||
|
@@ -194,6 +208,10 @@ stdenv.mkDerivation (finalAttrs: { | |
mkdir -p src/flutter/buildtools/${constants.alt-platform} | ||
ln -s ${llvm} src/flutter/buildtools/${constants.alt-platform}/clang | ||
mkdir -p src/buildtools/${constants.alt-platform} | ||
ln -s ${llvm} src/buildtools/${constants.alt-platform}/clang | ||
mkdir -p src/${dartPath}/tools/sdks | ||
ln -s ${dart} src/${dartPath}/tools/sdks/dart-sdk | ||
${lib.optionalString (stdenv.isLinux) '' | ||
|
@@ -204,13 +222,12 @@ stdenv.mkDerivation (finalAttrs: { | |
for dir in ''${patchgit[@]}; do | ||
pushd src/$dir | ||
rev=$(cat .git/HEAD) | ||
rm -rf .git | ||
git init | ||
git add . | ||
git config user.name "nobody" | ||
git config user.email "[email protected]" | ||
git commit -a -m "$rev" --quiet | ||
git commit -a -m "$dir" --quiet | ||
popd | ||
done | ||
|
@@ -239,7 +256,9 @@ stdenv.mkDerivation (finalAttrs: { | |
++ lib.optionals (targetPlatform.isx86_64 == false) [ | ||
"--linux" | ||
"--linux-cpu ${constants.alt-arch}" | ||
]; | ||
] | ||
++ lib.optional (!isOptimized) "--unoptimized" | ||
++ lib.optional (runtimeMode == "debug") "--no-stripped"; | ||
|
||
# NOTE: Once https://github.com/flutter/flutter/issues/127606 is fixed, use "--no-prebuilt-dart-sdk" | ||
configurePhase = | ||
|
@@ -267,22 +286,9 @@ stdenv.mkDerivation (finalAttrs: { | |
runHook preBuild | ||
export TERM=dumb | ||
for tool in flatc scenec gen_snapshot dart impellerc shader_archiver gen_snapshot_product; do | ||
ninja -C $out/out/$outName -j$NIX_BUILD_CORES $tool | ||
${lib.optionalString (stdenv.isLinux) '' | ||
patchelf $out/out/$outName/$tool --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) | ||
''} | ||
done | ||
ninja -C $out/out/$outName -j$NIX_BUILD_CORES | ||
${lib.optionalString (stdenv.isLinux) '' | ||
patchelf $out/out/$outName/dart-sdk/bin/dartaotruntime \ | ||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) | ||
find $out/out/$outName/exe.unstripped -executable -type f -exec patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) {} \; | ||
''} | ||
runHook postBuild | ||
''; | ||
|
||
|
@@ -323,5 +329,5 @@ stdenv.mkDerivation (finalAttrs: { | |
"x86_64-darwin" | ||
"aarch64-darwin" | ||
]; | ||
}; | ||
} // lib.optionalAttrs (lib.versionOlder flutterVersion "3.22") { hydraPlatforms = [ ]; }; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.