Commit Graph

93 Commits

Author SHA1 Message Date
David Korth
3022868577 [pugixml] Disable functionality we don't need.
This reduces the size of pugixml.dll to within range of what
tinyxml-10.dll was in previous versions.

Size comparisons: (amd64 release build, with LTO, MSVC 2022 17.6.5)

tinyxml-10.dll in rom-properties 2.4.1: 105,472

pugixml.dll:
- With all enabled:     222,208
- Disable XPATH:        142,336
- + disable STL:        121,856
- + disable exceptions: 121,856

NOTE: Disabling exceptions doesn't seem to change the code size at all,
even if STL is left enabled.
2025-04-20 11:13:35 -04:00
David Korth
5d3ec38bce [minizip-ng] Don't install CMake or pkgconfig files, or header files.
[extlib] CMakeLists.txt: Set SKIP_INSTALL_HDR for MiniZip-ng, which for
some reason checks this variable instead of SKIP_INSTALL_HEADERS.
2025-04-20 02:09:19 -04:00
David Korth
74b0465ae1 [zlib-ng] CMakeLists.txt: Disable the various optimization options.
We're setting these using SET() in extlib/CMakeLists.txt, so having them
as actual options causes CMake to print a bunch of warnings like this:

CMake Warning (dev) at extlib/zlib-ng/CMakeLists.txt:133 (option):
  Policy CMP0077 is not set: option() honors normal variables.  Run "cmake
  --help-policy CMP0077" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  For compatibility with older versions of CMake, option is clearing the
  normal variable 'WITH_SSE2'.
This warning is for project developers.  Use -Wno-dev to suppress it.

[extlib] CMakeLists.txt: SET(WITH_VPCLMULQDQ ON)
2025-04-19 17:19:05 -04:00
David Korth
b18e8b2fcd [extlib] CMakeLists.txt: Define ZEXPORT=__declspec(dllexport) for MiniZip.
A change in 4.0.8 results in ZEXPORT defaulting to nothing, which breaks
dllexports in the Windows version (and results in no import library
being generated).

Define ZEXPORT=__declspec(dllexport) to have the same behavior as 4.0.7.
2025-04-07 20:51:48 -04:00
David Korth
4779ac6f75 [extlib] CMakeLists.txt: Add STRICT macros for MiniZip.
This ensures unzFile/zipFile are opaque types instead of just
typedefs of void*.
2025-04-07 19:16:41 -04:00
Cameron Cawley
e361e653bc Link internal libraries statically on Mac OS X 2025-04-03 11:01:51 +01:00
David Korth
95e1b19473 [extlib] Enable pugixml's built-in DLL postfix option.
pugixml uses "_d" instead of "d".

[pugixml] CMakeLists.txt: Disable options. The cmake_dependent_option()
setup for PUGIXML_USE_POSTFIX prevented the postfix from working because
the top-level source directory is not the same as PugiXML's directory.

[libwin32common] DelayLoadHelper: Handle PugiXML's "_d" postfix.

DelayLoadHelper.cmake has new variables for debug/release only DLLs,
which is used for PugiXML due to the different debug postfix.
2025-04-01 19:19:20 -04:00
David Korth
55f86d1158 Add an internal copy of PugiXML and remove TinyXML2 completely.
TODO:
- Add the 'd' postfix to the debug DLL.
- Configure PugiXML options and hide them from the user, since these are
  configured by rom-properties.
2025-04-01 19:19:20 -04:00
David Korth
5e4571f209 Renamed extlib/libfmt/ to extlib/fmt/.
It's called just "fmt" upstream (or "fmtlib").
2025-03-20 22:16:59 -04:00
David Korth
41b84eb333 [libfmt] Install the DLL in Windows builds. 2025-02-25 22:55:55 -05:00
David Korth
ce2c376276 [extlib] zlib-ng: Remove obsolete CMake options.
These no longer apply to zlib-ng.

WITH_UNALIGNED was removed in v2.2.3.
2025-02-18 18:08:22 -05:00
David Korth
b7f33dc203 [zlib-ng] chunkset_avx(2|512).c: Fix for chunkmemset_16() in MSVC 2015 Debug x86 builds.
Re-enable AVX2 on MSVC 2015.

References:
- https://github.com/zlib-ng/zlib-ng/issues/1861
- https://github.com/zlib-ng/zlib-ng/pull/1862
2025-02-02 22:53:41 -05:00
David Korth
8a69aecabd [extlib] CMakeLists.txt: Disable AVX2 and AVX512 for zlib-ng if using MSVC 2015 or earlier.
Reference: https://github.com/zlib-ng/zlib-ng/issues/1861
2025-02-02 19:12:24 -05:00
David Korth
b11f9fa4c2 [libfmt] Build as a DLL on Windows and Mac OS X.
This significantly reduces the total size. fmt-11.dll's Release build
size is 128 KiB, and it cuts between 16-64 KiB from binaries that use it.

