Skip to content

Get every language preprocessor conditional into one library#378

Merged
majcosta merged 21 commits into
1dot13:masterfrom
majcosta:pr_remove_language_from_preprocessor
Dec 31, 2024
Merged

Get every language preprocessor conditional into one library#378
majcosta merged 21 commits into
1dot13:masterfrom
majcosta:pr_remove_language_from_preprocessor

Conversation

@majcosta
Copy link
Copy Markdown
Contributor

@majcosta majcosta commented Dec 24, 2024

cuts down compilation quite a bit, down to around ~2960 translation units from 17k to build everything

@majcosta majcosta force-pushed the pr_remove_language_from_preprocessor branch 3 times, most recently from 442dcdd to d135913 Compare December 24, 2024 11:38
@majcosta majcosta marked this pull request as draft December 24, 2024 13:07
@majcosta majcosta force-pushed the pr_remove_language_from_preprocessor branch from d135913 to 82dd4b2 Compare December 24, 2024 14:16
@majcosta majcosta marked this pull request as ready for review December 24, 2024 14:18
@majcosta majcosta marked this pull request as draft December 24, 2024 14:59
@majcosta majcosta force-pushed the pr_remove_language_from_preprocessor branch 7 times, most recently from b4e2100 to 196a4e0 Compare December 29, 2024 20:07
@majcosta majcosta changed the title begin extracting language flow from the preprocessor Get every language preprocessor conditional into one library Dec 29, 2024
@majcosta majcosta marked this pull request as ready for review December 29, 2024 20:09
@majcosta
Copy link
Copy Markdown
Contributor Author

probably better to merge rather than rebase this one

gather all ENGLISH|GERMAN|CHINESE etc preprocessor hell into a single
library, so to restrict the number of targets that need to be built 8x

this still has UB/EDITOR definitions so that still needs to be dealt
with before we can build it only 8 times
it has preprocessor silliness in it
this might cause a horrifying alignment bug, but I doubt it
eventually we'll switch between CHINESE and other languages during
runtime, so even if language is not chinese, these symbols must still
be there

these symbol names aren't used so this is fine
This one is big, but unless I missed something, should be all be
trivial.

scripted-diff with the following, then manually tweaked whatever needed:
```

if [ $# -ne 3 ]; then
    echo "Usage: $0 '<pattern>' '<replacement>' '<filename>'"
    exit 1
fi

pattern="$1"
replacement="$2"
filename="$3"

if [ ! -f "$filename" ]; then
    echo "Error: File $filename does not exist."
    exit 1
fi

sed -i '/'"$pattern"'/ {
    :loop
    $ !{
        N
        /'"$pattern"'.*\n.*#endif/ {
            s/'"$pattern"'/'"$replacement"'/
            s/#else/} else {/
            s/#endif/}/
            P
            D
        }
        /'"$pattern"'/ b loop
    }
}' "$filename"

echo "Replacement complete in $filename"
```

h/t to Grok2 for the sed command
A bit clunkier, had to repeat function calls because of how
preprocessor tricks don't map 1:1 with actual C++.
It's where all conditional language preprocessor goes
Never use relative paths for #includes. Didn't touch the rest because
out of scope.
This function is just for GERMAN but it has a unique name so it's no
problem.

Had to slightly change how MercID gets populated
@majcosta majcosta force-pushed the pr_remove_language_from_preprocessor branch from 196a4e0 to 9fd8c3f Compare December 31, 2024 19:29
Language is now just built once per app (still some JA2UB conditionals
going on in there) but building everything should now take eight times
less work
@majcosta majcosta force-pushed the pr_remove_language_from_preprocessor branch from 9fd8c3f to 959c294 Compare December 31, 2024 21:25
@majcosta majcosta merged commit 3e76e95 into 1dot13:master Dec 31, 2024
@majcosta majcosta deleted the pr_remove_language_from_preprocessor branch December 31, 2024 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant