Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
xfnty committed Jun 29, 2023
1 parent 3ec3007 commit 195d7a8
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 479 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@ jobs:
runs-on: ubuntu-20.04 # for GLIBC 2.31
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
sudo apt install -y build-essential git cmake libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev
- name: Configuring CMake
run: |
python toolchain.py -c --target Release
make configure
- name: Building
run: |
python toolchain.py -b --target Release
make build
8 changes: 2 additions & 6 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Configuring CMake
run: python toolchain.py -c --target Release
run: make configure

- name: Building
run: python toolchain.py -b --target Release
run: make build
12 changes: 4 additions & 8 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Configuring CMake
run: |
python toolchain.py -c --target Release
run: make configure

- name: Building
run: |
python toolchain.py -b --target Release
run: make build
114 changes: 0 additions & 114 deletions .github/workflows/release.yml

This file was deleted.

3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ compile_commands.json


# Folders
build/
bin/
.cmake/
.ignore/
.cache/
Expand All @@ -16,7 +16,6 @@ CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
Expand Down
32 changes: 11 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ include("CMakeHelpers.cmake")


# ===== Build options ===== #
set(PROJECT_BUILD_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build")
set(PROJECT_BUILD_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
option(BUILD_SHARED_LIBS "Build shared libs" OFF)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
add_compile_options(-O0 -g)
endif()


# ===== Project ===== #
Expand Down Expand Up @@ -37,23 +40,10 @@ link_libraries(${LINK_LIBRARIES})
# ===== Targets ===== #
add_executable(${PROJECT_NAME} ${SOURCE_MAIN} ${SOURCES})
add_library("lib-${PROJECT_NAME}" STATIC ${SOURCES})
if (UNIX)
set_target_properties(
${PROJECT_NAME}
PROPERTIES
OUTPUT_NAME "${PROJECT_NAME}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJECT_BUILD_DIRECTORY}/debug"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BUILD_DIRECTORY}/release"
)
elseif (WIN32)
set_target_properties(
${PROJECT_NAME}
PROPERTIES
OUTPUT_NAME "${PROJECT_NAME}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJECT_BUILD_DIRECTORY}\\debug"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BUILD_DIRECTORY}\\release"
)
endif()

# ===== Sandbox ===== #
add_subdirectory("sandbox")
set_target_properties(
${PROJECT_NAME}
PROPERTIES
OUTPUT_NAME "${PROJECT_NAME}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJECT_BUILD_DIRECTORY}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BUILD_DIRECTORY}"
)
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
MAKEFLAGS=--no-print-directory --quiet

PROJECT_NAME=flappy-bird
CMAKE_DIR=.cmake
OUTPUT_DIR=bin
EXE=$(OUTPUT_DIR)/$(PROJECT_NAME)

CONFIGURE=configure c
BUILD=build b
RUN=run r
DEBUG=debug d

all: configure build run

$(CONFIGURE):
echo ----- Configuring -----
mkdir -p $(CMAKE_DIR)
cmake -B $(CMAKE_DIR) -S . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1
cp -f $(CMAKE_DIR)/compile_commands.json ./compile_commands.json

$(BUILD):
echo ----- Building -----
mkdir -p $(OUTPUT_DIR)
cmake --build $(CMAKE_DIR)

$(RUN):
echo ----- Running -----
cp -rf ./assets $(OUTPUT_DIR)
cd $(OUTPUT_DIR)
$(EXE)

$(DEBUG):
echo ----- Debugging -----
cp -rf ./assets $(OUTPUT_DIR)
cd $(OUTPUT_DIR)
gdb -q --return-child-result $(EXE)

clean:
git clean -Xdfq

.PHONY=$(CONFIGURE) $(BUILD) $(RUN) $(DEBUG) clean
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ On Linux
sudo apt install -y build-essential git cmake libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev
```
On Windows
- [Install Python3](https://www.python.org/downloads/)
- [Install CMake](https://cmake.org/download/)
- [Check out Raylib installation guide](https://github.com/raysan5/raylib/wiki/Working-on-Windows) (everything should work anyway)

### Building
Run `toolchain.py` from the project root:
```
python toolchain.py -cbr
make configure build run
```
Run `./toolchain.py -h` to see all available options.
29 changes: 0 additions & 29 deletions sandbox/CMakeLists.txt

This file was deleted.

18 changes: 0 additions & 18 deletions sandbox/src/main.c

This file was deleted.

Loading

0 comments on commit 195d7a8

Please sign in to comment.