1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python2_7 )
7 CHROMIUM_LANGS="am ar bg bn ca cs da de el en-GB es es-419 et fa fi fil fr gu he
8 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
9 sv sw ta te th tr uk vi zh-CN zh-TW"
11 inherit check-reqs chromium-2 eapi7-ver gnome2-utils flag-o-matic multilib \
12 multiprocessing ninja-utils pax-utils portability python-any-r1 \
13 toolchain-funcs virtualx xdg-utils
15 # Keep this in sync with vendor/libchromiumcontent/VERSION
16 CHROMIUM_VERSION="61.0.3163.100"
17 # Keep this in sync with vendor/breakpad
18 BREAKPAD_COMMIT="82f0452e6b687b3c1e14e08d172b2f3fb79ae91a"
19 # Keep this in sync with vendor/breakpad/src (and find the corresponding
20 # commit in https://github.com/google/breakpad/)
21 BREAKPAD_SRC_COMMIT="67f738b7adb47dc1e3b272fb99062f4192fa6651"
22 # Keep this in sync with vendor/node
23 NODE_COMMIT="51abeb37cad3f2098c0f0fffdff739f4ac2393e8"
24 # Keep this in sync with vendor/native_mate
25 NATIVE_MATE_COMMIT="6a3d238b7e1e3742f2bb495336a84021d927a24f"
26 # Keep this in sync with vendor/pdf_viewer
27 PDF_VIEWER_COMMIT="a5251e497fb52e699b28f627e3cbb6d8cefb62df"
28 # Keep this in sync with vendor/pdf_viewer/vendor/grit
29 GRIT_COMMIT="9536fb6429147d27ef1563088341825db0a893cd"
30 # Keep this in sync with vendor/libchromiumcontent
31 LIBCHROMIUMCONTENT_COMMIT="cbd04c0dccc7655cd42f02baee3a622d5170ac08"
32 # Keep this in sync with package.json#devDependencies
34 BROWSERIFY_VERSION="14.0.0"
36 GENTOO_PATCHES_VERSION="f0fb7725cfe73704dce84ec51bdccc024dc7ceff"
38 PATCHES_P="gentoo-electron-patches-${GENTOO_PATCHES_VERSION}"
39 CHROMIUM_P="chromium-${CHROMIUM_VERSION}"
40 BREAKPAD_P="chromium-breakpad-${BREAKPAD_COMMIT}"
41 BREAKPAD_SRC_P="breakpad-${BREAKPAD_SRC_COMMIT}"
42 NODE_P="node-${NODE_COMMIT}"
43 NATIVE_MATE_P="native-mate-${NATIVE_MATE_COMMIT}"
44 PDF_VIEWER_P="pdf-viewer-${PDF_VIEWER_COMMIT}"
45 GRIT_P="grit-${GRIT_COMMIT}"
46 LIBCHROMIUMCONTENT_P="libchromiumcontent-${LIBCHROMIUMCONTENT_COMMIT}"
47 ASAR_P="asar-${ASAR_VERSION}"
48 BROWSERIFY_P="browserify-${BROWSERIFY_VERSION}"
50 DESCRIPTION="Cross platform application development framework based on web technologies"
51 HOMEPAGE="https://electronjs.org/"
53 https://commondatastorage.googleapis.com/chromium-browser-official/${CHROMIUM_P}.tar.xz
54 https://github.com/electron/electron/archive/v${PV}.tar.gz -> ${P}.tar.gz
55 https://github.com/electron/chromium-breakpad/archive/${BREAKPAD_COMMIT}.tar.gz -> electron-${BREAKPAD_P}.tar.gz
56 https://github.com/google/breakpad/archive/${BREAKPAD_SRC_COMMIT}.tar.gz -> electron-${BREAKPAD_SRC_P}.tar.gz
57 https://github.com/electron/node/archive/${NODE_COMMIT}.tar.gz -> electron-${NODE_P}.tar.gz
58 https://github.com/zcbenz/native-mate/archive/${NATIVE_MATE_COMMIT}.tar.gz -> electron-${NATIVE_MATE_P}.tar.gz
59 https://github.com/electron/pdf-viewer/archive/${PDF_VIEWER_COMMIT}.tar.gz -> electron-${PDF_VIEWER_P}.tar.gz
60 https://github.com/elprans/grit/archive/${GRIT_COMMIT}.tar.gz -> electron-${GRIT_P}.tar.gz
61 https://github.com/electron/libchromiumcontent/archive/${LIBCHROMIUMCONTENT_COMMIT}.tar.gz -> electron-${LIBCHROMIUMCONTENT_P}.tar.gz
62 https://github.com/elprans/asar/releases/download/v${ASAR_VERSION}-gentoo/asar-build.tar.gz -> ${ASAR_P}.tar.gz
63 https://github.com/elprans/node-browserify/releases/download/${BROWSERIFY_VERSION}-gentoo/browserify-build.tar.gz -> ${BROWSERIFY_P}.tar.gz
64 https://github.com/elprans/gentoo-electron-patches/archive/${GENTOO_PATCHES_VERSION}.tar.gz -> electron-patches-${GENTOO_PATCHES_VERSION}.tar.gz
65 https://github.com/ninja-build/ninja/archive/v${NINJA_VERSION}.tar.gz -> ninja-${NINJA_VERSION}.tar.gz
69 CHROMIUM_S="${S}/chromium"
70 NODE_S="${S}/vendor/node"
71 BREAKPAD_S="${S}/vendor/breakpad"
72 BREAKPAD_SRC_S="${BREAKPAD_S}/src"
73 NATIVE_MATE_S="${S}/vendor/native_mate"
74 PDF_VIEWER_S="${S}/vendor/pdf_viewer"
75 GRIT_S="${PDF_VIEWER_S}/vendor/grit"
76 LIBCC_S="${S}/vendor/libchromiumcontent"
81 IUSE="cups custom-cflags gconf gnome-keyring kerberos lto neon pic
82 +proprietary-codecs pulseaudio selinux +system-ffmpeg +tcmalloc"
83 RESTRICT="!system-ffmpeg? ( proprietary-codecs? ( bindist ) )"
85 # Native Client binaries are compiled with different set of flags, bug #452066.
86 QA_FLAGS_IGNORED=".*\.nexe"
88 # Native Client binaries may be stripped by the build system, which uses the
89 # right tools for it, bug #469144 .
90 QA_PRESTRIPPED=".*\.nexe"
94 >=app-eselect/eselect-electron-2.0
95 cups? ( >=net-print/cups-1.3.11:= )
99 dev-libs/libxml2:=[icu]
102 >=dev-libs/nss-3.14.3:=
103 >=dev-libs/re2-0.2016.05.01:=
104 gconf? ( >=gnome-base/gconf-2.24.0:= )
105 gnome-keyring? ( >=gnome-base/libgnome-keyring-3.12:= )
106 >=media-libs/alsa-lib-1.0.19:=
107 media-libs/fontconfig:=
108 media-libs/freetype:=
109 >=media-libs/harfbuzz-1.4.2:=[icu(+)]
111 media-libs/libjpeg-turbo:=
113 >=media-libs/libvpx-1.7.0:=[postproc,svc]
114 >=media-libs/openh264-1.6.0:=
115 pulseaudio? ( media-sound/pulseaudio:= )
117 >=media-video/ffmpeg-3:=
119 media-video/ffmpeg[-samba]
120 >=net-fs/samba-4.5.10-r1[-debug(-)]
122 !=net-fs/samba-4.5.12-r0
125 >=net-dns/c-ares-1.13.0:=
126 >=net-libs/nghttp2-1.32.0:=
131 x11-libs/gdk-pixbuf:2
136 x11-libs/libXcomposite:=
137 x11-libs/libXcursor:=
138 x11-libs/libXdamage:=
141 >=x11-libs/libXi-1.6.0:=
143 x11-libs/libXrender:=
144 x11-libs/libXScrnSaver:=
149 >=media-libs/libwebp-0.4.0:=
150 sys-libs/zlib:=[minizip]
151 kerberos? ( virtual/krb5 )
153 # For nvidia-drivers blocker, see bug #413637 .
154 RDEPEND="${COMMON_DEPEND}
155 !<dev-util/electron-0.36.12-r4
159 selinux? ( sec-policy/selinux-chromium )
160 tcmalloc? ( !<x11-drivers/nvidia-drivers-331.20 )
162 # dev-vcs/git - https://bugs.gentoo.org/593476
163 DEPEND="${COMMON_DEPEND}
170 >=dev-util/gperf-3.0.3
171 >=dev-util/ninja-1.7.2
172 >=net-libs/nodejs-4.6.1
173 sys-apps/hwids[usb(+)]
174 >=sys-devel/bison-2.4.3
178 $(python_gen_any_dep '
179 dev-python/beautifulsoup:python-2[${PYTHON_USEDEP}]
180 >=dev-python/beautifulsoup-4.3.2:4[${PYTHON_USEDEP}]
181 dev-python/html5lib[${PYTHON_USEDEP}]
182 dev-python/simplejson[${PYTHON_USEDEP}]
186 # Keep this in sync with the python_gen_any_dep call.
187 python_check_deps() {
188 has_version --host-root "dev-python/beautifulsoup:python-2[${PYTHON_USEDEP}]" &&
189 has_version --host-root ">=dev-python/beautifulsoup-4.3.2:4[${PYTHON_USEDEP}]" &&
190 has_version --host-root "dev-python/html5lib[${PYTHON_USEDEP}]" &&
191 has_version --host-root "dev-python/simplejson[${PYTHON_USEDEP}]"
194 if ! has chromium_pkg_die ${EBUILD_DEATH_HOOKS}; then
195 EBUILD_DEATH_HOOKS+=" chromium_pkg_die";
199 if [[ ${MERGE_TYPE} != binary ]]; then
200 local -x CPP="$(tc-getCXX) -E"
201 if tc-is-clang && ! ver_test "$(clang-fullversion)" -ge 3.9.1; then
203 die "At least clang 3.9.1 is required"
205 if tc-is-gcc && ! ver_test "$(gcc-version)" -ge 4.9; then
206 # bugs: #535730, #525374, #518668, #600288
207 die "At least gcc 4.9 is required"
211 # LTO pass requires more file descriptors
213 local lto_n_rlimit_min="16384"
214 local maxfiles=$(ulimit -n -H)
215 if [ "${maxfiles}" -lt "${lto_n_rlimit_min}" ]; then
217 eerror "Building with USE=\"lto\" requires file descriptor" \
218 "limit to be no less than ${lto_n_rlimit_min}."
219 eerror "The current limit for portage is ${maxfiles}."
220 eerror "Please add the following to /etc/security/limits.conf:"
222 eerror " root hard nofile ${lto_n_rlimit_min}"
223 eerror " root soft nofile ${lto_n_rlimit_min}"
229 # Check build requirements, bug #541816 and bug #471810 .
230 CHECKREQS_MEMORY="3G"
231 use lto && CHECKREQS_MEMORY="7G"
232 CHECKREQS_DISK_BUILD="5G"
233 eshopts_push -s extglob
234 if is-flagq '-g?(gdb)?([1-9])'; then
235 CHECKREQS_DISK_BUILD="25G"
236 CHECKREQS_MEMORY="16G"
239 check-reqs_pkg_pretend
249 # Make sure the build system will use the right python, bug #344367.
250 python-any-r1_pkg_setup
252 chromium_suid_sandbox_check_kernel_config
261 (find "${_s}" -mindepth 2 -name '*.patch' -printf "%P\n" || die) \
262 | while read -r path; do
263 relpath="$(dirname ${path})"
264 out="${_s}/__${relpath////_}_$(basename ${path})"
265 sed -r -e "s|^([-+]{3}) ([ab])/(.*)$|\1 \2/${relpath}/\3|g" \
266 "${_s}/${path}" > "${out}" || die
270 _get_install_suffix() {
271 local c=(${SLOT//\// })
275 if [[ "${slot}" == "0" ]]; then
285 echo -n "/usr/$(get_libdir)/electron$(_get_install_suffix)"
289 local myarch="$(tc-arch)"
292 if [[ $myarch = amd64 ]] ; then
294 elif [[ $myarch = x86 ]] ; then
296 elif [[ $myarch = arm64 ]] ; then
298 elif [[ $myarch = arm ]] ; then
301 die "Failed to determine target arch, got '$myarch'."
304 echo -n "${target_arch}"
308 mv "${WORKDIR}/${CHROMIUM_P}" "${CHROMIUM_S}" || die
310 mv "${WORKDIR}/${NODE_P}" "${NODE_S}" || die
311 rm -r "${BREAKPAD_S}" &&
312 mv "${WORKDIR}/${BREAKPAD_P}" "${BREAKPAD_S}" || die
313 rm -r "${BREAKPAD_SRC_S}" &&
314 mv "${WORKDIR}/${BREAKPAD_SRC_P}/src" "${BREAKPAD_SRC_S}" || die
315 rm -r "${NATIVE_MATE_S}" &&
316 mv "${WORKDIR}/${NATIVE_MATE_P}" "${NATIVE_MATE_S}" || die
317 rm -r "${PDF_VIEWER_S}" &&
318 mv "${WORKDIR}/${PDF_VIEWER_P}" "${PDF_VIEWER_S}" || die
320 mv "${WORKDIR}/${GRIT_P}" "${GRIT_S}" || die
321 rm -r "${LIBCC_S}" &&
322 mv "${WORKDIR}/${LIBCHROMIUMCONTENT_P}" "${LIBCC_S}" || die
323 rsync -a "${WORKDIR}/${ASAR_P}/node_modules/" \
324 "${S}/node_modules/" || die
325 rsync -a "${WORKDIR}/${BROWSERIFY_P}/node_modules/" \
326 "${S}/node_modules/" || die
329 cd "${NODE_S}" || die
330 # make sure node uses the correct version of v8
332 ln -s "${CHROMIUM_S}/v8" deps/ || die
334 # make sure we use python2.* while using gyp
335 sed -i -e "s/python/${EPYTHON}/" \
336 deps/npm/node_modules/node-gyp/gyp/gyp || die
337 sed -i -e "s/|| 'python'/|| '${EPYTHON}'/" \
338 deps/npm/node_modules/node-gyp/lib/configure.js || die
340 python_fix_shebang "${CHROMIUM_S}/chrome/browser"
341 python_fix_shebang "${CHROMIUM_S}/build/gyp_chromium"
342 python_fix_shebang "${S}/tools/"
344 # less verbose install output (stating the same as portage, basically)
345 sed -i -e "/print/d" tools/install.py || die
347 # proper libdir, hat tip @ryanpcmcquen
348 # https://github.com/iojs/io.js/issues/504
349 local LIBDIR=$(get_libdir)
350 sed -i -e "s|lib/|${LIBDIR}/|g" tools/install.py || die
351 sed -i -e "s/'lib'/'${LIBDIR}'/" lib/module.js || die
352 sed -i -e "s|\"lib\"|\"${LIBDIR}\"|" deps/npm/lib/npm.js || die
354 # Apply Gentoo patches for Electron itself.
356 _unnest_patches "${WORKDIR}/${PATCHES_P}/${PV}/electron/"
357 eapply "${WORKDIR}/${PATCHES_P}/${PV}/electron/"
359 # Apply Chromium patches from libchromiumcontent.
360 cd "${CHROMIUM_S}" || die
361 _unnest_patches "${LIBCC_S}/patches"
362 eapply "${LIBCC_S}/patches"
364 # Finally, apply Gentoo patches for Chromium.
365 eapply "${WORKDIR}/${PATCHES_P}/${PV}/chromium/"
367 # Merge chromiumcontent component into chromium source tree.
368 mkdir -p "${CHROMIUM_S}/chromiumcontent" || die
369 cp -a "${LIBCC_S}/chromiumcontent" "${CHROMIUM_S}/" || die
370 cp -a "${LIBCC_S}/tools/linux/" "${CHROMIUM_S}/tools/" || die
373 base/third_party/dmg_fp
374 base/third_party/dynamic_annotations
376 base/third_party/nspr
377 base/third_party/superfasthash
378 base/third_party/symbolize
379 base/third_party/valgrind
380 base/third_party/xdg_mime
381 base/third_party/xdg_user_dirs
382 breakpad/src/third_party/curl
383 chrome/third_party/mozilla_security_manager
384 courgette/third_party
385 net/third_party/mozilla_security_manager
388 third_party/analytics
390 third_party/angle/src/common/third_party/base
391 third_party/angle/src/common/third_party/murmurhash
392 third_party/angle/src/third_party/compiler
393 third_party/angle/src/third_party/libXNVCtrl
394 third_party/angle/src/third_party/trace_event
395 third_party/boringssl
397 third_party/cacheinvalidation
399 third_party/catapult/third_party/polymer
400 third_party/catapult/third_party/py_vulcanize
401 third_party/catapult/third_party/py_vulcanize/third_party/rcssmin
402 third_party/catapult/third_party/py_vulcanize/third_party/rjsmin
403 third_party/catapult/tracing/third_party/d3
404 third_party/catapult/tracing/third_party/gl-matrix
405 third_party/catapult/tracing/third_party/jszip
406 third_party/catapult/tracing/third_party/mannwhitneyu
407 third_party/catapult/tracing/third_party/oboe
411 third_party/cros_system_api
412 third_party/devscripts
413 third_party/dom_distiller_js
415 third_party/flatbuffers
418 third_party/glslang-angle
419 third_party/google_input_tools
420 third_party/google_input_tools/third_party/closure_library
421 third_party/google_input_tools/third_party/closure_library/third_party/closure
422 third_party/googletest
425 third_party/inspector_protocol
427 third_party/jstemplate
429 third_party/leveldatabase
430 third_party/libXNVCtrl
431 third_party/libaddressinput
432 third_party/libjingle
433 third_party/libphonenumber
434 third_party/libsecret
438 third_party/libxml/chromium
442 third_party/markupsafe
445 third_party/mt19937ar
447 third_party/node/node_modules/vulcanize/third_party/UglifyJS2
448 third_party/openmax_dl
451 third_party/pdfium/third_party/agg23
452 third_party/pdfium/third_party/base
453 third_party/pdfium/third_party/build
454 third_party/pdfium/third_party/bigint
455 third_party/pdfium/third_party/freetype
456 third_party/pdfium/third_party/lcms2-2.6
457 third_party/pdfium/third_party/libopenjpeg20
458 third_party/pdfium/third_party/libpng16
459 third_party/pdfium/third_party/libtiff
463 third_party/protobuf/third_party/six
467 third_party/skia/third_party/vulkan
469 third_party/spirv-headers
470 third_party/spirv-tools-angle
472 third_party/swiftshader
473 third_party/swiftshader/third_party/llvm-subzero
474 third_party/swiftshader/third_party/subzero
477 third_party/vulkan-validation-layers
478 third_party/web-animations-js
479 third_party/webdriver
483 third_party/zlib/google
484 url/third_party/mozilla
485 v8/src/third_party/valgrind
486 v8/third_party/inspector_protocol
488 # gyp -> gn leftovers
489 base/third_party/libevent
491 third_party/speech-dispatcher
493 third_party/xdg-utils
494 third_party/yasm/run_yasm.py
496 if ! use system-ffmpeg; then
497 keeplibs+=( third_party/ffmpeg third_party/opus )
499 if use tcmalloc; then
500 keeplibs+=( third_party/tcmalloc )
503 cd "${CHROMIUM_S}" || die
505 # Remove most bundled libraries. Some are still needed.
506 ebegin "Unbundling libraries"
507 build/linux/unbundle/remove_bundled_libraries.py \
508 "${keeplibs[@]}" --do-remove || die
520 cd "${CHROMIUM_S}" || die
522 # GN needs explicit config for Debug/Release as opposed to
523 # inferring it from build directory.
524 myconf_gn+=" is_debug=false"
526 # Disable nacl, we can't build without pnacl (http://crbug.com/269560).
527 myconf_gn+=" enable_nacl=false"
529 # Use system-provided libraries.
530 # TODO: freetype (https://bugs.chromium.org/p/pdfium/issues/detail?id=733).
531 # TODO: use_system_hunspell (upstream changes needed).
532 # TODO: use_system_libsrtp (bug #459932).
533 # TODO: xml (bug #616818).
534 # TODO: use_system_protobuf (bug #525560).
535 # TODO: use_system_ssl (http://crbug.com/58087).
536 # TODO: use_system_sqlite (http://crbug.com/22208).
538 # libevent: https://bugs.gentoo.org/593458
539 local gn_system_libraries=(
555 if use system-ffmpeg; then
556 gn_system_libraries+=( libvpx ffmpeg opus )
558 build/linux/unbundle/replace_gn_files.py \
559 --system-libraries ${gn_system_libraries[@]} || die
561 # Optional dependencies.
562 myconf_gn+=" use_cups=$(usex cups true false)"
563 myconf_gn+=" use_gconf=$(usex gconf true false)"
564 myconf_gn+=" use_gnome_keyring=$(usex gnome-keyring true false)"
565 myconf_gn+=" use_kerberos=$(usex kerberos true false)"
566 myconf_gn+=" use_pulseaudio=$(usex pulseaudio true false)"
568 # TODO: link_pulseaudio=true for GN.
570 myconf_gn+=" fieldtrial_testing_like_official_build=true"
573 myconf_gn+=" is_clang=true clang_base_path=\"/usr\" clang_use_chrome_plugins=false"
575 myconf_gn+=" is_clang=false"
578 # Never use bundled gold binary. Disable gold linker flags for now.
579 # Do not use bundled clang.
580 # Trying to use gold results in linker crash.
581 myconf_gn+=" use_gold=false use_sysroot=false"
582 myconf_gn+=" linux_use_bundled_binutils=false use_custom_libcxx=false"
584 ffmpeg_branding="$(usex proprietary-codecs Chrome Chromium)"
585 myconf_gn+=" proprietary_codecs=$(usex proprietary-codecs true false)"
586 myconf_gn+=" ffmpeg_branding=\"${ffmpeg_branding}\""
588 # Set up Google API keys, see http://www.chromium.org/developers/how-tos/api-keys .
589 # Note: these are for Gentoo use ONLY. For your own distribution,
590 # please get your own set of keys. Feel free to contact chromium@gentoo.org
592 local google_api_key="AIzaSyDEAOvatFo0eTgsV_ZlEzx0ObmepsMzfAc"
593 local google_default_client_id="329227923882.apps.googleusercontent.com"
594 local google_default_client_secret="vgKG0NNv7GoDpbtoFNLxCUXu"
595 myconf_gn+=" google_api_key=\"${google_api_key}\""
596 myconf_gn+=" google_default_client_id=\"${google_default_client_id}\""
597 myconf_gn+=" google_default_client_secret=\"${google_default_client_secret}\""
599 local target_arch=$(_get_target_arch)
600 local ffmpeg_target_arch="${target_arch}"
602 if [[ ${ffmpeg_target_arch} = arm ]]; then
603 ffmpeg_target_arch=$(usex neon arm-neon arm)
606 # Make sure that -Werror doesn't get added to CFLAGS by the build system.
607 # Depending on GCC version the warnings are different and we don't want
608 # the build to fail because of that.
609 myconf_gn+=" treat_warnings_as_errors=false"
611 # Disable fatal linker warnings, bug 506268.
612 myconf_gn+=" fatal_linker_warnings=false"
614 # Avoid CFLAGS problems, bug #352457, bug #390147.
615 if ! use custom-cflags; then
616 replace-flags "-Os" "-O2"
619 filter-flags "-Wl,--as-needed"
621 # Prevent linker from running out of address space, bug #471810 .
626 # Prevent libvpx build failures. Bug 530248, 544702, 546984.
627 if [[ ${myarch} == amd64 || ${myarch} == x86 ]]; then
628 filter-flags -mno-mmx -mno-sse2 -mno-ssse3 -mno-sse4.1 -mno-avx -mno-avx2
632 # Make sure the build system will use the right tools, bug #340795.
633 tc-export AR CC CXX NM
635 # Define a custom toolchain for GN
636 myconf_gn+=" custom_toolchain=\"${FILESDIR}/toolchain:default\""
638 if tc-is-cross-compiler; then
639 tc-export BUILD_{AR,CC,CXX,NM}
640 myconf_gn+=" host_toolchain=\"${FILESDIR}/toolchain:host\""
641 myconf_gn+=" v8_snapshot_toolchain=\"${FILESDIR}/toolchain:host\""
643 myconf_gn+=" host_toolchain=\"${FILESDIR}/toolchain:default\""
646 # https://bugs.gentoo.org/588596
647 append-cxxflags $(test-flags-CXX -fno-delete-null-pointer-checks)
649 myconf_gn+=" icu_use_data_file=false"
651 use lto && myconf_gn+=" allow_posix_link_time_opt=true"
653 # Tools for building programs to be executed on the build system, bug #410883.
654 if tc-is-cross-compiler; then
655 export AR_host=$(tc-getBUILD_AR)
656 export CC_host=$(tc-getBUILD_CC)
657 export CXX_host=$(tc-getBUILD_CXX)
658 export NM_host=$(tc-getBUILD_NM)
662 export TMPDIR="${WORKDIR}/temp"
663 mkdir -p -m 755 "${TMPDIR}" || die
665 if ! use system-ffmpeg; then
666 local build_ffmpeg_args=""
667 if use pic && [[ "${ffmpeg_target_arch}" == "ia32" ]]; then
668 build_ffmpeg_args+=" --disable-asm"
671 # Re-configure bundled ffmpeg. See bug #491378 for example reasons.
672 einfo "Configuring bundled ffmpeg..."
673 pushd third_party/ffmpeg > /dev/null || die
674 chromium/scripts/build_ffmpeg.py linux ${ffmpeg_target_arch} \
675 --branding ${ffmpeg_branding} -- ${build_ffmpeg_args} || die
676 chromium/scripts/copy_config.sh || die
677 chromium/scripts/generate_gn.py || die
678 popd > /dev/null || die
681 third_party/libaddressinput/chromium/tools/update-strings.py || die
683 touch chrome/test/data/webui/i18n_process_css_test.html || die
685 einfo "Configuring bundled nodejs..."
686 pushd "${S}/vendor/node" > /dev/null || die
687 # --shared-libuv cannot be used as electron's node fork
688 # patches uv_loop structure.
689 ./configure --shared --without-bundled-v8 \
690 --shared-http-parser --shared-zlib \
691 --shared-nghttp2 --shared-cares \
692 --without-npm --with-intl=system-icu --without-dtrace \
693 --dest-cpu=${target_arch} --prefix="" || die
694 popd > /dev/null || die
696 # libchromiumcontent configuration
697 myconf_gn+=" root_extra_deps = [\"//chromiumcontent:chromiumcontent\"]"
698 myconf_gn+=" is_electron_build = true"
699 myconf_gn+=" is_component_build = false"
700 myconf_gn+=" use_allocator=$(usex tcmalloc \"tcmalloc\" \"none\")"
702 einfo "Configuring chromiumcontent..."
703 set -- gn gen --args="${myconf_gn} ${EXTRA_GN}" out/Release
711 if [[ -z ${NINJAOPTS+set} ]]; then
712 local jobs=$(makeopts_jobs)
713 local loadavg=$(makeopts_loadavg)
715 if [[ ${MAKEOPTS} == *-j* && ${jobs} != 999 ]]; then
716 NINJAOPTS+=" -j ${jobs}"
718 if [[ ${MAKEOPTS} == *-l* && ${loadavg} != 999 ]]; then
719 NINJAOPTS+=" -l ${loadavg}"
722 set -- ninja -v ${NINJAOPTS} "$@"
728 local compile_target="${S}/out/R"
730 local chromium_target="${CHROMIUM_S}/out/Release"
731 local libcc_path="${S}/vendor/libchromiumcontent"
732 local libcc_dist_path="${libcc_path}/dist/main"
733 local libcc_dist_static_path="${libcc_dist_path}/static_library"
734 local libcc_dist_shared_path="${libcc_dist_path}/shared_library"
735 local libcc_output="${CHROMIUM_S}/out/Release/obj/chromiumcontent"
736 local libcc_output_shared="${libcc_output}-shared"
737 local target_arch=$(_get_target_arch)
739 local create_dist_args=""
741 tc-export AR CC CXX NM
743 mkdir -p "${compile_target}" || die
745 cd "${CHROMIUM_S}" || die
747 # Build mksnapshot and pax-mark it.
748 eninja -C "${chromium_target}" mksnapshot || die
749 pax-mark m "${chromium_target}/mksnapshot"
750 cp -a "${chromium_target}/mksnapshot" "${compile_target}/" || die
752 # Build chromedriver.
753 eninja -C "${chromium_target}" chromedriver
754 cp -a "${chromium_target}/chromedriver" "${compile_target}/" || die
756 # Build libchromiumcontent components.
757 eninja -C "${chromium_target}" chromiumcontent:chromiumcontent
758 CHROMIUMCONTENT_2ND_PASS=1 \
759 eninja -C "${chromium_target}" chromiumcontent:libs
763 # Gather and prepare built components of libchromiumcontent.
764 create_dist_args+=" --target_arch=${target_arch} --component=static_library"
765 create_dist_args+=" --no_zip"
766 create_dist_args+=" --system-icu"
767 CHROMIUM_BUILD_DIR="${chromium_target}" \
768 PYTHONPATH="${WORKDIR}/ninja-${NINJA_VERSION}/misc" \
769 "${EPYTHON}" "${libcc_path}"/script/create-dist ${create_dist_args} || die
771 # v8 is built as a shared library, so copy it manually
772 # for generate_filenames_gypi to find.
773 mkdir -p "${libcc_dist_shared_path}" || die
774 cp "${chromium_target}/libv8.so" "${libcc_dist_shared_path}" || die
776 "${EPYTHON}" "${libcc_path}"/tools/generate_filenames_gypi.py \
777 "${libcc_dist_path}/filenames.gypi" \
779 "${libcc_dist_shared_path}" \
780 "${libcc_dist_static_path}"
782 # Configure electron.
785 $(gyp_use gconf use_gconf)
786 $(gyp_use gnome-keyring use_gnome_keyring)
787 $(gyp_use gnome-keyring linux_link_gnome_keyring)
790 myconf_gyp+=" -Duse_system_icu=1"
792 if [[ $(tc-getCC) == *clang* ]]; then
793 myconf_gyp+=" -Dclang=1"
795 myconf_gyp+=" -Dclang=0"
798 # Never use bundled gold binary. Disable gold linker flags for now.
799 # Do not use bundled clang.
801 -Dclang_use_chrome_plugins=0
803 -Dlinux_use_bundled_binutils=0
804 -Dlinux_use_bundled_gold=0
805 -Dlinux_use_gold_flags=0
808 myconf_gyp+=" -Dtarget_arch=${target_arch}"
809 myconf_gyp+=" -Dpython=${EPYTHON}"
811 # Make sure that -Werror doesn't get added to CFLAGS by the build system.
812 # Depending on GCC version the warnings are different and we don't want
813 # the build to fail because of that.
814 myconf_gyp+=" -Dwerror="
816 # Disable fatal linker warnings, bug 506268.
817 myconf_gyp+=" -Ddisable_fatal_linker_warnings=1"
819 myconf_gyp+=" -Dicu_use_data_file_flag=0"
820 myconf_gyp+=" -Dgenerate_character_data=0"
822 myconf_gyp+=" -Dmas_build=0"
823 myconf_gyp+=" -Dlibchromiumcontent_component=0"
824 myconf_gyp+=" -Dcomponent=static_library"
825 myconf_gyp+=" -Dlibrary=static_library"
826 myconf_gyp+=" -Icommon.gypi electron.gyp"
828 EGYP_CHROMIUM_COMMAND="${CHROMIUM_S}/build/gyp_chromium" \
829 egyp_chromium ${myconf_gyp} || die
831 mkdir -p "${compile_target}/lib/" || die
832 # Copy libv8 and snapshot files so the node binary can find them.
833 cp "${chromium_target}/libv8.so" "${compile_target}/lib/" || die
834 cp "${chromium_target}/natives_blob.bin" "${compile_target}" || die
835 cp "${chromium_target}/snapshot_blob.bin" "${compile_target}" || die
837 # Copy generated shim headers.
838 mkdir -p "${compile_target}/gen" || die
839 cp -r "${chromium_target}/gen/shim_headers" \
840 "${compile_target}/gen" || die
842 # Build the Node binary and pax-mark it.
843 eninja -C ${compile_target} nodebin
844 pax-mark m ${compile_target}/nodebin
846 # Finally, build Electron.
847 eninja -C ${compile_target} electron
848 pax-mark m ${compile_target}/electron
850 echo "v${PV}" > ${compile_target}/version
854 local install_dir="$(_get_install_dir)"
855 local install_suffix="$(_get_install_suffix)"
856 local LIBDIR="${ED}/usr/$(get_libdir)"
858 pushd out/R/locales > /dev/null || die
859 chromium_remove_language_paks
860 popd > /dev/null || die
863 insinto "${install_dir}"
864 exeinto "${install_dir}"
865 newexe out/R/nodebin node
867 doexe out/R/chromedriver
868 doexe out/R/mksnapshot
870 fperms +x "${install_dir}/libv8.so"
871 doins out/R/libnode.so
872 fperms +x "${install_dir}/libnode.so"
873 doins out/R/natives_blob.bin
874 doins out/R/snapshot_blob.bin
875 doins out/R/blink_image_resources_200_percent.pak
876 doins out/R/content_resources_200_percent.pak
877 doins out/R/content_shell.pak
878 doins out/R/pdf_viewer_resources.pak
879 doins out/R/ui_resources_200_percent.pak
880 doins out/R/views_resources_200_percent.pak
881 doins -r out/R/resources
882 doins -r out/R/locales
883 dosym "${install_dir}/electron" "/usr/bin/electron${install_suffix}"
887 # Install Node headers
889 "${S}/vendor/node/tools/install.py" install "${ED}" "/usr" || die
890 # set up a symlink structure that npm expects..
891 dodir /usr/include/node/deps/{v8,uv}
892 dosym . /usr/include/node/src
893 for var in deps/{uv,v8}/include; do
894 dosym ../.. /usr/include/node/${var}
897 dodir "/usr/include/electron${install_suffix}"
898 mv "${ED}/usr/include/node" \
899 "${ED}/usr/include/electron${install_suffix}/node" || die
903 electron-config update
907 electron-config update