patches and low-level development discussion
 help / color / mirror / code / Atom feed
d617401138fd3fcff3acc27158e1f2e3b6b1e189 blob 3408 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
 
{ stdenv, lib, fetchFromGitiles, upstreamInfo, gn, pkgconfig, python3, ninja
# , libchrome
}:

{ platformSubdir

# Mandatory, unlike in mkDerivation, because Google doesn't provide
# install tasks and just does that in their ebuilds.
, installPhase

# src allows an out-of-tree (i.e., out-of-platform2) package to be
# built with common-mk.  patches will be applied to `src` -- to patch
# platform2 itself use platform2Patches.
, src ? null, platform2Patches ? []

# gnArgs allows structured data (attribute sets) to be serialized and
# passed to gn, unlike gnFlags provided by gn's setupHook, which is a
# flat list of strings.
, gnArgs ? {}, gnFlags ? [], use ? {}

, postUnpack ? "", prePatch ? "", postPatch ? ""
, nativeBuildInputs ? []
, meta ? {}
, ... } @ args:

let
  platform2 = fetchFromGitiles upstreamInfo.components."src/platform2";

  attrsToGnList = lib.mapAttrsToList (name: value: "${name}=${toGn value}");

  toGn = value:
    if lib.isAttrs value then
      "{${lib.concatStringsSep " " (attrsToGnList value)}}"
    else
      builtins.toJSON value;
in

stdenv.mkDerivation ({
  pname = lib.last (lib.splitString "/" platformSubdir);
  inherit (upstreamInfo) version;

  srcs = [ platform2 ] ++ lib.optional (src != null) src;
  sourceRoot = "platform2";

  postUnpack = lib.optionalString (src != null) ''
    ln -s ../${src.name} $sourceRoot/${platformSubdir}
    chmod -R +w ${src.name}
  '' + postUnpack;

  prePatch = ''
    pushd ${platformSubdir}
  '' + prePatch;

  postPatch = ''
    popd
    ${lib.concatMapStrings (patch: ''
      echo applying patch ${patch}
      patch -p1 < ${patch} 
    '') ([
      ./0001-common-mk-don-t-leak-source-absolute-paths.patch
      ./0002-common-mk-.gn-don-t-hardcode-env-path.patch
    ] ++ platform2Patches)}

    patchShebangs common-mk
  '' + (lib.optionalString (!stdenv.cc.isClang) ''
    substituteInPlace common-mk/BUILD.gn \
        --replace '"-Wno-c99-designator",' "" \
        --replace '"-Wstring-compare",' "" \
        --replace '"-Wstring-plus-int",' "" \
        --replace '"-Wxor-used-as-pow",' "" \
        --replace '"-Wunreachable-code-return",' ""
  '') + postPatch;

  nativeBuildInputs = [ gn pkgconfig python3 ninja ] ++ nativeBuildInputs;

  gnFlags = (attrsToGnList ({
    ar = "ar";
    cc = "cc";
    cxx = "c++";
    # libbase_ver = libchrome.version;
    libdir = placeholder "out";
    pkg_config = "pkg-config";
    platform2_root = ".";
    platform_subdir = platformSubdir;
    use = {
      amd64 = stdenv.targetPlatform.isx86_64;
      arm = stdenv.targetPlatform.isAarch32 || stdenv.targetPlatform.isAarch64;
      asan = false;
      coverage = false;
      cros_host = false;
      crypto = false;
      dbus = false;
      device_mapper = false;
      fuzzer = false;
      mojo = false;
      profiling = false;
      tcmalloc = false;
      test = false;
      timers = false;
      udev = false;
    } // use;
  } // gnArgs)) ++ gnFlags;

  passthru.updateScript = ../update.py;

  meta = {
    homepage =
      if src == null then
        "${platform2.meta.homepage}/+/HEAD/${platformSubdir}"
      else
        src.meta.homepage;
    platform = lib.platforms.linux;
  } // lib.optionalAttrs (src == null) {
    license = lib.licenses.bsd3;
  } // meta;
} // (builtins.removeAttrs args [
  "src"
  "gnArgs" "gnFlags" "use"
  "postUnpack" "prePatch" "postPatch"
  "nativeBuildInputs"
  "meta"
]))
debug log:

solving d617401138f ...
found d617401138f in https://spectrum-os.org/git/nixpkgs

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).