From 804c3ba6e9e8f51f49df7cd85e547a8ff0c8bb5b Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 9 May 2020 14:56:39 +0100 Subject: [PATCH] Upgrade to C++17 [CI] (#4716) * Update CI * Reduce one build to minimum cmake version * Update compile instructions with new minimum versions * Update more guides * Run debug build with VS 2017 Co-authored-by: Peter Bell --- .travis.yml | 76 ++++++++++++++++++---------------------------- COMPILING.md | 17 ++++++++--- CONTRIBUTING.md | 2 +- GETTING-STARTED.md | 2 +- appveyor.yml | 20 +++++++++--- 5 files changed, 60 insertions(+), 57 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6f181e22d..b5d953c18 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,78 +1,60 @@ language: cpp -sudo: false +cache: ccache # Use Linux by default os: linux +dist: bionic + +# CMake version out of date: update +# TODO: add ARM64, PPC, SPARC builds when we find CMake for them +addons: + snaps: + - name: cmake + confinement: classic + channel: latest matrix: include: - # gcc on arm64 - - compiler: gcc - arch: arm64 - addons: - apt: - packages: - - ccache - env: &Debug - - TRAVIS_CUBERITE_BUILD_TYPE=DEBUG - # AppleClang + # AppleClang Release # OSX workers are slower to start up. Having these first in the build matrix makes travis faster overall. - os: osx - compiler: clang + osx_image: xcode11.3 before_install: - HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache env: &Release - TRAVIS_CUBERITE_BUILD_TYPE=RELEASE + + # AppleClang Debug - os: osx - compiler: clang - env: *Debug + osx_image: xcode11.3 before_install: - HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache - # Default clang + env: &Debug + - TRAVIS_CUBERITE_BUILD_TYPE=DEBUG + + # Clang 7.0 - Release - compiler: clang + before_install: &use-cmake + - export PATH=/snap/bin/:${PATH} env: *Release + + # Clang 7.0 - Debug - compiler: clang + before_install: *use-cmake env: *Debug - # clang 3.5 - - compiler: clang - dist: trusty - addons: &clang35 - apt: - packages: - - clang++-3.5 - - clang-3.5 - before_install: - - CC=clang-3.5;CXX=clang++-3.5 - env: *Release - - compiler: clang - dist: trusty - addons: *clang35 - before_install: - - CC=clang-3.5;CXX=clang++-3.5 - env: *Debug - # gcc 4.8 + + # GCC 7.4 - Release, CMake 3.12 - compiler: gcc - addons: &gcc48 - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 - - gcc-4.8 - before_install: - - CC=gcc-4.8;CXX=g++-4.8 env: *Release + + # GCC 7.4 - Debug - compiler: gcc - addons: *gcc48 - before_install: - - CC=gcc-4.8;CXX=g++-4.8 + before_install: *use-cmake env: *Debug before_script: - export PATH=$(echo "$PATH" | sed -e 's/:\/usr\/lib\/ccache//') script: ./travisbuild.sh -cache: ccache - notifications: email: diff --git a/COMPILING.md b/COMPILING.md index 4c6826f7e..e30ec1e3b 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -6,16 +6,16 @@ To compile Cuberite from source, you need the following set of software: - CMake - Platform-specific make tool (Windows would be MSVC, Linux/macOS GNU make, etc.) - C compiler - - Modern C++ compiler and linker + - Modern C++17 capable compiler and linker To contribute code, you also need a Git client. Windows ------- -We use Microsoft Visual Studio for Windows compilation. It is possible to use other toolchains, but we don't test against them and they aren't supported. Visual Studio 2013 Express for Desktop is being actively used for development. +We use Microsoft Visual Studio for Windows compilation. It is possible to use other toolchains, but we don't test against them and they aren't supported. Visual Studio 2017 Community and above are being actively used for development. -You can find download links for VS2013 Express [here][1]. +You can find download links for VS2019 Community [here][1]. Next, you need to download and install [CMake][2]. You should download a full installation package, so that the installer will set everything up for you (especially the paths). @@ -56,6 +56,8 @@ macOS - Install CMake from its [website][9] or homebrew: `brew install cmake`. +Cuberite requires Xcode 11.3 or newer. + ### Getting the Source ``` @@ -77,7 +79,13 @@ Install git, make, cmake and clang (or gcc), using your platform's package manag ``` sudo apt-get install git make cmake clang ``` -Ensure that you have modern C++ compiler and linker (Clang 3.5+, GCC 4.8+, or VS 2013+). +Ensure that you have modern C++ compiler and linker (Clang 7.0+, GCC 7.4+, or VS 2017+). +Cuberite also requires CMake 3.13 or newer. You might find that your distribution +defaults are too out of date, in which case you may need to add a new `apt` source, +or download directly from the projects' websites: + + - [Clang][Clang-download] + - [CMake][2] ### Getting the Source @@ -260,3 +268,4 @@ Disables optimizations for the build host. This is important when building on a [10]: https://developer.android.com/ndk/downloads/index.html [11]: https://www.lua.org/download.html [12]: https://github.com/ninja-build/ninja/releases +[clang-download]: https://releases.llvm.org/download.html diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 662a2bbb0..789d3998f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ When contributing, you must follow our code conventions. Otherwise, CI builds wi Here are the conventions: - - We use the subset of C++11 supported by MSVC 2013 (ask if you think that something outside of this subset would be useful) + - We use C++17. - All new public functions in all classes need documenting comments on what they do and what behavior they follow, use doxy-comments formatted as `/** Description */`. Do not use asterisks on additional lines in multi-line comments. - Use spaces after the comment markers: `// Comment` instead of `//Comment`. A comment must be prefixed with two spaces if it's on the same line with code: - `SomeFunction()//Note the two spaces prefixed to me and the space after the slashes.` diff --git a/GETTING-STARTED.md b/GETTING-STARTED.md index 9ba612919..016659a49 100644 --- a/GETTING-STARTED.md +++ b/GETTING-STARTED.md @@ -27,7 +27,7 @@ Useful Resources - [Minecraft Wiki](https://minecraft.gamepedia.com/Minecraft_Wiki) - [Minecraft Protocol Wiki](http://wiki.vg/Main_Page) - [Lua API Documentation](https://api.cuberite.org/) - - [VS2013 Community Edition Download](https://www.visualstudio.com/downloads/) + - [Visual Studio Community Edition Download](https://www.visualstudio.com/downloads/) Setting up a Dev Environment ============================ diff --git a/appveyor.yml b/appveyor.yml index c66be5f12..bb3847585 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,10 @@ version: 1.0.{build} -image: Visual Studio 2015 clone_depth: 50 +image: +- Visual Studio 2019 +- Visual Studio 2017 + # Set up environment variables for build info environment: CUBERITE_BUILD_SERIES_NAME: AppVeyor @@ -21,6 +24,14 @@ environment: configuration: Release BUILD_DIR: Release-x64 +matrix: + exclude: + - image: Visual Studio 2017 + configuration: Release + - image: Visual Studio 2019 + configuration: Debug + + install: - echo %TIME% - git submodule update --init @@ -38,7 +49,8 @@ for: - if not exist %BUILD_DIR% mkdir %BUILD_DIR% - cd %BUILD_DIR% - echo %TIME% - - cmake -G "Visual Studio 14 2015 Win64" -DSELF_TEST=1 -DBUILD_TOOLS=1 .. + # TODO: re-add -DSELF_TEST=YES -DBUILD_TOOLS=YES once PCH for tools enabled (too slow otherwise) + - cmake -G "Visual Studio 15 2017" -A "x64" -DSELF_TEST=NO -DBUILD_TOOLS=NO .. - echo %TIME% - cd .. @@ -63,7 +75,7 @@ for: - if not exist %BUILD_DIR% mkdir %BUILD_DIR% - cd %BUILD_DIR% - echo %TIME% - - cmake -G "Visual Studio 14 2015" .. + - cmake -G "Visual Studio 16 2019" .. - echo %TIME% - cd .. @@ -88,7 +100,7 @@ for: - if not exist %BUILD_DIR% mkdir %BUILD_DIR% - cd %BUILD_DIR% - echo %TIME% - - cmake -G "Visual Studio 14 2015 Win64" .. + - cmake -G "Visual Studio 16 2019" -A "x64" .. - echo %TIME% - cd ..