Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true

- name: Install Libraries
run: |
sudo apt update
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-gfx-dev

- name: Run CMake
run: cmake -G "Unix Makefiles" .
run: cmake -G "Unix Makefiles" . -DCMAKE_BUILD_TYPE=Release

- name: Make
run: make -j4
8 changes: 6 additions & 2 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true

- uses: seanmiddleditch/gha-setup-ninja@master

- name: Install Libraries
run: |
brew install sdl2 sdl2_image sdl2_gfx sdl2_ttf sdl2_mixer

- name: Run CMake
run: cmake -G "Unix Makefiles" .
run: cmake -G "Unix Makefiles" . -DCMAKE_BUILD_TYPE=Release

- name: Make
run: |
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/build-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true

- uses: seanmiddleditch/gha-setup-ninja@master

- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v7
uses: mymindstorm/setup-emsdk@v11
with:
actions-cache-folder: "emsdk-cache"

- name: Run CMake
run: emcmake cmake -G "Unix Makefiles" .
run: emcmake cmake -G "Unix Makefiles" . -DCMAKE_BUILD_TYPE=Release

- name: Make
run: emmake make -j4
run: make -j4
37 changes: 25 additions & 12 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,35 @@ jobs:
build:
name: Build Windows
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}

steps:
- name: Checkout
uses: actions/checkout@v2
- uses: msys2/setup-msys2@v2
with:
update: true
install: >-
make
git
mingw-w64-x86_64-gcc-libs
mingw-w64-x86_64-SDL2
mingw-w64-x86_64-SDL2_mixer
mingw-w64-x86_64-SDL2_image
mingw-w64-x86_64-SDL2_ttf
mingw-w64-x86_64-SDL2_gfx
pacboy: >-
toolchain:p
cmake:p
ninja:p

- name: Install Libraries
run: |
Set-Item -Path Env:Path -Value ("C:/msys64/usr/bin;" + $Env:Path)
pacman --noconfirm -S mingw-w64-i686-gcc-libs mingw-w64-i686-SDL2 mingw-w64-i686-SDL2_mixer mingw-w64-i686-SDL2_image mingw-w64-i686-SDL2_ttf mingw-w64-i686-SDL2_gfx
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Run CMake
run: |
Set-Item -Path Env:Path -Value ("C:/msys64/mingw32/bin;" + $Env:Path)
cmake -G "MSYS Makefiles" .
run: cmake -G Ninja . -DCMAKE_BUILD_TYPE=Release

- name: Make
run: |
Set-Item -Path Env:Path -Value ("C:/msys64/mingw32/bin;" + $Env:Path)
make -j4
run: ninja
14 changes: 9 additions & 5 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true

- uses: seanmiddleditch/gha-setup-ninja@master

- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v7
uses: mymindstorm/setup-emsdk@v11
with:
actions-cache-folder: "emsdk-cache"

- name: Run CMake
run: emcmake cmake -G "Unix Makefiles" .
run: emcmake cmake -G "Unix Makefiles" . -DCMAKE_BUILD_TYPE=Release

- name: Make
run: emmake make -j4
run: ninja

- name: Install graphviz
run: sudo apt install graphviz
Expand All @@ -33,7 +37,7 @@ jobs:
doxyfile-path: "./Doxyfile"

- name: Copy Bin to Docs
run: sudo cp -r ./bin ./docs/examples
run: sudo cp -r ./build/examples ./docs/examples

- name: Deploy docs
uses: peaceiris/actions-gh-pages@v3
Expand Down
12 changes: 4 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ Icon
.Trashes

CppCheckResults.xml
CMakeFiles
CMakeCache.txt
Makefile
*.cmake
install_manifest.txt
bin
docs
lib
docs/
.idea/
build/
Testing/
3 changes: 2 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"intelliSenseMode": "gcc-x86",
"cStandard": "c11",
"cppStandard": "c++17",
"includePath": ["include"]
"includePath": ["afk/include"],
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
Expand Down
11 changes: 8 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@
"filesystem": "cpp",
"unordered_set": "cpp",
"*.inc": "cpp",
"*.def": "cpp"
"*.def": "cpp",
"numbers": "cpp",
"semaphore": "cpp",
"any": "cpp",
"codecvt": "cpp"
},
"cmake.configureOnOpen": true
}
"cmake.configureOnOpen": true,
"sonarlint.pathToCompileCommands": "c:\\Users\\alege\\Documents\\GitHub\\AfkLib\\build\\compile_commands.json"
}
19 changes: 15 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "make -j24",
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
}
},
"detail": "Task generated by Debugger."
}
]
}
112 changes: 8 additions & 104 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,109 +1,13 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.16)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
project (root)

project (afk VERSION 1.0.0 LANGUAGES CXX)
# Config
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
set(EXTERNAL_DIR ${PROJECT_SOURCE_DIR}/lib)

