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: ".*"
32 changes: 15 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ on:
tags:
- v*

env:
EM_VERSION: "latest"
EM_CACHE_FOLDER: "emsdk-cache"

permissions:
contents: read
pages: write
Expand All @@ -25,42 +21,44 @@ 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: "_deps"
key: deps-${{ runner.os }}

- uses: awalsh128/cache-apt-pkgs-action@latest
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EM_VERSION}}-${{ runner.os }}
packages: libharfbuzz-dev libfreetype-dev libasound2-dev
version: 1.0

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

- 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
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')
uses: adsgames/deploy-to-adsgames@v1.1.2
with:
project-id: breaker
project-id: minesweeper
build-dir: ./build/
platform: WEB
bucket-access-key: ${{ secrets.LINODE_BUCKET_ACCESS_KEY }}
Expand Down
51 changes: 19 additions & 32 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,35 @@ jobs:
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: "recursive"

- uses: awalsh128/cache-apt-pkgs-action@latest
- name: Setup cache
uses: actions/cache@v4
with:
packages: libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-gfx-dev
version: 1.0
path: "_deps"
key: deps-${{ runner.os }}

- name: Set up JDK 11
uses: actions/setup-java@v1
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
java-version: 11

- name: Download and set up sonar-scanner
env:
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
run: |
mkdir -p $HOME/.sonar
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH

- name: Download and set up build-wrapper
env:
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip
run: |
curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH
packages: libharfbuzz-dev libfreetype-dev libasound2-dev
version: 1.0

- name: Setup project
run: cmake .
run: cmake . -DSDL_UNIX_CONSOLE_BUILD=ON

- name: Run build-wrapper
- name: Install Build Wrapper
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5

- name: Run Build Wrapper
run: |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make -j4

- name: Run sonar-scanner
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
with:
args: >
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
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 @@ -50,4 +49,5 @@ bin
docs
build/
*.ninja*
compile_commands.json
compile_commands.json
_deps/
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

28 changes: 27 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,33 @@
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp"
"typeinfo": "cpp",
"__bit_reference": "cpp",
"__config": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__node_handle": "cpp",
"__split_buffer": "cpp",
"__threading_support": "cpp",
"__tree": "cpp",
"__verbose_abort": "cpp",
"bitset": "cpp",
"charconv": "cpp",
"complex": "cpp",
"execution": "cpp",
"ios": "cpp",
"locale": "cpp",
"optional": "cpp",
"queue": "cpp",
"set": "cpp",
"variant": "cpp",
"format": "cpp",
"list": "cpp",
"map": "cpp",
"span": "cpp",
"stack": "cpp",
"unordered_set": "cpp",
"forward_list": "cpp"
},
"sonarlint.pathToCompileCommands": "${workspaceFolder}\\compile_commands.json"
}
74 changes: 24 additions & 50 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,84 +1,58 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.24)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(FetchContent)

project (Breaker)

# 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 36fac408305d134f2def93580bbafc871c359536
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/)
35 changes: 5 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,26 @@

A simple clear the board style breaking game.

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

## Demo

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

## 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 mingw-w64-i686-SDL2_gfx
```

### Mac OS

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

### Linux

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

### Build

```bash
cmake .
make
make -j<threads>
```

### Build Emscripten

```bash
emcmake cmake .
make
make -j<threads>
```
1 change: 0 additions & 1 deletion lib/asw
Submodule asw deleted from d7adc6
4 changes: 2 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sonar.projectKey=AdsGames_Breaker
sonar.organization=adsgames
sonar.projectKey=AdsGames_breaker
sonar.organization=adsgames
Loading