mirror of
https://github.com/mitch030504/Wiicompiled_VR_Frame.git
synced 2026-10-06 07:00:30 +02:00
init
This commit is contained in:
commit
ec226e8348
1099 files changed
+400981
No files matched your search
@@ -0,0 +1,117 @@
|
||||
# Consume a precompiled aurora + third-party package instead of compiling
|
||||
# aurora-main and its extern/ tree.
|
||||
#
|
||||
# Produced by launcher/Prepare-NativePrebuilt.ps1 with the same toolchain and the
|
||||
# same canonical flag set the consuming build uses, which is what makes a single
|
||||
# package valid for every user. Nothing about this project's own code changes:
|
||||
# the runtime, the translated shards and the products still compile locally and
|
||||
# still link targets named aurora::gx / aurora::pad / aurora::si / aurora::vi /
|
||||
# aurora::mtx, so cmake/PublicProducts.cmake needs no prebuilt-specific branch.
|
||||
#
|
||||
# The aurora and dependency source trees are still present in the workspace - the
|
||||
# runtime includes aurora headers directly - so the package records include
|
||||
# directories as tokens (@AURORA@, @RUNTIME@, @DEPS@, @PKG@) that resolve here
|
||||
# rather than baking a maintainer machine's paths into a redistributable.
|
||||
|
||||
get_filename_component(MKW_NP_PACKAGE_DIR "${MKW_NATIVE_PREBUILT_DIR}" ABSOLUTE)
|
||||
if(NOT EXISTS "${MKW_NP_PACKAGE_DIR}/native_prebuilt.cmake")
|
||||
message(FATAL_ERROR
|
||||
"MKW_NATIVE_PREBUILT_DIR does not contain native_prebuilt.cmake: ${MKW_NP_PACKAGE_DIR}")
|
||||
endif()
|
||||
|
||||
# The package ships as <workspace>/Dependencies/native_prebuilt, next to the
|
||||
# pinned sources it was built against.
|
||||
get_filename_component(MKW_NP_DEPS_DIR "${MKW_NP_PACKAGE_DIR}" DIRECTORY)
|
||||
get_filename_component(MKW_NP_AURORA_DIR "${MKW_AURORA_DIR}" ABSOLUTE)
|
||||
get_filename_component(MKW_NP_RUNTIME_DIR "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY)
|
||||
|
||||
include("${MKW_NP_PACKAGE_DIR}/native_prebuilt.cmake")
|
||||
|
||||
function(mkw_np_resolve out_var)
|
||||
set(_resolved "")
|
||||
foreach(_item IN LISTS ARGN)
|
||||
string(REPLACE "@PKG@" "${MKW_NP_PACKAGE_DIR}" _item "${_item}")
|
||||
string(REPLACE "@AURORA@" "${MKW_NP_AURORA_DIR}" _item "${_item}")
|
||||
string(REPLACE "@RUNTIME@" "${MKW_NP_RUNTIME_DIR}" _item "${_item}")
|
||||
string(REPLACE "@DEPS@" "${MKW_NP_DEPS_DIR}" _item "${_item}")
|
||||
list(APPEND _resolved "${_item}")
|
||||
endforeach()
|
||||
set(${out_var} "${_resolved}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
mkw_np_resolve(_mkw_np_includes ${MKW_NP_INCLUDE_DIRECTORIES})
|
||||
mkw_np_resolve(_mkw_np_links ${MKW_NP_LINK_LIBRARIES})
|
||||
mkw_np_resolve(_mkw_np_dawn_config ${MKW_NP_DAWN_CONFIG_DIR})
|
||||
|
||||
foreach(_dir IN LISTS _mkw_np_includes)
|
||||
if(NOT IS_DIRECTORY "${_dir}")
|
||||
message(FATAL_ERROR
|
||||
"The precompiled package expects an include directory that this workspace "
|
||||
"does not have: ${_dir}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Dawn is a prebuilt package on both sides; resolve the same install tree the
|
||||
# package was built against so its imported target (and therefore
|
||||
# webgpu_dawn.dll / dxcompiler.dll / dxil.dll) is available exactly as a
|
||||
# from-source aurora build would provide it.
|
||||
if(NOT EXISTS "${_mkw_np_dawn_config}/DawnConfig.cmake")
|
||||
message(FATAL_ERROR "Prebuilt Dawn package is missing DawnConfig.cmake: ${_mkw_np_dawn_config}")
|
||||
endif()
|
||||
set(_mkw_np_saved_find_global ${CMAKE_FIND_PACKAGE_TARGETS_GLOBAL})
|
||||
set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL ON)
|
||||
find_package(Dawn REQUIRED CONFIG PATHS "${_mkw_np_dawn_config}" NO_DEFAULT_PATH)
|
||||
set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL ${_mkw_np_saved_find_global})
|
||||
if(NOT TARGET dawn::webgpu_dawn)
|
||||
message(FATAL_ERROR "Prebuilt Dawn package did not provide dawn::webgpu_dawn")
|
||||
endif()
|
||||
|
||||
# One interface target carries the whole compile/link surface. The public aurora
|
||||
# names then reduce to aliases of it, which keeps the link line free of the
|
||||
# fivefold duplication that giving each of them the full list would produce.
|
||||
add_library(mkw_native_prebuilt INTERFACE IMPORTED GLOBAL)
|
||||
set_target_properties(mkw_native_prebuilt PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_mkw_np_includes}"
|
||||
INTERFACE_COMPILE_DEFINITIONS "${MKW_NP_COMPILE_DEFINITIONS}"
|
||||
INTERFACE_COMPILE_OPTIONS "${MKW_NP_COMPILE_OPTIONS}"
|
||||
INTERFACE_LINK_LIBRARIES "${_mkw_np_links}")
|
||||
|
||||
foreach(_target IN LISTS MKW_NP_AURORA_TARGETS)
|
||||
add_library(${_target} INTERFACE IMPORTED GLOBAL)
|
||||
set_target_properties(${_target} PROPERTIES INTERFACE_LINK_LIBRARIES mkw_native_prebuilt)
|
||||
endforeach()
|
||||
|
||||
# The vendored Crypto++ ships precompiled alongside aurora: under the fixed
|
||||
# toolchain its archive is identical for every user, so compiling ~150 of its
|
||||
# translation units locally buys nothing. Only the archive is consumed here -
|
||||
# the vendored headers still ship in the workspace because first-party TUs
|
||||
# include them directly (runtime/include/wii_es_crypto.h).
|
||||
if(NOT MKW_CRYPTOPP_INTERFACE_DEFINITIONS)
|
||||
message(FATAL_ERROR
|
||||
"The prebuilt consumer requires MKW_CRYPTOPP_INTERFACE_DEFINITIONS from "
|
||||
"the top-level CMakeLists.txt; without them first-party TUs would compile "
|
||||
"against Crypto++ headers configured differently than the archive.")
|
||||
endif()
|
||||
file(GLOB _mkw_np_cryptopp_archives "${MKW_NP_PACKAGE_DIR}/lib/libmkw_cryptopp.a")
|
||||
list(LENGTH _mkw_np_cryptopp_archives _mkw_np_cryptopp_count)
|
||||
if(NOT _mkw_np_cryptopp_count EQUAL 1)
|
||||
message(FATAL_ERROR
|
||||
"The precompiled package must contain exactly one libmkw_cryptopp.a: "
|
||||
"${MKW_NP_PACKAGE_DIR}")
|
||||
endif()
|
||||
if(NOT TARGET mkw_cryptopp)
|
||||
add_library(mkw_cryptopp STATIC IMPORTED GLOBAL)
|
||||
set_target_properties(mkw_cryptopp PROPERTIES
|
||||
IMPORTED_LOCATION "${_mkw_np_cryptopp_archives}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${MKW_NP_RUNTIME_DIR}/third_party"
|
||||
INTERFACE_COMPILE_DEFINITIONS "${MKW_CRYPTOPP_INTERFACE_DEFINITIONS}")
|
||||
add_library(mkw::cryptopp ALIAS mkw_cryptopp)
|
||||
endif()
|
||||
# The aggregate link list carries the same archive once more (the harvest probe
|
||||
# linked it, so the probe-vs-control diff includes it). Repeating a static
|
||||
# archive on the link line is harmless; the second pass resolves no members.
|
||||
|
||||
list(LENGTH _mkw_np_links _mkw_np_link_count)
|
||||
message(STATUS
|
||||
"Aurora and third-party libraries come from the precompiled package "
|
||||
"(${_mkw_np_link_count} link inputs); they are not compiled here")
|
||||
@@ -0,0 +1,149 @@
|
||||
# Maintainer-only: describe the configured aurora + third-party build so it can
|
||||
# be harvested into a redistributable precompiled package.
|
||||
#
|
||||
# Enabled with -DMKW_NATIVE_PREBUILT_EXPORT_DIR=<dir>. It never changes what is
|
||||
# compiled: it adds two never-built probe targets and writes plain text files
|
||||
# describing (a) which library targets aurora produced and where their build
|
||||
# outputs land, and (b) the exact compile/link interface a consumer of
|
||||
# aurora::gx/pad/si/vi/mtx receives.
|
||||
#
|
||||
# Everything is taken from the real, fully configured project rather than
|
||||
# hand-written, so the package cannot describe a graph the build does not have.
|
||||
# The compile/link interface is read back out of build.ninja by
|
||||
# launcher/Prepare-NativePrebuilt.ps1: generator expressions cannot be evaluated
|
||||
# for a specific language by file(GENERATE), and $<LINK_ONLY:...> collapses to
|
||||
# nothing outside a link context, so the generated buildsystem is the only place
|
||||
# where the fully resolved, correctly ordered values exist.
|
||||
|
||||
if(NOT CMAKE_GENERATOR STREQUAL "Ninja")
|
||||
message(FATAL_ERROR "MKW_NATIVE_PREBUILT_EXPORT_DIR requires the Ninja generator")
|
||||
endif()
|
||||
|
||||
# Enumerates every target defined anywhere in the configured directory-scope
|
||||
# tree rooted at _dir (aurora-main plus whatever its providers FetchContent'ed,
|
||||
# whose sources live under the build tree rather than under aurora-main). The
|
||||
# walk follows real SUBDIRECTORIES properties instead of parsing files, so it
|
||||
# cannot disagree with the configure that just ran. The names are candidates
|
||||
# only - each is re-checked below (TARGET existence, library type) and against
|
||||
# the link closure mkw_np_probe actually pulled in before anything ships.
|
||||
function(mkw_collect_buildsystem_targets _root_dir _out_var)
|
||||
set(_candidates "")
|
||||
set(_visited "")
|
||||
set(_pending "${_root_dir}")
|
||||
while(_pending)
|
||||
list(POP_FRONT _pending _dir)
|
||||
get_filename_component(_dir "${_dir}" ABSOLUTE)
|
||||
if(_dir IN_LIST _visited)
|
||||
continue()
|
||||
endif()
|
||||
list(APPEND _visited "${_dir}")
|
||||
get_property(_scope_targets DIRECTORY "${_dir}" PROPERTY BUILDSYSTEM_TARGETS)
|
||||
if(_scope_targets)
|
||||
list(APPEND _candidates ${_scope_targets})
|
||||
endif()
|
||||
get_property(_children DIRECTORY "${_dir}" PROPERTY SUBDIRECTORIES)
|
||||
foreach(_child IN LISTS _children)
|
||||
if(NOT IS_ABSOLUTE "${_child}")
|
||||
set(_child "${_dir}/${_child}")
|
||||
endif()
|
||||
list(APPEND _pending "${_child}")
|
||||
endforeach()
|
||||
endwhile()
|
||||
set(${_out_var} "${_candidates}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
set(_mkw_np_probe_dir "${CMAKE_BINARY_DIR}/native_prebuilt_probe")
|
||||
file(MAKE_DIRECTORY "${_mkw_np_probe_dir}")
|
||||
file(WRITE "${_mkw_np_probe_dir}/probe.cpp"
|
||||
"// Records the compile and link interface aurora's public targets hand to a\n"
|
||||
"// consumer. Building mkw_np_probe compiles exactly the aurora + third-party\n"
|
||||
"// closure the game products need, and proves the resulting archives link.\n"
|
||||
"int main() { return 0; }\n")
|
||||
|
||||
# Control: identical target with no aurora dependency. Subtracting its command
|
||||
# line from the probe's isolates exactly the aurora-derived contribution.
|
||||
add_executable(mkw_np_probe_control EXCLUDE_FROM_ALL "${_mkw_np_probe_dir}/probe.cpp")
|
||||
set_target_properties(mkw_np_probe_control PROPERTIES UNITY_BUILD OFF)
|
||||
target_compile_features(mkw_np_probe_control PRIVATE cxx_std_20)
|
||||
|
||||
add_executable(mkw_np_probe EXCLUDE_FROM_ALL "${_mkw_np_probe_dir}/probe.cpp")
|
||||
set_target_properties(mkw_np_probe PROPERTIES UNITY_BUILD OFF)
|
||||
target_compile_features(mkw_np_probe PRIVATE cxx_std_20)
|
||||
# Exactly what mkw_runtime_common and the products link (PublicProducts.cmake)
|
||||
# with one deliberate exception: pugixml stays a locally compiled single
|
||||
# translation unit, so it must not enter this closure. The runtime's vendored
|
||||
# Crypto++ does join the harvest - ~150 translation units that are identical
|
||||
# for every user under the pinned toolchain and flag set.
|
||||
target_link_libraries(mkw_np_probe PRIVATE
|
||||
aurora::gx aurora::pad aurora::si aurora::vi aurora::mtx
|
||||
mkw::cryptopp)
|
||||
|
||||
get_filename_component(_mkw_np_aurora_dir "${MKW_AURORA_DIR}" ABSOLUTE)
|
||||
mkw_collect_buildsystem_targets("${_mkw_np_aurora_dir}" _mkw_np_all_targets)
|
||||
# mkw_cryptopp is defined by this runtime project, not under aurora-main, so
|
||||
# the scan above cannot see it; it is appended explicitly. The type and closure
|
||||
# checks below still apply to it.
|
||||
list(APPEND _mkw_np_all_targets "mkw_cryptopp")
|
||||
if(NOT _mkw_np_all_targets)
|
||||
message(FATAL_ERROR "No buildsystem targets were found under ${_mkw_np_aurora_dir}")
|
||||
endif()
|
||||
list(REMOVE_DUPLICATES _mkw_np_all_targets)
|
||||
list(SORT _mkw_np_all_targets)
|
||||
|
||||
set(_mkw_np_lib_targets "")
|
||||
foreach(_t IN LISTS _mkw_np_all_targets)
|
||||
if(NOT TARGET ${_t})
|
||||
continue()
|
||||
endif()
|
||||
get_target_property(_imported ${_t} IMPORTED)
|
||||
if(_imported)
|
||||
continue()
|
||||
endif()
|
||||
get_target_property(_type ${_t} TYPE)
|
||||
if(_type STREQUAL "STATIC_LIBRARY" OR _type STREQUAL "SHARED_LIBRARY" OR
|
||||
_type STREQUAL "MODULE_LIBRARY")
|
||||
list(APPEND _mkw_np_lib_targets ${_t})
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT _mkw_np_lib_targets)
|
||||
message(FATAL_ERROR "aurora produced no library targets to export")
|
||||
endif()
|
||||
|
||||
set(_mkw_np_target_lines "")
|
||||
foreach(_t IN LISTS _mkw_np_lib_targets)
|
||||
string(APPEND _mkw_np_target_lines
|
||||
"${_t}|$<TARGET_PROPERTY:${_t},TYPE>|$<TARGET_FILE:${_t}>|$<TARGET_LINKER_FILE:${_t}>\n")
|
||||
endforeach()
|
||||
file(GENERATE OUTPUT "${MKW_NATIVE_PREBUILT_EXPORT_DIR}/targets.txt"
|
||||
CONTENT "${_mkw_np_target_lines}")
|
||||
|
||||
# Dawn stays a prebuilt package on the consumer side too; record how this build
|
||||
# resolved it so the consumer can reproduce the same imported target.
|
||||
set(_mkw_np_dawn_line "")
|
||||
if(TARGET dawn::webgpu_dawn)
|
||||
set(_mkw_np_dawn_line
|
||||
"$<TARGET_PROPERTY:dawn::webgpu_dawn,TYPE>|$<TARGET_FILE:dawn::webgpu_dawn>|$<TARGET_LINKER_FILE:dawn::webgpu_dawn>\n")
|
||||
endif()
|
||||
file(GENERATE OUTPUT "${MKW_NATIVE_PREBUILT_EXPORT_DIR}/dawn.txt"
|
||||
CONTENT "${_mkw_np_dawn_line}")
|
||||
|
||||
set(_mkw_np_dawn_config_dir "")
|
||||
if(Dawn_DIR AND EXISTS "${Dawn_DIR}/DawnConfig.cmake")
|
||||
set(_mkw_np_dawn_config_dir "${Dawn_DIR}")
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" "," _mkw_np_lib_targets_csv "${_mkw_np_lib_targets}")
|
||||
file(WRITE "${MKW_NATIVE_PREBUILT_EXPORT_DIR}/meta.txt"
|
||||
"aurora_dir=${_mkw_np_aurora_dir}\n"
|
||||
"runtime_dir=${CMAKE_CURRENT_SOURCE_DIR}\n"
|
||||
"binary_dir=${CMAKE_BINARY_DIR}\n"
|
||||
"dawn_config_dir=${_mkw_np_dawn_config_dir}\n"
|
||||
"dawn_prebuilt_source_dir=${dawn_prebuilt_SOURCE_DIR}\n"
|
||||
"aurora_sdl3_target=${AURORA_SDL3_TARGET}\n"
|
||||
"aurora_dawn_version=${AURORA_DAWN_VERSION}\n"
|
||||
"aurora_dawn_linkage=${AURORA_DAWN_LINKAGE}\n"
|
||||
"cxx_compiler=${CMAKE_CXX_COMPILER}\n"
|
||||
"cxx_compiler_version=${CMAKE_CXX_COMPILER_VERSION}\n"
|
||||
"library_targets=${_mkw_np_lib_targets_csv}\n")
|
||||
|
||||
message(STATUS "Native prebuilt export: ${MKW_NATIVE_PREBUILT_EXPORT_DIR}")
|
||||
@@ -0,0 +1,292 @@
|
||||
# Public WiiCompiled product graph.
|
||||
#
|
||||
# The translator owns the translated build graph. Mario Kart's profile-neutral
|
||||
# functions are compiled once into mkw_base_shared; only callers whose direct
|
||||
# ABI differs between profiles receive small base/RR variants.
|
||||
|
||||
set(DATA_INIT_FILE "${MKW_RUNTIME_SOURCE_DIR}/../generated/data_sections_init.cpp")
|
||||
set(DATA_INIT_BLOB_ASM "${MKW_RUNTIME_SOURCE_DIR}/../generated/data_sections_init_blobs.S")
|
||||
if(EXISTS "${DATA_INIT_FILE}")
|
||||
list(APPEND SOURCES "${DATA_INIT_FILE}")
|
||||
endif()
|
||||
# Crash-report symbolization table emitted by generate-data-init. The stub
|
||||
# (deliberately outside the globbed src/ tree so it is never picked up twice)
|
||||
# keeps link succeeding when the generated table has not been produced yet.
|
||||
set(GUEST_SYMBOL_TABLE_FILE "${MKW_RUNTIME_SOURCE_DIR}/../generated/guest_symbol_table.cpp")
|
||||
if(EXISTS "${GUEST_SYMBOL_TABLE_FILE}")
|
||||
list(APPEND SOURCES "${GUEST_SYMBOL_TABLE_FILE}")
|
||||
else()
|
||||
list(APPEND SOURCES "${MKW_RUNTIME_SOURCE_DIR}/cmake/guest_symbol_table_stub.cpp")
|
||||
endif()
|
||||
if(EXISTS "${DATA_INIT_BLOB_ASM}")
|
||||
enable_language(ASM)
|
||||
set_source_files_properties("${DATA_INIT_BLOB_ASM}" PROPERTIES LANGUAGE ASM SKIP_UNITY_BUILD_INCLUSION ON)
|
||||
list(APPEND SOURCES "${DATA_INIT_BLOB_ASM}")
|
||||
endif()
|
||||
list(REMOVE_DUPLICATES SOURCES)
|
||||
|
||||
function(mkw_apply_common_compile_options target)
|
||||
target_compile_options(${target} PRIVATE -O3 -ffast-math -w -pipe)
|
||||
endfunction()
|
||||
|
||||
function(mkw_apply_translated_compile_options target)
|
||||
target_compile_options(${target} PRIVATE
|
||||
-O2 ${MKW_TRANSLATED_PPC_FP_OPTIONS} -fno-slp-vectorize -w -pipe)
|
||||
endfunction()
|
||||
|
||||
function(mkw_configure_object_target target)
|
||||
target_include_directories(${target} PRIVATE
|
||||
"${MKW_RUNTIME_SOURCE_DIR}/include"
|
||||
"${MKW_RUNTIME_SOURCE_DIR}/src"
|
||||
# Workspace root, so translator output is spelled "generated/<x>.h"
|
||||
# instead of a ../ chain whose depth depends on the includer.
|
||||
"${MKW_RUNTIME_SOURCE_DIR}/.."
|
||||
"${MKW_RUNTIME_SOURCE_DIR}/../aurora-main/include")
|
||||
target_compile_definitions(${target} PRIVATE
|
||||
TARGET_PC)
|
||||
set_target_properties(${target} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
|
||||
endfunction()
|
||||
|
||||
# Translated shard TUs are the memory-hungry compiles; everything else in the build is
|
||||
# comparatively small. A dedicated Ninja job pool caps how many of them run at once so the
|
||||
# global parallelism can use every core for the cheap TUs without the memory ceiling being a
|
||||
# guess. The pool depth is per-machine (derived from installed RAM by LocalBuild.ps1) and is
|
||||
# deliberately not part of the canonical flag set: it changes scheduling, never output bytes.
|
||||
if(MKW_TRANSLATED_COMPILE_JOBS GREATER 0)
|
||||
set_property(GLOBAL APPEND PROPERTY JOB_POOLS "mkw_translated=${MKW_TRANSLATED_COMPILE_JOBS}")
|
||||
endif()
|
||||
|
||||
function(mkw_bound_translated_compiles target)
|
||||
if(MKW_TRANSLATED_COMPILE_JOBS GREATER 0)
|
||||
set_property(TARGET ${target} PROPERTY JOB_POOL_COMPILE mkw_translated)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(mkw_configure_translated_target target)
|
||||
mkw_configure_object_target(${target})
|
||||
mkw_apply_translated_compile_options(${target})
|
||||
mkw_bound_translated_compiles(${target})
|
||||
endfunction()
|
||||
|
||||
add_library(mkw_runtime_common OBJECT ${SOURCES})
|
||||
mkw_configure_object_target(mkw_runtime_common)
|
||||
target_compile_features(mkw_runtime_common PRIVATE cxx_std_20)
|
||||
target_compile_definitions(mkw_runtime_common PRIVATE
|
||||
SDL_MAIN_HANDLED
|
||||
_DISABLE_STRING_ANNOTATION _DISABLE_VECTOR_ANNOTATION)
|
||||
target_link_libraries(mkw_runtime_common PRIVATE
|
||||
aurora::gx aurora::pad aurora::si aurora::vi aurora::mtx)
|
||||
target_link_libraries(mkw_runtime_common PRIVATE mkw::pugixml mkw::toml11 mkw::cryptopp)
|
||||
target_link_libraries(mkw_runtime_common PRIVATE shell32 windowsapp)
|
||||
if(MKW_CPPWINRT_INCLUDE_DIR)
|
||||
if(NOT EXISTS "${MKW_CPPWINRT_INCLUDE_DIR}/winrt/base.h")
|
||||
message(FATAL_ERROR
|
||||
"MKW_CPPWINRT_INCLUDE_DIR does not contain winrt/base.h: ${MKW_CPPWINRT_INCLUDE_DIR}")
|
||||
endif()
|
||||
target_include_directories(mkw_runtime_common PRIVATE "${MKW_CPPWINRT_INCLUDE_DIR}")
|
||||
endif()
|
||||
|
||||
# Keep runtime unity units small and semantically related. The old generated-TU
|
||||
# batch size put all 57 native runtime sources into one memory-heavy compiler job.
|
||||
foreach(source IN LISTS SOURCES)
|
||||
get_filename_component(source_name "${source}" NAME_WE)
|
||||
string(REPLACE "\\" "/" source_normalized "${source}")
|
||||
if(source_normalized MATCHES "/hle/gx/")
|
||||
set(runtime_group "gx_bridge")
|
||||
elseif(source_name MATCHES "network|socket|dns|dwc|ios")
|
||||
set(runtime_group "network_ios")
|
||||
elseif(source_name MATCHES "os_|system|memory|fiber|scheduler")
|
||||
set(runtime_group "guest_system")
|
||||
elseif(source_name MATCHES "debug|trace|prof")
|
||||
set(runtime_group "diagnostics")
|
||||
else()
|
||||
string(SHA256 source_hash "${source_name}")
|
||||
string(SUBSTRING "${source_hash}" 0 4 source_hash_prefix)
|
||||
math(EXPR runtime_bucket "0x${source_hash_prefix} % 8")
|
||||
set(runtime_group "runtime_${runtime_bucket}")
|
||||
endif()
|
||||
set_source_files_properties("${source}" PROPERTIES UNITY_GROUP "${runtime_group}")
|
||||
endforeach()
|
||||
# These translation units implement guest-visible floating-point bit
|
||||
# semantics. Keep them out of the fast-math runtime unity groups and apply
|
||||
# the same contraction/rounding policy as translated PPC shards.
|
||||
set(MKW_PPC_SEMANTIC_RUNTIME_SOURCES
|
||||
"${MKW_RUNTIME_SOURCE_DIR}/src/ppc_helpers.cpp"
|
||||
"${MKW_RUNTIME_SOURCE_DIR}/src/fpu_helpers.cpp")
|
||||
set_source_files_properties(${MKW_PPC_SEMANTIC_RUNTIME_SOURCES} PROPERTIES
|
||||
SKIP_UNITY_BUILD_INCLUSION ON
|
||||
SKIP_PRECOMPILE_HEADERS ON
|
||||
COMPILE_OPTIONS "${MKW_TRANSLATED_PPC_FP_OPTIONS}")
|
||||
set_target_properties(mkw_runtime_common PROPERTIES UNITY_BUILD ON UNITY_BUILD_MODE GROUP)
|
||||
target_precompile_headers(mkw_runtime_common PRIVATE "${MKW_RUNTIME_SOURCE_DIR}/include/mkw_pch.h")
|
||||
mkw_apply_common_compile_options(mkw_runtime_common)
|
||||
|
||||
# Host ISA guard. Everything in MKW_ALL_BUILD_TARGETS below is compiled with
|
||||
# -march=x86-64-v3; this object library deliberately is not, which
|
||||
# is the whole point of keeping it out of mkw_runtime_common. It runs a CPUID
|
||||
# check from a C initializer so an unsupported machine gets a readable error
|
||||
# instead of an illegal-instruction crash. Excluded from the unity build and the
|
||||
# precompiled header because both are produced with the owning target's flags.
|
||||
add_library(mkw_cpu_baseline OBJECT "${MKW_CPU_BASELINE_SOURCE}")
|
||||
target_compile_features(mkw_cpu_baseline PRIVATE cxx_std_17)
|
||||
set_target_properties(mkw_cpu_baseline PROPERTIES UNITY_BUILD OFF)
|
||||
target_compile_options(mkw_cpu_baseline PRIVATE -w)
|
||||
|
||||
if(NOT MKW_BASE_COMMON_SHARDS)
|
||||
message(FATAL_ERROR "Translator build graph contains no shared base shards")
|
||||
endif()
|
||||
|
||||
add_library(mkw_base_shared STATIC ${MKW_BASE_COMMON_SHARDS})
|
||||
mkw_configure_translated_target(mkw_base_shared)
|
||||
target_precompile_headers(mkw_base_shared PRIVATE "${MKW_RUNTIME_SOURCE_DIR}/include/mkw_pch.h")
|
||||
|
||||
if(MKW_BASE_PORTABLE_SENSITIVE_SHARDS)
|
||||
add_library(mkw_base_sensitive OBJECT ${MKW_BASE_PORTABLE_SENSITIVE_SHARDS})
|
||||
mkw_configure_translated_target(mkw_base_sensitive)
|
||||
target_precompile_headers(mkw_base_sensitive REUSE_FROM mkw_base_shared)
|
||||
endif()
|
||||
|
||||
if(MKW_HAVE_RETRO_REWIND)
|
||||
if(MKW_RETRO_PORTABLE_SENSITIVE_SHARDS)
|
||||
add_library(mkw_retro_sensitive OBJECT ${MKW_RETRO_PORTABLE_SENSITIVE_SHARDS})
|
||||
mkw_configure_translated_target(mkw_retro_sensitive)
|
||||
target_precompile_headers(mkw_retro_sensitive REUSE_FROM mkw_base_shared)
|
||||
endif()
|
||||
|
||||
set(MKW_RETRO_TRANSLATED_SOURCES ${MKW_RETRO_MOD_SHARDS} ${MKW_RETRO_EXTRA_SOURCES})
|
||||
set(MKW_RETRO_BLOB_OBJECTS)
|
||||
foreach(source IN LISTS MKW_RETRO_EXTRA_SOURCES)
|
||||
if(source MATCHES "\\.S$")
|
||||
enable_language(ASM)
|
||||
set_source_files_properties("${source}" PROPERTIES LANGUAGE ASM SKIP_PRECOMPILE_HEADERS ON)
|
||||
endif()
|
||||
endforeach()
|
||||
add_library(mkw_retro_rewind_functions OBJECT ${MKW_RETRO_TRANSLATED_SOURCES})
|
||||
mkw_configure_translated_target(mkw_retro_rewind_functions)
|
||||
target_precompile_headers(mkw_retro_rewind_functions REUSE_FROM mkw_base_shared)
|
||||
endif()
|
||||
|
||||
function(mkw_configure_product target)
|
||||
target_sources(${target} PRIVATE $<TARGET_OBJECTS:mkw_runtime_common>)
|
||||
# Startup CPU check. Must stay a separate object library so it keeps the
|
||||
# plain baseline ISA while everything around it is built for x86-64-v3.
|
||||
target_sources(${target} PRIVATE $<TARGET_OBJECTS:mkw_cpu_baseline>)
|
||||
target_include_directories(${target} PRIVATE
|
||||
"${MKW_RUNTIME_SOURCE_DIR}/include"
|
||||
"${MKW_RUNTIME_SOURCE_DIR}/src"
|
||||
# Workspace root, so translator output is spelled "generated/<x>.h"
|
||||
# instead of a ../ chain whose depth depends on the includer.
|
||||
"${MKW_RUNTIME_SOURCE_DIR}/.."
|
||||
"${MKW_RUNTIME_SOURCE_DIR}/../aurora-main/include")
|
||||
target_compile_definitions(${target} PRIVATE
|
||||
SDL_MAIN_HANDLED _DISABLE_STRING_ANNOTATION _DISABLE_VECTOR_ANNOTATION TARGET_PC)
|
||||
target_compile_features(${target} PRIVATE cxx_std_20)
|
||||
mkw_apply_common_compile_options(${target})
|
||||
# The dispatch-table and registration shards compile inside the product target itself and
|
||||
# include the same fat translated headers; bound them by the same pool.
|
||||
mkw_bound_translated_compiles(${target})
|
||||
target_link_libraries(${target} PRIVATE
|
||||
mkw_base_shared mkw::pugixml mkw::toml11 mkw::cryptopp)
|
||||
|
||||
target_link_libraries(${target} PRIVATE
|
||||
aurora::gx aurora::pad aurora::si aurora::vi aurora::mtx)
|
||||
if(EXISTS "${MKW_AURORA_DIR}/cmake/AuroraCopyRuntimeDLLs.cmake")
|
||||
include("${MKW_AURORA_DIR}/cmake/AuroraCopyRuntimeDLLs.cmake")
|
||||
aurora_copy_runtime_dlls(${target})
|
||||
endif()
|
||||
if(TARGET sqlite3)
|
||||
get_target_property(MKW_SQLITE_TARGET_TYPE sqlite3 TYPE)
|
||||
endif()
|
||||
if(TARGET sqlite3 AND
|
||||
(MKW_SQLITE_TARGET_TYPE STREQUAL "SHARED_LIBRARY" OR
|
||||
MKW_SQLITE_TARGET_TYPE STREQUAL "MODULE_LIBRARY"))
|
||||
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
$<TARGET_FILE:sqlite3> $<TARGET_FILE_DIR:${target}>)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${target} PRIVATE
|
||||
dbghelp user32 winmm ws2_32 iphlpapi secur32 crypt32 windowsapp)
|
||||
|
||||
set_target_properties(${target} PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||
foreach(runtime_dll libc++.dll libunwind.dll)
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_CXX_COMPILER}" "--print-file-name=${runtime_dll}"
|
||||
OUTPUT_VARIABLE runtime_dll_path
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT EXISTS "${runtime_dll_path}")
|
||||
get_filename_component(mkw_compiler_bin "${CMAKE_CXX_COMPILER}" DIRECTORY)
|
||||
set(runtime_dll_path "${mkw_compiler_bin}/${runtime_dll}")
|
||||
endif()
|
||||
if(NOT EXISTS "${runtime_dll_path}")
|
||||
message(FATAL_ERROR "llvm-mingw runtime DLL not found: ${runtime_dll}")
|
||||
endif()
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${runtime_dll_path}" $<TARGET_FILE_DIR:${target}>)
|
||||
endforeach()
|
||||
|
||||
set(MKW_WII_BOOTSTRAP_SOURCE_DIR "${MKW_RUNTIME_SOURCE_DIR}/assets/wii")
|
||||
if(NOT EXISTS "${MKW_WII_BOOTSTRAP_SOURCE_DIR}/shared2/wc24")
|
||||
message(FATAL_ERROR "Missing Wii first-run bootstrap payload: ${MKW_WII_BOOTSTRAP_SOURCE_DIR}")
|
||||
endif()
|
||||
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"${MKW_WII_BOOTSTRAP_SOURCE_DIR}" "$<TARGET_FILE_DIR:${target}>/wii_bootstrap")
|
||||
|
||||
set(MKW_DSP_COEFFICIENT_ROM "${MKW_RUNTIME_SOURCE_DIR}/assets/dsp/dsp_coef.bin")
|
||||
if(NOT EXISTS "${MKW_DSP_COEFFICIENT_ROM}")
|
||||
message(FATAL_ERROR "Missing Wii DSP coefficient ROM: ${MKW_DSP_COEFFICIENT_ROM}")
|
||||
endif()
|
||||
file(SHA256 "${MKW_DSP_COEFFICIENT_ROM}" MKW_DSP_COEFFICIENT_ROM_SHA256)
|
||||
if(NOT MKW_DSP_COEFFICIENT_ROM_SHA256 STREQUAL
|
||||
"d7741279c2e8ec5c5fb318f8fbdd6de6bf583520d288e836a5383233a4238179")
|
||||
message(FATAL_ERROR "Wii DSP coefficient ROM hash mismatch: ${MKW_DSP_COEFFICIENT_ROM_SHA256}")
|
||||
endif()
|
||||
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${MKW_DSP_COEFFICIENT_ROM}" "$<TARGET_FILE_DIR:${target}>/dsp_coef.bin")
|
||||
|
||||
# Aurora imports this portable recipe database into each user's writable
|
||||
# pipeline cache. Keep the upstream filename so its default resourcesPath
|
||||
# lookup works without application-specific configuration.
|
||||
set(MKW_INITIAL_PIPELINE_CACHE
|
||||
"${MKW_RUNTIME_SOURCE_DIR}/assets/pipeline/initial_pipeline_cache.db")
|
||||
if(NOT EXISTS "${MKW_INITIAL_PIPELINE_CACHE}")
|
||||
message(FATAL_ERROR "Missing transferable Aurora pipeline cache: ${MKW_INITIAL_PIPELINE_CACHE}")
|
||||
endif()
|
||||
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${MKW_INITIAL_PIPELINE_CACHE}"
|
||||
"$<TARGET_FILE_DIR:${target}>/initial_pipeline_cache.db")
|
||||
endfunction()
|
||||
|
||||
add_executable(WiiCompiled "${MKW_BASE_PRODUCT_SOURCE}" ${MKW_BASE_REGISTRATION_SOURCES})
|
||||
mkw_configure_product(WiiCompiled)
|
||||
target_precompile_headers(WiiCompiled PRIVATE
|
||||
"${MKW_RUNTIME_SOURCE_DIR}/include/mkw_pch.h")
|
||||
if(TARGET mkw_base_sensitive)
|
||||
target_sources(WiiCompiled PRIVATE $<TARGET_OBJECTS:mkw_base_sensitive>)
|
||||
endif()
|
||||
|
||||
if(MKW_HAVE_RETRO_REWIND)
|
||||
add_executable(RetroRewind "${MKW_RETRO_REWIND_PRODUCT_SOURCE}" ${MKW_RETRO_REGISTRATION_SOURCES})
|
||||
mkw_configure_product(RetroRewind)
|
||||
target_precompile_headers(RetroRewind REUSE_FROM WiiCompiled)
|
||||
if(TARGET mkw_retro_sensitive)
|
||||
target_sources(RetroRewind PRIVATE $<TARGET_OBJECTS:mkw_retro_sensitive>)
|
||||
endif()
|
||||
target_sources(RetroRewind PRIVATE $<TARGET_OBJECTS:mkw_retro_rewind_functions>)
|
||||
if(MKW_RETRO_BLOB_OBJECTS)
|
||||
target_sources(RetroRewind PRIVATE ${MKW_RETRO_BLOB_OBJECTS})
|
||||
endif()
|
||||
add_custom_target(mkw_release DEPENDS WiiCompiled RetroRewind)
|
||||
else()
|
||||
add_custom_target(mkw_release DEPENDS WiiCompiled)
|
||||
message(STATUS "RetroRewind target disabled (run translate-mod and emit-build-shards)")
|
||||
endif()
|
||||
|
||||
set(MKW_ALL_BUILD_TARGETS
|
||||
mkw_runtime_common mkw_base_shared mkw_base_sensitive mkw_retro_sensitive
|
||||
mkw_retro_rewind_functions WiiCompiled RetroRewind)
|
||||
foreach(target IN LISTS MKW_ALL_BUILD_TARGETS)
|
||||
if(TARGET ${target})
|
||||
target_compile_options(${target} PRIVATE -march=x86-64-v3)
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -0,0 +1,18 @@
|
||||
// Fallback for builds where generated/guest_symbol_table.cpp has not been
|
||||
// produced yet (generate-data-init emits the real table from the project's
|
||||
// function map). An empty table simply disables crash-report symbolization.
|
||||
#include <cstdint>
|
||||
|
||||
extern "C" {
|
||||
|
||||
// The extern declarations force external linkage: namespace-scope const
|
||||
// objects are internal-linkage by default in C++, even inside extern "C".
|
||||
extern const uint32_t kGuestMapSymbolCount;
|
||||
extern const uint32_t kGuestMapSymbolAddresses[];
|
||||
extern const char* const kGuestMapSymbolNames[];
|
||||
|
||||
const uint32_t kGuestMapSymbolCount = 0u;
|
||||
const uint32_t kGuestMapSymbolAddresses[] = {0u};
|
||||
const char* const kGuestMapSymbolNames[] = {""};
|
||||
|
||||
} // extern "C"
|
||||
Reference in new issue
Block a user