From c2d7463a387a31884e6fad3a8275c90d17baf20e Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Fri, 15 Jun 2018 23:01:02 +0200 Subject: [PATCH] Add Clang to Travis and treat warnings as errors The GCC version used by Travis is old and appears not to support all the warnings we would like to get, so reenable Clang. Additionally make lots of cleanups to Travis config and make the build a lot faster too. Also change both Travis and AppVeyor builds to treat warnings as errors, and include VS2017 in the matrix for AppVeyor. I have also removed VS2010 because it is ancient at this point. Updated Premake to alpha12 and fixed the premake build file appropriately. --- .editorconfig | 6 +++++- .travis.yml | 38 ++++++++++++-------------------------- RecastDemo/CMakeLists.txt | 4 ++-- RecastDemo/premake5.lua | 29 +++++++++++++---------------- appveyor.yml | 25 +++++++++++++------------ 5 files changed, 45 insertions(+), 57 deletions(-) diff --git a/.editorconfig b/.editorconfig index 8a938ec..08f28f4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,4 +5,8 @@ root = true [*] indent_size = 4 -indent_style = tab \ No newline at end of file +indent_style = tab + +[*.yml] +indent_size = 2 +indent_style = space diff --git a/.travis.yml b/.travis.yml index 17ec14a..f39e8c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,36 +5,22 @@ language: cpp # Build with gcc and clang. compiler: - gcc -# Disable clang for now since it seems there's a problem using it with fast fp math; it's likely Travis' ancient environment that's at fault. -# - clang + - clang # Build both debug and release configurations, through use of an environment variable in the build matrix. env: - - CONFIGURATION: debug - CMAKE_BUILD_TYPE: Debug - - CONFIGURATION: release - CMAKE_BUILD_TYPE: Release + - BUILD_TYPE=debug CMAKE_BUILD_TYPE=Debug + - BUILD_TYPE=release CMAKE_BUILD_TYPE=Release + +addons: + apt: + packages: + - libsdl2-dev install: - # Download and build SDL2 from source. - - mkdir dummyprefix - - export PREFIX=$PWD/dummyprefix - - export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig - - export PATH=$PATH:$PWD/dummyprefix/bin - - wget https://www.libsdl.org/release/SDL2-2.0.4.tar.gz -O SDL2.tar.gz - - tar -xzf SDL2.tar.gz - - cd SDL2-2.0.4 - - ./configure --prefix=$PREFIX - - make -j$(nproc) - - make install - - cd .. - # Download and build premake5 from source; the Travis environment doesn't have the right version of glibc6 for the prebuilt binaries to work. - - wget https://github.com/premake/premake-core/releases/download/v5.0.0-alpha6/premake-5.0.0-alpha6-src.zip -O premake.zip - - unzip premake.zip - - cd premake-5.0.0-alpha6/build/gmake.unix - - make config=release - - cd ../../.. - - mv premake-5.0.0-alpha6/bin/release/premake5 premake5 + - wget https://github.com/premake/premake-core/releases/download/v5.0.0-alpha12/premake-5.0.0-alpha12-linux.tar.gz -O premake.tar.gz + - tar -xf premake.tar.gz + - rm premake.tar.gz # Run premake to generate makefiles. # Have to cd into directory and back out since premake5 doesn't appear to accept a directory argument. @@ -44,7 +30,7 @@ before_script: # Run make in the directory containing generated makefiles, on the configuration specified by the environment variable. script: - - make -C RecastDemo/Build/gmake -j$(nproc) config=$CONFIGURATION + - make -C RecastDemo/Build/gmake -j$(nproc) config=${BUILD_TYPE} - RecastDemo/Bin/Tests - make -C build -j$(nproc) - cd build && ctest diff --git a/RecastDemo/CMakeLists.txt b/RecastDemo/CMakeLists.txt index d3208d2..c3ee81b 100644 --- a/RecastDemo/CMakeLists.txt +++ b/RecastDemo/CMakeLists.txt @@ -1,12 +1,12 @@ file(GLOB SOURCES Source/*.cpp Contrib/fastlz/fastlz.c) -include(cmake/FindSDL2.cmake) +LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") find_package(OpenGL REQUIRED) find_package(SDL2 REQUIRED) include_directories(SYSTEM ${OPENGL_INCLUDE_DIR}) -include_directories(SYSTEM ${SDL2_INCLUDE_DIRS}) +include_directories(SYSTEM ${SDL2_INCLUDE_DIR}) include_directories(SYSTEM Contrib/fastlz) include_directories(SYSTEM Contrib) include_directories(../DebugUtils/Include) diff --git a/RecastDemo/premake5.lua b/RecastDemo/premake5.lua index 2dfab88..5f72e8a 100644 --- a/RecastDemo/premake5.lua +++ b/RecastDemo/premake5.lua @@ -11,16 +11,14 @@ solution "recastnavigation" "Debug", "Release" } + location (todir) - -- extra warnings, no exceptions or rtti - flags { - "ExtraWarnings", - "FloatFast", - "Symbols" - } + floatingpoint "Fast" + symbols "On" exceptionhandling "Off" rtti "Off" + flags { "FatalCompileWarnings" } -- debug configs configuration "Debug*" @@ -30,19 +28,20 @@ solution "recastnavigation" -- release configs configuration "Release*" defines { "NDEBUG" } - flags { "Optimize" } + optimize "On" targetdir ( todir .. "/lib/Release" ) + configuration "not windows" + warnings "Extra" + -- windows specific configuration "windows" defines { "WIN32", "_WINDOWS", "_CRT_SECURE_NO_WARNINGS", "_HAS_EXCEPTIONS=0" } - - -- linux specific - configuration { "linux", "gmake" } - buildoptions { - "-Wall", - "-Werror" - } + -- warnings "Extra" uses /W4 which is too aggressive for us, so use W3 instead. + -- Disable: + -- * C4351: new behavior for array initialization + -- * C4291: no matching operator delete found; we don't use exceptions, so doesn't matter + buildoptions { "/W3", "/wd4351", "/wd4291" } project "DebugUtils" language "C++" @@ -171,7 +170,6 @@ project "RecastDemo" configuration { "macosx" } kind "ConsoleApp" -- xcode4 failes to run the project if using WindowedApp includedirs { "/Library/Frameworks/SDL2.framework/Headers" } - buildoptions { "-Wunused-value -Wshadow -Wreorder -Wsign-compare -Wall" } links { "OpenGL.framework", "SDL2.framework", @@ -248,7 +246,6 @@ project "Tests" configuration { "macosx" } kind "ConsoleApp" includedirs { "/Library/Frameworks/SDL2.framework/Headers" } - buildoptions { "-Wunused-value -Wshadow -Wreorder -Wsign-compare -Wall" } links { "OpenGL.framework", "SDL2.framework", diff --git a/appveyor.yml b/appveyor.yml index 0705055..c61bf88 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,17 +1,21 @@ shallow_clone: true -os: - - Visual Studio 2015 - environment: matrix: - - TOOLSET: vs2010 - - TOOLSET: vs2013 - - TOOLSET: vs2015 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + PREMAKE_ACTION: vs2013 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + PREMAKE_ACTION: vs2015 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + PREMAKE_ACTION: vs2017 + +configuration: + - Debug + - Release install: # Download Premake - - ps: Start-FileDownload 'https://github.com/premake/premake-core/releases/download/v5.0.0-alpha7/premake-5.0.0-alpha7-windows.zip' 'premake.zip' + - ps: Start-FileDownload 'https://github.com/premake/premake-core/releases/download/v5.0.0-alpha12/premake-5.0.0-alpha12-windows.zip' 'premake.zip' # Extract it in-place; premake5.exe is at the top level. - 7z x premake.zip @@ -23,14 +27,11 @@ install: - cd RecastDemo\Contrib && 7z x SDL.zip && ren SDL2-2.0.4 SDL && cd ..\.. # Generate solution files using premake. - - cd RecastDemo && "../premake5.exe" %TOOLSET% && cd .. + - cd RecastDemo && "../premake5.exe" %PREMAKE_ACTION% && cd .. -configuration: - - Debug - - Release build: - project: RecastDemo/Build/$(TOOLSET)/recastnavigation.sln + project: RecastDemo/Build/$(PREMAKE_ACTION)/recastnavigation.sln after_test: - RecastDemo\Bin\Tests.exe