Initial commit
This commit is contained in:
13
.editorconfig
Normal file
13
.editorconfig
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.{ts,js,tsx,jsx,lua,html,yml,json}]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.go]
|
||||||
|
indent_style = tab
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
||||||
45
.gitignore
vendored
Normal file
45
.gitignore
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# Production
|
||||||
|
dist
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
build*
|
||||||
|
cmake-build-*
|
||||||
|
!build*.sh
|
||||||
|
|
||||||
|
# Xcode
|
||||||
|
*.xcworkspace
|
||||||
|
*.xcodeproj
|
||||||
|
|
||||||
|
# Visual Studio
|
||||||
|
*.sln
|
||||||
|
*.vcxproj
|
||||||
|
*.vcxproj.filters
|
||||||
|
*.vcxproj.user
|
||||||
|
.vs
|
||||||
|
|
||||||
|
# Makefile
|
||||||
|
Makefile
|
||||||
|
*.make
|
||||||
|
|
||||||
|
# nvim
|
||||||
|
.ccls
|
||||||
|
.ccls-cache
|
||||||
|
compile_commands.json
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# JetBrains Fleet
|
||||||
|
.fleet
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# MIDI Files
|
||||||
|
*.mid
|
||||||
128
CMakeLists.txt
Normal file
128
CMakeLists.txt
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.21)
|
||||||
|
project(aoc VERSION 0.0.0)
|
||||||
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Group CMake targets inside a folder
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Generate compile_commands.json for language servers
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(
|
||||||
|
fmt
|
||||||
|
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
|
||||||
|
GIT_TAG 10.1.0
|
||||||
|
)
|
||||||
|
list(APPEND FETCH_CONTENTS fmt)
|
||||||
|
FetchContent_Declare(
|
||||||
|
utf8cpp
|
||||||
|
GIT_REPOSITORY https://github.com/nemtrif/utfcpp.git
|
||||||
|
GIT_TAG v4.0.5
|
||||||
|
)
|
||||||
|
list(APPEND FETCH_CONTENTS utf8cpp)
|
||||||
|
FetchContent_Declare(
|
||||||
|
stb
|
||||||
|
GIT_REPOSITORY https://github.com/mononerv/stb.git
|
||||||
|
GIT_TAG 698c6fb9889c71494b49c9187d249af5fc87b211
|
||||||
|
)
|
||||||
|
list(APPEND FETCH_CONTENTS stb)
|
||||||
|
# Turn off BUILD_TESTING globally to prevent CTest from being included in CTRE
|
||||||
|
set(BUILD_TESTING OFF CACHE BOOL "Disable testing globally" FORCE)
|
||||||
|
# Set the CTRE_BUILD_TESTS option before including the CTRE library
|
||||||
|
set(CTRE_BUILD_TESTS OFF CACHE BOOL "Build ctre Tests" FORCE)
|
||||||
|
FetchContent_Declare(
|
||||||
|
ctre
|
||||||
|
GIT_REPOSITORY https://github.com/hanickadot/compile-time-regular-expressions.git
|
||||||
|
GIT_TAG v3.9.0
|
||||||
|
)
|
||||||
|
list(APPEND FETCH_CONTENTS ctre)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(${FETCH_CONTENTS})
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
|
# Group dependencies in Visual Studio and Xcode
|
||||||
|
if (CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES "Xcode")
|
||||||
|
set_target_properties(fmt PROPERTIES FOLDER deps)
|
||||||
|
set_target_properties(stb PROPERTIES FOLDER deps)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(BASE_DEFINITIONS "ASIO_STANDALONE")
|
||||||
|
if (APPLE)
|
||||||
|
message("Platform Apple")
|
||||||
|
list(APPEND BASE_DEFINITIONS
|
||||||
|
"AOC_PLATFORM=Apple"
|
||||||
|
)
|
||||||
|
set(IS_UNIX true)
|
||||||
|
elseif (UNIX AND NOT APPLE AND NOT EMSCRIPTEN) # Linux, BSD, Solaris, Minix
|
||||||
|
message("Platform Unix")
|
||||||
|
list(APPEND BASE_DEFINITIONS
|
||||||
|
"AOC_PLATFORM=Linux"
|
||||||
|
)
|
||||||
|
set(IS_UNIX true)
|
||||||
|
elseif (WIN32)
|
||||||
|
message("Platform Windows")
|
||||||
|
list(APPEND BASE_DEFINITIONS
|
||||||
|
"AOC_PLATFORM=Windows"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Unkown platform!")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Compiler specific options
|
||||||
|
if (NOT MSVC)
|
||||||
|
set(BASE_OPTIONS
|
||||||
|
"-Wall"
|
||||||
|
"-Wextra"
|
||||||
|
"-Wconversion"
|
||||||
|
"-Wpedantic"
|
||||||
|
"-Wshadow"
|
||||||
|
"-Werror"
|
||||||
|
# fmt warnings
|
||||||
|
"-Wno-unknown-attributes"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
set(BASE_OPTIONS
|
||||||
|
"/W4"
|
||||||
|
"/WX"
|
||||||
|
"/utf-8"
|
||||||
|
"/Zc:__cplusplus"
|
||||||
|
#"/fsanitize=address" # Doesn't work without Visual Studio
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(HEADERS
|
||||||
|
aoc/aoc.hpp
|
||||||
|
)
|
||||||
|
set(SOURCES "")
|
||||||
|
add_library(aoclib OBJECT ${HEADERS} ${SOURCES})
|
||||||
|
target_include_directories(aoclib
|
||||||
|
PUBLIC
|
||||||
|
${PROJECT_SOURCE_DIR}
|
||||||
|
PRIVATE
|
||||||
|
${PROJECT_SOURCE_DIR}/aoc
|
||||||
|
)
|
||||||
|
target_compile_features(aoclib PRIVATE cxx_std_23)
|
||||||
|
target_compile_options(aoclib PRIVATE ${BASE_OPTIONS})
|
||||||
|
target_compile_definitions(aoclib
|
||||||
|
PRIVATE
|
||||||
|
${BASE_DEFINITIONS}
|
||||||
|
)
|
||||||
|
target_link_libraries(aoclib
|
||||||
|
PUBLIC
|
||||||
|
fmt
|
||||||
|
utf8cpp
|
||||||
|
ctre
|
||||||
|
stb::stb
|
||||||
|
Threads::Threads
|
||||||
|
)
|
||||||
|
source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" FILES ${HEADERS} ${SOURCES})
|
||||||
|
|
||||||
|
set(HEADERS "")
|
||||||
|
set(SOURCES aoc.cpp)
|
||||||
|
add_executable(aoc ${HEADERS} ${SOURCES})
|
||||||
|
target_include_directories(aoc PRIVATE ${PROJECT_SOURCE_DIR})
|
||||||
|
target_compile_features(aoc PRIVATE cxx_std_23)
|
||||||
|
target_compile_options(aoc PRIVATE ${BASE_OPTIONS})
|
||||||
|
target_compile_definitions(aoc PRIVATE ${BASE_DEFINITIONS})
|
||||||
|
target_link_libraries(aoc
|
||||||
|
PRIVATE
|
||||||
|
aoclib
|
||||||
|
)
|
||||||
|
source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" FILES ${HEADERS} ${SOURCES})
|
||||||
|
|
||||||
51
README.md
Normal file
51
README.md
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# ensam
|
||||||
|
|
||||||
|
`ensam` is a learning project on how to parse MIDI files and play them.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- [cmake](https://cmake.org/)
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
There are different ways to setup this project, using `ninja` or Visual Studio.
|
||||||
|
|
||||||
|
### Ninja
|
||||||
|
|
||||||
|
To use `miniaudio` to play audio on host machine use the flag `-DUSE_MINIAUDIO=ON`.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake -S . -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Debug
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `ninja` to build.
|
||||||
|
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ninja -C build
|
||||||
|
```
|
||||||
|
|
||||||
|
Symlink `compile_commands.json` to root directory for `ccls`/`clangd`.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ln -sfn ./build/compile_commands.json .
|
||||||
|
```
|
||||||
|
|
||||||
|
**Windows (requires admin)**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
New-Item -ItemType SymbolicLink -Path "compile_commands.json" -Target "./build/compile_commands.json"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Visual Studio
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake -S . -Bbuild
|
||||||
|
```
|
||||||
|
|
||||||
|
Open either the visual studio project in the build directory or use
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake --open build
|
||||||
|
```
|
||||||
|
|
||||||
6
aoc.cpp
Normal file
6
aoc.cpp
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
|
auto main([[maybe_unused]]int argc, [[maybe_unused]]char const* argv[]) -> int {
|
||||||
|
fmt::print("Hello, World!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
0
aoc/2024/day01.hpp
Normal file
0
aoc/2024/day01.hpp
Normal file
7
aoc/aoc.hpp
Normal file
7
aoc/aoc.hpp
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#ifndef AOC_AOC_HPP
|
||||||
|
#define AOC_AOC_HPP
|
||||||
|
|
||||||
|
namespace aoc {
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !AOC_AOC_HPP
|
||||||
1000
data/2024/day01/input.txt
Normal file
1000
data/2024/day01/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
6
data/2024/day01/sample.txt
Normal file
6
data/2024/day01/sample.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
3 4
|
||||||
|
4 3
|
||||||
|
2 5
|
||||||
|
1 3
|
||||||
|
3 9
|
||||||
|
3 3
|
||||||
Reference in New Issue
Block a user