allow building with nix

This commit is contained in:
Michael Bishop 2021-11-07 03:25:49 -04:00
parent a32fbb6d51
commit 9c818c89be
6 changed files with 120 additions and 7 deletions

View File

@ -62,7 +62,7 @@ TARGET = $(EXENAME)$(EXE)
DELETEFILES = $(MUSASHIGENCFILES) $(MUSASHIGENHFILES) $(.OFILES) $(.OFILES:%.o=%.d) $(TARGET) $(MUSASHIGENERATOR)$(EXE)
all: $(MUSASHIGENCFILES) $(MUSASHIGENHFILES) $(TARGET)
all: $(MUSASHIGENCFILES) $(MUSASHIGENHFILES) $(TARGET) buptest
clean:
rm -f $(DELETEFILES)
@ -70,6 +70,9 @@ clean:
$(TARGET): $(MUSAHIGENCFILES:%.c=%.o) $(.CFILES:%.c=%.o) a314/a314.o
$(CC) -o $@ $^ -O3 -pthread $(LFLAGS) -lm -lstdc++
buptest: buptest.c gpio/ps_protocol.c
$(CC) $^ -o $@ -I./ -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O0
a314/a314.o: a314/a314.cc a314/a314.h
$(CXX) -MMD -MP -c -o a314/a314.o -O3 a314/a314.cc -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -I. -I..

View File

@ -358,14 +358,14 @@ void *keyboard_task() {
struct pollfd kbdpoll[1];
int kpollrc;
char c = 0, c_code = 0, c_type = 0;
char grab_message[] = "[KBD] Grabbing keyboard from input layer\n",
ungrab_message[] = "[KBD] Ungrabbing keyboard\n";
char grab_message[] = "[KBD] Grabbing keyboard from input layer",
ungrab_message[] = "[KBD] Ungrabbing keyboard";
printf("[KBD] Keyboard thread started\n");
// because we permit the keyboard to be grabbed on startup, quickly check if we need to grab it
if (kb_hook_enabled && cfg->keyboard_grab) {
printf(grab_message);
puts(grab_message);
grab_device(keyboard_fd);
}
@ -395,7 +395,7 @@ key_loop:
printf("[KBD] Keyboard hook enabled.\n");
if (cfg->keyboard_grab) {
grab_device(keyboard_fd);
printf(grab_message);
puts(grab_message);
}
} else if (kb_hook_enabled) {
if (c == 0x1B && c_type) {
@ -403,7 +403,7 @@ key_loop:
printf("[KBD] Keyboard hook disabled.\n");
if (cfg->keyboard_grab) {
release_device(keyboard_fd);
printf(ungrab_message);
puts(ungrab_message);
}
} else {
if (queue_keypress(c_code, c_type, cfg->platform->id)) {
@ -472,7 +472,7 @@ key_loop:
key_end:
printf("[KBD] Keyboard thread ending\n");
if (cfg->keyboard_grab) {
printf(ungrab_message);
puts(ungrab_message);
release_device(keyboard_fd);
}
return (void*)NULL;

25
flake.lock generated Normal file
View File

@ -0,0 +1,25 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1636242081,
"narHash": "sha256-lfMU1G5sj1E5xBaR8JF0Nu2GBZ40iMNm205fh9cCJj4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "50d250c7db4070963cb403ad616042220e6bb221",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

36
flake.nix Normal file
View File

@ -0,0 +1,36 @@
{
outputs = { self, nixpkgs }:
let
hostPkgs = import nixpkgs { system = "x86_64-linux"; };
overlay = self: super: {
pistorm = self.callPackage ./pistorm.nix {};
e2fsprogs = null;
libraspberrypi = super.libraspberrypi.overrideAttrs (old: { patches = [ ./userland.patch ]; });
pistorm-tar = hostPkgs.callPackage (nixpkgs + "/nixos/lib/make-system-tarball.nix") {
contents = [];
storeContents = [
{
object = self.pistorm;
symlink = "/pistorm";
}
];
};
};
in {
packages.aarch64-linux =
let
pkgs = import nixpkgs { system = "aarch64-linux"; overlays = [ overlay ]; };
in {
inherit (pkgs) pistorm;
};
packages.armv7l-linux =
let
pkgs = import nixpkgs { system = "armv7l-linux"; overlays = [ overlay ]; };
in {
inherit (pkgs) pistorm pistorm-tar;
};
hydraJobs.armv7l-linux = {
inherit (self.packages.armv7l-linux) pistorm pistorm-tar;
};
};
}

35
pistorm.nix Normal file
View File

@ -0,0 +1,35 @@
{ stdenv, libraspberrypi, alsaLib, openocd, makeWrapper }:
stdenv.mkDerivation {
name = "pistorm";
src = ./.;
enableParallelBuilding = false;
buildInputs = [ libraspberrypi alsaLib makeWrapper ];
installPhase = ''
find | grep --color buptest
pwd
ls -ltrh
mkdir -pv $out/bin $out/share/pistorm
cp -vi emulator buptest $out/bin/
cp -vr rtl $out/share/pistorm
cp -vr nprog $out/share/pistorm
cp -v *.cfg $out/share/pistorm
cp -vr data $out/share/pistorm
mkdir -pv $out/share/pistorm/platforms/amiga/piscsi
cp -v platforms/amiga/piscsi/piscsi.rom $out/share/pistorm/platforms/amiga/piscsi/
cp -v platforms/amiga/pistorm.hdf $out/share/pistorm/platforms/amiga/
mkdir -pv $out/share/pistorm/platforms/amiga/rtg
cp -v platforms/amiga/rtg/*.shader $out/share/pistorm/platforms/amiga/rtg/
cat <<EOF > $out/bin/pistorm
#!${stdenv.shell}
cd $out/share/pistorm
$out/bin/emulator "\''${@}"
EOF
chmod +x $out/bin/pistorm
cp -v *.sh $out/bin/
#wrapProgram $out/bin/nprog.sh --prefix PATH : {openocd}/bin
'';
}

14
userland.patch Normal file
View File

@ -0,0 +1,14 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fe67fc8..5154630 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,9 +66,7 @@ endif()
add_subdirectory(interface/vcos)
add_subdirectory(interface/vmcs_host)
add_subdirectory(interface/vchiq_arm)
-if(NOT ARM64)
add_subdirectory(interface/khronos)
-endif()
#add_subdirectory(opensrc/tools/lua)
if(BUILD_MMAL)