build: list sources explicitly in meson.build instead of shelling out

This commit is contained in:
MatthewBeshay 2026-04-08 19:20:43 +10:00
parent d7eca58551
commit 6b3b0134cf
6 changed files with 1391 additions and 51 deletions

97
scripts/list_sources.py Normal file
View file

@ -0,0 +1,97 @@
#!/usr/bin/env python3
"""Enumerate C/C++ source files for a meson target.
Replaces the run_command('sh', '-c', 'find ...') hack in
targets/{minecraft,app}/meson.build. Run this whenever source files are
added or removed and commit the regenerated *_sources.txt files.
Usage:
python3 scripts/list_sources.py
Each module's sources.txt is generated relative to its meson source dir.
"""
import os
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
# Module configuration: (output_path, scan_root, [exclude_basenames]).
# Paths in the output file are relative to the directory containing the
# meson.build that reads it.
MODULES = [
{
"name": "minecraft",
"output": REPO_ROOT / "targets" / "minecraft" / "sources.txt",
"scan_root": REPO_ROOT / "targets" / "minecraft",
"rel_to": REPO_ROOT / "targets" / "minecraft",
"exclude": {
"DurangoStats.cpp", # Durango-specific
# Incomplete / unused
"SkyIslandDimension.cpp",
"MemoryChunkStorage.cpp",
"MemoryLevelStorage.cpp",
"MemoryLevelStorageSource.cpp",
"NbtSlotFile.cpp",
"ZonedChunkStorage.cpp",
"ZoneFile.cpp",
"ZoneIo.cpp",
"LevelConflictException.cpp",
"SurvivalMode.cpp",
"CreativeMode.cpp",
"GameMode.cpp",
"DemoMode.cpp",
},
},
{
"name": "app_common",
"output": REPO_ROOT / "targets" / "app" / "common_sources.txt",
"scan_root": REPO_ROOT / "targets" / "app" / "common",
"rel_to": REPO_ROOT / "targets" / "app",
"exclude": {
"UIScene_InGameSaveManagementMenu.cpp",
},
},
{
"name": "app_linux",
"output": REPO_ROOT / "targets" / "app" / "linux_sources.txt",
"scan_root": REPO_ROOT / "targets" / "app" / "linux",
"rel_to": REPO_ROOT / "targets" / "app",
"exclude": set(),
},
]
EXTENSIONS = (".cpp", ".c")
def collect(scan_root: Path, rel_to: Path, exclude: set[str]) -> list[str]:
out: list[str] = []
for dirpath, _dirnames, filenames in os.walk(scan_root):
for name in filenames:
if not name.endswith(EXTENSIONS):
continue
if name in exclude:
continue
full = Path(dirpath) / name
out.append(str(full.relative_to(rel_to)))
out.sort()
return out
def main() -> int:
for mod in MODULES:
sources = collect(mod["scan_root"], mod["rel_to"], mod["exclude"])
body = "\n".join(sources) + "\n"
out_path: Path = mod["output"]
previous = out_path.read_text() if out_path.exists() else ""
if previous == body:
print(f"{mod['name']}: {len(sources)} files (unchanged)")
else:
out_path.write_text(body)
print(f"{mod['name']}: {len(sources)} files (regenerated {out_path.relative_to(REPO_ROOT)})")
return 0
if __name__ == "__main__":
sys.exit(main())

View file

