-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wxrc:
MakePackageCPP
: Faster&leaner compilation of C++ source code …
…generated by our resource compiler. In order for C++-compilation to run much faster and consume much less memory (in the presence of thousands of input resource files) (especially with g++-14, at least with optimization and debugging information i.e. `-O2 -g`) and for the resulting machine code to occupy less space (on disk and in memory), we avoid (via an intermediary function with parameters of type "pointers to arrays of characters") the generation of (thousands of pieces of) machine code which constructs and destructs `wxString` arguments (especially since (anyway) our arguments (in the generated C++ source code) are pointers to arrays of characters, not yet strings). (Details and benchmarks can be found in C++ comments in this commit.)
- Loading branch information
DoctorNoobingstoneIPresume
authored and
DoctorNoobingstoneIPresume
committed
Mar 27, 2024
1 parent
edd288e
commit 524b53d
Showing
2 changed files
with
128 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
set -e -o pipefail | ||
|
||
# Usage example: | ||
# | ||
# The following command line: | ||
# './GenerateBigXRCFile.sh' 2000 >'MyInputFileReferencingManyResources.xrc' | ||
# will generate an XRC file referencing 2000 small PNG images. | ||
# | ||
# Compiling this XRC file using `wxrc` and further compiling the generated C++ source code | ||
# can help us tune our code and avoid slow C++ compilation process | ||
# (when thousands of input resource files have been given as input). | ||
|
||
GenerateExampleImages () | ||
{ | ||
local folder_images='ExampleImages' | ||
mkdir -p "${folder_images}/" | ||
|
||
local i | ||
local n="${1:-10000}" | ||
|
||
printf '<?xml version="1.0" encoding="UTF-8"?>\n' | ||
printf '<resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">\n' | ||
for ((i = 0; i < n; ++i)); do | ||
local pathname_image; printf -v pathname_image "%s/Example_%04Xh.png" "${folder_images}" "$((i))" | ||
|
||
if ((1)); then | ||
rm -f "${pathname_image}" | ||
printf >>"${pathname_image}" "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52" | ||
printf >>"${pathname_image}" "\x00\x00\x00\x10\x00\x00\x00\x10\x08\x02\x00\x00\x00\x90\x91\x68" | ||
printf >>"${pathname_image}" "\x36\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0E\xC4\x00\x00\x0E" | ||
printf >>"${pathname_image}" "\xC4\x01\x95\x2B\x0E\x1B\x00\x00\x00\x1A\x49\x44\x41\x54\x28\xCF" | ||
printf >>"${pathname_image}" "\x63\x6C\x60\xF8\xCF\x40\x0A\x60\x62\x20\x11\x8C\x6A\x18\xD5\x30" | ||
printf >>"${pathname_image}" "\x74\x34\x00\x00\xC5\xBF\x01\x9F\x22\x91\xFF\xBD\x00\x00\x00\x00" | ||
printf >>"${pathname_image}" "\x49\x45\x4E\x44\xAE\x42\x60\x82" | ||
fi | ||
|
||
printf ' <object class="wxBitmap" name="Cat_%04Xh">%s</object>\n' "$((i))" "${pathname_image}" | ||
done | ||
printf '</resource>\n' | ||
} | ||
|
||
GenerateExampleImages "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters