Extract base into something like a library
This commit is contained in:
parent
6c02253868
commit
53651c161b
29
flake.nix
29
flake.nix
|
@ -28,7 +28,8 @@
|
|||
];
|
||||
};
|
||||
|
||||
/*
|
||||
packages."x86_64-linux"."base-attiny85" = (packages."x86_64-linux"."base" attiny85);
|
||||
|
||||
packages."x86_64-linux"."base" =
|
||||
{ mcu, chip_select, f_cpu }:
|
||||
let
|
||||
|
@ -38,8 +39,16 @@
|
|||
name = "base";
|
||||
src = ./.;
|
||||
|
||||
CFLAGS = cflags { inherit mcu chip_select f_cpu; };
|
||||
|
||||
buildPhase = ''
|
||||
${avr.gcc}/bin/avr-gcc ${CFLAGS} -o base.o -c ${src}/base/base.c
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
cp base/base.h base.o $out/
|
||||
'';
|
||||
};
|
||||
*/
|
||||
|
||||
packages."x86_64-linux"."flame" =
|
||||
{ mcu, chip_select, f_cpu }:
|
||||
|
@ -52,11 +61,19 @@
|
|||
|
||||
CFLAGS = cflags { inherit mcu chip_select f_cpu; };
|
||||
|
||||
buildInputs = [
|
||||
(packages."x86_64-linux"."base" { inherit mcu chip_select f_cpu; })
|
||||
];
|
||||
|
||||
INCLUDE_DIRS = pkgs.lib.concatStringsSep " " (map (dir: "-I${dir}") buildInputs);
|
||||
OBJECT_FILES = pkgs.lib.concatStringsSep " " (map (dir: "${dir}/*.o") buildInputs);
|
||||
|
||||
buildPhase = ''
|
||||
${avr.gcc}/bin/avr-gcc ${CFLAGS} -I${src}/base -o base.o -c ${src}/base/base.c
|
||||
${avr.gcc}/bin/avr-gcc ${CFLAGS} -I${src}/base -o sk9822.o -c ${src}/sk9822/sk9822.c
|
||||
${avr.gcc}/bin/avr-gcc ${CFLAGS} -I${src}/base -I${src}/sk9822 -o main.o -c ${src}/flame/main.c
|
||||
${avr.gcc}/bin/avr-gcc ${CFLAGS} -o flame.elf main.o sk9822.o base.o
|
||||
set -x
|
||||
echo Object files: ${OBJECT_FILES}
|
||||
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o sk9822.o -c ${src}/sk9822/sk9822.c
|
||||
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -I${src}/sk9822 -o main.o -c ${src}/flame/main.c
|
||||
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o flame.elf main.o sk9822.o ${OBJECT_FILES}
|
||||
$OBJCOPY -O ihex flame.elf flame.hex
|
||||
'';
|
||||
installPhase = ''
|
||||
|
|
Loading…
Reference in New Issue