Total size of EXEs and DLLs, with amiiboc.exe and libgnuintl-8.dll,
but without test executables or PDBs:
[MSVC 2022 v17.6.5, Release build]

- Total size of EXEs and DLLs with header-only: 4,332,032
- Total size of EXEs and DLLs with fmt-11.dll:  4,161,536
- Difference:                                    -170,496

With test executables:

- Total size of EXEs and DLLs with header-only: 9,716,224
- Total size of EXEs and DLLs with fmt-11.dll:  7,907,840
- Difference:                                  -1,808,384

TODO: Add Delay-Load checks for fmt-11.dll to e.g. rpcli and the
Win32 UI frontend. (amiiboc and unit tests don't need it.)
2025-01-23 00:36:34 -05:00
David Korth
4007754b77 [extlib] CMakeLists.txt: Don't set extlib properties on fmt-header-only.
CMake 3.16.2 on AppVeyor (Win32) shows this error:

CMake Error in extlib/libfmt/CMakeLists.txt:
  INTERFACE_LIBRARY targets may only have whitelisted properties.  The
  property "POSITION_INDEPENDENT_CODE" is not allowed.

CMake 3.31.0 on my Windows 7 VM didn't show this error...
2025-01-22 00:58:53 -05:00
David Korth
fa932de93f [libfmt] Add an internal copy of libfmt-11.1.2.
Currently used as a header-only build. Will eventually be changed to
build a DLL for Windows and Mac OS X.

Other changes needed to get the Windows version to build with libfmt:

Add #include <fmt/xchar.h> to some files for full wchar_t support
in libfmt. Otherwise, errors like this appear:

src\amiibo-data\amiiboc.cpp(175,8): error C2665: 'fmt::v11::print': no overloaded function could convert all the argument types
extlib\libfmt\include\fmt\base.h(2925,17): message : could be 'void fmt::v11::print<TCHAR*&>(FILE *,fmt::v11::fstring<TCHAR *&>,TCHAR *&)'
src\amiibo-data\amiiboc.cpp(175,8): message : 'void fmt::v11::print<TCHAR*&>(FILE *,fmt::v11::fstring<TCHAR *&>,TCHAR *&)': cannot convert argument 2 from 'wmain::<lambda_1>::()::FMT_COMPILE_STRING' to 'fmt::v11::fstring<TCHAR *&>'
src\amiibo-data\amiiboc.cpp(175,22): message : No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
extlib\libfmt\include\fmt\base.h(2908,17): message : or       'void fmt::v11::print<wmain::<lambda_1>::()::FMT_COMPILE_STRING,TCHAR*&>(fmt::v11::fstring<wmain::<lambda_1>::()::FMT_COMPILE_STRING,TCHAR *&>,wmain::<lambda_1>::()::FMT_COMPILE_STRING &&,TCHAR *&)'
src\amiibo-data\amiiboc.cpp(175,8): message : 'void fmt::v11::print<wmain::<lambda_1>::()::FMT_COMPILE_STRING,TCHAR*&>(fmt::v11::fstring<wmain::<lambda_1>::()::FMT_COMPILE_STRING,TCHAR *&>,wmain::<lambda_1>::()::FMT_COMPILE_STRING &&,TCHAR *&)': cannot convert argument 1 from 'FILE *' to 'fmt::v11::fstring<wmain::<lambda_1>::()::FMT_COMPILE_STRING,TCHAR *&>'
src\amiibo-data\amiiboc.cpp(175,14): message : No constructor could take the source type, or constructor overload resolution was ambiguous
src\amiibo-data\amiiboc.cpp(175,8): message : while trying to match the argument list '(FILE *, wmain::<lambda_1>::()::FMT_COMPILE_STRING, TCHAR *)' [build.vc17_64\src\amiibo-data\amiiboc.vcxproj]

Files modified for xchar.h:
- amiibo-data/amiiboc.cpp
- libromdata/stdafx.h (needed by WiiUPackage)
- libromdata/tests/RomHeaderTest.cpp

NOTE: Only included on Windows. xchar.h was added in libfmt-8.0.0,
which was first added (in Ubuntu LTS releases) in Ubuntu 20.04.
It's not needed on Linux, anyway.

New option USE_INTERNAL_FMT to force the use of the internal copy of
libfmt on Linux, for testing purposes. (...and also for Ubuntu 16.04)
- TODO: Maybe use it on 18.04, etc. for improved performance?
2025-01-21 23:59:20 -05:00
David Korth
fe163149b9 [googletest] Disable gtest_main and gmock_main.
The recent PIC changes for the internal TinyXML2 somehow broke compiling
gtest_main on Windows:

extlib\googletest\googletest\src\gtest_main.cc(48): error C2491: 'main':
    definition of dllimport function not allowed

Also disable gmock_main, since it depends on gtest_main.

We aren't actually using these, so it's not an issue.
(We implement our own main() in gtest_init.cpp.)

[extlib] CMakeLists.txt: Rename SET_EXTLIB_PROPERTIES_PIC() to
SET_EXTLIB_PROPERTIES_PIC_ONLY(), since SET_EXTLIB_PROPERTIES()
also sets POSITION_INDEPENDENT_CODE=TRUE.

Also use SET_EXTLIB_PROPERTIES_PIC_ONLY() for shared libraries that
may be installed, since we can't use SET_EXTLIB_PROPERTIES().
2025-01-11 12:30:51 -05:00
David Korth
b41b737c2c [extlib] CMakeLists.txt: Set POSITION_INDEPENDENT_CODE on all targets.
Adjusted SET_EXTLIB_PROPERTIES() to skip EXCLUDE_FROM_ALL if they're
being installed (i.e. SKIP_INSTALL_ALL is set when the function is
called).

This should fix a PIC issue when building the internal copy of
TinyXML2 on Linux, and possibly other libraries too:

/usr/bin/ld: lib/../extlib/tinyxml2/CMakeFiles/tinyxml2.dir/tinyxml2.cpp.o: warning: relocation against `stdout@@GLIBC_2.2.5' in read-only section `.text'
/usr/bin/ld: lib/../extlib/tinyxml2/CMakeFiles/tinyxml2.dir/tinyxml2.cpp.o: relocation R_X86_64_PC32 against symbol `stdout@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
2025-01-10 23:50:02 -05:00
David Korth
d470035e61 Switch to CMake's POSITION_INDEPENDENT_CODE property instead of manually adding "-fpic -fPIC".
Something changed that caused the build on Xubuntu 16.04 (32-bit) to fail:

[ 63%] Linking CXX shared library ../../lib/libromdata.so
/usr/bin/ld: read-only segment has dynamic IFUNC relocations; recompile with -fPIC
/usr/bin/ld: failed to set dynamic section sizes: Bad value
collect2: error: ld returned 1 exit status
src/libromdata/CMakeFiles/romdata.dir/build.make:3614: recipe for target 'lib/libromdata.so.6.0' failed
make[2]: *** [lib/libromdata.so.6.0] Error 1

Setting POSITION_INDEPENDENT_CODE instead of "-fpic -fPIC" fixes this.

[extlib] Correctly set properties on the 'mspack' target instead of
'libmspack'. Otherwise, libmspack won't have either EXCLUDE_FROM_ALL
or POSITION_INDEPENDENT_CODE.
2025-01-05 14:02:13 -05:00
David Korth
1f8bd87910 [minizip-ng] Fix MiniZip DLL packaging on Windows.
- Don't install binaries. minigzip and minizip aren't compiled by
  default, so attempting to install them will fail.

- Set SKIP_INSTALL_LIBRARIES to OFF when building DLLs.

- Disable installation of headers, import libraries, and .cmake files.

- Install PDB files.
2024-11-23 14:10:54 -05:00
David Korth
c99b4c0837 [minizip-ng] Build as a .dll on Windows.
Since we're now using MiniZip in the J2ME parser, it should be compiled
as a DLL instead of statically linked.

Disable zstd support. It's causing issues with DelayLoad, since we're not
loading zstd in the J2ME parser. I originally enabled this to potentially
improve compression for test cases, but I ended up using .tar.zst instead
of zstd-compressed .zip files.

[libwin32common] Add MiniZip DLL information.

[libromdata] J2ME: Add MiniZip delay-load handling.

[libromdata] GczReader: Improve delay-load handling a bit.
2024-11-23 13:51:23 -05:00
David Korth
6ff4efda18 [extlib] CMakeLists.txt: minigzip_cmd -> minigzip_cli; minizip_cmd -> minizip_cli
Without this renaming, these binaries are built automatically, even
though we don't need them most of the time.

With this renaming, they'll only be built if the user explicitly
specifies that they should be built.

This regressed when updating from minizip-ng v4.0.6 to v4.0.7 in
commit 3c90ea3d26.
2024-11-10 16:54:50 -05:00
David Korth
0fba585f24 [libpng] Update: v1.6.43 -> v1.6.44
[extlib] CMakeLists.txt: Set SKIP_INSTALL_CONFIG_FILE=ON.
New setting checked by the libpng-1.6.44 update.
2024-09-26 21:29:36 -04:00
David Korth
fc9e22799f [extlib] CMakeLists.txt: Update CMake options for zlib-ng 2.2.1. 2024-08-02 20:55:23 -04:00
David Korth
20d731aad7 [libpng] Update: v1.6.40 -> v1.6.42
[zlib-ng] Export zlib as ZLIB::ZLIB. This is needed by
libpng-1.6.42's CMakeLists.txt
2024-02-17 20:13:22 -05:00
David Korth
b4f2ad34e7 [minizip-ng] Update: v4.0.2 -> v4.0.4
[extlib] CMakeLists.txt: Set -DMZ_COMPAT_VERSION=120 so we get
the newer version of unzLocateFile().
2024-01-07 23:51:40 -05:00
David Korth
9c1db18574 Remove half-hearted support for Windows versions older than XP.
Windows 2000 support only partially worked in rp-config. The actual
shell extension component didn't work.

Support for ANSI Windows was mostly just compile-tested, and it was
becoming a burden to support something almost no one will use.

Removed most `#ifdef UNICODE` and `#ifdef _UNICODE` branches in
favor of using the Unicode path exclusively.

Removed oldwincompat, which was an attempt to get things working
properly on Windows 9x and 2000 with the MSVC 2010 runtime.
rom-properties doesn't compile with MSVC 2010 anymore, so this
probably wasn't very useful anyways.

Consolidated tstring macros in tcharx.h.

Removed GUID_fns.c since it was only useful in ANSI builds.
2023-07-31 21:32:47 -04:00
David Korth
dd87260759 [libpng] Update: v1.6.39 -> v1.6.40 2023-06-26 18:01:52 -04:00
David Korth
5086061436 [zlib-ng] Update: v2.0.7 -> v2.1.2
zlib-ng v2.1 has significant performance improvements compared to v2.0.
In particular, decompression can be up to 56% faster on amd64 when
using AVX2 instructions.

FIXME: RomHeaderTest infinite-loops on Xubuntu 16.04 32-bit with 1.5 GB
RAM due to memory allocation issues. microtar_zstd.c doesn't ever receive
an "out of memory" error...
2023-06-11 12:45:30 -04:00
David Korth
f3f7846988 [extlib] CMakeLists.txt: Set ZSTD_LIBRARY and ZSTD_LIBRARIES when using the internal copy of zstd. 2023-02-15 00:18:00 -05:00
David Korth
48b3d8530e [microtar] Initial import of MicroTAR, a small tar implementation.
This only implements tar v7, which has some limitations.
(maximum of 100 characters for filenames, etc.)

https://github.com/rxi/microtar
License: MIT
2023-02-13 20:05:21 -05:00
David Korth
e644206255 [uniwidth] Import of the uniwidth subset of gnulib.
uniwidth provides a uc_width() function, which is similar to wcwidth().
Our version removes the 'encoding' parameter, which isn't needed because
we're always using UTF-8.

Fixes #353: rpcli: bad table alignment on multibyte characters
Reported by @DankRank.
2022-08-28 18:47:34 -04:00
David Korth
554680989f [extlib] CMakeLists.txt: Set LZ4 bundled mode.
This should have been committed with the LZ4 v1.9.4 update,
but I forgot.
2022-08-26 00:50:04 -04:00
David Korth
1317a931d4 [librptexture] GodotSTEX: Initial implementation of ASTC 8x8 decoding.
Added the ASTC decoder from Basis Universal.

FIXME: The decoded images have swapped R and B channels.
2021-09-03 23:24:42 -04:00
David Korth
f2d6b4652d [lz4] Update: v1.9.2 -> v1.9.3 2021-03-22 01:18:02 -04:00
David Korth
c3f4db832c [zlib] Updated from v1.2.11 to zlib-ng v2.0.0-RC2.
https://github.com/zlib-ng/zlib-ng
2021-02-18 23:50:27 -05:00
David Korth
7d302b51c9 [minizip] Updated from v2.10.5 to minizip-ng 3.0.0.
As of 3.0.0, the minizip fork is now called minizip-ng.

https://github.com/zlib-ng/minizip-ng
2021-02-17 18:38:19 -05:00
David Korth
860288ab05 [minizip] Updated to v2.10.5 from the MiniZip fork.
https://github.com/nmoinvaz/minizip

NOTE: iconv support is disabled for now, since it isn't needed by any
of the test cases. It may be re-enabled later if minizip is needed for
the main program.
2020-12-19 11:25:05 -05:00
David Korth
777897befa [extlib] Make sure LZ4 and MiniLZO are installed in the Windows package.
Also install the .pdb file.
2020-09-20 14:55:13 -04:00
David Korth
13798dc609 Revert "Use a static library for LZ4 on Mac OS X."
This reverts commit 0bfdc891b5.

It *still* links to a shared library, even though I told it not to...
2020-09-07 12:22:04 -04:00
David Korth
0bfdc891b5 Use a static library for LZ4 on Mac OS X.
The unit tests aren't finidng the shared library.
2020-09-07 11:44:18 -04:00
David Korth
cdd88e2455 [rapidjson] Added rapidjson-1.1.0.
The JSON output code will be rewritten to use rapidjson, which will allow
us to add more stuff without having to worry if the resulting text has
the correct formatting.

This adds around 20 KB to the compiled binary.
2020-09-06 00:33:12 -04:00
David Korth
7b282f5d81 [minilzo] Added an internal copy of MiniLZO.
I chose MiniLZO instead of regular LZO because we only need to be able to
decompress LZO1X blocks.

[libromdata] CisoPspReader: Don't call lzo_init() if this JISO isn't
actually using LZO. Otherwise, if the DLL is missing on Windows, the
program will crash.
2020-09-05 11:05:12 -04:00
David Korth
ad476eb9a0 [lz4] Added a copy of lz4-1.9.2 for PSP CISO. 2020-09-05 02:32:50 -04:00
David Korth
0136021beb [extlib] CMakeLists.txt: Don't install zstd.dll right now.
We're not using zstd outside of the test suite, so we don't need to
install it.
2020-07-12 17:22:54 -04:00
David Korth
f8fdaa7ae8 Allow disabling ZSTD entirely using ENABLE_ZSTD.
Similar to ENABLE_XML.

Print ZSTD status in the build summary.
2020-06-27 03:09:19 -04:00
David Korth
dc587561b4 [zstd] Added zstd for use with MiniZip.
MiniZip 2.10.0 added support for zstd as a compression method, so we
should support it.

Note that a system version of zstd is preferred on Linux systems.

Enabled the MiniZip test tools for manual builds only. Info-ZIP hasn't
been updated in a while, so I'm going to use the MiniZip test tools to
compress ZIP archives using zstd.

Enabled MiniZip compression in order to compress stuff using the minizip
test program.

mz_strm_zstd.c: FIXME: Compression level doesn't work. Hard-coded the
maximum compression level for now.
2020-06-27 03:09:15 -04:00
David Korth
6e8c90b906 [oldwincompat] Added stubs for Windows 2000 (and maybe later Win9x) compatibility.
Stubbed functions for MSVC 2010-2017:
- InitializeSListHead()
- GetModuleHandleExW()
- EncodePointer()
- DecodePointer()
- SetFilePointerEx()

rpcli.exe now works, but rom-properties.dll fails to register.

CRT linkage is forced to static when enabling old Windows compatibility
on MSVC 2010 and later, since this is needed in order to get the CRT to
use the stub functions.

References:
- https://stackoverflow.com/questions/19516796/visual-studio-2012-win32-project-targeting-windows-2000/53548116
- https://stackoverflow.com/a/53548116

NOTE: NLS needs to be disabled; otherwise, gettext won't load due to
___mb_cur_max_func not being found in msvcrt.dll. This will require
a rebuild of gettext to use an older version.

Reference:
- https://docs.microsoft.com/en-us/cpp/c-runtime-library/mb-cur-max-func-mb-cur-max-l-func-p-mb-cur-max-mb-cur-max?view=vs-2019
2019-12-21 12:54:28 -05:00
David Korth
e51803a4fe [librptexture] Use the PowerVR Native SDK (well, a subset) to decode PVRTC.
It seems that the R and B channels are backwards, so we'll need to fix
that next. Other than that, both 2bpp and 4bpp decoding seems to work.
(A lot better than my terrible attempt, at least.)

[cmake] options.cmake: Added an option for PVRTC. The code is licensed
under the MIT license, but we might as well provide an option for it
because it's third-party code instead of my own code.

TODO:
- Fix R/B channel ordering.
- PVRTC-II decoding?
- Add PVRTC decoding to KTX and DDS.
2019-12-10 22:01:21 -05:00
David Korth
1e2d39d479 [extlib] CMakeLists.txt: Set MZ_SIGNING.
New option added by minizip-2.9.0.
2019-10-25 00:31:57 -04:00