# Add sources
file(GLOB_RECURSE SOURCES ${CMAKE_BINARY_DIR}/src/*.cpp)
file(GLOB_RECURSE HEADERS ${CMAKE_BINARY_DIR}/include/*.h)

# Create lib
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})

# Add compile options
target_compile_options(${PROJECT_NAME} PRIVATE -O2 -Wall -Wextra -pedantic)

# Add include
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE src)

# Versioning
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 1)

if(EMSCRIPTEN)
target_compile_options(
${PROJECT_NAME}
PRIVATE
-sUSE_SDL=2
-sUSE_SDL_IMAGE=2
-sUSE_SDL_TTF=2
-sUSE_SDL_MIXER=2
-sUSE_SDL_GFX=2
-sSDL2_IMAGE_FORMATS=["png"]
)
target_link_libraries(
${PROJECT_NAME}
-sWASM=1
-sUSE_SDL=2
-sUSE_SDL_IMAGE=2
-sUSE_SDL_TTF=2
-sUSE_SDL_MIXER=2
-sUSE_SDL_GFX=2
-sSDL2_IMAGE_FORMATS=["png"]
-sDEMANGLE_SUPPORT=1
)
target_link_libraries(${PROJECT_NAME} -sUSE_SDL=2 -fsanitize=address)
else(EMSCRIPTEN)
# Find libs
find_library(SDL_LIBRARY NAMES SDL2 REQUIRED)
find_library(SDL_MIXER_LIBRARY NAMES SDL2_mixer REQUIRED)
find_library(SDL_IMAGE_LIBRARY NAMES SDL2_image REQUIRED)
find_library(SDL_TTF_LIBRARY NAMES SDL2_ttf REQUIRED)
find_library(SDL_GFX_LIBRARY NAMES SDL2_gfx REQUIRED)
find_library(SDL_MAIN_LIBRARY NAMES SDL2main REQUIRED)

# Link Libs
target_link_libraries(${PROJECT_NAME} ${SDL_LIBRARY} ${SDL_MIXER_LIBRARY} ${SDL_IMAGE_LIBRARY} ${SDL_TTF_LIBRARY} ${SDL_GFX_LIBRARY} ${SDL_MAIN_LIBRARY})
endif(EMSCRIPTEN)

# Install info
if (EMSCRIPTEN)
if (NOT CMAKE_TOOLCHAIN_FILE)
message("CMAKE_TOOLCHAIN_FILE not provided, can not automatically install")
else()
get_filename_component(EMSDK_DIR ${CMAKE_TOOLCHAIN_FILE} DIRECTORY)
set(EMSDK_DIR ${EMSDK_DIR}/../../../system)
message("Lib install directory set to ${EMSDK_DIR}")

install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION ${EMSDK_DIR}/lib
LIBRARY DESTINATION ${EMSDK_DIR}/lib
RUNTIME DESTINATION ${EMSDK_DIR}/bin)

install(DIRECTORY include/ DESTINATION ${EMSDK_DIR}/include/${PROJECT_NAME})
endif()
elseif (WIN32)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION C:/msys64/mingw32/lib
LIBRARY DESTINATION C:/msys64/mingw32/lib
RUNTIME DESTINATION C:/msys64/mingw32/bin)

install(DIRECTORY include/ DESTINATION C:/msys64/mingw32/include/${PROJECT_NAME})

install(EXPORT ${PROJECT_NAME} DESTINATION C:/msys64/mingw32/share/${PROJECT_NAME}/cmake)
export(TARGETS ${PROJECT_NAME} FILE ${PROJECT_NAME}.cmake)
else()
include(GNUInstallDirs)

install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})

install(EXPORT ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
export(TARGETS ${PROJECT_NAME} FILE ${PROJECT_NAME}.cmake)
endif()
# Core lib
add_subdirectory(${PROJECT_SOURCE_DIR}/afk)

# Examples
include(${CMAKE_BINARY_DIR}/examples/CMakeLists.txt)
add_subdirectory(${PROJECT_SOURCE_DIR}/examples)
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Allans FrameworK
# Allan's FrameworK

![Build Windows](https://github.com/AdsGames/AfkLib/workflows/Build%20Windows/badge.svg)
![Build Linux](https://github.com/AdsGames/AfkLib/workflows/Build%20Linux/badge.svg)
Expand Down Expand Up @@ -30,7 +30,7 @@ Game framework
### Windows (MSYS2)

```bash
pacman -S mingw-w64-i686-gcc-libs mingw-w64-i686-SDL2 mingw-w64-i686-SDL2_mixer mingw-w64-i686-SDL2_image mingw-w64-i686-SDL2_ttf mingw-w64-i686-SDL2_gfx
pacman -S mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_ttf mingw-w64-x86_64-SDL2_gfx
```

### Mac OS
Expand All @@ -48,7 +48,9 @@ sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev
### Build

```bash
cmake .
mkdir build
cd build
cmake ../
```

```bash
Expand All @@ -58,7 +60,9 @@ make
### Build Emscripten

```bash
emcmake cmake .
mkdir build
cd build
emcmake cmake ../
```

```bash
Expand All @@ -68,5 +72,6 @@ make
### Install Library (works for emscripten)

```bash
cd build
make install
```
Loading