Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
skhaz committed Dec 12, 2024
1 parent ba5f525 commit 70f297c
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 184 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ jobs:
- name: Detect Conan Profile
run: conan profile detect --force

- name: Set Conan Center
run: conan remote update conancenter --url https://center2.conan.io

- name: Detect WebAssembly Conan Profile
if: matrix.config.name == 'WebAssembly'
run: |
Expand All @@ -67,7 +70,7 @@ jobs:
os=Emscripten
[tool_requires]
*: emsdk/3.1.44
*: emsdk/3.1.50
EOF
- name: Install Windows Or macOS Dependencies
Expand Down
54 changes: 24 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(OpenAL CONFIG REQUIRED)
set(SDL2_DIR "${CMAKE_BINARY_DIR}")

if(NOT CMAKE_SYSTEM_NAME MATCHES "Emscripten")
find_package(Boost CONFIG REQUIRED)
endif()

find_package(chipmunk2d CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(Ogg CONFIG REQUIRED)
Expand All @@ -16,53 +21,47 @@ find_package(SDL2 CONFIG REQUIRED)
find_package(SPNG CONFIG REQUIRED)
find_package(sol2 CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(OpenAL CONFIG REQUIRED)
find_package(Vorbis CONFIG REQUIRED)

if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
# WebSocket++
endif()

file(GLOB HEADER_FILES "src/*.hpp")
file(GLOB SOURCE_FILES "src/*.cpp")

add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_precompile_headers(${PROJECT_NAME} PRIVATE ${HEADER_FILES})

function(set_compile_options target)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
if (MSVC)
target_compile_options(${target} PRIVATE /W4 /Od /Zi)
else()
target_compile_options(${target} PRIVATE -Wall -Wextra -Werror -O0 -g)
endif()
elseif (CMAKE_BUILD_TYPE MATCHES "Release")
if (MSVC)
target_compile_options(${target} PRIVATE /W4 /O2 /GL)
else()
target_compile_options(${target} PRIVATE -Wall -Wextra -Werror -pedantic -O3 -flto)
endif()
if (CMAKE_BUILD_TYPE MATCHES "Debug")
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /Od /Zi)
endif()
endfunction()
if (NOT MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror -O0 -g)
endif()
endif()

set_compile_options(${PROJECT_NAME})
if (CMAKE_BUILD_TYPE MATCHES "Release")
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /O2 /GL)
endif()
if (NOT MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror -pedantic -O3 -flto)
endif()
endif()

if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set(EMSCRIPTEN_OPTIONS
"-s EVAL_CTORS=1"
"-s WASM_BIGINT=1"
"-s ALLOW_MEMORY_GROWTH=1"
"-s PTHREAD_POOL_SIZE=4"
"-s INITIAL_MEMORY=128MB"
"-l websocket.js"
"-s USE_SDL=2"
"-s WEBSOCKET_SUBPROTOCOL=text"
"-s EXPORTED_RUNTIME_METHODS=['callMain']"
# Debugging
# Debug
"-s ASSERTIONS=2"
# "-s RUNTIME_DEBUG"
"-s NO_DISABLE_EXCEPTION_CATCHING"
)

target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror -pedantic -O3 -flto)
target_link_libraries(${PROJECT_NAME} PRIVATE ${EMSCRIPTEN_OPTIONS})
endif()
Expand All @@ -86,10 +85,5 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
)

if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
target_link_libraries(${PROJECT_NAME} PRIVATE
OpenAL::OpenAL
# WebSocket++
)
target_link_libraries(${PROJECT_NAME} PRIVATE boost::boost OpenAL::OpenAL)
endif()

configure_file(${CMAKE_SOURCE_DIR}/assets/index.html ${CMAKE_BINARY_DIR}/index.html COPYONLY)
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.PHONY: help build clean configure watch
.SILENT:

SHELL := bash -eou pipefail

ifeq ($(shell command -v docker-compose;),)
COMPOSE := docker compose
else
COMPOSE := docker-compose
endif

help:
awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

clean: ## Clean
unalias rm 2>/dev/null || true
rm -rf build 2>/dev/null

build: ## Build
cmake --build build --parallel 8

configure: clean ## Configure
conan install . --output-folder=build --build=missing --profile=webassembly --settings compiler.cppstd=20 --settings build_type=Release
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DSDL2_DIR=generators -DCMAKE_BUILD_TYPE=Release -DSANDBOX=OFF

watch: configure ## Watch
while true; do ls src/*.{cpp,hpp} 2>/dev/null | entr -d cmake --build build --parallel 8; done
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Conan & pre-commit hooks
```shell
uv pip install -r requirements.txt
pre-commit install
conan profile detect --force
conan remote update conancenter --url https://center2.conan.io
conan install . --output-folder=build --build=missing --settings compiler.cppstd=20 --settings build_type=Release
```

Expand Down
58 changes: 0 additions & 58 deletions assets/index.html

This file was deleted.

Binary file removed assets/sandbox/blobs/deitzis.ogg
Binary file not shown.
Binary file removed assets/sandbox/blobs/matrix.avif
Binary file not shown.
79 changes: 0 additions & 79 deletions assets/sandbox/scripts/main.lua

This file was deleted.

29 changes: 29 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps


class MeuProjetoConan(ConanFile):
name = "Carimbo"
version = "1.0"
settings = "os", "arch", "compiler", "build_type"

def requirements(self):
self.requires("chipmunk2d/7.0.3")
self.requires("fmt/11.0.2")
self.requires("libspng/0.7.4")
self.requires("nlohmann_json/3.11.3")
self.requires("ogg/1.3.5")
self.requires("openal-soft/1.23.1")
self.requires("physfs/3.2.0")
self.requires("sdl/2.30.7")
self.requires("sol2/3.3.1")
self.requires("vorbis/1.3.7")

if not self.settings.os == "Emscripten":
self.requires("boost/1.86.0")

def generate(self):
tc = CMakeToolchain(self)
tc.generate()
deps = CMakeDeps(self)
deps.generate()
15 changes: 0 additions & 15 deletions conanfile.txt

This file was deleted.

2 changes: 1 addition & 1 deletion src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ application::application(int argc, char **argv) {
int application::run() {
try {
#if SANDBOX
// storage::filesystem::mount("../assets/sandbox", "/");
storage::filesystem::mount("../../sandbox"sv, "/"sv);
storage::filesystem::mount("../../megarick"sv, "/"sv);
#else
storage::filesystem::mount("bundle.7z"sv, "/"sv);
Expand Down

0 comments on commit 70f297c

Please sign in to comment.