build: get rid of clang-cl in favor of actual clang among other things (#1589)

* git: ignore vs build dir

* cmake: ditch `clang-cl` on windows in favor of actual `clang`

* build: suppress a significant number of warnings

* build: adjust workflows and vendor nasm

* docs: update docs to remove `clang-cl` mentions

* build: fix some copy-paste mistakes in the linux build

* build: remove C++20 compat warnings as that is useful if we want to upgrade
This commit is contained in:
Tyler Wilding 2022-07-03 17:35:39 -04:00 committed by GitHub
parent 6c595355b6
commit 8fefd298fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 356 additions and 235 deletions

View file

@ -1,7 +1,5 @@
name: Linux
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
@ -15,7 +13,6 @@ on:
jobs:
build:
strategy:
# Prevent one build from failing everything (although maybe those should be included as experimental builds instead)
fail-fast: false
matrix:
os: [ubuntu-20.04]
@ -23,7 +20,6 @@ jobs:
name: ${{ matrix.compiler }}
runs-on: ${{ matrix.os }}
# Set some sort of timeout in the event of run-away builds. We are limited on concurrent jobs so, get rid of them.
timeout-minutes: 45
env: # overrides: https://github.com/mbitsnbites/buildcache/blob/master/doc/configuration.md
@ -33,63 +29,66 @@ jobs:
BUILDCACHE_DIRECT_MODE: true
BUILDCACHE_LOG_FILE: ${{ github.workspace }}/buildcache.log
# TODO - separate clang and gcc into separate workflows
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Checkout Submodules
run: git submodule update --init --recursive -j 2
- name: Get Common Package Dependencies
run: sudo apt install build-essential cmake clang gcc g++ lcov make nasm libxrandr-dev libxinerama-dev libxcursor-dev libpulse-dev libxi-dev zip
- name: Get Clang
if: matrix.compiler == 'clang'
run: sudo apt install clang
- name: Install Package Dependencies
run: >
sudo apt install build-essential cmake
clang gcc g++ lcov make nasm libxrandr-dev
libxinerama-dev libxcursor-dev libpulse-dev
libxi-dev zip
- name: Setup Buildcache
uses: mikehardy/buildcache-action@v1.2.2
uses: mikehardy/buildcache-action@v1.3.0
with:
cache_key: ${{ matrix.os }}-${{ matrix.compiler }}
- name: CMake Generation - Clang
if: matrix.compiler == 'clang' && !startsWith(github.ref, 'refs/tags/')
# TODO - CMake - replace with presets!
- name: CMake Generation - Clang - ASAN
if: matrix.compiler == 'clang'
env:
CC: clang
CXX: clang++
run: |
export CC=clang
export CXX=clang++
ls -l ${{ github.workspace }}/buildcache/bin/buildcache
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_FOR_RELEASE=ON \
-DCMAKE_C_COMPILER_LAUNCHER="${{ github.workspace }}"/buildcache/bin/buildcache \
-DCMAKE_CXX_COMPILER_LAUNCHER="${{ github.workspace }}"/buildcache/bin/buildcache \
-DASAN_BUILD=ON
-DASAN_BUILD=ON \
-DCMAKE_C_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache \
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache
- name: CMake Generation - Clang - No ASAN
# TODO - CMake - replace with presets!
- name: CMake Generation - Clang - Statically Linked
if: matrix.compiler == 'clang' && startsWith(github.ref, 'refs/tags/')
env:
CC: clang
CXX: clang++
run: |
export CC=clang
export CXX=clang++
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_FOR_RELEASE=ON \
-DCMAKE_C_COMPILER_LAUNCHER="${{ github.workspace }}"/buildcache/bin/buildcache \
-DCMAKE_CXX_COMPILER_LAUNCHER="${{ github.workspace }}"/buildcache/bin/buildcache \
-DASAN_BUILD=OFF
-DSTATICALLY_LINK=ON \
-DCMAKE_C_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache \
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache
- name: CMake Generation - GCC
if: matrix.compiler == 'gcc'
env:
CC: gcc
CXX: g++
run: |
export CC=gcc
export CXX=g++
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER="${{ github.workspace }}"/buildcache/bin/buildcache \
-DCMAKE_CXX_COMPILER_LAUNCHER="${{ github.workspace }}"/buildcache/bin/buildcache \
-DCODE_COVERAGE=ON
-DCODE_COVERAGE=ON \
-DCMAKE_C_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache \
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache
- name: Build Project
working-directory: ./build
run: make -j4
run: make -j$((`nproc`+1))
- name: Run Tests
if: matrix.compiler == 'clang'
@ -105,9 +104,27 @@ jobs:
continue-on-error: true
with:
project-token: ${{ secrets.CODACY_PROJECT_KEY }}
# lcov report
coverage-reports: ./build/goalc-test_coverage.info
- name: Upload artifact
# NOTE - the GCC executables are huge as they've been compiled with coverage support
if: matrix.compiler == 'clang'
uses: actions/upload-artifact@v3
with:
name: opengoal-${{ matrix.os }}-${{ matrix.compiler }}
path: |
./build/**/*.so
./build/**/*.a
./build/decompiler/decompiler
./build/decompiler/extractor
./build/game/gk
./build/sound/sndplay
./build/goalc/goalc
./build/tools/dgo_packer
./build/tools/dgo_unpacker
./build/tools/memory_dump_tolls
./build/tools/level_tools/level_dump
# ---- Release / Tagging related steps ----
- name: Prepare Build Artifacts
if: github.repository == 'open-goal/jak-project' && startsWith(github.ref, 'refs/tags/') && matrix.compiler == 'clang'

View file

@ -39,45 +39,52 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Checkout Submodules
run: git submodule update --init --recursive -j 2
- name: Install Dependencies
run: Choco-Install -PackageName nasm
- name: Install NASM
run: choco install ${{ github.workspace }}/third-party/nasm/nasm.2.15.05.nupkg
- name: Setup Buildcache
uses: mikehardy/buildcache-action@v1.2.2
uses: mikehardy/buildcache-action@v1.3.0
with:
cache_key: ${{ matrix.os }}-${{ matrix.compiler }}
# TODO - eventually fight with this to get it to use Ninja and such
- name: CMake Generation
shell: cmd # ideally id like everything to be powershell but running this bat file is finicky
run: |
if "${{ matrix.compiler }}" == "clang" (
call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
cmake -B build -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_FOR_RELEASE=ON -DCMAKE_C_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe" -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe" .
) else (
call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
cmake -B build -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER="${{ github.workspace }}"/buildcache/bin/buildcache.exe -DCMAKE_CXX_COMPILER_LAUNCHER="${{ github.workspace }}"/buildcache/bin/buildcache.exe .
)
- uses: ilammy/msvc-dev-cmd@v1
# TODO - separate workflows!
- name: CMake Generation - Clang
shell: cmd
if: matrix.compiler == 'clang'
run: cmake -B build --preset=Release-clang -DCMAKE_C_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache.exe -DCMAKE_CXX_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache.exe .
- name: CMake Generation - Clang - Statically Linked
shell: cmd
if: matrix.compiler == 'clang' && startsWith(github.ref, 'refs/tags/')
run: cmake -B build --preset=Release-clang-static -DCMAKE_C_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache.exe -DCMAKE_CXX_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache.exe .
- name: CMake Generation - MSVC
shell: cmd
if: matrix.compiler == 'msvc'
run: cmake -B build --preset=Release-msvc -DCMAKE_C_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache.exe -DCMAKE_CXX_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache.exe .
- name: Build Project
working-directory: ./build
shell: cmd
run: |
call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
if "${{ matrix.compiler }}" == "msvc" (
set CL=/MP
)
nmake
cmake --build build -j 2
- name: Run Tests
timeout-minutes: 5
env:
NEXT_DIR: ${{ github.workspace }}
timeout-minutes: 10
run: ./build/bin/goalc-test.exe --gtest_color=yes --gtest_filter="-*MANUAL_TEST*"
- name: Upload artifact
if: matrix.compiler == 'clang'
uses: actions/upload-artifact@v3
with:
name: opengoal-${{ matrix.os }}-${{ matrix.compiler }}
path: ./build/bin
# ---- Release / Tagging related steps ----
- name: Prepare Build Artifacts
if: github.repository == 'open-goal/jak-project' && startsWith(github.ref, 'refs/tags/') && matrix.compiler == 'clang'

View file

@ -5,43 +5,70 @@ set(CMAKE_CXX_STANDARD 17)
project(jak)
include(CTest)
# Include third-party modules
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/third-party/cmake/modules/)
# Default to Release mode
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
option(BUILD_FOR_RELEASE "Build for release purposes (static everything)" OFF)
if(BUILD_FOR_RELEASE)
# Potentially statically build the project
option(STATICALLY_LINK "Build for release purposes (statically link everything)" OFF)
if(STATICALLY_LINK)
message(STATUS "Statically linking project")
set(BUILD_SHARED_LIBS OFF)
else()
set(BUILD_SHARED_LIBS ON)
endif()
# Set default compile flags
# optimization level can be set here. You can overwrite these in a per-project basis if you want.
if(MSVC AND (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
message(STATUS "Clang on MSVC detected! Adding compile flags")
# Setup compiler flags
# TODO - consider moving most of the configuration into presets
# - https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
# - requires atleast CMake 3.19
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message(STATUS "Clang Detected - Setting Defaults")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} \
-Xclang -fcxx-exceptions \
-Xclang -fexceptions \
-Xclang -std=c++17 \
-Xclang -D_CRT_SECURE_NO_WARNINGS \
/arch:AVX \
-Wno-c++11-narrowing -Wno-c++98-compat -Wno-c++20-compat -W3")
-fcxx-exceptions \
-fexceptions \
-fdiagnostics-color=always \
-std=c++17 \
-mavx \
-Wall \
-Wno-c++11-narrowing \
-Wno-c++98-compat \
-O3")
# linker flags
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:16000000,16384")
# additional c++ and linker flags for release mode for our projects
if(CMAKE_BUILD_TYPE MATCHES "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Ob2")
elseif(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Ob2")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
# Increase stack size for windows, who's default is too low
if(WIN32)
# Increase the reserved stack size for all threads to 16MB
# Note: this is only _reserved_ memory, not necessarily _committed_ memory
# TODO - test with add_link_options instead
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LDFLAGS} -Xlinker /STACK:16000000")
endif()
elseif(UNIX)
message(STATUS "GCC detected! Adding compile flags")
# additional c++ and linker flags for release mode for our projects
if(CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif()
if(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
# TODO - test with add_link_options instead
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LDFLAGS} -Xlinker /debug")
endif()
# Fuzzing
if(NOT STATICALLY_LINK AND ASAN_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -O1")
message(STATUS "Doing ASAN build")
endif()
# Warnings
set(THIRDPARTY_IGNORED_WARNINGS "-Wno-everything")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
message(STATUS "GCC detected - Setting Defaults")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} \
-Wall \
@ -64,62 +91,59 @@ elseif(UNIX)
if(CMAKE_BUILD_TYPE MATCHES "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif()
set(THIRDPARTY_IGNORED_WARNINGS "-w")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
message(STATUS "MSVC detected - Setting Defaults")
elseif(MSVC)
message(STATUS "MSVC detected!! Adding compile flags")
if(CMAKE_BUILD_TYPE MATCHES "Debug")
# This actually breaks some standard library things for some reason?
# message("Setting Flags to Enable Edit and Continue")
# set(CMAKE_CXX_FLAGS_DEBUG "/ZI")
endif()
# c++ flags for all build types
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /utf-8 /arch:AVX")
# linker flags
# Increase stack size for windows, who's default is too low
# Increase the reserved stack size for all threads to 16MB
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:16000000,16384")
# additional c++ and linker flags for specific build types
if(CMAKE_BUILD_TYPE MATCHES "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Ob2")
elseif(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
if(CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Ob2")
endif()
if(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
endif()
set(THIRDPARTY_IGNORED_WARNINGS "/w")
else()
message(FATAL_ERROR "Unknown Compiler '${CMAKE_CXX_COMPILER_ID}', get out!")
endif()
# Platform Specific Settings
if(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION 7.1.7600.0.30514) # win7.1, supports xp
message("Windows SDK version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
endif()
if(ASAN_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -O1")
message(STATUS "Doing ASAN build")
endif()
# Code Coverage
option(CODE_COVERAGE "Enable Code Coverage Compiler Flags" OFF)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/third-party/cmake/modules/)
if(UNIX AND CODE_COVERAGE)
include(CodeCoverage)
append_coverage_compiler_flags()
message("Code Coverage build is enabled!")
else()
message("Code Coverage build is disabled!")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CODE_COVERAGE)
include(CodeCoverage)
append_coverage_compiler_flags()
message(STATUS "Code Coverage build is enabled!")
endif()
# Dependencies and Libraries
# includes relative to top level jak-project folder
include_directories(./)
# build templating engine library
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${THIRDPARTY_IGNORED_WARNINGS} ")
include_directories(SYSTEM third-party/inja)
# build repl library
add_subdirectory(third-party/replxx EXCLUDE_FROM_ALL)
string(REPLACE " ${THIRDPARTY_IGNORED_WARNINGS} " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# build common library
add_subdirectory(common)
@ -127,6 +151,7 @@ add_subdirectory(common)
# build decompiler
add_subdirectory(decompiler)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${THIRDPARTY_IGNORED_WARNINGS} ")
add_subdirectory(third-party/cubeb)
# build glfw library
@ -137,6 +162,7 @@ add_subdirectory(third-party/zstd)
include_directories(third-party/glad/include)
include_directories(third-party/glfw/include)
add_subdirectory(third-party/imgui)
string(REPLACE " ${THIRDPARTY_IGNORED_WARNINGS} " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# build the game code in C++
add_subdirectory(game)
@ -149,41 +175,47 @@ add_subdirectory(tools)
# build the gtest libraries
if(WIN32)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${THIRDPARTY_IGNORED_WARNINGS} ")
add_subdirectory(third-party/googletest EXCLUDE_FROM_ALL)
include(GoogleTest)
string(REPLACE " ${THIRDPARTY_IGNORED_WARNINGS} " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# build tests
include(test/CMakeLists.txt)
# build lzokay library
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${THIRDPARTY_IGNORED_WARNINGS} ")
add_subdirectory(third-party/lzokay EXCLUDE_FROM_ALL)
# build format library
add_subdirectory(third-party/fmt EXCLUDE_FROM_ALL)
add_subdirectory(third-party/stb_image EXCLUDE_FROM_ALL)
add_subdirectory(third-party/tiny_gltf EXCLUDE_FROM_ALL)
add_subdirectory(third-party/xdelta3 EXCLUDE_FROM_ALL)
# discord rich presence
include_directories(third-party/discord-rpc/include)
add_subdirectory(third-party/discord-rpc EXCLUDE_FROM_ALL)
# build zydis third party library for disassembling x86
# NOTE: Once under CMake 3.13's policy CMP0077, override with `set()` instead
# TODO - Once under CMake 3.13's policy CMP0077, override with `set()` instead
option(ZYDIS_BUILD_TOOLS "Zydis: Build tools" OFF)
option(ZYDIS_BUILD_EXAMPLES "Zydis: Build examples" OFF)
if(BUILD_SHARED_LIBS)
option(ZYDIS_BUILD_SHARED_LIB "Zydis: Build shared library" ON)
else()
option(ZYDIS_BUILD_SHARED_LIB "Zydis: Build shared library" OFF)
endif()
add_subdirectory(third-party/zydis EXCLUDE_FROM_ALL)
# windows memory management lib
if(WIN32)
add_subdirectory(third-party/mman)
endif()
string(REPLACE " ${THIRDPARTY_IGNORED_WARNINGS} " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

View file

@ -2,130 +2,100 @@
"version": 2,
"configurePresets": [
{
"name": "linux-default",
"displayName": "Linux Debug",
"description": "Target the Windows Subsystem for Linux (WSL) or a remote Linux system.",
"name": "base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
"architecture": {
"value": "x64",
"strategy": "external"
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ "Linux" ] },
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" }
"cacheVariables": {
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"INSTALL_GTEST": "True",
"ASAN_BUILD": "OFF"
}
},
{
"name": "base-release",
"hidden": true,
"inherits": "base",
"binaryDir": "${sourceDir}/out/build/Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "base-relwithdeb",
"hidden": true,
"inherits": "base",
"binaryDir": "${sourceDir}/out/build/Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "base-debug",
"hidden": true,
"inherits": "base",
"binaryDir": "${sourceDir}/out/build/Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "base-clang",
"hidden": true,
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
}
},
{
"name": "base-msvc",
"hidden": true,
"cacheVariables": {
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl"
}
},
{
"name": "Debug-clang",
"displayName": "Windows Debug (clang-cl)",
"description": "Target Windows with the Visual Studio development environment.",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/Debug",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"INSTALL_GTEST": "True",
"CMAKE_C_COMPILER": "clang-cl",
"CMAKE_CXX_COMPILER": "clang-cl"
},
"vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ "Windows" ] } }
},
{
"name": "Release-clang",
"displayName": "Windows Release (clang-cl)",
"description": "Target Windows with the Visual Studio development environment.",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/Release",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"INSTALL_GTEST": "True",
"CMAKE_C_COMPILER": "clang-cl",
"CMAKE_CXX_COMPILER": "clang-cl"
},
"vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ "Windows" ] } }
"displayName": "Windows Debug (clang)",
"description": "Build with Clang with Debug Symbols",
"inherits": ["base-debug", "base-clang"]
},
{
"name": "RelWithDebInfo-clang",
"displayName": "Windows RelWithDebInfo (clang-cl)",
"description": "Target Windows with the Visual Studio development environment.",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/Release",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"INSTALL_GTEST": "True",
"CMAKE_C_COMPILER": "clang-cl",
"CMAKE_CXX_COMPILER": "clang-cl"
},
"vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ "Windows" ] } }
"displayName": "Windows RelWithDebInfo (clang)",
"description": "Build with Clang as Release with Debug Symbols",
"inherits": ["base-relwithdeb", "base-clang"]
},
{
"name": "Release-clang",
"displayName": "Windows Release (clang)",
"description": "Build with Clang as Release without Debug Symbols",
"inherits": ["base-release", "base-clang"]
},
{
"name": "Release-clang-static",
"displayName": "Windows Release - Static (clang-cl)",
"description": "Target Windows with the Visual Studio development environment.",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/Release",
"architecture": {
"value": "x64",
"strategy": "external"
},
"displayName": "Windows Static Release (clang)",
"description": "Build with Clang as Release but statically linked",
"inherits": ["base-release", "base-clang"],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"INSTALL_GTEST": "True",
"CMAKE_C_COMPILER": "clang-cl",
"CMAKE_CXX_COMPILER": "clang-cl",
"BUILD_FOR_RELEASE": "true"
},
"vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ "Windows" ] } }
"STATICALLY_LINK": "true"
}
},
{
"name": "Debug-msvc",
"displayName": "Windows Debug (msvc)",
"description": "Target Windows with the Visual Studio development environment.",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/Debug",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"INSTALL_GTEST": "True"
},
"vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ "Windows" ] } }
"description": "Build with MSVC's CL with Debug Symbols",
"inherits": ["base-debug", "base-msvc"]
},
{
"name": "Release-msvc",
"displayName": "Windows Release (msvc)",
"description": "Target Windows with the Visual Studio development environment.",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/Release",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"INSTALL_GTEST": "True"
},
"vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ "Windows" ] } }
"description": "Build with MSVC's CL as Release without Debug Symbols",
"inherits": ["base-release", "base-msvc"]
}
]
}

