diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8a55b3497..53f49412d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -40,13 +40,6 @@ jobs: with: fetch-depth: 0 - - name: Cache premake5 - id: cache-premake5 - uses: actions/cache@main - with: - path: tools/build/bin/premake5 - key: ${{ runner.os }}-premake5-${{ hashFiles('third_party/premake-core/**') }} - - name: Cache Qt6 id: cache-qt-linux uses: actions/cache@v3 @@ -86,7 +79,7 @@ jobs: sudo apt-add-repository "deb http://apt.llvm.org/${UBUNTU_BASE}/ llvm-toolchain-${UBUNTU_BASE}-21 main" sudo apt-get -y update - sudo apt-get -y install mesa-vulkan-drivers valgrind libc++-dev libc++abi-dev libsdl2-dev libvulkan-dev libx11-xcb-dev clang-21 ninja-build spirv-tools libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-cursor0 libxcb-shape0 libfontconfig1-dev libxtst-dev + 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-21 lld-21 ninja-build cmake spirv-tools libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-cursor0 libxcb-shape0 libfontconfig1-dev libxtst-dev # Install Vulkan SDK if [ '${{ steps.cache-vulkan-sdk-linux.outputs.cache-hit }}' != 'true' ]; then @@ -131,12 +124,7 @@ jobs: # Update submodules if not cached if [ '${{ steps.cache-submodules.outputs.cache-hit }}' != 'true' ]; then - git submodule update --init --depth=1 -j$(getconf _NPROCESSORS_ONLN) $(grep -oP '(?<=path = )(?!third_party\/(DirectXShaderCompiler|premake-(androidndk|export-compile-commands))).+' .gitmodules) - fi - - if [ '${{ steps.cache-premake5.outputs.cache-hit }}' != 'true' ]; then - ./xenia-build.py premake - cp third_party/premake-core/bin/release/premake5 tools/build/bin + git submodule update --init --depth=1 -j$(getconf _NPROCESSORS_ONLN) $(grep -oP '(?<=path = )(?!third_party\/DirectXShaderCompiler).+' .gitmodules) fi # Fetch data repos (game-patches, optimized-settings) @@ -310,7 +298,7 @@ jobs: $cacheHit = '${{ steps.cache-submodules.outputs.cache-hit }}' if ($cacheHit -ne 'true') { - 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 } # Fetch data repos (game-patches, optimized-settings) diff --git a/.gitignore b/.gitignore index 89f11cb08..2b089129a 100644 --- a/.gitignore +++ b/.gitignore @@ -94,7 +94,13 @@ node_modules/.bin/ # coverage/etc /scratch/ +# CMake build trees /build/ +/build-vs/ + +# CMake user-specific overrides + compile commands export +CMakeUserPresets.json +/compile_commands.json # ============================================================================== # Local-only paths diff --git a/.gitmodules b/.gitmodules index 0182fcf66..2811d61a2 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..a30cce83c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,326 @@ +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) + +option(XENIA_BUILD_TESTS "Build test suites" OFF) +option(XENIA_BUILD_MISC "Build misc subprojects (trace viewers, shader compiler, vfs-dump, demos)" OFF) +option(XENIA_ENABLE_LTO "Enable link-time optimization in Release (slow link)" ON) + +get_property(_is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_is_multi_config) + set(CMAKE_CONFIGURATION_TYPES "Checked;Debug;Release;Valgrind" CACHE STRING "" FORCE) +endif() + +# Checked and Valgrind inherit Debug's flags as a starting point; the +# platform blocks below layer sanitizers and config-specific tweaks on top. +foreach(_cfg CHECKED VALGRIND) + set(CMAKE_C_FLAGS_${_cfg} "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "" FORCE) + set(CMAKE_CXX_FLAGS_${_cfg} "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "" FORCE) + set(CMAKE_EXE_LINKER_FLAGS_${_cfg} "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "" FORCE) + set(CMAKE_SHARED_LINKER_FLAGS_${_cfg} "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING "" FORCE) + set(CMAKE_STATIC_LINKER_FLAGS_${_cfg} "${CMAKE_STATIC_LINKER_FLAGS_DEBUG}" CACHE STRING "" FORCE) +endforeach() + +if(WIN32) + set(XE_PLATFORM_NAME "Windows") +else() + set(XE_PLATFORM_NAME "Linux") +endif() + +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}") + +file(MAKE_DIRECTORY "${PROJECT_SOURCE_DIR}/scratch") + +find_package(Python3 REQUIRED COMPONENTS Interpreter) + +# Debug/Checked/Valgrind are compiled against the release CRT (/MD) so we +# can link the Vulkan SDK's release-only SPIRV-Tools libs. Force any +# imported library (Qt6::*, etc.) to resolve to its Release variant in +# those configs too — otherwise Qt6*d.dll drags in /MDd and the process +# ends up mixing two CRTs, corrupting std::string/QString allocations. +# NOCONFIG is the fallback for imported targets that ship without a +# configuration suffix (FindOpenGL on Linux creates OpenGL::OpenGL this +# way — without NOCONFIG in the map we fail to resolve it in Debug et al). +set(CMAKE_MAP_IMPORTED_CONFIG_DEBUG "Release;NOCONFIG" CACHE STRING "" FORCE) +set(CMAKE_MAP_IMPORTED_CONFIG_CHECKED "Release;NOCONFIG" CACHE STRING "" FORCE) +set(CMAKE_MAP_IMPORTED_CONFIG_VALGRIND "Release;NOCONFIG" CACHE STRING "" FORCE) + +include(cmake/XeniaHelpers.cmake) + +include_directories( + ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/third_party + # Build directory — for `#include "version.h"` (generated by xenia-build.py + # into CMAKE_BINARY_DIR, which varies per configure: build/, build-vs/, ...). + ${CMAKE_BINARY_DIR} +) + +add_compile_definitions( + VULKAN_HPP_NO_TO_STRING + IMGUI_DISABLE_OBSOLETE_FUNCTIONS + IMGUI_DISABLE_DEFAULT_FONT + IMGUI_USE_STB_SPRINTF + USE_CPP17 # Tabulate + _LIB +) + +# ============================================================================== +# Qt6 (optional, gated on the QT_DIR env var) +# ============================================================================== + +set(XE_QT_DIR "$ENV{QT_DIR}") +if(XE_QT_DIR) + list(PREPEND CMAKE_PREFIX_PATH "${XE_QT_DIR}") + set(QT_NO_PRIVATE_MODULE_WARNING ON) + find_package(Qt6 COMPONENTS Core Gui GuiPrivate Widgets QUIET) + if(Qt6_FOUND) + message(STATUS "Qt6: using QT_DIR=${XE_QT_DIR} (version ${Qt6_VERSION})") + set(CMAKE_AUTOMOC ON) + # CMAKE_INCLUDE_CURRENT_DIR is intentionally off. Setting it globally + # would add each target's source dir to its include path, and + # src/xenia/base contains files named assert.h / string.h / memory.h / + # mutex.h that collide with C/C++ standard headers. Targets that need + # their source dir on the path (xenia-ui, so AUTOMOC-generated moc + # files can find Q_OBJECT headers) add it via target_include_directories. + if(NOT WIN32) + add_link_options("-Wl,-rpath,${XE_QT_DIR}/lib") + endif() + set(XE_HAS_QT TRUE) + + # Qt6 pulls in third-party find-modules (FindOpenGL, FindXKB, …) that + # create UNKNOWN IMPORTED targets with only a bare IMPORTED_LOCATION (no + # config suffix). Ninja Multi-Config can't map NOCONFIG locations for + # custom configs even with CMAKE_MAP_IMPORTED_CONFIG_*. Re-tag every + # such target as Release so the existing MAP resolves them correctly. + get_property(_imported_targets DIRECTORY PROPERTY IMPORTED_TARGETS) + foreach(_tgt IN LISTS _imported_targets) + get_target_property(_loc ${_tgt} IMPORTED_LOCATION) + if(_loc AND NOT _loc MATCHES "-NOTFOUND$") + get_target_property(_confs ${_tgt} IMPORTED_CONFIGURATIONS) + if(NOT _confs OR _confs MATCHES "-NOTFOUND$") + set_target_properties(${_tgt} PROPERTIES + IMPORTED_CONFIGURATIONS "Release" + IMPORTED_LOCATION_RELEASE "${_loc}" + ) + endif() + endif() + endforeach() + else() + message(WARNING "QT_DIR=${XE_QT_DIR} is set but find_package(Qt6) failed; building without Qt") + endif() +endif() + +# ============================================================================== +# Platform-specific global settings +# ============================================================================== + +if(MSVC) + # CRT runtime selection via CMP0091. Debug and Release use the release + # CRT (/MD); Checked uses the debug CRT (/MDd) because it pairs /RTCsu + # with ASan. + set(CMAKE_MSVC_RUNTIME_LIBRARY + "MultiThreaded$<$:Debug>DLL" + CACHE STRING "" FORCE) + + add_compile_options( + /utf-8 # non-Latin-codepage-safe source parsing + /Zc:__cplusplus # correct __cplusplus macro value (Qt6 needs this) + /Zc:preprocessor # conformant preprocessor + /wd4201 # nameless struct/unions are ok + /arch:AVX + /MP + ) + add_compile_definitions( + _CRT_NONSTDC_NO_DEPRECATE + _CRT_SECURE_NO_WARNINGS + WIN32 + _WIN64=1 + _AMD64=1 + UNICODE + _UNICODE + ) + add_link_options( + /ignore:4006 # duplicate symbols in static libs + /ignore:4221 # empty obj files + ) + link_libraries( + ntdll wsock32 ws2_32 xinput comctl32 shcore shlwapi dxguid bcrypt + ) + + # Checked: /RTCsu + ASan + debug symbols. /RTC1 from CMake's default + # Debug flags conflicts with /RTCsu, so strip it first. + string(REPLACE "/RTC1" "" CMAKE_C_FLAGS_CHECKED "${CMAKE_C_FLAGS_CHECKED}") + string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_CHECKED "${CMAKE_CXX_FLAGS_CHECKED}") + string(APPEND CMAKE_C_FLAGS_CHECKED " /RTCsu /fsanitize=address /Zi") + string(APPEND CMAKE_CXX_FLAGS_CHECKED " /RTCsu /fsanitize=address /Zi") + string(APPEND CMAKE_EXE_LINKER_FLAGS_CHECKED " /INCREMENTAL:NO") + add_compile_definitions( + $<$:DEBUG> + $<$:NDEBUG> + # STB_SPRINTF is incompatible with ASan runtime hooks. + $<$:IMGUI_USE_STB_SPRINTF_DISABLED> + ) + + # Debug: /RTC1 requires the debug CRT, so strip it — we're on /MD. Pin + # _ITERATOR_DEBUG_LEVEL=0 so our STL object layouts match release-CRT + # prebuilts (Vulkan SDK SPIRV-Tools) and we don't hit LNK2038. + string(REPLACE "/RTC1" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") + string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + add_compile_definitions( + $<$:DEBUG> + $<$:_NO_DEBUG_HEAP=1> + $<$:_ITERATOR_DEBUG_LEVEL=0> + ) + + add_compile_definitions( + $<$:NDEBUG> + $<$:_NO_DEBUG_HEAP=1> + ) + add_compile_options( + $<$:/Gw> + $<$:/GS-> # NoBufferSecurityCheck + ) + # /Ob3 is a stronger inline heuristic than CMake's default /Ob2. + string(REPLACE "/Ob2" "/Ob3" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + string(REPLACE "/Ob2" "/Ob3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + # LTCG (whole-program optimization). Disabled by -DXENIA_ENABLE_LTO=OFF + # for faster Release link times during iterative work. + if(XENIA_ENABLE_LTO) + add_compile_options($<$:/GL>) + add_link_options($<$:/LTCG>) + set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG") + endif() + # Release has no PDB. + string(REPLACE "/Zi" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + string(REPLACE "/DEBUG" "" CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") + +else() + # GCC/Clang (Linux) + add_compile_options(-mavx) + + add_compile_options( + $<$:-Wno-switch> + $<$:-Wno-attributes> + ) + + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options( + $<$:-Wno-deprecated-register> + $<$:-Wno-deprecated-volatile> + $<$:-Wno-deprecated-enum-enum-conversion> + ) + 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") + add_compile_options( + $<$:-Wno-unused-result> + $<$:-Wno-volatile> + $<$:-Wno-template-id-cdtor> + $<$:-Wno-return-type> + $<$:-Wno-deprecated> + -fpermissive # HACK + ) + add_link_options(-fpermissive) + endif() + + add_compile_options( + $<$:-Wno-implicit-function-declaration> + ) + + 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}) + + link_libraries(stdc++fs dl lz4 m pthread rt) + + # Link group so executables resolve circular static-lib 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") + + # Checked: UBSan. + string(APPEND CMAKE_C_FLAGS_CHECKED " -fsanitize=undefined") + string(APPEND CMAKE_CXX_FLAGS_CHECKED " -fsanitize=undefined") + string(APPEND CMAKE_EXE_LINKER_FLAGS_CHECKED " -fsanitize=undefined") + add_compile_definitions( + $<$:DEBUG> + $<$:NDEBUG> + ) + + add_compile_definitions( + $<$:DEBUG> + $<$:_NO_DEBUG_HEAP=1> + ) + + # Release keeps -g so crashes in the field have resolvable frames. + add_compile_definitions( + $<$:NDEBUG> + $<$:_NO_DEBUG_HEAP=1> + ) + add_compile_options( + $<$:-O3> + $<$:-finline-functions> + $<$:-funroll-loops> + $<$:-fomit-frame-pointer> + $<$:-g> + ) + # ThinLTO + lld. Gated behind XENIA_ENABLE_LTO so -DXENIA_ENABLE_LTO=OFF + # produces a Release binary with the standard system linker and no LTO, + # which links an order of magnitude faster during iterative work. + if(XENIA_ENABLE_LTO) + add_compile_options($<$:-flto=thin>) + add_link_options( + $<$:-flto=thin> + $<$:-fuse-ld=lld> + ) + endif() + + # Valgrind: -Og for debuggability without the pathological debug perf + # cost, no sanitizers (they fight valgrind), no inlining so stack + # traces reflect source structure. + string(APPEND CMAKE_C_FLAGS_VALGRIND " -Og -g3 -fno-omit-frame-pointer -fno-inline-functions") + string(APPEND CMAKE_CXX_FLAGS_VALGRIND " -Og -g3 -fno-omit-frame-pointer -fno-inline-functions") + add_compile_definitions( + $<$:DEBUG> + $<$:NDEBUG> + $<$:_NO_DEBUG_HEAP=1> + ) +endif() + +# ============================================================================== +# Subdirectories +# ============================================================================== + +# third_party is added before Qt is made directory-global so its libs +# don't pull Qt into their compile lines. +add_subdirectory(third_party) + +# Qt headers reach into src/xenia/kernel, src/xenia/gpu, etc. via +# transitive includes of app/emulator_window.h and ui/*_qt.h — not just +# the targets with Q_OBJECT. Linking Qt at directory scope keeps all +# xenia src libs consistent. +if(XE_HAS_QT) + link_libraries(Qt6::Core Qt6::Gui Qt6::Widgets) +endif() + +add_subdirectory(src/xenia) + +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..d3f46c291 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,60 @@ +{ + "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": "valgrind", + "configurePreset": "default", + "configuration": "Valgrind" + }, + { + "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..b3db267c1 --- /dev/null +++ b/cmake/XeniaHelpers.cmake @@ -0,0 +1,242 @@ +# Helper functions for the xenia build. + +include(CMakeParseArguments) + +set(XE_PLATFORM_SUFFIXES + _win _linux _posix _gnulinux _x11 _gtk _android _mac +) + +# xe_platform_sources(target base_path [RECURSIVE]) +# +# Globs source files from base_path and adds them to target. Excludes +# *_main.cc / *_test.cc / *_demo.cc, and any file with a platform suffix +# that doesn't match the current platform. RECURSIVE descends into +# subdirectories. +function(xe_platform_sources target base_path) + set(options RECURSIVE) + cmake_parse_arguments(ARG "${options}" "" "" ${ARGN}) + + if(ARG_RECURSIVE) + set(glob_mode GLOB_RECURSE) + else() + set(glob_mode GLOB) + endif() + + file(${glob_mode} _all_sources + "${base_path}/*.h" + "${base_path}/*.cc" + "${base_path}/*.cpp" + "${base_path}/*.c" + "${base_path}/*.inc" + ) + + set(_excluded) + foreach(src ${_all_sources}) + get_filename_component(_name_we ${src} NAME_WE) + if(_name_we MATCHES "_main$" OR _name_we MATCHES "_test$" OR _name_we MATCHES "_demo$") + list(APPEND _excluded ${src}) + continue() + endif() + foreach(suffix ${XE_PLATFORM_SUFFIXES}) + if(_name_we MATCHES "${suffix}$") + list(APPEND _excluded ${src}) + break() + endif() + endforeach() + endforeach() + + set(_sources ${_all_sources}) + if(_excluded) + list(REMOVE_ITEM _sources ${_excluded}) + endif() + + 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-wide compile defaults to a target: project-root include +# directories and warnings-as-errors. GCC is excluded from -Werror because +# it's too noisy to keep clean across the codebase. +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") + target_compile_options(${target} PRIVATE -Werror) + endif() +endfunction() + +# xe_shader_rules_spirv(target shader_dir) +# +# Wires up SPIR-V shader compilation (glslang + spirv-opt + spirv-dis, +# via tools/build/compile_shader_spirv.py) as a prerequisite of target. +# Sources are *.xesl / *.glsl with a stage suffix (vs/hs/ds/gs/ps/cs); +# outputs land in /bytecode/vulkan_spirv/.h. A stamp +# file drives incremental rebuilds when any source or the compile +# script changes. +function(xe_shader_rules_spirv target shader_dir) + get_filename_component(shader_dir "${shader_dir}" ABSOLUTE) + file(GLOB _sources + "${shader_dir}/*.xesl" "${shader_dir}/*.glsl" + "${shader_dir}/*.xesli" "${shader_dir}/*.glsli") + set(_stamp "${CMAKE_CURRENT_BINARY_DIR}/${target}_spirv.stamp") + set(_script "${PROJECT_SOURCE_DIR}/tools/build/compile_shader_spirv.py") + set(_valid_stages vs hs ds gs ps cs) + set(_commands) + set(_bytecode_dir "${shader_dir}/bytecode/vulkan_spirv") + list(APPEND _commands COMMAND ${CMAKE_COMMAND} -E make_directory "${_bytecode_dir}") + foreach(src ${_sources}) + get_filename_component(_name ${src} NAME) + string(REGEX REPLACE "\\.[^.]+$" "" _basename "${_name}") + string(REPLACE "." "_" _id "${_basename}") + string(LENGTH "${_id}" _len) + if(_len LESS 3) + continue() + endif() + math(EXPR _s "${_len} - 2") + string(SUBSTRING "${_id}" ${_s} 2 _stage) + if(NOT _stage IN_LIST _valid_stages) + continue() + endif() + list(APPEND _commands COMMAND ${Python3_EXECUTABLE} "${_script}" "${src}" "${_bytecode_dir}/${_id}.h") + endforeach() + add_custom_command( + OUTPUT "${_stamp}" + ${_commands} + COMMAND ${CMAKE_COMMAND} -E touch "${_stamp}" + DEPENDS ${_sources} "${_script}" + COMMENT "Compiling SPIR-V shaders for ${target}..." + VERBATIM + ) + add_custom_target(${target}-spirv-shaders DEPENDS "${_stamp}") + add_dependencies(${target} ${target}-spirv-shaders) + # Attach sources to the target for IDE visibility without letting VS + # try to compile them as C++. + set_source_files_properties(${_sources} PROPERTIES HEADER_FILE_ONLY TRUE) + target_sources(${target} PRIVATE ${_sources}) +endfunction() + +# xe_shader_rules_dxbc(target shader_dir) +# +# DXBC counterpart to xe_shader_rules_spirv: invokes FXC via +# tools/build/compile_shader_dxbc.py on each stage-suffixed *.xesl / +# *.hlsl under shader_dir, emitting /bytecode/d3d12_5_1/.h. +function(xe_shader_rules_dxbc target shader_dir) + get_filename_component(shader_dir "${shader_dir}" ABSOLUTE) + file(GLOB _sources + "${shader_dir}/*.xesl" "${shader_dir}/*.hlsl" + "${shader_dir}/*.xesli" "${shader_dir}/*.hlsli") + set(_stamp "${CMAKE_CURRENT_BINARY_DIR}/${target}_dxbc.stamp") + set(_script "${PROJECT_SOURCE_DIR}/tools/build/compile_shader_dxbc.py") + set(_valid_stages vs hs ds gs ps cs) + set(_commands) + set(_bytecode_dir "${shader_dir}/bytecode/d3d12_5_1") + list(APPEND _commands COMMAND ${CMAKE_COMMAND} -E make_directory "${_bytecode_dir}") + foreach(src ${_sources}) + get_filename_component(_name ${src} NAME) + string(REGEX REPLACE "\\.[^.]+$" "" _basename "${_name}") + string(REPLACE "." "_" _id "${_basename}") + string(LENGTH "${_id}" _len) + if(_len LESS 3) + continue() + endif() + math(EXPR _s "${_len} - 2") + string(SUBSTRING "${_id}" ${_s} 2 _stage) + if(NOT _stage IN_LIST _valid_stages) + continue() + endif() + list(APPEND _commands COMMAND ${Python3_EXECUTABLE} "${_script}" "${src}" "${_bytecode_dir}/${_id}.h") + endforeach() + add_custom_command( + OUTPUT "${_stamp}" + ${_commands} + COMMAND ${CMAKE_COMMAND} -E touch "${_stamp}" + DEPENDS ${_sources} "${_script}" + COMMENT "Compiling DXBC shaders for ${target}..." + VERBATIM + ) + add_custom_target(${target}-dxbc-shaders DEPENDS "${_stamp}") + add_dependencies(${target} ${target}-dxbc-shaders) + set_source_files_properties(${_sources} PROPERTIES HEADER_FILE_ONLY TRUE) + target_sources(${target} PRIVATE ${_sources}) +endfunction() + +# xe_force_c(files...) — compile the given sources as C. +function(xe_force_c) + set_source_files_properties(${ARGN} PROPERTIES LANGUAGE C) +endfunction() + +# xe_force_cxx(files...) — compile the given sources 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. +# Returns early (no target) if no test sources are found. +function(xe_test_suite name base_path) + cmake_parse_arguments(ARG "" "" "LINKS" ${ARGN}) + + file(GLOB _test_sources "${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 + ) + + 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) + # Edit-and-Continue rewrites __LINE__ and breaks Catch2 test discovery. + target_compile_options(${name} PRIVATE /Zi) + endif() +endfunction() diff --git a/premake5.lua b/premake5.lua deleted file mode 100644 index 951a26db9..000000000 --- a/premake5.lua +++ /dev/null @@ -1,558 +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 - --- Helper function to extract Qt version from qconfig.pri -function get_qt_version(qt_dir) - local qconfig_path = path.join(qt_dir, "mkspecs/qconfig.pri") - local qconfig_file = io.open(qconfig_path, "r") - if qconfig_file then - for line in qconfig_file:lines() do - local version = line:match("^QT_VERSION%s*=%s*(.+)$") - if version then - qconfig_file:close() - return version:gsub("^%s*", ""):gsub("%s*$", "") -- trim whitespace - end - end - qconfig_file:close() - end - error("Could not read Qt version from " .. qconfig_path) -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_OBSOLETE_FUNCTIONS", - "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"}) - -- AVX2 requires Haswell (2013+) or newer - vectorextensions("AVX") - filter({}) -end - -filter("kind:StaticLib") - defines({ - "_LIB", - }) - -filter("configurations:Checked") - runtime("Debug") - inlining("Auto") -- /Ob2 for Checked builds - flags("NoIncrementalLink") - editandcontinue("Off") - staticruntime("Off") - optimize("Off") - removedefines({ - "IMGUI_USE_STB_SPRINTF", - }) - defines({ - "DEBUG", - "NDEBUG", - }) - -filter({"configurations:Checked", "platforms:Linux"}) - buildoptions({ - "-fsanitize=undefined", - }) - linkoptions({ - "-fsanitize=undefined", - }) - -filter({"configurations:Checked", "platforms:Windows"}) -- "toolset:msc" - buildoptions({ - "/RTCsu", -- Full Run-Time Checks. - }) - -- AddressSanitizer on Windows (doesn't conflict with memory layout like on Linux) - sanitize("Address") - -filter({"configurations:Checked or Debug", "platforms:Linux"}) - defines({ - -- "_GLIBCXX_DEBUG", -- libstdc++ debug mode (disabled - causes ABI issues with system libraries) - }) - -filter({"configurations:Checked or Debug", "platforms:Windows"}) -- "toolset:msc" - symbols("Full") - -filter("configurations:Debug") - runtime("Release") - optimize("Off") - inlining("Disabled") -- No inlining for debug - defines({ - "DEBUG", - "_NO_DEBUG_HEAP=1", - }) - -filter("configurations:Release") - runtime("Release") - defines({ - "NDEBUG", - "_NO_DEBUG_HEAP=1", - }) - optimize("Speed") - flags({ - "NoBufferSecurityCheck" - }) - 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("On") -- Enable debug symbols for crash debugging - linktimeoptimization("On") - buildoptions({ - "-O3", -- Maximum optimization (premake's optimize("Speed") might only be -O2) - "-finline-functions", -- Aggressive function inlining - "-funroll-loops", -- Unroll loops where beneficial - "-fomit-frame-pointer", -- Don't keep frame pointer for better performance - }) - -filter({"configurations:Release", "platforms:Windows"}) -- "toolset:msc" - symbols("Off") -- Disable PDB generation for release builds - linktimeoptimization("On") - buildoptions({ - "/Gw", - "/Ob3", -- Aggressive inlining for maximum performance --- "/Qpar", -- TODO: Test this. - }) - -filter("configurations:Valgrind") - runtime("Release") - optimize("Debug") -- -Og for reasonable performance with debuggability - symbols("Full") -- Full debug symbols for better Valgrind output - defines({ - "DEBUG", - "NDEBUG", - "_NO_DEBUG_HEAP=1", - }) - -- NO sanitize("Address") - incompatible with Valgrind - -- Disable optimizations that make debugging harder - buildoptions({ - "-fno-omit-frame-pointer", -- Keep frame pointers for better stack traces - "-fno-inline-functions", -- Disable function inlining for clearer traces - }) - -filter({"configurations:Valgrind", "platforms:Linux"}) - -- Additional Valgrind-friendly settings for Linux - buildoptions({ - "-g3", -- Maximum debug info - }) - -filter("platforms:Linux") - system("linux") - toolset("clang") - local qt_dir = os.getenv("QT_DIR") - if qt_dir then - local qt_version = get_qt_version(qt_dir) - includedirs({ - path.join(qt_dir, "include"), - path.join(qt_dir, "include/QtCore"), - path.join(qt_dir, "include/QtCore", qt_version), - path.join(qt_dir, "include/QtCore", qt_version, "QtCore"), - path.join(qt_dir, "include/QtGui"), - path.join(qt_dir, "include/QtGui", qt_version), - path.join(qt_dir, "include/QtGui", qt_version, "QtGui"), - path.join(qt_dir, "include/QtWidgets"), - }) - libdirs({ - path.join(qt_dir, "lib"), - }) - runpathdirs({ - path.join(qt_dir, "lib"), - }) - -- For CMake: set RPATH to find Qt libraries - linkoptions({ - "-Wl,-rpath," .. path.join(qt_dir, "lib"), - }) - links({ - "Qt6Core", - "Qt6Gui", - "Qt6Widgets", - }) - end - - links({ - "stdc++fs", - "dl", - "lz4", - "m", - "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'. - "/Zc:__cplusplus", -- Enable correct __cplusplus macro value (required for Qt6). - "/Zc:preprocessor", -- Enable conformant preprocessor (supports #if in macro args). - -- 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", - }) - linkoptions({ - "/ignore:4006", -- Ignores complaints about empty obj files. - "/ignore:4221", - }) - links({ - "ntdll", - "wsock32", - "ws2_32", - "xinput", - "comctl32", - "shcore", - "shlwapi", - "dxguid", - "bcrypt", - }) - -- Add Qt for Windows - local qt_dir = os.getenv("QT_DIR") - if qt_dir then - includedirs({ - path.join(qt_dir, "include"), - path.join(qt_dir, "include/QtCore"), - path.join(qt_dir, "include/QtGui"), - path.join(qt_dir, "include/QtWidgets"), - }) - libdirs({ - path.join(qt_dir, "lib"), - }) - end - -filter({"platforms:Windows", "configurations:Release"}) - if qt_dir then - links({ - "Qt6Core", - "Qt6Gui", - "Qt6Widgets", - }) - end - -filter({"platforms:Windows", "configurations:Debug or Checked"}) - if qt_dir then - links({ - "Qt6Cored", - "Qt6Guid", - "Qt6Widgetsd", - }) - end - -filter("platforms:Windows") - --- 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", "Valgrind"}) - - include("third_party/aes_128.lua") - include("third_party/asio.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/metal-shader-converter.lua") - include("third_party/metal-cpp.lua") - include("third_party/miniaudio.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") - - filter({"platforms:Linux", "configurations:Checked"}) - buildoptions({ - "-fsanitize=undefined", - }) - linkoptions({ - "-fsanitize=undefined", - }) - filter({}) - - -- Add POSIX feature test macros for FFmpeg on Linux - if prj.name == "libavutil" or prj.name == "libavcodec" or prj.name == "libavformat" then - filter({"platforms:Linux"}) - defines({ - "_GNU_SOURCE", - "_POSIX_C_SOURCE=200809L", - "_XOPEN_SOURCE=700", - }) - filter({}) - end - - -- Suppress warnings for third_party modules on Windows - filter({"platforms:Windows"}) - if string.startswith(prj.name, "third_party") or - prj.name == "aes_128" or - prj.name == "capstone" or - prj.name == "dxbc" or - prj.name == "discord-rpc" or - prj.name == "cxxopts" or - prj.name == "tomlplusplus" or - prj.name == "FFmpeg" or - prj.name == "fmt" or - prj.name == "glslang-spirv" or - prj.name == "imgui" or - prj.name == "mspack" or - prj.name == "snappy" or - prj.name == "xxhash" or - prj.name == "zarchive" or - prj.name == "zstd" or - prj.name == "zlib-ng" or - prj.name == "pugixml" or - prj.name == "libusb" or - prj.name == "SDL2" then - buildoptions({ - "/W0", -- Disable all warnings for third_party code - }) - end - filter({}) - 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/debug/gdb") -- Needs socket support for other systems. - 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..255df5549 --- /dev/null +++ b/src/xenia/CMakeLists.txt @@ -0,0 +1,46 @@ +# xenia-core: the loose .h/.cc files directly under src/xenia/ (emulator, +# kernel_state, etc.) that aren't part of any specific submodule. +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) + +add_subdirectory(base) +add_subdirectory(cpu) +add_subdirectory(cpu/backend/x64) +add_subdirectory(apu) +add_subdirectory(apu/nop) +add_subdirectory(apu/sdl) +add_subdirectory(gpu) +add_subdirectory(gpu/null) +add_subdirectory(gpu/vulkan) +add_subdirectory(helper/sdl) +add_subdirectory(hid) +add_subdirectory(hid/nop) +add_subdirectory(hid/sdl) +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) + +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + add_subdirectory(apu/alsa) +endif() + +if(WIN32) + add_subdirectory(apu/xaudio2) + add_subdirectory(debug/gdb) + 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..05586b658 --- /dev/null +++ b/src/xenia/app/CMakeLists.txt @@ -0,0 +1,172 @@ +if(WIN32) + add_executable(xenia-app WIN32) +else() + add_executable(xenia-app) +endif() + +set_target_properties(xenia-app PROPERTIES OUTPUT_NAME "xenia_edge") + +target_sources(xenia-app PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/xenia_main.cc +) + +xe_platform_sources(xenia-app ${CMAKE_CURRENT_SOURCE_DIR}) + +# Qt owns the windowed main entry point; one implementation is shared +# across platforms. +target_sources(xenia-app PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/ui/windowed_app_main_qt.cc +) + +if(WIN32) + target_sources(xenia-app PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/main_init_win.cc + ${CMAKE_CURRENT_SOURCE_DIR}/main_resources.rc + ${PROJECT_SOURCE_DIR}/src/xenia/base/app_win32.manifest + ) + # main_init runs the AVX feature check — it must itself not use AVX. + set_source_files_properties( + ${PROJECT_SOURCE_DIR}/src/xenia/base/main_init_win.cc + PROPERTIES COMPILE_OPTIONS "/arch:SSE2" + ) + # WIN32 executable defaults to /SUBSYSTEM:WINDOWS; override to CONSOLE + # in Debug so stdout/stderr reach an attached terminal. /ENTRY points + # at the Qt-style main() rather than WinMain. + target_link_options(xenia-app PRIVATE + $<$:/SUBSYSTEM:CONSOLE> + /ENTRY:mainCRTStartup + ) +else() + target_sources(xenia-app PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/main_init_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 +) + +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 + aes_128 + capstone + fmt + dxbc + discord-rpc + glslang-spirv + imgui + libavcodec + libavutil + mspack + snappy + xxhash + xenia-app-discord + xenia-apu-sdl + xenia-debug-ui + xenia-helper-sdl + xenia-hid-sdl +) + +if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + target_link_libraries(xenia-app PRIVATE xenia-cpu-backend-x64) +endif() + +if(WIN32) + target_link_libraries(xenia-app PRIVATE + xenia-apu-xaudio2 + xenia-debug-gdb + 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) + +# ============================================================================== +# Post-build: Qt deployment and runtime asset copy +# ============================================================================== + +set(_edge_assets_font_src "${PROJECT_SOURCE_DIR}/assets/font") +set(_edge_optimized_src "${PROJECT_SOURCE_DIR}/.data_repos/optimized-settings/settings") +set(_edge_game_patches_src "${PROJECT_SOURCE_DIR}/.data_repos/game-patches/patches") + +# windeployqt always deploys --release DLLs. All our configs link +# release Qt (root CMakeLists maps Debug/Checked/Valgrind imported +# configs to Release), so deploying Qt6Cored.dll would pull in the +# debug CRT and corrupt Qt/STL objects at runtime. +if(WIN32) + set(XE_QT_DIR "$ENV{QT_DIR}") + if(XE_QT_DIR AND EXISTS "${XE_QT_DIR}/bin/windeployqt.exe") + add_custom_command(TARGET xenia-app POST_BUILD + COMMAND "${XE_QT_DIR}/bin/windeployqt.exe" + --release + --no-translations + --no-system-d3d-compiler + --no-opengl-sw + --no-compiler-runtime + "$" + VERBATIM + ) + endif() +endif() + +# Stage runtime assets (fonts, game patches, optimized settings) next to +# the executable. Same layout on Windows and Linux. +add_custom_command(TARGET xenia-app POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory "$/optimized_settings" + COMMAND ${CMAKE_COMMAND} -E make_directory "$/game_patches" + COMMAND ${CMAKE_COMMAND} -E make_directory "$/assets/font" + VERBATIM +) +if(EXISTS "${_edge_optimized_src}") + add_custom_command(TARGET xenia-app POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${_edge_optimized_src}" "$/optimized_settings" + VERBATIM + ) +endif() +if(EXISTS "${_edge_game_patches_src}") + add_custom_command(TARGET xenia-app POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${_edge_game_patches_src}" "$/game_patches" + VERBATIM + ) +endif() +if(EXISTS "${_edge_assets_font_src}") + add_custom_command(TARGET xenia-app POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${_edge_assets_font_src}" "$/assets/font" + VERBATIM + ) +endif() 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/emulator_window.cc b/src/xenia/app/emulator_window.cc index dae171c6c..22af98563 100644 --- a/src/xenia/app/emulator_window.cc +++ b/src/xenia/app/emulator_window.cc @@ -125,8 +125,8 @@ #include "xenia/ui/virtual_key.h" #include "xenia/ui/window_qt.h" -// Autogenerated by `xb premake`. -#include "build/version.h" +// version.h is autogenerated by xenia-build.py into the CMake binary dir. +#include "version.h" DECLARE_bool(debug); diff --git a/src/xenia/app/premake5.lua b/src/xenia/app/premake5.lua deleted file mode 100644 index d157e7fd2..000000000 --- a/src/xenia/app/premake5.lua +++ /dev/null @@ -1,211 +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", - }) - apu_transitive_deps() - local_platform_files() - files({ - "../base/main_init_"..platform_suffix..".cc", - "../ui/windowed_app_main_qt.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") - filter({NOT_SINGLE_LIBRARY_FILTER, "platforms:Windows", "configurations:Debug"}) - kind("ConsoleApp") - - -- `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_edge") - - 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", - }) - linkoptions({"/ENTRY:mainCRTStartup"}) - - 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-debug-gdb", - "xenia-gpu-d3d12", - "xenia-hid-winkey", - "xenia-hid-xinput", - "xenia-ui-d3d12", - }) - - filter("platforms:Windows") - - 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 - - -- Run windeployqt as post-build event to copy Qt DLLs - filter({"platforms:Windows", "configurations:Debug or Checked"}) - local qt_dir = os.getenv("QT_DIR") - if qt_dir then - local windeployqt = path.translate(path.join(qt_dir, "bin", "windeployqt.exe"), "\\") - postbuildcommands { - 'if exist "' .. windeployqt .. '" "' .. windeployqt .. '" --debug --no-translations --no-system-d3d-compiler --no-opengl-sw --no-compiler-runtime "$(TargetPath)"' - } - end - - filter({"platforms:Windows", "configurations:Release"}) - local qt_dir = os.getenv("QT_DIR") - if qt_dir then - local windeployqt = path.translate(path.join(qt_dir, "bin", "windeployqt.exe"), "\\") - postbuildcommands { - 'if exist "' .. windeployqt .. '" "' .. windeployqt .. '" --release --no-translations --no-system-d3d-compiler --no-opengl-sw --no-compiler-runtime "$(TargetPath)"' - } - end - - -- Copy optimized-settings files (TOML or JSON) next to executable - filter("platforms:Windows") - -- Use absolute path to avoid issues with relative paths - local optimized_settings_src = path.translate(path.getabsolute(path.join(project_root, ".data_repos", "optimized-settings", "settings")), "\\") - postbuildcommands { - 'if not exist "$(TargetDir)optimized_settings" mkdir "$(TargetDir)optimized_settings"', - 'if exist "' .. optimized_settings_src .. '\\*.json" xcopy /I /Y /Q "' .. optimized_settings_src .. '\\*.json" "$(TargetDir)optimized_settings\\"', - 'if exist "' .. optimized_settings_src .. '\\*.toml" xcopy /I /Y /Q "' .. optimized_settings_src .. '\\*.toml" "$(TargetDir)optimized_settings\\"' - } - - -- Copy game-patches TOML files next to executable - filter("platforms:Windows") - local game_patches_src = path.translate(path.getabsolute(path.join(project_root, ".data_repos", "game-patches", "patches")), "\\") - postbuildcommands { - 'if not exist "$(TargetDir)game_patches" mkdir "$(TargetDir)game_patches"', - 'xcopy /I /Y /Q "' .. game_patches_src .. '\\*.toml" "$(TargetDir)game_patches\\"' - } - - -- Copy assets/font next to executable - filter("platforms:Windows") - local assets_font_src = path.translate(path.getabsolute(path.join(project_root, "assets", "font")), "\\") - postbuildcommands { - 'if not exist "$(TargetDir)assets\\font" mkdir "$(TargetDir)assets\\font"', - 'xcopy /I /Y /Q "' .. assets_font_src .. '\\*.*" "$(TargetDir)assets\\font\\"' - } - - filter("platforms:Linux") - local optimized_settings_src = path.getabsolute(path.join(project_root, ".data_repos", "optimized-settings", "settings")) - local optimized_settings_dst = path.getabsolute(path.join(project_root, "build", "bin", "Linux")) .. "/%{cfg.buildcfg}/optimized_settings" - postbuildcommands { - '{MKDIR} ' .. optimized_settings_dst, - '{COPY} ' .. optimized_settings_src .. '/*.json ' .. optimized_settings_dst .. ' 2>/dev/null || true', - '{COPY} ' .. optimized_settings_src .. '/*.toml ' .. optimized_settings_dst .. ' 2>/dev/null || true' - } - - filter("platforms:Linux") - local game_patches_src = path.getabsolute(path.join(project_root, ".data_repos", "game-patches", "patches")) - local game_patches_dst = path.getabsolute(path.join(project_root, "build", "bin", "Linux")) .. "/%{cfg.buildcfg}/game_patches" - postbuildcommands { - '{MKDIR} ' .. game_patches_dst, - '{COPY} ' .. game_patches_src .. '/*.toml ' .. game_patches_dst - } - - -- Copy assets/font next to executable - filter("platforms:Linux") - local assets_font_src = path.getabsolute(path.join(project_root, "assets", "font")) - local assets_font_dst = path.getabsolute(path.join(project_root, "build", "bin", "Linux")) .. "/%{cfg.buildcfg}/assets/font" - postbuildcommands { - '{MKDIR} ' .. assets_font_dst, - '{COPY} ' .. assets_font_src .. '/* ' .. assets_font_dst - } diff --git a/src/xenia/apu/CMakeLists.txt b/src/xenia/apu/CMakeLists.txt new file mode 100644 index 000000000..456c68fb0 --- /dev/null +++ b/src/xenia/apu/CMakeLists.txt @@ -0,0 +1,13 @@ +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) +# AudioMediaPlayer instantiates SDLAudioDriver directly on Linux, so the +# SDL chain is a transitive dependency of xenia-apu there. +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(xenia-apu PUBLIC xenia-helper-sdl SDL2) +endif() +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 0b0b297e2..000000000 --- a/src/xenia/apu/premake5.lua +++ /dev/null @@ -1,26 +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", - }) - filter("platforms:Linux") - links({ - "xenia-helper-sdl", - "SDL2", - }) - sdl2_include() - filter({}) - 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..b2e8c99fd --- /dev/null +++ b/src/xenia/base/CMakeLists.txt @@ -0,0 +1,18 @@ +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/main_win.cc b/src/xenia/base/main_win.cc index 98e84a071..5df9b4b1d 100644 --- a/src/xenia/base/main_win.cc +++ b/src/xenia/base/main_win.cc @@ -15,8 +15,8 @@ #include "xenia/base/platform_win.h" #include "xenia/base/string.h" -// Autogenerated by `xb premake`. -#include "build/version.h" +// version.h is autogenerated by xenia-build.py into the CMake binary dir. +#include "version.h" // For RequestWin32MMCSS. #include 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..20491c344 --- /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 xenia-core xenia-cpu xenia-gpu +) diff --git a/src/xenia/base/testing/premake5.lua b/src/xenia/base/testing/premake5.lua deleted file mode 100644 index 371606537..000000000 --- a/src/xenia/base/testing/premake5.lua +++ /dev/null @@ -1,12 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -test_suite("xenia-base-tests", project_root, ".", { - links = { - "fmt", - "xenia-base", - "xenia-core", - "xenia-cpu", - "xenia-gpu", - }, -}) 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/a64/premake5.lua b/src/xenia/cpu/backend/a64/premake5.lua deleted file mode 100644 index 2ff243630..000000000 --- a/src/xenia/cpu/backend/a64/premake5.lua +++ /dev/null @@ -1,47 +0,0 @@ -project_root = "../../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-cpu-backend-a64") - uuid("495f3f3e-f5e8-489a-bd0f-289d0495bc08") - - -- Apply settings only for ARM64 - filter("architecture:ARM64") - kind("StaticLib") - language("C++") - cppdialect("C++20") - links({ - "fmt", - "xenia-base", - "xenia-cpu", - }) - sysincludedirs({ - project_root.."/third_party/oaknut/include", - }) - defines({ - }) - - -- Add oaknut as external include to suppress warnings - filter("toolset:clang or toolset:gcc") - externalincludedirs({ - project_root.."/third_party/oaknut/include", - }) - -- Also explicitly disable the warning for third-party code - buildoptions({ - "-Wno-shorten-64-to-32", - }) - filter("toolset:msc") - includedirs({ - project_root.."/third_party/oaknut/include", - }) - filter("architecture:ARM64") - - -- Include only ARM64-specific files - local_platform_files() - - -- For non-ARM64 architectures, create an empty static lib - filter("architecture:x86_64") - kind("None") - - -- Reset filter - filter({}) 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..6eb2e75b2 --- /dev/null +++ b/src/xenia/cpu/ppc/testing/CMakeLists.txt @@ -0,0 +1,41 @@ +if(NOT XENIA_BUILD_TESTS) + return() +endif() + +add_executable(xenia-cpu-ppc-tests + ${CMAKE_CURRENT_SOURCE_DIR}/ppc_testing_main.cc +) + +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() + +# Attach the PPC assembly test inputs to the target for IDE visibility; +# they're test data, not compiled code. +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 +) + +if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + target_link_libraries(xenia-cpu-ppc-tests PRIVATE xenia-cpu-backend-x64) +endif() + +# See src/xenia/apu/CMakeLists.txt — xenia-apu requires xenia-apu-sdl on Linux. +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(xenia-cpu-ppc-tests PRIVATE xenia-apu-sdl) +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 02f6d56b7..000000000 --- a/src/xenia/cpu/ppc/testing/premake5.lua +++ /dev/null @@ -1,97 +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", - }) - apu_transitive_deps() - -- Qt is required because xenia-kernel now uses Qt for achievements dialog - filter("platforms:Linux") - local qt_dir = os.getenv("QT_DIR") - if qt_dir then - links({ - "Qt6Core", - "Qt6Gui", - "Qt6Widgets", - }) - end - filter({}) - 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..a92ed2dda --- /dev/null +++ b/src/xenia/cpu/testing/CMakeLists.txt @@ -0,0 +1,13 @@ +xe_test_suite(xenia-cpu-tests ${CMAKE_CURRENT_SOURCE_DIR} + LINKS + capstone fmt imgui + xenia-apu xenia-base xenia-core xenia-cpu xenia-gpu + xenia-hid-skylander xenia-kernel xenia-ui xenia-patcher +) +if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64" AND TARGET xenia-cpu-tests) + target_link_libraries(xenia-cpu-tests PRIVATE xenia-cpu-backend-x64) +endif() +# xenia-apu pulls in xenia-apu-sdl on Linux (see src/xenia/apu/CMakeLists.txt). +if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND TARGET xenia-cpu-tests) + target_link_libraries(xenia-cpu-tests PRIVATE xenia-apu-sdl) +endif() diff --git a/src/xenia/cpu/testing/premake5.lua b/src/xenia/cpu/testing/premake5.lua deleted file mode 100644 index b9c5896fc..000000000 --- a/src/xenia/cpu/testing/premake5.lua +++ /dev/null @@ -1,32 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -test_suite("xenia-cpu-tests", project_root, ".", { - links = { - "capstone", - "fmt", - "imgui", - "xenia-apu", -- Explicitly link xenia-apu (transitively required by xenia-kernel) - "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", - }, - } - }, -}) - --- xenia-kernel links to xenia-apu, which needs SDL on Linux -apu_transitive_deps() diff --git a/src/xenia/debug/gdb/CMakeLists.txt b/src/xenia/debug/gdb/CMakeLists.txt new file mode 100644 index 000000000..3dadfc0eb --- /dev/null +++ b/src/xenia/debug/gdb/CMakeLists.txt @@ -0,0 +1,10 @@ +add_library(xenia-debug-gdb STATIC) +xe_platform_sources(xenia-debug-gdb ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(xenia-debug-gdb PUBLIC imgui xenia-base xenia-cpu xenia-ui) +if(MSVC) + # Prefer size over speed — the GDB stub isn't performance-critical. + target_compile_options(xenia-debug-gdb PRIVATE + $<$:/Os> + ) +endif() +xe_target_defaults(xenia-debug-gdb) diff --git a/src/xenia/debug/gdb/premake5.lua b/src/xenia/debug/gdb/premake5.lua deleted file mode 100644 index 9e6db656c..000000000 --- a/src/xenia/debug/gdb/premake5.lua +++ /dev/null @@ -1,25 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-debug-gdb") - uuid("9193a274-f4c2-4746-bd85-93fcfc5c3e39") - kind("StaticLib") - language("C++") - links({ - "imgui", - "xenia-base", - "xenia-cpu", - "xenia-ui", - }) - filter({"configurations:Release", "platforms:Windows"}) - buildoptions({ - "/Os", - "/O1" - }) - filter{} - defines({ - }) - includedirs({ - }) - local_platform_files() 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..bba9cfa95 --- /dev/null +++ b/src/xenia/gpu/CMakeLists.txt @@ -0,0 +1,37 @@ +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 +) +# Windows: SPIRV-Tools headers come from the Vulkan SDK +if(WIN32 AND DEFINED ENV{VULKAN_SDK}) + target_include_directories(xenia-gpu PRIVATE "$ENV{VULKAN_SDK}/Include") +endif() +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 + ) + if(WIN32 AND DEFINED ENV{VULKAN_SDK}) + target_include_directories(xenia-gpu-shader-compiler PRIVATE "$ENV{VULKAN_SDK}/Include") + endif() + 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..b6721e52a --- /dev/null +++ b/src/xenia/gpu/d3d12/CMakeLists.txt @@ -0,0 +1,40 @@ +add_library(xenia-gpu-d3d12 STATIC) +xe_platform_sources(xenia-gpu-d3d12 ${CMAKE_CURRENT_SOURCE_DIR}) +xe_shader_rules_dxbc(xenia-gpu-d3d12 ${CMAKE_CURRENT_SOURCE_DIR}/../shaders) +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) + 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_qt.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 0ef8f2da0..000000000 --- a/src/xenia/gpu/d3d12/premake5.lua +++ /dev/null @@ -1,130 +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", - }) - apu_transitive_deps() - files({ - "d3d12_trace_viewer_main.cc", - "../../ui/windowed_app_main_qt.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", - }) - apu_transitive_deps() - 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/metal/premake5.lua b/src/xenia/gpu/metal/premake5.lua deleted file mode 100644 index d228b8b0f..000000000 --- a/src/xenia/gpu/metal/premake5.lua +++ /dev/null @@ -1,326 +0,0 @@ --- premake5.lua -local project_root = "../../../.." -local metal_converter_libdir = path.join(project_root, "third_party/metal-shader-converter/lib") -local dxilconv_root = path.join(project_root, "third_party/DirectXShaderCompiler") -local dxilconv_libdir_arm64 = path.join(dxilconv_root, "build_dxilconv_macos/lib") -local dxilconv_libdir_x86_64 = - path.join(dxilconv_root, "build_dxilconv_macos_x86_64/lib") -local sdl2_libdir_arm64 = "/opt/homebrew/opt/sdl2/lib" -local sdl2_libdir_x86_64 = "/usr/local/opt/sdl2/lib" -local dxilconv_includes = { - path.join(dxilconv_root, "include"), - path.join(dxilconv_root, "projects/dxilconv/include"), -} - -include(path.join(project_root, "tools/build")) - ----------------------------------------------------------------------- --- GPU backend ------------------------------------------------------- ----------------------------------------------------------------------- - -group("src") -project("xenia-gpu-metal") - uuid("a1b2c3d4-e5f6-7890-abcd-ef1234567890") - kind("StaticLib") - language("C++") - - links { - "xenia-base", - "xenia-gpu", - "xenia-ui", - "fmt", - "metal-cpp", - } - - filter "system:macosx" - files { - "dxbc_to_dxil_converter.cc", - "dxbc_to_dxil_converter.h", - "ir_runtime_impl.mm", - "metal_command_processor.cc", - "metal_command_processor.h", - "metal_geometry_shader.cc", - "metal_geometry_shader.h", - "metal_graphics_system.cc", - "metal_graphics_system.h", - "metal_heap_pool.cc", - "metal_heap_pool.h", - "metal_primitive_processor.cc", - "metal_primitive_processor.h", - "metal_render_target_cache.cc", - "metal_render_target_cache.h", - "metal_shader.cc", - "metal_shader.h", - "metal_shader_cache.cc", - "metal_shader_cache.h", - "metal_shader_converter.cc", - "metal_shader_converter.h", - "metal_shared_memory.cc", - "metal_shared_memory.h", - "metal_texture_cache.cc", - "metal_texture_cache.h", - } - - includedirs { - dxilconv_includes[1], - dxilconv_includes[2], - path.join(project_root, "third_party/metal-shader-converter/include"), - "/usr/local/include/metal_irconverter_runtime" - } - - defines { "METAL_SHADER_CONVERTER_AVAILABLE" } - - libdirs { metal_converter_libdir } - runpathdirs { - "@executable_path/../Frameworks", - "@loader_path/../Frameworks", - metal_converter_libdir, - } - linkoptions({ - "-Wl,-rpath,@executable_path/../Frameworks", - "-Wl,-rpath,@loader_path/../Frameworks", - "-Wl,-headerpad_max_install_names", - }) - - links { - "Metal.framework", - "MetalKit.framework", - "metalirconverter", - "dxilconv", - "LLVMDxcSupport", - } - filter {"system:macosx", "architecture:ARM64"} - libdirs { dxilconv_libdir_arm64, sdl2_libdir_arm64 } - runpathdirs { dxilconv_libdir_arm64, sdl2_libdir_arm64 } - filter {"system:macosx", "architecture:x86_64"} - libdirs { dxilconv_libdir_x86_64, sdl2_libdir_x86_64 } - runpathdirs { dxilconv_libdir_x86_64, sdl2_libdir_x86_64 } - removelinks { "LLVMDxcSupport" } - linkoptions { - path.getabsolute(path.join(dxilconv_libdir_x86_64, - "libLLVMDxcSupport.a")), - } - filter "not system:macosx" - removefiles "**" - filter {} - ----------------------------------------------------------------------- --- Trace‑dump utility ----------------------------------------------- ----------------------------------------------------------------------- - -project("xenia-gpu-metal-trace-viewer") - uuid("2f2d0f7a-0c2c-4d6d-9e7a-9fb0b72fb2a1") - single_library_windowed_app_kind() - language("C++") - - links { - "xenia-apu", - "xenia-apu-nop", - "xenia-base", - "xenia-core", - "xenia-cpu", - "xenia-gpu", - "xenia-gpu-metal", - "xenia-hid", - "xenia-hid-nop", - "xenia-kernel", - "xenia-patcher", - "xenia-ui", - "xenia-ui-metal", - "xenia-vfs", - - "aes_128", - "capstone", - "fmt", - "imgui", - "libavcodec", - "libavutil", - "mspack", - "snappy", - "xxhash", - "metal-cpp", - } - - files { - "metal_trace_viewer_main.cc", - } - - -- Use the Qt entrypoint for macOS builds. - local qt_main = path.join("..", "..", "ui", "windowed_app_main_qt.cc") - - filter "system:macosx" - files { qt_main } - filter "not system:macosx" - removefiles "**" - filter {} - - filter "architecture:ARM64" - links { "xenia-cpu-backend-a64" } - - filter "system:macosx" - libdirs { metal_converter_libdir } - runpathdirs { metal_converter_libdir } - includedirs { - dxilconv_includes[1], - dxilconv_includes[2], - path.join(project_root, "third_party/metal-shader-converter/include"), - "/usr/local/include/metal_irconverter_runtime" - } - - defines { "METAL_SHADER_CONVERTER_AVAILABLE" } - - links { - "Cocoa.framework", - "CoreFoundation.framework", - "Metal.framework", - "MetalFX.framework", - "MetalKit.framework", - "QuartzCore.framework", - "SDL2", - "metalirconverter", - "dxilconv", - "LLVMDxcSupport", - } - xcodebuildsettings({ - ["GENERATE_INFOPLIST_FILE"] = "YES", - ["MACOSX_DEPLOYMENT_TARGET"] = "15.0", - ["PRODUCT_BUNDLE_IDENTIFIER"] = "com.xenia.gpu-metal-trace-viewer", - ["CODE_SIGN_STYLE"] = "Automatic", - ["LD_RUNPATH_SEARCH_PATHS"] = - "@executable_path/../Frameworks @loader_path/../Frameworks " - .. "@loader_path/../../../../third_party/metal-shader-converter/lib " - .. "/opt/homebrew/opt/sdl2/lib /usr/local/opt/sdl2/lib", - }) - filter {"system:macosx", "architecture:ARM64"} - libdirs { dxilconv_libdir_arm64 } - runpathdirs { dxilconv_libdir_arm64 } - linkoptions { - path.getabsolute(path.join(dxilconv_libdir_arm64, "libdxilconv.dylib")), - } - xcodebuildsettings({ - ["MACOSX_DEPLOYMENT_TARGET"] = "15.0", - ["LD_RUNPATH_SEARCH_PATHS"] = - "@executable_path/../Frameworks @loader_path/../Frameworks " - .. "@loader_path/../../../../third_party/metal-shader-converter/lib " - .. "@loader_path/../../../../third_party/DirectXShaderCompiler/build_dxilconv_macos/lib " - .. "/opt/homebrew/opt/sdl2/lib", - }) - filter {"system:macosx", "architecture:x86_64"} - libdirs { dxilconv_libdir_x86_64 } - runpathdirs { dxilconv_libdir_x86_64 } - removelinks { "SDL2", "LLVMDxcSupport" } - linkoptions { - path.getabsolute(path.join(dxilconv_libdir_x86_64, - "libLLVMDxcSupport.a")), - path.getabsolute("/usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib"), - } - xcodebuildsettings({ - ["MACOSX_DEPLOYMENT_TARGET"] = "15.0", - ["LD_RUNPATH_SEARCH_PATHS"] = - "@executable_path/../Frameworks @loader_path/../Frameworks " - .. "@loader_path/../../../../third_party/metal-shader-converter/lib " - .. "@loader_path/../../../../third_party/DirectXShaderCompiler/build_dxilconv_macos_x86_64/lib " - .. "/usr/local/opt/sdl2/lib", - }) - filter {} - -project("xenia-gpu-metal-trace-dump") - uuid("8e9f0a1b-2c3d-4e5f-6789-0abcdef12345") - kind("ConsoleApp") - language("C++") - - links { - "xenia-apu", - "xenia-apu-nop", - "xenia-base", - "xenia-core", - "xenia-cpu", - "xenia-gpu", - "xenia-gpu-metal", - "xenia-hid", - "xenia-hid-nop", - "xenia-kernel", - "xenia-patcher", - "xenia-ui", - "xenia-ui-metal", - "xenia-vfs", - - "aes_128", - "capstone", - "fmt", - "imgui", - "libavcodec", - "libavutil", - "mspack", - "snappy", - "xxhash", - "metal-cpp", - } - - files { - "metal_trace_dump_main.cc", - } - - -- Check if mac-specific file exists, otherwise use posix - local mac_main_cc = path.join("..", "..", "base", "console_app_main_mac.cc") - local mac_main_mm = path.join("..", "..", "base", "console_app_main_mac.mm") - local posix_main = path.join("..", "..", "base", "console_app_main_posix.cc") - - filter "system:macosx" - if os.isfile(path.join(project_root, "src/xenia/base/console_app_main_mac.mm")) then - files { mac_main_mm } - elseif os.isfile(path.join(project_root, "src/xenia/base/console_app_main_mac.cc")) then - files { mac_main_cc } - else - files { posix_main } - end - filter "not system:macosx" - files { path.join("..", "..", "base", "console_app_main_" .. platform_suffix .. ".cc") } - filter {} - - filter "architecture:ARM64" - links { "xenia-cpu-backend-a64" } - - filter "system:macosx" - libdirs { metal_converter_libdir } - runpathdirs { metal_converter_libdir } - includedirs { - dxilconv_includes[1], - dxilconv_includes[2], - path.join(project_root, "third_party/metal-shader-converter/include"), - "/usr/local/include/metal_irconverter_runtime" - } - - defines { "METAL_SHADER_CONVERTER_AVAILABLE" } - - links { - "Cocoa.framework", - "CoreFoundation.framework", - "Metal.framework", - "MetalFX.framework", - "MetalKit.framework", - "QuartzCore.framework", - "metalirconverter", - "dxilconv", - "LLVMDxcSupport", - } - xcodebuildsettings({ - ["MACOSX_DEPLOYMENT_TARGET"] = "15.0", - }) - filter {"system:macosx", "architecture:ARM64"} - libdirs { dxilconv_libdir_arm64, sdl2_libdir_arm64 } - runpathdirs { dxilconv_libdir_arm64, sdl2_libdir_arm64 } - linkoptions { - path.getabsolute(path.join(dxilconv_libdir_arm64, "libdxilconv.dylib")), - } - filter {"system:macosx", "architecture:x86_64"} - libdirs { dxilconv_libdir_x86_64, sdl2_libdir_x86_64 } - runpathdirs { dxilconv_libdir_x86_64, sdl2_libdir_x86_64 } - removelinks { "LLVMDxcSupport" } - linkoptions { - path.getabsolute(path.join(dxilconv_libdir_x86_64, - "libLLVMDxcSupport.a")), - } - filter "not system:macosx" - removefiles "**" - filter {} 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 73e0c381b..000000000 --- a/src/xenia/gpu/premake5.lua +++ /dev/null @@ -1,74 +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 - }) - - -- Include SPIRV-Tools headers from Vulkan SDK for Windows - filter("platforms:Windows") - includedirs({ - "$(VULKAN_SDK)/Include", - }) - filter({}) - - 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", - }) - files({ - "shader_compiler_main.cc", - "../base/console_app_main_"..platform_suffix..".cc", - }) - - -- Include SPIRV-Tools headers from Vulkan SDK - filter("platforms:Windows") - includedirs({ - "$(VULKAN_SDK)/Include", - }) - filter({}) - - 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/trace_writer.cc b/src/xenia/gpu/trace_writer.cc index e1fb81cce..bd78b55bf 100644 --- a/src/xenia/gpu/trace_writer.cc +++ b/src/xenia/gpu/trace_writer.cc @@ -14,7 +14,8 @@ #include "third_party/snappy/snappy-sinksource.h" #include "third_party/snappy/snappy.h" -#include "build/version.h" +// version.h is autogenerated by xenia-build.py into the CMake binary dir. +#include "version.h" #include "xenia/base/assert.h" #include "xenia/base/filesystem.h" #include "xenia/base/logging.h" diff --git a/src/xenia/gpu/vulkan/CMakeLists.txt b/src/xenia/gpu/vulkan/CMakeLists.txt new file mode 100644 index 000000000..86a38e940 --- /dev/null +++ b/src/xenia/gpu/vulkan/CMakeLists.txt @@ -0,0 +1,67 @@ +add_library(xenia-gpu-vulkan STATIC) +xe_platform_sources(xenia-gpu-vulkan ${CMAKE_CURRENT_SOURCE_DIR}) +xe_shader_rules_spirv(xenia-gpu-vulkan ${CMAKE_CURRENT_SOURCE_DIR}/../shaders) +target_include_directories(xenia-gpu-vulkan PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/Vulkan-Headers/include + ${PROJECT_SOURCE_DIR}/third_party/glslang +) +if(WIN32 AND DEFINED ENV{VULKAN_SDK}) + target_include_directories(xenia-gpu-vulkan PRIVATE "$ENV{VULKAN_SDK}/Include") +endif() +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) + add_executable(xenia-gpu-vulkan-trace-viewer + ${CMAKE_CURRENT_SOURCE_DIR}/vulkan_trace_viewer_main.cc + ${PROJECT_SOURCE_DIR}/src/xenia/ui/windowed_app_main_qt.cc + ) + 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 xenia-apu-sdl) + 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() + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(xenia-gpu-vulkan-trace-dump PRIVATE xenia-apu-sdl) + 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 6cb3cda84..000000000 --- a/src/xenia/gpu/vulkan/premake5.lua +++ /dev/null @@ -1,169 +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 - }) - - -- Include SPIRV-Tools headers from Vulkan SDK for Windows - filter("platforms:Windows") - includedirs({ - "$(VULKAN_SDK)/Include", - }) - filter({}) - - 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", - }) - apu_transitive_deps() - 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_qt.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", - }) - apu_transitive_deps() - 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..8b4e4c506 --- /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..f25c61dd0 --- /dev/null +++ b/src/xenia/kernel/CMakeLists.txt @@ -0,0 +1,24 @@ +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 + _WINSOCK_DEPRECATED_NO_WARNINGS + ) +endif() +target_link_libraries(xenia-kernel PUBLIC + aes_128 asio 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 d2799dbce..000000000 --- a/src/xenia/kernel/premake5.lua +++ /dev/null @@ -1,57 +0,0 @@ -project_root = "../../.." -include(project_root.."/tools/build") - -group("src") -project("xenia-kernel") - uuid("ae185c4a-1c4f-4503-9892-328e549e871a") - kind("StaticLib") - language("C++") - includedirs({ - project_root.."/third_party/asio/include", - }) - defines({ - "ASIO_STANDALONE", - "ASIO_NO_DEPRECATED", - }) - filter("platforms:Windows") - defines({ - "_WIN32_WINNT=0x0A00", -- Windows 10+ for Asio - "_WINSOCK_DEPRECATED_NO_WARNINGS", -- Suppress deprecated Winsock API warnings - }) - filter({}) - 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", - }) - -if enableTests then - include("testing") -end diff --git a/src/xenia/kernel/testing/premake5.lua b/src/xenia/kernel/testing/premake5.lua deleted file mode 100644 index 0787f15f7..000000000 --- a/src/xenia/kernel/testing/premake5.lua +++ /dev/null @@ -1,10 +0,0 @@ -project_root = "../../../.." -include(project_root.."/tools/build") - -test_suite("xenia-kernel-tests", project_root, ".", { - links = { - "fmt", - "xenia-base", - "xenia-kernel", - }, -}) 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..78003f133 --- /dev/null +++ b/src/xenia/ui/CMakeLists.txt @@ -0,0 +1,37 @@ +add_library(xenia-ui STATIC) +xe_platform_sources(xenia-ui ${CMAKE_CURRENT_SOURCE_DIR}) +# Demo files are standalone executables in XENIA_BUILD_MISC; moc_*.cc are +# owned by AUTOMOC and land in the build tree. Neither should reach this +# target's source list from the repo glob. +file(GLOB _ui_exclude + "${CMAKE_CURRENT_SOURCE_DIR}/*_demo.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/moc_*.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() +# The Qt resource compiler output is checked in under src/xenia/ui/ on +# Linux only (Windows embeds resources via main_resources.rc instead). +if(CMAKE_SYSTEM_NAME STREQUAL "Linux" + AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ui_resources_qrc.cpp") + target_sources(xenia-ui PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ui_resources_qrc.cpp) +endif() +target_link_libraries(xenia-ui PUBLIC xenia-base) +if(XE_HAS_QT) + target_link_libraries(xenia-ui PUBLIC Qt6::Core Qt6::Gui Qt6::Widgets) + target_link_libraries(xenia-ui PRIVATE Qt6::GuiPrivate) + # AUTOMOC-generated moc files sit in xenia-ui_autogen/ and include the + # original header via `#include "foo.h"`, so their directory needs to + # be on the quoted-include path. Scoped to this target — the global + # CMAKE_INCLUDE_CURRENT_DIR is off because other modules have source + # files that would shadow standard C headers. + target_include_directories(xenia-ui PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +endif() +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..551788884 --- /dev/null +++ b/src/xenia/ui/d3d12/CMakeLists.txt @@ -0,0 +1,23 @@ +add_library(xenia-ui-d3d12 STATIC) +xe_platform_sources(xenia-ui-d3d12 ${CMAKE_CURRENT_SOURCE_DIR}) +xe_shader_rules_dxbc(xenia-ui-d3d12 ${CMAKE_CURRENT_SOURCE_DIR}/../shaders) +target_link_libraries(xenia-ui-d3d12 PUBLIC xenia-base xenia-ui) +xe_target_defaults(xenia-ui-d3d12) + +if(XENIA_BUILD_MISC) + 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_qt.cc + ) + target_link_libraries(xenia-ui-window-d3d12-demo PRIVATE + xenia-apu xenia-base xenia-core xenia-cpu + xenia-gpu xenia-hid xenia-hid-skylander + xenia-kernel xenia-patcher xenia-ui xenia-ui-d3d12 xenia-vfs + aes_128 capstone dxbc fmt glslang-spirv imgui mspack snappy xxhash + ) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + target_link_libraries(xenia-ui-window-d3d12-demo PRIVATE xenia-cpu-backend-x64) + endif() + 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 19ec7ccad..000000000 --- a/src/xenia/ui/d3d12/premake5.lua +++ /dev/null @@ -1,62 +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-apu", - "xenia-base", - "xenia-core", - "xenia-gpu", - "xenia-hid", - "xenia-hid-skylander", - "xenia-kernel", -- Required by xenia-hid - "xenia-patcher", - "xenia-ui", - "xenia-ui-d3d12", - "xenia-vfs", - }) - links({ - "aes_128", - "capstone", - "dxbc", - "glslang-spirv", - "mspack", - "snappy", - "xxhash", - }) - apu_transitive_deps() - files({ - "../window_demo.cc", - "d3d12_window_demo.cc", - project_root.."/src/xenia/ui/windowed_app_main_qt.cc", - }) - resincludedirs({ - project_root, - }) - - filter("architecture:x86_64") - links({ - "xenia-cpu-backend-x64", - }) -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 ec7183382..000000000 --- a/src/xenia/ui/premake5.lua +++ /dev/null @@ -1,38 +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", - }) - 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" - }) - files({ - "ui_resources_qrc.cpp", - }) diff --git a/src/xenia/ui/vulkan/CMakeLists.txt b/src/xenia/ui/vulkan/CMakeLists.txt new file mode 100644 index 000000000..dfcd96ca6 --- /dev/null +++ b/src/xenia/ui/vulkan/CMakeLists.txt @@ -0,0 +1,47 @@ +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) +xe_shader_rules_spirv(xenia-ui-vulkan ${CMAKE_CURRENT_SOURCE_DIR}/../shaders) +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) + +# SPIRV-Tools: Vulkan SDK on Windows (headers + libs under $VULKAN_SDK), +# system package on Linux (libspirv-tools-*). +if(WIN32 AND DEFINED ENV{VULKAN_SDK}) + target_include_directories(xenia-ui-vulkan PRIVATE "$ENV{VULKAN_SDK}/Include") + target_link_directories(xenia-ui-vulkan PUBLIC "$ENV{VULKAN_SDK}/Lib") + target_link_libraries(xenia-ui-vulkan PUBLIC SPIRV-Tools-opt SPIRV-Tools) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(xenia-ui-vulkan PUBLIC SPIRV-Tools-opt SPIRV-Tools) +endif() +xe_target_defaults(xenia-ui-vulkan) + +if(XENIA_BUILD_MISC) + add_executable(xenia-ui-window-vulkan-demo + ${CMAKE_CURRENT_SOURCE_DIR}/../window_demo.cc + ${CMAKE_CURRENT_SOURCE_DIR}/vulkan_window_demo.cc + ${PROJECT_SOURCE_DIR}/src/xenia/ui/windowed_app_main_qt.cc + ) + if(WIN32) + set_target_properties(xenia-ui-window-vulkan-demo PROPERTIES WIN32_EXECUTABLE TRUE) + endif() + 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 + xenia-apu xenia-base xenia-core xenia-cpu + xenia-gpu xenia-hid xenia-hid-skylander + xenia-kernel xenia-patcher xenia-ui xenia-ui-vulkan xenia-vfs + aes_128 capstone dxbc fmt glslang-spirv imgui mspack snappy xxhash + ) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + target_link_libraries(xenia-ui-window-vulkan-demo PRIVATE xenia-cpu-backend-x64) + endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(xenia-ui-window-vulkan-demo PRIVATE X11 xcb X11-xcb xenia-apu-sdl) + 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 6d90277bf..000000000 --- a/src/xenia/ui/vulkan/premake5.lua +++ /dev/null @@ -1,97 +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 - }) - - -- Include SPIRV-Tools from Vulkan SDK - filter("platforms:Windows") - includedirs({ - "$(VULKAN_SDK)/Include", - }) - libdirs({ - "$(VULKAN_SDK)/Lib", - }) - links({ - "SPIRV-Tools-opt.lib", - "SPIRV-Tools.lib", - }) - - filter("platforms:Linux") - links({ - "SPIRV-Tools-opt", - "SPIRV-Tools", - }) - filter({}) - 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-apu", - "xenia-base", - "xenia-core", - "xenia-gpu", - "xenia-hid", - "xenia-hid-skylander", - "xenia-kernel", -- Required by xenia-hid - "xenia-patcher", - "xenia-ui", - "xenia-ui-vulkan", - "xenia-vfs", - }) - links({ - "aes_128", - "capstone", - "dxbc", - "glslang-spirv", - "mspack", - "snappy", - "xxhash", - }) - apu_transitive_deps() - includedirs({ - project_root.."/third_party/Vulkan-Headers/include", - }) - files({ - "../window_demo.cc", - "vulkan_window_demo.cc", - project_root.."/src/xenia/ui/windowed_app_main_qt.cc", - }) - resincludedirs({ - project_root, - }) - - filter("architecture:x86_64") - links({ - "xenia-cpu-backend-x64", - }) - - filter("platforms:Linux") - links({ - "X11", - "xcb", - "X11-xcb", - }) -end diff --git a/src/xenia/vfs/CMakeLists.txt b/src/xenia/vfs/CMakeLists.txt new file mode 100644 index 000000000..a06a5f86c --- /dev/null +++ b/src/xenia/vfs/CMakeLists.txt @@ -0,0 +1,48 @@ +add_library(xenia-vfs STATIC) +xe_platform_sources(xenia-vfs ${CMAKE_CURRENT_SOURCE_DIR} RECURSIVE) +# Exclude vfs_dump.cc and xex_metadata_main.cc (these are their own executables) +file(GLOB _vfs_exclude + "${CMAKE_CURRENT_SOURCE_DIR}/vfs_dump.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/xex_metadata_main.cc" +) +get_target_property(_vfs_srcs xenia-vfs SOURCES) +if(_vfs_exclude AND _vfs_srcs) + list(REMOVE_ITEM _vfs_srcs ${_vfs_exclude}) + 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) + +# xenia-xex-metadata: standalone console tool that dumps XEX metadata +add_executable(xenia-xex-metadata + ${CMAKE_CURRENT_SOURCE_DIR}/xex_metadata_main.cc +) +if(WIN32) + target_sources(xenia-xex-metadata PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/console_app_main_win.cc) +else() + target_sources(xenia-xex-metadata PRIVATE + ${PROJECT_SOURCE_DIR}/src/xenia/base/console_app_main_posix.cc) +endif() +target_link_libraries(xenia-xex-metadata PRIVATE fmt xenia-base xenia-vfs) +xe_target_defaults(xenia-xex-metadata) + +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 d187cb524..000000000 --- a/src/xenia/vfs/premake5.lua +++ /dev/null @@ -1,61 +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", - "xex_metadata_main.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, - }) - - project("xenia-xex-metadata") - uuid("A1B2C3D4-E5F6-7890-ABCD-EF1234567890") - kind("ConsoleApp") - language("C++") - links({ - "fmt", - "xenia-base", - "xenia-vfs", - }) - - files({ - "xex_metadata_main.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..cf4e6e774 --- /dev/null +++ b/third_party/CMakeLists.txt @@ -0,0 +1,687 @@ +# Suppress warnings for all third-party code — we can't clean them up and +# don't want them contributing to -Werror noise on our own targets. +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) + +# ============================================================================== +# asio (header-only) +# ============================================================================== +add_library(asio INTERFACE) +target_include_directories(asio INTERFACE asio/include) +target_compile_definitions(asio INTERFACE + ASIO_STANDALONE + ASIO_NO_DEPRECATED +) +if(WIN32) + target_compile_definitions(asio INTERFACE _WIN32_WINNT=0x0A00) +endif() + +# ============================================================================== +# 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) + +# ============================================================================== +# miniaudio (header-only) +# ============================================================================== +add_library(miniaudio INTERFACE) +target_include_directories(miniaudio INTERFACE miniaudio) + +# ============================================================================== +# 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) + +# ============================================================================== +# oaknut (header-only, ARM64 codegen) +# ============================================================================== +add_library(oaknut INTERFACE) +target_include_directories(oaknut INTERFACE oaknut/include) + +# ============================================================================== +# 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 — upstream source lives in the FFmpeg submodule; xenia's static +# config.h / asm configuration overlay lives in ffmpeg-xenia alongside it. +# ============================================================================== + +# Shared FFmpeg settings applied to each libav* target (defines, include +# paths, platform-specific link deps, warning suppression, C linkage). +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) + # FFmpeg in unoptimized builds emits so much dead code that link time + # blows up; /Os keeps Debug and Checked within sane limits. + target_compile_options(${target} PRIVATE + $<$:/Os> + $<$:/Os> + ) + else() + target_include_directories(${target} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/FFmpeg/compat/atomics/gcc + ) + # glibc POSIX feature macros — FFmpeg assumes them for certain + # syscalls and string extensions. + target_compile_definitions(${target} PRIVATE + _GNU_SOURCE + _POSIX_C_SOURCE=200809L + _XOPEN_SOURCE=700 + ) + endif() + + 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 da0456f8b..000000000 --- a/third_party/SDL2.lua +++ /dev/null @@ -1,94 +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 sdl2_sys_libdirs = {} -local third_party_path = os.getcwd() -local sdl2_config = os.getenv("SDL2_CONFIG") or "sdl2-config" - -if os.istarget("windows") then - -- build ourselves - include("SDL2-static.lua") -else - -- use system libraries - if os.istarget("macosx") then - local target_arch = os.targetarch() or "" - local option_arch = _OPTIONS and _OPTIONS["arch"] or "" - local want_x86 = - _OPTIONS and _OPTIONS["mac-x86_64"] or - target_arch == "x86_64" or target_arch == "x64" or - option_arch == "x86_64" or option_arch == "x64" - local want_arm = target_arch == "arm64" or option_arch == "arm64" - if want_x86 and os.isfile("/usr/local/bin/sdl2-config") then - sdl2_config = "/usr/local/bin/sdl2-config" - elseif want_arm and os.isfile("/opt/homebrew/bin/sdl2-config") then - sdl2_config = "/opt/homebrew/bin/sdl2-config" - end - end - local result, code, what = os.outputof(sdl2_config .. " --cflags") - if result then - print("SDL2: sdl2-config --cflags returned: " .. result) - for inc in string.gmatch(result, "-I([%S]+)") do - table.insert(sdl2_sys_includedirs, inc) - print("SDL2: Added include dir: " .. inc) - end - if #sdl2_sys_includedirs == 0 then - print("SDL2: Warning - no include directories found in sdl2-config output") - end - else - error("Failed to run 'sdl2-config'. Are libsdl2 development files installed?") - end - local libs, libs_code, libs_what = os.outputof(sdl2_config .. " --libs") - if libs then - for libdir in string.gmatch(libs, "-L([%S]+)") do - table.insert(sdl2_sys_libdirs, libdir) - end - else - error("Failed to run 'sdl2-config --libs'. Are libsdl2 development files installed?") - end -end - -if os.istarget("macosx") then - local target_arch = os.targetarch() or "" - local option_arch = _OPTIONS and _OPTIONS["arch"] or "" - local want_x86 = - _OPTIONS and _OPTIONS["mac-x86_64"] or - target_arch == "x86_64" or target_arch == "x64" or - option_arch == "x86_64" or option_arch == "x64" - local want_arm = target_arch == "arm64" or option_arch == "arm64" - if want_x86 and os.isdir("/usr/local/opt/sdl2/lib") then - table.insert(sdl2_sys_libdirs, "/usr/local/opt/sdl2/lib") - elseif want_arm and os.isdir("/opt/homebrew/opt/sdl2/lib") then - table.insert(sdl2_sys_libdirs, "/opt/homebrew/opt/sdl2/lib") - 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 Mac") - includedirs(sdl2_sys_includedirs) - libdirs(sdl2_sys_libdirs) - filter({}) - - -- For Linux, also add SDL2 includes outside of filter for cmake compatibility - -- The premake-cmake module doesn't properly handle filtered include directories - if os.istarget("linux") then - includedirs(sdl2_sys_includedirs) - libdirs(sdl2_sys_libdirs) - -- Also add common fallback path for cases where sdl2-config doesn't return -I flags - if #sdl2_sys_includedirs == 0 then - includedirs({"/usr/include/SDL2"}) - print("SDL2: Using fallback include path /usr/include/SDL2") - else - print("SDL2: Added includes for Linux cmake: " .. table.concat(sdl2_sys_includedirs, ", ")) - end - end -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/asio.lua b/third_party/asio.lua deleted file mode 100644 index 72e9fc0b7..000000000 --- a/third_party/asio.lua +++ /dev/null @@ -1,26 +0,0 @@ -group("third_party") -project("asio") - uuid("a5f06be0-9c7d-4e8f-b2a1-3d4c5e6f7890") - kind("Utility") - language("C++") - - includedirs({ - "third_party/asio/include", - }) - - defines({ - "ASIO_STANDALONE", - "ASIO_NO_DEPRECATED", - }) - - filter("platforms:Windows") - defines({ - "_WIN32_WINNT=0x0A00", -- Windows 10+ - }) - filter({}) - - files({ - "third_party/asio/include/asio.hpp", - }) - - warnings("Off") diff --git a/third_party/capstone.lua b/third_party/capstone.lua deleted file mode 100644 index f2f25681e..000000000 --- a/third_party/capstone.lua +++ /dev/null @@ -1,73 +0,0 @@ -group("third_party") -project("capstone") - uuid("b3a89f7e-bb02-4945-ae75-219caed6afa2") - kind("StaticLib") - language("C") - defines({ - "CAPSTONE_DIET_NO", - "CAPSTONE_USE_SYS_DYN_MEM", - "_LIB", - }) - filter("architecture:x86_64") - defines({ - "CAPSTONE_HAS_X86", - "CAPSTONE_X86_ATT_DISABLE", - "CAPSTONE_X86_REDUCE_NO", - }) - files({ - "capstone/arch/X86/*.c", - "capstone/arch/X86/*.h", - "capstone/arch/X86/*.inc", - }) - force_compile_as_c({ - "capstone/arch/X86/**.c", - }) - filter("architecture:ARM64") - defines({ - "CAPSTONE_HAS_AARCH64", - "CAPSTONE_HAS_ARM64", - }) - files({ - "capstone/arch/AArch64/*.c", - "capstone/arch/AArch64/*.h", - "capstone/arch/AArch64/*.inc", - }) - force_compile_as_c({ - "capstone/arch/AArch64/**.c", - }) - filter({}) - includedirs({ - "capstone", - "capstone/include", - }) - externalincludedirs({ - "capstone/include", - }) - files({ - "capstone/cs.c", - "capstone/cs_priv.h", - "capstone/LEB128.h", - "capstone/MathExtras.h", - "capstone/MCDisassembler.h", - "capstone/MCFixedLenDisassembler.h", - "capstone/MCInst.c", - "capstone/MCInst.h", - "capstone/MCInstPrinter.c", - "capstone/MCInstPrinter.h", - "capstone/MCInstrDesc.c", - "capstone/MCInstrDesc.h", - "capstone/MCRegisterInfo.c", - "capstone/MCRegisterInfo.h", - "capstone/SStream.c", - "capstone/SStream.h", - "capstone/utils.c", - "capstone/utils.h", - "capstone/Mapping.c", - }) - force_compile_as_c({ - "capstone/**.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 538030907..000000000 --- a/third_party/discord-rpc.lua +++ /dev/null @@ -1,65 +0,0 @@ -group("third_party") -project("discord-rpc") - uuid("012f6131-efc0-4abd-852d-a33640732d4c") - kind("StaticLib") - language("C++") - includedirs({ - "discord-rpc/include", - "rapidjson/include" - }) - - -- Common files for all platforms - 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" - }) - - -- x86_64 uses SSE4.2, ARM64 uses NEON for rapidjson SIMD - filter("architecture:x86_64") - defines({ "RAPIDJSON_SSE42" }) - filter("architecture:ARM64") - defines({ "RAPIDJSON_NEON" }) - filter({}) - - -- Platform-specific connection implementations - -- For premake-cmake compatibility, we use os.istarget() which is evaluated at - -- premake generation time. This ensures the correct files are included in cmake. - if os.istarget("linux") then - files({ - "discord-rpc/src/connection_unix.cpp", - "discord-rpc/src/discord_register_linux.cpp" - }) - elseif os.istarget("macosx") then - files({ - "discord-rpc/src/connection_unix.cpp", - "discord-rpc/src/discord_register_osx.m" - }) - elseif os.istarget("windows") then - files({ - "discord-rpc/src/connection_win.cpp", - "discord-rpc/src/discord_register_win.cpp" - }) - end - - -- Also add system filter for generators that handle platforms differently - filter("system:linux") - files({ - "discord-rpc/src/connection_unix.cpp", - "discord-rpc/src/discord_register_linux.cpp" - }) - filter("system:macosx") - files({ - "discord-rpc/src/connection_unix.cpp", - "discord-rpc/src/discord_register_osx.m" - }) - filter("system:windows") - files({ - "discord-rpc/src/connection_win.cpp", - "discord-rpc/src/discord_register_win.cpp" - }) - filter({}) 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/libavcodec/premake5.lua b/third_party/ffmpeg-xenia/libavcodec/premake5.lua deleted file mode 100644 index 8c922d4d8..000000000 --- a/third_party/ffmpeg-xenia/libavcodec/premake5.lua +++ /dev/null @@ -1,156 +0,0 @@ -project("libavcodec") - uuid("9DB2830C-D326-48ED-B4CC-08EA6A1B7272") - kind("StaticLib") - language("C") - ffmpeg_common() - - filter("files:not ../../FFmpeg/libavcodec/wmaprodec.c") - warnings "Off" - filter({}) - - links({ - "libavutil", - }) - - -- Needed for files in subdirectories (e.g. bsf/null.c) that include - -- headers relative to libavcodec/. - includedirs({ - "../../FFmpeg/libavcodec", - }) - - -- libavcodec/Makefile: - -- HEADERS: - files({ - "../../FFmpeg/libavcodec/ac3_parser.h", - "../../FFmpeg/libavcodec/adts_parser.h", - "../../FFmpeg/libavcodec/avcodec.h", - "../../FFmpeg/libavcodec/avdct.h", - "../../FFmpeg/libavcodec/bsf.h", - "../../FFmpeg/libavcodec/codec.h", - "../../FFmpeg/libavcodec/codec_desc.h", - "../../FFmpeg/libavcodec/codec_id.h", - "../../FFmpeg/libavcodec/codec_par.h", - "../../FFmpeg/libavcodec/d3d11va.h", - "../../FFmpeg/libavcodec/dirac.h", - "../../FFmpeg/libavcodec/dv_profile.h", - "../../FFmpeg/libavcodec/dxva2.h", - "../../FFmpeg/libavcodec/jni.h", - "../../FFmpeg/libavcodec/mediacodec.h", - "../../FFmpeg/libavcodec/packet.h", - "../../FFmpeg/libavcodec/qsv.h", - "../../FFmpeg/libavcodec/vdpau.h", - "../../FFmpeg/libavcodec/version.h", - "../../FFmpeg/libavcodec/videotoolbox.h", - "../../FFmpeg/libavcodec/vorbis_parser.h", - }) - -- OBJS: - files({ - "../../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", - }) - filter({"platforms:Windows"}) - files({ - "../../FFmpeg/libavcodec/file_open.c", - }) - filter({}) - - -- libavcodec/aarch64/Makefile: - -- OBJS: - filter({"platforms:Android-ARM64"}) - files({ - "../../FFmpeg/libavcodec/aarch64/idctdsp_init_aarch64.c", - "../../FFmpeg/libavcodec/aarch64/mpegaudiodsp_init.c", - }) - filter({}) - -- NEON-OBJS: - filter({"platforms:Android-ARM64"}) - files({ - "../../FFmpeg/libavcodec/aarch64/fft_neon.S", - "../../FFmpeg/libavcodec/aarch64/simple_idct_neon.S", - "../../FFmpeg/libavcodec/aarch64/mdct_neon.S", - "../../FFmpeg/libavcodec/aarch64/mpegaudiodsp_neon.S", - }) - filter({}) - - -- libavcodec/x86/Makefile: - -- OBJS: - filter({"platforms:Android-x86_64 or platforms:Linux or platforms:Windows"}) - files({ - "../../FFmpeg/libavcodec/x86/constants.c", - "../../FFmpeg/libavcodec/x86/fdctdsp_init.c", - "../../FFmpeg/libavcodec/x86/idctdsp_init.c", - "../../FFmpeg/libavcodec/x86/mpegaudiodsp.c", - }) - filter({}) - -- MMX-OBJS: - filter({"platforms:Android-x86_64 or platforms:Linux or platforms:Windows"}) - files({ - "../../FFmpeg/libavcodec/x86/fdct.c", - }) - filter({}) diff --git a/third_party/ffmpeg-xenia/libavformat/premake5.lua b/third_party/ffmpeg-xenia/libavformat/premake5.lua deleted file mode 100644 index 489034d34..000000000 --- a/third_party/ffmpeg-xenia/libavformat/premake5.lua +++ /dev/null @@ -1,61 +0,0 @@ -project("libavformat") - uuid("CEF2E128-AA08-4A36-8045-0AA68A556364") - kind("StaticLib") - language("C") - ffmpeg_common() - - filter("files:not wmaprodec.c") - warnings "Off" - filter({}) - - links({ - "libavutil", - "libavcodec", - }) - - -- libavformat/Makefile: - -- HEADERS: - files({ - "../../FFmpeg/libavformat/avformat.h", - "../../FFmpeg/libavformat/avio.h", - "../../FFmpeg/libavformat/version.h", - }) - -- OBJS: - files({ - "../../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", - }) - filter({"platforms:Windows"}) - files({ - "../../FFmpeg/libavformat/file_open.c", - }) - filter({}) diff --git a/third_party/ffmpeg-xenia/libavutil/premake5.lua b/third_party/ffmpeg-xenia/libavutil/premake5.lua deleted file mode 100644 index 009797019..000000000 --- a/third_party/ffmpeg-xenia/libavutil/premake5.lua +++ /dev/null @@ -1,225 +0,0 @@ -project("libavutil") - uuid("19216035-F781-4F15-B009-213B7E3A18AC") - kind("StaticLib") - language("C") - ffmpeg_common() - - filter("files:not wmaprodec.c") - warnings "Off" - filter({}) - - -- libavutil/Makefile: - -- HEADERS: - files({ - "../../FFmpeg/libavutil/adler32.h", - "../../FFmpeg/libavutil/aes.h", - "../../FFmpeg/libavutil/aes_ctr.h", - "../../FFmpeg/libavutil/attributes.h", - "../../FFmpeg/libavutil/audio_fifo.h", - "../../FFmpeg/libavutil/avassert.h", - "../../FFmpeg/libavutil/avstring.h", - "../../FFmpeg/libavutil/avutil.h", - "../../FFmpeg/libavutil/base64.h", - "../../FFmpeg/libavutil/blowfish.h", - "../../FFmpeg/libavutil/bprint.h", - "../../FFmpeg/libavutil/bswap.h", - "../../FFmpeg/libavutil/buffer.h", - "../../FFmpeg/libavutil/cast5.h", - "../../FFmpeg/libavutil/camellia.h", - "../../FFmpeg/libavutil/channel_layout.h", - "../../FFmpeg/libavutil/common.h", - "../../FFmpeg/libavutil/cpu.h", - "../../FFmpeg/libavutil/crc.h", - "../../FFmpeg/libavutil/des.h", - "../../FFmpeg/libavutil/dict.h", - "../../FFmpeg/libavutil/display.h", - "../../FFmpeg/libavutil/dovi_meta.h", - "../../FFmpeg/libavutil/downmix_info.h", - "../../FFmpeg/libavutil/encryption_info.h", - "../../FFmpeg/libavutil/error.h", - "../../FFmpeg/libavutil/eval.h", - "../../FFmpeg/libavutil/fifo.h", - "../../FFmpeg/libavutil/file.h", - "../../FFmpeg/libavutil/frame.h", - "../../FFmpeg/libavutil/hash.h", - "../../FFmpeg/libavutil/hdr_dynamic_metadata.h", - "../../FFmpeg/libavutil/hmac.h", - "../../FFmpeg/libavutil/hwcontext.h", - "../../FFmpeg/libavutil/hwcontext_cuda.h", - "../../FFmpeg/libavutil/hwcontext_d3d11va.h", - "../../FFmpeg/libavutil/hwcontext_drm.h", - "../../FFmpeg/libavutil/hwcontext_dxva2.h", - "../../FFmpeg/libavutil/hwcontext_qsv.h", - "../../FFmpeg/libavutil/hwcontext_mediacodec.h", - "../../FFmpeg/libavutil/hwcontext_opencl.h", - "../../FFmpeg/libavutil/hwcontext_vaapi.h", - "../../FFmpeg/libavutil/hwcontext_videotoolbox.h", - "../../FFmpeg/libavutil/hwcontext_vdpau.h", - "../../FFmpeg/libavutil/hwcontext_vulkan.h", - "../../FFmpeg/libavutil/imgutils.h", - "../../FFmpeg/libavutil/intfloat.h", - "../../FFmpeg/libavutil/intreadwrite.h", - "../../FFmpeg/libavutil/lfg.h", - "../../FFmpeg/libavutil/log.h", - "../../FFmpeg/libavutil/macros.h", - "../../FFmpeg/libavutil/mathematics.h", - "../../FFmpeg/libavutil/mastering_display_metadata.h", - "../../FFmpeg/libavutil/md5.h", - "../../FFmpeg/libavutil/mem.h", - "../../FFmpeg/libavutil/motion_vector.h", - "../../FFmpeg/libavutil/murmur3.h", - "../../FFmpeg/libavutil/opt.h", - "../../FFmpeg/libavutil/parseutils.h", - "../../FFmpeg/libavutil/pixdesc.h", - "../../FFmpeg/libavutil/pixelutils.h", - "../../FFmpeg/libavutil/pixfmt.h", - "../../FFmpeg/libavutil/random_seed.h", - "../../FFmpeg/libavutil/rc4.h", - "../../FFmpeg/libavutil/rational.h", - "../../FFmpeg/libavutil/replaygain.h", - "../../FFmpeg/libavutil/ripemd.h", - "../../FFmpeg/libavutil/samplefmt.h", - "../../FFmpeg/libavutil/sha.h", - "../../FFmpeg/libavutil/sha512.h", - "../../FFmpeg/libavutil/spherical.h", - "../../FFmpeg/libavutil/stereo3d.h", - "../../FFmpeg/libavutil/threadmessage.h", - "../../FFmpeg/libavutil/time.h", - "../../FFmpeg/libavutil/timecode.h", - "../../FFmpeg/libavutil/timestamp.h", - "../../FFmpeg/libavutil/tree.h", - "../../FFmpeg/libavutil/twofish.h", - "../../FFmpeg/libavutil/version.h", - "../../FFmpeg/libavutil/video_enc_params.h", - "../../FFmpeg/libavutil/xtea.h", - "../../FFmpeg/libavutil/tea.h", - "../../FFmpeg/libavutil/tx.h", - "../../FFmpeg/libavutil/film_grain_params.h", - }) - -- ARCH_HEADERS: - files({ - "../../FFmpeg/libavutil/bswap.h", - "../../FFmpeg/libavutil/intmath.h", - "../../FFmpeg/libavutil/intreadwrite.h", - "../../FFmpeg/libavutil/timer.h", - }) - -- BUILT_HEADERS (local xenia-specific copies): - files({ - "avconfig.h", - "ffversion.h", - }) - -- OBJS: - files({ - "../../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", - }) - - -- libavutil/aarch64/Makefile: - -- OBJS: - filter({"platforms:Android-ARM64"}) - files({ - "../../FFmpeg/libavutil/aarch64/cpu.c", - "../../FFmpeg/libavutil/aarch64/float_dsp_init.c", - "../../FFmpeg/libavutil/aarch64/tx_float_init.c", - }) - filter({}) - -- NEON-OBJS: - filter({"platforms:Android-ARM64"}) - files({ - "../../FFmpeg/libavutil/aarch64/float_dsp_neon.S", - }) - filter({}) - - -- libavutil/x86/Makefile: - -- OBJS: - filter({"platforms:Android-x86_64 or platforms:Linux or platforms:Windows"}) - files({ - "../../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", - }) - filter({}) 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/metal-cpp.lua b/third_party/metal-cpp.lua deleted file mode 100644 index 50bf89b2c..000000000 --- a/third_party/metal-cpp.lua +++ /dev/null @@ -1,21 +0,0 @@ -if not os.istarget("macosx") then - return -end - -group("third_party") -project("metal-cpp") - uuid("11c84c8d-bfa2-4b14-b832-4e85e9ca8e3b") - kind("None") -- Header-only library - language("C++") - defines({ - "METAL_CPP_AVAILABLE=1", - }) - includedirs({ - "metal-cpp", - }) - files({ - "metal-cpp/Foundation/Foundation.hpp", - "metal-cpp/Metal/Metal.hpp", - "metal-cpp/MetalFX/MetalFX.hpp", - "metal-cpp/QuartzCore/QuartzCore.hpp", - }) diff --git a/third_party/metal-shader-converter.lua b/third_party/metal-shader-converter.lua deleted file mode 100644 index d762e9015..000000000 --- a/third_party/metal-shader-converter.lua +++ /dev/null @@ -1,30 +0,0 @@ -if not os.istarget("macosx") then - return -end - -group("third_party") -project("metal-shader-converter") - uuid("b1b2c3d4-e5f6-7890-abcd-ef1234567890") - kind("StaticLib") - language("C++") - defines({ - "_LIB", - }) - includedirs({ - "metal-shader-converter/include", - }) - files({ - "metal-shader-converter/include/metal_irconverter.h", - "metal-shader-converter/include/metal_irconverter_runtime.h", - }) - -- Link against the Metal Shader Converter dynamic library - libdirs({ - "metal-shader-converter/lib", - }) - links({ - "metalirconverter", - }) - links({ - "Metal.framework", - "MetalKit.framework", - }) diff --git a/third_party/miniaudio.lua b/third_party/miniaudio.lua deleted file mode 100644 index 8ef445a87..000000000 --- a/third_party/miniaudio.lua +++ /dev/null @@ -1,14 +0,0 @@ -group("third_party") -project("miniaudio") - uuid("d8f3a2b1-c4e5-4f6a-8b9c-0d1e2f3a4b5c") - if os.istarget("android") then - -- ndk-build only supports StaticLib and SharedLib. - kind("StaticLib") - else - kind("Utility") - end - language("C") - files({ - "miniaudio/miniaudio.h", - }) - warnings("Off") 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/premake-androidndk b/third_party/premake-androidndk deleted file mode 160000 index 35a695541..000000000 --- a/third_party/premake-androidndk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 35a6955410a34840c9d091f071c46cd3e5280fb7 diff --git a/third_party/premake-cmake b/third_party/premake-cmake deleted file mode 160000 index db70344d7..000000000 --- a/third_party/premake-cmake +++ /dev/null @@ -1 +0,0 @@ -Subproject commit db70344d70d6d5cd62094b28258ecbea5c19ebb2 diff --git a/third_party/premake-core b/third_party/premake-core deleted file mode 160000 index ba2c383c0..000000000 --- a/third_party/premake-core +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ba2c383c0456aa75d1b93faf62f4aec2691f23b2 diff --git a/third_party/premake-export-compile-commands b/third_party/premake-export-compile-commands deleted file mode 160000 index 59e3e55df..000000000 --- a/third_party/premake-export-compile-commands +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 59e3e55df8dd87eea70556f50d172a17f1c4b6d0 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 d72f96f40..000000000 --- a/third_party/snappy.lua +++ /dev/null @@ -1,25 +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", - }) - - -- Disable AVX requirement to prevent BMI2 instructions from being baked in at compile time - -- This allows Snappy to work on CPUs without BMI2 support (e.g., Sandy Bridge, Ivy Bridge) - 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 "..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 da85f15d5..000000000 --- a/third_party/zlib-ng.lua +++ /dev/null @@ -1,68 +0,0 @@ -group("third_party") -project("zlib-ng") - uuid("13d4073d-f1c9-47e3-a057-79b133596fc2") - kind("StaticLib") - language("C") - - defines({ - "WITH_GZFILEOP", - }) - - files({ - "zlib-ng/*.c", - "zlib-ng/arch/generic/*.c", - }) - filter("architecture:x86_64") - defines({ - "X86_FEATURES", - "X86_HAVE_XSAVE_INTRIN", - "X86_SSSE3", - "X86_SSE42", - }) - files({ - "zlib-ng/arch/x86/*.c", - }) - if os.istarget("windows") then - defines({ - "X86_SSE2", - "X86_AVX2", - "X86_AVX512", - "X86_AVX512VNNI", - "X86_PCLMULQDQ_CRC", - "X86_VPCLMULQDQ_CRC", - }) - else - 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 - filter({}) - - 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 e26713288..000000000 --- a/third_party/zstd.lua +++ /dev/null @@ -1,19 +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", - }) - filter({"toolset:msc"}) - defines({ - -- Override STATIC_BMI2=1 assumption on Windows - -- MSVC incorrectly assumes AVX2 implies BMI2, but Sandy Bridge has AVX2 without BMI2 - "STATIC_BMI2=0", - "DYNAMIC_BMI2=1", - }) - filter({}) - 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/compile_shader_dxbc.py b/tools/build/compile_shader_dxbc.py new file mode 100644 index 000000000..d191a2125 --- /dev/null +++ b/tools/build/compile_shader_dxbc.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python3 + +"""Compiles a single shader to DXBC and generates a C header via FXC. + +Usage: compile_shader_dxbc.py + +FXC directly produces the .h file — no post-processing needed. +""" + +import os +import subprocess +import sys +from glob import glob + + +DXBC_STAGES = ["vs", "hs", "ds", "gs", "ps", "cs"] + + +def find_fxc(): + """Find FXC via FXC_PATH env or Windows SDK search.""" + fxc = os.environ.get("FXC_PATH") + if fxc: + return fxc + + # Search Windows Kits. + program_files_x86 = os.environ.get("ProgramFiles(x86)", "") + candidates = glob(os.path.join( + program_files_x86, "Windows Kits", "10", "bin", "*", "x64", "fxc.exe")) + if candidates: + return candidates[-1] # Highest version is last + + return None + + +def parse_stage(filename): + """Extract the 2-char shader stage from filename like 'foo.cs.xesl'.""" + basename = os.path.splitext(filename)[0] # 'foo.cs' + identifier = basename.replace(".", "_") # 'foo_cs' + stage_key = identifier[-2:] + if stage_key not in DXBC_STAGES: + return None + return stage_key + + +def main(): + if len(sys.argv) != 3: + print(f"Usage: {sys.argv[0]} ", file=sys.stderr) + return 1 + + input_path = sys.argv[1] + output_path = sys.argv[2] + + src_name = os.path.basename(input_path) + src_dir = os.path.dirname(input_path) + + stage = parse_stage(src_name) + if stage is None: + print(f"ERROR: cannot determine shader stage from: {src_name}", file=sys.stderr) + return 1 + + identifier = os.path.splitext(src_name)[0].replace(".", "_") + + fxc = find_fxc() + if not fxc: + print("ERROR: could not find fxc! Set FXC_PATH environment variable " + "or install Windows SDK.", file=sys.stderr) + return 1 + + # Create output directory if needed. + os.makedirs(os.path.dirname(output_path), exist_ok=True) + + is_dxc = "dxc" in os.path.basename(fxc).lower() + + # Start with base command — use wine on non-Windows platforms. + if sys.platform != "win32": + compiler_args = ["wine", fxc] + else: + compiler_args = [fxc] + + if is_dxc: + # DXC only supports SM 6.0+. + compiler_args.extend([ + "-T", f"{stage}_6_0", + "-HV", "2017", + "-D", "SHADING_LANGUAGE_HLSL_XE=1", + "-I", src_dir, + "-Fh", output_path, + "-Vn", identifier, + "-nologo", + input_path, + ]) + else: + # FXC uses traditional syntax. + compiler_args.extend([ + "/D", "SHADING_LANGUAGE_HLSL_XE=1", + "/I", src_dir, + "/Fh", output_path, + "/T", f"{stage}_5_1", + "/Vn", identifier, + "/O3", + "/Qstrip_reflect", + "/Qstrip_debug", + "/Qstrip_priv", + "/Gfp", + "/nologo", + input_path, + ]) + + result = subprocess.run(compiler_args, stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE) + if result.returncode != 0: + print(f"ERROR: failed to compile DXBC shader: {src_name}", file=sys.stderr) + if result.stderr: + sys.stderr.buffer.write(result.stderr) + return 1 + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/build/compile_shader_spirv.py b/tools/build/compile_shader_spirv.py new file mode 100644 index 000000000..2f7eb262c --- /dev/null +++ b/tools/build/compile_shader_spirv.py @@ -0,0 +1,171 @@ +#!/usr/bin/env python3 + +"""Compiles a single shader to SPIR-V and generates a C header. + +Usage: compile_shader_spirv.py + +Pipeline: + 1. glslangValidator -> unoptimized .spv + 2. spirv-opt -> optimized .spv + 3. spirv-dis -> disassembly .txt + 4. Generate .h with disassembly comment + uint32_t array +""" + +import os +import struct +import subprocess +import sys + + +SPIRV_STAGES = { + "vs": "vert", "hs": "tesc", "ds": "tese", + "gs": "geom", "ps": "frag", "cs": "comp", +} + +XESL_WRAPPER = ( + "#version 460\n" + "#extension GL_EXT_control_flow_attributes : require\n" + "#extension GL_EXT_samplerless_texture_functions : require\n" + "#extension GL_GOOGLE_include_directive : require\n" + "#include \"%s\"\n" +) + + +def find_vulkan_tools(): + """Find Vulkan SDK tools via VULKAN_SDK env or PATH.""" + vulkan_sdk = os.environ.get("VULKAN_SDK") + if vulkan_sdk: + bin_dir = os.path.join(vulkan_sdk, "bin") + if os.path.isdir(bin_dir): + return ( + os.path.join(bin_dir, "glslangValidator"), + os.path.join(bin_dir, "spirv-opt"), + os.path.join(bin_dir, "spirv-dis"), + ) + + # Fall back to PATH + return ("glslangValidator", "spirv-opt", "spirv-dis") + + +def parse_stage(filename): + """Extract the 2-char shader stage from filename like 'foo.cs.xesl'.""" + basename = os.path.splitext(filename)[0] # 'foo.cs' + identifier = basename.replace(".", "_") # 'foo_cs' + stage_key = identifier[-2:] + if stage_key not in SPIRV_STAGES: + return None, None + return stage_key, SPIRV_STAGES[stage_key] + + +def main(): + if len(sys.argv) != 3: + print(f"Usage: {sys.argv[0]} ", file=sys.stderr) + return 1 + + input_path = sys.argv[1] + output_path = sys.argv[2] + + src_name = os.path.basename(input_path) + src_dir = os.path.dirname(input_path) + src_is_xesl = src_name.endswith(".xesl") + + stage_key, spirv_stage = parse_stage(src_name) + if spirv_stage is None: + print(f"ERROR: cannot determine shader stage from: {src_name}", file=sys.stderr) + return 1 + + # Compute identifier (matches what Lua does: basename with dots -> underscores) + identifier = os.path.splitext(src_name)[0].replace(".", "_") + + glslang, spirv_opt, spirv_dis = find_vulkan_tools() + + # Create output directory if needed. + os.makedirs(os.path.dirname(output_path), exist_ok=True) + + # Temp file paths next to output. + base = os.path.splitext(output_path)[0] + glslang_spv = base + ".glslang.spv" + opt_spv = base + ".spv" + dis_txt = base + ".txt" + + try: + # Step 1: glslangValidator + glslang_args = [ + glslang, + "--stdin" if src_is_xesl else input_path, + "-DSHADING_LANGUAGE_GLSL_XE=1", + "-S", spirv_stage, + "-o", glslang_spv, + "-V", + ] + if src_is_xesl: + glslang_args.append(f"-I{src_dir}") + + stdin_data = (XESL_WRAPPER % src_name) if src_is_xesl else None + result = subprocess.run(glslang_args, input=stdin_data, text=True, + stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) + if result.returncode != 0: + print(f"ERROR: glslangValidator failed for {src_name}", file=sys.stderr) + if result.stderr: + sys.stderr.write(result.stderr) + return 1 + + # Step 2: spirv-opt + result = subprocess.run([ + spirv_opt, "-O", "-O", "--canonicalize-ids", + glslang_spv, "-o", opt_spv, + ], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) + if result.returncode != 0: + print(f"ERROR: spirv-opt failed for {src_name}", file=sys.stderr) + if result.stderr: + sys.stderr.write(result.stderr) + return 1 + + # Step 3: spirv-dis + result = subprocess.run([spirv_dis, "-o", dis_txt, opt_spv], + stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) + if result.returncode != 0: + print(f"ERROR: spirv-dis failed for {src_name}", file=sys.stderr) + if result.stderr: + sys.stderr.write(result.stderr) + return 1 + + # Step 4: Generate header + with open(output_path, "w") as out: + out.write("// Generated with `xb buildshaders`.\n#if 0\n") + with open(dis_txt, "r") as dis_file: + dis_data = dis_file.read() + if dis_data: + out.write(dis_data) + if dis_data[-1] != "\n": + out.write("\n") + out.write("#endif\n\nconst uint32_t %s[] = {" % identifier) + with open(opt_spv, "rb") as spv_file: + index = 0 + while True: + word = spv_file.read(4) + if len(word) == 0: + break + if len(word) != 4: + print("ERROR: SPIR-V binary is misaligned", file=sys.stderr) + return 1 + if index % 6 == 0: + out.write("\n ") + else: + out.write(" ") + index += 1 + value = struct.unpack(" 0: - # Map internal version to year version: 17->2022, 18->2026, etc. - internal_version = int(vswhere[0].get("catalog", {}).get("productLineVersion", 17)) - version_map = {17: 2022, 18: 2026} - version = version_map.get(internal_version, 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 87cd820f7..000000000 --- a/tools/build/premake5.lua +++ /dev/null @@ -1,10 +0,0 @@ -require("vstudio") - -include("scripts/apu_deps.lua") -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/apu_deps.lua b/tools/build/scripts/apu_deps.lua deleted file mode 100644 index 0396a7367..000000000 --- a/tools/build/scripts/apu_deps.lua +++ /dev/null @@ -1,11 +0,0 @@ --- Helper function to add APU transitive dependencies --- Call this after linking to xenia-apu to ensure all transitive dependencies are included --- On Linux, xenia-apu's AudioMediaPlayer directly instantiates SDLAudioDriver, --- so consumers must link xenia-apu-sdl (which in turn brings in xenia-helper-sdl and SDL2) -function apu_transitive_deps() - filter("platforms:Linux") - links({ - "xenia-apu-sdl", -- Contains SDLAudioDriver used by AudioMediaPlayer - }) - filter({}) -end 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 2cbeee6f2..000000000 --- a/tools/build/scripts/single_library.lua +++ /dev/null @@ -1,19 +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"); - 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 a52ddd48c..fbf296566 100755 --- a/xenia-build.py +++ b/xenia-build.py @@ -6,7 +6,6 @@ Run with --help or no arguments for possible commands. """ -from datetime import datetime from multiprocessing import Pool from functools import partial from argparse import ArgumentParser @@ -298,138 +297,6 @@ def setup_qt(): return False -def get_dir_newest_mtime(directory): - """Get the newest modification time in a directory tree (files and dirs). - - Checks both files and directories to catch deletions/additions. - """ - newest = 0 - try: - for root, dirs, files in os.walk(directory): - # Skip bytecode subdirectories when scanning source - dirs[:] = [d for d in dirs if d != "bytecode"] - # Check directory mtime (changes when files added/removed) - mtime = os.path.getmtime(root) - if mtime > newest: - newest = mtime - for name in files: - mtime = os.path.getmtime(os.path.join(root, name)) - if mtime > newest: - newest = mtime - except OSError: - pass - return newest - - -def get_dir_oldest_mtime(directory): - """Get the oldest modification time in a directory tree (files and dirs). - - Checks both files and directories to catch deletions/additions. - """ - oldest = float('inf') - try: - for root, dirs, files in os.walk(directory): - # Check directory mtime - mtime = os.path.getmtime(root) - if mtime < oldest: - oldest = mtime - for name in files: - mtime = os.path.getmtime(os.path.join(root, name)) - if mtime < oldest: - oldest = mtime - except OSError: - pass - return oldest - - -def generate_moc_files(): - """Generates Qt MOC files for all headers containing Q_OBJECT. - - Returns: - True if MOC generation succeeded or was skipped, False on error. - """ - qt_dir = os.environ.get("QT_DIR") - if not qt_dir: - return True # Qt not available, skip MOC generation - - # Find moc executable - if sys.platform == "win32": - moc_path = os.path.join(qt_dir, "bin", "moc.exe") - else: - moc_path = os.path.join(qt_dir, "libexec", "moc") - if not os.path.exists(moc_path): - moc_path = os.path.join(qt_dir, "bin", "moc") - - if not os.path.exists(moc_path): - print_warning(f"moc not found at {moc_path}") - return False - - # Find all Qt headers with Q_OBJECT - ui_dir = os.path.join("src", "xenia", "ui") - qt_headers = [] - for filename in os.listdir(ui_dir): - if filename.endswith("_qt.h"): - header_path = os.path.join(ui_dir, filename) - with open(header_path, "r", encoding="utf-8", errors="ignore") as f: - content = f.read() - if "Q_OBJECT" in content: - qt_headers.append(header_path) - - if not qt_headers: - return True - - # Remove orphaned moc files (source was deleted) - expected_moc_files = set() - for header_path in qt_headers: - header_name = os.path.basename(header_path) - moc_name = "moc_" + header_name[:-2] + ".cc" - expected_moc_files.add(moc_name) - - for filename in os.listdir(ui_dir): - if filename.startswith("moc_") and filename.endswith(".cc"): - if filename not in expected_moc_files: - orphan_path = os.path.join(ui_dir, filename) - print(f"- removing orphaned {filename}...") - os.remove(orphan_path) - - # Generate MOC files (only if source is newer) - any_errors = False - generated_count = 0 - for header_path in qt_headers: - header_name = os.path.basename(header_path) - moc_name = "moc_" + header_name[:-2] + ".cc" # Replace .h with .cc - moc_path_out = os.path.join(os.path.dirname(header_path), moc_name) - - # Skip if moc file exists and is newer than source - if os.path.exists(moc_path_out): - if os.path.getmtime(moc_path_out) >= os.path.getmtime(header_path): - continue - - # Build include paths for MOC - include_args = [ - f"-I{os.path.join(qt_dir, 'include')}", - f"-I{os.path.join(qt_dir, 'include', 'QtCore')}", - f"-I{os.path.join(qt_dir, 'include', 'QtGui')}", - f"-I{os.path.join(qt_dir, 'include', 'QtWidgets')}", - "-Isrc", - ] - - cmd = [moc_path] + include_args + ["-o", moc_path_out, header_path] - - result = subprocess.call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) - if result != 0: - print_error(f"Failed to generate {moc_name}") - any_errors = True - else: - print(f"- generated {moc_name}") - generated_count += 1 - - if generated_count == 0 and not any_errors: - print("MOC files are up-to-date, skipping generation.") - - return not any_errors - - def main(): # Add self to the root search path. sys.path.insert(0, self_path) @@ -578,10 +445,15 @@ def shell_call(command, throw_on_error=True, stdout_path=None, stderr_path=None, return result -def generate_version_h(): - """Generates a build/version.h file that contains current git info. +def generate_version_h(build_dir="build"): + """Writes /version.h with the current branch/commit/PR info. + The file is included by source files via `#include "version.h"`; the + relevant build directory is added to the project include path by the + root CMakeLists.txt, so different build trees (build/, build-vs/, ...) + each get their own copy. """ - header_file = "build/version.h" + os.makedirs(build_dir, exist_ok=True) + header_file = os.path.join(build_dir, "version.h") pr_number = None if git_is_repository(): @@ -595,7 +467,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}" @@ -624,49 +496,6 @@ def generate_version_h(): f.write(contents_new) -def generate_source_class(path): - header_path = f"{path}.h" - source_path = f"{path}.cc" - - if os.path.isfile(header_path) or os.path.isfile(source_path): - print_error("Target file already exists") - return 1 - - if generate_source_file(header_path) > 0: - return 1 - if generate_source_file(source_path) > 0: - # remove header if source file generation failed - os.remove(os.path.join(source_root, header_path)) - return 1 - - return 0 - -def generate_source_file(path): - """Generates a source file at the specified path containing copyright notice - """ - copyright = f"""/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright {datetime.now().year} Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */""" - - if os.path.isfile(path): - print_error("Target file already exists") - return 1 - try: - with open(path, "w") as f: - f.write(copyright) - except Exception as e: - print_error(f"Could not write to file [path {path}]") - return 1 - - return 0 - - - def git_get_head_info(): """Queries the current branch and commit checksum from git. @@ -853,88 +682,43 @@ 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(cc=None, generator=None, build_tests=False, + disable_lto=False): + """Runs `cmake` to (re)configure build/ from the source root. - Args: - target_os_override: override specified by the user for cross-compilation, - or None to target the host platform. - - 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. + Uses Ninja Multi-Config by default on all platforms. On Linux the + C/C++ compilers come from get_cc() / the CC env var; on Windows the + detected Visual Studio toolchain wins. build_tests toggles + -DXENIA_BUILD_TESTS=ON; disable_lto toggles -DXENIA_ENABLE_LTO=OFF + (faster Release link, at the cost of LTO's whole-program opts). """ + if not generator: + generator = "Ninja Multi-Config" 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", generator, ] - 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}", + ] + if build_tests: + args += ["-DXENIA_BUILD_TESTS=ON"] + if disable_lto: + args += ["-DXENIA_ENABLE_LTO=OFF"] ret = subprocess.call(args) - if ret == 0: generate_version_h() - 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) - if vs_version == "2026": # Still no vs2026 target, force 2022 - 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. @@ -954,64 +738,6 @@ def get_build_bin_path(args): return os.path.join(self_path, "build", "bin", platform.capitalize(), args["config"].capitalize()) -def run_windeployqt(bin_path, config): - """Runs windeployqt to copy Qt DLLs to the build output directory. - - Args: - bin_path: Path to the directory containing the built executable. - config: Build configuration (debug, checked, or release). - - Returns: - True if windeployqt succeeded or was not needed, False on error. - """ - if sys.platform != "win32": - return True - - qt_dir = os.environ.get("QT_DIR") - if not qt_dir: - # Qt not configured, skip - return True - - windeployqt_path = os.path.join(qt_dir, "bin", "windeployqt.exe") - if not os.path.exists(windeployqt_path): - print_warning(f"windeployqt not found at {windeployqt_path}") - return True - - # Find the xenia executable - exe_path = os.path.join(bin_path, "xenia_edge.exe") - if not os.path.exists(exe_path): - # Executable not found, might not be building xenia-app - return True - - print(f"\n- deploying Qt dependencies to {bin_path}...") - - # Determine if we need debug or release Qt DLLs - # Debug and Checked builds need debug Qt DLLs - deploy_args = [ - windeployqt_path, - "--no-translations", # Don't copy translation files - "--no-system-d3d-compiler", # Don't copy D3D compiler - "--no-opengl-sw", # Don't copy software OpenGL renderer - "--no-compiler-runtime", # Don't copy vc_redist.x64.exe (25MB) - ] - - if config.lower() in ["debug", "checked", "valgrind"]: - deploy_args.append("--debug") - else: - deploy_args.append("--release") - - deploy_args.append(exe_path) - - result = subprocess.call(deploy_args) - - if result == 0: - print(" Qt dependencies deployed successfully") - return True - else: - print_warning(f"windeployqt failed with exit code {result}") - return False - - def create_clion_workspace(): """Creates some basic workspace information inside the .idea directory for first start. """ @@ -1062,22 +788,14 @@ def discover_commands(subparsers): commands = { "setup": SetupCommand(subparsers), "fetchdata": FetchDataCommand(subparsers), - "pull": PullCommand(subparsers), - "premake": PremakeCommand(subparsers), "build": BuildCommand(subparsers), - "buildshaders": BuildShadersCommand(subparsers), "devenv": DevenvCommand(subparsers), "gentests": GenTestsCommand(subparsers), "test": TestCommand(subparsers), - "gputest": GpuTestCommand(subparsers), "clean": CleanCommand(subparsers), - "nuke": NukeCommand(subparsers), - "cleangenerated": CleanGeneratedCommand(subparsers), "lint": LintCommand(subparsers), "format": FormatCommand(subparsers), - "style": StyleCommand(subparsers), "tidy": TidyCommand(subparsers), - "stub": StubCommand(subparsers), } return commands @@ -1129,14 +847,10 @@ 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") - # Setup submodules. print("- git submodule init / update...") if git_is_repository(): git_submodule_update() @@ -1144,8 +858,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 @@ -1174,86 +888,6 @@ class FetchDataCommand(Command): return 0 -class PullCommand(Command): - """'pull' command. - """ - - def __init__(self, subparsers, *args, **kwargs): - super(PullCommand, self).__init__( - subparsers, - name="pull", - help_short="Pulls the repo and all dependencies and rebases changes.", - *args, **kwargs) - 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") - - print(f"- switching to {default_branch}...") - shell_call([ - "git", - "checkout", - default_branch, - ]) - print("") - - print("- pulling self...") - if args["merge"]: - shell_call([ - "git", - "pull", - ]) - else: - shell_call([ - "git", - "pull", - "--rebase", - ]) - - print("\n- pulling dependencies...") - git_submodule_update() - print("") - - print("- running premake...") - if run_platform_premake(target_os_override=args["target_os"]) == 0: - print_status(ResultStatus.SUCCESS) - - return 0 - - -class PremakeCommand(Command): - """'premake' command. - """ - - def __init__(self, subparsers, *args, **kwargs): - super(PremakeCommand, self).__init__( - subparsers, - name="premake", - help_short="Runs premake 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") - - 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_status(ResultStatus.SUCCESS if not ret else ResultStatus.FAILURE) - - return ret - - class BaseBuildCommand(Command): """Base command for things that require building. """ @@ -1263,7 +897,8 @@ 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", "valgrind"], default="debug", type=str.lower, help="Chooses the build configuration.") @@ -1274,11 +909,20 @@ class BaseBuildCommand(Command): "--force", action="store_true", help="Forces a full rebuild.") self.parser.add_argument( - "--no_premake", action="store_true", - help="Skips running premake before building.") + "--no_configure", action="store_true", + help="Skips the cmake configure step before building.") + self.parser.add_argument( + "--build-tests", dest="build_tests", action="store_true", + default=False, + help="Enables building test suites (sets -DXENIA_BUILD_TESTS=ON).") + self.parser.add_argument( + "--disable-lto", dest="disable_lto", action="store_true", + default=False, + help="Disables link-time optimization for Release builds " + "(sets -DXENIA_ENABLE_LTO=OFF). Much faster Release link " + "at the cost of whole-program opts.") def execute(self, args, pass_args, cwd): - # Check Vulkan SDK availability if not os.environ.get("VULKAN_SDK"): print_error("Vulkan SDK not found!" "\nPlease install Vulkan SDK from:" @@ -1286,89 +930,31 @@ class BaseBuildCommand(Command): f"\nSee: https://github.com/has207/xenia-edge/blob/{default_branch}/docs/building.md") return 1 - if not args["no_premake"]: - print("- running premake...") - run_platform_premake(cc=args["cc"]) + if not args["no_configure"]: + print("- running cmake configure...") + run_cmake_configure( + cc=args["cc"], + build_tests=args["build_tests"], + disable_lto=args["disable_lto"], + ) 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"]: - # Build each project file directly to avoid MSBuild trying to - # run the target on every project in the solution - result = 0 - # Convert config name to match project configuration names - # e.g., "debug" -> "Debug Windows" - config_name = f"{args['config'].capitalize()} Windows" - for target in args["target"]: - project_file = f"build/{target}.vcxproj" - if not os.path.exists(project_file): - print_error(f"Project file {project_file} does not exist") - result = 1 - break - - target_arg = "/t:Rebuild" if args["force"] else "/t:Build" - result = subprocess.call([ - "msbuild", - project_file, - "/nologo", - "/m", - "/v:m", - target_arg, - f"/p:Configuration={config_name}", - "/p:Platform=x64", - ] + pass_args) - if result != 0: - break - else: - # Build entire solution - 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.") + config = args["config"].title() + cmake_args = [ + "cmake", "--build", "build", + "--config", config, + ] + if args["force"]: + cmake_args.append("--clean-first") + if args["target"]: + cmake_args.append("--target") + cmake_args.extend(args["target"]) + result = subprocess.call(cmake_args + pass_args, env=dict(os.environ)) + if result != 0: + print_error("cmake build failed with one or more errors.") return result @@ -1385,320 +971,11 @@ class BuildCommand(BaseBuildCommand): def execute(self, args, pass_args, cwd): print(f"Building {args['config']}...\n") - - # Generate MOC files before building - if not generate_moc_files(): - print_error("MOC generation failed") - return 1 - - # Generate shader bytecode before building - shader_result = build_shaders() - if shader_result != 0: - print_error("Shader generation failed") - return shader_result - result = super(BuildCommand, self).execute(args, pass_args, cwd) - - if not result: - # Run windeployqt to copy Qt DLLs - bin_path = get_build_bin_path(args) - run_windeployqt(bin_path, args["config"]) - print_status(ResultStatus.SUCCESS if not result else ResultStatus.FAILURE) - return result -class BuildShadersCommand(Command): - """'buildshaders' command. - """ - - def __init__(self, subparsers, *args, **kwargs): - super(BuildShadersCommand, self).__init__( - subparsers, - name="buildshaders", - help_short="Generates shader binaries for inclusion in C++ files.", - help_long=""" - Generates the shader binaries under src/*/shaders/bytecode/. - Run after modifying any .hs/vs/ds/gs/ps/cs.glsl/hlsl/xesl files. - Direct3D shaders can be built only on a Windows host. - """, - *args, **kwargs) - self.parser.add_argument( - "--target", action="append", choices=["dxbc", "spirv"], default=[], - help="Builds only the given target(s).") - - def execute(self, args, pass_args, cwd): - return build_shaders(args["target"]) - - -def build_shaders(targets=None): - """Builds shader bytecode. Called by BuildShadersCommand and BuildCommand. - - Args: - targets: List of targets ("dxbc", "spirv"), or None/empty for all. - - Returns: - 0 on success, non-zero on error. - """ - # Check if shaders need rebuilding by comparing source vs generated timestamps - gpu_shaders = "src/xenia/gpu/shaders" - ui_shaders = "src/xenia/ui/shaders" - # DXBC directories only on Windows, SPIR-V everywhere - bytecode_dirs = [ - "src/xenia/gpu/shaders/bytecode/vulkan_spirv", - "src/xenia/ui/shaders/bytecode/vulkan_spirv", - ] - if sys.platform == "win32": - bytecode_dirs.extend([ - "src/xenia/gpu/shaders/bytecode/d3d12_5_1", - "src/xenia/ui/shaders/bytecode/d3d12_5_1", - ]) - - newest_source = max(get_dir_newest_mtime(gpu_shaders), - get_dir_newest_mtime(ui_shaders)) - oldest_generated = min((get_dir_oldest_mtime(d) for d in bytecode_dirs), - default=0) - - # If oldest_generated is inf, bytecode doesn't exist - need to generate - if oldest_generated != float('inf') and newest_source <= oldest_generated: - print("Shaders are up-to-date, skipping generation.") - return 0 - - # Clean old bytecode before regenerating to remove stale files from deleted sources - clean_shader_bytecode() - - src_paths = [os.path.join(root, name) - for root, dirs, files in os.walk("src") - for name in files - if (name.endswith(".glsl") or - name.endswith(".hlsl") or - name.endswith(".xesl"))] - if targets is None: - targets = [] - all_targets = len(targets) == 0 - - # XeSL ("Xenia Shading Language") means shader files that can be - # compiled as multiple languages from a single file. Whenever possible, - # this is achieved without the involvement of the build script, using - # just conditionals, macros and functions in shaders, however, in some - # cases, that's necessary (such as to prepend `#version` in GLSL, as - # well as to enable `#include` in GLSL, to include `xesl.xesli` itself, - # without writing the same `#if` / `#extension` / `#endif` in every - # shader). Also, not all shading languages provide a built-in - # preprocessor definition for identification of them, so - # `SHADING_LANGUAGE_*_XE` is also defined via the build arguments. - # `SHADING_LANGUAGE_*_XE` is set regardless of whether the file is XeSL - # or a raw source file in a specific language, as XeSL headers may be - # used in language-specific sources. - - # Direct3D DXBC (Windows only). - if (all_targets or "dxbc" in targets) and sys.platform == "win32": - print("Building Direct3D 12 Shader Model 5.1 DXBC shaders...") - - # Get the FXC path. - fxc = os.environ.get("FXC_PATH") - if not fxc: - # Fall back to searching Windows Kits - fxc = glob(os.path.join(os.environ.get("ProgramFiles(x86)", ""), - "Windows Kits", "10", "bin", "*", "x64", "fxc.exe")) - if not fxc: - print_error("could not find fxc! Set FXC_PATH environment variable or install Windows SDK.") - return 1 - fxc = fxc[-1] # Highest version is last - else: - print(f"Using FXC from environment variable: {fxc}") - - # Build DXBC. - dxbc_stages = ["vs", "hs", "ds", "gs", "ps", "cs"] - for src_path in src_paths: - src_name = os.path.basename(src_path) - if ((not src_name.endswith(".hlsl") and - not src_name.endswith(".xesl")) or - len(src_name) <= 8 or src_name[-8] != "."): - continue - dxbc_identifier = src_name[:-5].replace(".", "_") - dxbc_stage = dxbc_identifier[-2:] - if dxbc_stage not in dxbc_stages: - continue - print(f"- {src_path} > d3d12_5_1") - dxbc_dir_path = os.path.join(os.path.dirname(src_path), - "bytecode/d3d12_5_1") - os.makedirs(dxbc_dir_path, exist_ok=True) - dxbc_file_path_base = os.path.join(dxbc_dir_path, dxbc_identifier) - # Not enabling treating warnings as errors (/WX) because it - # overrides #pragma warning, and the FXAA shader triggers a - # bug in FXC causing an uninitialized variable warning if - # early exit from a function is done. - # FXC writes errors and warnings to stderr, not stdout, but - # stdout receives generic status messages that only add - # clutter in this case. - # Check if using DXC or FXC based on executable name - is_dxc = "dxc" in fxc.lower() - - # Start with base command - use wine on non-Windows platforms - if sys.platform != "win32": - compiler_args = ["wine", fxc] - else: - compiler_args = [fxc] - - src_dir = os.path.dirname(src_path) - if is_dxc: - # DXC only supports SM 6.0+, cannot compile SM 5.1 - print_warning("DXC doesn't support SM 5.1, using SM 6.0") - compiler_args.extend([ - "-T", f"{dxbc_stage}_6_0", - "-HV", "2017", - "-D", "SHADING_LANGUAGE_HLSL_XE=1", - "-I", src_dir, - "-Fh", f"{dxbc_file_path_base}.h", - "-Vn", dxbc_identifier, - "-nologo", - src_path, - ]) - else: - # FXC uses traditional syntax - compiler_args.extend([ - "/D", "SHADING_LANGUAGE_HLSL_XE=1", - "/I", src_dir, - "/Fh", f"{dxbc_file_path_base}.h", - "/T", f"{dxbc_stage}_5_1", - "/Vn", dxbc_identifier, - "/O3", - "/Qstrip_reflect", - "/Qstrip_debug", - "/Qstrip_priv", - "/all_resources_bound", - "/Gfp", - "/nologo", - src_path, - ]) - if subprocess.call(compiler_args, stdout=subprocess.DEVNULL) != 0: - print_error(f"failed to compile DXBC shader: {src_path}") - return 1 - - # Vulkan SPIR-V. - if all_targets or "spirv" in targets: - print("Building Vulkan SPIR-V shaders...") - - # Get the SPIR-V tool paths. - vulkan_sdk_path = os.environ.get("VULKAN_SDK") - if not vulkan_sdk_path: - print_error("VULKAN_SDK environment variable is not set") - if sys.platform == "win32": - print("Please install Vulkan SDK from:") - print("https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe") - else: - print("Please install Vulkan SDK and set VULKAN_SDK environment variable") - return 1 - if not os.path.exists(vulkan_sdk_path): - print_error(f"could not find the Vulkan SDK at {vulkan_sdk_path}") - return 1 - vulkan_bin_path = os.path.join(vulkan_sdk_path, "bin") - if not os.path.exists(vulkan_bin_path): - print_error("could not find the Vulkan SDK binaries") - return 1 - glslang = os.path.join(vulkan_bin_path, "glslangValidator") - if not has_bin(glslang): - print_error("could not find glslangValidator") - return 1 - spirv_opt = os.path.join(vulkan_bin_path, "spirv-opt") - if not has_bin(spirv_opt): - print_error("could not find spirv-opt") - return 1 - spirv_dis = os.path.join(vulkan_bin_path, "spirv-dis") - if not has_bin(spirv_dis): - print_error("could not find spirv-dis") - return 1 - - # Build SPIR-V. - spirv_stages = { - "vs": "vert", "hs": "tesc", "ds": "tese", - "gs": "geom", "ps": "frag", "cs": "comp", - } - spirv_xesl_wrapper = ( - "#version 460\n" - "#extension GL_EXT_control_flow_attributes : require\n" - "#extension GL_EXT_samplerless_texture_functions : require\n" - "#extension GL_GOOGLE_include_directive : require\n" - "#include \"%s\"\n" - ) - for src_path in src_paths: - src_name = os.path.basename(src_path) - src_is_xesl = src_name.endswith(".xesl") - if ((not src_is_xesl and not src_name.endswith(".glsl")) or - len(src_name) <= 8 or src_name[-8] != "."): - continue - spirv_identifier = src_name[:-5].replace(".", "_") - spirv_stage = spirv_stages.get(spirv_identifier[-2:], None) - if spirv_stage is None: - continue - print(f"- {src_path} > vulkan_spirv") - src_dir = os.path.dirname(src_path) - spirv_dir_path = os.path.join(src_dir, "bytecode/vulkan_spirv") - os.makedirs(spirv_dir_path, exist_ok=True) - spirv_file_path_base = os.path.join(spirv_dir_path, spirv_identifier) - spirv_glslang_file_path = f"{spirv_file_path_base}.glslang.spv" - - glslang_arguments = [glslang, - "--stdin" if src_is_xesl else src_path, - "-DSHADING_LANGUAGE_GLSL_XE=1", - "-S", spirv_stage, - "-o", spirv_glslang_file_path, - "-V"] - if src_is_xesl: - glslang_arguments.append(f"-I{src_dir}") - if subprocess.run( - glslang_arguments, - input=(spirv_xesl_wrapper % src_name) if src_is_xesl else None, - text=True).returncode != 0: - print_error("failed to build a SPIR-V shader") - return 1 - - spirv_file_path = f"{spirv_file_path_base}.spv" - if subprocess.call([spirv_opt, "-O", "-O", "--canonicalize-ids", - spirv_glslang_file_path, "-o", spirv_file_path]) != 0: - print_error("failed to optimize a SPIR-V shader") - return 1 - os.remove(spirv_glslang_file_path) - - spirv_dis_file_path = f"{spirv_file_path_base}.txt" - if subprocess.call([spirv_dis, "-o", spirv_dis_file_path, - spirv_file_path]) != 0: - print_error("failed to disassemble a SPIR-V shader") - return 1 - - # Generate the header from the disassembly and the binary. - with open(f"{spirv_file_path_base}.h", "w") as out_file: - out_file.write("// Generated with `xb buildshaders`.\n#if 0\n") - with open(spirv_dis_file_path, "r") as spirv_dis_file: - spirv_dis_data = spirv_dis_file.read() - if len(spirv_dis_data) > 0: - out_file.write(spirv_dis_data) - if spirv_dis_data[-1] != "\n": - out_file.write("\n") - out_file.write("#endif\n\nconst uint32_t %s[] = {" % spirv_identifier) - with open(spirv_file_path, "rb") as spirv_file: - index = 0 - c = spirv_file.read(4) - while len(c) != 0: - if len(c) != 4: - print_error("a SPIR-V shader is misaligned") - return 1 - if index % 6 == 0: - out_file.write("\n ") - else: - out_file.write(" ") - index += 1 - out_file.write("0x%08X," % int.from_bytes(c, sys.byteorder)) - c = spirv_file.read(4) - out_file.write("\n};\n") - os.remove(spirv_dis_file_path) - os.remove(spirv_file_path) - - return 0 - - class TestCommand(BaseBuildCommand): """'test' command. """ @@ -1956,86 +1233,6 @@ class GenTestsCommand(Command): return 0 -class GpuTestCommand(BaseBuildCommand): - """'gputest' command. - """ - - def __init__(self, subparsers, *args, **kwargs): - super(GpuTestCommand, self).__init__( - subparsers, - name="gputest", - help_short="Runs automated GPU diff tests against reference imagery.", - help_long=""" - To pass arguments to the test executables separate them with `--`. - """, - *args, **kwargs) - self.parser.add_argument( - "--no_build", action="store_true", - help="Don't build before running tests.") - self.parser.add_argument( - "--update_reference_files", action="store_true", - help="Update all reference imagery.") - self.parser.add_argument( - "--generate_missing_reference_files", action="store_true", - help="Create reference files for new traces.") - - def execute(self, args, pass_args, cwd): - print("Testing...\n") - - # The test executables that will be built and run. - test_targets = args["target"] or [ - "xenia-gpu-vulkan-trace-dump", - ] - args["target"] = test_targets - - # Build all targets (if desired). - if not args["no_build"]: - result = super(GpuTestCommand, self).execute(args, [], cwd) - if result: - print("Failed to build, aborting test run.") - return result - - # Ensure all targets exist before we run. - test_executables = [ - get_bin(os.path.join(get_build_bin_path(args), test_target)) - for test_target in test_targets] - for i in range(0, len(test_targets)): - if test_executables[i] is None: - print_error(f"Unable to find {test_targets[i]} - build it.") - return 1 - - output_path = os.path.join(self_path, "build", "gputest") - if os.path.isdir(output_path): - rmtree(output_path) - os.makedirs(output_path) - print(f"Running tests and outputting to {output_path}...") - - reference_trace_root = os.path.join(self_path, "testdata", - "reference-gpu-traces") - - # Run tests. - any_failed = False - result = shell_call([ - sys.executable, - os.path.join(self_path, "tools", "gpu-trace-diff.py"), - f"--executable={test_executables[0]}", - f"--trace_path={os.path.join(reference_trace_root, 'traces')}", - f"--output_path={output_path}", - f"--reference_path={os.path.join(reference_trace_root, 'references')}", - ] + (["--generate_missing_reference_files"] if args["generate_missing_reference_files"] else []) + - (["--update_reference_files"] if args["update_reference_files"] else []) + - pass_args, - throw_on_error=False) - if result: - any_failed = True - - if any_failed: - print_error("one or more tests failed.") - result = 1 - print(f"Check {output_path}/results.html for more details.") - return result - - class CleanCommand(Command): """'clean' command. """ @@ -2046,18 +1243,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") - - # Also clean generated files + "- cmake clean...") + if os.path.isdir("build"): + subprocess.call(["cmake", "--build", "build", "--target", "clean"]) clean_generated_files() - print_status(ResultStatus.SUCCESS) return 0 @@ -2093,62 +1285,6 @@ def clean_generated_files(): clean_moc_files() -class NukeCommand(Command): - """'nuke' command. - """ - - def __init__(self, subparsers, *args, **kwargs): - super(NukeCommand, self).__init__( - subparsers, - 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" - "- removing build/...") - if os.path.isdir("build/"): - rmtree("build/") - - # Clean generated files - clean_generated_files() - - print(f"\n- git reset to {default_branch}...") - shell_call([ - "git", - "reset", - "--hard", - default_branch, - ]) - - print("\n- running premake...") - run_platform_premake(target_os_override=args["target_os"]) - - print_status(ResultStatus.SUCCESS) - return 0 - - -class CleanGeneratedCommand(Command): - """'cleangenerated' command. - """ - - def __init__(self, subparsers, *args, **kwargs): - super(CleanGeneratedCommand, self).__init__( - subparsers, - name="cleangenerated", - help_short="Removes generated shader bytecode and MOC files.", - *args, **kwargs) - - def execute(self, args, pass_args, cwd): - print("Cleaning generated files...") - clean_generated_files() - print("\nSuccess!") - return 0 - - # Generated files that should be excluded from linting/formatting GENERATED_FILES = [ "src/xenia/ui/ui_resources_qrc.cpp", # Qt resource file @@ -2341,37 +1477,6 @@ class FormatCommand(Command): # TODO(benvanik): merge into linter, or as lint --anal? -class StyleCommand(Command): - """'style' command. - """ - - def __init__(self, subparsers, *args, **kwargs): - super(StyleCommand, self).__init__( - subparsers, - name="style", - help_short="Runs the style checker on all code.", - *args, **kwargs) - - def execute(self, args, pass_args, cwd): - all_files = [file_path for file_path in find_xenia_source_files() - if not file_path.endswith("_test.cc")] - print(f"- cpplint [{len(all_files)} files]") - ret = shell_call([ - sys.executable, - "third_party/cpplint/cpplint.py", - "--output=vs7", - #"--linelength=80", - "--filter=-build/c++11,+build/include_alpha", - "--root=src", - ] + all_files, throw_on_error=False) - if ret: - print_error("1+ cpplint calls failed.") - return 1 - else: - print("\nStyle linting completed successfully.") - return 0 - - # TODO(benvanik): merge into linter, or as lint --anal? class TidyCommand(Command): """'tidy' command. @@ -2386,15 +1491,17 @@ 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") + # clang-tidy needs a compile_commands.json; CMake emits one when + # CMAKE_EXPORT_COMPILE_COMMANDS is on. + ret = subprocess.call([ + "cmake", "-S", ".", "-B", "build", + "-G", "Ninja Multi-Config", + "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", + ]) + if ret != 0: + return ret if sys.platform == "darwin": platform_name = "darwin" @@ -2437,59 +1544,6 @@ class TidyCommand(Command): print("\nTidy completed successfully.") return 0 -class StubCommand(Command): - """'stub' command. - """ - - def __init__(self, subparsers, *args, **kwargs): - super(StubCommand, self).__init__( - subparsers, - name="stub", - help_short="Create new file(s) in the xenia source tree and run premake", - *args, **kwargs) - self.parser.add_argument( - "--file", default=None, - help="Generate a source file at the provided location in the source tree") - 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__)) - source_root = os.path.join(root, os.path.normpath("src/xenia")) - - if args["class"]: - path = os.path.normpath(os.path.join(source_root, args["class"])) - target_dir = os.path.dirname(path) - class_name = os.path.basename(path) - - status = generate_source_class(path) - if status > 0: - return status - - print(f"Created class '{class_name}' at {target_dir}") - - elif args["file"]: - path = os.path.normpath(os.path.join(source_root, args["file"])) - target_dir = os.path.dirname(path) - file_name = os.path.basename(path) - - status = generate_source_file(path) - if status > 0: - return status - - print(f"Created file '{file_name}' at {target_dir}") - - else: - print_error("Please specify a file/class to generate") - return 1 - - run_platform_premake(target_os_override=args["target_os"]) - return 0 - class DevenvCommand(Command): """'devenv' command. """ @@ -2502,57 +1556,53 @@ 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"): + return self._launch_visual_studio() + # Non-Windows: CLion is the only IDE we know how to launch + # automatically. macOS falls through to the manual-open message + # (the Xcode generator isn't supported). + if 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("\n- running premake...") - run_platform_premake(devenv=devenv) - - 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", - ]) - elif has_bin("clion"): - shell_call([ - "clion", - ".", - ]) - elif has_bin("clion.sh"): - shell_call([ - "clion.sh", - ".", - ]) - else: - shell_call([ - "codelite", - "build/xenia.workspace", - ]) - print("") + if run_cmake_configure() != 0: + return 1 + if show_reload_prompt: + print_box("Please run \"File ⇒ ↺ Reload CMake Project\" from inside the IDE!") + bin_name = "clion" if has_bin("clion") else "clion.sh" + shell_call([bin_name, "."]) + return 0 + print("No supported IDE found. Open the project root in your IDE.") + print("CMakeLists.txt and CMakePresets.json are in the project root.") + return 0 + def _launch_visual_studio(self): + """Configures a VS build tree under build-vs/ and launches devenv.""" + if not vs_version: + print_error("Visual Studio is not installed.") + return 1 + # Kept separate from build/ (Ninja Multi-Config) because CMake + # refuses to change generators on an existing tree — mixing the + # two workflows in one dir would force a full wipe each time. + vs_build_dir = "build-vs" + print(f"Configuring Visual Studio build tree in {vs_build_dir}...") + # -A x64 without -G lets CMake pick whichever VS generator matches + # the installed toolchain (VS 2022, 2026, ...). + ret = subprocess.call([ + "cmake", "-S", ".", "-B", vs_build_dir, "-A", "x64", + ]) + if ret != 0: + print_error("cmake configure failed for the VS build tree") + return ret + generate_version_h(vs_build_dir) + # VS 2026+ emits xenia.slnx; older VS emits xenia.sln. + sln_path = os.path.join(vs_build_dir, "xenia.slnx") + if not os.path.exists(sln_path): + sln_path = os.path.join(vs_build_dir, "xenia.sln") + if not os.path.exists(sln_path): + print_error("cmake configured successfully but no .sln/.slnx was produced") + return 1 + print(f"\n- launching devenv on {sln_path}...") + shell_call(["devenv", sln_path]) return 0