@ -0,0 +1,225 @@
common/AppGameServices.cpp
common/ArchiveManager.cpp
common/Audio/Consoles_SoundEngine.cpp
common/Audio/SoundEngine.cpp
common/Audio/SoundNames.cpp
common/BannedListManager.cpp
common/Colours/ColourTable.cpp
common/ConsoleGameMode.cpp
common/DLC/DLCAudioFile.cpp
common/DLC/DLCCapeFile.cpp
common/DLC/DLCColourTableFile.cpp
common/DLC/DLCFile.cpp
common/DLC/DLCGameRulesFile.cpp
common/DLC/DLCGameRulesHeader.cpp
common/DLC/DLCLocalisationFile.cpp
common/DLC/DLCManager.cpp
common/DLC/DLCPack.cpp
common/DLC/DLCSkinFile.cpp
common/DLC/DLCTextureFile.cpp
common/DLC/DLCUIDataFile.cpp
common/DLCController.cpp
common/DebugOptions.cpp
common/Game.cpp
common/GameMenuService.cpp
common/GameRules/GameRuleManager.cpp
common/GameRules/LevelGeneration/ApplySchematicRuleDefinition.cpp
common/GameRules/LevelGeneration/BiomeOverride.cpp
common/GameRules/LevelGeneration/ConsoleGenerateStructure.cpp
common/GameRules/LevelGeneration/ConsoleSchematicFile.cpp
common/GameRules/LevelGeneration/LevelGenerationOptions.cpp
common/GameRules/LevelGeneration/LevelGenerators.cpp
common/GameRules/LevelGeneration/StartFeature.cpp
common/GameRules/LevelGeneration/StructureActions/XboxStructureActionGenerateBox.cpp
common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceBlock.cpp
common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceContainer.cpp
common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceSpawner.cpp
common/GameRules/LevelRules/LevelRules.cpp
common/GameRules/LevelRules/RuleDefinitions/AddEnchantmentRuleDefinition.cpp
common/GameRules/LevelRules/RuleDefinitions/AddItemRuleDefinition.cpp
common/GameRules/LevelRules/RuleDefinitions/CollectItemRuleDefinition.cpp
common/GameRules/LevelRules/RuleDefinitions/CompleteAllRuleDefinition.cpp
common/GameRules/LevelRules/RuleDefinitions/CompoundGameRuleDefinition.cpp
common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.cpp
common/GameRules/LevelRules/RuleDefinitions/LevelRuleset.cpp
common/GameRules/LevelRules/RuleDefinitions/NamedAreaRuleDefinition.cpp
common/GameRules/LevelRules/RuleDefinitions/UpdatePlayerRuleDefinition.cpp
common/GameRules/LevelRules/RuleDefinitions/UseTileRuleDefinition.cpp
common/GameRules/LevelRules/Rules/GameRule.cpp
common/GameRules/WstringLookup.cpp
common/GameSettingsManager.cpp
common/Game_XuiActions.cpp
common/Leaderboards/LeaderboardInterface.cpp
common/Leaderboards/LeaderboardManager.cpp
common/Localisation/StringTable.cpp
common/LocalizationManager.cpp
common/MenuController.cpp
common/Network/GameNetworkManager.cpp
common/Network/NetworkPlayerQNet.cpp
common/Network/PlatformNetworkManagerStub.cpp
common/Network/QNetStubs.cpp
common/Network/Socket.cpp
common/NetworkController.cpp
common/SaveManager.cpp
common/SkinManager.cpp
common/TerrainFeatureManager.cpp
common/Trial/TrialMode.cpp
common/Tutorial/Constraints/AreaConstraint.cpp
common/Tutorial/Constraints/ChangeStateConstraint.cpp
common/Tutorial/Constraints/InputConstraint.cpp
common/Tutorial/FullTutorial.cpp
common/Tutorial/FullTutorialMode.cpp
common/Tutorial/Hints/AreaHint.cpp
common/Tutorial/Hints/DiggerItemHint.cpp
common/Tutorial/Hints/LookAtEntityHint.cpp
common/Tutorial/Hints/LookAtTileHint.cpp
common/Tutorial/Hints/TakeItemHint.cpp
common/Tutorial/Hints/TutorialHint.cpp
common/Tutorial/Tasks/AreaTask.cpp
common/Tutorial/Tasks/ChoiceTask.cpp
common/Tutorial/Tasks/CompleteUsingItemTask.cpp
common/Tutorial/Tasks/ControllerTask.cpp
common/Tutorial/Tasks/CraftTask.cpp
common/Tutorial/Tasks/EffectChangedTask.cpp
common/Tutorial/Tasks/FullTutorialActiveTask.cpp
common/Tutorial/Tasks/HorseChoiceTask.cpp
common/Tutorial/Tasks/InfoTask.cpp
common/Tutorial/Tasks/PickupTask.cpp
common/Tutorial/Tasks/ProcedureCompoundTask.cpp
common/Tutorial/Tasks/ProgressFlagTask.cpp
common/Tutorial/Tasks/RideEntityTask.cpp
common/Tutorial/Tasks/StatTask.cpp
common/Tutorial/Tasks/TutorialTask.cpp
common/Tutorial/Tasks/UseItemTask.cpp
common/Tutorial/Tasks/UseTileTask.cpp
common/Tutorial/Tasks/XuiCraftingTask.cpp
common/Tutorial/Tutorial.cpp
common/Tutorial/TutorialMessage.cpp
common/Tutorial/TutorialMode.cpp
common/UI/All Platforms/ArchiveFile.cpp
common/UI/All Platforms/IUIScene_AbstractContainerMenu.cpp
common/UI/All Platforms/IUIScene_AnvilMenu.cpp
common/UI/All Platforms/IUIScene_BeaconMenu.cpp
common/UI/All Platforms/IUIScene_BrewingMenu.cpp
common/UI/All Platforms/IUIScene_CommandBlockMenu.cpp
common/UI/All Platforms/IUIScene_ContainerMenu.cpp
common/UI/All Platforms/IUIScene_CraftingMenu.cpp
common/UI/All Platforms/IUIScene_CreativeMenu.cpp
common/UI/All Platforms/IUIScene_DispenserMenu.cpp
common/UI/All Platforms/IUIScene_EnchantingMenu.cpp
common/UI/All Platforms/IUIScene_FireworksMenu.cpp
common/UI/All Platforms/IUIScene_FurnaceMenu.cpp
common/UI/All Platforms/IUIScene_HUD.cpp
common/UI/All Platforms/IUIScene_HopperMenu.cpp
common/UI/All Platforms/IUIScene_HorseInventoryMenu.cpp
common/UI/All Platforms/IUIScene_InventoryMenu.cpp
common/UI/All Platforms/IUIScene_PauseMenu.cpp
common/UI/All Platforms/IUIScene_TradingMenu.cpp
common/UI/Components/UIComponent_Chat.cpp
common/UI/Components/UIComponent_DebugUIConsole.cpp
common/UI/Components/UIComponent_DebugUIMarketingGuide.cpp
common/UI/Components/UIComponent_Logo.cpp
common/UI/Components/UIComponent_MenuBackground.cpp
common/UI/Components/UIComponent_Panorama.cpp
common/UI/Components/UIComponent_PressStartToPlay.cpp
common/UI/Components/UIComponent_Tooltips.cpp
common/UI/Components/UIComponent_TutorialPopup.cpp
common/UI/Components/UIScene_HUD.cpp
common/UI/Controls/UIControl.cpp
common/UI/Controls/UIControl_Base.cpp
common/UI/Controls/UIControl_BeaconEffectButton.cpp
common/UI/Controls/UIControl_BitmapIcon.cpp
common/UI/Controls/UIControl_Button.cpp
common/UI/Controls/UIControl_ButtonList.cpp
common/UI/Controls/UIControl_CheckBox.cpp
common/UI/Controls/UIControl_Cursor.cpp
common/UI/Controls/UIControl_DLCList.cpp
common/UI/Controls/UIControl_DynamicLabel.cpp
common/UI/Controls/UIControl_EnchantmentBook.cpp
common/UI/Controls/UIControl_EnchantmentButton.cpp
common/UI/Controls/UIControl_HTMLLabel.cpp
common/UI/Controls/UIControl_Label.cpp
common/UI/Controls/UIControl_LeaderboardList.cpp
common/UI/Controls/UIControl_MinecraftHorse.cpp
common/UI/Controls/UIControl_MinecraftPlayer.cpp
common/UI/Controls/UIControl_PlayerList.cpp
common/UI/Controls/UIControl_PlayerSkinPreview.cpp
common/UI/Controls/UIControl_Progress.cpp
common/UI/Controls/UIControl_SaveList.cpp
common/UI/Controls/UIControl_Slider.cpp
common/UI/Controls/UIControl_SlotList.cpp
common/UI/Controls/UIControl_SpaceIndicatorBar.cpp
common/UI/Controls/UIControl_TextInput.cpp
common/UI/Controls/UIControl_TexturePackList.cpp
common/UI/Controls/UIControl_Touch.cpp
common/UI/Scenes/Debug/UIScene_DebugCreateSchematic.cpp
common/UI/Scenes/Debug/UIScene_DebugOptions.cpp
common/UI/Scenes/Debug/UIScene_DebugOverlay.cpp
common/UI/Scenes/Debug/UIScene_DebugSetCamera.cpp
common/UI/Scenes/Frontend Menu screens/IUIScene_StartGame.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_CreateWorldMenu.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_DLCMainMenu.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_DLCOffersMenu.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_EULA.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_Intro.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_JoinMenu.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_LaunchMoreOptionsMenu.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_LeaderboardsMenu.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_LoadMenu.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_LoadOrJoinMenu.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_NewUpdateMessage.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_SaveMessage.cpp
common/UI/Scenes/Frontend Menu screens/UIScene_TrialExitUpsell.cpp
common/UI/Scenes/Help & Options/UIScene_ControlsMenu.cpp
common/UI/Scenes/Help & Options/UIScene_Credits.cpp
common/UI/Scenes/Help & Options/UIScene_HelpAndOptionsMenu.cpp
common/UI/Scenes/Help & Options/UIScene_HowToPlay.cpp
common/UI/Scenes/Help & Options/UIScene_HowToPlayMenu.cpp
common/UI/Scenes/Help & Options/UIScene_LanguageSelector.cpp
common/UI/Scenes/Help & Options/UIScene_ReinstallMenu.cpp
common/UI/Scenes/Help & Options/UIScene_SettingsAudioMenu.cpp
common/UI/Scenes/Help & Options/UIScene_SettingsControlMenu.cpp
common/UI/Scenes/Help & Options/UIScene_SettingsGraphicsMenu.cpp
common/UI/Scenes/Help & Options/UIScene_SettingsMenu.cpp
common/UI/Scenes/Help & Options/UIScene_SettingsOptionsMenu.cpp
common/UI/Scenes/Help & Options/UIScene_SettingsUIMenu.cpp
common/UI/Scenes/Help & Options/UIScene_SkinSelectMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_AbstractContainerMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_AnvilMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_BeaconMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_BrewingStandMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_ContainerMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_CreativeMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_DispenserMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_EnchantingMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_FireworksMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_FurnaceMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_HopperMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_HorseInventoryMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_InventoryMenu.cpp
common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_TradingMenu.cpp
common/UI/Scenes/In-Game Menu Screens/UIScene_CraftingMenu.cpp
common/UI/Scenes/In-Game Menu Screens/UIScene_DeathMenu.cpp
common/UI/Scenes/In-Game Menu Screens/UIScene_EndPoem.cpp
common/UI/Scenes/In-Game Menu Screens/UIScene_InGameHostOptionsMenu.cpp
common/UI/Scenes/In-Game Menu Screens/UIScene_InGameInfoMenu.cpp
common/UI/Scenes/In-Game Menu Screens/UIScene_InGamePlayerOptionsMenu.cpp
common/UI/Scenes/In-Game Menu Screens/UIScene_PauseMenu.cpp
common/UI/Scenes/In-Game Menu Screens/UIScene_SignEntryMenu.cpp
common/UI/Scenes/In-Game Menu Screens/UIScene_TeleportMenu.cpp
common/UI/Scenes/UIScene_ConnectingProgress.cpp
common/UI/Scenes/UIScene_FullscreenProgress.cpp
common/UI/Scenes/UIScene_Keyboard.cpp
common/UI/Scenes/UIScene_MessageBox.cpp
common/UI/Scenes/UIScene_QuadrantSignin.cpp
common/UI/Scenes/UIScene_Timer.cpp
common/UI/UIBitmapFont.cpp
common/UI/UIController.cpp
common/UI/UIFontData.cpp
common/UI/UIGroup.cpp
common/UI/UILayer.cpp
common/UI/UIScene.cpp
common/UI/UIString.cpp
common/UI/UITTFFont.cpp
common/XboxStubs.cpp

