|
| 1 | +# Copyright 2024 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=8 |
| 5 | +# NOTE: dawn seems to have angle as a submodule, causing a circular dependency. gclient resolves this but we don't use it to keep the network sandbox. |
| 6 | +# NOTE: lunarg-vulkantools doesn't have HEAD and I don't know how to fetch that, but apparently we don't need it to get Ladybird running. |
| 7 | + |
| 8 | +DESCRIPTION="ANGLE - Almost Native Graphics Layer Engine, translates OpenGL ES API calls to various hardware-supported graphics APIs like Vulkan, DirectX, and OpenGL." |
| 9 | +HOMEPAGE="https://angleproject.org" |
| 10 | + |
| 11 | +# TODO: get working with clang |
| 12 | +# LLVM_COMPAT=( 18 19 ) |
| 13 | +# LLVM_OPTIONAL=1 |
| 14 | +inherit git-r3 |
| 15 | +# inherit git-r3 llvm-r1 |
| 16 | + |
| 17 | +EGIT_LFS=1 |
| 18 | +EGIT_REPO_URI="https://chromium.googlesource.com/angle/angle.git" |
| 19 | +EGIT_BRANCH="main" |
| 20 | +EGIT_COMMIT="ec2a04cc9535607a209989e093254d1290d0d2f5" |
| 21 | + |
| 22 | +# Not using submodule for jsoncpp, see repo:angle/DEPS for the reason |
| 23 | +SRC_URI="https://github.com/open-source-parsers/jsoncpp/archive/refs/tags/1.9.6.tar.gz -> jsoncpp-1.9.6.tar.gz" |
| 24 | + |
| 25 | +# TODO: which license? |
| 26 | +# LICENSE="BSD-3-Clause" # Vulkan Memory Allocator is MIT |
| 27 | +LICENSE="BSD" # Vulkan Memory Allocator is MIT |
| 28 | +SLOT="${PV}" |
| 29 | +KEYWORDS="~amd64" |
| 30 | +CXX_FLAGS="-std=c++17" |
| 31 | + |
| 32 | +# TODO: no clue if this is correct |
| 33 | +# x11-libs/libX11 |
| 34 | +# x11-libs/libXext |
| 35 | +# virtual/opengl |
| 36 | +# dev-cpp/abseil-cpp |
| 37 | +DEPEND="" |
| 38 | +# dev-util/vulkan-headers |
| 39 | +# vulkan? ( media-libs/vulkan-loader ) |
| 40 | +RDEPEND="${DEPEND}" |
| 41 | +BDEPEND=" |
| 42 | + dev-build/gn |
| 43 | +" |
| 44 | +# clang? ( |
| 45 | +# $(llvm_gen_dep ' |
| 46 | +# llvm-core/clang:${LLVM_SLOT}= |
| 47 | +# llvm-core/llvm:${LLVM_SLOT}= |
| 48 | +# ') |
| 49 | +# ) |
| 50 | + |
| 51 | +# IUSE="clang vulkan" |
| 52 | +IUSE="vulkan" |
| 53 | +# Set submodules manually |
| 54 | +EGIT_SUBMODULES=() |
| 55 | + |
| 56 | +src_unpack() { |
| 57 | + EGIT_SUBMODULES=( |
| 58 | + # Core dependencies |
| 59 | + "build" |
| 60 | + "testing" |
| 61 | + "third_party/EGL-Registry/src" |
| 62 | + "third_party/OpenCL-CTS/src" |
| 63 | + "third_party/OpenCL-Docs/src" |
| 64 | + "third_party/OpenCL-ICD-Loader/src" |
| 65 | + "third_party/OpenGL-Registry/src" |
| 66 | + "third_party/Python-Markdown" |
| 67 | + "third_party/SwiftShader" |
| 68 | + "third_party/VK-GL-CTS/src" |
| 69 | + "third_party/abseil-cpp" |
| 70 | + "third_party/astc-encoder/src" |
| 71 | + "third_party/catapult" |
| 72 | + "third_party/cherry" |
| 73 | + "third_party/cpu_features/src" |
| 74 | + "third_party/flac" |
| 75 | + "third_party/flatbuffers/src" |
| 76 | + "third_party/glslang/src" |
| 77 | + "third_party/googletest" |
| 78 | + "third_party/gtest" |
| 79 | + "third_party/ijar" |
| 80 | + "third_party/jinja2" |
| 81 | + "third_party/jsoncpp" |
| 82 | + "third_party/libc++/src" |
| 83 | + "third_party/libc++abi/src" |
| 84 | + "third_party/libdrm/src" |
| 85 | + "third_party/libjpeg_turbo" |
| 86 | + "third_party/libpng/src" |
| 87 | + "third_party/libunwind/src" |
| 88 | + "third_party/llvm/src" |
| 89 | + "third_party/markupsafe" |
| 90 | + "third_party/nasm" |
| 91 | + "third_party/protobuf" |
| 92 | + "third_party/rapidjson/src" |
| 93 | + "third_party/re2/src" |
| 94 | + "third_party/rust" |
| 95 | + "third_party/spirv-cross/src" |
| 96 | + "third_party/spirv-headers/src" |
| 97 | + "third_party/spirv-tools/src" |
| 98 | + "third_party/vulkan-headers/src" |
| 99 | + "third_party/zlib" |
| 100 | + |
| 101 | + # Tools |
| 102 | + "tools/mb" |
| 103 | + "tools/protoc_wrapper" |
| 104 | + "tools/rust" |
| 105 | + ) |
| 106 | + |
| 107 | + if use vulkan ; then |
| 108 | + EGIT_SUBMODULES+=( |
| 109 | + "third_party/vulkan_memory_allocator" |
| 110 | + "third_party/vulkan-loader/src" |
| 111 | + "third_party/vulkan-tools/src" |
| 112 | + ) |
| 113 | + fi |
| 114 | + # if use clang ; then |
| 115 | + # EGIT_SUBMODULES+=( |
| 116 | + # "third_party/llvm/src" |
| 117 | + # ) |
| 118 | + # fi |
| 119 | + git-r3_fetch |
| 120 | + git-r3_checkout |
| 121 | +} |
| 122 | + |
| 123 | +src_prepare() { |
| 124 | + echo starting src_prepare |
| 125 | + echo CURDIR: $PWD |
| 126 | + |
| 127 | + eapply -p0 "${FILESDIR}"/7287-sysroot.gni.patch |
| 128 | + eapply -p0 "${FILESDIR}"/7287-test.gni.patch |
| 129 | + eapply -p0 "${FILESDIR}"/7287-config.BUILD.gn.patch |
| 130 | + eapply_user |
| 131 | + |
| 132 | + echo Removing gclient |
| 133 | + find -type f -name "*.gn*" | xargs sed -i 's/\(^import.*gclient_args.gni.*\)/# NO GCLIENT \1/' |
| 134 | + |
| 135 | + unpack jsoncpp-1.9.6.tar.gz |
| 136 | + rsync -a jsoncpp-1.9.6/ third_party/jsoncpp/source || die "moving jsoncpp failed" |
| 137 | +} |
| 138 | + |
| 139 | +src_configure() { |
| 140 | + # is_clang=$(usex clang 'true' 'false') |
| 141 | + local angle_args=" |
| 142 | + angle_build_tests=false |
| 143 | + angle_enable_renderdoc=false |
| 144 | + angle_enable_swiftshader=false |
| 145 | + angle_enable_vulkan=$(usex vulkan 'true' 'false') |
| 146 | + angle_enable_wgpu=false |
| 147 | + angle_expose_non_conformant_extensions_and_versions=true |
| 148 | + angle_use_wayland=true |
| 149 | + angle_use_x11=false |
| 150 | + build_angle_deqp_tests=false |
| 151 | + chrome_pgo_phase=0 |
| 152 | + is_cfi=false |
| 153 | + is_component_build=true |
| 154 | + is_debug=false |
| 155 | + is_official_build=true |
| 156 | + is_clang=false |
| 157 | + use_custom_libcxx=false |
| 158 | + use_safe_libstdcxx=true |
| 159 | + use_sysroot=false |
| 160 | + install_prefix=\"${D}/usr\" |
| 161 | + " |
| 162 | + |
| 163 | + # if use clang ; then |
| 164 | + # _LL_BIN="/usr/lib/llvm/${LLVM_SLOT}/bin/" |
| 165 | + # export CC="${_LL_BIN}clang" |
| 166 | + # export CXX="${_LL_BIN}clang++" |
| 167 | + # angle_args+="cc=\"${CC}\" cxx=\"${CXX}\" " |
| 168 | + # fi |
| 169 | + |
| 170 | + gn gen out --args="${angle_args}" || die "gn failed" |
| 171 | +} |
| 172 | +# src_compile() { |
| 173 | +# } |
| 174 | + |
| 175 | +src_install() { |
| 176 | + default |
| 177 | + ninja -C out install_angle zlib |
| 178 | + # Move to Gentoo's standard pkgconfig location |
| 179 | + dodir /usr/share/pkgconfig |
| 180 | + # Avoid collision with e.g. /usr/lib64/pkgconfig/glesv2.pc |
| 181 | + # I tried doing this with PKG_CONFIG_PATH but couldn't get it to work. |
| 182 | + # CMake would just default to /usr/lib64/pkgconfig/glesv2.pc |
| 183 | + for file in "${D}"/usr/lib/pkgconfig/*.pc |
| 184 | + do |
| 185 | + mv $file "${D}"/usr/share/pkgconfig/angle_$(basename $file) |
| 186 | + done |
| 187 | + |
| 188 | + rm -rf "${D}"/usr/lib/pkgconfig |
| 189 | + # Fix install_prefix paths |
| 190 | + sed -i -E "s@/var/tmp/portage/media-libs/${PN}-[0-9]{4}/image@@g" "${D}"/usr/share/pkgconfig/*.pc |
| 191 | + sed -i -E "s@libdir=.*@libdir=\${prefix}/$(get_libdir)/${PN}@g" "${D}"/usr/share/pkgconfig/*.pc |
| 192 | + sed -i -E "s@includedir=.*@includedir=\${prefix}/include/${PN}@g" "${D}"/usr/share/pkgconfig/*.pc |
| 193 | + # fix multilib |
| 194 | + dodir /usr/$(get_libdir)/${PN} |
| 195 | + rsync --remove-source-files -aq "${D}"/usr/lib/ "${D}"/usr/$(get_libdir)/${PN} |
| 196 | + rm -rf "${D}"/usr/lib |
| 197 | + # avoid collisions with libglvnd and mesa |
| 198 | + mv "${D}"/usr/include "${D}"/${PN} |
| 199 | + dodir /usr/include/${PN} |
| 200 | + mv "${D}"/${PN} "${D}"/usr/include |
| 201 | + |
| 202 | + # Ladybird doesn't start without this. Skipped the related install sript. |
| 203 | + dolib.so "out/libchrome_zlib.so" |
| 204 | + # if use vulkan ; then |
| 205 | + # dolib.so "out/libVkICD_mock_icd.so" |
| 206 | + # dolib.so "out/libvulkan.so.1" |
| 207 | + # fi |
| 208 | + |
| 209 | + # make normal archives instead of thin ones |
| 210 | + ar rcs "${D}"/usr/$(get_libdir)/libangle_common.a ./out/obj/angle_common/*.o |
| 211 | + ar rcs "${D}"/usr/$(get_libdir)/libtranslator.a ./out/obj/translator/*.o |
| 212 | + ar rcs "${D}"/usr/$(get_libdir)/libangle_image_util.a ./out/obj/angle_image_util/*.o |
| 213 | + ar rcs "${D}"/usr/$(get_libdir)/libpreprocessor.a ./out/obj/preprocessor/*.o |
| 214 | + ar rcs "${D}"/usr/$(get_libdir)/libangle_gpu_info_util.a ./out/obj/angle_gpu_info_util/*.o |
| 215 | + ar rcs "${D}"/usr/$(get_libdir)/libangle_common_shader_state.a ./out/obj/angle_common_shader_state/*.o |
| 216 | + |
| 217 | + dodir /usr/share/pkgconfig |
| 218 | + cat > "${D}/usr/share/pkgconfig/angle.pc"<<EOF |
| 219 | +prefix=/usr/$(get_libdir) |
| 220 | +includedir=/usr/include/${PN} |
| 221 | +
|
| 222 | +Name: angle |
| 223 | +Description: ${DESCRIPTION} |
| 224 | +Version: ${PV} |
| 225 | +Cflags: -I\${includedir} |
| 226 | +Libs: -L\${prefix} -langle_common |
| 227 | +EOF |
| 228 | +} |
0 commit comments