at master 191 lines 4.9 kB view raw
1{ 2 stdenv, 3 gn, 4 ninja, 5 llvmPackages_21, 6 gclient2nix, 7 pkg-config, 8 glib, 9 python3, 10 symlinkJoin, 11 lib, 12 xorg, 13 wayland, 14 pciutils, 15 libGL, 16 apple-sdk_15, 17 xcbuild, 18}: 19let 20 llvmPackages = llvmPackages_21; 21 llvmMajorVersion = lib.versions.major llvmPackages.llvm.version; 22 arch = stdenv.hostPlatform.parsed.cpu.name; 23 triplet = lib.getAttr arch { 24 "x86_64" = "x86_64-unknown-linux-gnu"; 25 "aarch64" = "aarch64-unknown-linux-gnu"; 26 }; 27 28 clang = symlinkJoin { 29 name = "angle-clang-llvm-join"; 30 paths = [ 31 llvmPackages.llvm 32 llvmPackages.clang 33 ]; 34 postBuild = 35 if stdenv.isDarwin then 36 '' 37 mkdir -p $out/lib/clang/${llvmMajorVersion}/lib/darwin 38 ln -s $out/resource-root/lib/darwin/libclang_rt.osx.a \ 39 $out/lib/clang/${llvmMajorVersion}/lib/darwin/libclang_rt.osx.a 40 ln -s $out/resource-root/lib/darwin/libclang_rt.osx.a \ 41 $out/lib/clang/${llvmMajorVersion}/lib/darwin/libclang_rt.osx-${arch}.a 42 '' 43 else 44 '' 45 mkdir -p $out/lib/clang/${llvmMajorVersion}/lib/ 46 ln -s $out/resource-root/lib/linux \ 47 $out/lib/clang/${llvmMajorVersion}/lib/${triplet} 48 ''; 49 }; 50in 51stdenv.mkDerivation (finalAttrs: { 52 pname = "angle"; 53 version = "7258"; 54 55 gclientDeps = gclient2nix.importGclientDeps ./info.json; 56 sourceRoot = "src"; 57 strictDeps = true; 58 59 nativeBuildInputs = [ 60 gn 61 ninja 62 gclient2nix.gclientUnpackHook 63 pkg-config 64 python3 65 llvmPackages.bintools 66 ] 67 ++ lib.optionals stdenv.isDarwin [ 68 xcbuild 69 ]; 70 71 buildInputs = 72 lib.optionals stdenv.isLinux [ 73 glib 74 xorg.libxcb.dev 75 xorg.libX11.dev 76 xorg.libXext.dev 77 xorg.libXi 78 wayland.dev 79 pciutils 80 libGL 81 ] 82 ++ lib.optionals stdenv.isDarwin [ 83 apple-sdk_15 84 ]; 85 86 gnFlags = [ 87 "is_debug=false" 88 "use_sysroot=false" 89 "clang_base_path=\"${clang}\"" 90 "angle_build_tests=false" 91 "concurrent_links=1" 92 "use_custom_libcxx=true" 93 "angle_enable_swiftshader=false" 94 "angle_enable_wgpu=false" 95 # On darwin during linking: 96 # clang++: error: argument unused during compilation: '-stdlib=libc++' 97 "treat_warnings_as_errors=false" 98 ]; 99 100 patches = [ 101 # https://issues.chromium.org/issues/432275627 102 # https://chromium-review.googlesource.com/c/chromium/src/+/6761936/2/build/config/compiler/BUILD.gn 103 ./fix-uninitialized-const-pointer-error-001.patch 104 ]; 105 106 postPatch = '' 107 substituteInPlace build/config/clang/BUILD.gn \ 108 --replace-fail \ 109 "_dir = \"${triplet}\"" \ 110 "_dir = \"${triplet}\" 111 _suffix = \"-${arch}\"" 112 113 # Don't precompile Metal shaders, because the compiler is non-free. 114 substituteInPlace src/libANGLE/renderer/metal/metal_backend.gni \ 115 --replace-fail \ 116 "metal_internal_shader_compilation_supported =" \ 117 "metal_internal_shader_compilation_supported = false &&" 118 119 cat > build/config/gclient_args.gni <<EOF 120 # Generated from 'DEPS' 121 checkout_angle_internal = false 122 checkout_angle_mesa = false 123 checkout_angle_restricted_traces = false 124 generate_location_tags = false 125 EOF 126 127 # For sandboxed build on darwin. 128 patchShebangs build/toolchain/apple 129 ''; 130 131 installPhase = '' 132 runHook preInstall 133 134 install -v -m755 -D \ 135 *${stdenv.hostPlatform.extensions.sharedLibrary}* \ 136 -t "$out/lib" 137 install -v -m755 -D \ 138 angle_shader_translator \ 139 gaussian_distribution_gentables \ 140 -t "$out/bin" 141 142 cp -rv ../../include "$out" 143 144 mkdir -p $out/lib/pkgconfig 145 146 cat > $out/lib/pkgconfig/angle.pc <<EOF 147 prefix=${placeholder "out"} 148 exec_prefix=''${prefix} 149 libdir=''${prefix}/lib 150 includedir=''${prefix}/include 151 152 Name: angle 153 Description: ${finalAttrs.meta.description} 154 155 URL: ${finalAttrs.meta.homepage} 156 Version: ${lib.versions.major finalAttrs.version} 157 Libs: -L''${libdir} -l${ 158 lib.concatStringsSep " -l" [ 159 "EGL" 160 "EGL_vulkan_secondaries" 161 "GLESv1_CM" 162 "GLESv2" 163 "GLESv2_vulkan_secondaries" 164 "GLESv2_with_capture" 165 "VkICD_mock_icd" 166 "feature_support" 167 ] 168 } 169 Cflags: -I''${includedir} 170 EOF 171 172 runHook postInstall 173 ''; 174 175 meta = { 176 description = "Conformant OpenGL ES implementation for Windows, Mac, Linux, iOS and Android"; 177 longDescription = '' 178 The goal of ANGLE is to allow users of multiple operating systems 179 to seamlessly run WebGL and other OpenGL ES content by translating 180 OpenGL ES API calls to one of the hardware-supported APIs available 181 for that platform. 182 ''; 183 homepage = "https://angleproject.org"; 184 maintainers = with lib.maintainers; [ 185 jess 186 jk 187 ]; 188 license = lib.licenses.bsd3; 189 platforms = lib.platforms.linux ++ lib.platforms.darwin; 190 }; 191})