Skip to content

Commit

Permalink
Finish v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hsandt committed Jul 9, 2020
2 parents c100177 + 3d1300f commit 07c30f8
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 53 deletions.
56 changes: 36 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ addons:
packages: &linux_packages
libxrandr-dev
libudev-dev
libgl-dev
libgl1-mesa-dev
libflac-dev
libogg-dev
libvorbis-dev
Expand All @@ -31,40 +31,44 @@ addons:

jobs:
include:
# For OSX, use 10.15.4 with Xcode 11.6 to have clang++-11 and premake5 for correct architecture
- os: osx
# For OSX, use 10.15.4 with Xcode 11.6 to have clang++-10 and premake5 for correct architecture
osx_image: xcode11.6
env: COMPILER=clang++ # osx simply names "clang" the latest clang installed with Xcode toolchain
env:
- COMPILER=clang++ # osx simply names "clang++" the latest clang installed with Xcode toolchain
- PREMAKE_GENERATOR=gmake
compiler: clang++
- os: osx
osx_image: xcode11.6
env:
- COMPILER=clang++
- PREMAKE_GENERATOR=xcode4
compiler: clang++
- os: linux
env: COMPILER=g++-10
env:
- COMPILER=g++-10
- PREMAKE_GENERATOR=gmake
addons:
apt:
packages:
- *linux_packages
- g++-10
- lcov
sources:
- ubuntu-toolchain-r-test
- os: linux
env: COMPILER=clang++-10
# On Linux we stick to 10 which is LLVM's latest stable
env:
- COMPILER=clang++-10
- PREMAKE_GENERATOR=gmake
addons:
apt:
packages:
- *linux_packages
- clang-10
- lcov
sources:
- llvm-toolchain-bionic-10
compiler: clang++

before_install:
# install lcov for OSX
- |
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
brew install lcov
fi
install:
# Set the ${CXX} variable properly (don't do it in env, it is too early and would be overriden
# by travis compiler settings just afterward)
Expand All @@ -80,6 +84,7 @@ install:
# Download premake binary for current platform if not already done via cache (also check version just in case)
- |
if [[ ! -d "premake-${PREMAKE_VERSION}" || ! -x "premake-${PREMAKE_VERSION}/premake5" || "$(premake5 --version)" != *"${PREMAKE_VERSION}" ]]; then
rm -rf "premake-${PREMAKE_VERSION}"
mkdir -p "premake-${PREMAKE_VERSION}"
pushd "premake-${PREMAKE_VERSION}"
Expand All @@ -89,7 +94,6 @@ install:
PREMAKE_BINARY_OS_NAME="linux"
fi
wget "https://github.com/premake/premake-core/releases/download/v${PREMAKE_VERSION}/premake-${PREMAKE_VERSION}-${PREMAKE_BINARY_OS_NAME}.tar.gz"
rm -rf "premake-${PREMAKE_VERSION}"
tar -xvzf "premake-${PREMAKE_VERSION}-${PREMAKE_BINARY_OS_NAME}.tar.gz"
popd
Expand Down Expand Up @@ -130,13 +134,25 @@ before_script:
# Build dependencies
- engine/third-party/build_sfml.py
# Premake
- premake5 gmake
- premake5 "${PREMAKE_GENERATOR}"

script:
# Make (build dir must have been created by premake5)
- pushd build
# Manual debug to understand how each platform generates Makefile for premake
- echo "build/Game.make content:"
- cat build/Game.make
- config=release make -j${JOBS}
- |
if [[ "${PREMAKE_GENERATOR}" == "gmake"* ]]; then
config=release make -j${JOBS}
elif [[ "${PREMAKE_GENERATOR}" == "xcode"* ]]; then
xcodebuild -project Game.xcodeproj -target Game -configuration Release
fi
- popd

