Tweaks to cmake globbing/source_grouping (#4439)

This commit is contained in:
Garrett Cox 2024-10-18 16:35:07 +00:00 committed by GitHub
parent a7cb7da9fc
commit cbd35d0ef5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 153 deletions

View File

@ -120,94 +120,55 @@ source_group("include" FILES ${Header_Files__include})
# }}} # }}}
# soh (root) # soh (root)
file(GLOB soh__ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "soh/*.c" "soh/*.cpp" "soh/*.h") file(GLOB_RECURSE soh__ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "soh/*.c" "soh/*.cpp" "soh/*.h" "soh/*.hpp")
source_group("soh" FILES ${soh__})
# Add specific files that don't match the pattern
list(APPEND soh__ ${CMAKE_CURRENT_SOURCE_DIR}/soh/Enhancements/savestates_extern.inc)
list(APPEND soh__ ${CMAKE_CURRENT_SOURCE_DIR}/soh/Enhancements/speechsynthesizer/DarwinSpeechSynthesizer.mm)
# Create source groups that match the real file directory paths
foreach(source IN LISTS soh__)
get_filename_component(source_path "${source}" PATH)
string(REPLACE "/" "\\" source_path_adjusted "${source_path}")
source_group("${source_path_adjusted}" FILES "${source}")
endforeach()
# Fix UTF-8 issues for MSVC
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set_source_files_properties(soh/OTRGlobals.cpp PROPERTIES COMPILE_FLAGS "/utf-8") set_source_files_properties(soh/OTRGlobals.cpp PROPERTIES COMPILE_FLAGS "/utf-8")
set_source_files_properties(soh/Enhancements/tts/tts.cpp PROPERTIES COMPILE_FLAGS "/utf-8")
endif() endif()
# soh/config {{{ # handle Network removals
file(GLOB_RECURSE soh__config RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"soh/config/*.h"
"soh/config/*.cpp"
)
# }}}
# soh/enhancements {{{
file(GLOB_RECURSE soh__Enhancements RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"soh/Enhancements/*.c"
"soh/Enhancements/*.cpp"
"soh/Enhancements/*.h"
"soh/Enhancements/*.hpp"
"soh/Enhancements/*_extern.inc"
"soh/Enhancements/*.mm"
)
list(REMOVE_ITEM soh__Enhancements "soh/Enhancements/gamecommand.h")
list(FILTER soh__Enhancements EXCLUDE REGEX "soh/Enhancements/gfx.*")
# handle crowd control removals
list(REMOVE_ITEM soh__Enhancements "soh/Enhancements/crowd-control/soh.cs")
list(REMOVE_ITEM soh__Enhancements "soh/Enhancements/crowd-control/soh.ccpak")
if (!BUILD_REMOTE_CONTROL) if (!BUILD_REMOTE_CONTROL)
list(FILTER soh__Enhancements EXCLUDE REGEX "soh/Enhancements/crowd-control/*") list(FILTER soh__ EXCLUDE REGEX "soh/Enhancements/crowd-control/*")
endif() endif()
# handle speechsynthesizer removals # handle speechsynthesizer removals
if (CMAKE_SYSTEM_NAME STREQUAL "Windows") if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
list(FILTER soh__Enhancements EXCLUDE REGEX "soh/Enhancements/speechsynthesizer/Darwin*") list(FILTER soh__ EXCLUDE REGEX "soh/Enhancements/speechsynthesizer/Darwin*")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin") elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
list(FILTER soh__Enhancements EXCLUDE REGEX "soh/Enhancements/speechsynthesizer/SAPI*") list(FILTER soh__ EXCLUDE REGEX "soh/Enhancements/speechsynthesizer/SAPI*")
else() else()
list(FILTER soh__Enhancements EXCLUDE REGEX "soh/Enhancements/speechsynthesizer/(Darwin|SAPI).*") list(FILTER soh__ EXCLUDE REGEX "soh/Enhancements/speechsynthesizer/(Darwin|SAPI).*")
endif() endif()
source_group("soh\\Enhancements" REGULAR_EXPRESSION "soh/Enhancements/*") # soh/Extractor {{{
source_group("soh\\Enhancements\\audio" REGULAR_EXPRESSION "soh/Enhancements/audio/*") list(FILTER ship__ EXCLUDE REGEX "soh/Extractor/*")
source_group("soh\\Enhancements\\controls" REGULAR_EXPRESSION "soh/Enhancements/controls/*")
source_group("soh\\Enhancements\\cosmetics" REGULAR_EXPRESSION "soh/Enhancements/cosmetics/*")
source_group("soh\\Enhancements\\crowd-control" REGULAR_EXPRESSION "soh/Enhancements/crowd-control/*")
source_group("soh\\Enhancements\\custom-message" REGULAR_EXPRESSION "soh/Enhancements/custom-message/*")
source_group("soh\\Enhancements\\debugger" REGULAR_EXPRESSION "soh/Enhancements/debugger/*")
source_group("soh\\Enhancements\\game-interactor" REGULAR_EXPRESSION "soh/Enhancements/game-interactor/*")
source_group("soh\\Enhancements\\item-tables" REGULAR_EXPRESSION "soh/Enhancements/item-tables/*")
source_group("soh\\Enhancements\\randomizer" REGULAR_EXPRESSION "soh/Enhancements/randomizer/*")
source_group("soh\\Enhancements\\randomizer\\3drando" REGULAR_EXPRESSION "soh/Enhancements/randomizer/3drando/*")
source_group("soh\\Enhancements\\randomizer\\3drando\\hint_list" REGULAR_EXPRESSION "soh/Enhancements/randomizer/3drando/hint_list/*")
source_group("soh\\Enhancements\\randomizer\\3drando\\location_access" REGULAR_EXPRESSION "soh/Enhancements/randomizer/3drando/location_access/*")
source_group("soh\\Enhancements\\speechsynthesizer" REGULAR_EXPRESSION "soh/Enhancements/speechsynthesizer/*")
source_group("soh\\Enhancements\\tts" REGULAR_EXPRESSION "soh/Enhancements/tts/*")
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set_source_files_properties(soh/Enhancements/tts/tts.cpp PROPERTIES COMPILE_FLAGS "/utf-8")
endif()
# }}}
if(NOT CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch|CafeOS") if(NOT CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch|CafeOS")
# soh/Extractor {{{
file(GLOB_RECURSE soh__Extractor RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} file(GLOB_RECURSE soh__Extractor RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"soh/Extractor/*.c" "soh/Extractor/*.c"
"soh/Extractor/*.cpp" "soh/Extractor/*.cpp"
"soh/Extractor/*.h" "soh/Extractor/*.h"
"soh/Extractor/*.hpp" "soh/Extractor/*.hpp"
) )
# }}}
else() else()
file(GLOB_RECURSE soh__Extractor RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} file(GLOB_RECURSE soh__Extractor RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"soh/Extractor/*.h" "soh/Extractor/*.h"
"soh/Extractor/*.hpp" "soh/Extractor/*.hpp"
) )
# }}}
endif() endif()
# soh/resource {{{
file(GLOB_RECURSE soh__Resource RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "soh/resource/*.cpp" "soh/resource/*.h")
source_group("soh\\resource\\type" REGULAR_EXPRESSION "soh/resource/type/*")
source_group("soh\\resource\\type\\scenecommand" REGULAR_EXPRESSION "soh/resource/type/scenecommand/*")
source_group("soh\\resource\\importer" REGULAR_EXPRESSION "soh/resource/importer/*")
source_group("soh\\resource\\importer\\scenecommand" REGULAR_EXPRESSION "soh/resource/importer/scenecommand/*")
# }}} # }}}
# src (decomp) {{{ # src (decomp) {{{
@ -246,10 +207,7 @@ set(ALL_FILES
${Header_Files} ${Header_Files}
${Header_Files__include} ${Header_Files__include}
${soh__} ${soh__}
${soh__config}
${soh__Enhancements}
${soh__Extractor} ${soh__Extractor}
${soh__Resource}
${src__} ${src__}
) )

