diff --git a/.github/workflows/Linux_build.yml b/.github/workflows/Linux_build.yml index 50e43fe82..86c64167a 100644 --- a/.github/workflows/Linux_build.yml +++ b/.github/workflows/Linux_build.yml @@ -77,11 +77,6 @@ jobs: - uses: actions/checkout@main with: fetch-depth: 0 - - uses: actions/cache@main - id: cache - with: - key: ${{ hashFiles('tools/build/bin/premake5.exe') }} - path: tools/build/bin/premake5 - name: Cache Vulkan SDK id: cache-vulkan-sdk-linux uses: actions/cache@v4 @@ -95,7 +90,7 @@ jobs: wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc sudo apt-add-repository "deb http://apt.llvm.org/${UBUNTU_BASE}/ llvm-toolchain-${UBUNTU_BASE}-${{ matrix.LLVM_VERSION }} main" sudo apt-get -y update - sudo apt-get -y install mesa-vulkan-drivers valgrind libc++-dev libc++abi-dev libgtk-3-dev libsdl2-dev libvulkan-dev libx11-xcb-dev clang-${{ matrix.LLVM_VERSION }} ninja-build spirv-tools + sudo apt-get -y install mesa-vulkan-drivers valgrind libc++-dev libc++abi-dev libgtk-3-dev libsdl2-dev libvulkan-dev libx11-xcb-dev clang-${{ matrix.LLVM_VERSION }} lld-${{ matrix.LLVM_VERSION }} ninja-build spirv-tools cmake # Install Vulkan SDK if [ '${{ steps.cache-vulkan-sdk-linux.outputs.cache-hit }}' != 'true' ]; then @@ -112,11 +107,7 @@ jobs: which spirv-opt && spirv-opt --version || echo "Warning: spirv-opt not found" which spirv-dis || echo "Warning: spirv-dis not found" - git submodule update --init --depth=1 -j$(getconf _NPROCESSORS_ONLN) $(grep -oP '(?<=path = )(?!third_party\/(DirectXShaderCompiler|premake-(androidndk|export-compile-commands))).+' .gitmodules) - if [ '${{ steps.cache.outputs.cache-hit }}' != 'true' ]; then - ./xenia-build.py premake - cp third_party/premake-core/bin/release/premake5 tools/build/bin - fi + git submodule update --init --depth=1 -j$(getconf _NPROCESSORS_ONLN) $(grep -oP '(?<=path = )(?!third_party\/DirectXShaderCompiler).+' .gitmodules) - name: Build env: CC: clang-${{ matrix.LLVM_VERSION }} diff --git a/.github/workflows/Windows_build.yml b/.github/workflows/Windows_build.yml index 8a2a91cbb..c64c50561 100644 --- a/.github/workflows/Windows_build.yml +++ b/.github/workflows/Windows_build.yml @@ -123,19 +123,19 @@ jobs: echo "Warning: fxc.exe not found in Windows SDK" } - git submodule update --init --depth=1 -j $env:NUMBER_OF_PROCESSORS (Select-String -CaseSensitive '(?<=path = )(?!third_party\/(premake-(androidndk|cmake|export-compile-commands))).+' .gitmodules).Matches.Value + git submodule update --init --depth=1 -j $env:NUMBER_OF_PROCESSORS (Select-String -CaseSensitive '(?<=path = ).+' .gitmodules).Matches.Value - name: Build - run: python xenia-build.py build --config=Release --target=src\xenia-app + run: python xenia-build.py build --config=Release --target=xenia-app - name: Prepare artifacts id: prepare_artifacts run: | - foreach ($file in 'build\bin\Windows\Release\xenia_canary.exe','build\bin\Windows\Release\xenia_canary.pdb') { + foreach ($file in 'build\bin\Windows\Release\xenia_canary.exe') { if ((get-item $file).Length -le 100000) { echo "::error::$file is too small." } } - robocopy . build\bin\Windows\Release LICENSE /r:0 /w:0 - robocopy build\bin\Windows\Release artifacts\xenia_canary xenia_canary.exe xenia_canary.pdb LICENSE /r:0 /w:0 + robocopy . build\bin\Windows\Release LICENSE /r:0 /w:0 + robocopy build\bin\Windows\Release artifacts\xenia_canary xenia_canary.exe LICENSE /r:0 /w:0 If ($LastExitCode -le 7) { echo "LastExitCode = $LastExitCode";$LastExitCode = 0 } - name: Upload xenia canary artifacts if: steps.prepare_artifacts.outcome == 'success' diff --git a/.gitmodules b/.gitmodules index f2de9aba9..0ee64ac52 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,16 +7,10 @@ [submodule "third_party/catch"] path = third_party/catch url = https://github.com/catchorg/Catch2.git -[submodule "third_party/premake-core"] - path = third_party/premake-core - url = https://github.com/premake/premake-core.git [submodule "third_party/snappy"] path = third_party/snappy url = https://github.com/google/snappy.git ignore = dirty -[submodule "third_party/premake-export-compile-commands"] - path = third_party/premake-export-compile-commands - url = https://github.com/xenia-project/premake-export-compile-commands.git [submodule "third_party/discord-rpc"] path = third_party/discord-rpc url = https://github.com/discordapp/discord-rpc.git @@ -50,9 +44,6 @@ [submodule "third_party/DirectXShaderCompiler"] path = third_party/DirectXShaderCompiler url = https://github.com/microsoft/DirectXShaderCompiler.git -[submodule "third_party/premake-cmake"] - path = third_party/premake-cmake - url = https://github.com/JoelLinn/premake-cmake.git [submodule "third_party/date"] path = third_party/date url = https://github.com/HowardHinnant/date.git @@ -63,9 +54,6 @@ path = third_party/FFmpeg url = https://github.com/has207/FFmpeg.git branch = xmaframes -[submodule "third_party/premake-androidndk"] - path = third_party/premake-androidndk - url = https://github.com/Triang3l/premake-androidndk.git [submodule "third_party/FidelityFX-CAS"] path = third_party/FidelityFX-CAS url = https://github.com/GPUOpen-Effects/FidelityFX-CAS.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..193f6d896 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,231 @@ +cmake_minimum_required(VERSION 3.20) +project(xenia LANGUAGES C CXX) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_C_STANDARD 17) +set(CMAKE_C_STANDARD_REQUIRED ON) + +# Options +option(XENIA_BUILD_TESTS "Build test suites" OFF) +option(XENIA_BUILD_MISC "Build misc subprojects (trace viewers, shader compiler, vfs-dump, demos)" OFF) + +# Multi-config generators (VS, Ninja Multi-Config) +get_property(_is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_is_multi_config) + set(CMAKE_CONFIGURATION_TYPES "Checked;Debug;Release" CACHE STRING "" FORCE) +endif() + +# Custom Checked configuration (ASan + debug runtime) +set(CMAKE_C_FLAGS_CHECKED "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_CHECKED "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "" FORCE) +set(CMAKE_EXE_LINKER_FLAGS_CHECKED "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "" FORCE) +set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING "" FORCE) +set(CMAKE_STATIC_LINKER_FLAGS_CHECKED "${CMAKE_STATIC_LINKER_FLAGS_DEBUG}" CACHE STRING "" FORCE) + +# Platform name for output paths +if(WIN32) + set(XE_PLATFORM_NAME "Windows") +else() + set(XE_PLATFORM_NAME "Linux") +endif() + +# Output directories +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${XE_PLATFORM_NAME}") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${XE_PLATFORM_NAME}") +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/obj/${XE_PLATFORM_NAME}") + +# Create scratch/ if needed +file(MAKE_DIRECTORY "${PROJECT_SOURCE_DIR}/scratch") + +# Include helpers +include(cmake/XeniaHelpers.cmake) + +# Global include directories (these apply to all targets via directory scope) +include_directories( + ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/third_party +) + +# Global defines +add_compile_definitions( + VULKAN_HPP_NO_TO_STRING + IMGUI_DISABLE_DEFAULT_FONT + IMGUI_USE_STB_SPRINTF + USE_CPP17 # Tabulate +) + +# Static library define +add_compile_definitions(_LIB) + +# ============================================================================== +# Platform-specific global settings +# ============================================================================== + +if(MSVC) + # Global MSVC settings + add_compile_options( + /utf-8 # Build correctly on systems with non-Latin codepages + /wd4201 # Nameless struct/unions are ok + /arch:AVX # AVX vector extensions + /MP # Multi-processor compilation + ) + add_compile_definitions( + _CRT_NONSTDC_NO_DEPRECATE + _CRT_SECURE_NO_WARNINGS + WIN32 + _WIN64=1 + _AMD64=1 + UNICODE + _UNICODE + IMGUI_DISABLE_OBSOLETE_FUNCTIONS + ) + add_link_options( + /ignore:4006 # Ignores complaints about empty obj files + /ignore:4221 + ) + # Global Windows system libraries + link_libraries( + ntdll wsock32 ws2_32 xinput comctl32 shcore shlwapi dxguid bcrypt + ) + # Windows manifest for executables is handled per-target + + # --- Per-configuration MSVC flags --- + # Checked + string(APPEND CMAKE_C_FLAGS_CHECKED " /RTCsu /fsanitize=address") + string(APPEND CMAKE_CXX_FLAGS_CHECKED " /RTCsu /fsanitize=address") + string(APPEND CMAKE_EXE_LINKER_FLAGS_CHECKED " /INCREMENTAL:NO") + add_compile_definitions($<$:DEBUG>) + + # Debug: use release runtime (/MD) for heap performance, matching premake + string(REPLACE "/MDd" "/MD" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") + string(REPLACE "/MDd" "/MD" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + add_compile_definitions($<$:DEBUG>) + add_compile_definitions($<$:_NO_DEBUG_HEAP=1>) + + # Checked or Debug: full symbols + string(APPEND CMAKE_C_FLAGS_CHECKED " /Zi") + string(APPEND CMAKE_CXX_FLAGS_CHECKED " /Zi") + # Debug already has /Zi by default + + # Release + add_compile_definitions($<$:NDEBUG>) + add_compile_definitions($<$:_NO_DEBUG_HEAP=1>) + add_compile_options($<$:/Gw>) + add_compile_options($<$:/GS->) # NoBufferSecurityCheck + # Replace /Ob2 with /Ob3 in CMake's default Release flags + string(REPLACE "/Ob2" "/Ob3" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + string(REPLACE "/Ob2" "/Ob3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + # Link-time optimization (whole program optimization) + add_compile_options($<$:/GL>) + add_link_options($<$:/LTCG>) + set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG") + +else() + # GCC/Clang (Linux) + add_compile_options(-mavx) + + # Disable specific warnings for C++ + add_compile_options( + $<$:-Wno-switch> + $<$:-Wno-attributes> + ) + + # Clang-specific C++ warnings + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options( + $<$:-Wno-deprecated-register> + $<$:-Wno-deprecated-volatile> + $<$:-Wno-deprecated-enum-enum-conversion> + ) + + # Check Clang version for newer warnings + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 20) + add_compile_options( + $<$:-Wno-deprecated-literal-operator> + $<$:-Wno-nontrivial-memcall> + ) + endif() + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 21) + add_compile_options( + $<$:-Wno-character-conversion> + ) + endif() + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # GCC-specific + add_compile_options( + $<$:-Wno-unused-result> + $<$:-Wno-volatile> + $<$:-Wno-template-id-cdtor> + $<$:-Wno-return-type> + $<$:-Wno-deprecated> + -fpermissive # HACK + ) + add_link_options(-fpermissive) + # GCC: do not use -Werror + endif() + + # C-specific warnings + add_compile_options( + $<$:-Wno-implicit-function-declaration> + ) + + # GTK3 via pkg-config + find_package(PkgConfig REQUIRED) + pkg_check_modules(GTK3 REQUIRED gtk+-x11-3.0) + include_directories(${GTK3_INCLUDE_DIRS}) + link_directories(${GTK3_LIBRARY_DIRS}) + add_compile_options(${GTK3_CFLAGS_OTHER}) + + # Global Linux libraries + link_libraries(stdc++fs dl lz4 pthread rt) + + # Link groups for executables (resolves circular deps) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--start-group") + set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -Wl,--end-group") + + # --- Per-configuration Linux flags --- + # Checked + string(APPEND CMAKE_C_FLAGS_CHECKED " -fsanitize=address") + string(APPEND CMAKE_CXX_FLAGS_CHECKED " -fsanitize=address") + string(APPEND CMAKE_EXE_LINKER_FLAGS_CHECKED " -fsanitize=address") + add_compile_definitions( + $<$:DEBUG> + $<$:_GLIBCXX_DEBUG> + ) + + # Debug + add_compile_definitions( + $<$:DEBUG> + $<$:_NO_DEBUG_HEAP=1> + $<$:_GLIBCXX_DEBUG> + ) + + # Release + add_compile_definitions( + $<$:NDEBUG> + $<$:_NO_DEBUG_HEAP=1> + ) + add_compile_options($<$:-O3>) + # Link-time optimization (use lld to avoid system linker LTO plugin version mismatch) + add_compile_options($<$:-flto=thin>) + add_link_options($<$:-flto=thin>) + add_link_options($<$:-fuse-ld=lld>) + # No symbols in release on non-Windows + string(REPLACE "-g" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + string(REPLACE "-g" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") +endif() + +# ============================================================================== +# Subdirectories +# ============================================================================== + +# Third-party libraries first (no -Werror applied to these) +add_subdirectory(third_party) + +# Xenia source modules (xe_target_defaults applies -Werror) +add_subdirectory(src/xenia) + +# Set default startup project for Visual Studio +set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT xenia-app) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..090e39003 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,55 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 20, + "patch": 0 + }, + "configurePresets": [ + { + "name": "default", + "displayName": "Ninja Multi-Config", + "generator": "Ninja Multi-Config", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "vs", + "displayName": "Visual Studio 2022", + "generator": "Visual Studio 17 2022", + "architecture": "x64", + "binaryDir": "${sourceDir}/build" + } + ], + "buildPresets": [ + { + "name": "debug", + "configurePreset": "default", + "configuration": "Debug" + }, + { + "name": "release", + "configurePreset": "default", + "configuration": "Release" + }, + { + "name": "checked", + "configurePreset": "default", + "configuration": "Checked" + }, + { + "name": "vs-debug", + "configurePreset": "vs", + "configuration": "Debug" + }, + { + "name": "vs-release", + "configurePreset": "vs", + "configuration": "Release" + }, + { + "name": "vs-checked", + "configurePreset": "vs", + "configuration": "Checked" + } + ] +} diff --git a/cmake/XeniaHelpers.cmake b/cmake/XeniaHelpers.cmake new file mode 100644 index 000000000..4390ee68b --- /dev/null +++ b/cmake/XeniaHelpers.cmake @@ -0,0 +1,160 @@ +# XeniaHelpers.cmake - Helper functions for the Xenia build system. +# Replaces tools/build/scripts/*.lua + +include(CMakeParseArguments) + +# Platform suffix lists for file filtering +set(XE_PLATFORM_SUFFIXES + _win _linux _posix _gnulinux _x11 _gtk _android _mac +) + +# xe_platform_sources(target base_path [RECURSIVE]) +# +# Adds platform-filtered source files to a target. +# Globs *.h, *.cc, *.cpp, *.c, *.inc from base_path. +# Excludes all platform suffixes, then adds back the ones matching the current platform. +# Always excludes *_main.cc and *_test.cc. +function(xe_platform_sources target base_path) + set(options RECURSIVE) + cmake_parse_arguments(ARG "${options}" "" "" ${ARGN}) + + if(ARG_RECURSIVE) + set(glob_mode GLOB_RECURSE) + set(pattern "**") + else() + set(glob_mode GLOB) + set(pattern "*") + endif() + + # Glob all source files + file(${glob_mode} _all_sources "${base_path}/*.h" + "${base_path}/*.cc" + "${base_path}/*.cpp" + "${base_path}/*.c" + "${base_path}/*.inc" + ) + + # Build exclude patterns + set(_excluded) + foreach(src ${_all_sources}) + get_filename_component(_name_we ${src} NAME_WE) + # Exclude *_main.cc, *_test.cc, and *_demo.cc + if(_name_we MATCHES "_main$" OR _name_we MATCHES "_test$" OR _name_we MATCHES "_demo$") + list(APPEND _excluded ${src}) + continue() + endif() + # Exclude all platform suffixes + foreach(suffix ${XE_PLATFORM_SUFFIXES}) + if(_name_we MATCHES "${suffix}$") + list(APPEND _excluded ${src}) + break() + endif() + endforeach() + endforeach() + + # Remove excluded files + set(_sources ${_all_sources}) + if(_excluded) + list(REMOVE_ITEM _sources ${_excluded}) + endif() + + # Add back platform-specific files + if(WIN32) + file(${glob_mode} _plat_sources "${base_path}/*_win.h" + "${base_path}/*_win.cc" + ) + elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + file(${glob_mode} _plat_sources "${base_path}/*_posix.h" + "${base_path}/*_posix.cc" + "${base_path}/*_linux.h" + "${base_path}/*_linux.cc" + "${base_path}/*_gnulinux.h" + "${base_path}/*_gnulinux.cc" + "${base_path}/*_x11.h" + "${base_path}/*_x11.cc" + "${base_path}/*_gtk.h" + "${base_path}/*_gtk.cc" + ) + endif() + + list(APPEND _sources ${_plat_sources}) + target_sources(${target} PRIVATE ${_sources}) +endfunction() + +# xe_target_defaults(target) +# +# Applies xenia-specific compile settings to a target: +# - Fatal warnings (-Werror / /WX) +# - Common include directories +function(xe_target_defaults target) + target_include_directories(${target} PRIVATE + ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/third_party + ) + if(MSVC) + target_compile_options(${target} PRIVATE /WX) + elseif(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # GCC is too noisy for -Werror; only apply to Clang + target_compile_options(${target} PRIVATE -Werror) + endif() +endfunction() + +# xe_force_c(files...) +# +# Forces the given source files to compile as C. +function(xe_force_c) + set_source_files_properties(${ARGN} PROPERTIES LANGUAGE C) +endfunction() + +# xe_force_cxx(files...) +# +# Forces the given source files to compile as C++. +function(xe_force_cxx) + set_source_files_properties(${ARGN} PROPERTIES LANGUAGE CXX) +endfunction() + +# xe_test_suite(name base_path LINKS lib1 lib2 ...) +# +# Creates a Catch2 test executable from *_test.cc files in base_path. +function(xe_test_suite name base_path) + cmake_parse_arguments(ARG "" "" "LINKS" ${ARGN}) + + file(GLOB _test_sources CONFIGURE_DEPENDS "${base_path}/*_test.cc") + + if(NOT _test_sources) + return() + endif() + + add_executable(${name} + ${_test_sources} + ${PROJECT_SOURCE_DIR}/tools/build/src/test_suite_main.cc + ) + + # Add platform-specific console app main + if(WIN32) + target_sources(${name} PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/console_app_main_win.cc) + else() + target_sources(${name} PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/console_app_main_posix.cc) + endif() + + target_compile_definitions(${name} PRIVATE + "XE_TEST_SUITE_NAME=\"${name}\"" + ) + target_include_directories(${name} PRIVATE + ${PROJECT_SOURCE_DIR}/tools/build + ${PROJECT_SOURCE_DIR}/tools/build/src + ${PROJECT_SOURCE_DIR}/tools/build/third_party/catch/include + ) + if(ARG_LINKS) + target_link_libraries(${name} PRIVATE ${ARG_LINKS}) + endif() + xe_target_defaults(${name}) + + if(MSVC) + # Disable Edit and Continue - breaks Catch2 __LINE__ usage + target_compile_options(${name} PRIVATE /Zi) + endif() +endfunction() diff --git a/premake5.lua b/premake5.lua deleted file mode 100644 index 0062425fb..000000000 --- a/premake5.lua +++ /dev/null @@ -1,384 +0,0 @@ -include("tools/build") -if _ACTION == "export-compile-commands" then - require("third_party/premake-export-compile-commands/export-compile-commands") -end -if os.istarget("android") then - require("third_party/premake-androidndk/androidndk") -end -if _ACTION == "cmake" then - require("third_party/premake-cmake/cmake") -end - -location(build_root) -targetdir(build_bin) -objdir(build_obj) - --- Define variables for enabling specific submodules --- Todo: Add changing from xb command -enableTests = false -enableMiscSubprojects = false - --- Define an ARCH variable --- Only use this to enable architecture-specific functionality. -if os.istarget("linux") then - ARCH = os.outputof("uname -p") -else - ARCH = "unknown" -end - -includedirs({ - ".", - "src", - "third_party", -}) - -defines({ - "VULKAN_HPP_NO_TO_STRING", - "IMGUI_DISABLE_DEFAULT_FONT", - --"IMGUI_USE_WCHAR32", - "IMGUI_USE_STB_SPRINTF", - --"IMGUI_ENABLE_FREETYPE", - "USE_CPP17", -- Tabulate -}) - -cdialect("C17") -cppdialect("C++20") -symbols("On") -fatalwarnings("All") - --- TODO(DrChat): Find a way to disable this on other architectures. -if ARCH ~= "ppc64" then - filter("architecture:x86_64") - vectorextensions("AVX") - filter({}) -end - -filter("kind:StaticLib") - defines({ - "_LIB", - }) - -filter("configurations:Checked") - runtime("Debug") - sanitize("Address") - flags("NoIncrementalLink") - editandcontinue("Off") - staticruntime("Off") - optimize("Off") - removedefines({ - "IMGUI_USE_STB_SPRINTF", - }) - defines({ - "DEBUG", - }) - -filter({"configurations:Checked", "platforms:Windows"}) -- "toolset:msc" - buildoptions({ - "/RTCsu", -- Full Run-Time Checks. - }) - -filter({"configurations:Checked or Debug", "platforms:Linux"}) - defines({ - "_GLIBCXX_DEBUG", -- libstdc++ debug mode - }) - -filter({"configurations:Checked or Debug", "platforms:Windows"}) -- "toolset:msc" - symbols("Full") - -filter("configurations:Debug") - runtime("Release") - optimize("Off") - defines({ - "DEBUG", - "_NO_DEBUG_HEAP=1", - }) - -filter("configurations:Release") - runtime("Release") - defines({ - "NDEBUG", - "_NO_DEBUG_HEAP=1", - }) - optimize("Speed") - flags({ - "NoBufferSecurityCheck" - }) - inlining("Auto") - editandcontinue("Off") - -- Not using floatingpoint("Fast") - NaN checks are used in some places - -- (though rarely), overall preferable to avoid any functional differences - -- between debug and release builds, and to have calculations involved in GPU - -- (especially anything that may affect vertex position invariance) and CPU - -- (such as constant propagation) emulation as predictable as possible, - -- including handling of specials since games make assumptions about them. - -filter({"configurations:Release", "platforms:not Windows"}) - symbols("Off") - -filter({"configurations:Release", "platforms:Windows"}) -- "toolset:msc" - linktimeoptimization("On") - buildoptions({ - "/Gw", - "/Ob3", --- "/Qpar", -- TODO: Test this. - }) - -filter("platforms:Linux") - system("linux") - toolset("clang") - --buildoptions({ - -- "-mlzcnt", -- (don't) Assume lzcnt is supported. - --}) - pkg_config.all("gtk+-x11-3.0") - links({ - "stdc++fs", - "dl", - "lz4", - "pthread", - "rt", - }) - -filter({"platforms:Linux", "kind:*App"}) - linkgroups("On") - -filter({"language:C++", "toolset:clang or gcc"}) -- "platforms:Linux" - disablewarnings({ - "switch", - "attributes", - }) - -filter({"language:C++", "toolset:gcc"}) -- "platforms:Linux" - disablewarnings({ - "unused-result", - "volatile", - "template-id-cdtor", - "return-type", - "deprecated", - }) - -filter("toolset:gcc") -- "platforms:Linux" - removefatalwarnings("All") -- HACK - if ARCH == "ppc64" then - buildoptions({ - "-m32", - "-mpowerpc64" - }) - linkoptions({ - "-m32", - "-mpowerpc64" - }) - else - buildoptions({ - "-fpermissive", -- HACK - }) - linkoptions({ - "-fpermissive", -- HACK - }) - end - -filter({"language:C++", "toolset:clang"}) -- "platforms:Linux" - disablewarnings({ - "deprecated-register", - "deprecated-volatile", - "deprecated-enum-enum-conversion", - }) -CLANG_BIN = os.getenv("CC") or _OPTIONS["cc"] or "clang" -if os.istarget("linux") and string.contains(CLANG_BIN, "clang") then - CLANG_VER = tonumber(string.match(os.outputof(CLANG_BIN.." --version"), "version (%d%d)")) - if CLANG_VER >= 20 then - filter({"language:C++", "toolset:clang"}) -- "platforms:Linux" - disablewarnings({ - "deprecated-literal-operator", -- Needed only for tabulate - "nontrivial-memcall", - }) - end - if CLANG_VER >= 21 then - filter({"language:C++", "toolset:clang"}) -- "platforms:Linux" - disablewarnings({ - "character-conversion", -- Needed for utfcpp third-party library - }) - end -end - -filter({"language:C", "toolset:clang or gcc"}) -- "platforms:Linux" - disablewarnings({ - "implicit-function-declaration", - }) - -if os.istarget("android") then - filter("platforms:Android-*") - system("android") - systemversion("24") - cppstl("c++") - staticruntime("On") - -- Hidden visibility is needed to prevent dynamic relocations in FFmpeg - -- AArch64 Neon libavcodec assembly with PIC (accesses extern lookup tables - -- using `adrp` and `add`, without the Global Object Table, expecting that all - -- FFmpeg symbols that aren't a part of the FFmpeg API are hidden by FFmpeg's - -- original build system) by resolving those relocations at link time instead. - visibility("Hidden") - links({ - "android", - "dl", - "log", - }) -end - -filter("platforms:Windows") - system("windows") - toolset("msc") - buildoptions({ - "/utf-8", -- 'build correctly on systems with non-Latin codepages'. - -- Disable warnings - "/wd4201", -- Nameless struct/unions are ok. - }) - flags({ - "MultiProcessorCompile", -- Multiprocessor compilation. - "NoMinimalRebuild", -- Required for /MP above. - }) - - defines({ - "_CRT_NONSTDC_NO_DEPRECATE", - "_CRT_SECURE_NO_WARNINGS", - "WIN32", - "_WIN64=1", - "_AMD64=1", - "IMGUI_DISABLE_OBSOLETE_FUNCTIONS", - }) - linkoptions({ - "/ignore:4006", -- Ignores complaints about empty obj files. - "/ignore:4221", - }) - links({ - "ntdll", - "wsock32", - "ws2_32", - "xinput", - "comctl32", - "shcore", - "shlwapi", - "dxguid", - "bcrypt", - }) - --- Embed the manifest for things like dependencies and DPI awareness. -filter({"platforms:Windows", "kind:ConsoleApp or WindowedApp"}) - files({ - "src/xenia/base/app_win32.manifest" - }) - --- Create scratch/ path -if not os.isdir("scratch") then - os.mkdir("scratch") -end - -workspace("xenia") - uuid("931ef4b0-6170-4f7a-aaf2-0fece7632747") - startproject("xenia-app") - if os.istarget("android") then - platforms({"Android-ARM64", "Android-x86_64"}) - filter("platforms:Android-ARM64") - architecture("ARM64") - filter("platforms:Android-x86_64") - architecture("x86_64") - filter({}) - else - architecture("x86_64") - if os.istarget("linux") then - platforms({"Linux"}) - elseif os.istarget("macosx") then - platforms({"Mac"}) - xcodebuildsettings({ - ["ARCHS"] = "x86_64" - }) - elseif os.istarget("windows") then - platforms({"Windows"}) - -- 10.0.15063.0: ID3D12GraphicsCommandList1::SetSamplePositions. - -- 10.0.19041.0: D3D12_HEAP_FLAG_CREATE_NOT_ZEROED. - -- 10.0.22000.0: DWMWA_WINDOW_CORNER_PREFERENCE. - systemversion("latest") - filter({}) - end - end - configurations({"Checked", "Debug", "Release"}) - - include("third_party/aes_128.lua") - include("third_party/capstone.lua") - include("third_party/dxbc.lua") - include("third_party/discord-rpc.lua") - include("third_party/cxxopts.lua") - include("third_party/tomlplusplus.lua") - include("third_party/ffmpeg-xenia/premake5.lua") - include("third_party/fmt.lua") - include("third_party/glslang-spirv.lua") - include("third_party/imgui.lua") - include("third_party/mspack.lua") - include("third_party/snappy.lua") - include("third_party/xxhash.lua") - include("third_party/zarchive.lua") - include("third_party/zstd.lua") - include("third_party/zlib-ng.lua") - include("third_party/pugixml.lua") - - if os.istarget("windows") then - include("third_party/libusb.lua") - end - - if not os.istarget("android") then - -- SDL2 requires sdl2-config, and as of November 2020 isn't high-quality on - -- Android yet, most importantly in game controllers - the keycode and axis - -- enums are being ruined during conversion to SDL2 enums resulting in only - -- one controller (Nvidia Shield) being supported, digital triggers are also - -- not supported; lifecycle management (especially surface loss) is also - -- complicated. - include("third_party/SDL2.lua") - end - - -- Disable treating warnings as fatal errors for all third party projects, as - -- well as other things relevant only to Xenia itself. - for _, prj in ipairs(premake.api.scope.current.solution.projects) do - project(prj.name) - removefiles({ - "src/xenia/base/app_win32.manifest" - }) - removefatalwarnings("All") - end - - include("src/xenia") - include("src/xenia/app") - include("src/xenia/app/discord") - include("src/xenia/apu") - include("src/xenia/apu/nop") - include("src/xenia/base") - include("src/xenia/cpu") - include("src/xenia/cpu/backend/x64") - include("src/xenia/debug/ui") - include("src/xenia/gpu") - include("src/xenia/gpu/null") - include("src/xenia/gpu/vulkan") - include("src/xenia/hid") - include("src/xenia/hid/nop") - include("src/xenia/hid/skylander") - include("src/xenia/kernel") - include("src/xenia/patcher") - include("src/xenia/ui") - include("src/xenia/ui/vulkan") - include("src/xenia/vfs") - - if not os.istarget("android") then - include("src/xenia/apu/sdl") - include("src/xenia/helper/sdl") - include("src/xenia/hid/sdl") - end - - if os.istarget("linux") then - include("src/xenia/apu/alsa") - end - - if os.istarget("windows") then - include("src/xenia/apu/xaudio2") - include("src/xenia/gpu/d3d12") - include("src/xenia/hid/winkey") - include("src/xenia/hid/xinput") - include("src/xenia/ui/d3d12") - end diff --git a/src/xenia/CMakeLists.txt b/src/xenia/CMakeLists.txt new file mode 100644 index 000000000..ad6c41a2f --- /dev/null +++ b/src/xenia/CMakeLists.txt @@ -0,0 +1,49 @@ +# src/xenia/CMakeLists.txt - Master file for all xenia modules. + +# xenia-core (this directory's own sources) +add_library(xenia-core STATIC) +file(GLOB _core_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.h" + "${CMAKE_CURRENT_SOURCE_DIR}/*.cc" +) +target_sources(xenia-core PRIVATE ${_core_sources}) +target_link_libraries(xenia-core PUBLIC fmt xenia-base) +xe_target_defaults(xenia-core) + +# All subdirectories +add_subdirectory(base) +add_subdirectory(cpu) +add_subdirectory(cpu/backend/x64) +add_subdirectory(apu) +add_subdirectory(apu/nop) +add_subdirectory(gpu) +add_subdirectory(gpu/null) +add_subdirectory(gpu/vulkan) +add_subdirectory(hid) +add_subdirectory(hid/nop) +add_subdirectory(hid/skylander) +add_subdirectory(kernel) +add_subdirectory(patcher) +add_subdirectory(ui) +add_subdirectory(ui/vulkan) +add_subdirectory(vfs) +add_subdirectory(debug/ui) +add_subdirectory(app/discord) +add_subdirectory(app) + +# SDL-based modules (not Android) +add_subdirectory(apu/sdl) +add_subdirectory(helper/sdl) +add_subdirectory(hid/sdl) + +# Platform-conditional modules +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + add_subdirectory(apu/alsa) +endif() + +if(WIN32) + add_subdirectory(apu/xaudio2) + add_subdirectory(gpu/d3d12) + add_subdirectory(hid/winkey) + add_subdirectory(hid/xinput) + add_subdirectory(ui/d3d12) +endif() diff --git a/src/xenia/app/CMakeLists.txt b/src/xenia/app/CMakeLists.txt new file mode 100644 index 000000000..291a2a113 --- /dev/null +++ b/src/xenia/app/CMakeLists.txt @@ -0,0 +1,115 @@ +# src/xenia/app/CMakeLists.txt - Main xenia_canary executable. + +if(WIN32) + add_executable(xenia-app WIN32) +else() + add_executable(xenia-app) +endif() + +set_target_properties(xenia-app PROPERTIES OUTPUT_NAME "xenia_canary") + +# Main source +target_sources(xenia-app PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/xenia_main.cc +) + +# Other app sources (emulator_window, profile_dialogs, etc.) +xe_platform_sources(xenia-app ${CMAKE_CURRENT_SOURCE_DIR}) + +# Platform-specific entry points +if(WIN32) + target_sources(xenia-app PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/main_init_win.cc + ${PROJECT_SOURCE_DIR}/src/xenia/ui/windowed_app_main_win.cc + ${CMAKE_CURRENT_SOURCE_DIR}/main_resources.rc + ${PROJECT_SOURCE_DIR}/src/xenia/base/app_win32.manifest + ) + # main_init_win.cc needs SSE2 only (not AVX) + set_source_files_properties( + ${PROJECT_SOURCE_DIR}/src/xenia/base/main_init_win.cc + PROPERTIES COMPILE_OPTIONS "/arch:SSE2" + ) +else() + target_sources(xenia-app PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/main_init_posix.cc + ${PROJECT_SOURCE_DIR}/src/xenia/ui/windowed_app_main_posix.cc + ) + if(NOT MSVC) + set_source_files_properties( + ${PROJECT_SOURCE_DIR}/src/xenia/base/main_init_posix.cc + PROPERTIES COMPILE_OPTIONS "-msse2;-mno-avx" + ) + endif() +endif() + +target_compile_definitions(xenia-app PRIVATE + XBYAK_NO_OP_NAMES + XBYAK_ENABLE_OMITTED_OPERAND +) + +# Core libraries (all platforms) +target_link_libraries(xenia-app PRIVATE + xenia-apu + xenia-apu-nop + xenia-base + xenia-core + xenia-cpu + xenia-gpu + xenia-gpu-null + xenia-gpu-vulkan + xenia-hid + xenia-hid-nop + xenia-kernel + xenia-patcher + xenia-ui + xenia-ui-vulkan + xenia-vfs + # Third-party + aes_128 + capstone + fmt + dxbc + discord-rpc + glslang-spirv + imgui + libavcodec + libavutil + mspack + snappy + xxhash +) + +# Non-Android specific (always true for Windows/Linux) +target_link_libraries(xenia-app PRIVATE + xenia-app-discord + xenia-apu-sdl + xenia-debug-ui + xenia-helper-sdl + xenia-hid-sdl +) + +# x64 backend +if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + target_link_libraries(xenia-app PRIVATE xenia-cpu-backend-x64) +endif() + +# Platform-specific libraries +if(WIN32) + target_link_libraries(xenia-app PRIVATE + xenia-apu-xaudio2 + xenia-gpu-d3d12 + xenia-hid-winkey + xenia-hid-xinput + xenia-ui-d3d12 + ) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(xenia-app PRIVATE + xenia-apu-alsa + X11 + xcb + X11-xcb + SDL2 + ) +endif() + +xe_target_defaults(xenia-app) diff --git a/src/xenia/app/discord/CMakeLists.txt b/src/xenia/app/discord/CMakeLists.txt new file mode 100644 index 000000000..5f7adb86b --- /dev/null +++ b/src/xenia/app/discord/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(xenia-app-discord STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/discord_presence.cc + ${CMAKE_CURRENT_SOURCE_DIR}/discord_presence.h +) +target_include_directories(xenia-app-discord PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/discord-rpc/src +) +target_link_libraries(xenia-app-discord PUBLIC discord-rpc) +xe_target_defaults(xenia-app-discord) diff --git a/src/xenia/app/discord/premake5.lua b/src/xenia/app/discord/premake5.lua deleted file mode 100644 index 13e82b5f0..000000000 --- a/src/xenia/app/discord/premake5.lua +++ /dev/null @@ -1,18 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-app-discord") - uuid("d14c0885-22d2-40de-ab28-7b234ef2b949") - kind("StaticLib") - language("C++") - links({ - "discord-rpc" - }) - includedirs({ - project_root.."/third_party/discord-rpc/src" - }) - files({ - "discord_presence.cc", - "discord_presence.h" - }) diff --git a/src/xenia/app/premake5.lua b/src/xenia/app/premake5.lua deleted file mode 100644 index 2b75a4dd9..000000000 --- a/src/xenia/app/premake5.lua +++ /dev/null @@ -1,133 +0,0 @@ -project_root = "../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-app") - uuid("d7e98620-d007-4ad8-9dbd-b47c8853a17f") - language("C++") - links({ - "xenia-apu", - "xenia-apu-nop", - "xenia-base", - "xenia-core", - "xenia-cpu", - "xenia-gpu", - "xenia-gpu-null", - "xenia-gpu-vulkan", - "xenia-hid", - "xenia-hid-nop", - "xenia-kernel", - "xenia-patcher", - "xenia-ui", - "xenia-ui-vulkan", - "xenia-vfs", - }) - links({ - "aes_128", - "capstone", - "fmt", - "dxbc", - "discord-rpc", - "glslang-spirv", - "imgui", - "libavcodec", - "libavutil", - "mspack", - "snappy", - "xxhash", - }) - defines({ - "XBYAK_NO_OP_NAMES", - "XBYAK_ENABLE_OMITTED_OPERAND", - }) - local_platform_files() - files({ - "../base/main_init_"..platform_suffix..".cc", - "../ui/windowed_app_main_"..platform_suffix..".cc", - }) - - resincludedirs({ - project_root, - }) - - filter(SINGLE_LIBRARY_FILTER) - -- Unified library containing all apps as StaticLibs, not just the main - -- emulator windowed app. - kind("SharedLib") - if enableMiscSubprojects then - links({ - "xenia-gpu-vulkan-trace-viewer", - "xenia-hid-demo", - "xenia-ui-window-vulkan-demo", - }) - end - filter(NOT_SINGLE_LIBRARY_FILTER) - kind("WindowedApp") - - -- `targetname` is broken if building from Gradle, works only for toggling the - -- `lib` prefix, as Gradle uses LOCAL_MODULE_FILENAME, not a derivative of - -- LOCAL_MODULE, to specify the targets to build when executing ndk-build. - filter("platforms:not Android-*") - targetname("xenia_canary") - - filter("architecture:x86_64") - links({ - "xenia-cpu-backend-x64", - }) - - -- TODO(Triang3l): The emulator itself on Android. - filter("platforms:not Android-*") - files({ - "xenia_main.cc", - }) - - filter("platforms:Windows") - files({ - "main_resources.rc", - }) - - filter({"architecture:x86_64", "files:../base/main_init_"..platform_suffix..".cc"}) - vectorextensions("SSE2") -- Disable AVX for main_init_win.cc so our AVX check doesn't use AVX instructions. - - filter("platforms:not Android-*") - links({ - "xenia-app-discord", - "xenia-apu-sdl", - -- TODO(Triang3l): CPU debugger on Android. - "xenia-debug-ui", - "xenia-helper-sdl", - "xenia-hid-sdl", - }) - - filter("platforms:Linux") - links({ - "xenia-apu-alsa", - "X11", - "xcb", - "X11-xcb", - "SDL2", - }) - - filter("platforms:Windows") - links({ - "xenia-apu-xaudio2", - "xenia-gpu-d3d12", - "xenia-hid-winkey", - "xenia-hid-xinput", - "xenia-ui-d3d12", - }) - - if enableMiscSubprojects then - filter({"platforms:Windows", SINGLE_LIBRARY_FILTER}) - links({ - "xenia-gpu-d3d12-trace-viewer", - "xenia-ui-window-d3d12-demo", - }) - end - - filter("platforms:Windows") - -- Only create the .user file if it doesn't already exist. - local user_file = project_root.."/build/xenia-app.vcxproj.user" - if not os.isfile(user_file) then - debugdir(project_root) - end diff --git a/src/xenia/apu/CMakeLists.txt b/src/xenia/apu/CMakeLists.txt new file mode 100644 index 000000000..77eda88b9 --- /dev/null +++ b/src/xenia/apu/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(xenia-apu STATIC) +xe_platform_sources(xenia-apu ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(xenia-apu PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/FFmpeg + ${PROJECT_SOURCE_DIR}/third_party/ffmpeg-xenia +) +target_link_libraries(xenia-apu PUBLIC libavcodec libavutil libavformat xenia-base) +xe_target_defaults(xenia-apu) diff --git a/src/xenia/apu/alsa/CMakeLists.txt b/src/xenia/apu/alsa/CMakeLists.txt new file mode 100644 index 000000000..ee4662ed8 --- /dev/null +++ b/src/xenia/apu/alsa/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(xenia-apu-alsa STATIC) +xe_platform_sources(xenia-apu-alsa ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(xenia-apu-alsa PUBLIC xenia-apu xenia-base) +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(xenia-apu-alsa PRIVATE asound pthread) +endif() +xe_target_defaults(xenia-apu-alsa) diff --git a/src/xenia/apu/alsa/premake5.lua b/src/xenia/apu/alsa/premake5.lua deleted file mode 100644 index cad0cdc61..000000000 --- a/src/xenia/apu/alsa/premake5.lua +++ /dev/null @@ -1,18 +0,0 @@ -group("src") -project("xenia-apu-alsa") - uuid("8c2e1340-f847-4f9a-8b2e-5d8c1b7a8f9e") - kind("StaticLib") - language("C++") - links({ - "xenia-apu", - "xenia-base", - }) - defines({ - }) - local_platform_files() - - filter("platforms:Linux") - links({ - "asound", - "pthread", - }) diff --git a/src/xenia/apu/nop/CMakeLists.txt b/src/xenia/apu/nop/CMakeLists.txt new file mode 100644 index 000000000..febc15c28 --- /dev/null +++ b/src/xenia/apu/nop/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(xenia-apu-nop STATIC) +xe_platform_sources(xenia-apu-nop ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(xenia-apu-nop PUBLIC xenia-base xenia-apu) +xe_target_defaults(xenia-apu-nop) diff --git a/src/xenia/apu/nop/premake5.lua b/src/xenia/apu/nop/premake5.lua deleted file mode 100644 index 2b5435229..000000000 --- a/src/xenia/apu/nop/premake5.lua +++ /dev/null @@ -1,13 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-apu-nop") - uuid("f37dbf3a-d200-4cc0-83f0-f801b1bdd862") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - "xenia-apu", - }) - local_platform_files() diff --git a/src/xenia/apu/premake5.lua b/src/xenia/apu/premake5.lua deleted file mode 100644 index 0768b19be..000000000 --- a/src/xenia/apu/premake5.lua +++ /dev/null @@ -1,19 +0,0 @@ -project_root = "../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-apu") - uuid("f4df01f0-50e4-4c67-8f54-61660696cc79") - kind("StaticLib") - language("C++") - links({ - "libavcodec", - "libavutil", - "libavformat", - "xenia-base", - }) - includedirs({ - project_root.."/third_party/FFmpeg", - project_root.."/third_party/ffmpeg-xenia", - }) - local_platform_files() diff --git a/src/xenia/apu/sdl/CMakeLists.txt b/src/xenia/apu/sdl/CMakeLists.txt new file mode 100644 index 000000000..3052fde6c --- /dev/null +++ b/src/xenia/apu/sdl/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(xenia-apu-sdl STATIC) +xe_platform_sources(xenia-apu-sdl ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(xenia-apu-sdl PUBLIC xenia-apu xenia-base xenia-helper-sdl SDL2) +xe_target_defaults(xenia-apu-sdl) diff --git a/src/xenia/apu/sdl/premake5.lua b/src/xenia/apu/sdl/premake5.lua deleted file mode 100644 index 77bf00131..000000000 --- a/src/xenia/apu/sdl/premake5.lua +++ /dev/null @@ -1,16 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-apu-sdl") - uuid("153b4e8b-813a-40e6-9366-4b51abc73c45") - kind("StaticLib") - language("C++") - links({ - "xenia-apu", - "xenia-base", - "xenia-helper-sdl", - "SDL2", - }) - local_platform_files() - sdl2_include() diff --git a/src/xenia/apu/xaudio2/CMakeLists.txt b/src/xenia/apu/xaudio2/CMakeLists.txt new file mode 100644 index 000000000..c598ccc5a --- /dev/null +++ b/src/xenia/apu/xaudio2/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(xenia-apu-xaudio2 STATIC) +xe_platform_sources(xenia-apu-xaudio2 ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(xenia-apu-xaudio2 PUBLIC xenia-base xenia-apu) +xe_target_defaults(xenia-apu-xaudio2) diff --git a/src/xenia/apu/xaudio2/premake5.lua b/src/xenia/apu/xaudio2/premake5.lua deleted file mode 100644 index 8444d05b1..000000000 --- a/src/xenia/apu/xaudio2/premake5.lua +++ /dev/null @@ -1,13 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-apu-xaudio2") - uuid("7a54a497-24d9-4c0e-a013-8507a04231f9") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - "xenia-apu", - }) - local_platform_files() diff --git a/src/xenia/base/CMakeLists.txt b/src/xenia/base/CMakeLists.txt new file mode 100644 index 000000000..0443d112b --- /dev/null +++ b/src/xenia/base/CMakeLists.txt @@ -0,0 +1,17 @@ +add_library(xenia-base STATIC) +xe_platform_sources(xenia-base ${CMAKE_CURRENT_SOURCE_DIR}) +# Exclude console_app_main and main_init files +file(GLOB _base_exclude "${CMAKE_CURRENT_SOURCE_DIR}/console_app_main_*.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/main_init_*.cc" +) +get_target_property(_base_srcs xenia-base SOURCES) +if(_base_exclude AND _base_srcs) + list(REMOVE_ITEM _base_srcs ${_base_exclude}) + set_target_properties(xenia-base PROPERTIES SOURCES "${_base_srcs}") +endif() +target_link_libraries(xenia-base PUBLIC fmt) +xe_target_defaults(xenia-base) + +if(XENIA_BUILD_TESTS) + add_subdirectory(testing) +endif() diff --git a/src/xenia/base/premake5.lua b/src/xenia/base/premake5.lua deleted file mode 100644 index a4ed45935..000000000 --- a/src/xenia/base/premake5.lua +++ /dev/null @@ -1,22 +0,0 @@ -project_root = "../../.." -include(project_root.."/tools/build") - -project("xenia-base") - uuid("aeadaf22-2b20-4941-b05f-a802d5679c11") - kind("StaticLib") - language("C++") - links({ - "fmt", - }) - local_platform_files() - removefiles({ - "console_app_main_*.cc", - "main_init_*.cc", - }) - files({ - "debug_visualizers.natvis", - }) - -if enableTests then - include("testing") -end diff --git a/src/xenia/base/testing/CMakeLists.txt b/src/xenia/base/testing/CMakeLists.txt new file mode 100644 index 000000000..674b6d148 --- /dev/null +++ b/src/xenia/base/testing/CMakeLists.txt @@ -0,0 +1,3 @@ +xe_test_suite(xenia-base-tests ${CMAKE_CURRENT_SOURCE_DIR} + LINKS fmt xenia-base +) diff --git a/src/xenia/base/testing/premake5.lua b/src/xenia/base/testing/premake5.lua deleted file mode 100644 index 74d39aa65..000000000 --- a/src/xenia/base/testing/premake5.lua +++ /dev/null @@ -1,9 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -test_suite("xenia-base-tests", project_root, ".", { - links = { - "fmt", - "xenia-base", - }, -}) diff --git a/src/xenia/cpu/CMakeLists.txt b/src/xenia/cpu/CMakeLists.txt new file mode 100644 index 000000000..6637bdad9 --- /dev/null +++ b/src/xenia/cpu/CMakeLists.txt @@ -0,0 +1,17 @@ +add_library(xenia-cpu STATIC) +xe_platform_sources(xenia-cpu ${CMAKE_CURRENT_SOURCE_DIR}) +xe_platform_sources(xenia-cpu ${CMAKE_CURRENT_SOURCE_DIR}/backend) +xe_platform_sources(xenia-cpu ${CMAKE_CURRENT_SOURCE_DIR}/compiler) +xe_platform_sources(xenia-cpu ${CMAKE_CURRENT_SOURCE_DIR}/compiler/passes) +xe_platform_sources(xenia-cpu ${CMAKE_CURRENT_SOURCE_DIR}/hir) +xe_platform_sources(xenia-cpu ${CMAKE_CURRENT_SOURCE_DIR}/ppc) +target_include_directories(xenia-cpu PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/llvm/include +) +target_link_libraries(xenia-cpu PUBLIC xenia-base mspack) +xe_target_defaults(xenia-cpu) + +if(XENIA_BUILD_TESTS) + add_subdirectory(testing) + add_subdirectory(ppc/testing) +endif() diff --git a/src/xenia/cpu/backend/x64/CMakeLists.txt b/src/xenia/cpu/backend/x64/CMakeLists.txt new file mode 100644 index 000000000..b7ec45902 --- /dev/null +++ b/src/xenia/cpu/backend/x64/CMakeLists.txt @@ -0,0 +1,18 @@ +add_library(xenia-cpu-backend-x64 STATIC) +xe_platform_sources(xenia-cpu-backend-x64 ${CMAKE_CURRENT_SOURCE_DIR}) +target_compile_definitions(xenia-cpu-backend-x64 PRIVATE + CAPSTONE_X86_ATT_DISABLE + CAPSTONE_HAS_X86 + CAPSTONE_USE_SYS_DYN_MEM + XBYAK_NO_OP_NAMES + XBYAK_ENABLE_OMITTED_OPERAND +) +# Optional VTune support +if(EXISTS "${PROJECT_SOURCE_DIR}/third_party/vtune") + target_compile_definitions(xenia-cpu-backend-x64 PRIVATE ENABLE_VTUNE=1) +endif() +target_include_directories(xenia-cpu-backend-x64 PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/capstone/include +) +target_link_libraries(xenia-cpu-backend-x64 PUBLIC capstone fmt xenia-base xenia-cpu) +xe_target_defaults(xenia-cpu-backend-x64) diff --git a/src/xenia/cpu/backend/x64/premake5.lua b/src/xenia/cpu/backend/x64/premake5.lua deleted file mode 100644 index ac9c7f80d..000000000 --- a/src/xenia/cpu/backend/x64/premake5.lua +++ /dev/null @@ -1,30 +0,0 @@ -project_root = "../../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-cpu-backend-x64") - uuid("7d8d5dce-4696-4197-952a-09506f725afe") - kind("StaticLib") - language("C++") - links({ - "capstone", - "fmt", - "xenia-base", - "xenia-cpu", - }) - defines({ - "CAPSTONE_X86_ATT_DISABLE", - "CAPSTONE_HAS_X86", - "CAPSTONE_USE_SYS_DYN_MEM", - "XBYAK_NO_OP_NAMES", - "XBYAK_ENABLE_OMITTED_OPERAND", - }) - -- Enable VTune, if it's installed. - if os.isdir(project_root.."/third_party/vtune") then - defines { "ENABLE_VTUNE=1" } - end - - includedirs({ - project_root.."/third_party/capstone/include", - }) - local_platform_files() diff --git a/src/xenia/cpu/ppc/testing/CMakeLists.txt b/src/xenia/cpu/ppc/testing/CMakeLists.txt new file mode 100644 index 000000000..97a726f0f --- /dev/null +++ b/src/xenia/cpu/ppc/testing/CMakeLists.txt @@ -0,0 +1,37 @@ +if(NOT XENIA_BUILD_TESTS) + return() +endif() + +add_executable(xenia-cpu-ppc-tests + ${CMAKE_CURRENT_SOURCE_DIR}/ppc_testing_main.cc +) + +# Add platform-specific console app main +if(WIN32) + target_sources(xenia-cpu-ppc-tests PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/console_app_main_win.cc) +else() + target_sources(xenia-cpu-ppc-tests PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/console_app_main_posix.cc) +endif() + +# Add .s files but exclude from build (they're test data) +file(GLOB _ppc_asm "${CMAKE_CURRENT_SOURCE_DIR}/*.s") +target_sources(xenia-cpu-ppc-tests PRIVATE ${_ppc_asm}) +set_source_files_properties(${_ppc_asm} PROPERTIES HEADER_FILE_ONLY TRUE) + +target_link_libraries(xenia-cpu-ppc-tests PRIVATE + xenia-apu xenia-apu-nop + xenia-base xenia-core xenia-cpu + xenia-gpu xenia-gpu-null + xenia-hid xenia-hid-nop + xenia-kernel xenia-patcher xenia-ui xenia-vfs + capstone fmt imgui mspack +) + +# x64 backend +if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + target_link_libraries(xenia-cpu-ppc-tests PRIVATE xenia-cpu-backend-x64) +endif() + +xe_target_defaults(xenia-cpu-ppc-tests) diff --git a/src/xenia/cpu/ppc/testing/premake5.lua b/src/xenia/cpu/ppc/testing/premake5.lua deleted file mode 100644 index 6db094847..000000000 --- a/src/xenia/cpu/ppc/testing/premake5.lua +++ /dev/null @@ -1,85 +0,0 @@ -project_root = "../../../../.." -include(project_root.."/tools/build") - -group("tests") -project("xenia-cpu-ppc-tests") - uuid("2a57d5ac-4024-4c49-9cd3-aa3a603c2ef8") - kind("ConsoleApp") - language("C++") - links({ - "xenia-apu", - "xenia-apu-nop", - "xenia-base", - "xenia-core", - "xenia-cpu", - "xenia-gpu", - "xenia-gpu-null", - "xenia-hid", - "xenia-hid-nop", - "xenia-kernel", - "xenia-patcher", - "xenia-ui", - "xenia-vfs", - }) - links({ - "capstone", - "fmt", - "imgui", - "mspack", - }) - files({ - "ppc_testing_main.cc", - "../../../base/console_app_main_"..platform_suffix..".cc", - }) - files({ - "*.s", - }) - filter("files:*.s") - flags({ - "ExcludeFromBuild", - }) - filter("architecture:x86_64") - links({ - "xenia-cpu-backend-x64", - }) - filter("platforms:Windows") - debugdir(project_root) - debugargs({ - "2>&1", - "1>scratch/stdout-testing.txt", - }) - - filter({}) - -if ARCH == "ppc64" or ARCH == "powerpc64" then - -project("xenia-cpu-ppc-nativetests") - uuid("E381E8EE-65CD-4D5E-9223-D9C03B2CE78C") - kind("ConsoleApp") - language("C++") - links({ - "fmt", - "xenia-base", - }) - files({ - "ppc_testing_native_main.cc", - "../../../base/console_app_main_"..platform_suffix..".cc", - }) - files({ - "instr_*.s", - "seq_*.s", - }) - filter("files:instr_*.s", "files:seq_*.s") - flags({ - "ExcludeFromBuild", - }) - filter({}) - buildoptions({ - "-Wa,-mregnames", -- Tell GAS to accept register names. - }) - - files({ - "ppc_testing_native_thunks.s", - }) - -end diff --git a/src/xenia/cpu/premake5.lua b/src/xenia/cpu/premake5.lua deleted file mode 100644 index 6c0240c9d..000000000 --- a/src/xenia/cpu/premake5.lua +++ /dev/null @@ -1,27 +0,0 @@ -project_root = "../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-cpu") - uuid("0109c91e-5a04-41ab-9168-0d5187d11298") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - "mspack", - }) - - includedirs({ - project_root.."/third_party/llvm/include", - }) - local_platform_files() - local_platform_files("backend") - local_platform_files("compiler") - local_platform_files("compiler/passes") - local_platform_files("hir") - local_platform_files("ppc") - -if enableTests then - include("testing") - include("ppc/testing") -end diff --git a/src/xenia/cpu/testing/CMakeLists.txt b/src/xenia/cpu/testing/CMakeLists.txt new file mode 100644 index 000000000..d6ebd280e --- /dev/null +++ b/src/xenia/cpu/testing/CMakeLists.txt @@ -0,0 +1,7 @@ +xe_test_suite(xenia-cpu-tests ${CMAKE_CURRENT_SOURCE_DIR} + LINKS + capstone fmt imgui + xenia-base xenia-core xenia-cpu xenia-gpu + xenia-hid-skylander xenia-kernel xenia-ui xenia-patcher + $<$:xenia-cpu-backend-x64> +) diff --git a/src/xenia/cpu/testing/premake5.lua b/src/xenia/cpu/testing/premake5.lua deleted file mode 100644 index 23c0c6fb9..000000000 --- a/src/xenia/cpu/testing/premake5.lua +++ /dev/null @@ -1,28 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -test_suite("xenia-cpu-tests", project_root, ".", { - links = { - "capstone", - "fmt", - "imgui", - "xenia-base", - "xenia-core", - "xenia-cpu", - "xenia-gpu", - "xenia-hid-skylander", - - -- TODO(benvanik): cut these dependencies? - "xenia-kernel", - "xenia-ui", -- needed by xenia-base - "xenia-patcher", - }, - filtered_links = { - { - filter = 'architecture:x86_64', - links = { - "xenia-cpu-backend-x64", - }, - } - }, -}) diff --git a/src/xenia/debug/ui/CMakeLists.txt b/src/xenia/debug/ui/CMakeLists.txt new file mode 100644 index 000000000..8038cae65 --- /dev/null +++ b/src/xenia/debug/ui/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(xenia-debug-ui STATIC) +xe_platform_sources(xenia-debug-ui ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(xenia-debug-ui PUBLIC imgui xenia-base xenia-cpu xenia-ui) +xe_target_defaults(xenia-debug-ui) diff --git a/src/xenia/debug/ui/premake5.lua b/src/xenia/debug/ui/premake5.lua deleted file mode 100644 index 19d48cc2f..000000000 --- a/src/xenia/debug/ui/premake5.lua +++ /dev/null @@ -1,15 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-debug-ui") - uuid("9193a274-f4c2-4746-bd85-93fcfc5c3e38") - kind("StaticLib") - language("C++") - links({ - "imgui", - "xenia-base", - "xenia-cpu", - "xenia-ui", - }) - local_platform_files() diff --git a/src/xenia/gpu/CMakeLists.txt b/src/xenia/gpu/CMakeLists.txt new file mode 100644 index 000000000..65dba58e0 --- /dev/null +++ b/src/xenia/gpu/CMakeLists.txt @@ -0,0 +1,30 @@ +add_library(xenia-gpu STATIC) +xe_platform_sources(xenia-gpu ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(xenia-gpu PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/Vulkan-Headers/include + ${PROJECT_SOURCE_DIR}/third_party/glslang +) +target_link_libraries(xenia-gpu PUBLIC dxbc fmt glslang-spirv snappy xxhash xenia-base xenia-ui) +xe_target_defaults(xenia-gpu) + +if(XENIA_BUILD_MISC) + # Shader compiler tool + add_executable(xenia-gpu-shader-compiler + ${CMAKE_CURRENT_SOURCE_DIR}/shader_compiler_main.cc + ) + if(WIN32) + target_sources(xenia-gpu-shader-compiler PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/console_app_main_win.cc) + else() + target_sources(xenia-gpu-shader-compiler PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/console_app_main_posix.cc) + endif() + target_include_directories(xenia-gpu-shader-compiler PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/Vulkan-Headers/include + ${PROJECT_SOURCE_DIR}/third_party/glslang + ) + target_link_libraries(xenia-gpu-shader-compiler PRIVATE + dxbc fmt glslang-spirv snappy xenia-base xenia-gpu xenia-ui xenia-ui-vulkan + ) + xe_target_defaults(xenia-gpu-shader-compiler) +endif() diff --git a/src/xenia/gpu/d3d12/CMakeLists.txt b/src/xenia/gpu/d3d12/CMakeLists.txt new file mode 100644 index 000000000..cbe9fdfba --- /dev/null +++ b/src/xenia/gpu/d3d12/CMakeLists.txt @@ -0,0 +1,44 @@ +add_library(xenia-gpu-d3d12 STATIC) +xe_platform_sources(xenia-gpu-d3d12 ${CMAKE_CURRENT_SOURCE_DIR}) +# Include shader bytecode headers +file(GLOB _d3d12_shader_headers "${CMAKE_CURRENT_SOURCE_DIR}/../shaders/bytecode/d3d12_5_1/*.h" +) +target_sources(xenia-gpu-d3d12 PRIVATE ${_d3d12_shader_headers}) +target_link_libraries(xenia-gpu-d3d12 PUBLIC + fmt xxhash xenia-base xenia-gpu xenia-ui xenia-ui-d3d12 +) +xe_target_defaults(xenia-gpu-d3d12) + +if(XENIA_BUILD_MISC) + # D3D12 trace viewer + add_executable(xenia-gpu-d3d12-trace-viewer WIN32 + ${CMAKE_CURRENT_SOURCE_DIR}/d3d12_trace_viewer_main.cc + ${PROJECT_SOURCE_DIR}/src/xenia/ui/windowed_app_main_win.cc + ) + target_link_libraries(xenia-gpu-d3d12-trace-viewer PRIVATE + xenia-apu xenia-apu-nop xenia-base xenia-core xenia-cpu + xenia-gpu xenia-gpu-d3d12 xenia-hid xenia-hid-nop xenia-hid-skylander + xenia-kernel xenia-patcher xenia-ui xenia-ui-d3d12 xenia-vfs + aes_128 capstone dxbc fmt imgui libavcodec libavutil mspack snappy xxhash + ) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + target_link_libraries(xenia-gpu-d3d12-trace-viewer PRIVATE xenia-cpu-backend-x64) + endif() + xe_target_defaults(xenia-gpu-d3d12-trace-viewer) + + # D3D12 trace dump + add_executable(xenia-gpu-d3d12-trace-dump + ${CMAKE_CURRENT_SOURCE_DIR}/d3d12_trace_dump_main.cc + ${PROJECT_SOURCE_DIR}/src/xenia/base/console_app_main_win.cc + ) + target_link_libraries(xenia-gpu-d3d12-trace-dump PRIVATE + xenia-apu xenia-apu-nop xenia-base xenia-core xenia-cpu + xenia-gpu xenia-gpu-d3d12 xenia-hid xenia-hid-nop xenia-hid-skylander + xenia-kernel xenia-patcher xenia-ui xenia-ui-d3d12 xenia-vfs + aes_128 capstone dxbc fmt imgui libavcodec libavutil mspack snappy xxhash + ) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + target_link_libraries(xenia-gpu-d3d12-trace-dump PRIVATE xenia-cpu-backend-x64) + endif() + xe_target_defaults(xenia-gpu-d3d12-trace-dump) +endif() diff --git a/src/xenia/gpu/d3d12/premake5.lua b/src/xenia/gpu/d3d12/premake5.lua deleted file mode 100644 index c79ceec02..000000000 --- a/src/xenia/gpu/d3d12/premake5.lua +++ /dev/null @@ -1,128 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-gpu-d3d12") - uuid("c057eae4-e7bb-4113-9a69-1fe07b735c49") - kind("StaticLib") - language("C++") - links({ - "fmt", - "xenia-base", - "xenia-gpu", - "xenia-ui", - "xenia-ui-d3d12", - "xxhash", - }) - local_platform_files() - files({ - "../shaders/bytecode/d3d12_5_1/*.h", - }) - -if enableMiscSubprojects then - group("src") - project("xenia-gpu-d3d12-trace-viewer") - uuid("7b5b9fcb-7bf1-43ff-a774-d4c41c8706be") - single_library_windowed_app_kind() - language("C++") - links({ - "xenia-apu", - "xenia-apu-nop", - "xenia-base", - "xenia-core", - "xenia-cpu", - "xenia-gpu", - "xenia-gpu-d3d12", - "xenia-hid", - "xenia-hid-nop", - "xenia-hid-skylander", - "xenia-kernel", - "xenia-patcher", - "xenia-ui", - "xenia-ui-d3d12", - "xenia-vfs", - }) - links({ - "aes_128", - "capstone", - "dxbc", - "fmt", - "imgui", - "libavcodec", - "libavutil", - "mspack", - "snappy", - "xxhash", - }) - files({ - "d3d12_trace_viewer_main.cc", - "../../ui/windowed_app_main_"..platform_suffix..".cc", - }) - -- Only create the .user file if it doesn't already exist. - local user_file = project_root.."/build/xenia-gpu-d3d12-trace-viewer.vcxproj.user" - if not os.isfile(user_file) then - debugdir(project_root) - debugargs({ - "2>&1", - "1>scratch/stdout-trace-viewer.txt", - }) - end - - filter("architecture:x86_64") - links({ - "xenia-cpu-backend-x64", - }) - - group("src") - project("xenia-gpu-d3d12-trace-dump") - uuid("686b859c-0046-44c4-a02c-41fc3fb75698") - kind("ConsoleApp") - language("C++") - links({ - "xenia-apu", - "xenia-apu-nop", - "xenia-base", - "xenia-core", - "xenia-cpu", - "xenia-gpu", - "xenia-gpu-d3d12", - "xenia-hid", - "xenia-hid-nop", - "xenia-hid-skylander", - "xenia-kernel", - "xenia-ui", - "xenia-ui-d3d12", - "xenia-vfs", - "xenia-patcher", - }) - links({ - "aes_128", - "capstone", - "dxbc", - "fmt", - "imgui", - "libavcodec", - "libavutil", - "mspack", - "snappy", - "xxhash", - }) - files({ - "d3d12_trace_dump_main.cc", - "../../base/console_app_main_"..platform_suffix..".cc", - }) - -- Only create the .user file if it doesn't already exist. - local user_file = project_root.."/build/xenia-gpu-d3d12-trace-dump.vcxproj.user" - if not os.isfile(user_file) then - debugdir(project_root) - debugargs({ - "2>&1", - "1>scratch/stdout-trace-dump.txt", - }) - end - - filter("architecture:x86_64") - links({ - "xenia-cpu-backend-x64", - }) -end \ No newline at end of file diff --git a/src/xenia/gpu/null/CMakeLists.txt b/src/xenia/gpu/null/CMakeLists.txt new file mode 100644 index 000000000..d295b4ce9 --- /dev/null +++ b/src/xenia/gpu/null/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(xenia-gpu-null STATIC) +xe_platform_sources(xenia-gpu-null ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(xenia-gpu-null PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/Vulkan-Headers/include +) +target_link_libraries(xenia-gpu-null PUBLIC xenia-base xenia-gpu xenia-ui xenia-ui-vulkan xxhash) +xe_target_defaults(xenia-gpu-null) diff --git a/src/xenia/gpu/null/premake5.lua b/src/xenia/gpu/null/premake5.lua deleted file mode 100644 index 3f920eab0..000000000 --- a/src/xenia/gpu/null/premake5.lua +++ /dev/null @@ -1,19 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-gpu-null") - uuid("42FCA0B3-4C20-4532-95E9-07D297013BE4") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - "xenia-gpu", - "xenia-ui", - "xenia-ui-vulkan", - "xxhash", - }) - includedirs({ - project_root.."/third_party/Vulkan-Headers/include", - }) - local_platform_files() diff --git a/src/xenia/gpu/premake5.lua b/src/xenia/gpu/premake5.lua deleted file mode 100644 index ecf070220..000000000 --- a/src/xenia/gpu/premake5.lua +++ /dev/null @@ -1,60 +0,0 @@ -project_root = "../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-gpu") - uuid("0e8d3370-e4b1-4b05-a2e8-39ebbcdf9b17") - kind("StaticLib") - language("C++") - links({ - "dxbc", - "fmt", - "glslang-spirv", - "snappy", - "xenia-base", - "xenia-ui", - "xxhash", - }) - includedirs({ - project_root.."/third_party/Vulkan-Headers/include", - project_root.."/third_party/glslang", -- For glslang SPIRV headers - }) - local_platform_files() - -if enableMiscSubprojects then - group("src") - project("xenia-gpu-shader-compiler") - uuid("ad76d3e4-4c62-439b-a0f6-f83fcf0e83c5") - kind("ConsoleApp") - language("C++") - links({ - "dxbc", - "fmt", - "glslang-spirv", - "snappy", - "xenia-base", - "xenia-gpu", - "xenia-ui", - "xenia-ui-vulkan", - }) - includedirs({ - project_root.."/third_party/Vulkan-Headers/include", - project_root.."/third_party/glslang", -- For glslang SPIRV headers - }) - files({ - "shader_compiler_main.cc", - "../base/console_app_main_"..platform_suffix..".cc", - }) - - filter("platforms:Windows") - -- Only create the .user file if it doesn't already exist. - local user_file = project_root.."/build/xenia-gpu-shader-compiler.vcxproj.user" - if not os.isfile(user_file) then - debugdir(project_root) - debugargs({ - "2>&1", - "1>scratch/stdout-shader-compiler.txt", - }) - end - filter({}) -end diff --git a/src/xenia/gpu/vulkan/CMakeLists.txt b/src/xenia/gpu/vulkan/CMakeLists.txt new file mode 100644 index 000000000..22c8b57f6 --- /dev/null +++ b/src/xenia/gpu/vulkan/CMakeLists.txt @@ -0,0 +1,71 @@ +add_library(xenia-gpu-vulkan STATIC) +xe_platform_sources(xenia-gpu-vulkan ${CMAKE_CURRENT_SOURCE_DIR}) +# Include shader bytecode headers +file(GLOB _vk_shader_headers "${CMAKE_CURRENT_SOURCE_DIR}/../shaders/bytecode/vulkan_spirv/*.h" +) +target_sources(xenia-gpu-vulkan PRIVATE ${_vk_shader_headers}) +target_include_directories(xenia-gpu-vulkan PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/Vulkan-Headers/include + ${PROJECT_SOURCE_DIR}/third_party/glslang +) +target_link_libraries(xenia-gpu-vulkan PUBLIC + fmt glslang-spirv xxhash xenia-base xenia-gpu xenia-ui xenia-ui-vulkan +) +xe_target_defaults(xenia-gpu-vulkan) + +if(XENIA_BUILD_MISC) + # Vulkan trace viewer + add_executable(xenia-gpu-vulkan-trace-viewer + ${CMAKE_CURRENT_SOURCE_DIR}/vulkan_trace_viewer_main.cc + ) + if(WIN32) + target_sources(xenia-gpu-vulkan-trace-viewer PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/ui/windowed_app_main_win.cc) + else() + target_sources(xenia-gpu-vulkan-trace-viewer PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/ui/windowed_app_main_posix.cc) + endif() + target_include_directories(xenia-gpu-vulkan-trace-viewer PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/Vulkan-Headers/include + ${PROJECT_SOURCE_DIR}/third_party/glslang + ) + target_link_libraries(xenia-gpu-vulkan-trace-viewer PRIVATE + xenia-apu xenia-apu-nop xenia-base xenia-core xenia-cpu + xenia-gpu xenia-gpu-vulkan xenia-hid xenia-hid-nop xenia-hid-skylander + xenia-kernel xenia-patcher xenia-ui xenia-ui-vulkan xenia-vfs + aes_128 capstone fmt glslang-spirv imgui libavcodec libavutil mspack snappy xxhash + ) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + target_link_libraries(xenia-gpu-vulkan-trace-viewer PRIVATE xenia-cpu-backend-x64) + endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(xenia-gpu-vulkan-trace-viewer PRIVATE X11 xcb X11-xcb) + endif() + xe_target_defaults(xenia-gpu-vulkan-trace-viewer) + + # Vulkan trace dump + add_executable(xenia-gpu-vulkan-trace-dump + ${CMAKE_CURRENT_SOURCE_DIR}/vulkan_trace_dump_main.cc + ) + if(WIN32) + target_sources(xenia-gpu-vulkan-trace-dump PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/console_app_main_win.cc) + else() + target_sources(xenia-gpu-vulkan-trace-dump PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/console_app_main_posix.cc) + endif() + target_include_directories(xenia-gpu-vulkan-trace-dump PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/Vulkan-Headers/include + ${PROJECT_SOURCE_DIR}/third_party/glslang + ) + target_link_libraries(xenia-gpu-vulkan-trace-dump PRIVATE + xenia-apu xenia-apu-nop xenia-base xenia-core xenia-cpu + xenia-gpu xenia-gpu-vulkan xenia-hid xenia-hid-nop xenia-hid-skylander + xenia-kernel xenia-patcher xenia-ui xenia-ui-vulkan xenia-vfs + aes_128 capstone fmt glslang-spirv imgui libavcodec libavutil mspack snappy xxhash + ) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + target_link_libraries(xenia-gpu-vulkan-trace-dump PRIVATE xenia-cpu-backend-x64) + endif() + xe_target_defaults(xenia-gpu-vulkan-trace-dump) +endif() diff --git a/src/xenia/gpu/vulkan/premake5.lua b/src/xenia/gpu/vulkan/premake5.lua deleted file mode 100644 index 5e4a4dcbb..000000000 --- a/src/xenia/gpu/vulkan/premake5.lua +++ /dev/null @@ -1,159 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-gpu-vulkan") - uuid("717590b4-f579-4162-8f23-0624e87d6cca") - kind("StaticLib") - language("C++") - links({ - "fmt", - "glslang-spirv", - "xenia-base", - "xenia-gpu", - "xenia-ui", - "xenia-ui-vulkan", - "xxhash", - }) - includedirs({ - project_root.."/third_party/Vulkan-Headers/include", - project_root.."/third_party/glslang", -- For glslang SPIRV headers - }) - local_platform_files() - files({ - "../shaders/bytecode/vulkan_spirv/*.h", - }) - -if enableMiscSubprojects then - group("src") - project("xenia-gpu-vulkan-trace-viewer") - uuid("86a1dddc-a26a-4885-8c55-cf745225d93e") - single_library_windowed_app_kind() - language("C++") - links({ - "xenia-apu", - "xenia-apu-nop", - "xenia-base", - "xenia-core", - "xenia-cpu", - "xenia-gpu", - "xenia-gpu-vulkan", - "xenia-hid", - "xenia-hid-nop", - "xenia-hid-skylander", - "xenia-kernel", - "xenia-patcher", - "xenia-ui", - "xenia-ui-vulkan", - "xenia-vfs", - }) - links({ - "aes_128", - "capstone", - "fmt", - "glslang-spirv", - "imgui", - "libavcodec", - "libavutil", - "mspack", - "snappy", - "xxhash", - }) - includedirs({ - project_root.."/third_party/Vulkan-Headers/include", - project_root.."/third_party/glslang", -- For glslang SPIRV headers - }) - files({ - "vulkan_trace_viewer_main.cc", - "../../ui/windowed_app_main_"..platform_suffix..".cc", - }) - - filter("architecture:x86_64") - links({ - "xenia-cpu-backend-x64", - }) - - filter("platforms:Linux") - links({ - "X11", - "xcb", - "X11-xcb", - }) - - filter("platforms:Windows") - -- Only create the .user file if it doesn't already exist. - local user_file = project_root.."/build/xenia-gpu-vulkan-trace-viewer.vcxproj.user" - if not os.isfile(user_file) then - debugdir(project_root) - debugargs({ - "2>&1", - "1>scratch/stdout-trace-viewer.txt", - }) - end - - group("src") - project("xenia-gpu-vulkan-trace-dump") - uuid("0dd0dd1c-b321-494d-ab9a-6c062f0c65cc") - kind("ConsoleApp") - language("C++") - links({ - "xenia-apu", - "xenia-apu-nop", - "xenia-base", - "xenia-core", - "xenia-cpu", - "xenia-gpu", - "xenia-gpu-vulkan", - "xenia-hid", - "xenia-hid-nop", - "xenia-hid-skylander", - "xenia-kernel", - "xenia-ui", - "xenia-ui-vulkan", - "xenia-vfs", - "xenia-patcher", - }) - links({ - "aes_128", - "capstone", - "fmt", - "glslang-spirv", - "imgui", - "libavcodec", - "libavutil", - "mspack", - "snappy", - "xxhash", - }) - includedirs({ - project_root.."/third_party/Vulkan-Headers/include", - project_root.."/third_party/glslang", -- For glslang SPIRV headers - }) - files({ - "vulkan_trace_dump_main.cc", - "../../base/console_app_main_"..platform_suffix..".cc", - }) - - filter("architecture:x86_64") - links({ - "xenia-cpu-backend-x64", - }) - - filter("platforms:Linux") - links({ - "X11", - "xcb", - "X11-xcb", - }) - - filter("platforms:Windows") - -- Only create the .user file if it doesn't already exist. - local user_file = project_root.."/build/xenia-gpu-vulkan-trace-dump.vcxproj.user" - if not os.isfile(user_file) then - debugdir(project_root) - debugargs({ - "2>&1", - "1>scratch/stdout-trace-dump.txt", - }) - end -end diff --git a/src/xenia/helper/sdl/CMakeLists.txt b/src/xenia/helper/sdl/CMakeLists.txt new file mode 100644 index 000000000..e072735c9 --- /dev/null +++ b/src/xenia/helper/sdl/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(xenia-helper-sdl STATIC) +xe_platform_sources(xenia-helper-sdl ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(xenia-helper-sdl PUBLIC SDL2) +xe_target_defaults(xenia-helper-sdl) diff --git a/src/xenia/helper/sdl/premake5.lua b/src/xenia/helper/sdl/premake5.lua deleted file mode 100644 index 26058f713..000000000 --- a/src/xenia/helper/sdl/premake5.lua +++ /dev/null @@ -1,13 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-helper-sdl") - uuid("84b00ad3-fba3-4561-96c9-1f9993b14c9c") - kind("StaticLib") - language("C++") - links({ - "SDL2", - }) - local_platform_files() - sdl2_include() diff --git a/src/xenia/hid/CMakeLists.txt b/src/xenia/hid/CMakeLists.txt new file mode 100644 index 000000000..8bbb1ee56 --- /dev/null +++ b/src/xenia/hid/CMakeLists.txt @@ -0,0 +1,11 @@ +add_library(xenia-hid STATIC) +xe_platform_sources(xenia-hid ${CMAKE_CURRENT_SOURCE_DIR}) +# Exclude demo files +file(GLOB _hid_demo "${CMAKE_CURRENT_SOURCE_DIR}/*_demo.cc") +get_target_property(_hid_srcs xenia-hid SOURCES) +if(_hid_demo AND _hid_srcs) + list(REMOVE_ITEM _hid_srcs ${_hid_demo}) + set_target_properties(xenia-hid PROPERTIES SOURCES "${_hid_srcs}") +endif() +target_link_libraries(xenia-hid PUBLIC xenia-base xenia-hid-skylander) +xe_target_defaults(xenia-hid) diff --git a/src/xenia/hid/nop/CMakeLists.txt b/src/xenia/hid/nop/CMakeLists.txt new file mode 100644 index 000000000..dd8985665 --- /dev/null +++ b/src/xenia/hid/nop/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(xenia-hid-nop STATIC) +xe_platform_sources(xenia-hid-nop ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(xenia-hid-nop PUBLIC xenia-base xenia-hid) +xe_target_defaults(xenia-hid-nop) diff --git a/src/xenia/hid/nop/premake5.lua b/src/xenia/hid/nop/premake5.lua deleted file mode 100644 index 4b83e2573..000000000 --- a/src/xenia/hid/nop/premake5.lua +++ /dev/null @@ -1,13 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-hid-nop") - uuid("887b6f26-b0c1-43c1-a013-a37e7b9634fd") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - "xenia-hid", - }) - local_platform_files() diff --git a/src/xenia/hid/premake5.lua b/src/xenia/hid/premake5.lua deleted file mode 100644 index dabe3402a..000000000 --- a/src/xenia/hid/premake5.lua +++ /dev/null @@ -1,16 +0,0 @@ -project_root = "../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-hid") - uuid("88a4ef38-c550-430f-8c22-8ded4e4ef601") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - "xenia-hid-skylander", - }) - local_platform_files() - removefiles({ - "*_demo.cc", - }) diff --git a/src/xenia/hid/sdl/CMakeLists.txt b/src/xenia/hid/sdl/CMakeLists.txt new file mode 100644 index 000000000..7e639d821 --- /dev/null +++ b/src/xenia/hid/sdl/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(xenia-hid-sdl STATIC) +xe_platform_sources(xenia-hid-sdl ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(xenia-hid-sdl PUBLIC xenia-base xenia-hid xenia-ui SDL2) +xe_target_defaults(xenia-hid-sdl) diff --git a/src/xenia/hid/sdl/premake5.lua b/src/xenia/hid/sdl/premake5.lua deleted file mode 100644 index 15bcf4fca..000000000 --- a/src/xenia/hid/sdl/premake5.lua +++ /dev/null @@ -1,16 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-hid-sdl") - uuid("44f5b9a1-00f8-4825-acf1-5c93f26eba9b") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - "xenia-hid", - "xenia-ui", - "SDL2", - }) - local_platform_files() - sdl2_include() diff --git a/src/xenia/hid/skylander/CMakeLists.txt b/src/xenia/hid/skylander/CMakeLists.txt new file mode 100644 index 000000000..8ae07a842 --- /dev/null +++ b/src/xenia/hid/skylander/CMakeLists.txt @@ -0,0 +1,14 @@ +add_library(xenia-hid-skylander STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/skylander_portal.h + ${CMAKE_CURRENT_SOURCE_DIR}/skylander_portal.cc + ${CMAKE_CURRENT_SOURCE_DIR}/skylander_emulated.h + ${CMAKE_CURRENT_SOURCE_DIR}/skylander_emulated.cc +) +if(WIN32) + target_sources(xenia-hid-skylander PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/skylander_hardware.h + ${CMAKE_CURRENT_SOURCE_DIR}/skylander_hardware.cc + ) + target_link_libraries(xenia-hid-skylander PUBLIC libusb) +endif() +xe_target_defaults(xenia-hid-skylander) diff --git a/src/xenia/hid/skylander/premake5.lua b/src/xenia/hid/skylander/premake5.lua deleted file mode 100644 index a55c4c7c3..000000000 --- a/src/xenia/hid/skylander/premake5.lua +++ /dev/null @@ -1,23 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-hid-skylander") - uuid("ddc114da-a279-4868-8b20-53108599bd78") - kind("StaticLib") - language("C++") - files({ - "skylander_portal.h", - "skylander_portal.cc", - "skylander_emulated.h", - "skylander_emulated.cc" - }) - - filter({"platforms:Windows"}) - links({ - "libusb", - }) - files({ - "skylander_hardware.h", - "skylander_hardware.cc" - }) diff --git a/src/xenia/hid/winkey/CMakeLists.txt b/src/xenia/hid/winkey/CMakeLists.txt new file mode 100644 index 000000000..d48a1d7c7 --- /dev/null +++ b/src/xenia/hid/winkey/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(xenia-hid-winkey STATIC) +xe_platform_sources(xenia-hid-winkey ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(xenia-hid-winkey PUBLIC xenia-base xenia-hid xenia-ui) +xe_target_defaults(xenia-hid-winkey) diff --git a/src/xenia/hid/winkey/premake5.lua b/src/xenia/hid/winkey/premake5.lua deleted file mode 100644 index 819bc8f97..000000000 --- a/src/xenia/hid/winkey/premake5.lua +++ /dev/null @@ -1,14 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-hid-winkey") - uuid("fd16e19a-6219-4ab7-b95a-7c78523c50c3") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - "xenia-hid", - "xenia-ui", - }) - local_platform_files() diff --git a/src/xenia/hid/xinput/CMakeLists.txt b/src/xenia/hid/xinput/CMakeLists.txt new file mode 100644 index 000000000..3386b8985 --- /dev/null +++ b/src/xenia/hid/xinput/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(xenia-hid-xinput STATIC) +xe_platform_sources(xenia-hid-xinput ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(xenia-hid-xinput PUBLIC xenia-base xenia-hid) +xe_target_defaults(xenia-hid-xinput) diff --git a/src/xenia/hid/xinput/premake5.lua b/src/xenia/hid/xinput/premake5.lua deleted file mode 100644 index d50332af9..000000000 --- a/src/xenia/hid/xinput/premake5.lua +++ /dev/null @@ -1,13 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-hid-xinput") - uuid("3d49e251-07a7-40ae-9bc6-aae984c85568") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - "xenia-hid", - }) - local_platform_files() diff --git a/src/xenia/kernel/CMakeLists.txt b/src/xenia/kernel/CMakeLists.txt new file mode 100644 index 000000000..766ec05e1 --- /dev/null +++ b/src/xenia/kernel/CMakeLists.txt @@ -0,0 +1,23 @@ +add_library(xenia-kernel STATIC) +xe_platform_sources(xenia-kernel ${CMAKE_CURRENT_SOURCE_DIR} RECURSIVE) +target_compile_definitions(xenia-kernel PRIVATE + X86_FEATURES + X86_HAVE_XSAVE_INTRIN + X86_SSSE3 + X86_SSE42 + WITH_GZFILEOP +) +if(WIN32) + target_compile_definitions(xenia-kernel PRIVATE + X86_SSE2 + X86_AVX2 + X86_AVX512 + X86_AVX512VNNI + X86_PCLMULQDQ_CRC + X86_VPCLMULQDQ_CRC + ) +endif() +target_link_libraries(xenia-kernel PUBLIC + aes_128 fmt zlib-ng pugixml xenia-apu xenia-base xenia-cpu xenia-hid xenia-vfs +) +xe_target_defaults(xenia-kernel) diff --git a/src/xenia/kernel/premake5.lua b/src/xenia/kernel/premake5.lua deleted file mode 100644 index f478c9f22..000000000 --- a/src/xenia/kernel/premake5.lua +++ /dev/null @@ -1,40 +0,0 @@ -project_root = "../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-kernel") - uuid("ae185c4a-1c4f-4503-9892-328e549e871a") - kind("StaticLib") - language("C++") - links({ - "aes_128", - "fmt", - "zlib-ng", - "pugixml", - "xenia-apu", - "xenia-base", - "xenia-cpu", - "xenia-hid", - "xenia-vfs", - }) - defines({ - "X86_FEATURES", - "X86_HAVE_XSAVE_INTRIN", - "X86_SSSE3", - "X86_SSE42", - "WITH_GZFILEOP", - }) - if os.istarget("windows") then - defines({ - "X86_SSE2", - "X86_AVX2", - "X86_AVX512", - "X86_AVX512VNNI", - "X86_PCLMULQDQ_CRC", - "X86_VPCLMULQDQ_CRC", - }) - end - recursive_platform_files() - files({ - "debug_visualizers.natvis", - }) diff --git a/src/xenia/patcher/CMakeLists.txt b/src/xenia/patcher/CMakeLists.txt new file mode 100644 index 000000000..078a6624a --- /dev/null +++ b/src/xenia/patcher/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(xenia-patcher STATIC) +xe_platform_sources(xenia-patcher ${CMAKE_CURRENT_SOURCE_DIR} RECURSIVE) +target_link_libraries(xenia-patcher PUBLIC xenia-base) +xe_target_defaults(xenia-patcher) diff --git a/src/xenia/patcher/premake5.lua b/src/xenia/patcher/premake5.lua deleted file mode 100644 index c41265f0b..000000000 --- a/src/xenia/patcher/premake5.lua +++ /dev/null @@ -1,12 +0,0 @@ -project_root = "../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-patcher") - uuid("e1c75f76-9e7b-48f6-b17e-dbd20f7a1592") - kind("StaticLib") - language("C++") - links({ - "xenia-base" - }) - recursive_platform_files() diff --git a/src/xenia/premake5.lua b/src/xenia/premake5.lua deleted file mode 100644 index 98846361e..000000000 --- a/src/xenia/premake5.lua +++ /dev/null @@ -1,16 +0,0 @@ -project_root = "../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-core") - uuid("970f7892-f19a-4bf5-8795-478c51757bec") - kind("StaticLib") - language("C++") - links({ - "fmt", - "xenia-base", - }) - files({ - "*.h", - "*.cc", - }) diff --git a/src/xenia/ui/CMakeLists.txt b/src/xenia/ui/CMakeLists.txt new file mode 100644 index 000000000..fc0d69f85 --- /dev/null +++ b/src/xenia/ui/CMakeLists.txt @@ -0,0 +1,18 @@ +add_library(xenia-ui STATIC) +xe_platform_sources(xenia-ui ${CMAKE_CURRENT_SOURCE_DIR}) +# Exclude demo and windowed_app_main files +file(GLOB _ui_exclude "${CMAKE_CURRENT_SOURCE_DIR}/*_demo.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/windowed_app_main_*.cc" +) +get_target_property(_ui_srcs xenia-ui SOURCES) +if(_ui_exclude AND _ui_srcs) + list(REMOVE_ITEM _ui_srcs ${_ui_exclude}) + set_target_properties(xenia-ui PROPERTIES SOURCES "${_ui_srcs}") +endif() +target_link_libraries(xenia-ui PUBLIC xenia-base) +if(WIN32) + target_link_libraries(xenia-ui PRIVATE dwmapi dxgi winmm) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(xenia-ui PRIVATE xcb X11 X11-xcb fontconfig ${GTK3_LIBRARIES}) +endif() +xe_target_defaults(xenia-ui) diff --git a/src/xenia/ui/d3d12/CMakeLists.txt b/src/xenia/ui/d3d12/CMakeLists.txt new file mode 100644 index 000000000..d214c403a --- /dev/null +++ b/src/xenia/ui/d3d12/CMakeLists.txt @@ -0,0 +1,21 @@ +add_library(xenia-ui-d3d12 STATIC) +xe_platform_sources(xenia-ui-d3d12 ${CMAKE_CURRENT_SOURCE_DIR}) +# Include shader bytecode headers +file(GLOB _d3d12_ui_shader_headers "${CMAKE_CURRENT_SOURCE_DIR}/../shaders/bytecode/d3d12_5_1/*.h" +) +target_sources(xenia-ui-d3d12 PRIVATE ${_d3d12_ui_shader_headers}) +target_link_libraries(xenia-ui-d3d12 PUBLIC xenia-base xenia-ui) +xe_target_defaults(xenia-ui-d3d12) + +if(XENIA_BUILD_MISC) + # D3D12 window demo + add_executable(xenia-ui-window-d3d12-demo WIN32 + ${CMAKE_CURRENT_SOURCE_DIR}/../window_demo.cc + ${CMAKE_CURRENT_SOURCE_DIR}/d3d12_window_demo.cc + ${PROJECT_SOURCE_DIR}/src/xenia/ui/windowed_app_main_win.cc + ) + target_link_libraries(xenia-ui-window-d3d12-demo PRIVATE + fmt imgui xenia-base xenia-ui xenia-ui-d3d12 + ) + xe_target_defaults(xenia-ui-window-d3d12-demo) +endif() diff --git a/src/xenia/ui/d3d12/premake5.lua b/src/xenia/ui/d3d12/premake5.lua deleted file mode 100644 index fdbdf73bf..000000000 --- a/src/xenia/ui/d3d12/premake5.lua +++ /dev/null @@ -1,39 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-ui-d3d12") - uuid("f93dc1a8-600f-43e7-b0fc-ae3eefbe836b") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - "xenia-ui", - }) - local_platform_files() - files({ - "../shaders/bytecode/d3d12_5_1/*.h", - }) - -if enableMiscSubprojects then - group("demos") - project("xenia-ui-window-d3d12-demo") - uuid("3b9686a7-0f04-4e17-8b00-aeb78ae1107c") - single_library_windowed_app_kind() - language("C++") - links({ - "fmt", - "imgui", - "xenia-base", - "xenia-ui", - "xenia-ui-d3d12", - }) - files({ - "../window_demo.cc", - "d3d12_window_demo.cc", - project_root.."/src/xenia/ui/windowed_app_main_"..platform_suffix..".cc", - }) - resincludedirs({ - project_root, - }) -end \ No newline at end of file diff --git a/src/xenia/ui/premake5.lua b/src/xenia/ui/premake5.lua deleted file mode 100644 index 6380b65cc..000000000 --- a/src/xenia/ui/premake5.lua +++ /dev/null @@ -1,36 +0,0 @@ -project_root = "../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-ui") - uuid("d0407c25-b0ea-40dc-846c-82c46fbd9fa2") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - }) - local_platform_files() - removefiles({ - "*_demo.cc", - "windowed_app_main_*.cc", - }) - if os.istarget("android") then - filter("platforms:Android-*") - -- Exports JNI functions. - wholelib("On") - end - - filter("platforms:Windows") - links({ - "dwmapi", - "dxgi", - "winmm", - }) - - filter("platforms:Linux") - links({ - "xcb", - "X11", - "X11-xcb", - "fontconfig" - }) diff --git a/src/xenia/ui/vulkan/CMakeLists.txt b/src/xenia/ui/vulkan/CMakeLists.txt new file mode 100644 index 000000000..b6af414bb --- /dev/null +++ b/src/xenia/ui/vulkan/CMakeLists.txt @@ -0,0 +1,40 @@ +add_library(xenia-ui-vulkan STATIC) +xe_platform_sources(xenia-ui-vulkan ${CMAKE_CURRENT_SOURCE_DIR}) +xe_platform_sources(xenia-ui-vulkan ${CMAKE_CURRENT_SOURCE_DIR}/functions) +# Include shader bytecode headers +file(GLOB _vk_ui_shader_headers "${CMAKE_CURRENT_SOURCE_DIR}/../shaders/bytecode/vulkan_spirv/*.h" +) +target_sources(xenia-ui-vulkan PRIVATE ${_vk_ui_shader_headers}) +target_include_directories(xenia-ui-vulkan PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/Vulkan-Headers/include + ${PROJECT_SOURCE_DIR}/third_party/glslang +) +target_link_libraries(xenia-ui-vulkan PUBLIC xenia-base xenia-ui) +xe_target_defaults(xenia-ui-vulkan) + +if(XENIA_BUILD_MISC) + # Vulkan window demo + add_executable(xenia-ui-window-vulkan-demo) + if(WIN32) + set_target_properties(xenia-ui-window-vulkan-demo PROPERTIES WIN32_EXECUTABLE TRUE) + target_sources(xenia-ui-window-vulkan-demo PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/ui/windowed_app_main_win.cc) + else() + target_sources(xenia-ui-window-vulkan-demo PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/ui/windowed_app_main_posix.cc) + endif() + target_sources(xenia-ui-window-vulkan-demo PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/../window_demo.cc + ${CMAKE_CURRENT_SOURCE_DIR}/vulkan_window_demo.cc + ) + target_include_directories(xenia-ui-window-vulkan-demo PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/Vulkan-Headers/include + ) + target_link_libraries(xenia-ui-window-vulkan-demo PRIVATE + fmt imgui xenia-base xenia-ui xenia-ui-vulkan + ) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(xenia-ui-window-vulkan-demo PRIVATE X11 xcb X11-xcb) + endif() + xe_target_defaults(xenia-ui-window-vulkan-demo) +endif() diff --git a/src/xenia/ui/vulkan/premake5.lua b/src/xenia/ui/vulkan/premake5.lua deleted file mode 100644 index 9c528e3fa..000000000 --- a/src/xenia/ui/vulkan/premake5.lua +++ /dev/null @@ -1,54 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-ui-vulkan") - uuid("4933d81e-1c2c-4d5d-b104-3c0eb9dc2f00") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - "xenia-ui", - }) - includedirs({ - project_root.."/third_party/Vulkan-Headers/include", - project_root.."/third_party/glslang", -- For glslang SPIRV headers - }) - local_platform_files() - local_platform_files("functions") - files({ - "../shaders/bytecode/vulkan_spirv/*.h", - }) - -if enableMiscSubprojects then - group("demos") - project("xenia-ui-window-vulkan-demo") - uuid("97598f13-3177-454c-8e58-c59e2b6ede27") - single_library_windowed_app_kind() - language("C++") - links({ - "fmt", - "imgui", - "xenia-base", - "xenia-ui", - "xenia-ui-vulkan", - }) - includedirs({ - project_root.."/third_party/Vulkan-Headers/include", - }) - files({ - "../window_demo.cc", - "vulkan_window_demo.cc", - project_root.."/src/xenia/ui/windowed_app_main_"..platform_suffix..".cc", - }) - resincludedirs({ - project_root, - }) - - filter("platforms:Linux") - links({ - "X11", - "xcb", - "X11-xcb", - }) -end \ No newline at end of file diff --git a/src/xenia/vfs/CMakeLists.txt b/src/xenia/vfs/CMakeLists.txt new file mode 100644 index 000000000..6fb0ee6fb --- /dev/null +++ b/src/xenia/vfs/CMakeLists.txt @@ -0,0 +1,31 @@ +add_library(xenia-vfs STATIC) +xe_platform_sources(xenia-vfs ${CMAKE_CURRENT_SOURCE_DIR} RECURSIVE) +# Exclude vfs_dump.cc +file(GLOB _vfs_dump "${CMAKE_CURRENT_SOURCE_DIR}/vfs_dump.cc") +get_target_property(_vfs_srcs xenia-vfs SOURCES) +if(_vfs_dump AND _vfs_srcs) + list(REMOVE_ITEM _vfs_srcs ${_vfs_dump}) + set_target_properties(xenia-vfs PROPERTIES SOURCES "${_vfs_srcs}") +endif() +target_link_libraries(xenia-vfs PUBLIC xenia-base zstd zarchive) +xe_target_defaults(xenia-vfs) + +if(XENIA_BUILD_MISC) + # VFS dump tool + add_executable(xenia-vfs-dump + ${CMAKE_CURRENT_SOURCE_DIR}/vfs_dump.cc + ) + if(WIN32) + target_sources(xenia-vfs-dump PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/console_app_main_win.cc) + else() + target_sources(xenia-vfs-dump PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/console_app_main_posix.cc) + endif() + target_link_libraries(xenia-vfs-dump PRIVATE fmt xenia-base xenia-vfs) + xe_target_defaults(xenia-vfs-dump) +endif() + +if(XENIA_BUILD_TESTS) + add_subdirectory(testing) +endif() diff --git a/src/xenia/vfs/premake5.lua b/src/xenia/vfs/premake5.lua deleted file mode 100644 index f857da693..000000000 --- a/src/xenia/vfs/premake5.lua +++ /dev/null @@ -1,42 +0,0 @@ -project_root = "../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-vfs") - uuid("395c8abd-4dc9-46ed-af7a-c2b9b68a3a98") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - "zstd", - "zarchive" - }) - - recursive_platform_files() - removefiles({ - "vfs_dump.cc", - }) - -if enableMiscSubprojects then - project("xenia-vfs-dump") - uuid("2EF270C7-41A8-4D0E-ACC5-59693A9CCE32") - kind("ConsoleApp") - language("C++") - links({ - "fmt", - "xenia-base", - "xenia-vfs", - }) - - files({ - "vfs_dump.cc", - project_root.."/src/xenia/base/console_app_main_"..platform_suffix..".cc", - }) - resincludedirs({ - project_root, - }) -end - -if enableTests then - include("testing") -end diff --git a/src/xenia/vfs/testing/CMakeLists.txt b/src/xenia/vfs/testing/CMakeLists.txt new file mode 100644 index 000000000..31ac711f3 --- /dev/null +++ b/src/xenia/vfs/testing/CMakeLists.txt @@ -0,0 +1,3 @@ +xe_test_suite(xenia-vfs-tests ${CMAKE_CURRENT_SOURCE_DIR} + LINKS xenia-vfs +) diff --git a/src/xenia/vfs/testing/premake5.lua b/src/xenia/vfs/testing/premake5.lua deleted file mode 100644 index d9cd89626..000000000 --- a/src/xenia/vfs/testing/premake5.lua +++ /dev/null @@ -1,8 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -test_suite("xenia-vfs-tests", project_root, ".", { - links = { - "xenia-vfs", - }, -}) diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt new file mode 100644 index 000000000..2b24479ae --- /dev/null +++ b/third_party/CMakeLists.txt @@ -0,0 +1,654 @@ +# third_party/CMakeLists.txt - All third-party library targets. + +# Suppress warnings for all third-party code. +if(MSVC) + add_compile_options(/W0) +else() + add_compile_options(-w) +endif() + +# ============================================================================== +# aes_128 +# ============================================================================== +add_library(aes_128 STATIC + aes_128/unroll/aes.c +) +target_include_directories(aes_128 PUBLIC aes_128) + +# ============================================================================== +# capstone +# ============================================================================== +add_library(capstone STATIC + capstone/cs.c + capstone/MCInst.c + capstone/MCInstrDesc.c + capstone/MCRegisterInfo.c + capstone/SStream.c + capstone/utils.c + capstone/Mapping.c +) +# Glob X86 arch files +file(GLOB _capstone_x86_c "capstone/arch/X86/*.c") +file(GLOB _capstone_x86_h "capstone/arch/X86/*.h") +file(GLOB _capstone_x86_inc "capstone/arch/X86/*.inc") +# Remove excluded files +list(FILTER _capstone_x86_c EXCLUDE REGEX "X86ATTInstPrinter\\.c$") +list(FILTER _capstone_x86_inc EXCLUDE REGEX "reduce\\.inc$") +target_sources(capstone PRIVATE ${_capstone_x86_c} ${_capstone_x86_h} ${_capstone_x86_inc}) +target_compile_definitions(capstone PRIVATE + CAPSTONE_X86_ATT_DISABLE + CAPSTONE_HAS_X86 + CAPSTONE_USE_SYS_DYN_MEM +) +target_include_directories(capstone PUBLIC capstone/include PRIVATE capstone) +# Force all capstone sources to compile as C +file(GLOB_RECURSE _capstone_all_c "capstone/*.c") +set_source_files_properties(${_capstone_all_c} PROPERTIES LANGUAGE C) + +# ============================================================================== +# cxxopts (header-only) +# ============================================================================== +add_library(cxxopts INTERFACE) +target_include_directories(cxxopts INTERFACE cxxopts/include) + +# ============================================================================== +# tomlplusplus (header-only) +# ============================================================================== +add_library(tomlplusplus INTERFACE) +target_include_directories(tomlplusplus INTERFACE tomlplusplus/include) + +# ============================================================================== +# dxbc +# ============================================================================== +add_library(dxbc STATIC + dxbc/DXBCChecksum.cpp +) +target_include_directories(dxbc PUBLIC dxbc) + +# ============================================================================== +# discord-rpc +# ============================================================================== +add_library(discord-rpc STATIC + discord-rpc/src/connection.h + discord-rpc/src/discord_rpc.cpp + discord-rpc/src/msg_queue.h + discord-rpc/src/rpc_connection.cpp + discord-rpc/src/rpc_connection.h + discord-rpc/src/serialization.cpp + discord-rpc/src/serialization.h +) +target_compile_definitions(discord-rpc PRIVATE RAPIDJSON_SSE42) +target_include_directories(discord-rpc PUBLIC discord-rpc/include PRIVATE rapidjson/include) +if(WIN32) + target_sources(discord-rpc PRIVATE + discord-rpc/src/connection_win.cpp + discord-rpc/src/discord_register_win.cpp + ) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_sources(discord-rpc PRIVATE + discord-rpc/src/connection_unix.cpp + discord-rpc/src/discord_register_linux.cpp + ) +endif() + +# ============================================================================== +# fmt +# ============================================================================== +add_library(fmt STATIC + fmt/src/format.cc + fmt/src/os.cc +) +target_include_directories(fmt PUBLIC fmt/include) + +# ============================================================================== +# glslang-spirv +# ============================================================================== +file(GLOB _glslang_spirv_cpp "glslang/SPIRV/*.cpp") +file(GLOB _glslang_spirv_h "glslang/SPIRV/*.h") +file(GLOB _glslang_spirv_hpp "glslang/SPIRV/*.hpp11") +list(FILTER _glslang_spirv_cpp EXCLUDE REGEX "GlslangToSpv\\.cpp$") +add_library(glslang-spirv STATIC + ${_glslang_spirv_cpp} + ${_glslang_spirv_h} + ${_glslang_spirv_hpp} + glslang/glslang/Include/visibility.h +) +target_include_directories(glslang-spirv PUBLIC glslang) + +# ============================================================================== +# imgui +# ============================================================================== +add_library(imgui STATIC + imgui/imgui.cpp + imgui/imgui_demo.cpp + imgui/imgui_draw.cpp + imgui/imgui_tables.cpp + imgui/imgui_widgets.cpp +) +target_include_directories(imgui PUBLIC imgui PRIVATE stb) + +# ============================================================================== +# mspack +# ============================================================================== +add_library(mspack STATIC + mspack/logging.cc + mspack/lzxd.c + mspack/system.c +) +target_compile_definitions(mspack PRIVATE HAVE_CONFIG_H) +target_include_directories(mspack PUBLIC mspack) +target_link_libraries(mspack PUBLIC xenia-base) + +# ============================================================================== +# pugixml +# ============================================================================== +add_library(pugixml STATIC + pugixml/src/pugixml.cpp +) +target_include_directories(pugixml PUBLIC pugixml/src) + +# ============================================================================== +# snappy +# ============================================================================== +# Generate snappy-stubs-public.h if missing +if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/snappy/snappy-stubs-public.h") + execute_process( + COMMAND ${CMAKE_COMMAND} + -DSNAPPY_BUILD_TESTS=OFF + -DSNAPPY_BUILD_BENCHMARKS=OFF + -DSNAPPY_REQUIRE_AVX=ON + ${CMAKE_CURRENT_SOURCE_DIR}/snappy + -B${CMAKE_CURRENT_SOURCE_DIR}/snappy + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) +endif() +add_library(snappy STATIC + snappy/snappy-internal.h + snappy/snappy-sinksource.cc + snappy/snappy-sinksource.h + snappy/snappy-stubs-internal.cc + snappy/snappy-stubs-internal.h + snappy/snappy-stubs-public.h + snappy/snappy.cc + snappy/snappy.h +) +target_include_directories(snappy PUBLIC snappy) + +# ============================================================================== +# xxhash +# ============================================================================== +add_library(xxhash STATIC + xxhash/xxhash.c +) +target_include_directories(xxhash PUBLIC xxhash) + +# ============================================================================== +# zstd +# ============================================================================== +file(GLOB_RECURSE _zstd_common "zstd/lib/common/*.c" "zstd/lib/common/*.h") +file(GLOB_RECURSE _zstd_compress "zstd/lib/compress/*.c" "zstd/lib/compress/*.h") +file(GLOB_RECURSE _zstd_decompress "zstd/lib/decompress/*.c" "zstd/lib/decompress/*.h") +add_library(zstd STATIC + zstd/lib/zstd.h + ${_zstd_common} + ${_zstd_compress} + ${_zstd_decompress} +) +target_include_directories(zstd PUBLIC zstd/lib PRIVATE zstd/lib/common) +target_compile_definitions(zstd PRIVATE + XXH_NAMESPACE=ZSTD_ + ZSTD_LEGACY_SUPPORT=0 +) +if(NOT MSVC) + target_compile_definitions(zstd PRIVATE ZSTD_DISABLE_ASM) +endif() + +# ============================================================================== +# zarchive +# ============================================================================== +add_library(zarchive STATIC + zarchive/include/zarchive/zarchivecommon.h + zarchive/include/zarchive/zarchivereader.h + zarchive/include/zarchive/zarchivewriter.h + zarchive/src/zarchivereader.cpp + zarchive/src/zarchivewriter.cpp + zarchive/src/sha_256.c + zarchive/src/sha_256.h +) +target_include_directories(zarchive PUBLIC zarchive/include PRIVATE zstd/lib) +target_link_libraries(zarchive PUBLIC zstd) + +# ============================================================================== +# zlib-ng +# ============================================================================== +# Generate headers if missing +set(_zlibng_needs_configure FALSE) +foreach(_hdr zlib-ng.h zconf-ng.h zlib_name_mangling-ng.h gzread.c) + if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/zlib-ng/${_hdr}") + set(_zlibng_needs_configure TRUE) + break() + endif() +endforeach() +if(_zlibng_needs_configure) + execute_process( + COMMAND ${CMAKE_COMMAND} + -DZLIB_ENABLE_TESTS=OFF + -DWITH_GTEST=OFF + ${CMAKE_CURRENT_SOURCE_DIR}/zlib-ng + -B${CMAKE_CURRENT_SOURCE_DIR}/zlib-ng + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) +endif() +file(GLOB _zlibng_c "zlib-ng/*.c") +file(GLOB _zlibng_x86 "zlib-ng/arch/x86/*.c") +file(GLOB _zlibng_generic "zlib-ng/arch/generic/*.c") +add_library(zlib-ng STATIC + ${_zlibng_c} + ${_zlibng_x86} + ${_zlibng_generic} +) +target_compile_definitions(zlib-ng PRIVATE + X86_FEATURES + X86_HAVE_XSAVE_INTRIN + X86_SSSE3 + X86_SSE42 + WITH_GZFILEOP +) +if(WIN32) + target_compile_definitions(zlib-ng PRIVATE + X86_SSE2 + X86_AVX2 + X86_AVX512 + X86_AVX512VNNI + X86_PCLMULQDQ_CRC + X86_VPCLMULQDQ_CRC + ) +else() + # Remove AVX2/AVX512 files on non-Windows + set(_zlibng_exclude_patterns + "adler32_avx2" "adler32_avx512" "adler32_avx512_vnni" + "chunkset_avx2" "compare256_avx2" + "crc32_pclmulqdq" "crc32_vpclmulqdq" + "slide_hash_avx2" + ) + foreach(_pat ${_zlibng_exclude_patterns}) + list(FILTER _zlibng_x86 EXCLUDE REGEX "${_pat}") + endforeach() + # Re-set sources without excluded files + get_target_property(_zlibng_srcs zlib-ng SOURCES) + set_target_properties(zlib-ng PROPERTIES SOURCES "") + target_sources(zlib-ng PRIVATE ${_zlibng_c} ${_zlibng_x86} ${_zlibng_generic}) +endif() +target_include_directories(zlib-ng PUBLIC zlib-ng) + +# ============================================================================== +# libusb (Windows only) +# ============================================================================== +if(WIN32) + add_library(libusb STATIC + libusb/libusb/core.c + libusb/libusb/descriptor.c + libusb/libusb/hotplug.c + libusb/libusb/io.c + libusb/libusb/strerror.c + libusb/libusb/sync.c + libusb/libusb/os/events_windows.c + libusb/libusb/os/events_windows.h + libusb/libusb/os/threads_windows.c + libusb/libusb/os/threads_windows.h + libusb/libusb/os/windows_common.c + libusb/libusb/os/windows_common.h + libusb/libusb/os/windows_usbdk.c + libusb/libusb/os/windows_usbdk.h + libusb/libusb/os/windows_winusb.c + libusb/libusb/os/windows_winusb.h + ) + target_include_directories(libusb PUBLIC libusb/libusb PRIVATE libusb/msvc) +endif() + +# ============================================================================== +# SDL2 +# ============================================================================== +if(WIN32) + # Build SDL2 from source on Windows + file(GLOB _sdl2_sources + "SDL2/src/*.c" + "SDL2/src/atomic/*.c" + "SDL2/src/audio/*.c" + "SDL2/src/audio/directsound/*.c" + "SDL2/src/audio/disk/*.c" + "SDL2/src/audio/dummy/*.c" + "SDL2/src/audio/wasapi/*.c" + "SDL2/src/audio/winmm/*.c" + "SDL2/src/core/windows/*.c" + "SDL2/src/cpuinfo/*.c" + "SDL2/src/dynapi/*.c" + "SDL2/src/events/*.c" + "SDL2/src/file/*.c" + "SDL2/src/filesystem/windows/*.c" + "SDL2/src/haptic/*.c" + "SDL2/src/haptic/dummy/*.c" + "SDL2/src/haptic/windows/*.c" + "SDL2/src/hidapi/*.c" + "SDL2/src/joystick/*.c" + "SDL2/src/joystick/dummy/*.c" + "SDL2/src/joystick/hidapi/*.c" + "SDL2/src/joystick/virtual/*.c" + "SDL2/src/joystick/windows/*.c" + "SDL2/src/libm/*.c" + "SDL2/src/loadso/windows/*.c" + "SDL2/src/locale/*.c" + "SDL2/src/locale/windows/*.c" + "SDL2/src/misc/*.c" + "SDL2/src/misc/windows/*.c" + "SDL2/src/power/*.c" + "SDL2/src/power/windows/*.c" + "SDL2/src/render/*.c" + "SDL2/src/render/direct3d/*.c" + "SDL2/src/render/direct3d11/*.c" + "SDL2/src/render/direct3d12/*.c" + "SDL2/src/render/opengl/*.c" + "SDL2/src/render/opengles2/*.c" + "SDL2/src/render/software/*.c" + "SDL2/src/sensor/*.c" + "SDL2/src/sensor/dummy/*.c" + "SDL2/src/sensor/windows/*.c" + "SDL2/src/stdlib/*.c" + "SDL2/src/thread/*.c" + "SDL2/src/thread/generic/SDL_syscond.c" + "SDL2/src/thread/windows/*.c" + "SDL2/src/timer/*.c" + "SDL2/src/timer/windows/*.c" + "SDL2/src/video/*.c" + "SDL2/src/video/dummy/*.c" + "SDL2/src/video/windows/*.c" + "SDL2/src/video/yuv2rgb/*.c" + ) + add_library(SDL2 STATIC ${_sdl2_sources}) + target_compile_definitions(SDL2 PRIVATE + HAVE_LIBC + SDL_LEAN_AND_MEAN + SDL_RENDER_DISABLED + ) + target_include_directories(SDL2 PUBLIC SDL2/include) + target_link_libraries(SDL2 PRIVATE setupapi winmm imm32 version) +else() + # Use system SDL2 on Linux + add_library(SDL2 INTERFACE) + find_package(PkgConfig REQUIRED) + pkg_check_modules(SDL2_PKG REQUIRED sdl2) + target_include_directories(SDL2 INTERFACE ${SDL2_PKG_INCLUDE_DIRS}) + target_link_libraries(SDL2 INTERFACE ${SDL2_PKG_LDFLAGS}) + target_compile_options(SDL2 INTERFACE ${SDL2_PKG_CFLAGS_OTHER}) +endif() + +# ============================================================================== +# FFmpeg (source in FFmpeg submodule, config overlay in ffmpeg-xenia) +# ============================================================================== + +# Common function to apply shared FFmpeg settings to a target. +function(ffmpeg_common target) + target_compile_definitions(${target} PRIVATE + HAVE_AV_CONFIG_H + _USE_MATH_DEFINES + ) + target_include_directories(${target} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg-xenia + ${CMAKE_CURRENT_SOURCE_DIR}/FFmpeg + ) + + if(WIN32) + target_include_directories(${target} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/FFmpeg/compat/atomics/win32 + ) + target_link_libraries(${target} PRIVATE bcrypt) + # Size optimization on Debug/Checked (dead code elimination is mandatory) + target_compile_options(${target} PRIVATE + $<$:/Os> + $<$:/Os> + ) + else() + target_include_directories(${target} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/FFmpeg/compat/atomics/gcc + ) + endif() + + # Suppress all warnings for FFmpeg code + if(MSVC) + target_compile_options(${target} PRIVATE /w) + else() + target_compile_options(${target} PRIVATE -w) + endif() + + # All FFmpeg source is C + set_target_properties(${target} PROPERTIES LINKER_LANGUAGE C) +endfunction() + +# --- libavutil --- +add_library(libavutil STATIC + FFmpeg/libavutil/adler32.c + FFmpeg/libavutil/aes.c + FFmpeg/libavutil/aes_ctr.c + FFmpeg/libavutil/audio_fifo.c + FFmpeg/libavutil/avstring.c + FFmpeg/libavutil/avsscanf.c + FFmpeg/libavutil/base64.c + FFmpeg/libavutil/blowfish.c + FFmpeg/libavutil/bprint.c + FFmpeg/libavutil/buffer.c + FFmpeg/libavutil/cast5.c + FFmpeg/libavutil/camellia.c + FFmpeg/libavutil/channel_layout.c + FFmpeg/libavutil/csp.c + FFmpeg/libavutil/cpu.c + FFmpeg/libavutil/crc.c + FFmpeg/libavutil/des.c + FFmpeg/libavutil/dict.c + FFmpeg/libavutil/display.c + FFmpeg/libavutil/dovi_meta.c + FFmpeg/libavutil/downmix_info.c + FFmpeg/libavutil/encryption_info.c + FFmpeg/libavutil/error.c + FFmpeg/libavutil/eval.c + FFmpeg/libavutil/fifo.c + FFmpeg/libavutil/file.c + FFmpeg/libavutil/file_open.c + FFmpeg/libavutil/float_dsp.c + FFmpeg/libavutil/fixed_dsp.c + FFmpeg/libavutil/frame.c + FFmpeg/libavutil/hash.c + FFmpeg/libavutil/hdr_dynamic_metadata.c + FFmpeg/libavutil/hmac.c + FFmpeg/libavutil/hwcontext.c + FFmpeg/libavutil/imgutils.c + FFmpeg/libavutil/integer.c + FFmpeg/libavutil/intmath.c + FFmpeg/libavutil/lfg.c + FFmpeg/libavutil/lls.c + FFmpeg/libavutil/log.c + FFmpeg/libavutil/log2_tab.c + FFmpeg/libavutil/mathematics.c + FFmpeg/libavutil/mastering_display_metadata.c + FFmpeg/libavutil/md5.c + FFmpeg/libavutil/mem.c + FFmpeg/libavutil/murmur3.c + FFmpeg/libavutil/opt.c + FFmpeg/libavutil/parseutils.c + FFmpeg/libavutil/pixdesc.c + FFmpeg/libavutil/pixelutils.c + FFmpeg/libavutil/random_seed.c + FFmpeg/libavutil/rational.c + FFmpeg/libavutil/reverse.c + FFmpeg/libavutil/rc4.c + FFmpeg/libavutil/ripemd.c + FFmpeg/libavutil/samplefmt.c + FFmpeg/libavutil/sha.c + FFmpeg/libavutil/sha512.c + FFmpeg/libavutil/slicethread.c + FFmpeg/libavutil/spherical.c + FFmpeg/libavutil/stereo3d.c + FFmpeg/libavutil/threadmessage.c + FFmpeg/libavutil/time.c + FFmpeg/libavutil/timecode.c + FFmpeg/libavutil/tree.c + FFmpeg/libavutil/twofish.c + FFmpeg/libavutil/utils.c + FFmpeg/libavutil/xga_font_data.c + FFmpeg/libavutil/xtea.c + FFmpeg/libavutil/tea.c + FFmpeg/libavutil/tx.c + FFmpeg/libavutil/tx_float.c + FFmpeg/libavutil/tx_double.c + FFmpeg/libavutil/tx_int32.c + FFmpeg/libavutil/video_enc_params.c + FFmpeg/libavutil/film_grain_params.c + FFmpeg/libavutil/side_data.c + FFmpeg/libavutil/refstruct.c + FFmpeg/libavutil/container_fifo.c + FFmpeg/libavutil/float_scalarproduct.c + FFmpeg/libavutil/timecode_internal.c + FFmpeg/libavutil/iamf.c + FFmpeg/libavutil/timestamp.c +) +# x86 platform files +if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|ARM64") + target_sources(libavutil PRIVATE + FFmpeg/libavutil/x86/cpu.c + FFmpeg/libavutil/x86/fixed_dsp_init.c + FFmpeg/libavutil/x86/float_dsp_init.c + FFmpeg/libavutil/x86/imgutils_init.c + FFmpeg/libavutil/x86/lls_init.c + FFmpeg/libavutil/x86/tx_float_init.c + ) +endif() +ffmpeg_common(libavutil) + +# --- libavcodec --- +add_library(libavcodec STATIC + FFmpeg/libavcodec/ac3_parser.c + FFmpeg/libavcodec/adts_parser.c + FFmpeg/libavcodec/allcodecs.c + FFmpeg/libavcodec/avcodec.c + FFmpeg/libavcodec/avdct.c + FFmpeg/libavcodec/packet.c + FFmpeg/libavcodec/bitstream.c + FFmpeg/libavcodec/bitstream_filters.c + FFmpeg/libavcodec/bsf.c + FFmpeg/libavcodec/codec_desc.c + FFmpeg/libavcodec/codec_par.c + FFmpeg/libavcodec/d3d11va.c + FFmpeg/libavcodec/decode.c + FFmpeg/libavcodec/dirac.c + FFmpeg/libavcodec/dv_profile.c + FFmpeg/libavcodec/encode.c + FFmpeg/libavcodec/imgconvert.c + FFmpeg/libavcodec/jni.c + FFmpeg/libavcodec/mathtables.c + FFmpeg/libavcodec/mediacodec.c + FFmpeg/libavcodec/mpeg12framerate.c + FFmpeg/libavcodec/options.c + FFmpeg/libavcodec/parser.c + FFmpeg/libavcodec/parsers.c + FFmpeg/libavcodec/profiles.c + FFmpeg/libavcodec/qsv_api.c + FFmpeg/libavcodec/raw.c + FFmpeg/libavcodec/utils.c + FFmpeg/libavcodec/vorbis_parser.c + FFmpeg/libavcodec/xiph.c + FFmpeg/libavcodec/dct32_fixed.c + FFmpeg/libavcodec/dct32_float.c + FFmpeg/libavcodec/faandct.c + FFmpeg/libavcodec/faanidct.c + FFmpeg/libavcodec/fdctdsp.c + FFmpeg/libavcodec/jfdctfst.c + FFmpeg/libavcodec/jfdctint.c + FFmpeg/libavcodec/idctdsp.c + FFmpeg/libavcodec/simple_idct.c + FFmpeg/libavcodec/jrevdct.c + FFmpeg/libavcodec/mpegaudio.c + FFmpeg/libavcodec/mpegaudiodec_common.c + FFmpeg/libavcodec/mpegaudiodsp.c + FFmpeg/libavcodec/mpegaudiodsp_data.c + FFmpeg/libavcodec/mpegaudiodsp_fixed.c + FFmpeg/libavcodec/mpegaudiodsp_float.c + FFmpeg/libavcodec/mpegaudiodecheader.c + FFmpeg/libavcodec/mpegaudiodata.c + FFmpeg/libavcodec/sinewin.c + FFmpeg/libavcodec/wma_freqs.c + FFmpeg/libavcodec/mpegaudiodec_fixed.c + FFmpeg/libavcodec/mpegaudiodec_float.c + FFmpeg/libavcodec/wmaprodec.c + FFmpeg/libavcodec/wma.c + FFmpeg/libavcodec/wma_common.c + FFmpeg/libavcodec/wmadec.c + FFmpeg/libavcodec/aactab.c + FFmpeg/libavcodec/mpegaudio_parser.c + FFmpeg/libavcodec/pthread.c + FFmpeg/libavcodec/pthread_slice.c + FFmpeg/libavcodec/pthread_frame.c + FFmpeg/libavcodec/get_buffer.c + FFmpeg/libavcodec/vlc.c + FFmpeg/libavcodec/threadprogress.c + FFmpeg/libavcodec/bsf/null.c + FFmpeg/libavcodec/exif.c + FFmpeg/libavcodec/mpegaudiotabs.c + FFmpeg/libavcodec/tiff_common.c +) +if(WIN32) + target_sources(libavcodec PRIVATE FFmpeg/libavcodec/file_open.c) +endif() +# x86 platform files +if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|ARM64") + target_sources(libavcodec PRIVATE + FFmpeg/libavcodec/x86/constants.c + FFmpeg/libavcodec/x86/fdctdsp_init.c + FFmpeg/libavcodec/x86/idctdsp_init.c + FFmpeg/libavcodec/x86/mpegaudiodsp.c + FFmpeg/libavcodec/x86/fdct.c + ) +endif() +target_include_directories(libavcodec PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/FFmpeg/libavcodec +) +target_link_libraries(libavcodec PRIVATE libavutil) +ffmpeg_common(libavcodec) + +# --- libavformat --- +add_library(libavformat STATIC + FFmpeg/libavformat/allformats.c + FFmpeg/libavformat/avio.c + FFmpeg/libavformat/aviobuf.c + FFmpeg/libavformat/dump.c + FFmpeg/libavformat/format.c + FFmpeg/libavformat/id3v1.c + FFmpeg/libavformat/id3v2.c + FFmpeg/libavformat/metadata.c + FFmpeg/libavformat/mux.c + FFmpeg/libavformat/options.c + FFmpeg/libavformat/os_support.c + FFmpeg/libavformat/protocols.c + FFmpeg/libavformat/riff.c + FFmpeg/libavformat/sdp.c + FFmpeg/libavformat/url.c + FFmpeg/libavformat/utils.c + FFmpeg/libavformat/riffdec.c + FFmpeg/libavformat/asfdec_f.c + FFmpeg/libavformat/asf.c + FFmpeg/libavformat/asfcrypt.c + FFmpeg/libavformat/avlanguage.c + FFmpeg/libavformat/mp3dec.c + FFmpeg/libavformat/replaygain.c + FFmpeg/libavformat/file.c + FFmpeg/libavformat/demux.c + FFmpeg/libavformat/avformat.c + FFmpeg/libavformat/seek.c + FFmpeg/libavformat/demux_utils.c + FFmpeg/libavformat/urldecode.c + FFmpeg/libavformat/asf_tags.c + FFmpeg/libavformat/to_upper4.c +) +if(WIN32) + target_sources(libavformat PRIVATE FFmpeg/libavformat/file_open.c) +endif() +target_link_libraries(libavformat PRIVATE libavutil libavcodec) +ffmpeg_common(libavformat) diff --git a/third_party/SDL2-static.lua b/third_party/SDL2-static.lua deleted file mode 100644 index 2598b90a9..000000000 --- a/third_party/SDL2-static.lua +++ /dev/null @@ -1,360 +0,0 @@ --- This project resembles the build configuration on Windows only. -group("third_party") -project("SDL2") - uuid("65878768-95A1-4E7B-8DFB-B23A09E0DE7C") - kind("StaticLib") - language("C") - - defines({ - "HAVE_LIBC", - "SDL_LEAN_AND_MEAN", - "SDL_RENDER_DISABLED", - }) - links({ - "setupapi.lib", - "winmm.lib", - "imm32.lib", - "version.lib", - }) - includedirs({ - "SDL2/include", - }) - files({ - -- 1:1 from SDL2/VisualC/SDL/SDL.vcxproj file - "SDL2/src/audio/directsound/SDL_directsound.h", - "SDL2/src/audio/disk/SDL_diskaudio.h", - "SDL2/src/audio/dummy/SDL_dummyaudio.h", - "SDL2/src/audio/SDL_audio_c.h", - "SDL2/src/audio/SDL_audiodev_c.h", - "SDL2/src/audio/SDL_sysaudio.h", - "SDL2/src/audio/SDL_wave.h", - "SDL2/src/audio/wasapi/SDL_wasapi.h", - "SDL2/src/audio/winmm/SDL_winmm.h", - "SDL2/src/core/windows/SDL_directx.h", - "SDL2/src/core/windows/SDL_hid.h", - "SDL2/src/core/windows/SDL_immdevice.h", - "SDL2/src/core/windows/SDL_windows.h", - "SDL2/src/core/windows/SDL_xinput.h", - "SDL2/src/dynapi/SDL_dynapi.h", - "SDL2/src/dynapi/SDL_dynapi_overrides.h", - "SDL2/src/dynapi/SDL_dynapi_procs.h", - "SDL2/src/events/blank_cursor.h", - "SDL2/src/events/default_cursor.h", - "SDL2/src/events/scancodes_windows.h", - "SDL2/src/events/SDL_clipboardevents_c.h", - "SDL2/src/events/SDL_displayevents_c.h", - "SDL2/src/events/SDL_dropevents_c.h", - "SDL2/src/events/SDL_events_c.h", - "SDL2/src/events/SDL_gesture_c.h", - "SDL2/src/events/SDL_keyboard_c.h", - "SDL2/src/events/SDL_mouse_c.h", - "SDL2/src/events/SDL_touch_c.h", - "SDL2/src/events/SDL_windowevents_c.h", - "SDL2/src/haptic/SDL_haptic_c.h", - "SDL2/src/haptic/SDL_syshaptic.h", - "SDL2/src/haptic/windows/SDL_dinputhaptic_c.h", - "SDL2/src/haptic/windows/SDL_windowshaptic_c.h", - "SDL2/src/haptic/windows/SDL_xinputhaptic_c.h", - "SDL2/src/hidapi/hidapi/hidapi.h", - "SDL2/src/hidapi/SDL_hidapi_c.h", - "SDL2/src/joystick/controller_type.h", - "SDL2/src/joystick/hidapi/SDL_hidapijoystick_c.h", - "SDL2/src/joystick/hidapi/SDL_hidapi_rumble.h", - "SDL2/src/joystick/SDL_gamecontrollerdb.h", - "SDL2/src/joystick/SDL_joystick_c.h", - "SDL2/src/joystick/SDL_steam_virtual_gamepad.h", - "SDL2/src/joystick/SDL_sysjoystick.h", - "SDL2/src/joystick/usb_ids.h", - "SDL2/src/joystick/virtual/SDL_virtualjoystick_c.h", - "SDL2/src/joystick/windows/SDL_dinputjoystick_c.h", - "SDL2/src/joystick/windows/SDL_rawinputjoystick_c.h", - "SDL2/src/joystick/windows/SDL_windowsjoystick_c.h", - "SDL2/src/joystick/windows/SDL_xinputjoystick_c.h", - "SDL2/src/libm/math_libm.h", - "SDL2/src/libm/math_private.h", - "SDL2/src/locale/SDL_syslocale.h", - "SDL2/src/misc/SDL_sysurl.h", - "SDL2/src/power/SDL_syspower.h", - "SDL2/src/render/direct3d11/SDL_shaders_d3d11.h", - "SDL2/src/render/direct3d12/SDL_shaders_d3d12.h", - "SDL2/src/render/direct3d/SDL_shaders_d3d.h", - "SDL2/src/render/opengles2/SDL_gles2funcs.h", - "SDL2/src/render/opengles2/SDL_shaders_gles2.h", - "SDL2/src/render/opengl/SDL_glfuncs.h", - "SDL2/src/render/opengl/SDL_shaders_gl.h", - "SDL2/src/render/SDL_d3dmath.h", - "SDL2/src/render/SDL_sysrender.h", - "SDL2/src/render/SDL_yuv_sw_c.h", - "SDL2/src/render/software/SDL_blendfillrect.h", - "SDL2/src/render/software/SDL_blendline.h", - "SDL2/src/render/software/SDL_blendpoint.h", - "SDL2/src/render/software/SDL_draw.h", - "SDL2/src/render/software/SDL_drawline.h", - "SDL2/src/render/software/SDL_drawpoint.h", - "SDL2/src/render/software/SDL_render_sw_c.h", - "SDL2/src/render/software/SDL_rotate.h", - "SDL2/src/render/software/SDL_triangle.h", - "SDL2/src/SDL_assert_c.h", - "SDL2/src/SDL_dataqueue.h", - "SDL2/src/SDL_error_c.h", - "SDL2/src/SDL_guid.c", - "SDL2/src/SDL_hints_c.h", - "SDL2/src/SDL_internal.h", - "SDL2/src/SDL_list.h", - "SDL2/src/SDL_log_c.h", - "SDL2/src/sensor/dummy/SDL_dummysensor.h", - "SDL2/src/sensor/SDL_sensor_c.h", - "SDL2/src/sensor/SDL_syssensor.h", - "SDL2/src/sensor/windows/SDL_windowssensor.h", - "SDL2/src/thread/SDL_systhread.h", - "SDL2/src/thread/SDL_thread_c.h", - "SDL2/src/thread/generic/SDL_syscond_c.h", - "SDL2/src/thread/windows/SDL_sysmutex_c.h", - "SDL2/src/thread/windows/SDL_systhread_c.h", - "SDL2/src/timer/SDL_timer_c.h", - "SDL2/src/video/dummy/SDL_nullevents_c.h", - "SDL2/src/video/dummy/SDL_nullframebuffer_c.h", - "SDL2/src/video/dummy/SDL_nullvideo.h", - "SDL2/src/video/khronos/vulkan/vk_icd.h", - "SDL2/src/video/khronos/vulkan/vk_layer.h", - "SDL2/src/video/khronos/vulkan/vk_platform.h", - "SDL2/src/video/khronos/vulkan/vk_sdk_platform.h", - "SDL2/src/video/khronos/vulkan/vulkan.h", - "SDL2/src/video/khronos/vulkan/vulkan_android.h", - "SDL2/src/video/khronos/vulkan/vulkan_beta.h", - "SDL2/src/video/khronos/vulkan/vulkan_core.h", - "SDL2/src/video/khronos/vulkan/vulkan_directfb.h", - "SDL2/src/video/khronos/vulkan/vulkan_fuchsia.h", - "SDL2/src/video/khronos/vulkan/vulkan_ggp.h", - "SDL2/src/video/khronos/vulkan/vulkan_ios.h", - "SDL2/src/video/khronos/vulkan/vulkan_macos.h", - "SDL2/src/video/khronos/vulkan/vulkan_metal.h", - "SDL2/src/video/khronos/vulkan/vulkan_vi.h", - "SDL2/src/video/khronos/vulkan/vulkan_wayland.h", - "SDL2/src/video/khronos/vulkan/vulkan_win32.h", - "SDL2/src/video/khronos/vulkan/vulkan_xcb.h", - "SDL2/src/video/khronos/vulkan/vulkan_xlib.h", - "SDL2/src/video/khronos/vulkan/vulkan_xlib_xrandr.h", - "SDL2/src/video/SDL_blit.h", - "SDL2/src/video/SDL_blit_auto.h", - "SDL2/src/video/SDL_blit_copy.h", - "SDL2/src/video/SDL_blit_slow.h", - "SDL2/src/video/SDL_egl_c.h", - "SDL2/src/video/SDL_pixels_c.h", - "SDL2/src/video/SDL_rect_c.h", - "SDL2/src/video/SDL_RLEaccel_c.h", - "SDL2/src/video/SDL_shape_internals.h", - "SDL2/src/video/SDL_sysvideo.h", - "SDL2/src/video/SDL_vulkan_internal.h", - "SDL2/src/video/SDL_yuv_c.h", - "SDL2/src/video/windows/SDL_msctf.h", - "SDL2/src/video/windows/SDL_vkeys.h", - "SDL2/src/video/windows/SDL_windowsclipboard.h", - "SDL2/src/video/windows/SDL_windowsevents.h", - "SDL2/src/video/windows/SDL_windowsframebuffer.h", - "SDL2/src/video/windows/SDL_windowskeyboard.h", - "SDL2/src/video/windows/SDL_windowsmessagebox.h", - "SDL2/src/video/windows/SDL_windowsmodes.h", - "SDL2/src/video/windows/SDL_windowsmouse.h", - "SDL2/src/video/windows/SDL_windowsopengl.h", - "SDL2/src/video/windows/SDL_windowsopengles.h", - "SDL2/src/video/windows/SDL_windowsshape.h", - "SDL2/src/video/windows/SDL_windowsvideo.h", - "SDL2/src/video/windows/SDL_windowsvulkan.h", - "SDL2/src/video/windows/SDL_windowswindow.h", - "SDL2/src/video/windows/wmmsg.h", - "SDL2/src/video/yuv2rgb/yuv_rgb.h", - "SDL2/src/video/yuv2rgb/yuv_rgb_common.h", - "SDL2/src/video/yuv2rgb/yuv_rgb_internal.h", - "SDL2/src/video/yuv2rgb/yuv_rgb_lsx.h", - "SDL2/src/video/yuv2rgb/yuv_rgb_lsx_func.h", - "SDL2/src/video/yuv2rgb/yuv_rgb_sse.h", - "SDL2/src/video/yuv2rgb/yuv_rgb_sse_func.h", - "SDL2/src/video/yuv2rgb/yuv_rgb_std.h", - "SDL2/src/video/yuv2rgb/yuv_rgb_std_func.h", - - "SDL2/src/atomic/SDL_atomic.c", - "SDL2/src/atomic/SDL_spinlock.c", - "SDL2/src/audio/directsound/SDL_directsound.c", - "SDL2/src/audio/disk/SDL_diskaudio.c", - "SDL2/src/audio/dummy/SDL_dummyaudio.c", - "SDL2/src/audio/SDL_audio.c", - "SDL2/src/audio/SDL_audiocvt.c", - "SDL2/src/audio/SDL_audiodev.c", - "SDL2/src/audio/SDL_audiotypecvt.c", - "SDL2/src/audio/SDL_mixer.c", - "SDL2/src/audio/SDL_wave.c", - "SDL2/src/audio/winmm/SDL_winmm.c", - "SDL2/src/audio/wasapi/SDL_wasapi.c", - "SDL2/src/audio/wasapi/SDL_wasapi_win32.c", - "SDL2/src/core/windows/SDL_hid.c", - "SDL2/src/core/windows/SDL_immdevice.c", - "SDL2/src/core/windows/SDL_windows.c", - "SDL2/src/core/windows/SDL_xinput.c", - "SDL2/src/cpuinfo/SDL_cpuinfo.c", - "SDL2/src/dynapi/SDL_dynapi.c", - "SDL2/src/events/SDL_clipboardevents.c", - "SDL2/src/events/SDL_displayevents.c", - "SDL2/src/events/SDL_dropevents.c", - "SDL2/src/events/SDL_events.c", - "SDL2/src/events/SDL_gesture.c", - "SDL2/src/events/SDL_keyboard.c", - "SDL2/src/events/SDL_mouse.c", - "SDL2/src/events/SDL_quit.c", - "SDL2/src/events/SDL_touch.c", - "SDL2/src/events/SDL_windowevents.c", - "SDL2/src/file/SDL_rwops.c", - "SDL2/src/filesystem/windows/SDL_sysfilesystem.c", - "SDL2/src/haptic/dummy/SDL_syshaptic.c", - "SDL2/src/haptic/SDL_haptic.c", - "SDL2/src/haptic/windows/SDL_dinputhaptic.c", - "SDL2/src/haptic/windows/SDL_windowshaptic.c", - "SDL2/src/haptic/windows/SDL_xinputhaptic.c", - "SDL2/src/hidapi/SDL_hidapi.c", - "SDL2/src/joystick/controller_type.c", - "SDL2/src/joystick/dummy/SDL_sysjoystick.c", - "SDL2/src/joystick/hidapi/SDL_hidapijoystick.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_combined.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_gamecube.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_luna.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_ps3.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_ps4.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_ps5.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_rumble.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_shield.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_stadia.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_steam.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_steamdeck.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_switch.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_wii.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_xbox360.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_xbox360w.c", - "SDL2/src/joystick/hidapi/SDL_hidapi_xboxone.c", - "SDL2/src/joystick/SDL_gamecontroller.c", - "SDL2/src/joystick/SDL_joystick.c", - "SDL2/src/joystick/SDL_steam_virtual_gamepad.c", - "SDL2/src/joystick/virtual/SDL_virtualjoystick.c", - "SDL2/src/joystick/windows/SDL_dinputjoystick.c", - "SDL2/src/joystick/windows/SDL_rawinputjoystick.c", - "SDL2/src/joystick/windows/SDL_windowsjoystick.c", - "SDL2/src/joystick/windows/SDL_windows_gaming_input.c", - "SDL2/src/joystick/windows/SDL_xinputjoystick.c", - "SDL2/src/libm/e_atan2.c", - "SDL2/src/libm/e_exp.c", - "SDL2/src/libm/e_fmod.c", - "SDL2/src/libm/e_log.c", - "SDL2/src/libm/e_log10.c", - "SDL2/src/libm/e_pow.c", - "SDL2/src/libm/e_rem_pio2.c", - "SDL2/src/libm/e_sqrt.c", - "SDL2/src/libm/k_cos.c", - "SDL2/src/libm/k_rem_pio2.c", - "SDL2/src/libm/k_sin.c", - "SDL2/src/libm/k_tan.c", - "SDL2/src/libm/s_atan.c", - "SDL2/src/libm/s_copysign.c", - "SDL2/src/libm/s_cos.c", - "SDL2/src/libm/s_fabs.c", - "SDL2/src/libm/s_floor.c", - "SDL2/src/libm/s_scalbn.c", - "SDL2/src/libm/s_sin.c", - "SDL2/src/libm/s_tan.c", - "SDL2/src/loadso/windows/SDL_sysloadso.c", - "SDL2/src/locale/SDL_locale.c", - "SDL2/src/locale/windows/SDL_syslocale.c", - "SDL2/src/misc/SDL_url.c", - "SDL2/src/misc/windows/SDL_sysurl.c", - "SDL2/src/power/SDL_power.c", - "SDL2/src/power/windows/SDL_syspower.c", - "SDL2/src/render/direct3d11/SDL_shaders_d3d11.c", - "SDL2/src/render/direct3d12/SDL_render_d3d12.c", - "SDL2/src/render/direct3d12/SDL_shaders_d3d12.c", - "SDL2/src/render/direct3d/SDL_render_d3d.c", - "SDL2/src/render/direct3d11/SDL_render_d3d11.c", - "SDL2/src/render/direct3d/SDL_shaders_d3d.c", - "SDL2/src/render/opengl/SDL_render_gl.c", - "SDL2/src/render/opengl/SDL_shaders_gl.c", - "SDL2/src/render/opengles2/SDL_render_gles2.c", - "SDL2/src/render/opengles2/SDL_shaders_gles2.c", - "SDL2/src/render/SDL_d3dmath.c", - "SDL2/src/render/SDL_render.c", - "SDL2/src/render/SDL_yuv_sw.c", - "SDL2/src/render/software/SDL_blendfillrect.c", - "SDL2/src/render/software/SDL_blendline.c", - "SDL2/src/render/software/SDL_blendpoint.c", - "SDL2/src/render/software/SDL_drawline.c", - "SDL2/src/render/software/SDL_drawpoint.c", - "SDL2/src/render/software/SDL_render_sw.c", - "SDL2/src/render/software/SDL_rotate.c", - "SDL2/src/render/software/SDL_triangle.c", - "SDL2/src/SDL.c", - "SDL2/src/SDL_assert.c", - "SDL2/src/SDL_dataqueue.c", - "SDL2/src/SDL_list.c", - "SDL2/src/SDL_error.c", - "SDL2/src/SDL_hints.c", - "SDL2/src/SDL_log.c", - "SDL2/src/SDL_utils.c", - "SDL2/src/sensor/dummy/SDL_dummysensor.c", - "SDL2/src/sensor/SDL_sensor.c", - "SDL2/src/sensor/windows/SDL_windowssensor.c", - "SDL2/src/stdlib/SDL_crc16.c", - "SDL2/src/stdlib/SDL_crc32.c", - "SDL2/src/stdlib/SDL_getenv.c", - "SDL2/src/stdlib/SDL_iconv.c", - "SDL2/src/stdlib/SDL_malloc.c", - "SDL2/src/stdlib/SDL_mslibc.c", - "SDL2/src/stdlib/SDL_qsort.c", - "SDL2/src/stdlib/SDL_stdlib.c", - "SDL2/src/stdlib/SDL_string.c", - "SDL2/src/stdlib/SDL_strtokr.c", - "SDL2/src/thread/generic/SDL_syscond.c", - "SDL2/src/thread/SDL_thread.c", - "SDL2/src/thread/windows/SDL_syscond_cv.c", - "SDL2/src/thread/windows/SDL_sysmutex.c", - "SDL2/src/thread/windows/SDL_syssem.c", - "SDL2/src/thread/windows/SDL_systhread.c", - "SDL2/src/thread/windows/SDL_systls.c", - "SDL2/src/timer/SDL_timer.c", - "SDL2/src/timer/windows/SDL_systimer.c", - "SDL2/src/video/dummy/SDL_nullevents.c", - "SDL2/src/video/dummy/SDL_nullframebuffer.c", - "SDL2/src/video/dummy/SDL_nullvideo.c", - "SDL2/src/video/SDL_blit.c", - "SDL2/src/video/SDL_blit_0.c", - "SDL2/src/video/SDL_blit_1.c", - "SDL2/src/video/SDL_blit_A.c", - "SDL2/src/video/SDL_blit_auto.c", - "SDL2/src/video/SDL_blit_copy.c", - "SDL2/src/video/SDL_blit_N.c", - "SDL2/src/video/SDL_blit_slow.c", - "SDL2/src/video/SDL_bmp.c", - "SDL2/src/video/SDL_clipboard.c", - "SDL2/src/video/SDL_egl.c", - "SDL2/src/video/SDL_fillrect.c", - "SDL2/src/video/SDL_pixels.c", - "SDL2/src/video/SDL_rect.c", - "SDL2/src/video/SDL_RLEaccel.c", - "SDL2/src/video/SDL_shape.c", - "SDL2/src/video/SDL_stretch.c", - "SDL2/src/video/SDL_surface.c", - "SDL2/src/video/SDL_video.c", - "SDL2/src/video/SDL_vulkan_utils.c", - "SDL2/src/video/SDL_yuv.c", - "SDL2/src/video/windows/SDL_windowsclipboard.c", - "SDL2/src/video/windows/SDL_windowsevents.c", - "SDL2/src/video/windows/SDL_windowsframebuffer.c", - "SDL2/src/video/windows/SDL_windowskeyboard.c", - "SDL2/src/video/windows/SDL_windowsmessagebox.c", - "SDL2/src/video/windows/SDL_windowsmodes.c", - "SDL2/src/video/windows/SDL_windowsmouse.c", - "SDL2/src/video/windows/SDL_windowsopengl.c", - "SDL2/src/video/windows/SDL_windowsopengles.c", - "SDL2/src/video/windows/SDL_windowsshape.c", - "SDL2/src/video/windows/SDL_windowsvideo.c", - "SDL2/src/video/windows/SDL_windowsvulkan.c", - "SDL2/src/video/windows/SDL_windowswindow.c", - "SDL2/src/video/yuv2rgb/yuv_rgb_lsx.c", - "SDL2/src/video/yuv2rgb/yuv_rgb_sse.c", - "SDL2/src/video/yuv2rgb/yuv_rgb_std.c", - }) diff --git a/third_party/SDL2.lua b/third_party/SDL2.lua deleted file mode 100644 index 972aa1aa7..000000000 --- a/third_party/SDL2.lua +++ /dev/null @@ -1,36 +0,0 @@ --- --- On Linux we build against the system version (libsdl2-dev for building), --- since SDL2 is our robust API there like DirectX is on Windows. --- - -local sdl2_sys_includedirs = {} -local third_party_path = os.getcwd() - -if os.istarget("windows") then - -- build ourselves - include("SDL2-static.lua") -else - -- use system libraries - local result, code, what = os.outputof("sdl2-config --cflags") - if result then - for inc in string.gmatch(result, "-I([%S]+)") do - table.insert(sdl2_sys_includedirs, inc) - end - else - error("Failed to run 'sdl2-config'. Are libsdl2 development files installed?") - end -end - - --- --- Call this function in project scope to include the SDL2 headers. --- -function sdl2_include() - filter("platforms:Windows") - includedirs({ - path.getrelative(".", third_party_path) .. "/SDL2/include", - }) - filter("platforms:Linux or platforms:Mac") - includedirs(sdl2_sys_includedirs) - filter({}) -end diff --git a/third_party/aes_128.lua b/third_party/aes_128.lua deleted file mode 100644 index d53f66eaa..000000000 --- a/third_party/aes_128.lua +++ /dev/null @@ -1,11 +0,0 @@ -group("third_party") -project("aes_128") - uuid("b50458bf-dd83-4c1a-8cad-61f5fbbfd720") - kind("StaticLib") - language("C") - includedirs({ - "aes_128", - }) - files({ - "aes_128/unroll/aes.c", - }) diff --git a/third_party/capstone.lua b/third_party/capstone.lua deleted file mode 100644 index ee8aea191..000000000 --- a/third_party/capstone.lua +++ /dev/null @@ -1,36 +0,0 @@ -group("third_party") -project("capstone") - uuid("b3a89f7e-bb02-4945-ae75-219caed6afa2") - kind("StaticLib") - language("C") - defines({ - "CAPSTONE_X86_ATT_DISABLE", - "CAPSTONE_HAS_X86", - "CAPSTONE_USE_SYS_DYN_MEM", - }) - - includedirs({ - "capstone", - "capstone/include", - }) - files({ - "capstone/cs.c", - "capstone/MCInst.c", - "capstone/MCInstrDesc.c", - "capstone/MCRegisterInfo.c", - "capstone/SStream.c", - "capstone/utils.c", - "capstone/Mapping.c", - - "capstone/arch/X86/*.c", - "capstone/arch/X86/*.h", - "capstone/arch/X86/*.inc", - }) - force_compile_as_c({ - "capstone/**.c", - "capstone/arch/X86/**.c", - }) - removefiles({ - "capstone/arch/X86/X86ATTInstPrinter.c", - "capstone/arch/X86/*reduce.inc", - }) diff --git a/third_party/cxxopts.lua b/third_party/cxxopts.lua deleted file mode 100644 index a54899457..000000000 --- a/third_party/cxxopts.lua +++ /dev/null @@ -1,14 +0,0 @@ -group("third_party") -project("cxxopts") - uuid("8b68cbe8-2da4-4f28-be14-9352eafa3168") - if os.istarget("android") then - -- ndk-build only supports StaticLib and SharedLib. - kind("StaticLib") - else - kind("Utility") - end - language("C++") - files({ - "cxxopts/include/cxxopts.hpp", - }) - warnings("Off") diff --git a/third_party/discord-rpc.lua b/third_party/discord-rpc.lua deleted file mode 100644 index 52776718b..000000000 --- a/third_party/discord-rpc.lua +++ /dev/null @@ -1,36 +0,0 @@ -group("third_party") -project("discord-rpc") - uuid("012f6131-efc0-4abd-852d-a33640732d4c") - kind("StaticLib") - language("C++") - defines({ - "RAPIDJSON_SSE42", - -- "RAPIDJSON_NEON", - }) - includedirs({ - "discord-rpc/include", - "rapidjson/include" - }) - files({ - "discord-rpc/src/connection.h", - "discord-rpc/src/discord_rpc.cpp", - "discord-rpc/src/msg_queue.h", - "discord-rpc/src/rpc_connection.cpp", - "discord-rpc/src/rpc_connection.h", - "discord-rpc/src/serialization.cpp", - "discord-rpc/src/serialization.h" - }) - filter("platforms:Linux") - files({ - "discord-rpc/src/connection_unix.cpp", - "discord-rpc/src/discord_register_linux.cpp" - }) - filter("platforms:Mac") - files({ - "discord-rpc/src/discord_register_osx.m" - }) - filter("platforms:Windows") - files({ - "discord-rpc/src/connection_win.cpp", - "discord-rpc/src/discord_register_win.cpp" - }) diff --git a/third_party/dxbc.lua b/third_party/dxbc.lua deleted file mode 100644 index 83f48eb1a..000000000 --- a/third_party/dxbc.lua +++ /dev/null @@ -1,11 +0,0 @@ -group("third_party") -project("dxbc") - uuid("c96688ca-51ca-406e-aeef-068734a67abe") - kind("StaticLib") - language("C++") - includedirs({ - "dxbc", - }) - files({ - "dxbc/DXBCChecksum.cpp", - }) diff --git a/third_party/ffmpeg-xenia/premake5.lua b/third_party/ffmpeg-xenia/premake5.lua deleted file mode 100644 index dd5c773bb..000000000 --- a/third_party/ffmpeg-xenia/premake5.lua +++ /dev/null @@ -1,42 +0,0 @@ -group("third_party") - --- --- Call this function in subproject scope to set the needed include --- dirs and defines. --- -function ffmpeg_common() - defines({ - "HAVE_AV_CONFIG_H", - "_USE_MATH_DEFINES", -- For M_PI/etc - }) - - -- Paths are relative to the calling script (sub-library premake files), - -- which are one level deeper (e.g. libavcodec/premake5.lua). - includedirs({ - "..", -- ffmpeg-xenia/ (config.h, avconfig.h, ffversion.h) - "../../FFmpeg", -- FFmpeg source headers - }) - filter({"platforms:Windows", "configurations:Debug or configurations:Checked"}) - optimize("Size") -- dead code elimination is mandatory - removebuildoptions({ - "/RTCsu", -- '/O1' and '/RTCs' command-line options are incompatible - }) - filter({"platforms:Windows", "configurations:Release"}) - linktimeoptimization("Off") - filter("platforms:Windows") - includedirs({ - "../../FFmpeg/compat/atomics/win32", - }) - links({ - "bcrypt", - }) - filter("platforms:Linux") - includedirs({ - "../../FFmpeg/compat/atomics/gcc", - }) - filter({}) -end - -include("libavcodec/premake5.lua") -include("libavformat/premake5.lua") -include("libavutil/premake5.lua") diff --git a/third_party/fmt.lua b/third_party/fmt.lua deleted file mode 100644 index 1be2a91bf..000000000 --- a/third_party/fmt.lua +++ /dev/null @@ -1,13 +0,0 @@ -group("third_party") -project("fmt") - uuid("b9ff4b2c-b438-42a9-971e-e0c19a711a13") - kind("StaticLib") - language("C++") - - includedirs({ - "fmt/include", - }) - files({ - "fmt/src/format.cc", - "fmt/src/os.cc" - }) diff --git a/third_party/glslang-spirv.lua b/third_party/glslang-spirv.lua deleted file mode 100644 index 80811444b..000000000 --- a/third_party/glslang-spirv.lua +++ /dev/null @@ -1,20 +0,0 @@ -group("third_party") -project("glslang-spirv") - uuid("1cc8f45e-91e2-4daf-a55e-666bf8b5e6b2") - kind("StaticLib") - language("C++") - - includedirs({ - "glslang", - }) - - files({ - "glslang/SPIRV/*.cpp", - "glslang/SPIRV/*.h", - "glslang/SPIRV/*.hpp11", - "glslang/glslang/Include/visibility.h", - }) - - removefiles({ - "glslang/SPIRV/GlslangToSpv.cpp", - }) diff --git a/third_party/imgui.lua b/third_party/imgui.lua deleted file mode 100644 index 410f93579..000000000 --- a/third_party/imgui.lua +++ /dev/null @@ -1,19 +0,0 @@ -group("third_party") -project("imgui") - uuid("ed9271c4-b0a1-42ef-8403-067b11bf49d0") - kind("StaticLib") - language("C++") - includedirs({ - "imgui", - --"imgui/misc/freetype", - --"freetype/include", - "stb", - }) - files({ - "imgui/imgui.cpp", - "imgui/imgui_demo.cpp", - "imgui/imgui_draw.cpp", - "imgui/imgui_tables.cpp", - "imgui/imgui_widgets.cpp", - --"imgui/misc/freetype/imgui_freetype.cpp", - }) diff --git a/third_party/libusb.lua b/third_party/libusb.lua deleted file mode 100644 index d053b8cb6..000000000 --- a/third_party/libusb.lua +++ /dev/null @@ -1,47 +0,0 @@ -group("third_party") -project("libusb") - uuid("5f8b5485-fde5-4a42-8a13-8545fcf6d25b") - kind("StaticLib") - language("C") - includedirs({ - "libusb/libusb", - }) - - files({ - "libusb/libusb/core.c", - "libusb/libusb/descriptor.c", - "libusb/libusb/hotplug.c", - "libusb/libusb/io.c", - "libusb/libusb/strerror.c", - "libusb/libusb/sync.c", - }) - - filter({"platforms:Windows"}) - includedirs({ - "libusb/msvc", - }) - files({ - "libusb/libusb/os/events_windows.c", - "libusb/libusb/os/events_windows.h", - "libusb/libusb/os/threads_windows.c", - "libusb/libusb/os/threads_windows.h", - "libusb/libusb/os/windows_common.c", - "libusb/libusb/os/windows_common.h", - "libusb/libusb/os/windows_usbdk.c", - "libusb/libusb/os/windows_usbdk.h", - "libusb/libusb/os/windows_winusb.c", - "libusb/libusb/os/windows_winusb.h" - }) - - filter({"platforms:Linux"}) - files({ - "libusb/libusb/config.h", - "libusb/libusb/os/events_posix.c", - "libusb/libusb/os/events_posix.h", - "libusb/libusb/os/threads_posix.c", - "libusb/libusb/os/threads_posix.h", - "libusb/libusb/os/linux_netlink.c", - "libusb/libusb/os/linux_udev.c", - "libusb/libusb/os/linux_usbfs.c", - "libusb/libusb/os/linux_usbfs.h" - }) diff --git a/third_party/mspack.lua b/third_party/mspack.lua deleted file mode 100644 index 862ad71d0..000000000 --- a/third_party/mspack.lua +++ /dev/null @@ -1,19 +0,0 @@ -group("third_party") -project("mspack") - uuid("0881692A-75A1-4E7B-87D8-BB9108CEDEA4") - kind("StaticLib") - language("C++") - links({ - "xenia-base", - }) - defines({ - "HAVE_CONFIG_H", - }) - includedirs({ - "mspack", - }) - files({ - "mspack/logging.cc", - "mspack/lzxd.c", - "mspack/system.c", - }) diff --git a/third_party/pugixml.lua b/third_party/pugixml.lua deleted file mode 100644 index 4b7f97a1b..000000000 --- a/third_party/pugixml.lua +++ /dev/null @@ -1,8 +0,0 @@ -group("third_party") -project("pugixml") - uuid("d1089e5e-46ae-48c9-bee6-d38c674c8f61") - kind("StaticLib") - language("C++") - files({ - "pugixml/src/pugixml.cpp", - }) diff --git a/third_party/snappy.lua b/third_party/snappy.lua deleted file mode 100644 index 2d338362b..000000000 --- a/third_party/snappy.lua +++ /dev/null @@ -1,23 +0,0 @@ -group("third_party") -project("snappy") - uuid("bb143d61-3fd4-44c2-8b7e-04cc538ba2c7") - kind("StaticLib") - language("C++") - - files({ - "snappy/snappy-internal.h", - "snappy/snappy-sinksource.cc", - "snappy/snappy-sinksource.h", - "snappy/snappy-stubs-internal.cc", - "snappy/snappy-stubs-internal.h", - "snappy/snappy-stubs-public.h", - "snappy/snappy.cc", - "snappy/snappy.h", - }) - - local snappy_dir = path.getabsolute("snappy") - if not os.isfile(path.join(snappy_dir, "snappy-stubs-public.h")) then - prebuildcommands({ - "cmake -DSNAPPY_BUILD_TESTS=OFF -DSNAPPY_BUILD_BENCHMARKS=OFF -DSNAPPY_REQUIRE_AVX=ON "..snappy_dir.." -B"..snappy_dir - }) - end diff --git a/third_party/tomlplusplus.lua b/third_party/tomlplusplus.lua deleted file mode 100644 index 25860b01c..000000000 --- a/third_party/tomlplusplus.lua +++ /dev/null @@ -1,13 +0,0 @@ -group("third_party") -project("tomlplusplus") - uuid("1e86cc51-3f8b-476d-9249-3b200424846b") - if os.istarget("android") then - -- ndk-build only supports StaticLib and SharedLib. - kind("StaticLib") - else - kind("Utility") - end - language("C++") - files({ - "tomlplusplus/include/toml++/toml.hpp" - }) diff --git a/third_party/xxhash.lua b/third_party/xxhash.lua deleted file mode 100644 index a6bb1f873..000000000 --- a/third_party/xxhash.lua +++ /dev/null @@ -1,11 +0,0 @@ -group("third_party") -project("xxhash") - uuid("40d4ce21-5448-4399-9f98-589b7e1c23b1") - kind("StaticLib") - language("C") - includedirs({ - "xxhash", - }) - files({ - "xxhash/xxhash.c", - }) diff --git a/third_party/zarchive.lua b/third_party/zarchive.lua deleted file mode 100644 index 7856bd81f..000000000 --- a/third_party/zarchive.lua +++ /dev/null @@ -1,21 +0,0 @@ -group("third_party") -project("zarchive") - uuid("d32f03aa-f0c9-11ed-a05b-0242ac120003") - kind("StaticLib") - language("C++") - links({ - "zstd", - }) - includedirs({ - "zarchive/include", - "zstd/lib", - }) - files({ - "zarchive/include/zarchive/zarchivecommon.h", - "zarchive/include/zarchive/zarchivereader.h", - "zarchive/include/zarchive/zarchivewriter.h", - "zarchive/src/zarchivereader.cpp", - "zarchive/src/zarchivewriter.cpp", - "zarchive/src/sha_256.c", - "zarchive/src/sha_256.h", - }) diff --git a/third_party/zlib-ng.lua b/third_party/zlib-ng.lua deleted file mode 100644 index 9884307c2..000000000 --- a/third_party/zlib-ng.lua +++ /dev/null @@ -1,63 +0,0 @@ -group("third_party") -project("zlib-ng") - uuid("13d4073d-f1c9-47e3-a057-79b133596fc2") - kind("StaticLib") - language("C") - - defines({ - "X86_FEATURES", - "X86_HAVE_XSAVE_INTRIN", - "X86_SSSE3", - "X86_SSE42", - "WITH_GZFILEOP", - }) - if os.istarget("windows") then - defines({ - "X86_SSE2", - "X86_AVX2", - "X86_AVX512", - "X86_AVX512VNNI", - "X86_PCLMULQDQ_CRC", - "X86_VPCLMULQDQ_CRC", - }) - end - - files({ - "zlib-ng/*.c", - "zlib-ng/arch/x86/*.c", - "zlib-ng/arch/generic/*.c", - }) - if not os.istarget("windows") then - removefiles({ - "zlib-ng/arch/x86/adler32_avx2.c", - "zlib-ng/arch/x86/adler32_avx512.c", - "zlib-ng/arch/x86/adler32_avx512_vnni.c", - "zlib-ng/arch/x86/chunkset_avx2.c", - "zlib-ng/arch/x86/compare256_avx2.c", - "zlib-ng/arch/x86/crc32_pclmulqdq.c", - "zlib-ng/arch/x86/crc32_vpclmulqdq.c", - "zlib-ng/arch/x86/slide_hash_avx2.c", - }) - end - - includedirs({ - "zlib-ng", - }) - - local zlibng_dir = path.getabsolute("zlib-ng") - local zlibng_h_src_files = { - path.join(zlibng_build_dir, "zlib-ng.h"), - path.join(zlibng_build_dir, "zconf-ng.h"), - path.join(zlibng_build_dir, "zlib_name_mangling-ng.h"), - path.join(zlibng_build_dir, "gzread.c"), - } - for i = 1,#zlibng_h_src_files,1 - do - if not os.isfile(path.join(zlibng_dir, zlibng_h_src_files[i])) then - zlibng_build = true - break - end - end - if zlibng_build then - os.execute("cmake -DZLIB_ENABLE_TESTS=OFF -DWITH_GTEST=OFF "..zlibng_dir.." -B"..zlibng_dir) - end diff --git a/third_party/zstd.lua b/third_party/zstd.lua deleted file mode 100644 index 8761de8af..000000000 --- a/third_party/zstd.lua +++ /dev/null @@ -1,11 +0,0 @@ -include("third_party/zstd/contrib/premake/zstd.lua") - -group("third_party") -project("zstd") - uuid("df336aac-f0c8-11ed-a05b-0242ac120003") - -- https://gitlab.kitware.com/cmake/cmake/-/issues/25744 - filter({"toolset:not msc"}) - defines({ - "ZSTD_DISABLE_ASM", - }) - project_zstd("zstd/lib/") diff --git a/tools/build/bin/premake5.exe b/tools/build/bin/premake5.exe deleted file mode 100644 index 52ae09d3b..000000000 Binary files a/tools/build/bin/premake5.exe and /dev/null differ diff --git a/tools/build/premake.py b/tools/build/premake.py deleted file mode 100755 index 05778ba57..000000000 --- a/tools/build/premake.py +++ /dev/null @@ -1,272 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright 2015 Ben Vanik. All Rights Reserved. - -"""Premake trampoline script. -""" - -__author__ = "ben.vanik@gmail.com (Ben Vanik)" - - -from json import loads as jsonloads -import os -from shutil import rmtree -import subprocess -import sys - - -self_path = os.path.dirname(os.path.abspath(__file__)) -root_path = os.path.join(self_path, "..", "..") -premake_submodule_path = os.path.join(root_path, "third_party", "premake-core") -premake_path = premake_submodule_path - - -def setup_premake_path_override(): - global premake_path - premake_path = premake_submodule_path - if sys.platform == "linux": - # On Android, the repository may be cloned to the external storage, which - # doesn't support executables in it. - # In this case, premake-core needs to be checked out in the internal - # storage, which supports executables, with all the permissions as set in - # its repository. - # On Termux, the home directory is in the internal storage - use it for - # executing. - # If xenia-build.py doesn't have execute permissions, Xenia is in the external - # storage now. - try: - popen = subprocess.Popen( - ["uname", "-o"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, - text=True) - if popen.communicate()[0] == "Android\n": - xb_file = os.path.join(root_path, "xenia-build.py") - if (os.path.isfile(xb_file) and not os.access(xb_file, os.X_OK) and - "HOME" in os.environ): - premake_path = os.path.join(os.environ["HOME"], ".xenia-build", "premake-core") - except Exception: - pass - -setup_premake_path_override() - - -def main(): - # First try the freshly-built premake. - premake5_bin = os.path.join(premake_path, "bin", "release", "premake5") - if not has_bin(premake5_bin): - # No fresh build, so fallback to checked in copy (which we may not have). - premake5_bin = os.path.join(self_path, "bin", "premake5") - if not has_bin(premake5_bin): - # Still no valid binary, so build it. - print("premake5 executable not found, attempting build...") - build_premake() - premake5_bin = os.path.join(premake_path, "bin", "release", "premake5") - if not has_bin(premake5_bin): - # Nope, boned. - print("ERROR: cannot build premake5 executable.") - sys.exit(1) - - # Ensure the submodule has been checked out. - if not os.path.exists(os.path.join(premake_path, "scripts", "package.lua")): - print("third_party/premake-core was not present; run xb setup...") - sys.exit(1) - - if sys.platform == "win32": - # Append the executable extension on windows. - premake5_bin += ".exe" - - return_code = shell_call([ - premake5_bin, - f"--scripts={premake_path}", - ] + sys.argv[1:], - throw_on_error=False) - - sys.exit(return_code) - - -def build_premake(): - """Builds premake from source. - """ - # Ensure that on Android, premake-core is in the internal storage. - clone_premake_to_internal_storage() - cwd = os.getcwd() - try: - os.chdir(premake_path) - if sys.platform == "darwin": - subprocess.call([ - "make", - "-f", "Bootstrap.mak", - "osx", - ]) - elif sys.platform == "win32": - # Grab Visual Studio version and execute shell to set up environment. - vs_version = import_vs_environment() - if not vs_version: - print("ERROR: Visual Studio not found!") - sys.exit(1) - return - - subprocess.call([ - "nmake", - "-f", "Bootstrap.mak", - "windows", - ]) - else: - subprocess.call([ - "make", - "-f", "Bootstrap.mak", - "linux", - ]) - finally: - os.chdir(cwd) - pass - - -def clone_premake_to_internal_storage(): - """Clones premake to the Android internal storage so it can be executed. - """ - # premake_path is initialized to a value different than premake_submodule_path - # if running from the Android external storage, and may not exist yet. - if premake_path == premake_submodule_path: - return - - # Ensure the submodule has been checked out. - if not os.path.exists( - os.path.join(premake_submodule_path, "scripts", "package.lua")): - print("third_party/premake-core was not present; run xb setup...") - sys.exit(1) - - # Create or refresh premake-core in the internal storage. - print("Cloning premake5 to the internal storage...") - rmtree(premake_path, ignore_errors=True) - os.makedirs(premake_path) - shell_call([ - "git", - "clone", - "--depth=1", - premake_submodule_path, - premake_path, - ]) - - -def has_bin(bin): - """Checks whether the given binary is present. - """ - for path in os.environ["PATH"].split(os.pathsep): - if sys.platform == "win32": - exe_file = os.path.join(path, f"{bin}.exe") - if os.path.isfile(exe_file) and os.access(exe_file, os.X_OK): - return True - else: - path = path.strip("\"") - exe_file = os.path.join(path, bin) - if os.path.isfile(exe_file) and os.access(exe_file, os.X_OK): - return True - return None - - -def shell_call(command, throw_on_error=True, stdout_path=None, stderr_path=None, shell=False): - """Executes a shell command. - - Args: - command: Command to execute, as a list of parameters. - throw_on_error: Whether to throw an error or return the status code. - stdout_path: File path to write stdout output to. - stderr_path: File path to write stderr output to. - - Returns: - If throw_on_error is False the status code of the call will be returned. - """ - stdout_file = None - if stdout_path: - stdout_file = open(stdout_path, "w") - stderr_file = None - if stderr_path: - stderr_file = open(stderr_path, "w") - result = 0 - try: - if throw_on_error: - result = 1 - subprocess.check_call(command, shell=shell, stdout=stdout_file, stderr=stderr_file) - result = 0 - else: - result = subprocess.call(command, shell=shell, stdout=stdout_file, stderr=stderr_file) - finally: - if stdout_file: - stdout_file.close() - if stderr_file: - stderr_file.close() - return result - - -def import_vs_environment(): - """Finds the installed Visual Studio version and imports - interesting environment variables into os.environ. - - Returns: - A version such as 2022 or None if no installation is found. - """ - - if sys.platform != "win32": - return None - - version = None - install_path = None - env_tool_args = None - - vswhere = subprocess.check_output( - "tools/vswhere/vswhere.exe -version \"[17,)\" -latest -prerelease -format json -utf8 -products" - " Microsoft.VisualStudio.Product.Enterprise" - " Microsoft.VisualStudio.Product.Professional" - " Microsoft.VisualStudio.Product.Community" - " Microsoft.VisualStudio.Product.BuildTools", - encoding="utf-8", - ) - if vswhere: - vswhere = jsonloads(vswhere) - if vswhere and len(vswhere) > 0: - version = int(vswhere[0].get("catalog", {}).get("productLineVersion", 2022)) - install_path = vswhere[0].get("installationPath", None) - - vsdevcmd_path = os.path.join(install_path, "Common7", "Tools", "VsDevCmd.bat") - if os.access(vsdevcmd_path, os.X_OK): - env_tool_args = [vsdevcmd_path, "-arch=amd64", "-host_arch=amd64", "&&", "set"] - else: - vcvars_path = os.path.join(install_path, "VC", "Auxiliary", "Build", "vcvarsall.bat") - env_tool_args = [vcvars_path, "x64", "&&", "set"] - - if not version: - return None - - import_subprocess_environment(env_tool_args) - os.environ["VSVERSION"] = f"{version}" - return version - - -def import_subprocess_environment(args): - popen = subprocess.Popen( - args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) - variables, _ = popen.communicate() - envvars_to_save = ( - "devenvdir", - "include", - "lib", - "libpath", - "path", - "pathext", - "systemroot", - "temp", - "tmp", - "vcinstalldir", - "windowssdkdir", - ) - for line in variables.splitlines(): - for envvar in envvars_to_save: - if f"{envvar}=" in line.lower(): - var, setting = line.split("=", 1) - if envvar == "path": - setting = f"{os.path.dirname(sys.executable)}{os.pathsep}{setting}" - os.environ[var.upper()] = setting - break - -if __name__ == "__main__": - main() diff --git a/tools/build/premake5.lua b/tools/build/premake5.lua deleted file mode 100644 index 6f99284e4..000000000 --- a/tools/build/premake5.lua +++ /dev/null @@ -1,9 +0,0 @@ -require("vstudio") - -include("scripts/build_paths.lua") -include("scripts/force_compile_as_c.lua") -include("scripts/force_compile_as_cc.lua") -include("scripts/pkg_config.lua") -include("scripts/platform_files.lua") -include("scripts/single_library.lua") -include("scripts/test_suite.lua") diff --git a/tools/build/scripts/build_paths.lua b/tools/build/scripts/build_paths.lua deleted file mode 100644 index 5daa73a3f..000000000 --- a/tools/build/scripts/build_paths.lua +++ /dev/null @@ -1,16 +0,0 @@ -build_root = "build" -build_bin = build_root .. "/bin/%{cfg.platform}/%{cfg.buildcfg}" -build_gen = build_root .. "/gen/%{cfg.platform}/%{cfg.buildcfg}" -build_obj = build_root .. "/obj/%{cfg.platform}/%{cfg.buildcfg}" - -build_tools = "tools/build" -build_scripts = build_tools .. "/scripts" -build_tools_src = build_tools .. "/src" - -if os.istarget("android") then - platform_suffix = "android" -elseif os.istarget("windows") then - platform_suffix = "win" -else - platform_suffix = "posix" -end diff --git a/tools/build/scripts/force_compile_as_c.lua b/tools/build/scripts/force_compile_as_c.lua deleted file mode 100644 index 30de988e9..000000000 --- a/tools/build/scripts/force_compile_as_c.lua +++ /dev/null @@ -1,32 +0,0 @@ -if premake.override then - local forced_c_files = {} - - -- Forces all of the given .c and .cc files to be compiled as if they were C. - function force_compile_as_c(files) - for _, val in ipairs(files) do - for _, fname in ipairs(os.matchfiles(val)) do - table.insert(forced_c_files, path.getabsolute(fname)) - end - end - end - - -- for gmake - premake.override(path, "iscfile", function(base, fname) - if table.contains(forced_c_files, fname) then - return true - else - return base(fname) - end - end) - -- for msvc - premake.override(premake.vstudio.vc2010, "additionalCompileOptions", function(base, cfg, condition) - if cfg.abspath and table.contains(forced_c_files, cfg.abspath) then - if condition == nil or condition == '' then - _p(3,'CompileAsC') - else - _p(3,'CompileAsC', condition) - end - end - return base(cfg, condition) - end) -end diff --git a/tools/build/scripts/force_compile_as_cc.lua b/tools/build/scripts/force_compile_as_cc.lua deleted file mode 100644 index c7a15cef0..000000000 --- a/tools/build/scripts/force_compile_as_cc.lua +++ /dev/null @@ -1,32 +0,0 @@ -if premake.override then - local forced_cc_files = {} - - -- Forces all of the given .c files to be compiled as if they were C++. - function force_compile_as_cc(files) - for _, val in ipairs(files) do - for _, fname in ipairs(os.matchfiles(val)) do - table.insert(forced_cc_files, path.getabsolute(fname)) - end - end - end - - -- for gmake - premake.override(path, "iscfile", function(base, fname) - if table.contains(forced_cc_files, fname) then - return false - else - return base(fname) - end - end) - -- for msvc - premake.override(premake.vstudio.vc2010, "additionalCompileOptions", function(base, cfg, condition) - if cfg.abspath and table.contains(forced_cc_files, cfg.abspath) then - if condition == nil or condition == '' then - _p(3,'CompileAsCpp') - else - _p(3,'CompileAsCpp', condition) - end - end - return base(cfg, condition) - end) -end diff --git a/tools/build/scripts/pkg_config.lua b/tools/build/scripts/pkg_config.lua deleted file mode 100644 index bc83ae1c0..000000000 --- a/tools/build/scripts/pkg_config.lua +++ /dev/null @@ -1,45 +0,0 @@ --- Helper methods to use the system pkg-config utility - -pkg_config = {} - -local function pkg_config_call(lib, what) - local result, code = os.outputof("pkg-config --"..what.." "..lib) - if result then - return result - else - error("Failed to run 'pkg-config' for library '"..lib.."'. Are the development files installed?") - end -end - -function pkg_config.cflags(lib) - if not os.istarget("linux") then - return - end - buildoptions({ - pkg_config_call(lib, "cflags"), - }) -end - -function pkg_config.lflags(lib) - if not os.istarget("linux") then - return - end - linkoptions({ - pkg_config_call(lib, "libs-only-L"), - pkg_config_call(lib, "libs-only-other"), - }) - -- We can't just drop the stdout of the `--libs` command in - -- linkoptions because library order matters - local output = pkg_config_call(lib, "libs-only-l") - for k, flag in next, string.explode(output, " ") do - -- remove "-l" - if flag ~= "" then - links(string.sub(flag, 3)) - end - end -end - -function pkg_config.all(lib) - pkg_config.cflags(lib) - pkg_config.lflags(lib) -end diff --git a/tools/build/scripts/platform_files.lua b/tools/build/scripts/platform_files.lua deleted file mode 100644 index 1e243731e..000000000 --- a/tools/build/scripts/platform_files.lua +++ /dev/null @@ -1,71 +0,0 @@ -include("build_paths.lua") -include("util.lua") - -local function match_platform_files(base_path, base_match) - files({ - base_path.."/"..base_match..".h", - base_path.."/"..base_match..".c", - base_path.."/"..base_match..".cc", - base_path.."/"..base_match..".cpp", - base_path.."/"..base_match..".inc", - }) - removefiles({ - base_path.."/".."**_main.cc", - base_path.."/".."**_test.cc", - base_path.."/".."**_posix.h", - base_path.."/".."**_posix.cc", - base_path.."/".."**_linux.h", - base_path.."/".."**_linux.cc", - base_path.."/".."**_gnulinux.h", - base_path.."/".."**_gnulinux.cc", - base_path.."/".."**_x11.h", - base_path.."/".."**_x11.cc", - base_path.."/".."**_gtk.h", - base_path.."/".."**_gtk.cc", - base_path.."/".."**_android.h", - base_path.."/".."**_android.cc", - base_path.."/".."**_mac.h", - base_path.."/".."**_mac.cc", - base_path.."/".."**_win.h", - base_path.."/".."**_win.cc", - }) - filter("platforms:Windows") - files({ - base_path.."/"..base_match.."_win.h", - base_path.."/"..base_match.."_win.cc", - }) - filter("platforms:Linux or Android-*") - files({ - base_path.."/"..base_match.."_posix.h", - base_path.."/"..base_match.."_posix.cc", - base_path.."/"..base_match.."_linux.h", - base_path.."/"..base_match.."_linux.cc", - }) - filter("platforms:Linux") - files({ - base_path.."/"..base_match.."_gnulinux.h", - base_path.."/"..base_match.."_gnulinux.cc", - base_path.."/"..base_match.."_x11.h", - base_path.."/"..base_match.."_x11.cc", - base_path.."/"..base_match.."_gtk.h", - base_path.."/"..base_match.."_gtk.cc", - }) - filter("platforms:Android-*") - files({ - base_path.."/"..base_match.."_android.h", - base_path.."/"..base_match.."_android.cc", - }) - filter({}) -end - --- Adds all .h and .cc files in the current path that match the current platform --- suffix (_win, etc). -function local_platform_files(base_path) - match_platform_files(base_path or ".", "*") -end - --- Adds all .h and .cc files in the current path and all subpaths that match --- the current platform suffix (_win, etc). -function recursive_platform_files(base_path) - match_platform_files(base_path or ".", "**") -end diff --git a/tools/build/scripts/single_library.lua b/tools/build/scripts/single_library.lua deleted file mode 100644 index 50f60f2cf..000000000 --- a/tools/build/scripts/single_library.lua +++ /dev/null @@ -1,20 +0,0 @@ -SINGLE_LIBRARY_PLATFORM_PATTERNS = { - "Android-*", -}; - -SINGLE_LIBRARY_FILTER = - "platforms:" .. table.concat(SINGLE_LIBRARY_PLATFORM_PATTERNS, " or "); -NOT_SINGLE_LIBRARY_FILTER = table.translate( - SINGLE_LIBRARY_PLATFORM_PATTERNS, - function(pattern) - return "platforms:not " .. pattern; - end); - -function single_library_windowed_app_kind() - filter(SINGLE_LIBRARY_FILTER); - kind("StaticLib"); - wholelib("On"); - filter(NOT_SINGLE_LIBRARY_FILTER); - kind("WindowedApp"); - filter({}); -end diff --git a/tools/build/scripts/test_suite.lua b/tools/build/scripts/test_suite.lua deleted file mode 100644 index 2ef600995..000000000 --- a/tools/build/scripts/test_suite.lua +++ /dev/null @@ -1,99 +0,0 @@ -include("build_paths.lua") -include("util.lua") - -newoption({ - trigger = "test-suite-mode", - description = "Whether to merge all tests in a test_suite into a single project", - value = "MODE", - allowed = { - { "individual", "One binary per test." }, - { "combined", "One binary per test suite (default)." }, - }, -}) - -local function combined_test_suite(test_suite_name, project_root, base_path, config) - group("tests") - project(test_suite_name) - kind("ConsoleApp") - language("C++") - includedirs(merge_arrays(config["includedirs"], { - project_root.."/"..build_tools, - project_root.."/"..build_tools_src, - project_root.."/"..build_tools.."/third_party/catch/include", - })) - libdirs(merge_arrays(config["libdirs"], { - project_root.."/"..build_bin, - })) - links(config["links"]) - if config.filtered_links ~= nil then - for _, filtered_links in ipairs(config.filtered_links) do - filter(filtered_links.filter) - links(filtered_links.links) - end - filter({}) - end - defines({ - "XE_TEST_SUITE_NAME=\""..test_suite_name.."\"", - }) - files({ - project_root.."/"..build_tools_src.."/test_suite_main.cc", - project_root.."/src/xenia/base/console_app_main_"..platform_suffix..".cc", - base_path.."/**_test.cc", - }) - filter("toolset:msc") - -- Edit and Continue in MSVC can cause the __LINE__ macro to produce - -- invalid values, which breaks the usability of Catch2 output on - -- failed tests. - editAndContinue("Off") -end - -local function split_test_suite(test_suite_name, project_root, base_path, config) - local test_paths = os.matchfiles(base_path.."/**_test.cc") - for _, file_path in pairs(test_paths) do - local test_name = file_path:match("(.*).cc") - group("tests/"..test_suite_name) - project(test_suite_name.."-"..test_name) - kind("ConsoleApp") - language("C++") - includedirs(merge_arrays(config["includedirs"], { - project_root.."/"..build_tools, - project_root.."/"..build_tools_src, - project_root.."/"..build_tools.."/third_party/catch/include", - })) - libdirs(merge_arrays(config["libdirs"], { - project_root.."/"..build_bin, - })) - links(config["links"]) - if config.filtered_links ~= nil then - for _, filtered_links in ipairs(config.filtered_links) do - filter(filtered_links.filter) - links(filtered_links.links) - end - filter({}) - end - files({ - project_root.."/"..build_tools_src.."/test_suite_main.cc", - file_path, - }) - filter("toolset:msc") - -- Edit and Continue in MSVC can cause the __LINE__ macro to produce - -- invalid values, which breaks the usability of Catch2 output on - -- failed tests. - editAndContinue("Off") - end -end - --- Defines a test suite binary. --- Can either be a single binary with all tests or one binary per test based on --- the --test-suite-mode= option. -function test_suite( - test_suite_name, -- Project or group name for the entire suite. - project_root, -- Project root path (with build_tools/ under it). - base_path, -- Base source path to search for _test.cc files. - config) -- Include/lib directories and links for binaries. - if _OPTIONS["test-suite-mode"] == "individual" then - split_test_suite(test_suite_name, project_root, base_path, config) - else - combined_test_suite(test_suite_name, project_root, base_path, config) - end -end diff --git a/tools/build/scripts/util.lua b/tools/build/scripts/util.lua deleted file mode 100644 index c220d46de..000000000 --- a/tools/build/scripts/util.lua +++ /dev/null @@ -1,50 +0,0 @@ --- Prints a table and all of its contents. -function print_r(t) - local print_r_cache={} - local function sub_print_r(t, indent) - if (print_r_cache[tostring(t)]) then - print(indent.."*"..tostring(t)) - else - print_r_cache[tostring(t)]=true - if (type(t)=="table") then - for pos,val in pairs(t) do - if (type(val)=="table") then - print(indent.."["..pos.."] => "..tostring(t).." {") - sub_print_r(val,indent..string.rep(" ",string.len(pos)+8)) - print(indent..string.rep(" ",string.len(pos)+6).."}") - elseif (type(val)=="string") then - print(indent.."["..pos..'] => "'..val..'"') - else - print(indent.."["..pos.."] => "..tostring(val)) - end - end - else - print(indent..tostring(t)) - end - end - end - if (type(t)=="table") then - print(tostring(t).." {") - sub_print_r(t," ") - print("}") - else - sub_print_r(t," ") - end - print() -end - --- Merges two tables and returns the resulting table. -function merge_tables(t1, t2) - local result = {} - for k,v in pairs(t1 or {}) do result[k] = v end - for k,v in pairs(t2 or {}) do result[k] = v end - return result -end - --- Merges to arrays and returns the resulting array. -function merge_arrays(t1, t2) - local result = {} - for k,v in pairs(t1 or {}) do result[#result + 1] = v end - for k,v in pairs(t2 or {}) do result[#result + 1] = v end - return result -end diff --git a/xenia-build.py b/xenia-build.py index a98c39e14..18388b4cf 100755 --- a/xenia-build.py +++ b/xenia-build.py @@ -413,7 +413,7 @@ def generate_version_h(): commit_short = ":(" # header - contents_new = f"""// Autogenerated by `xb premake`. + contents_new = f"""// Autogenerated by xenia-build.py. #ifndef GENERATED_VERSION_H_ #define GENERATED_VERSION_H_ #define XE_BUILD_BRANCH "{branch_name}" @@ -626,58 +626,31 @@ def get_clang_format_binary(): sys.exit(1) -def get_premake_target_os(target_os_override=None): - """Gets the target --os to pass to premake, either for the current platform - or for the user-specified cross-compilation target. +def run_cmake_configure(build_type="Release", cc=None): + """Runs cmake configure on the project. Args: - target_os_override: override specified by the user for cross-compilation, - or None to target the host platform. + build_type: Build configuration (Debug, Release, Checked). + cc: C compiler to use (e.g. 'clang', 'gcc'). Returns: - Target --os to pass to premake. If a return value of this function valid - for the current configuration is passed to it again, the same value will - be returned. - """ - if sys.platform == "darwin": - target_os = "macosx" - elif sys.platform == "win32": - target_os = "windows" - elif host_linux_platform_is_android: - target_os = "android" - else: - target_os = "linux" - if target_os_override and target_os_override != target_os: - if target_os_override == "android": - target_os = target_os_override - else: - print_error( - "cross-compilation is only supported for Android target") - sys.exit(1) - return target_os - - -def run_premake(target_os, action, cc=None): - """Runs premake on the main project with the given format. - - Args: - target_os: target --os to pass to premake. - action: action to perform. + Return code from cmake. """ args = [ - sys.executable, - os.path.join("tools", "build", "premake.py"), - "--file=premake5.lua", - f"--os={target_os}", - "--test-suite-mode=combined", - "--verbose", - action, + "cmake", + "-S", ".", + "-B", "build", + "-G", "Ninja Multi-Config", ] - if not cc: - cc = get_cc(cc=cc) - - if cc: - args.insert(4, f"--cc={cc}") + if sys.platform != "win32": + if not cc: + cc = get_cc(cc=cc) + c_compiler = cc or os.environ.get("CC", "clang") + cxx_compiler = (cc + "++") if cc else os.environ.get("CXX", "clang++") + args += [ + f"-DCMAKE_C_COMPILER={c_compiler}", + f"-DCMAKE_CXX_COMPILER={cxx_compiler}", + ] ret = subprocess.call(args) @@ -687,29 +660,6 @@ def run_premake(target_os, action, cc=None): return ret -def run_platform_premake(target_os_override=None, cc=None, devenv=None): - """Runs all gyp configurations. - """ - target_os = get_premake_target_os(target_os_override) - if not devenv: - if target_os == "macosx": - devenv = "xcode4" - elif target_os == "windows": - vs_version = os.getenv("VSVERSION", VSVERSION_MINIMUM) - # VS 2026 preview reports as vs18, map to vs2022 for premake - # as it doesn't yet have a vs2026 target - if vs_version == "18": - vs_version = "2022" - devenv = f"vs{vs_version}" - elif target_os == "android": - devenv = "androidndk" - else: - devenv = "cmake" - if not cc: - cc = get_cc(cc=cc) - return run_premake(target_os=target_os, action=devenv, cc=cc) - - def get_build_bin_path(args): """Returns the path of the bin/ path with build results based on the configuration specified in the parsed arguments. @@ -720,13 +670,10 @@ def get_build_bin_path(args): Returns: A full path for the bin folder. """ - if sys.platform == "darwin": - platform = "macosx" - elif sys.platform == "win32": - platform = "windows" - else: - platform = "linux" - return os.path.join(self_path, "build", "bin", platform.capitalize(), args["config"].capitalize()) + config = args["config"].title() + platform = "Windows" if sys.platform == "win32" else "Linux" + # Multi-config: build/bin// + return os.path.join(self_path, "build", "bin", platform, config) def create_clion_workspace(): @@ -743,7 +690,7 @@ def create_clion_workspace(): with open(os.path.join(".idea", "misc.xml"), "w") as f: f.write(""" - + @@ -845,9 +792,6 @@ class SetupCommand(Command): name="setup", help_short="Setup the build environment.", *args, **kwargs) - self.parser.add_argument( - "--target_os", default=None, - help="Target OS passed to premake, for cross-compilation") def execute(self, args, pass_args, cwd): print("Setting up the build environment...\n") @@ -859,8 +803,8 @@ class SetupCommand(Command): else: print_warning("Git not available or not a repository. Dependencies may be missing.") - print("\n- running premake...") - ret = run_platform_premake(target_os_override=args["target_os"]) + print("\n- running cmake configure...") + ret = run_cmake_configure() print_status(ResultStatus.SUCCESS if not ret else ResultStatus.FAILURE) return ret @@ -878,9 +822,6 @@ class PullCommand(Command): self.parser.add_argument( "--merge", action="store_true", help=f"Merges on {default_branch} instead of rebasing.") - self.parser.add_argument( - "--target_os", default=None, - help="Target OS passed to premake, for cross-compilation") def execute(self, args, pass_args, cwd): print("Pulling...\n") @@ -910,36 +851,29 @@ class PullCommand(Command): git_submodule_update() print("") - print("- running premake...") - if run_platform_premake(target_os_override=args["target_os"]) == 0: + print("- running cmake configure...") + if run_cmake_configure() == 0: print_status(ResultStatus.SUCCESS) return 0 class PremakeCommand(Command): - """'premake' command. + """'premake' command (now runs cmake configure). """ def __init__(self, subparsers, *args, **kwargs): super(PremakeCommand, self).__init__( subparsers, name="premake", - help_short="Runs premake to update all projects.", + help_short="Runs cmake configure to update all projects.", *args, **kwargs) self.parser.add_argument( - "--cc", choices=["clang", "gcc", "msc"], default=None, help="Compiler toolchain passed to premake") - self.parser.add_argument( - "--devenv", default=None, help="Development environment") - self.parser.add_argument( - "--target_os", default=None, - help="Target OS passed to premake, for cross-compilation") + "--cc", choices=["clang", "gcc", "msc"], default=None, help="Compiler toolchain") def execute(self, args, pass_args, cwd): - # Update premake. If no binary found, it will be built from source. - print("Running premake...\n") - ret = run_platform_premake(target_os_override=args["target_os"], - cc=args["cc"], devenv=args["devenv"]) + print("Running cmake configure...\n") + ret = run_cmake_configure(cc=args["cc"]) print_status(ResultStatus.SUCCESS if not ret else ResultStatus.FAILURE) return ret @@ -954,7 +888,7 @@ class BaseBuildCommand(Command): subparsers, *args, **kwargs) self.parser.add_argument( - "--cc", choices=["clang", "gcc", "msc"], default=None, help="Compiler toolchain passed to premake") + "--cc", choices=["clang", "gcc", "msc"], default=None, help="Compiler toolchain") self.parser.add_argument( "--config", choices=["checked", "debug", "release"], default="debug", type=str.lower, help="Chooses the build configuration.") @@ -966,69 +900,32 @@ class BaseBuildCommand(Command): help="Forces a full rebuild.") self.parser.add_argument( "--no_premake", action="store_true", - help="Skips running premake before building.") + help="Skips running cmake configure before building.") def execute(self, args, pass_args, cwd): + config = args["config"].title() + if not args["no_premake"]: - print("- running premake...") - run_platform_premake(cc=args["cc"]) + print("- running cmake configure...") + run_cmake_configure(build_type=config, cc=args["cc"]) print("") print("- building (%s):%s..." % ( "all" if not len(args["target"]) else ", ".join(args["target"]), args["config"])) - if sys.platform == "win32": - if not vs_version: - print_error("Visual Studio is not installed.") - result = 1 - else: - targets = None - if args["target"]: - targets = "/t:" + ";".join( - target + (":Rebuild" if args["force"] else "") - for target in args["target"]) - else: - targets = "/t:Rebuild" if args["force"] else None - - result = subprocess.call([ - "msbuild", - "build/xenia.sln", - "/nologo", - "/m", - "/v:m", - f"/p:Configuration={args['config']}", - ] + ([targets] if targets else []) + pass_args) - elif sys.platform == "darwin": - schemes = args["target"] or ["xenia-app"] - nested_args = [["-scheme", scheme] for scheme in schemes] - scheme_args = [arg for pair in nested_args for arg in pair] - result = subprocess.call([ - "xcodebuild", - "-workspace", - "build/xenia.xcworkspace", - "-configuration", - args["config"] - ] + scheme_args + pass_args, env=dict(os.environ)) - else: - result = subprocess.call([ - "cmake", - "-Sbuild", - f"-Bbuild/build_{args['config']}", - f"-DCMAKE_BUILD_TYPE={args['config'].title()}", - f"-DCMAKE_C_COMPILER={os.environ.get('CC', 'clang')}", - f"-DCMAKE_CXX_COMPILER={os.environ.get('CXX', 'clang++')}", - "-GNinja" - ] + pass_args, env=dict(os.environ)) - print("") - if result != 0: - print_error("cmake failed with one or more errors.") - return result - result = subprocess.call([ - "ninja", - f"-Cbuild/build_{args['config']}", - ] + pass_args, env=dict(os.environ)) - if result != 0: - print_error("ninja failed with one or more errors.") + build_args = [ + "cmake", + "--build", "build", + "--config", config, + ] + if args["target"]: + for target in args["target"]: + build_args += ["--target", target] + if args["force"]: + build_args += ["--clean-first"] + result = subprocess.call(build_args + pass_args) + if result != 0: + print_error("Build failed with one or more errors.") return result @@ -1653,14 +1550,13 @@ class CleanCommand(Command): name="clean", help_short="Removes intermediate files and build outputs.", *args, **kwargs) - self.parser.add_argument( - "--target_os", default=None, - help="Target OS passed to premake, for cross-compilation") def execute(self, args, pass_args, cwd): - print("Cleaning build artifacts...\n" - "- premake clean...") - run_premake(get_premake_target_os(args["target_os"]), "clean") + print("Cleaning build artifacts...") + # Clean all build directories + if os.path.isdir("build"): + print("- cleaning build...") + subprocess.call(["cmake", "--build", "build", "--target", "clean"]) # Also clean generated files clean_generated_files() @@ -1698,9 +1594,6 @@ class NukeCommand(Command): name="nuke", help_short="Removes all build/ output.", *args, **kwargs) - self.parser.add_argument( - "--target_os", default=None, - help="Target OS passed to premake, for cross-compilation") def execute(self, args, pass_args, cwd): print("Cleaning build artifacts...\n" @@ -1719,8 +1612,8 @@ class NukeCommand(Command): default_branch, ]) - print("\n- running premake...") - run_platform_premake(target_os_override=args["target_os"]) + print("\n- running cmake configure...") + run_cmake_configure() print_status(ResultStatus.SUCCESS) return 0 @@ -1963,15 +1856,11 @@ class TidyCommand(Command): self.parser.add_argument( "--fix", action="store_true", help="Applies suggested fixes, where possible.") - self.parser.add_argument( - "--target_os", default=None, - help="Target OS passed to premake, for cross-compilation") def execute(self, args, pass_args, cwd): - # Run premake to generate our compile_commands.json file for clang to use. - # TODO(benvanik): only do linux? whatever clang-tidy is ok with. - run_premake(get_premake_target_os(args["target_os"]), - "export-compile-commands") + # Run cmake configure to generate compile_commands.json for clang-tidy. + # Use Ninja generator which produces compile_commands.json by default. + run_cmake_configure() if sys.platform == "darwin": platform_name = "darwin" @@ -2030,9 +1919,6 @@ class StubCommand(Command): self.parser.add_argument( "--class", default=None, help="Generate a class pair (.cc/.h) at the provided location in the source tree") - self.parser.add_argument( - "--target_os", default=None, - help="Target OS passed to premake, for cross-compilation") def execute(self, args, pass_args, cwd): root = os.path.dirname(os.path.realpath(__file__)) @@ -2064,7 +1950,8 @@ class StubCommand(Command): print_error("Please specify a file/class to generate") return 1 - run_platform_premake(target_os_override=args["target_os"]) + # Reconfigure to pick up the new source file. + run_cmake_configure() return 0 class DevenvCommand(Command): @@ -2079,23 +1966,15 @@ class DevenvCommand(Command): *args, **kwargs) def execute(self, args, pass_args, cwd): - devenv = None - show_reload_prompt = False if sys.platform == "win32": if not vs_version: print_error("Visual Studio is not installed."); return 1 print("Launching Visual Studio...") - elif sys.platform == "darwin": - print("Launching Xcode...") - devenv = "xcode4" elif has_bin("clion") or has_bin("clion.sh"): print("Launching CLion...") - show_reload_prompt = create_clion_workspace() - devenv = "cmake" else: - print("Launching CodeLite...") - devenv = "codelite" + print("IDE not detected. CMakeLists.txt is in the project root.") print("\n- generating shaders...") shader_result = build_shaders() @@ -2103,37 +1982,30 @@ class DevenvCommand(Command): print_error("Shader generation failed") return shader_result - print("\n- running premake...") - run_platform_premake(devenv=devenv) + print("\n- running cmake configure...") + run_cmake_configure() print("\n- launching devenv...") - if show_reload_prompt: - print_box("Please run \"File ⇒ ↺ Reload CMake Project\" from inside the IDE!") if sys.platform == "win32": - shell_call([ - "devenv", - "build\\xenia.sln", - ]) - elif sys.platform == "darwin": - shell_call([ - "xed", - "build/xenia.xcworkspace", + # Generate a VS .sln for IDE use (normal builds still use Ninja) + vs_build_dir = os.path.join("build", "vs") + subprocess.call([ + "cmake", + "-S", ".", + "-B", vs_build_dir, + "-G", "Visual Studio 17 2022", + "-A", "x64", ]) + sln_path = os.path.join(vs_build_dir, "xenia.sln") + print(f"Opening {sln_path} in Visual Studio...") + shell_call(["devenv", sln_path]) elif has_bin("clion"): - shell_call([ - "clion", - ".", - ]) + shell_call(["clion", "."]) elif has_bin("clion.sh"): - shell_call([ - "clion.sh", - ".", - ]) + shell_call(["clion.sh", "."]) else: - shell_call([ - "codelite", - "build/xenia.workspace", - ]) + print("No supported IDE found. Open the project root in your IDE.") + print("CMakeLists.txt and CMakePresets.json are in the project root.") print("") return 0