deploy:
- provider: releases
api_key:
secure: IhrVPJTMBqjDyaM2384WfLGlctyQKPWPLABaVWtLef9hEsGr2U1zSzvdTpChFfgFT8Rc6BZSyFeQTVUoNGMAx3Sb3ei44VBL7b3L4xPuRglnjesmgd0CwMmQjYYLn1eL8D599cxkobhkwMxgl4ynDXS/1e07g0HwDdw5e/MVguotnLvsu0PXmHJEJ6Vt7lgkCQb4qK207D2RDfxWHZYry9uLsC+RWG3c0rrEF+oYnUfrb7248OPGzOBQCzZtNcOzxP2YWw+Em2/cn2HbOjiYClM7gjZnVgisE+x4Xel7OPNKur2LtYEuoEMrvGd7r3m4xMmiNLWOb3XWzAQncqUiK1nLBoAdA9MQm7lIS8I+mpV0i9wvsWLmFM98gAKjY/bv5tcpjPC4iRlbWZCMm50+Oxpg4Jwkw60Te0teG2tSCdWEbqVYku6PIv699f6EfpADA4vyteC832sIirIJ/Q+XawnSJpHII/OcGgOzPujk/IzGLk8IZyM3z6ZVaXB0NSmdYKP7AdylsS3GKxIFCL+hf9hRQniXDgmZyf2ehGt1kdLuWayPjkmaWpu5rnen1JJARLAx8n2ozhMHQt32SrPOpDBxX4z05g1UR/rgbtN9ij65puHOcwXO0mOLwRlC5mb+/1PBYKfcC+9O2Gw6IrMlx4wbwah3cEBHVs7Vp3f8mVQ=
# both Linux and OSX generate a 'Game' executable, as we didn't set Xcode to produce an .app
file: build/bin/Release/Game
skip_cleanup: 'true'
on:
tags: true
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "0.2.0",
"configurations": [
{
"name": "gdb - Build and debug active file",
"name": "gdb - Build and debug project",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/Debug/Game",
Expand All @@ -27,7 +27,7 @@
"ignoreFailures": true
}
],
"preLaunchTask": "make",
"preLaunchTask": "make (g++)",
"miDebuggerPath": "/usr/bin/gdb"
}
]
Expand Down
35 changes: 27 additions & 8 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"label": "build dependencies (g++)",
"type": "shell",
"command": "engine/third-party/build_sfml.py",
"command": "python3 engine/third-party/build_sfml.py",
"options": {
"env": {"CXX": "g++-10"}
},
Expand All @@ -16,17 +16,27 @@
{
"label": "build dependencies (clang++)",
"type": "shell",
"command": "engine/third-party/build_sfml.py",
"command": "python3 engine/third-party/build_sfml.py",
"options": {
"env": {"CXX": "clang++-10"}
"env": {"CXX": "clang++-10", "CC": "clang-10"}
},
"osx": {
"options": {
"env": {"CXX": "clang++", "CC": "clang"}
}
},
"windows": {
"options": {
"env": {"CXX": "clang++", "CC": "clang"}
}
},
"problemMatcher": [],
"group": "build"
},
{
"label": "clean dependencies",
"type": "shell",
"command": "engine/scripts/try_delete_dir.py engine/third-party/build",
"command": "python3 engine/scripts/try_delete_dir.py engine/third-party/build",
"problemMatcher": [
{
"pattern": [
Expand All @@ -44,7 +54,7 @@
{
"label": "clean engine",
"type": "shell",
"command": "engine/scripts/try_delete_dir.py engine/build",
"command": "python3 engine/scripts/try_delete_dir.py engine/build",
"problemMatcher": [
{
"pattern": [
Expand Down Expand Up @@ -87,7 +97,17 @@
"command": "make",
"options": {
"cwd": "build",
"env": {"CXX": "clang++-10"}
"env": {"CXX": "clang++-10", "CC": "clang-10"}
},
"osx": {
"options": {
"env": {"CXX": "clang++", "CC": "clang"}
}
},
"windows": {
"options": {
"env": {"CXX": "clang++", "CC": "clang"}
}
},
"problemMatcher": [],
"group": {
Expand All @@ -99,7 +119,7 @@
{
"label": "clean",
"type": "shell",
"command": "engine/scripts/try_delete_dir.py build",
"command": "python3 engine/scripts/try_delete_dir.py build",
"problemMatcher": [
{
"pattern": [
Expand All @@ -117,7 +137,6 @@
{
"label": "clean all",
"type": "shell",
"command": "./clean.py",
"problemMatcher": [],
"group": "build",
"dependsOn": ["clean", "clean engine", "clean dependencies"]
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<!-- ## [Unreleased] -->

## [0.0.1] - 2020-07-09
### Added
- Initial project structure with README, LICENSE, CHANGELOG
- Engine third-party SFML as submodule and build_sfml script
- Basic main.cpp to demonstrate SFML window working
- Scripts to build game and cleanup
- .vscode folder for tasks, launch, general and C++ settings
- YAML for Travis (working) and AppVeyor (experimental)

<!-- [Unreleased]: https://github.com/hsandt/cpp-platform-adventure/compare/v0.0.1...HEAD -->
[1.0.0]: https://github.com/olivierlacan/keep-a-changelog/releases/tag/v0.0.1
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,52 @@

A personal game dev project to train making a game in C++20 with low-level libraries, and gradually extracting components to make a more generic engine.

## Changelog

See [CHANGELOG.md].

## Supported platforms

Only Linux is currently supported.
Only Linux is currently supported. Build is tested on Ubuntu and Mint, and probably works with other Debian-based distributions.

However, premake will make it easier to support Windows and OSX in a later version.

## Required compiler toolchain

This project will use C++20 (in particular concepts), so to build it you will need either GCC 10 (`g++-10`), LLVM 10/11 (`clang++-10` or just `clang++` on OSX) or Visual Studio 2019 (16.3+) depending on your platform.

In addition, you need `premake` to build the game project itself, and `cmake` to build the SFML submodule.

Premake binaries are available on the [official download page](https://premake.github.io/download.html).

You can either install `cmake` via a package manager (including chocolatey and scoop for Windows) or from the [official download page](https://cmake.org/download/).

Currently, only the current configurations are tested in CI:

- Linux Ubuntu with `g++-10`
- Linux Ubuntu with `clang++-10`
- OSX with `clang++` 11 (not passing yet)

You are free to install the toolchains as you wish as long as they are accessible in the `PATH`. Below I give a few instructions for supported platforms.

### Linux Ubuntu with g++-10

```shell
$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt install g++-10
```

### Linux Ubuntu with latest stable LLVM (currently 10)

Follow the instructions on https://apt.llvm.org/.

There is an install script for Debian and Ubuntu, and instructions to install the packages for Debian-based distributions.

### OSX with latest LLVM (currently 11)

On OSX, I recommend to install the latest Xcode (currently 11) and the lastest clang (currently 11) will be provided.

## Dependencies

### Linux
Expand All @@ -28,4 +68,13 @@ To build SFML, you need the libraries mentioned in https://www.sfml-dev.org/tuto
| openal | libopenal-dev |
| pthread | libc6-dev |

Note: `libc6-dev` is part of build-essential
Notes:

- for virtual package `libgl-dev`, install `libgl1-mesa-dev`
- `libc6-dev` is part of `build-essential`

Here is a one-liner you can use for a quick setup:

```shell
$ sudo apt install build-essential libx11-dev libxrandr-dev libudev-dev libgl1-mesa-dev libflac-dev libogg-dev libvorbis-dev libvorbisenc2 libvorbisfile3 libopenal-dev
```
25 changes: 14 additions & 11 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,33 @@ install:
# Dependencies required by the CI are installed in ${clone_folder}/deps/
- set DEPS_DIR="%clone_folder%\deps"
- if not exist "%DEPS_DIR%" mkdir "%DEPS_DIR%"
- pushd "%DEPS_DIR%"
# verify that batch vars are accessible from PS too
- ps: echo "${env:DEPS_DIR}"
- ps: pushd "${env:DEPS_DIR}"

# Download premake binary for current platform if not already done via cache (also check version just in case)
# We simplified checks compared to .travis.yml to make it easier to write in batch
# but eventually we can re-add them in PowerShell which is much more powerful
- |
if not exist "premake-%PREMAKE_VERSION%" mkdir "premake-%PREMAKE_VERSION%"
pushd "premake-%PREMAKE_VERSION%"
- if not exist "premake-%PREMAKE_VERSION%" mkdir "premake-%PREMAKE_VERSION%"
- ps: pushd "premake-${env:PREMAKE_VERSION}"

set PREMAKE_BINARY_OS_NAME="windows"
curl "https://github.com/premake/premake-core/releases/download/v%PREMAKE_VERSION%/premake-%PREMAKE_VERSION%-%PREMAKE_BINARY_OS_NAME%.zip"
rmdir /s /q -rf "premake-%PREMAKE_VERSION%"
tar -xvf "premake-%PREMAKE_VERSION%-%PREMAKE_BINARY_OS_NAME%.zip"
# https://superuser.com/questions/362152/native-alternative-to-wget-in-windows-powershell
# make sure to expand the archive in current directory, not a subdirectory
- ps: Invoke-WebRequest "https://github.com/premake/premake-core/releases/download/v${env:PREMAKE_VERSION}/premake-${env:PREMAKE_VERSION}-windows.zip" -OutFile "premake-${env:PREMAKE_VERSION}-windows.zip"
- ps: Expand-Archive "premake-${env:PREMAKE_VERSION}-windows.zip" -DestinationPath .

- ps: popd

popd
# No canonical path on AppVeyor Windows to copy premake to,
# so add premake location to PATH
- set PATH="premake-%PREMAKE_VERSION%;%PATH%"
- set PATH="${env:clone_folder}\premake-%PREMAKE_VERSION%;%PATH%"
- echo %PATH%

before_build:
# Build dependencies
- engine\third-party\build_sfml.py
# Premake
- premake5 gmake
- premake5.exe gmake

build_script:
# Make (build dir must have been created by premake5)
Expand Down
11 changes: 9 additions & 2 deletions engine/third-party/build_sfml.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
from pathlib import Path
from subprocess import run, CalledProcessError

import multiprocessing

# Version check
if sys.version_info.minor < 6:
Expand Down Expand Up @@ -36,6 +36,7 @@ def build_sfml(sfml_path: Path, sfml_build_path: Path, sfml_install_path: Path):
# - no OpenGL ES (default)
# - use deps in SFML/extlibs to reduce dependency on system libs (default) (for Windows and OSX)
options = [
"-G", "Unix Makefiles",
"-DBUILD_SHARED_LIBS=FALSE",
"-DSFML_BUILD_NETWORK=FALSE",
f"-DCMAKE_INSTALL_PREFIX={sfml_install_path}",
Expand All @@ -49,8 +50,14 @@ def build_sfml(sfml_path: Path, sfml_build_path: Path, sfml_install_path: Path):
logging.error(f"cmake command failed")
sys.exit(e.returncode)

cpu_count = 1
try:
cpu_count = multiprocessing.cpu_count()
except NotImplementedError as e:
logging.error(f"multiprocessing.cpu_count() not implemented, defaulting to -j1")

try:
run(["make"], cwd=sfml_build_path, check=True)
run(["make", f"-j{cpu_count}"], cwd=sfml_build_path, check=True)
except CalledProcessError as e:
logging.error(f"make command failed")
sys.exit(e.returncode)
Expand Down
Loading

0 comments on commit 07c30f8

Please sign in to comment.