EAPI=7 PYTHON_COMPAT=( python2_7 ) CHROMIUM_LANGS="am ar bg bn ca cs da de el en-GB es es-419 et fa fi fil fr gu he hi hr hu id it ja kn ko lt lv ml mr ms nb nl pl pt-BR pt-PT ro ru sk sl sr sv sw ta te th tr uk vi zh-CN zh-TW" inherit check-reqs chromium-2 multilib ninja-utils python-any-r1 toolchain-funcs flag-o-matic pax-utils llvm #META VERSION_MAJ="6" VERSION_MIN="1" DESCRIPTION="Cross platform application development framework based on web technologies" HOMEPAGE="https://electronjs.org/" LICENSE="MIT" SLOT="6/1" KEYWORDS="~amd64" IUSE="cups custom-cflags gconf gnome-keyring kerberos proxy pulseaudio +system-ffmpeg +system-libvpx +system-ssl component-build proprietary-codecs jumbo-build tcmalloc +suid debug" REQUIRED_USE="debug? ( component-build )" RESTRICT=" !system-ffmpeg? ( proprietary-codecs? ( bindist ) ) component-build? ( tcmalloc? ( usersandbox ) ) network-sandbox " #DEPS COMMON_DEPEND=" >=app-eselect/eselect-electron-2.2 cups? ( >=net-print/cups-2.2:= ) dev-libs/expat:= dev-libs/glib:2 >=dev-libs/icu-64:= dev-libs/libxml2:=[icu] dev-libs/libxslt:= dev-libs/nspr:= >=dev-libs/nss-3.40.1:= system-ssl? ( >=dev-libs/openssl-1.1.1d-r2:= ) dev-libs/re2:= gconf? ( >=gnome-base/gconf-3.2.6-r4:= ) gnome-keyring? ( >=gnome-base/libgnome-keyring-3.28.2:= ) >=media-libs/alsa-lib-1.1.2:= media-libs/fontconfig:= media-libs/freetype:= >=media-libs/harfbuzz-2.6.1:=[icu] media-libs/libexif:= media-libs/libjpeg-turbo:= media-libs/libpng:= system-libvpx? ( >=media-libs/libvpx-1.8.0:=[postproc,svc] ) >=media-libs/openh264-1.7.0:= pulseaudio? ( media-sound/pulseaudio:= ) system-ffmpeg? ( >=media-video/ffmpeg-4:= || ( media-video/ffmpeg[-samba] >=net-fs/samba-4.8.6-r2[-debug(-)] ) media-libs/opus:= ) >=net-dns/c-ares-1.13.0:= >=net-libs/nghttp2-1.39.2:= net-misc/curl:=[ssl] sys-apps/dbus:= sys-apps/pciutils:= virtual/udev x11-libs/cairo:= x11-libs/gdk-pixbuf:2 x11-libs/gtk+:3[X] x11-libs/libdrm x11-libs/libnotify:= x11-libs/libX11:= x11-libs/libXcomposite:= x11-libs/libXcursor:= x11-libs/libXdamage:= x11-libs/libXext:= x11-libs/libXfixes:= x11-libs/libXi:= x11-libs/libXrandr:= x11-libs/libXrender:= x11-libs/libXScrnSaver:= x11-libs/libXtst:= x11-libs/pango:= app-arch/snappy:= media-libs/flac:= media-libs/libwebp:= sys-libs/zlib:=[minizip] kerberos? ( virtual/krb5 ) sys-libs/libcap:= " RDEPEND="${COMMON_DEPEND} x11-misc/xdg-utils virtual/opengl virtual/ttf-fonts tcmalloc? ( ! /dev/null 2>&1 || die local patchlist=( $(cat "${patchloc}/.patches") ) for file in "${patchlist[@]}";do eapply -p1 "${file/#/${patchloc}/}" || die done popd > /dev/null 2>&1 || die } src_prepare() { python_setup cd "${S}" if ! use proxy;then my_proxy="" else my_proxy="$http_proxy" fi http_proxy="$my_proxy" yarn install || die "Yarn module installation failed" #apply electron patches if declare -p PATCHES | grep -q "^declare -a "; then [[ -n ${PATCHES[@]} ]] && eapply "${PATCHES[@]}" else [[ -n ${PATCHES} ]] && eapply ${PATCHES} fi #apply electron bundled patches do_patches "${CHROMIUM_S}" "${S}/patches/common/chromium" do_patches "${NODE_S}" "${S}/patches/node" do_patches "${FFMPEG_S}" "${S}/patches/common/ffmpeg" do_patches "${BORINGSSL_S}/src" "${S}/patches/common/boringssl" do_patches "${V8_S}" "${S}/patches/common/v8" #ensure node uses the correct v8 rm -r "${NODE_S}/deps/v8" || die ln -s "${CHROMIUM_S}/v8" "${NODE_S}/deps/" || die #setup link to node for chromium mkdir -p "${CHROMIUM_S}/third_party/node/linux/node-linux-x64/bin" || die ln -s "${EPREFIX}/usr/bin/node" "${CHROMIUM_S}/third_party/node/linux/node-linux-x64/bin/node" || die #libs in chromium source tree we need to keep local keeplibs=( base/third_party/cityhash base/third_party/dmg_fp base/third_party/dynamic_annotations base/third_party/icu base/third_party/nspr base/third_party/superfasthash base/third_party/symbolize base/third_party/valgrind base/third_party/xdg_mime base/third_party/xdg_user_dirs buildtools/third_party/libc++ buildtools/third_party/libc++abi chrome/third_party/mozilla_security_manager courgette/third_party net/third_party/mozilla_security_manager net/third_party/nss net/third_party/quic net/third_party/uri_template third_party/abseil-cpp third_party/angle third_party/angle/src/common/third_party/base third_party/angle/src/common/third_party/smhasher third_party/angle/src/common/third_party/xxhash third_party/angle/src/third_party/compiler third_party/angle/src/third_party/libXNVCtrl third_party/angle/src/third_party/trace_event third_party/angle/third_party/glslang third_party/angle/third_party/spirv-headers third_party/angle/third_party/spirv-tools third_party/angle/third_party/vulkan-headers third_party/angle/third_party/vulkan-loader third_party/angle/third_party/vulkan-tools third_party/angle/third_party/vulkan-validation-layers third_party/apple_apsl third_party/axe-core third_party/blink third_party/boringssl third_party/boringssl/src/third_party/fiat third_party/boringssl/src/third_party/sike third_party/boringssl/linux-aarch64/crypto/third_party/sike third_party/boringssl/linux-x86_64/crypto/third_party/sike third_party/breakpad third_party/breakpad/breakpad/src/third_party/curl third_party/brotli third_party/cacheinvalidation third_party/catapult third_party/catapult/common/py_vulcanize/third_party/rcssmin third_party/catapult/common/py_vulcanize/third_party/rjsmin third_party/catapult/third_party/beautifulsoup4 third_party/catapult/third_party/html5lib-python third_party/catapult/third_party/polymer third_party/catapult/third_party/six third_party/catapult/tracing/third_party/d3 third_party/catapult/tracing/third_party/gl-matrix third_party/catapult/tracing/third_party/jszip third_party/catapult/tracing/third_party/mannwhitneyu third_party/catapult/tracing/third_party/oboe third_party/catapult/tracing/third_party/pako third_party/ced third_party/cld_3 third_party/closure_compiler third_party/crashpad third_party/crashpad/crashpad/third_party/lss third_party/crashpad/crashpad/third_party/zlib third_party/crc32c third_party/cros_system_api third_party/dav1d third_party/dawn third_party/depot_tools third_party/devscripts third_party/dom_distiller_js third_party/emoji-segmenter third_party/flatbuffers third_party/flot third_party/freetype third_party/glslang third_party/google_input_tools third_party/google_input_tools/third_party/closure_library third_party/google_input_tools/third_party/closure_library/third_party/closure third_party/googletest third_party/hunspell third_party/iccjpeg third_party/inspector_protocol third_party/jinja2 third_party/jsoncpp third_party/jstemplate third_party/khronos third_party/leveldatabase third_party/libXNVCtrl third_party/libaddressinput third_party/libaom third_party/libaom/source/libaom/third_party/vector third_party/libaom/source/libaom/third_party/x86inc third_party/libjingle third_party/libphonenumber third_party/libsecret third_party/libsrtp third_party/libsync third_party/libudev third_party/libwebm third_party/libxml/chromium third_party/libyuv third_party/llvm third_party/lss third_party/lzma_sdk third_party/markupsafe third_party/mesa third_party/metrics_proto third_party/modp_b64 third_party/nasm third_party/node third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2 third_party/openscreen third_party/openscreen/src/third_party/tinycbor/src/src third_party/ots third_party/pdfium third_party/pdfium/third_party/agg23 third_party/pdfium/third_party/base third_party/pdfium/third_party/bigint third_party/pdfium/third_party/freetype third_party/pdfium/third_party/lcms third_party/pdfium/third_party/libopenjpeg20 third_party/pdfium/third_party/libpng16 third_party/pdfium/third_party/libtiff third_party/pdfium/third_party/skia_shared third_party/perfetto third_party/pffft third_party/ply third_party/polymer third_party/protobuf third_party/protobuf/third_party/six third_party/pyjson5 third_party/qcms third_party/rnnoise third_party/s2cellid third_party/sfntly third_party/simplejson third_party/skia third_party/skia/include/third_party/skcms third_party/skia/include/third_party/vulkan third_party/skia/third_party/gif third_party/skia/third_party/skcms third_party/skia/third_party/vulkan third_party/smhasher third_party/spirv-headers third_party/SPIRV-Tools third_party/sqlite third_party/swiftshader third_party/swiftshader/third_party/llvm-7.0 third_party/swiftshader/third_party/llvm-subzero third_party/swiftshader/third_party/subzero third_party/swiftshader/third_party/SPIRV-Headers/include/spirv/unified1 third_party/unrar third_party/usrsctp third_party/vulkan third_party/web-animations-js third_party/webdriver third_party/webrtc third_party/webrtc/common_audio/third_party/fft4g third_party/webrtc/common_audio/third_party/spl_sqrt_floor third_party/webrtc/modules/third_party/fft third_party/webrtc/modules/third_party/g711 third_party/webrtc/modules/third_party/g722 third_party/webrtc/rtc_base/third_party/base64 third_party/webrtc/rtc_base/third_party/sigslot third_party/widevine third_party/woff2 third_party/zlib/google url/third_party/mozilla v8/src/third_party/siphash v8/src/third_party/valgrind v8/src/third_party/utf8-decoder v8/third_party/inspector_protocol v8/third_party/v8 # gyp -> gn leftovers base/third_party/libevent third_party/adobe third_party/speech-dispatcher third_party/usb_ids third_party/xdg-utils third_party/yasm/run_yasm.py ) if ! use system-ffmpeg;then keeplibs+=( third_party/ffmpeg third_party/opus ) fi if ! use system-libvpx;then keeplibs+=( third_party/libvpx ) keeplibs+=( third_party/libvpx/source/libvpx/third_party/x86inc ) fi if use tcmalloc;then keeplibs+=( third_party/tcmalloc ) fi cd "${CHROMIUM_S}" || die #remove unneeded libraries from chromium tree ebegin "Unbundling libraries" build/linux/unbundle/remove_bundled_libraries.py "${keeplibs[@]}" --do-remove || die eend #apply patches to chromium eapply "${CHROMIUM_PATCHES[@]}" || die ln -s "${NODE_S}" "${CHROMIUM_S}/third_party/electron_node" || die cd "${S}" || die #Make sure we use python2.7 python_setup eapply_user } src_configure() { python_setup #CHROMIUM cd "${CHROMIUM_S}" || die local gn_system_libraries=( flac fontconfig freetype harfbuzz-ng icu libdrm libjpeg libpng libwebp libxml libxslt openh264 re2 snappy yasm zlib ) if use system-ffmpeg;then gn_system_libraries+=( ffmpeg opus ) fi if use system-libvpx;then gn_system_libraries+=( libvpx ) fi local llvm_prefix="$(get_llvm_prefix -b)" local myconf_gn="import(\"//electron/build/args/$(usex debug debug release).gn\") clang_base_path=\"${llvm_prefix}/bin/\"" tc-export AR CC CXX NM if ! tc-is-clang;then einfo "Using ${llvm_prefix}/bin/${CHOST}-clang++ for compilation..." CC="${CHOST}-clang" CXX="${CHOST}-clang++" strip-unsupported-flags fi if tc-is-clang;then myconf_gn+=" is_clang=true clang_use_chrome_plugins=false" else ewarn "Using a compiler other than clang is unsupported and will likely result in errors!" myconf_gn+=" is_clang=false" fi myconf_gn+=" custom_toolchain=\"//build/toolchain/linux/unbundle:default\"" if tc-is-cross-compiler;then tc-export BUILD {AR,CC,CXX,NM} myconf_gn+=" host_toolchain=\"//build/toolchain/linux/unbundle:host\"" myconf_gn+=" v8_snapshot_toolchain=\"//build/toolchain/linux/unbundle:host\"" else myconf_gn+=" host_toolchain=\"//build/toolchain/linux/unbundle:default\"" fi myconf_gn+=" is_debug=$(usex debug true false)" myconf_gn+=" is_component_build=$(usex component-build true false)" myconf_gn+=" is_official_build=$(usex component-build false $(usex debug false true))" myconf_gn+=" use_jumbo_build=$(usex jumbo-build true false)" myconf_gn+=" use_allocator=\"$(usex tcmalloc tcmalloc none)\"" myconf_gn+=" enable_nacl=false" myconf_gn+=" use_system_harfbuzz=true" myconf_gn+=" use_cups=$(usex cups true false)" myconf_gn+=" use_gio=$(usex gconf true false)" myconf_gn+=" use_gnome_keyring=$(usex gnome-keyring true false)" myconf_gn+=" use_kerberos=$(usex kerberos true false)" myconf_gn+=" use_pulseaudio=$(usex pulseaudio true false)" #prevent chromium from generating incompatible shims for pulse myconf_gn+=" link_pulseaudio=$(usex pulseaudio true false)" myconf_gn+=" icu_use_data_file=false" myconf_gn+=" fieldtrial_testing_like_official_build=true" myconf_gn+=" use_gold=false use_sysroot=false" myconf_gn+=" linux_use_bundled_binutils=false use_custom_libcxx=false" myconf_gn+=" use_lld=false" myconf_gn+=" proprietary_codecs=$(usex proprietary-codecs true false)" myconf_gn+=" ffmpeg_branding=\"$(usex proprietary-codecs Chrome Chromium)\"" myconf_gn+=" use_official_google_api_keys=false" myconf_gn+=" google_api_key=\"\"" myconf_gn+=" google_default_client_id=\"\"" myconf_gn+=" google_default_client_secret=\"\"" myconf_gn+=" treat_warnings_as_errors=false" myconf_gn+=" fatal_linker_warnings=false" myconf_gn+=" is_electron_build=true" build/linux/unbundle/replace_gn_files.py --system-libraries "${gn_system_libraries[@]}" || die local target_arch=$(_get_target_arch) local ffmpeg_target_arch="${target_arch}" if ! use custom-cflags;then replace-flags "-Os" "-O2" append-cxxflags $(test-flags-CXX -Wno-unknown-warning-option) append-cxxflags $(test-flags-CXX -Wno-invalid-offsetof) append-cxxflags $(test-flags-CXX -Wno-return-type) append-cxxflags $(test-flags-CXX -Wno-unused-variable) strip-flags if use x86;then filter-flags "-g*" fi if [ "${target_arch}" == "x64" ] || [ "${target_arch}" == "ia32" ];then filter-flags -mno-mmx -mno-sse2 -mno-ssse3 -mno-sse4.1 -mno-avx -mno-avx2 fi fi if ! use system-ffmpeg;then local build_ffmpeg_args="" einfo "Configuring bundled ffmpeg..." pushd "${CHROMIUM_S}/third_party/ffmpeg" > /dev/null 2>&1 || die chromium/scripts/build_ffmpeg.py linux ${ffmpeg_target_arch} \ --branding ${ffmpeg_branding} -- ${build_ffmpeg_args} || die chromium/scripts/copy_config.sh || die chromium/scripts/generate_gn.py || die popd > /dev/null 2>&1 || die fi export TMPDIR="${WORKDIR}/temp" mkdir -p -m 755 "${TMPDIR}" || die addpredict /dev/dri/ #NODE einfo "Configuring bundled nodejs..." pushd "${NODE_S}" > /dev/null 2>&1 || die ./configure --shared --without-bundled-v8 \ --shared-openssl --shared-http-parser --shared-zlib \ --shared-nghttp2 --shared-cares --without-npm --with-intl=system-icu \ --without-dtrace --dest-cpu=${target_arch} --prefix="" || die popd > /dev/null 2>&1 || die set -- gn gen --args="${myconf_gn} ${EXTRA_GN} ${GN_EXTRA_ARGS}" out/Release echo "$@" "$@" || die sed -i -e "s/python /${EPYTHON} /g" out/Release/toolchain.ninja || die cd "${S}" || die } src_compile() { python_setup cd "${CHROMIUM_S}" || die eninja -C out/Release electron || die einfo "Electron built successfully" if ! use debug;then electron/script/strip-binaries.py -d out/Release || die fi eninja -C out/Release electron:electron_dist_zip || die } src_install() { local install_dir="$(_get_install_dir)" local install_suffix="$(_get_install_suffix)" pushd "${CHROMIUM_S}/out/Release/locales" > /dev/null 2>&1 || die chromium_remove_language_paks popd > /dev/null 2>&1 || die cd "${CHROMIUM_S}/out/Release" || die dodir "${install_dir}" pushd "${ED}/${install_dir}" > /dev/null 2>&1 || die unpack "${CHROMIUM_S}/out/Release/dist.zip" || die popd > /dev/null 2>&1 || die if [ -e "${ED}/${install_dir}/chrome-sandbox" ];then use suid && chmod 4755 "${ED}/${install_dir}/chrome-sandbox" fi dodir "/usr/bin" || die dosym "../$(get_libdir)/electron${install_suffix}/electron" "/usr/bin/electron${install_suffix}" || die HEADERS_ONLY=1 \ "${NODE_S}/tools/install.py" install "${ED}" "/usr" || die dodir /usr/include/node/deps/{v8,uv} || die dosym . /usr/include/node/src || die for var in deps/{uv,v8}/include;do dosym "../.." "/usr/include/node/${var}" || die done dodir "/usr/include/electron${install_suffix}" || die mv "${ED}/usr/include/node" "${ED}/usr/include/electron${install_suffix}/node" || die } pkg_postinst() { if [ "$(eselect electron show)" == "(none)" ];then eselect electron set "${PN}-${VERSION_MAJ}.${VERSION_MIN}" fi } pkg_postrm() { if [ "$(eselect electron show)" == "(none)" ];then eselect electron set 1 fi }