View file

@ -167,8 +167,7 @@ On Windows, it's recommended to use a package manager, we use Scoop. Follow the
Once Scoop is installed, run the following commands:
```sh
scoop install git llvm nasm python
scoop install task
scoop install git llvm nasm python task
```
### Setting up and Opening the Project
@ -183,7 +182,7 @@ This will create a `jak-project` folder, open the project as a CMake project via
![](./docs/img/windows/open-project.png)
Then build the entire project as `Windows Release (clang-cl)`. You can also press Ctrl+Shift+B as a hotkey for Build All. We currently prefer `clang-cl` on Windows as opposed to `msvc`, though it should work as well!
Then build the entire project as `Windows Release (clang)`. You can also press Ctrl+Shift+B as a hotkey for Build All. We currently prefer `clang` on Windows as opposed to `msvc`, though it should work as well!
![](./docs/img/windows/release-build.png)
![](./docs/img/windows/build-all.png)

Binary file not shown.

Binary file not shown.

View file

@ -116,15 +116,15 @@ std::optional<std::string> try_get_jak_project_path() {
return {};
}
return std::string(my_path).substr(
0, pos + 11); // + 12 to include "/jak-project" in the returned filepath
return std::make_optional(std::string(my_path).substr(
0, pos + 11)); // + 12 to include "/jak-project" in the returned filepath
}
std::optional<std::filesystem::path> try_get_data_dir() {
std::filesystem::path my_path = get_current_executable_path();
auto data_dir = my_path.parent_path() / "data";
if (std::filesystem::exists(data_dir) && std::filesystem::is_directory(data_dir)) {
return data_dir;
return std::make_optional(data_dir);
} else {
return {};
}

View file

@ -1,5 +1,13 @@
#pragma once
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
/*!
* @file LinkedWord.h
* A word (4 bytes), possibly with some linking info.
@ -152,3 +160,9 @@ class LinkedWord {
};
} // namespace decompiler
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -1,3 +1,11 @@
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
#include "kmachine.h"
#include <filesystem>
@ -721,3 +729,9 @@ void InitMachineScheme() {
}
} // namespace jak1
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif

View file

@ -1,3 +1,11 @@
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
#endif
//--------------------------MIPS2C---------------------
#include "common/dma/gs.h"
@ -3274,4 +3282,8 @@ void link() {
} // namespace method_9_collide_puss_work
} // namespace Mips2C
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif

View file

@ -1,3 +1,10 @@
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
#endif
//--------------------------MIPS2C---------------------
#include "game/kernel/jak1/kscheme.h"
@ -1011,3 +1018,9 @@ void link() {
} // namespace method_18_collide_edge_work
} // namespace Mips2C
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif

View file

@ -9,6 +9,14 @@
* should work.
*/
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
#include "fake_iso.h"
#include <cstring>
@ -369,3 +377,9 @@ void LoadMusicTweaks() {
gMusicTweakInfo.TweakCount = 0;
}
}
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif

