Merge pull request #7 from ValorZard/remove-submodules
Remove submodules + simplify build
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
.lake/
|
.lake/
|
||||||
|
vendor/
|
||||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -1,6 +0,0 @@
|
|||||||
[submodule "SDL"]
|
|
||||||
path = vendor/SDL
|
|
||||||
url = https://github.com/libsdl-org/SDL.git
|
|
||||||
[submodule "SDL_image"]
|
|
||||||
path = vendor/SDL_image
|
|
||||||
url = https://github.com/libsdl-org/SDL_image.git
|
|
||||||
|
|||||||
@@ -14,14 +14,10 @@ Simple real-time Doom-style raycasting engine in Lean4:
|
|||||||
# Install elan if this is your first time using Lean
|
# Install elan if this is your first time using Lean
|
||||||
curl https://elan.lean-lang.org/elan-init.sh -sSf | sh
|
curl https://elan.lean-lang.org/elan-init.sh -sSf | sh
|
||||||
|
|
||||||
# Clone project and submodules (SDL3 etc)
|
# Clone project
|
||||||
git clone --recurse-submodules https://github.com/oOo0oOo/LeanDoomed.git
|
git clone --recursive https://github.com/oOo0oOo/LeanDoomed.git
|
||||||
cd LeanDoomed
|
cd LeanDoomed
|
||||||
|
|
||||||
# Build dependencies
|
|
||||||
chmod +x ./build_sdl_and_friends.sh
|
|
||||||
sudo ./build_sdl_and_friends.sh
|
|
||||||
|
|
||||||
# Run the "game"
|
# Run the "game"
|
||||||
lake exe LeanDoomed
|
lake exe LeanDoomed
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
cd vendor/SDL
|
|
||||||
cmake -S . -B build
|
|
||||||
cmake --build build
|
|
||||||
cd ../SDL_image
|
|
||||||
cmake -S . -B build -DSDL3_DIR=../SDL/build
|
|
||||||
cmake --build build
|
|
||||||
@@ -3,6 +3,15 @@ open System Lake DSL
|
|||||||
|
|
||||||
package LeanDoomed
|
package LeanDoomed
|
||||||
|
|
||||||
|
def sdlGitRepo : String := "https://github.com/libsdl-org/SDL.git"
|
||||||
|
def sdlRepoDir : String := "vendor/SDL"
|
||||||
|
|
||||||
|
def sdlImageGitRepo : String := "https://github.com/libsdl-org/SDL_image.git"
|
||||||
|
def sdlImageRepoDir : String := "vendor/SDL_image"
|
||||||
|
|
||||||
|
-- clone from a stable branch to avoid breakages
|
||||||
|
def sdlBranch : String := "release-3.2.x"
|
||||||
|
|
||||||
input_file sdl.c where
|
input_file sdl.c where
|
||||||
path := "c" / "sdl.c"
|
path := "c" / "sdl.c"
|
||||||
text := true
|
text := true
|
||||||
@@ -16,6 +25,74 @@ target sdl.o pkg : FilePath := do
|
|||||||
buildO oFile srcJob #[] #["-fPIC", s!"-I{sdlInclude}", s!"-I{sdlImageInclude}", "-D_REENTRANT", s!"-I{leanInclude}"] "cc"
|
buildO oFile srcJob #[] #["-fPIC", s!"-I{sdlInclude}", s!"-I{sdlImageInclude}", "-D_REENTRANT", s!"-I{leanInclude}"] "cc"
|
||||||
|
|
||||||
target libleansdl pkg : FilePath := do
|
target libleansdl pkg : FilePath := do
|
||||||
|
-- Helper function to run command and handle errors
|
||||||
|
-- Clone the repos if they don't exist
|
||||||
|
let sdlExists ← System.FilePath.pathExists sdlRepoDir
|
||||||
|
if !sdlExists then
|
||||||
|
IO.println "Cloning SDL"
|
||||||
|
let sdlClone ← IO.Process.output { cmd := "git", args := #["clone", "-b", sdlBranch, "--single-branch", "--depth", "1", "--recursive", sdlGitRepo, sdlRepoDir] }
|
||||||
|
if sdlClone.exitCode != 0 then
|
||||||
|
IO.println s!"Error cloning SDL: {sdlClone.stderr}"
|
||||||
|
else
|
||||||
|
IO.println "SDL cloned successfully"
|
||||||
|
IO.println sdlClone.stdout
|
||||||
|
|
||||||
|
let sdlImageExists ← System.FilePath.pathExists sdlImageRepoDir
|
||||||
|
if !sdlImageExists then
|
||||||
|
IO.println "Cloning SDL_image"
|
||||||
|
let sdlImageClone ← IO.Process.output { cmd := "git", args := #["clone", "-b", sdlBranch, "--single-branch", "--depth", "1", "--recursive", sdlImageGitRepo, sdlImageRepoDir] }
|
||||||
|
if sdlImageClone.exitCode != 0 then
|
||||||
|
IO.println s!"Error cloning SDL_image: {sdlImageClone.stderr}"
|
||||||
|
else
|
||||||
|
IO.println "SDL_image cloned successfully"
|
||||||
|
IO.println sdlImageClone.stdout
|
||||||
|
|
||||||
|
-- Build the repos with cmake
|
||||||
|
-- SDL itself needs to be built before SDL_image, as the latter depends on the former
|
||||||
|
-- We also need to make sure we are using a system provided C compiler, as the one that comes with Lean is missing important headers
|
||||||
|
IO.println "Building SDL"
|
||||||
|
-- Create build directory if it doesn't exist
|
||||||
|
let sdlBuildDirExists ← System.FilePath.pathExists (sdlRepoDir ++ "/build")
|
||||||
|
if !sdlBuildDirExists then
|
||||||
|
let configureSdlBuild ← IO.Process.output { cmd := "cmake", args := #["-S", sdlRepoDir, "-B", sdlRepoDir ++ "/build", "-DBUILD_SHARED_LIBS=ON", "-DCMAKE_BUILD_TYPE=Release", "-DCMAKE_C_COMPILER=cc"] }
|
||||||
|
if configureSdlBuild.exitCode != 0 then
|
||||||
|
IO.println s!"Error configuring SDL: {configureSdlBuild.stderr}"
|
||||||
|
else
|
||||||
|
IO.println "SDL configured successfully"
|
||||||
|
IO.println configureSdlBuild.stdout
|
||||||
|
else
|
||||||
|
IO.println "SDL build directory already exists, skipping configuration step"
|
||||||
|
-- now actually build SDL once we've configured it
|
||||||
|
let buildSdl ← IO.Process.output { cmd := "cmake", args := #["--build", sdlRepoDir ++ "/build", "--config", "Release",] }
|
||||||
|
if buildSdl.exitCode != 0 then
|
||||||
|
IO.println s!"Error building SDL: {buildSdl.exitCode}"
|
||||||
|
IO.println buildSdl.stderr
|
||||||
|
else
|
||||||
|
IO.println "SDL built successfully"
|
||||||
|
IO.println buildSdl.stdout
|
||||||
|
-- Build SDL_Image
|
||||||
|
IO.println "Building SDL_image"
|
||||||
|
-- Create SDL_Image build directory if it doesn't exist
|
||||||
|
let sdlImageBuildDirExists ← System.FilePath.pathExists (sdlImageRepoDir ++ "/build")
|
||||||
|
if !sdlImageBuildDirExists then
|
||||||
|
let currentDir ← IO.currentDir
|
||||||
|
let sdlConfigPath := currentDir / sdlRepoDir / "build"
|
||||||
|
let configureSdlImageBuild ← IO.Process.output { cmd := "cmake", args := #["-S", sdlImageRepoDir, "-B", sdlImageRepoDir ++ "/build", s!"-DSDL3_DIR={sdlConfigPath}", "-DBUILD_SHARED_LIBS=ON", "-DCMAKE_BUILD_TYPE=Release", "-DCMAKE_C_COMPILER=cc"] }
|
||||||
|
if configureSdlImageBuild.exitCode != 0 then
|
||||||
|
IO.println s!"Error configuring SDL_image: {configureSdlImageBuild.stderr}"
|
||||||
|
else
|
||||||
|
IO.println "SDL_image configured successfully"
|
||||||
|
IO.println configureSdlImageBuild.stdout
|
||||||
|
else
|
||||||
|
IO.println "SDL_image build directory already exists, skipping configuration step"
|
||||||
|
-- now actually build SDL_image once we've configured it
|
||||||
|
let buildSdlImage ← IO.Process.output { cmd := "cmake", args := #["--build", sdlImageRepoDir ++ "/build", "--config", "Release"] }
|
||||||
|
if buildSdlImage.exitCode != 0 then
|
||||||
|
IO.println s!"Error building SDL_image: {buildSdlImage.stderr}"
|
||||||
|
else
|
||||||
|
IO.println "SDL_image built successfully"
|
||||||
|
IO.println buildSdlImage.stdout
|
||||||
|
|
||||||
let sdlO ← sdl.o.fetch
|
let sdlO ← sdl.o.fetch
|
||||||
let name := nameToStaticLib "leansdl"
|
let name := nameToStaticLib "leansdl"
|
||||||
-- manually copy the DLLs we need to .lake/build/bin/ for the game to work
|
-- manually copy the DLLs we need to .lake/build/bin/ for the game to work
|
||||||
|
|||||||
1
vendor/SDL
vendored
1
vendor/SDL
vendored
Submodule vendor/SDL deleted from dc7a3a1219
1
vendor/SDL_image
vendored
1
vendor/SDL_image
vendored
Submodule vendor/SDL_image deleted from 21167aaec8
Reference in New Issue
Block a user