mirror of
https://github.com/NixOS/nix
synced 2025-07-07 14:21:48 +02:00
* Merge remaining stuff from the nix-make branch.
* Add support for the creation of shared libraries to `compileC', `link', and `makeLibrary'. * Enable the ATerm library to be made into a shared library.
This commit is contained in:
parent
02f2da0142
commit
36fb29f8f0
22 changed files with 347 additions and 0 deletions
34
make/examples/aterm/aterm/default.nix
Normal file
34
make/examples/aterm/aterm/default.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{sharedLib ? true}:
|
||||
|
||||
rec {
|
||||
|
||||
inherit (import ../../../lib) compileC makeLibrary;
|
||||
|
||||
sources = [
|
||||
./afun.c
|
||||
./aterm.c
|
||||
./bafio.c
|
||||
./byteio.c
|
||||
./gc.c
|
||||
./hash.c
|
||||
./list.c
|
||||
./make.c
|
||||
./md5c.c
|
||||
./memory.c
|
||||
./tafio.c
|
||||
./version.c
|
||||
];
|
||||
|
||||
compile = fn: compileC {
|
||||
main = fn;
|
||||
localIncludes = "auto";
|
||||
forSharedLib = sharedLib;
|
||||
};
|
||||
|
||||
libATerm = makeLibrary {
|
||||
libraryName = "ATerm";
|
||||
objects = map compile sources;
|
||||
inherit sharedLib;
|
||||
};
|
||||
|
||||
}
|
1
make/examples/aterm/default.nix
Normal file
1
make/examples/aterm/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
import test/default.nix
|
18
make/examples/aterm/test/default.nix
Normal file
18
make/examples/aterm/test/default.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
let {
|
||||
|
||||
inherit (import ../../../lib) compileC link;
|
||||
|
||||
inherit (import ../aterm {}) libATerm;
|
||||
|
||||
compile = fn: compileC {
|
||||
main = fn;
|
||||
localIncludes = "auto";
|
||||
cFlags = "-I../aterm";
|
||||
};
|
||||
|
||||
fib = link {objects = compile ./fib.c; libraries = libATerm;};
|
||||
|
||||
primes = link {objects = compile ./primes.c; libraries = libATerm;};
|
||||
|
||||
body = [fib primes];
|
||||
}
|
6
make/examples/default.nix
Normal file
6
make/examples/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
[ (import ./trivial)
|
||||
(import ./simple-header)
|
||||
(import ./not-so-simple-header)
|
||||
(import ./not-so-simple-header-auto)
|
||||
(import ./aterm)
|
||||
]
|
1
make/examples/not-so-simple-header-auto/bar/hello.h
Normal file
1
make/examples/not-so-simple-header-auto/bar/hello.h
Normal file
|
@ -0,0 +1 @@
|
|||
#define WHAT "World"
|
11
make/examples/not-so-simple-header-auto/default.nix
Normal file
11
make/examples/not-so-simple-header-auto/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
let {
|
||||
|
||||
inherit (import ../../lib) compileC findIncludes link;
|
||||
|
||||
hello = link {programName = "hello"; objects = compileC {
|
||||
main = ./foo/hello.c;
|
||||
localIncludes = "auto";
|
||||
};};
|
||||
|
||||
body = [hello];
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
#define HELLO "Hello"
|
||||
|
||||
#include "../../bar/hello.h"
|
9
make/examples/not-so-simple-header-auto/foo/hello.c
Normal file
9
make/examples/not-so-simple-header-auto/foo/hello.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "fnord/indirect.h"
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf(HELLO " " WHAT "\n");
|
||||
return 0;
|
||||
}
|
1
make/examples/not-so-simple-header/bar/hello.h
Normal file
1
make/examples/not-so-simple-header/bar/hello.h
Normal file
|
@ -0,0 +1 @@
|
|||
#define WHAT "World"
|
14
make/examples/not-so-simple-header/default.nix
Normal file
14
make/examples/not-so-simple-header/default.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
let {
|
||||
|
||||
inherit (import ../../lib) compileC link;
|
||||
|
||||
hello = link {programName = "hello"; objects = compileC {
|
||||
main = ./foo/hello.c;
|
||||
localIncludes = [
|
||||
[./foo/fnord/indirect.h "fnord/indirect.h"]
|
||||
[./bar/hello.h "fnord/../../bar/hello.h"]
|
||||
];
|
||||
};};
|
||||
|
||||
body = [hello];
|
||||
}
|
3
make/examples/not-so-simple-header/foo/fnord/indirect.h
Normal file
3
make/examples/not-so-simple-header/foo/fnord/indirect.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
#define HELLO "Hello"
|
||||
|
||||
#include "../../bar/hello.h"
|
9
make/examples/not-so-simple-header/foo/hello.c
Normal file
9
make/examples/not-so-simple-header/foo/hello.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "fnord/indirect.h"
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf(HELLO " " WHAT "\n");
|
||||
return 0;
|
||||
}
|
11
make/examples/simple-header/default.nix
Normal file
11
make/examples/simple-header/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
let {
|
||||
|
||||
inherit (import ../../lib) compileC link;
|
||||
|
||||
hello = link {objects = compileC {
|
||||
main = ./hello.c;
|
||||
localIncludes = [ [./hello.h "hello.h"] ];
|
||||
};};
|
||||
|
||||
body = [hello];
|
||||
}
|
9
make/examples/simple-header/hello.c
Normal file
9
make/examples/simple-header/hello.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "hello.h"
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf("Hello " WHAT "\n");
|
||||
return 0;
|
||||
}
|
1
make/examples/simple-header/hello.h
Normal file
1
make/examples/simple-header/hello.h
Normal file
|
@ -0,0 +1 @@
|
|||
#define WHAT "World"
|
8
make/examples/trivial/default.nix
Normal file
8
make/examples/trivial/default.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
let {
|
||||
|
||||
inherit (import ../../lib) compileC link;
|
||||
|
||||
hello = link {objects = compileC {main = ./hello.c;};};
|
||||
|
||||
body = [hello];
|
||||
}
|
7
make/examples/trivial/hello.c
Normal file
7
make/examples/trivial/hello.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf("Hello World\n");
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue