diff --git a/.circleci/config.yml b/.circleci/config.yml index 711be39d7..b3b97363e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,9 +1,9 @@ version: 2 jobs: build: - working_directory: /root/SRB2 + working_directory: /home/circleci/SRB2 docker: - - image: debian:stretch + - image: cimg/base:current environment: CC: ccache gcc -m32 PKG_CONFIG_LIBDIR: /usr/lib/i386-linux-gnu/pkgconfig @@ -11,7 +11,7 @@ jobs: LIBGME_LDFLAGS: -lgme CCACHE_COMPRESS: true WFLAGS: -Wno-unsuffixed-float-constants - GCC49: true + GCC81: true #- image: ubuntu:trusty # environment: # CC: ccache gcc -m32 @@ -25,39 +25,42 @@ jobs: steps: - run: name: Add i386 arch - command: dpkg --add-architecture i386 + command: sudo dpkg --add-architecture i386 - run: name: Add STJr PPA command: | - apt-get -qq update - apt-get -qq -y install dirmngr - apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0B1702D71499D9C25F986507F240F4449D3B0EC6 - echo "deb http://ppa.launchpad.net/stjr/srb2/ubuntu trusty main" >> /etc/apt/sources.list + sudo apt-get -qq update + sudo apt-get -qq -y install dirmngr + sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0B1702D71499D9C25F986507F240F4449D3B0EC6 + echo "deb http://ppa.launchpad.net/stjr/srb2/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list - run: name: Make APT cache folder - command: mkdir -p /root/.cache/apt/archives/partial + command: mkdir -p /home/circleci/.cache/apt/archives/partial - run: name: Make APT cache usage by _apt - command: chown -Rv _apt:root /root/.cache/apt/archives/partial + command: sudo chown -Rv _apt:root /home/circleci/.cache/apt/archives/partial - run: name: Update APT listing - command: apt-get -qq update + command: sudo apt-get -qq update - run: name: Support S3 upload - command: apt-get -qq -y install ca-certificates + command: sudo apt-get -qq -y install ca-certificates - restore_cache: keys: - v1-SRB2-APT - run: - name: Install SDK - command: apt-get -o Dir::Cache="/root/.cache/apt" -qq -y --no-install-recommends install git build-essential nasm libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 libcurl4-openssl-dev:i386 libopenmpt-dev:i386 gettext ccache wget gcc-multilib upx openssh-client + name: Uninstall amd64 SDK + command: sudo apt-get -o Dir::Cache="/home/circleci/.cache/apt" -qq -y --no-install-recommends remove libcurl4-openssl-dev:amd64 + - run: + name: Install i386 SDK + command: sudo apt-get -o Dir::Cache="/home/circleci/.cache/apt" -qq -y --no-install-recommends install git build-essential libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 libcurl4-openssl-dev:i386 libopenmpt-dev:i386 gettext ccache wget gcc-multilib upx openssh-client - run: name: make md5sum - command: find /root/.cache/apt/archives -type f -print0 | sort -z | xargs -r0 md5sum > /root/.cache/apt_archives.md5 + command: sudo find /home/circleci/.cache/apt/archives -type f -print0 | sort -z | sudo xargs -r0 md5sum > /home/circleci/.cache/apt_archives.md5 - save_cache: - key: v1-SRB2-APT-{{ checksum "/root/.cache/apt_archives.md5" }} + key: v1-SRB2-APT-{{ checksum "/home/circleci/.cache/apt_archives.md5" }} paths: - - /root/.cache/apt + - /home/circleci/.cache/apt - checkout - run: name: Compile without network support @@ -78,9 +81,9 @@ jobs: name: Compile command: make -C src LINUX=1 ERRORMODE=1 -k -j4 - store_artifacts: - path: /root/SRB2/bin/ + path: /home/circleci/SRB2/bin/ destination: bin - save_cache: key: v1-SRB2-{{ .Branch }}-{{ checksum "make/linux/SDL.deps" }} paths: - - /root/.ccache + - /home/circleci/.ccache diff --git a/.gitignore b/.gitignore index 2b4d9d2fb..268e36329 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ Win32_LIB_ASM_Release /bin /build /build/* +/CMakeUserPresets.json \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d36c1fb6..80a3bdcd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,7 +131,11 @@ if("${SRB2_CONFIG_SYSTEM_LIBRARIES}") find_package(SDL2_mixer REQUIRED) find_package(CURL REQUIRED) find_package(OPENMPT REQUIRED) - find_package(GME REQUIRED) + + # libgme defaults to "Nuked" YM2612 emulator, which is + # very SLOW. The system library probably uses the + # default so just always build it. + #find_package(GME REQUIRED) endif() if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) @@ -142,13 +146,6 @@ if ((${SRB2_USE_CCACHE}) AND (${CMAKE_C_COMPILER} MATCHES "clang")) message(WARNING "Using clang and CCache: You may want to set environment variable CCACHE_CPP2=yes to prevent include errors during compile.") endif() -# Add sources from Sourcefile -function(target_sourcefile type) - file(STRINGS Sourcefile list - REGEX "[-0-9A-Za-z_]+\.${type}") - target_sources(SRB2SDL2 PRIVATE ${list}) -endfunction() - # bitness check set(SRB2_SYSTEM_BITS 0) if(CMAKE_SIZEOF_VOID_P EQUAL 8) @@ -167,7 +164,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") # Set EXE names so the assets CMakeLists can refer to its target -set(SRB2_SDL2_EXE_NAME srb2 CACHE STRING "Executable binary output name") +set(SRB2_SDL2_EXE_NAME "" CACHE STRING "Override executable binary output name") +set(SRB2_SDL2_EXE_SUFFIX "" CACHE STRING "Optional executable suffix, separated by an underscore") include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) @@ -175,11 +173,37 @@ add_subdirectory(src) add_subdirectory(assets) -## config.h generation set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary") include(GitUtilities) -git_latest_commit(SRB2_COMP_COMMIT "${CMAKE_SOURCE_DIR}") -git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}") -set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}") -set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}") -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h) + +if("${SRB2_SDL2_EXE_NAME}" STREQUAL "") + # cause a reconfigure if the branch changes + get_git_dir(SRB2_GIT_DIR) + configure_file("${SRB2_GIT_DIR}/HEAD" HEAD COPYONLY) + + git_current_branch(SRB2_GIT_REVISION) + + if("${SRB2_GIT_REVISION}" STREQUAL "") + # use abbreviated commit hash if on detached HEAD + git_latest_commit(SRB2_GIT_REVISION) + endif() + + if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows") + list(APPEND EXE_NAME_PARTS "srb2win") + elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + list(APPEND EXE_NAME_PARTS "lsdlsrb2") + else() + list(APPEND EXE_NAME_PARTS "srb2") + endif() + + if(NOT "${SRB2_GIT_REVISION}" STREQUAL "master") + list(APPEND EXE_NAME_PARTS ${SRB2_GIT_REVISION}) + endif() +else() + list(APPEND EXE_NAME_PARTS ${SRB2_SDL2_EXE_NAME}) +endif() + +list(APPEND EXE_NAME_PARTS ${SRB2_SDL2_EXE_SUFFIX}) + +list(JOIN EXE_NAME_PARTS "_" EXE_NAME) +set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME ${EXE_NAME}) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..7713bb385 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,29 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "default", + "description": "Build using default generator", + "binaryDir": "build", + "cacheVariables": { + "CMAKE_C_FLAGS": "-fdiagnostics-color", + "CMAKE_CXX_FLAGS": "-fdiagnostics-color", + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } + }, + { + "name": "debug", + "description": "Build for development (no optimizations)", + "inherits": "default", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + } + ], + "buildPresets": [ + { + "name": "default", + "configurePreset": "default" + } + ] +} diff --git a/README.md b/README.md index 49a3cc36d..56ff2d02d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ [Sonic Robo Blast 2](https://srb2.org/) is a 3D Sonic the Hedgehog fangame based on a modified version of [Doom Legacy](http://doomlegacy.sourceforge.net/). ## Dependencies -- NASM (x86 builds only) - SDL2 (Linux/OS X only) - SDL2-Mixer (Linux/OS X only) - libupnp (Linux/OS X only) diff --git a/SRB2.cbp b/SRB2.cbp index 2a1eb87b8..9e887bf85 100644 --- a/SRB2.cbp +++ b/SRB2.cbp @@ -1992,24 +1992,6 @@ HW3SOUND for 3D hardware sound support