chromium: Split up source into multiple outputs.

This splits up the source into one base output (just the build and tools
directory), one for bundled dependencies, one for sandbox sources and
one for the sources of the main browser.

The state of this is heavily work in progress and contains a bunch of
workarounds. For example, we currently copy the entire sources into the
build directory, so a build ultimately requires even more space than
before.

Of course, it's just temporary as neither GYP nor ninja is particularly
friendly if it comes to out-of-tree builds.

Another thing which is heavily WIP is how we handle patches. Ultimately,
those patches shouldn't be applied to the source tree (at least not all)
but rather to the final build's temporary directory.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2013-09-26 09:04:28 +02:00
parent eed74f05c7
commit 27b72342ae
No known key found for this signature in database
GPG Key ID: D0EBD0EC8C2DC961

View File

@ -7,7 +7,7 @@
, xdg_utils, yasm, zlib
, libusb1, libexif, pciutils
, python, perl, pkgconfig
, python, pythonPackages, perl, pkgconfig
, nspr, udev, krb5
, utillinux, alsaLib
, gcc, bison, gperf
@ -36,7 +36,67 @@
with stdenv.lib;
let
sourceInfo = builtins.getAttr channel (import ./sources.nix);
src = with getAttr channel (import ./sources.nix); stdenv.mkDerivation {
name = "chromium-source-${version}";
src = fetchurl {
inherit url sha256;
};
phases = [ "unpackPhase" "patchPhase" "installPhase" ];
opensslPatches = optional useOpenSSL openssl.patches;
prePatch = "patchShebangs .";
patches = singleton (
if versionOlder version "30.0.0.0"
then ./sandbox_userns_29.patch
else if versionOlder version "31.0.0.0"
then ./sandbox_userns_30.patch
else ./sandbox_userns_31.patch
);
postPatch = ''
sed -i -r -e 's/-f(stack-protector)(-all)?/-fno-\1/' build/common.gypi
sed -i -e 's|/usr/bin/gcc|gcc|' third_party/WebKit/Source/core/core.gypi
'' + optionalString useOpenSSL ''
cat $opensslPatches | patch -p1 -d third_party/openssl/openssl
'';
outputs = [ "out" "sandbox" "bundled" "main" ];
installPhase = ''
ensureDir "$out" "$sandbox" "$bundled" "$main"
header "copying browser main sources to $main"
find . -mindepth 1 -maxdepth 1 \
\! -path ./sandbox \
\! -path ./third_party \
\! -path ./build \
\! -path ./tools \
\! -name '.*' \
-print | xargs cp -rt "$main"
stopNest
header "copying sandbox components to $sandbox"
cp -rt "$sandbox" sandbox/*
stopNest
header "copying third party sources to $bundled"
cp -rt "$bundled" third_party/*
stopNest
header "copying build requisites to $out"
cp -rt "$out" build tools
stopNest
rm -rf "$out/tools/gyp" # XXX: Don't even copy it in the first place.
'';
passthru = {
inherit version;
};
};
mkGypFlags =
let
@ -94,23 +154,9 @@ let
libExecPath = "$out/libexec/${packageName}";
sandboxPath = "${sandbox}/bin/${packageName}_sandbox";
# user namespace sandbox patch
userns_patch = if versionOlder sourceInfo.version "30.0.0.0"
then ./sandbox_userns_29.patch
else if versionOlder sourceInfo.version "31.0.0.0"
then ./sandbox_userns_30.patch
else ./sandbox_userns_31.patch;
in stdenv.mkDerivation rec {
name = "${packageName}-${version}";
inherit packageName;
version = sourceInfo.version;
src = fetchurl {
url = sourceInfo.url;
sha256 = sourceInfo.sha256;
};
name = "${packageName}-${src.version}";
inherit packageName src;
buildInputs = defaultDependencies ++ [
which makeWrapper
@ -123,25 +169,25 @@ in stdenv.mkDerivation rec {
glib gtk dbus_glib
libXScrnSaver libXcursor libXtst mesa
pciutils protobuf speechd libXdamage
pythonPackages.gyp
] ++ optional gnomeKeyringSupport libgnome_keyring
++ optionals gnomeSupport [ gconf libgcrypt ]
++ optional enableSELinux libselinux
++ optional cupsSupport libgcrypt
++ optional pulseSupport pulseaudio
++ optional (!versionOlder sourceInfo.version "30.0.0.0") file;
++ optional (!versionOlder src.version "30.0.0.0") file;
opensslPatches = optional useOpenSSL openssl.patches;
prePatch = ''
# XXX: Figure out a way how to split these properly.
#cpflags="-dsr --no-preserve=mode"
cpflags="-dr"
cp $cpflags "${src.main}"/* .
cp $cpflags "${src.bundled}" third_party
cp $cpflags "${src.sandbox}" sandbox
chmod -R u+w . # XXX!
'';
prePatch = "patchShebangs .";
patches = [ userns_patch ];
postPatch = ''
sed -i -r -e 's/-f(stack-protector)(-all)?/-fno-\1/' build/common.gypi
sed -i -e 's|/usr/bin/gcc|gcc|' third_party/WebKit/Source/core/core.gypi
'' + optionalString useOpenSSL ''
cat $opensslPatches | patch -p1 -d third_party/openssl/openssl
'' + optionalString (!versionOlder sourceInfo.version "30.0.0.0") ''
postPatch = optionalString (!versionOlder src.version "30.0.0.0") ''
sed -i -e '/base::FilePath exe_dir/,/^ *} *$/c \
sandbox_binary = \
base::FilePath("'"${sandboxPath}"'");
@ -182,7 +228,7 @@ in stdenv.mkDerivation rec {
});
configurePhase = ''
GYP_GENERATORS=ninja python build/gyp_chromium --depth "$(pwd)" ${gypFlags}
python build/gyp_chromium -f ninja --depth "$(pwd)" ${gypFlags}
'';
buildPhase = let