mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-23 03:58:59 +00:00
9ec7714ebc
None of these sources are referenced, either directly or indirectly, in any CMakeLists.txt file. NOTE: All of legacy/ is unused, but we're keeping it around. Process for this commit: (in bash) **NOTE: THIS MUST BE DONE ON A CASE-SENSITIVE FILESYSTEM**. There are a few instances of differing-in-case-only (hogmaker vs HogMaker, etc) that will catch you out otherwise. ``` # *** 1: Find all directly-referenced c/cpp files in CMakeLists.txt find . -name CMakeLists.txt -exec cat {} \+ | # Then, convert spaces and tabs to newlines for easy tokenizing tr -s ' \t' '\n' | # Filter to just tokens descripting c/cpp filenames (case insensitive) grep -iE '\.c(pp)?' | # Massage each filename to remove CMake-specific chars sed 's/[")]//g' | # Remove a URL that happens to match the pattern so far grep -v https: | # Remove files that start with # (and are thus comments, not refs) grep -Ev '^#' | # *** 2: In the output so far there is a curious entry ${SCRIPT}.cpp # Turns out, the makefiles generate some further filenames from script # names. So, delete the ${SCRIPT}.cpp filename... grep -v '${SCRIPT}.cpp' | # .. and add in the cpps. ( # We use a bash subshell to let us "concatenate" to the pipe. This # writes stdin back to stdout, and then starts a *new command* to # generate more to stdout. cat -; # All the generated script cpp references live in scripts/ cat scripts/CMakeLists.txt | # Squash the makefile onto one line for regex ease tr '\n' ' ' | # Extract the script names sed -E 's/.*set\(SCRIPTS([^)]+)\).*/\1/' | # Convert spaces and tabs to newlines for easy tokenizing tr -s ' \t' '\n' | # Remove blank lines grep -v '^$' | # Add cpp extension to each token while read TOKEN; do echo ${TOKEN}.cpp; done ) | # *** 3: Being referenced by CMakeFiles.txt isn't the only way a src # file can be used - it could also be potentially #include'ed. Let's # find those, with another subshell concatenation: ( cat -; # Look in ALL source files. We could actually probably limit the # search here to just src files listed so far in stdin + *.h, but # that'd require a bunch of redirections and this bash pipeline is # already ridiculous enough. (Case!) find . -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" | # Pull out the #include directives from them xargs grep --no-filename '#include' | # Look for any include of a .c or .cpp file (Case!) grep -iE '\.c(pp)?' | # Squash multiple spaces and tabs into one single space tr -s ' \t' ' ' | # Split on spaces, take the second field cut -d ' ' -f 2 | # Delete off quotes and angle brackets to get the included filename tr -d '"<>' ) | # *** 4: Protect all files under legacy/, per @Lgt2x's request ( cat -; find legacy -iname "*.cpp" -or -iname "*.c" ) | # *** 5: Reduce all entries to their basename while read FILENAME; do basename $FILENAME; done | # *** 6: FINALLY, sort and dedupe the output into a file. sort | uniq > used_srcs # Now that we know all the used source files, we need to find all of # the source files in the repo, and delete them if they do not appear # in the used_srcs list. for SRC in $(find . -iname "*.cpp" -or -iname "*.c"); do # find outputs the relative path, we want to operate on just filename basename $SRC | # grep to see if the basename occurs in the used_srcs list. # -q means be quiet, do not print the match (so this doesn't spam) # -x means match the entire line (so macfile.cpp doesn't sneak thru # via cfile.cpp) # -F means treat the lines patterns as fixed (not regexp) # -f means load patterns from the given file grep -qxFf used_srcs || # If the grep command *fails*, then the file is not in the list. # Bash performs logic short-circuiting, so we can use logical-OR git rm $SRC; done ``` Test Plan: On all three of `[win, mac, linux]`: ``` cmake --preset <platform> cmake --build --preset <platform> --config Debug cmake --build --preset <platform> --config Release ``` |
||
---|---|---|
.. | ||
data | ||
lnx | ||
aigame2.cpp | ||
aigame4.cpp | ||
AIGame3_External.h | ||
AIGame3.cpp | ||
AIGame.cpp | ||
barney.cpp | ||
BatteriesIncluded.cpp | ||
BatteriesIncluded.msg | ||
BossCamera.cpp | ||
CanyonsCTF.cpp | ||
CellTestLevel.cpp | ||
CellTestLevel.msg | ||
ChrisTest.cpp | ||
ChrisTest.msg | ||
clutter.cpp | ||
CMakeLists.txt | ||
DallasFuncs.cpp | ||
Gamegauge_FRN.msg | ||
Gamegauge_GER.msg | ||
Gamegauge_ITN.msg | ||
gamegauge_SPN.msg | ||
GameGauge.cpp | ||
GameGauge.msg | ||
gcc-game.def | ||
gcc-lvl.def | ||
generic.cpp | ||
Geodomes.cpp | ||
Geodomes.msg | ||
HalfPipe_Ger.msg | ||
HalfPipe.cpp | ||
HalfPipe.msg | ||
InfernalBolt_Ger.msg | ||
InfernalBolt.cpp | ||
InfernalBolt.msg | ||
Inversion.cpp | ||
Inversion.msg | ||
level1_Ger.msg | ||
level1_SPN.msg | ||
level1.cpp | ||
level1.msg | ||
level2_Ger.msg | ||
level2_SPN.msg | ||
level2.cpp | ||
level2.msg | ||
level3_Ger.msg | ||
level3_SPN.msg | ||
level3.cpp | ||
level3.msg | ||
level4_Ger.msg | ||
level4_SPN.msg | ||
level4.cpp | ||
level4.msg | ||
level5_Ger.msg | ||
level5_SPN.msg | ||
level5.cpp | ||
level5.msg | ||
level6_SPN.msg | ||
level7_Ger.msg | ||
level7_SPN.msg | ||
level7.cpp | ||
level7.msg | ||
level8_Ger.msg | ||
level8_SPN.msg | ||
level8.cpp | ||
level8.msg | ||
level9_SPN.msg | ||
level10_Ger.msg | ||
level10_SPN.msg | ||
level10.cpp | ||
level10.msg | ||
level11_Ger.msg | ||
level11_SPN.msg | ||
level11.cpp | ||
level11.msg | ||
level12_SPN.msg | ||
level13_Ger.msg | ||
level13_SPN.msg | ||
level13.cpp | ||
level13.msg | ||
level14_Ger.msg | ||
level14_SPN.msg | ||
level14.cpp | ||
level14.msg | ||
level15_SPN.msg | ||
level17.cpp | ||
level17.msg | ||
Level1_FRN.msg | ||
Level1_ITN.msg | ||
Level2_FRN.msg | ||
Level2_ITN.msg | ||
Level3_FRN.msg | ||
Level3_ITN.msg | ||
Level4_FRN.msg | ||
Level4_ITN.msg | ||
Level5_FRN.msg | ||
Level5_ITN.msg | ||
Level6_FRN.msg | ||
Level6_Ger.msg | ||
Level6_ITN.msg | ||
Level6.cpp | ||
Level6.msg | ||
Level7_FRN.msg | ||
Level7_ITN.msg | ||
Level8_FRN.msg | ||
Level8_ITN.msg | ||
Level9_FRN.msg | ||
Level9_Ger.msg | ||
Level9_ITN.msg | ||
Level9.cpp | ||
Level9.msg | ||
Level10_FRN.msg | ||
Level10_ITN.msg | ||
Level11_FRN.msg | ||
Level11_ITN.msg | ||
Level12_FRN.msg | ||
Level12_Ger.msg | ||
Level12_ITN.msg | ||
Level12.cpp | ||
Level12.msg | ||
Level13_FRN.msg | ||
Level13_ITN.msg | ||
Level14_FRN.msg | ||
Level14_ITN.msg | ||
Level15_FRN.msg | ||
Level15_ITN.msg | ||
Level16.cpp | ||
Level16.msg | ||
LEVEL0.cpp | ||
LEVEL15_Ger.msg | ||
LEVEL15.cpp | ||
LEVEL15.msg | ||
levels1_SPN.msg | ||
levels2_SPN.msg | ||
levelS2_Ger.msg | ||
levelS2.cpp | ||
levelS2.msg | ||
LevelS1_Ger.msg | ||
LevelS1_ITN.msg | ||
LevelS1.cpp | ||
LevelS1.msg | ||
LevelS2_ITN.msg | ||
LEVELS1_FRN.msg | ||
LEVELS2_FRN.msg | ||
linux_lib.cpp | ||
linux_lib.h | ||
merc5.cpp | ||
merc5.msg | ||
Merc1.cpp | ||
Merc1.msg | ||
Merc3.cpp | ||
Merc3.msg | ||
Merc4.cpp | ||
Merc4.msg | ||
Merc6.cpp | ||
Merc6.msg | ||
Merc7.cpp | ||
Merc7.msg | ||
Merc02.cpp | ||
Merc02.msg | ||
MS-GAME.DEF | ||
MS-LVL.DEF | ||
myPowerHouse.cpp | ||
Mysterious_Isle.cpp | ||
Mysterious_Isle.msg | ||
orbital.cpp | ||
osiris_common.h | ||
osiris_import.h | ||
osiris_vector.h | ||
Paranoia.cpp | ||
paranoia.msg | ||
PiccuStation.cpp | ||
PINBALL.MSG | ||
Polaris_FRN.msg | ||
Polaris_Ger.msg | ||
Polaris_ITN.msg | ||
Polaris_SPN.msg | ||
Polaris.cpp | ||
Polaris.msg | ||
Quadsomniac_Ger.msg | ||
Quadsomniac.cpp | ||
Quadsomniac.msg | ||
RudeAwakening.cpp | ||
RudeAwakening.msg | ||
s.asm | ||
SewerRat.cpp | ||
SewerRat.msg | ||
testscript.cpp | ||
TrainingMission_FRN.msg | ||
TrainingMission_Ger.msg | ||
TrainingMission_ITN.msg | ||
TrainingMission_SPN.msg | ||
TrainingMission.cpp | ||
TrainingMission.msg | ||
Y2K.cpp | ||
Y2K.msg |