my local debugging

This commit is contained in:
Greg Shuflin
2025-12-01 02:14:43 -08:00
parent 3c2bc194c1
commit 8f93a44cac
3 changed files with 41 additions and 9 deletions

View File

@@ -1,7 +1,9 @@
#include <stdint.h> #include <stdint.h>
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <SDL3/SDL_error.h>
#include <SDL3_image/SDL_image.h> #include <SDL3_image/SDL_image.h>
#include <lean/lean.h> #include <lean/lean.h>
#include <stdio.h>
static SDL_Window* g_window = NULL; static SDL_Window* g_window = NULL;
static SDL_Renderer* g_renderer = 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) { lean_obj_res sdl_init(uint32_t flags, lean_obj_arg w) {
int32_t result = SDL_Init(flags); 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)); return lean_io_result_mk_ok(lean_box_uint32(result));
} }
@@ -132,4 +138,4 @@ lean_obj_res sdl_render_texture_column(uint32_t dst_x, uint32_t dst_y, uint32_t
SDL_FRect dst_rect = {(float)dst_x, (float)dst_y, 1.0f, (float)dst_height}; SDL_FRect dst_rect = {(float)dst_x, (float)dst_y, 1.0f, (float)dst_height};
return lean_io_result_mk_ok(lean_box_uint32(SDL_RenderTexture(g_renderer, g_wall_texture, &src_rect, &dst_rect))); return lean_io_result_mk_ok(lean_box_uint32(SDL_RenderTexture(g_renderer, g_wall_texture, &src_rect, &dst_rect)));
} }

25
justfile Normal file
View 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

View File

@@ -115,13 +115,14 @@ target libleansdl pkg : FilePath := do
if entry.path.extension == some "dll" then if entry.path.extension == some "dll" then
copyFile entry.path (".lake/build/bin/" / entry.path.fileName.get!) copyFile entry.path (".lake/build/bin/" / entry.path.fileName.get!)
else else
-- binaries for Lean/Lake itself, like libgmp are on a different place on Linux -- binaries for Lean/Lake itself - only copy Lean-specific libraries, not all Nix libs
let lakeBinariesDir := ( IO.appPath).parent.get!.parent.get! / "lib" let leanLibDir := ( IO.appPath).parent.get!.parent.get! / "lib" / "lean"
println! "Copying Lake binaries from {lakeBinariesDir}" let leanLibDirExists System.FilePath.pathExists leanLibDir
if leanLibDirExists then
for entry in ( lakeBinariesDir.readDir) do println! "Copying Lean libraries from {leanLibDir}"
if entry.path.extension != none then for entry in ( leanLibDir.readDir) do
copyFile entry.path (".lake/build/bin/" / entry.path.fileName.get!) if entry.path.extension == some "so" then
copyFile entry.path (".lake/build/bin/" / entry.path.fileName.get!)
buildStaticLib (pkg.staticLibDir / name) #[sdlO] buildStaticLib (pkg.staticLibDir / name) #[sdlO]
@@ -138,4 +139,4 @@ lean_exe LeanDoomed where
moreLinkArgs := if Platform.isWindows then moreLinkArgs := if Platform.isWindows then
#["vendor/SDL/build/SDL3.dll", "vendor/SDL_image/build/SDL3_image.dll"] #["vendor/SDL/build/SDL3.dll", "vendor/SDL_image/build/SDL3_image.dll"]
else 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"]