about summary refs log tree commit diff
path: root/make/lib/default.nix
blob: a5059252daa797c20c978a60560286ed110b3839 (plain) (blame)
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
rec {

  # Should point at your Nixpkgs installation.
  pkgPath = ./pkgs;

  pkgs = import (pkgPath + /system/all-packages.nix) {};

  stdenv = pkgs.stdenv;
  

  compileC = {main, localIncludes ? [], cFlags ? "", forSharedLib ? false}:
  stdenv.mkDerivation {
    name = "compile-c";
    builder = ./compile-c.sh;
    localIncludes =
      if localIncludes == "auto" then
        import (findIncludes {
          main = toString main;
          hack = __currentTime;
          inherit cFlags;
        })
      else
        localIncludes;
    inherit main;
    cFlags = [
      cFlags
      (if forSharedLib then ["-fpic"] else [])
    ];
  };

  /*
  runCommand = {command}: {
    name = "run-command";
    builder = ./run-command.sh;
    inherit command;
  };
  */

  findIncludes = {main, hack, cFlags ? ""}: stdenv.mkDerivation {
    name = "find-includes";
    builder = ./find-includes.sh;
    inherit main hack cFlags;
  };
  
  link = {objects, programName ? "program", libraries ? []}: stdenv.mkDerivation {
    name = "link";
    builder = ./link.sh;
    inherit objects programName libraries;
  };

  makeLibrary = {objects, libraryName ? [], sharedLib ? false}:
  # assert sharedLib -> fold (obj: x: assert obj.sharedLib && x) false objects
  stdenv.mkDerivation {
    name = "library";
    builder = ./make-library.sh;
    inherit objects libraryName sharedLib;
  };

}