summary refs log tree commit diff
path: root/pkgs/test/simple/builder.sh
blob: 282fc520bd1f74f6cbaf47e93eb5b454f605a791 (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
#! /bin/sh

export NIX_DEBUG=1

. $stdenv/setup

#export NIX_CFLAGS_COMPILE="-v $NIX_CFLAGS_COMPILE"

mkdir $out
mkdir $out/bin

cat > hello.c <<EOF
#include <stdio.h>

int main(int argc, char * * argv)
{
    printf("Hello World!\n");
    return 0;
}
EOF

#gcc -I/nix/store/foo -I /nix/store/foo -I/usr/lib -I /usr/lib hello.c -o $out/bin/hello
gcc -L /nix/store/abcd/lib -isystem /usr/lib hello.c -o $out/bin/hello

$out/bin/hello

cat > hello2.cc <<EOF
#include <iostream>

int main(int argc, char * * argv)
{
    std::cout << "Hello World!\n";
    std::cout << VALUE << std::endl;
    return 0;
}
EOF

g++ hello2.cc -o $out/bin/hello2 -DVALUE="1 + 2 * 3"

$out/bin/hello2

ld -v