mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
* `dependencyClosure' now allows a search path, e.g.,
dependencyClosure { ... searchPath = [ ../foo ../bar ]; ... } * Primop `dirOf' to return the directory part of a path (e.g., dirOf /a/b/c == /a/b). * Primop `relativise' (according to Webster that's a real word!) that given paths A and B returns a string representing path B relative path to A; e.g., relativise /a/b/c a/b/x/y => "../x/y".
This commit is contained in:
parent
08c53923db
commit
e1a6fb7870
5 changed files with 89 additions and 32 deletions
|
@ -8,10 +8,17 @@ rec {
|
|||
stdenv = pkgs.stdenv;
|
||||
|
||||
|
||||
compileC = {main, localIncludes ? "auto", cFlags ? "", sharedLib ? false}:
|
||||
compileC =
|
||||
{ main
|
||||
, localIncludes ? "auto"
|
||||
, localIncludePath ? []
|
||||
, cFlags ? ""
|
||||
, sharedLib ? false
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
name = "compile-c";
|
||||
builder = ./compile-c.sh;
|
||||
|
||||
localIncludes =
|
||||
if localIncludes == "auto" then
|
||||
dependencyClosure {
|
||||
|
@ -19,38 +26,37 @@ rec {
|
|||
import (findIncludes {
|
||||
inherit main;
|
||||
});
|
||||
searchPath = localIncludePath;
|
||||
startSet = [main];
|
||||
}
|
||||
else
|
||||
localIncludes;
|
||||
|
||||
inherit main;
|
||||
|
||||
cFlags = [
|
||||
cFlags
|
||||
(if sharedLib then ["-fpic"] else [])
|
||||
(map (p: "-I" + (relativise (dirOf main) p)) localIncludePath)
|
||||
];
|
||||
};
|
||||
|
||||
/*
|
||||
runCommand = {command}: {
|
||||
name = "run-command";
|
||||
builder = ./run-command.sh;
|
||||
inherit command;
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
findIncludes = {main}: stdenv.mkDerivation {
|
||||
name = "find-includes";
|
||||
realBuilder = pkgs.perl ~ "bin/perl";
|
||||
args = [ ./find-includes.pl ];
|
||||
inherit main;
|
||||
};
|
||||
|
||||
|
||||
|
||||
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 {
|
||||
|
@ -59,4 +65,5 @@ rec {
|
|||
inherit objects libraryName sharedLib;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue