diff options
Diffstat (limited to 'make/examples')
-rw-r--r-- | make/examples/aterm/aterm/default.nix | 34 | ||||
-rw-r--r-- | make/examples/aterm/default.nix | 1 | ||||
-rw-r--r-- | make/examples/aterm/test/default.nix | 18 | ||||
-rw-r--r-- | make/examples/default.nix | 6 | ||||
-rw-r--r-- | make/examples/not-so-simple-header-auto/bar/hello.h | 1 | ||||
-rw-r--r-- | make/examples/not-so-simple-header-auto/default.nix | 11 | ||||
-rw-r--r-- | make/examples/not-so-simple-header-auto/foo/fnord/indirect.h | 3 | ||||
-rw-r--r-- | make/examples/not-so-simple-header-auto/foo/hello.c | 9 | ||||
-rw-r--r-- | make/examples/not-so-simple-header/bar/hello.h | 1 | ||||
-rw-r--r-- | make/examples/not-so-simple-header/default.nix | 14 | ||||
-rw-r--r-- | make/examples/not-so-simple-header/foo/fnord/indirect.h | 3 | ||||
-rw-r--r-- | make/examples/not-so-simple-header/foo/hello.c | 9 | ||||
-rw-r--r-- | make/examples/simple-header/default.nix | 11 | ||||
-rw-r--r-- | make/examples/simple-header/hello.c | 9 | ||||
-rw-r--r-- | make/examples/simple-header/hello.h | 1 | ||||
-rw-r--r-- | make/examples/trivial/default.nix | 8 | ||||
-rw-r--r-- | make/examples/trivial/hello.c | 7 |
17 files changed, 146 insertions, 0 deletions
diff --git a/make/examples/aterm/aterm/default.nix b/make/examples/aterm/aterm/default.nix new file mode 100644 index 000000000000..8b139219e916 --- /dev/null +++ b/make/examples/aterm/aterm/default.nix @@ -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; + }; + +} diff --git a/make/examples/aterm/default.nix b/make/examples/aterm/default.nix new file mode 100644 index 000000000000..edaac40aa499 --- /dev/null +++ b/make/examples/aterm/default.nix @@ -0,0 +1 @@ +import test/default.nix \ No newline at end of file diff --git a/make/examples/aterm/test/default.nix b/make/examples/aterm/test/default.nix new file mode 100644 index 000000000000..b7a9dd361977 --- /dev/null +++ b/make/examples/aterm/test/default.nix @@ -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]; +} diff --git a/make/examples/default.nix b/make/examples/default.nix new file mode 100644 index 000000000000..8b5b8bca5efc --- /dev/null +++ b/make/examples/default.nix @@ -0,0 +1,6 @@ +[ (import ./trivial) + (import ./simple-header) + (import ./not-so-simple-header) + (import ./not-so-simple-header-auto) + (import ./aterm) +] \ No newline at end of file diff --git a/make/examples/not-so-simple-header-auto/bar/hello.h b/make/examples/not-so-simple-header-auto/bar/hello.h new file mode 100644 index 000000000000..4595fad98d43 --- /dev/null +++ b/make/examples/not-so-simple-header-auto/bar/hello.h @@ -0,0 +1 @@ +#define WHAT "World" diff --git a/make/examples/not-so-simple-header-auto/default.nix b/make/examples/not-so-simple-header-auto/default.nix new file mode 100644 index 000000000000..9e84b0c28ae5 --- /dev/null +++ b/make/examples/not-so-simple-header-auto/default.nix @@ -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]; +} diff --git a/make/examples/not-so-simple-header-auto/foo/fnord/indirect.h b/make/examples/not-so-simple-header-auto/foo/fnord/indirect.h new file mode 100644 index 000000000000..2fde1e26c1dd --- /dev/null +++ b/make/examples/not-so-simple-header-auto/foo/fnord/indirect.h @@ -0,0 +1,3 @@ +#define HELLO "Hello" + +#include "../../bar/hello.h" diff --git a/make/examples/not-so-simple-header-auto/foo/hello.c b/make/examples/not-so-simple-header-auto/foo/hello.c new file mode 100644 index 000000000000..7d5b402ce5c2 --- /dev/null +++ b/make/examples/not-so-simple-header-auto/foo/hello.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +#include "fnord/indirect.h" + +int main(int argc, char * * argv) +{ + printf(HELLO " " WHAT "\n"); + return 0; +} diff --git a/make/examples/not-so-simple-header/bar/hello.h b/make/examples/not-so-simple-header/bar/hello.h new file mode 100644 index 000000000000..4595fad98d43 --- /dev/null +++ b/make/examples/not-so-simple-header/bar/hello.h @@ -0,0 +1 @@ +#define WHAT "World" diff --git a/make/examples/not-so-simple-header/default.nix b/make/examples/not-so-simple-header/default.nix new file mode 100644 index 000000000000..61ded57c82bb --- /dev/null +++ b/make/examples/not-so-simple-header/default.nix @@ -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]; +} diff --git a/make/examples/not-so-simple-header/foo/fnord/indirect.h b/make/examples/not-so-simple-header/foo/fnord/indirect.h new file mode 100644 index 000000000000..2fde1e26c1dd --- /dev/null +++ b/make/examples/not-so-simple-header/foo/fnord/indirect.h @@ -0,0 +1,3 @@ +#define HELLO "Hello" + +#include "../../bar/hello.h" diff --git a/make/examples/not-so-simple-header/foo/hello.c b/make/examples/not-so-simple-header/foo/hello.c new file mode 100644 index 000000000000..7d5b402ce5c2 --- /dev/null +++ b/make/examples/not-so-simple-header/foo/hello.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +#include "fnord/indirect.h" + +int main(int argc, char * * argv) +{ + printf(HELLO " " WHAT "\n"); + return 0; +} diff --git a/make/examples/simple-header/default.nix b/make/examples/simple-header/default.nix new file mode 100644 index 000000000000..e943471aaa4c --- /dev/null +++ b/make/examples/simple-header/default.nix @@ -0,0 +1,11 @@ +let { + + inherit (import ../../lib) compileC link; + + hello = link {objects = compileC { + main = ./hello.c; + localIncludes = [ [./hello.h "hello.h"] ]; + };}; + + body = [hello]; +} diff --git a/make/examples/simple-header/hello.c b/make/examples/simple-header/hello.c new file mode 100644 index 000000000000..15f1ac714e10 --- /dev/null +++ b/make/examples/simple-header/hello.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +#include "hello.h" + +int main(int argc, char * * argv) +{ + printf("Hello " WHAT "\n"); + return 0; +} diff --git a/make/examples/simple-header/hello.h b/make/examples/simple-header/hello.h new file mode 100644 index 000000000000..4595fad98d43 --- /dev/null +++ b/make/examples/simple-header/hello.h @@ -0,0 +1 @@ +#define WHAT "World" diff --git a/make/examples/trivial/default.nix b/make/examples/trivial/default.nix new file mode 100644 index 000000000000..132245e5823f --- /dev/null +++ b/make/examples/trivial/default.nix @@ -0,0 +1,8 @@ +let { + + inherit (import ../../lib) compileC link; + + hello = link {objects = compileC {main = ./hello.c;};}; + + body = [hello]; +} diff --git a/make/examples/trivial/hello.c b/make/examples/trivial/hello.c new file mode 100644 index 000000000000..237ad8ffe76f --- /dev/null +++ b/make/examples/trivial/hello.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char * * argv) +{ + printf("Hello World\n"); + return 0; +} |