Skip to content

Commit

Permalink
fix gcc build
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdcvlsc committed Oct 27, 2023
1 parent 9ab36da commit 1e4b6b9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
46 changes: 22 additions & 24 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- 'v*'

jobs:

build:
permissions: write-all

Expand All @@ -19,7 +20,8 @@ jobs:
platform:
- { name: Linux Clang, os: ubuntu-latest, font: ./build/calibril.ttf, bin: ./build/flappy_ffnn_ga, zip: ubuntu-executable.zip , zipper: zip, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
config:
- { name: Static, flags: -DBUILD_SHARED_LIBS=OFF }
- { name: static, flags: -DBUILD_SHARED_LIBS=FALSE -DCMAKE_BUILD_TYPE=Release }
- { name: shared, flags: -DBUILD_SHARED_LIBS=TRUE -DCMAKE_BUILD_TYPE=Release }

steps:
- name: Install Linux Dependencies
Expand All @@ -39,17 +41,13 @@ jobs:
run: cmake --build build --config Release

- name: Compress ${{matrix.platform.bin}} executable
run: ${{matrix.platform.zipper}} ${{matrix.platform.zip}} ${{matrix.platform.bin}} ${{matrix.platform.font}}
run: ${{matrix.platform.zipper}} ${{matrix.config.name}}-${{matrix.platform.zip}} ${{matrix.platform.bin}} ${{matrix.platform.font}}

- name: Create github release and upload ${{matrix.platform.zip}}
run: gh release create ${{github.ref_name}} ${{matrix.platform.zip}} --title "${{github.ref_name}}" --notes "Release notes for ${{github.ref_name}}" --draft=false --prerelease=false
- name: Create github release and upload ${{matrix.config.name}}-${{matrix.platform.zip}}
run: gh release create ${{github.ref_name}} ${{matrix.config.name}}-${{matrix.platform.zip}} --title "${{github.ref_name}}" --notes "Release notes for ${{github.ref_name}}" --draft=false --prerelease=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: Install
# shell: bash
# run: cmake --install build --config Release

build-others:
needs: build
permissions: write-all
Expand All @@ -61,35 +59,35 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: Windows VS2019, os: windows-2019, font: .\\build\\calibril.ttf, bin: .\\build\\Release\\flappy_ffnn_ga.exe, zip: windows-executable-VS19.zip, zipper: 7z a -tzip, flags: -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release }
- { name: Windows VS2022, os: windows-2022, font: .\\build\\calibril.ttf, bin: .\\build\\Release\\flappy_ffnn_ga.exe, zip: windows-executable-VS22.zip, zipper: 7z a -tzip, flags: -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release }
- { name: Windows Clang, os: windows-latest, font: .\\build\\calibril.ttf, bin: .\\build\\Release\\flappy_ffnn_ga.exe, zip: windows-executable-clang.zip, zipper: 7z a -tzip, flags: -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: Windows GCC, os: windows-latest, font: .\\build\\calibril.ttf, bin: .\\build\\Release\\flappy_ffnn_ga.exe, zip: windows-executable-gcc.zip, zipper: 7z a -tzip, flags: -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ }
- { name: MacOS XCode, os: macos-latest, font: ./build/calibril.ttf, bin: ./build/flappy_ffnn_ga, zip: mac-executable.zip, zipper: zip, flags: -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release }
- { name: Linux GCC, os: ubuntu-latest, font: ./build/calibril.ttf, bin: ./build/flappy_ffnn_ga, zip: mac-executable.zip, zipper: zip, flags: -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release }
- { name: Windows VS2019, os: windows-2019, font: .\\build\\calibril.ttf, bin: .\\build\\Release\\flappy_ffnn_ga.exe, zip: windows-executable-VS19.zip, zipper: 7z a -tzip, flags: -DBUILD_SHARED_LIBS=FALSE -DCMAKE_BUILD_TYPE=Release }
- { name: Windows VS2022, os: windows-2022, font: .\\build\\calibril.ttf, bin: .\\build\\Release\\flappy_ffnn_ga.exe, zip: windows-executable-VS22.zip, zipper: 7z a -tzip, flags: -DBUILD_SHARED_LIBS=FALSE -DCMAKE_BUILD_TYPE=Release }
- { name: Windows Clang, os: windows-latest, font: .\\build\\calibril.ttf, bin: .\\build\\Release\\flappy_ffnn_ga.exe, zip: windows-executable-clang.zip, zipper: 7z a -tzip, flags: -DBUILD_SHARED_LIBS=FALSE -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: Windows GCC, os: windows-latest, font: .\\build\\calibril.ttf, bin: .\\build\\Release\\flappy_ffnn_ga.exe, zip: windows-executable-gcc.zip, zipper: 7z a -tzip, flags: -DBUILD_SHARED_LIBS=FALSE -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ }
- { name: MacOS XCode, os: macos-latest, font: ./build/calibril.ttf, bin: ./build/flappy_ffnn_ga, zip: mac-executable.zip, zipper: zip, flags: -DBUILD_SHARED_LIBS=FALSE -DCMAKE_BUILD_TYPE=Release }
- { name: Linux GCC, os: ubuntu-latest, font: ./build/calibril.ttf, bin: ./build/flappy_ffnn_ga, zip: mac-executable.zip, zipper: zip, flags: -DBUILD_SHARED_LIBS=FALSE -DCMAKE_BUILD_TYPE=Release }
config:
- { name: Static, flags: -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release }
# - { name: Shared, flags: -DBUILD_SHARED_LIBS=TRUE -DCMAKE_BUILD_TYPE=Release }
- { name: static, flags: -DBUILD_SHARED_LIBS=FALSE -DCMAKE_BUILD_TYPE=Release }
- { name: shared, flags: -DBUILD_SHARED_LIBS=TRUE -DCMAKE_BUILD_TYPE=Release }

