Skip to content

Commit

Permalink
Merge pull request #29 from slo248/feat/improve-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
roni2406 committed Jan 8, 2024
2 parents b6875f2 + 6b475fe commit 634ced7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 112 deletions.
46 changes: 9 additions & 37 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,61 +26,33 @@ jobs:
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install libfreetype-dev libx11-dev libxcursor-dev libxrandr-dev libudev-dev libgl1-mesa-dev libopenal-dev libflac-dev libvorbis-dev libvorbisenc2 libvorbisfile3 libogg-dev libpthread-stubs0-dev libxcb-image0-dev libjpeg-dev libudev-dev libx11-xcb-dev libxcb-randr0-dev libxcb1-dev libxcb1 libxcb-util0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xinerama0-dev libxcb-shm0-dev libxcb-xkb-dev libxcb-cursor-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-xrm-dev libxcb-glx0-dev libxcb-xinput-dev libxcb-xrm-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-randr0-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-xfixes0-dev libxcb-sync-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-randr0-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-xfixes0-dev libxcb-sync-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-randr0-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-xfixes0-dev libxcb-sync-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-randr0-dev
sudo apt-get install libfreetype6-dev libx11-dev libxcursor-dev libxrandr-dev libudev-dev libgl1-mesa-dev libflac-dev libogg-dev libvorbis-dev libvorbisenc2 libvorbisfile3 libopenal-dev libpthread-stubs0-dev
- name: Install SFML
- name: Build
run: |
git clone https://github.com/SFML/SFML.git
cd SFML
git checkout 2.6.x
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make
sudo make install
- name: Building with cmake
run: |
mkdir build
cd build
cmake ..
make
cmake --build . --config Release
Windows-Build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Installing dependencies
- name: Build
run: |
choco install mingw
git clone https://github.com/SFML/SFML.git
cd SFML
git checkout 2.6.x
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G"MinGW Makefiles" ..
cmake --build . --config Release
cmake --install . --config Release
cd ../..
- name: Building
run: |
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G"MinGW Makefiles" ..
cmake ..
cmake --build . --config Release
MacOS-Build:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Installing dependencies
run: |
brew install sfml
- name: Building
- name: Build
run: |
mkdir build
cd build
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
mkdir build && cd build
cmake ..
cmake --build . --config Release
33 changes: 18 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,33 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${AllOutDir})
file(COPY ${CMAKE_SOURCE_DIR}/asset DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
file(COPY ${CMAKE_SOURCE_DIR}/data DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

# Add source files
file(GLOB_RECURSE SOURCES "src/*.cpp")

# Find SFML, if not found, download it
find_package(SFML 2.5 COMPONENTS graphics window system audio network REQUIRED)
find_package(SFML 2.6 COMPONENTS graphics window system audio)

if(NOT SFML_FOUND)
message(STATUS "SFML not found. Downloading from the internet...")
include(FetchContent)

FetchContent_Declare(
SFML
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG 2.5.1
GIT_TAG 2.6.1
)
FetchContent_MakeAvailable(SFML)

FetchContent_GetProperties(SFML)

if(NOT SFML_POPULATED)
FetchContent_Populate(SFML)
add_subdirectory(${sfml_SOURCE_DIR} ${sfml_BINARY_DIR})
endif()

set(SFML_INCLUDE_DIR ${sfml_SOURCE_DIR}/include)
endif()

# Add source files
file(GLOB_RECURSE SOURCES "src/*.cpp")
set(SFML_LIBRARIES sfml-graphics sfml-window sfml-system sfml-audio)

# Add executable
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE
sfml-graphics
sfml-window
sfml-system
sfml-audio
sfml-network
)
target_include_directories(${PROJECT_NAME} PRIVATE ${SFML_INCLUDE_DIR} include)
target_link_libraries(${PROJECT_NAME} ${SFML_LIBRARIES})
target_include_directories(${PROJECT_NAME} PUBLIC include ${SFML_INCLUDE_DIR})
69 changes: 9 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,82 +14,31 @@ Video demo: [Youtube](https://youtu.be/MwSDSFgAg_0)

| **Operating System** | **Compiler** |
|:--------------------:|:-----------------:|
| Linux (Ubuntu) | GNU 11.4.0 |
| Windows | Clang 16.0.6 |
| MacOS | AppleClang 14.0.0 |
| Linux (Ubuntu) | GNU 11.4 |
| Windows | MSVC 19.37 |
| MacOS | AppleClang 14.0 |

- CMake: v3.10
- SFML: [v2.6.1](https://github.com/SFML/SFML/releases/tag/2.6.1)

## III. How to run?

The executable file is located at `CS202-Crossy-Road/bin/<your operating system name>/CrossyRoad`.

### a. Linux (Ubuntu)

1. Install SFML (you would not have to do this if your machine already had SFML)
- Step 1: Install dependencies (**Linux users only**)
```console
sudo apt-get update
sudo apt-get install libfreetype-dev libx11-dev libxcursor-dev libxrandr-dev libudev-dev libgl1-mesa-dev libopenal-dev libflac-dev libvorbis-dev libvorbisenc2 libvorbisfile3 libogg-dev libpthread-stubs0-dev libxcb-image0-dev libjpeg-dev libudev-dev libx11-xcb-dev libxcb-randr0-dev libxcb1-dev libxcb1 libxcb-util0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xinerama0-dev libxcb-shm0-dev libxcb-xkb-dev libxcb-cursor-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-xrm-dev libxcb-glx0-dev libxcb-xinput-dev libxcb-xrm-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-randr0-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-xfixes0-dev libxcb-sync-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-randr0-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-xfixes0-dev libxcb-sync-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-randr0-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-xfixes0-dev libxcb-sync-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-randr0-dev
git clone https://github.com/SFML/SFML.git
cd SFML
git checkout 2.6.x
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make
sudo make install
sudo apt-get install libfreetype6-dev libx11-dev libxcursor-dev libxrandr-dev libudev-dev libgl1-mesa-dev libflac-dev libogg-dev libvorbis-dev libvorbisenc2 libvorbisfile3 libopenal-dev libpthread-stubs0-dev
```

2. Build code
- Step 2: Build
```console
git clone https://github.com/slo248/CS202-Crossy-Road.git
git clone git@github.com:slo248/CS202-Crossy-Road.git
cd CS202-Crossy-Road
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON ..
cmake --build . --config Release
```

### b. Windows

1. Install SFML
```console
choco install mingw
git clone https://github.com/SFML/SFML.git
cd SFML
git checkout 2.6.x
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G"MinGW Makefiles" ..
cmake ..
cmake --build . --config Release
cmake --install . --config Release
```

2. Build code
```console
git clone https://github.com/slo248/CS202-Crossy-Road.git
cd CS202-Crossy-Road
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G"MinGW Makefiles" ..
cmake --build . --config Release
```

### c. MacOS

1. Install SFML
```console
brew install sfml
```

2. Build code
```console
git clone https://github.com/slo248/CS202-Crossy-Road.git
cd CS202-Crossy-Road
mkdir build
cd build
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
cmake --build . --config Release
```
The executable file is located at `CS202-Crossy-Road/bin/<your operating system name>/CrossyRoad`.

## IV. Find a bug?

Expand Down

0 comments on commit 634ced7

Please sign in to comment.