1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-14 14:32:42 +01:00

* Linker accepts a name for the program.

* Better diagnostics.
This commit is contained in:
Eelco Dolstra 2004-07-06 14:10:09 +00:00
parent 0920fe3038
commit 321be4649d
4 changed files with 10 additions and 7 deletions

View file

@ -2,7 +2,7 @@ let {
inherit (import ../../lib) compileC link;
hello = link {objects = compileC {
hello = link {programName = "hello"; objects = compileC {
main = ./foo/hello.c;
localIncludes = [
[./foo/fnord/indirect.h "fnord/indirect.h"]

View file

@ -2,7 +2,7 @@
mainName=$(basename $main | cut -c34-)
echo "compiling $mainName..."
echo "compiling \`$mainName'..."
# Turn $localIncludes into an array.
localIncludes=($localIncludes)
@ -67,4 +67,5 @@ done
ln -s $main $prefix$mainName
mkdir $out
gcc -Wall -c $prefix$mainName -o $out/$mainName.o
test "$prefix" && cd $prefix
gcc -Wall -c $mainName -o $out/$mainName.o

View file

@ -8,10 +8,10 @@ rec {
inherit main localIncludes;
};
link = {objects}: stdenv.mkDerivation {
link = {objects, programName ? "program"}: stdenv.mkDerivation {
name = "link";
builder = ./link.sh;
inherit objects;
inherit objects programName;
};
}

View file

@ -2,9 +2,11 @@
objs=
for i in "$objects"; do
obj=$i/*.o
obj=$(echo $i/*.o)
objs="$objs $obj"
done
echo "linking object files into \`$programName'..."
mkdir $out
gcc -o $out/program $objs
gcc -o $out/$programName $objs