steps:

- name: Checkout Repository
uses: actions/checkout@v3

- name: Install Linux Dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev

- name: Configure project
run: cmake -S src -B build -DCMAKE_INSTALL_PREFIX=install ${{matrix.platform.flags}} ${{matrix.config.flags}}

- name: Build ${{matrix.platform.bin}} executable
run: cmake --build build --config Release

- name: Compress ${{matrix.platform.bin}} executable
run: ${{matrix.platform.zipper}} ${{matrix.platform.zip}} ${{matrix.platform.bin}} ${{matrix.platform.font}}
run: ${{matrix.platform.zipper}} ${{matrix.config.name}}-${{matrix.platform.zip}} ${{matrix.platform.bin}} ${{matrix.platform.font}}

- name: Upload ${{matrix.platform.zip}} to release
run: gh release upload ${{github.ref_name}} ${{matrix.platform.zip}}
- name: Upload ${{matrix.config.name}}-${{matrix.platform.zip}} to release
run: gh release upload ${{github.ref_name}} ${{matrix.config.name}}-${{matrix.platform.zip}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: Install
# shell: bash
# run: cmake --install build --config Release
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ option(BUILD_SHARED_LIBS "Build shared libraries" OFF)

include(FetchContent)

if (NOT WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -stdlib=libc++ -lc++abi")
endif()

set(FETCHCONTENT_QUIET off)

FetchContent_Declare(SFML
Expand Down
5 changes: 3 additions & 2 deletions src/makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# DEFAULT DEV MAKEFILE

LINKING:=
CC:=gcc
CXX:=g++
LIBS:=-lX11 -lXrandr -lXcursor -lsfml-graphics -lsfml-window -lsfml-system
CXX_STANDARD:=-std=c++20
CXX_STANDARD:=-std=c++17
WFLAGS:=-Wall -Wextra -Wpedantic
DFLAGS:=-g3 -fsanitize=address

Expand All @@ -16,7 +17,7 @@ run: $(BIN_OUT)
./$(BIN_OUT)

$(BIN_OUT): main.cc $(OBJ)
$(strip $(CXX) $(CXX_STANDARD) $(WFLAGS) main.cc $(OBJ) -o $(BIN_OUT) $(LIBS) $(DFLAGS))
$(strip $(CXX) $(CXX_STANDARD) $(WFLAGS) main.cc $(OBJ) -o $(BIN_OUT) $(LIBS) $(LINKING) $(DFLAGS))

######################## dependent targets ########################

Expand Down

0 comments on commit 1e4b6b9

Please sign in to comment.