my local debugging
This commit is contained in:
6
c/sdl.c
6
c/sdl.c
@@ -1,7 +1,9 @@
|
||||
#include <stdint.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_error.h>
|
||||
#include <SDL3_image/SDL_image.h>
|
||||
#include <lean/lean.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static SDL_Window* g_window = NULL;
|
||||
static SDL_Renderer* g_renderer = NULL;
|
||||
@@ -9,6 +11,10 @@ static SDL_Texture* g_wall_texture = NULL;
|
||||
|
||||
lean_obj_res sdl_init(uint32_t flags, lean_obj_arg w) {
|
||||
int32_t result = SDL_Init(flags);
|
||||
if (!result) {
|
||||
const char* err = SDL_GetError();
|
||||
printf("Error initializing SDL %d : %s\n", result, err);
|
||||
}
|
||||
return lean_io_result_mk_ok(lean_box_uint32(result));
|
||||
}
|
||||
|
||||
|
||||
25
justfile
Normal file
25
justfile
Normal file
@@ -0,0 +1,25 @@
|
||||
# Build the project
|
||||
build:
|
||||
lake build
|
||||
patchelf --set-interpreter /usr/lib/ld-linux-x86-64.so.2 .lake/build/bin/LeanDoomed
|
||||
patchelf --set-rpath '$ORIGIN:/usr/lib' .lake/build/bin/LeanDoomed
|
||||
|
||||
# Run LeanDoomed
|
||||
run: build
|
||||
.lake/build/bin/LeanDoomed
|
||||
|
||||
# Run with X11 explicitly (for Wayland systems)
|
||||
run-x11: build
|
||||
SDL_VIDEODRIVER=x11 .lake/build/bin/LeanDoomed
|
||||
|
||||
# Run with Wayland explicitly
|
||||
run-wayland: build
|
||||
SDL_VIDEODRIVER=wayland .lake/build/bin/LeanDoomed
|
||||
|
||||
# Clean build artifacts
|
||||
clean:
|
||||
lake clean
|
||||
rm -rf .lake/build/bin/*.so*
|
||||
|
||||
# Rebuild from scratch
|
||||
rebuild: clean build
|
||||
@@ -115,13 +115,14 @@ target libleansdl pkg : FilePath := do
|
||||
if entry.path.extension == some "dll" then
|
||||
copyFile entry.path (".lake/build/bin/" / entry.path.fileName.get!)
|
||||
else
|
||||
-- binaries for Lean/Lake itself, like libgmp are on a different place on Linux
|
||||
let lakeBinariesDir := (← IO.appPath).parent.get!.parent.get! / "lib"
|
||||
println! "Copying Lake binaries from {lakeBinariesDir}"
|
||||
|
||||
for entry in (← lakeBinariesDir.readDir) do
|
||||
if entry.path.extension != none then
|
||||
copyFile entry.path (".lake/build/bin/" / entry.path.fileName.get!)
|
||||
-- binaries for Lean/Lake itself - only copy Lean-specific libraries, not all Nix libs
|
||||
let leanLibDir := (← IO.appPath).parent.get!.parent.get! / "lib" / "lean"
|
||||
let leanLibDirExists ← System.FilePath.pathExists leanLibDir
|
||||
if leanLibDirExists then
|
||||
println! "Copying Lean libraries from {leanLibDir}"
|
||||
for entry in (← leanLibDir.readDir) do
|
||||
if entry.path.extension == some "so" then
|
||||
copyFile entry.path (".lake/build/bin/" / entry.path.fileName.get!)
|
||||
|
||||
buildStaticLib (pkg.staticLibDir / name) #[sdlO]
|
||||
|
||||
@@ -138,4 +139,4 @@ lean_exe LeanDoomed where
|
||||
moreLinkArgs := if Platform.isWindows then
|
||||
#["vendor/SDL/build/SDL3.dll", "vendor/SDL_image/build/SDL3_image.dll"]
|
||||
else
|
||||
#["vendor/SDL/build/libSDL3.so", "vendor/SDL_image/build/libSDL3_image.so", "-Wl,--allow-shlib-undefined", "-Wl,-rpath=$ORIGIN", "-Wl,-rpath=$ORIGIN"]
|
||||
#["vendor/SDL/build/libSDL3.so", "vendor/SDL_image/build/libSDL3_image.so", "-Wl,--allow-shlib-undefined", "-Wl,-rpath=$ORIGIN"]
|
||||
|
||||
Reference in New Issue
Block a user