View File

@ -1,10 +0,0 @@
#ifndef _GAMECOMMAND_H_
#define _GAMECOMMAND_H_
#include <ultra64.h>
#include <z64.h>
#define MAX_COMMAND_LEN 0x100
s32 GameCommand_ExecuteCommand();
#endif

View File

@ -1,63 +0,0 @@
#include "gfx.h"
#include "global.h"
#include "z64.h"
extern PlayState* gPlayState;
/**
* Simple wrapper to load a texture to be drawn.
*/
void sprite_load(sprite_t* sprite) {
OPEN_DISPS(gPlayState->state.gfxCtx);
if (sprite->im_siz == G_IM_SIZ_16b) {
gDPLoadTextureBlock(
OVERLAY_DISP++,
sprite->tex,
sprite->im_fmt,
G_IM_SIZ_16b, // @TEMP until I figure out how to use sprite->im_siz
sprite->width, sprite->height,
0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP,
G_TX_NOMASK, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD
);
} else {
gDPLoadTextureBlock(
OVERLAY_DISP++,
sprite->tex,
sprite->im_fmt,
G_IM_SIZ_32b, // @TEMP until I figure out how to use sprite->im_siz
sprite->width, sprite->height,
0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP,
G_TX_NOMASK, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD
);
}
CLOSE_DISPS(gPlayState->state.gfxCtx);
}
/**
* Simple wrapper to draw a sprite/texture on the screen.
* sprite_load needs to be ran right before this.
*/
void sprite_draw(sprite_t* sprite, int left, int top, int width, int height) {
int width_factor = (1 << 10) * sprite->width / width;
int height_factor = (1 << 10) * sprite->height / height;
OPEN_DISPS(gPlayState->state.gfxCtx);
gSPWideTextureRectangle(
OVERLAY_DISP++,
OTRGetRectDimensionFromRightEdge(left) << 2, top << 2,
(OTRGetRectDimensionFromRightEdge(left) + width) << 2, (top + height) << 2,
G_TX_RENDERTILE,
0, 0,
width_factor, height_factor
);
CLOSE_DISPS(gPlayState->state.gfxCtx);
}

View File

@ -1,17 +0,0 @@
#ifndef GFX_ENHANCEMENT_H
#define GFX_EHHANCEMENT_H
#include "z64.h"
typedef struct {
void *tex;
uint16_t width;
uint16_t height;
uint8_t im_fmt;
uint8_t im_siz;
} sprite_t;
void sprite_load(sprite_t *sprite);
void sprite_draw(sprite_t *sprite, int left, int top, int width, int height);
#endif