View file

@ -0,0 +1,5 @@
linux/Iggy/gdraw/gdraw.c
linux/Leaderboards/LinuxLeaderboardManager.cpp
linux/LinuxGame.cpp
linux/Linux_Minecraft.cpp
linux/Linux_UIController.cpp

View file

@ -1,26 +1,11 @@
exclude_platform_common_sources = [
' ! -name "UIScene_InGameSaveManagementMenu.cpp"',
]
# Source lists live in common_sources.txt / linux_sources.txt and are
# regenerated by scripts/list_sources.py whenever files are added or
# removed.
fs = import('fs')
platform_sources = files(fs.read('common_sources.txt').strip().split('\n'))
# all sources in common/
platform_sources = run_command(
'sh',
'-c', 'find "'
+ meson.current_source_dir() / 'common'
+ '" \\( -name "*.cpp" -o -name "*.c" \\)'
+ ' '.join(exclude_platform_common_sources),
check: true,
).stdout().strip().split('\n')
# linux-specific files
if host_machine.system() == 'linux'
platform_sources += run_command(
'sh',
'-c', 'find "'
+ meson.current_source_dir() / 'linux'
+ '" \\( -name "*.cpp" -o -name "*.c" \\) ',
check: true,
).stdout().strip().split('\n')
platform_sources += files(fs.read('linux_sources.txt').strip().split('\n'))
endif
client_dependencies = [

View file

@ -1,33 +1,9 @@
# sources that shouldn't be compiled for whatever reason
exclude_sources = [
'! -name DurangoStats.cpp', # Durango-specific
# Incomplete/Unused
'! -name SkyIslandDimension.cpp',
'! -name MemoryChunkStorage.cpp',
'! -name MemoryLevelStorage.cpp',
'! -name MemoryLevelStorageSource.cpp',
'! -name NbtSlotFile.cpp',
'! -name ZonedChunkStorage.cpp',
'! -name ZoneFile.cpp',
'! -name ZoneIo.cpp',
'! -name LevelConflictException.cpp',
'! -name "SurvivalMode.cpp"',
'! -name "CreativeMode.cpp"',
'! -name "GameMode.cpp"',
'! -name "DemoMode.cpp"',
]
# GET IT ALLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
# TODO: make this process more portable using a python script :3
minecraft_sources = run_command(
'sh', '-c',
'find "'
+ meson.current_source_dir()
+ '" \\( -name "*.cpp" -o -name "*.c" \\) '
+ ' '.join(exclude_sources),
check : true,
).stdout().strip().split('\n')
# Source list lives in sources.txt and is regenerated by
# scripts/list_sources.py whenever files are added or removed. Reading
# the committed file means meson reconfigures only when the list itself
# changes, which is what we want.
fs = import('fs')
minecraft_sources = files(fs.read('sources.txt').strip().split('\n'))
occlusion_mode = get_option('occlusion_culling')
if occlusion_mode == 'off'

File diff suppressed because it is too large Load diff