initial setup

This commit is contained in:
snit 2024-09-28 01:34:31 -05:00
commit 3a0691aa3b
5 changed files with 104 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
build/

32
CMakeLists.txt Normal file
View File

@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.10)
# Set the project name and specify the languages
project(simworld LANGUAGES C)
# Set compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -Wshadow -Wwrite-strings -Wstrict-prototypes")
# Specify the source directory
set(SOURCE_DIR ${CMAKE_SOURCE_DIR}/src)
# Create a list of source files
file(GLOB_RECURSE SOURCES ${SOURCE_DIR}/*.c)
# Create the executable from the source files
add_executable(${PROJECT_NAME} ${SOURCES})
# Dependencies
find_package(PkgConfig REQUIRED)
pkg_check_modules(LUA REQUIRED lua)
target_link_libraries(${PROJECT_NAME} ${LUA_LIBRARIES})
target_include_directories(${PROJECT_NAME} PRIVATE ${LUA_INCLUDE_DIRS})
# `#define DEBUG` if `cmake -DCMAKE_BUILD_TYPE=debug`
if(CMAKE_BUILD_TYPE STREQUAL "debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_DEBUG)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_RELEASE)
endif()

18
README.gmi Normal file
View File

@ -0,0 +1,18 @@
# Simworld Lite
Simworld is a zero-player game in which players create simulated environments and ecosystems that run with no user intervention. The environments and the creatures that inhabit them are all completely defined through user-created mods. Though there's no real goal to the game, a good challenge is to create ecosystems that are self-sustaining and can thus run indefinitely.
Note: I'm not galaxy-brained enough to do the full idea at the moment, so this is the "lite" version, contianing only the bare minimum to make the idea work.
## Build from Source
### Dependencies
* CMake
* Lua 5.4
### Building
```
mkdir -p build/
cd build/
cmake ..
make
./simworld
```

45
build.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/sh
set -e
run_exe=0
## Ensure first argument is correct
if [ "$1" = "debug" ]; then
debug=1
elif [ "$1" = "release" ]; then
debug=0
else
echo "Run as '$0 debug' or '$0 release'"
exit 1
fi
## Ensure second argument is correct
if [ "$2" = "run" ]; then
run_exe=1
fi
## Ensure its run in the right place
if ! [ -f "CMakeLists.txt" ]; then
echo "Run in the project root"
exit 1
fi
mkdir -p build
cd build || exit
if [ ${debug} -eq 1 ]; then
echo debug
cmake -DCMAKE_BUILD_TYPE=debug ..
else
echo release
cmake -DCMAKE_BUILD_TYPE=release ..
fi
make
if [ ${run_exe} -eq 1 ]; then
./simworld
fi
cd ..

8
src/main.c Normal file
View File

@ -0,0 +1,8 @@
// main.c
#include <stdio.h>
int main(void) {
puts("Hello, world!");
return 0;
}