6
third-party/fmt/CMakeLists.txt generated vendored
View file

@ -1,8 +1,8 @@
if (UNIX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "-O3")
else ()
elseif(MSVC)
set(CMAKE_CXX_FLAGS "/EHsc")
endif (UNIX)
endif()
include_directories(../)
add_library(fmt format.cc)

29
third-party/nasm/LICENSE generated vendored Normal file
View file

@ -0,0 +1,29 @@
NASM is now licensed under the 2-clause BSD license, also known as the
simplified BSD license.
Copyright 1996-2010 the NASM Authors - All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

BIN
third-party/nasm/nasm.2.15.05.nupkg generated vendored Normal file

Binary file not shown.

10
third-party/stb_image/CMakeLists.txt generated vendored
View file

@ -1,8 +1,8 @@
if (UNIX)
set(CMAKE_CXX_FLAGS "-O3")
else ()
set(CMAKE_CXX_FLAGS "/EHsc")
endif (UNIX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "-O3")
elseif(MSVC)
set(CMAKE_CXX_FLAGS "/EHsc")
endif()
add_library(stb_image stb_image.cpp)

10
third-party/tiny_gltf/CMakeLists.txt generated vendored
View file

@ -1,8 +1,8 @@
if (UNIX)
set(CMAKE_CXX_FLAGS "-O3")
else ()
set(CMAKE_CXX_FLAGS "/EHsc")
endif (UNIX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "-O3")
elseif(MSVC)
set(CMAKE_CXX_FLAGS "/EHsc")
endif()
include_directories(../ ../stb_image)
add_library(tiny_gltf tiny_gltf.cpp)