Skip to content
Merged
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
25 changes: 25 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Checks: |
bugprone-*
clang-analyzer-*
cppcoreguidelines-*
misc-*
modernize-*
performance-*
readability-*
portability-*
-cppcoreguidelines-avoid-magic-numbers
-readability-magic-numbers
-readability-identifier-length
-modernize-use-nodiscard
-cppcoreguidelines-init-variables
-bugprone-easily-swappable-parameters
-cppcoreguidelines-avoid-non-const-global-variables
-modernize-use-trailing-return-type
-performance-enum-size
-cppcoreguidelines-pro-bounds-constant-array-index
-cppcoreguidelines-non-private-member-variables-in-classes
-cppcoreguidelines-avoid-const-or-ref-data-members
-misc-include-cleaner
-misc-non-private-member-variables-in-classes
WarningsAsErrors: true
HeaderFilterRegex: ".*"
37 changes: 21 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ on:
- main
tags:
- v*

env:
EM_VERSION: "latest"
EM_CACHE_FOLDER: "emsdk-cache"
pull_request:
branches:
- main

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
deploy:
name: Deploy
Expand All @@ -25,36 +28,38 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
uses: actions/checkout@v4

- name: Setup cache
id: cache-system-libraries
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EM_VERSION}}-${{ runner.os }}
path: "_deps"
key: deps-${{ runner.os }}

- uses: mymindstorm/setup-emsdk@v11
- uses: mymindstorm/setup-emsdk@v14
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
version: 4.0.6
actions-cache-folder: "emsdk-cache"

- name: Download ports
run: |
embuilder build harfbuzz

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

- name: Make
run: emmake make -j4

- uses: actions/upload-pages-artifact@v1
- uses: actions/upload-pages-artifact@v3
if: github.ref == 'refs/heads/main'
with:
path: ./build

- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4

- name: Deploy to A.D.S. Games
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
62 changes: 0 additions & 62 deletions .github/workflows/sonar.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ $RECYCLE.BIN/
# Icon must ends with two \r.
Icon


# Thumbnails
._*

Expand All @@ -55,4 +54,5 @@ build.ninja
/build
.idea
Testing/
compile_commands.json
compile_commands.json
_deps/
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

12 changes: 0 additions & 12 deletions .vscode/c_cpp_properties.json

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"label": "Build",
"type": "shell",
"detail": "Run and build jim farm",
"detail": "Run and build memory",
"command": "cmake --build . && cd build && ./Memory",
"windows": {
"command": "cmake --build . && cd build && Memory.exe"
Expand Down
75 changes: 25 additions & 50 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,80 +5,55 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(FetchContent)

project (Memory)

# Source code
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/lib/*.cpp)
file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h ${CMAKE_CURRENT_SOURCE_DIR}/lib/*.h)
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h)

add_executable (${PROJECT_NAME} ${SOURCES} ${HEADERS})

target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -pedantic)

add_subdirectory(lib/asw)
FetchContent_Declare(
asw
GIT_REPOSITORY https://github.com/adsgames/asw.git
GIT_TAG v0.5.4
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(asw)

# Find libs
if(NOT EMSCRIPTEN)
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)
endif(NOT EMSCRIPTEN)
# Link Libs
if(MINGW)
target_link_libraries(${PROJECT_NAME} -lmingw32)
endif(MINGW)

target_link_libraries(
${PROJECT_NAME}
asw
)

# Link Libs
# Emscripten support
if(EMSCRIPTEN)
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "index")
set(CMAKE_EXECUTABLE_SUFFIX ".html")
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
-sTOTAL_MEMORY=512MB
asw
-sALLOW_MEMORY_GROWTH=1
-sMAXIMUM_MEMORY=1gb
)

set_target_properties(
${PROJECT_NAME}
PROPERTIES
LINK_FLAGS
"--preload-file ${CMAKE_CURRENT_LIST_DIR}/assets@/assets --use-preload-plugins --shell-file ${CMAKE_CURRENT_LIST_DIR}/index.html"
)

# Run of the mill executable
else(EMSCRIPTEN)
if(MINGW)
target_link_libraries(${PROJECT_NAME} -lmingw32)
endif(MINGW)
target_link_libraries(
${PROJECT_NAME}
-lm
${SDL_MAIN_LIBRARY}
${SDL_LIBRARY}
${SDL_MIXER_LIBRARY}
${SDL_IMAGE_LIBRARY}
${SDL_TTF_LIBRARY}
${SDL_GFX_LIBRARY}
asw
)
endif(EMSCRIPTEN)

file(COPY ${CMAKE_CURRENT_LIST_DIR}/assets/ DESTINATION ${CMAKE_BINARY_DIR}/build/assets/)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/assets/ DESTINATION ${CMAKE_BINARY_DIR}/build/assets/)

31 changes: 3 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,16 @@

Match all the cards on the table in four different difficulties. Compete against yourself and others with the high-score tables.

[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=AdsGames_Memory&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=AdsGames_Memory)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=AdsGames_Memory&metric=bugs)](https://sonarcloud.io/summary/new_code?id=AdsGames_Memory)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=AdsGames_memory&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=AdsGames_memory)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=AdsGames_memory&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=AdsGames_memory)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=AdsGames_memory&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=AdsGames_memory)

## Demo

[Web Demo](https://adsgames.github.io/memory/)

## Setup

### Dependencies

To pull the submodules, run the following command:

```bash
git submodule update --init --recursive
```

### 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
```

### Mac OS

```bash
brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer
```

### Linux

```bash
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev
```

### Build

```bash
Expand Down
Loading
Loading