Compare commits

...

174 Commits

Author SHA1 Message Date
Fabrice de Gans
e7cea4fc0e Disable dialog position save/restore on wxGTK
This is currently broken on Wayland, resulting in dialogs showing up in
random locations.
2024-09-07 13:40:25 -07:00
Rafael Kitover
5d7023a5d6 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-07 18:00:22 +00:00
Rafael Kitover
3bd7c918cc build: fix cmake -DTAG_RELEASE functionality
Update the cmake -DTAG_RELEASE script to work with recent cmake changes.

Change it to not automatically make the release commit and tag, instead
specifying in the instructions that the person making the release must
edit the CHANGELOG.md and then run the commands, given in the
instructions, to make the release commit and tag.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-07 06:30:14 +00:00
Rafael Kitover
67e4944cdb translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-01 10:00:23 +00:00
Rafael Kitover
df4ff16e2c translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-01 09:00:24 +00:00
Rafael Kitover
d4805065b3 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-31 14:00:23 +00:00
Rafael Kitover
e39b1f2c53 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-28 01:00:24 +00:00
Rafael Kitover
73b65a6553 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-28 00:00:23 +00:00
Rafael Kitover
9e556e6a56 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-21 14:00:34 +00:00
Rafael Kitover
11e73f2c61 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-21 13:00:24 +00:00
Rafael Kitover
e97b0448b7 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-20 17:00:22 +00:00
Fabrice de Gans
aa6ed14b2a [FAudio] Always convert UTF-16 names (#1328)
On Windows, wchar_t is 16 bits and represents UTF-16 code units.
However, on other platforms, wchar_t is typically implemented as 32 bits
to represent UTF-32 code units. In order to work around this problem, we
always convert the string we get from FAudio, which is represented as
UTF-16 code units, into UTF-8 and let wxString handle the conversion to
its native type internally.
2024-08-17 21:02:01 -07:00
Rafael Kitover
2ce20c4f59 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-16 06:00:25 +00:00
Fabrice de Gans
e4ef4aa625 Propagate key events (#1323)
Previously, `wxEVT_KEY_DOWN` and `wxEVT_KEY_UP` were transformed into
`VBAM_EVT_USER_INPUT` and marked as processed early. This broke a number
of controls that rely on the traditional widgets events.

To fix this, we now filter the `wxEVT_KEY_*` and `wxEVT_CHAR` events in
the only widget we use that cares about them, `UserInputCtrl` instead of
filtering them at the application level.
2024-07-28 15:19:19 -07:00
Rafael Kitover
cf5cb40cb9 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-26 09:00:24 +00:00
Rafael Kitover
c450d14311 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-26 08:00:24 +00:00
Rafael Kitover
41572be3f2 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-24 11:00:23 +00:00
Rafael Kitover
4f8da1c574 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-24 09:00:24 +00:00
Rafael Kitover
32091669d4 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-23 12:00:29 +00:00
Rafael Kitover
abd72a5b2e translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-23 02:00:23 +00:00
Rafael Kitover
7e6349b19f translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-22 13:00:22 +00:00
Rafael Kitover
0782be749e translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-22 12:00:24 +00:00
Rafael Kitover
a7b545ab1a translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-15 03:00:22 +00:00
Rafael Kitover
1a564f900c translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-13 10:00:25 +00:00
Rafael Kitover
3d4e03f85f translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-08 12:00:23 +00:00
Rafael Kitover
fc17209ac7 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-06 05:00:23 +00:00
Rafael Kitover
38877ef209 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-05 21:00:24 +00:00
Rafael Kitover
8691a15be8 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-05 20:00:32 +00:00
Rafael Kitover
961fd0304c translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-05 20:00:15 +00:00
Rafael Kitover
e2cf6ecba6 Add option to mute sound during speedup
Add core option to mute sound during speedup, implemented in the gba
core. Link the option to the SDL port as well.

Add the new Mute Sound option as a checkbox to the xrc for the
Speedup/Turbo dialog and improve the dialog appearance.

Fix the max values for the options speedup_throttle and
speedup_frame_skip.

Add base class for numeric OptionProxy types implementing the +=, -=
operators, increment/decrement operators and operator T(). Add tests for
these operators on numeric types.

Move Speedup/Turbo dialog code from guiinit.cpp to a dialog class and
rewrite it using validators.

Remove the "GL VIEWPORT" debug prints from panel.cpp.

Fix #865

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-05 12:14:58 -07:00
Avindra Goolcharan
7a0826a60c Migrate vba-m.com links in .github folder 2024-06-21 18:02:38 -04:00
Rafael Kitover
d516683a77 build: fix for wx using GTK2
Use the __WXGTK3__ macro to check for GTK3 when setting the gdk backend
to X11 when Wayland EGL is not available, GTK2 does not have this
function and always uses X11 anyway.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-06-14 11:10:00 +00:00
Rafael Kitover
834c7de86c build: update macOS builder dists
Update sdl2, faudio, wxWidgets and ffmpeg to the latest versions for the
macOS builder.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-06-06 05:32:51 +00:00
Fabrice de Gans
4f1a5dd726 [Test] Add tests for widgets code
This creates a vbam-wx-widgets target for the custom widgets code and
adds tests for them.
2024-05-29 19:30:35 -07:00
Rafael Kitover
5766b9b9c7 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-27 10:00:25 +00:00
Rafael Kitover
5d8426d317 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-27 09:00:26 +00:00
Rafael Kitover
63ec3528f1 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-26 07:00:24 +00:00
Fabrice de Gans
f646c3848c [Test] Change assert to custom CHECK macros
This changes the way we handle asserts to use a set of custom macros.
This greatly speeds up crashing, especially on Windows, and provides
assertions in release mode too.
2024-05-21 18:47:50 +00:00
Fabrice de Gans
09433875bc [CI] Remove workaround for MSVC CI
Upstream GitHub actions now uses a single toolchain version.
Fixes #1297
2024-05-19 16:14:22 -07:00
Fabrice de Gans
05c09ff506 [Build] Add devkitpro-based libretro targets to CI 2024-05-10 13:36:05 -07:00
Rafael Kitover
7f78fbb3c5 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-10 03:00:24 +00:00
Rafael Kitover
261e26f488 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-10 02:00:25 +00:00
Rafael Kitover
ed820708af translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-10 01:00:27 +00:00
Fabrice de Gans
5b8b6a0b47 [Test] Add tests for the EmulatedGamepad class 2024-05-09 17:48:48 -07:00
Fabrice de Gans
8809ce26b3 [Test] Add tests for the Bindings class
In addition to fixing a couple of minor bugs, this also creates some
utility functions to access the cmdtab data.

Finally, this disables tests on MSYS2 as they can be flaky.
2024-05-09 13:15:16 -07:00
Fabrice de Gans
a48625855b [Build] Share wx-related targets configuration
Breaking the main wx target down to multiple libraries had the side
effect that many build options were not properly applied to libraries.
This fixes the issue by having a common configuration function in CMake
to share most of the configuration between all of the wx-related
targets.
2024-05-09 12:28:05 -07:00
Rafael Kitover
55c1477d69 build: disable FAudio for 32 bit Windows builds
Disable FAudio for 32 bit Windows builds because it uses libraries that
Windows XP does not have.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-09 02:34:25 +00:00
Rafael Kitover
2d7a1ea25b build: fix faudio linkage regression on MSVC+vcpkg
Followup on 244149c0 (build: fix faudio static linkage, 2024-05-09)
which broke linking faudio on MSVC+vcpkg, go back to using the
FAudio::FAudio cmake target for MSVC.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-09 01:38:44 +00:00
Rafael Kitover
244149c00e build: fix faudio static linkage
Use "faudio" and dependent dlls on Windows instead of the FAudio::FAudio
cmake target, because the cmake target always links the faudio dll.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-09 01:25:05 +00:00
Fabrice de Gans
c0bcf3bfdf [Test] Add tests for many config classes
This also fixes a coupld of minor issues that were found while adding
tests.
2024-05-08 13:08:07 -07:00
Fabrice de Gans
13756bcbf9 [Test] Replace doctest with googletest
* Convert the only existing test (strutils) to googletest.
* Create a test target for vbam-wx-config.
* Add necessary fakes for the test binary.
* Add tests to CI.
2024-05-08 13:00:56 -07:00
Rafael Kitover
fc82e06270 build: do not build SDL bin on Windows or macOS
Stop enabling the SDL binary by default on Windows or macOS because it
usually only of interest to Linux users.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-08 12:53:52 +00:00
Rafael Kitover
df89beb256 build: disable gpg signatures by default
Add the GPG_SIGNATURES cmake option to control creating gpg clearsign
signatures for the translations and exe zips for UPSTREAM_RELEASE,
defaulting to OFF.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-07 02:59:17 +00:00
Rafael Kitover
82eda48e8f translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-06 06:00:30 +00:00
Rafael Kitover
b47787b317 translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-06 06:00:12 +00:00
Fabrice de Gans
c9668d9a88 [config] Create the vbam-wx-config target
Circular dependencies between the config sub-module and the rest of the
wx frontend have been removed. This change separates the config code to
its own submodule.

This is a preliminary change to improve testing coverage.
2024-05-05 22:57:47 -07:00
Fabrice de Gans
90a56c6937 [config] Move strutils to src/config/
This removes circular dependencies between the main wx target and the
config/ sub-directory.
2024-05-05 21:38:14 -07:00
Fabrice de Gans
d377f7abff [CI] Install only one MSVC toolchain
A change in GitHub Actions broke our MSVC build flow due to different
toolchains being used at different steps of the build process. While the
upstream issue will eventually be fixed, we need to explicitly specify
the toolchain version for now.

Bug: #1297
2024-05-05 14:54:58 -07:00
Rafael Kitover
1fac129746 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-05 15:00:20 +00:00
Rafael Kitover
af7d5f7b89 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-05 14:00:21 +00:00
Rafael Kitover
28f7c2010b translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-05 10:00:20 +00:00
Rafael Kitover
486330f23d Activate GitHub Sponsors
Add .github/FUNDING.yml with my username to activate GitHub Sponsors for
this repository.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-05 01:27:11 +00:00
Rafael Kitover
1ae78a04a8 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-05 00:00:26 +00:00
Rafael Kitover
c776da7120 translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-05 00:00:08 +00:00
Fabrice de Gans
d543784a3d [UserInput] Filter key events globally
This changes key events to be filtered globally by the application,
preventing any widget from accessing them. Widgets should instead use
the new VBAM_USER_INPUT_EVENT event.

In addition, this explicitly removes accelerator handling from wxWidgets
main menu, allowing us to populate joystick options in the menu without
firing wxWidgets assertions.
2024-05-04 16:07:25 -07:00
Fabrice de Gans
902c6c8e4b [UserInput] Only process shortcut commands once
This modifies the UserInputEvent class to fire a vector of events at
once, rather than individual down/up events for each UserInput. This
simplifies handling of the global event filter and prevents the firing
of spurious events.

This also fixes a bug when pressing "Ctrl+1" would trigger the command
for both the command assigned to "Ctrl+1" and to "1". Now, only the
"Ctrl+1" command will fire.
2024-05-04 13:38:43 -07:00
Fabrice de Gans
d32be9ddbe Move cmdtab and command enable flags to config/
* Moves cmdtab to config/. This removes the dependency on the wxvbam.h
  header from the config/ directory.
* Fixes a number of issues in the shortcuts configuration window:
  * The "Remove" command was not working properly due to an incorrect
    refactor.
  * The window is now fully expandable.
2024-05-04 10:44:06 -07:00
Fabrice de Gans
b776509287 [bindings] Set default shortcut for recent file 3
This was lost in translation between 2 refactors.
2024-05-03 17:30:51 -07:00
Rafael Kitover
56eb97c846 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-29 13:00:23 +00:00
Rafael Kitover
9f46c575fd translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-29 10:00:21 +00:00
Rafael Kitover
e0402a9b0b translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-28 20:00:23 +00:00
Rafael Kitover
3e30f54d5f translations: fix strings starting with lowercase
Fix translated strings that start with lowercase to start with
uppercase.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-28 19:16:26 +00:00
Rafael Kitover
d73085a88c translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-25 08:00:21 +00:00
Rafael Kitover
8eb6a6900f translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-25 04:00:20 +00:00
Rafael Kitover
3615137c12 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-24 19:00:20 +00:00
Rafael Kitover
bbd5b76f2a translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-24 02:00:25 +00:00
Rafael Kitover
bb3604f333 translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-24 02:00:07 +00:00
Fabrice de Gans
18a0067ca7 [Input] Unify command handling
This unifies command handling between game and shortcut commands. Both
types of commands are now handled in a common manner and the binding
configuration is shared. In particular, this prevents assigning the same
user input (joypad or keyboard) to a game command or a shortcut command.

Bug: #745
2024-04-23 18:02:25 -07:00
Fabrice de Gans
cfdbdc4ec2 [Input] Move input configuration objects to app
Previously, some input-related configuration objects were either owned
by `gopts` or global values. This moves these objects to be owned by the
app object instead.

Rather than directly accessing the app object, other objects (like
dialogs) that need to access the input-related configuration objects are
passed a `ConfigurationObjectProvider` function. This will make it
easier to test these objects independently down the line.

Bug: #745
2024-04-23 15:38:39 -07:00
Rafael Kitover
32ca2ae42f translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-23 22:00:25 +00:00
Rafael Kitover
bad96cf91e translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-23 22:00:07 +00:00
Fabrice de Gans
62294702e4 [Input] Remove transitional key, mod, joy triplet
Originally, UserInput was built around the key, mod, joy triplet values
to maintain compatibility with other parts of the code base that made
use of these values. Since the UserInput class was introduced, all use
cases have been transitioned off these values in favor of treating the
UserInput as an abstract input.

UserInput is now a simple wrapper around either a KeyboardInput or a
JoyInput structure that only contain data pertinent to their input type.

This concludes the transition to the UserInput type.

Bug: #745
2024-04-23 14:26:59 -07:00
Rafael Kitover
72c4f33d63 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-23 19:00:27 +00:00
Rafael Kitover
3fe57f540d translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-23 19:00:07 +00:00
Fabrice de Gans
1e1a369c8d [Input] Unify UserInput event handling
This adds a custom UserInputEvent for handling joypad and keyboard input
for both accelerators and emulator control configuration.

These changes fix a number of issues with the wxWidgets implementation
of key down / up event handling. In particular, every "down" event now
has a corresponding "up" event. All of the special handling that was
done in multiple places to handle shortcuts is now done in a new class,
`UserInputEventSender`, simplifying multiple call sites.

This is another step towards complete unification of UserInput handling,
which will prevent double assignment between shortcuts and emulator
controls.

Bug: #745
2024-04-23 11:30:20 -07:00
Squall Leonhart
cc65ef2849 doc: add system requirements to README.md
Add system requirements and a link to the DirectX redist for Windows to
the README.md.
2024-04-18 09:13:39 +00:00
Fabrice de Gans
32627f6b85 [Dialogs] Save and restore dialog positions
This changes most dialogs in the wx frontend to use a common base
abstraction, `dialogs::BaseDialog`. This base class sets up common
style options for every dialog and automatically saves and restores the
dialog position.

In addition, this moves the first time show position of the dialog to be
slightly to the bottom and right of the main window, even if the main
window is on a screen other than the main screen.
2024-04-18 09:02:08 +00:00
Rafael Kitover
41952d0625 build: update macOS linker tool to 1.5
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-18 08:02:51 +00:00
Rafael Kitover
0c39a5ba7a build: override FindGettext to not update po files
Copy the cmake 3.28.3 FindGettext.cmake to cmake/ and comment out the
line that updates the po file from the pot. Because we download po files
from transifex we don't want this.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-16 22:12:46 +00:00
Rafael Kitover
1b77d6594c build: update macOS build to ffmpeg 7.0
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-16 16:59:28 +00:00
Rafael Kitover
8d08223dbc build: fix compatibility with older ffmpeg
Check LIBAVCODEC_VERSION_MAJOR and use the older channel_layout API if
it's below 60.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-16 16:19:12 +00:00
Rafael Kitover
af6028a9dd build: fix build for nix on macOS
Add the NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM env var to the macOS CI as
faudio has not been marked compatible with macOS yet.

Remove FindGettext.cmake as it is a core cmake module that is available
in the versions of cmake we support now.

Add support for nix to MacPackageManagers.cmake and add brew gettext to
CMAKE_IGNORE_PATH when not using brew. Also update the cmake style.

Add faudio, libintl and the System framework to buildInputs in
default.nix.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-16 15:30:30 +00:00
Rafael Kitover
ff3b5ee042 build: update mac link tool to 1.4
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-16 02:13:37 +00:00
Rafael Kitover
b52edf52ff build: fix building on macOS with Homebrew
Move setting up the environment for macOS Homebrew earlier in
Options.cmake, as well as finding pkgconfig.

Update gcc/clang toolchain to not pass a gcc-specific option to clang.

Add faudio to list of brew packages to get in installdeps.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-15 23:30:34 +00:00
Rafael Kitover
6766b9ca54 build: fix ffmpeg 7.x compat
Update from the channels/channel_layout API to the new ch_layout API,
assume two channel stereo always.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-15 23:28:56 +00:00
Rafael Kitover
8eae2e5b90 build: add FAudio to nix deps
Add faudio to nix dependencies for both macOS and Linux.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-14 10:15:54 +00:00
Rafael Kitover
50d17363ea build: fail finding FAudio silently
Change the find_package() call for FAudio to QUIET to not show a giant
warning when it's not available.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-14 10:09:37 +00:00
Rafael Kitover
795f25bb85 build: fix nix deps for OpenGL
Change Linux nix dependencies in default.nix for OpenGL from mesa to
libGL and libGLU, also fixing the compile error for the SDL binary.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-14 10:06:54 +00:00
Ruben
647be137f6 gba: set cpsr=spsr when switching to FIQ mode
The CPSR register needs to be restored from SPSR when switching modes.
This is currently being done for all mode switches /except/ for FIQ,
which is very likely just an oversight rather than intended behaviour.

This fixes the random crashing in OpenLara, as well as fixing random
glitching of my own project that uses FIQ mode switches. The issue
happens "at random" because it requires an interrupt to occur while in
FIQ mode, and it must also fire inside a section of code that relies on
the status flags (or the CPSR register in general): When exiting the
interrupt exception, the CPSR register is supposed to be restored from
SPSR, but this isn't being done when switching from IRQ mode back to FIQ
mode, which results in CPSR (and thus the status flags) being corrupted.
For example, SUBS r0, #1; [interrupt]; BNE 1b would trigger the bug, but
[interrupt]; SUBS r0, #1; BNE 1b wouldn't, and neither would
SUBS r0,#1; BNE 1b; [interrupt].
2024-04-12 15:49:45 +00:00
Rafael Kitover
8abe3e79da build: remove -lgcc from static link flags
Remove -lgcc from static link flags for gcc/clang, clang does not
support this and -static-libgcc is enough.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-12 15:44:27 +00:00
Rafael Kitover
710ffeb1b2 build: update mac build
Update dists for gettext and gsed to get around new compile errors from
clang.

Update SDL and ffmpeg and add FAudio.

Make some other minor adjustments for recent changes.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-10 22:52:35 +00:00
Rafael Kitover
a855ff54f4 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-10 16:00:21 +00:00
Rafael Kitover
dbb5e534e4 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-10 00:00:21 +00:00
Rafael Kitover
753956963c translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-09 07:00:21 +00:00
Rafael Kitover
b00e23f5b5 build: enable FAudio on non-Windows
Enable FAudio on non-Windows too if the cmake support is found.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-08 04:02:48 +00:00
Fabrice de Gans
8ef9a66b74 [FAudio] Switch to portable condition_variable
This removes remaining dependencies on Windows in the FAudio code by
removing the device notification code and switching to portable
`condition_variable` for the buffer end notification event.
2024-04-07 16:33:22 -07:00
Rafael Kitover
0e503a525e translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-07 11:00:30 +00:00
Rafael Kitover
b4b020401c translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-07 11:00:07 +00:00
Fabrice de Gans
f4835674ed [Audio] Rework audio devices enumeration
This moves all of the audio code in the wx frontend to the
`src/wx/audio` folder and simplifies many call sites by having one
generic API to enumerate audio devices and create the audio driver.

In addition, this fixes many corner cases in device enumerations and
moves handling of the default device to the respective audio backends,
rather than pushing it to the UI.

Finally, this changes the `Sound/AudioDevice` setting to use the
underlying device ID, rather than the user-facing name.
2024-04-07 03:51:39 -07:00
Rafael Kitover
4104a3d179 build: fix codesigning Windows bins with signtool
Pass `/fd certHash /td certHash` to signtool as they are required
arguments.

signtool comes with Visual Studio and now works and we don't need to
require osslsigncode anymore.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-06 23:45:14 +00:00
Rafael Kitover
1e1ec2e330 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-06 18:00:20 +00:00
Rafael Kitover
ff21f8da21 build: enable FAudio sound driver on Windows
Enable FAudio on Windows if cmake can find it.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-06 11:22:20 +00:00
Rafael Kitover
775a571f75 build: fix detecting Visual Studio default vcpkg
Make the regular expression against VCPKG_ROOT less specific for
detecting the default Visual Studio vcpkg, for some reason it stopped
working.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-06 11:09:34 +00:00
Fabrice de Gans
64abd3e8dc [Audio] Remove manual memory allocations
* Remove explicit calls to new or malloc in favor of owned objects.
* Move AudioSdl to the sdl frontend, it is no longer used by the wx
  frontend.
2024-04-06 03:42:33 -07:00
Rafael Kitover
56320ec6d1 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-06 08:00:20 +00:00
Zach Bacon
311b232ee5 FAudio: Implement and have functional FAudio output
Corrected the current FAudio output code, FAudio api wasn't
a direct 1 for 1 code replacement. Adjusted the existing
code structure so that FAudioVoiceCallBack struct
was being properly called on.

Signed-off-by: Zach Bacon <zachbacon@vba-m.com>
2024-04-05 15:37:39 -07:00
Rafael Kitover
0e13cc9346 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-05 02:00:21 +00:00
Rafael Kitover
b455de01c6 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-04 22:00:27 +00:00
Rafael Kitover
c3053d3819 translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-04 22:00:08 +00:00
Fabrice de Gans
c8106573d8 [Dialogs] Move SoundConfig dialog to its own class
This fixes a number of issues with the current implementation. Namely,
some options were not properly saved and the audio driver was not
properly reloaded when some options were changed.
In addition, this moves most sound-related options to `g_owned_opts` and
simplifies many call sites.
2024-04-04 14:22:23 -07:00
Fabrice de Gans
047ad27777 [Dialogs] Prevent viewers from causing a crash
Some of the viewers dialogs were not properly set up and were causing a
crash at runtime.
2024-04-04 12:10:44 -07:00
Rafael Kitover
ecd16a21dc translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-03 14:00:25 +00:00
Rafael Kitover
1594fda1b6 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-03 13:00:22 +00:00
Rafael Kitover
de9b3a211b translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-03 12:00:22 +00:00
Rafael Kitover
045c98d8fa build: only use -Werror=lto-type-mismatch on gcc
Only pass -Werror=lto-type-mismatch to gcc, clang does not have this
option and throws a warning.

Also quote some barewords in if() statements.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-03 10:30:04 +00:00
Fabrice de Gans
4ace296b3a [Build] Improve the TRANSLATIONS_ONLY build speed
* Move CMake dependencies checkout to `cmake/Dependencies.cmake`.
* Disable most dependencies checkout from the `TRANSLATIONS_ONLY` build.
* Remove the debug/translations_only GitHub Action.
2024-04-02 11:56:19 -07:00
Rafael Kitover
011adce23e translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-02 17:00:21 +00:00
Rafael Kitover
cc99ec0c14 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-02 13:00:37 +00:00
Rafael Kitover
1d652edf83 translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-02 13:00:07 +00:00
Fabrice de Gans
db08ca93af [Build] Improve CI build coverage
This reworks the CI coverage to add `TRANSLATIONS_ONLY=ON` and libretro
builds to GitHub Actions.
2024-04-01 23:28:20 -07:00
Rafael Kitover
3518dc6a05 build: fix LTO on Linux
Add -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing to
compile and link options for gcc/clang always.

Rename struct yy_buffer_state in src/sdl/expr-lex.cpp to struct
yy_buffer_state_sdl because it breaks when linking the SDL binary with
-Werror=odr.

Fix #1260

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-01 21:40:35 -07:00
Rafael Kitover
cc9a03ce48 Add toggle: SDL GameController mode for joysticks
Add a toggle for SDL GameController Mode in the game key configuration
dialog, default enabled.

On check or uncheck, change the option and reinitialize joysticks, not
using GameController mode if it is disabled.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-01 21:21:53 -07:00
Fabrice de Gans
8576733c0d [Build] Remove lingering references to OpenAl
OpenAl is now required to build.
2024-04-01 21:14:51 -07:00
Rafael Kitover
c6da7e384e build: add faudio to list of optional vcpkg deps
Add faudio to list of optional vcpkg deps linked to ENABLE_FAUDIO.

This codepath is not used right now as we are using binary packages.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-01 14:17:48 +00:00
Rafael Kitover
98abb8c2e8 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-31 02:00:22 +00:00
Rafael Kitover
0556192238 build: fix MSYS2 check
Fix cmake logic for detecting MSYS2 "$ENV{MSYSTEM_PREFIX}".

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-31 01:16:36 +00:00
Rafael Kitover
d9432ebb14 build: fix build on MINGW{64,32}/UCRT64 on MSYS2
Pass -Wno-deprecated-copy only for C++, gcc gives a warning for C.

Pass -Wno-unused-command-line-argument for clang only, gcc gives a
warning about it.

Add a failsafe for gcc/clang static link flags if libstdc++ or
libpthread is not available as a static library.

Move link command adjustment script invocations to src/wx, the target is
not yet defined in the toolchain.

Add -lws2_32 to the end of the link command for gcc on Windows because
of link order issues with those symbols.

Disable LTO for gcc on Windows, as it is broken.

Don't install extra-cmake-modules on MINGW32, that package is not
available there.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-30 20:14:32 +00:00
Rafael Kitover
f57cad67c4 build: fix static linking on MSYS2 CLANG64
Bring back setting the MSYS variable under MSYS2, it's still being used
in a few places.

Link the SDL2::SDL2-static target for static builds.

Add -static-libgcc and -static-libstdc++ to the gcc/clang toolchain for
static builds.

Edit wxWidgets_LIBRARIES under MSYS2 to specify liblzma.a explicitly
because for some reason it's not being linked statically by default for
static builds.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-30 18:06:25 +00:00
Rafael Kitover
ce7cc4e223 build: add FAudio to MSYS2 deps
In preparation for FAudio support, add the dependency to ./installdeps
for MSYS2 toolchains.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-30 17:37:20 +00:00
Rafael Kitover
8183a005af translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-29 02:00:21 +00:00
Rafael Kitover
75a34cd098 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-28 02:00:21 +00:00
Rafael Kitover
23e1573442 build: set wxWidgets_DIR with vcpkg
When using vcpkg as the toolchain, pass NO_DEFAULT_PATH to
find_package(wxWidgets ...) so that the default cmake
FindwxWidgets.cmake is not included.

Set wxWidgets_DIR to the
<vcpkg-root>/installed/<triplet>/share/wxwidgets vcpkg port directory
for the subsequent find_package() calls to find the port-installed
wxWidgetsConfig.cmake file.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-27 03:02:33 +00:00
Fabrice de Gans
98b51910eb [Build] Remove ENABLE_NLS, fix TRANSLATIONS_ONLY
* Remove the ENABLE_NLS option, it is now always enabled.
* Fix the TRANSLATIONS_ONLY build to properly build the zip file.
2024-03-26 17:38:12 -07:00
Rafael Kitover
c3f0aa2edf translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-26 22:18:10 +00:00
Rafael Kitover
ea596e4cb0 translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-26 22:17:52 +00:00
Fabrice de Gans
68adb14b07 [Build] Use Toolchain-gcc-clang for non-MSVC
Apple compiler ID is defined as `AppleClang`. Rather than explicitly
adding every single compiler ID, this changes the build to try to apply
settings for GCC for every non-MSVC-like compilers.
2024-03-18 17:12:51 -07:00
Fabrice de Gans
a565cea8e9 [Build] Remove the OpenGL check
This is no longer necessary with modern CMake.
2024-03-18 23:56:22 +00:00
Fabrice de Gans
6ac95d373f [Build] Rework wx/CMakeLists.txt
* Bring the wx frontend more in-line with the rest of the codebase.
* Always default to Unicode APIs on Windows.
* Clean up all include guards and headers.
2024-03-18 23:56:22 +00:00
Fabrice de Gans
d4430ca440 [Build] Move SDL build configuration to sdl/
* Clean up SDL includes and include guards.
* Add the sdl target to `sdl/CMakeLists.txt`.
2024-03-17 14:41:07 -07:00
Fabrice de Gans
000c7f854c [Build] Move non-core common code to components/
* Create multiple components library. These depend on the core code and
  are used by multiple frontends.
* Clean up the filters declaration by moving them to a common header in
  `components/filters/filters.h`.
* Clean up the include guards and include orders.
* Fix the modified paths in `src/debian/copyright` to match their new
  location.
2024-03-16 17:32:09 -07:00
Fabrice de Gans
047bd935ea [Build] Move the core emulator to src/core/
* Move src/apu/, src/gb/ and src/gba/ to src/core/.
* Clean up include guards and headers.
* Rename `BKPT_SUPPORT` to `VBAM_ENABLE_DEBUGGER` and remove the
  `NO_DEBUGGER` define.
2024-03-16 14:35:36 -07:00
Fabrice de Gans
33cb9a66d4 [Build] Move System.h and most of Util.h to core/
* Move System.h to core/base.
* Move most of the functionality out of Util.h to core/base.
* Fix corresponding headers.
2024-03-15 20:43:57 -07:00
Fabrice de Gans
f8374b52a8 [Build] Move more of src/common to src/core/base
* Clean out all of the dependent headers.
* Modify generated version.h to improve the dependency chain and isolate
  the generated file to its own sub-directory within the build
  directory.
2024-03-15 19:51:52 -07:00
Fabrice de Gans
2f10e71f1d [Build] Cleanup files in src/common
* Remove unused files.
* Move files used only by the SDL frontend to the sdl folder.
* Remove contains.h in favor of manual iterator parsing.
2024-03-15 17:05:16 -07:00
Fabrice de Gans
8f92d99968 [Build] Move file-related utilities to core/base
* Remove duplicate function definitions between the libretro and other
  frontends by merging them into a common source file.
* Also move `systemMessage()` and message IDs definitions to core/base.
* Clean up and modernize many file utility methods.
2024-03-15 16:04:45 -07:00
Fabrice de Gans
ce12db1e06 [Build] Move fex/ to src/core/fex/
* Clean up source set and public headers.
* Make the fex library an OBJECT library to speed up build.
* Clean up the only fex include to use the full path to the header.
2024-03-15 12:16:40 -07:00
Fabrice de Gans
d8a1886ccb [Build] Use new way of setting /Z flag with MSVC
CMake 3.25 introduced the CMAKE_MSVC_DEBUG_INFORMATION_FORMAT to set the
/Z flag for MSVC toolchains. Use it rather than modifying the compile
options if possible. We revert to setting the compile options manually
if the CMake version is too old.
2024-03-15 11:32:38 -07:00
Fabrice de Gans
1d051d0e6e [Build] Make powershell optional on non-Windows (#1248)
Fixes: #1247
2024-03-15 11:32:24 -07:00
Fabrice de Gans
f96e42fe04 build: cmake refactor and improvements
* Use add_compile_definitions everywhere.
* Remove unused intermediate target.
* Add ASAN support for MSVC.
* Remove duplicate option definitions.
* Configure MinGW separately from the toolchain
2024-03-15 16:19:01 +00:00
Fabrice de Gans
aa59d94490 [Build] Add toolchain-specific files (#1244)
* Move toolchain-specific options to their own files.
* Clean up and modernize the use of toolchain options.
* Use modern cmake LTO support.
* Remove dead cmake code and cmake functions available in upstream cmake.
* Update README.md to remove references to removed build options.
2024-03-13 11:13:55 -07:00
Fabrice de Gans
07e490254c Fix most remaining release warnings (#1243)
Bug: #1003
2024-03-11 18:56:01 -07:00
Fabrice de Gans
18b97b4342 Fix various build warnings (#1242)
* Mass-rename some global variables with clangd
* Fix various int conversion issues

Bug: #1003
2024-03-11 16:47:45 -07:00
Rafael Kitover
b45a4066b1 ci: add clang+bintools for macOS, disable LTO
Add llvmPackages_latest.clang and bintools to the macOS part of
default.nix for nix, because for some reason the `ar` utility is not
found in GitHub actions right now.

Disable LTO for the macOS action for now, this is a consequence of
recent cmake refactoring and needs to be fixed.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-11 08:53:47 +00:00
Fabrice de Gans
1fff5cb1f7 Move build options to their own file
This moves all build options to their own file to clean up the main
CMakeLists.txt. In addition, this upgrades the minimum required CMake
version and changes the build to use CMAKE_MSVC_RUNTIME_LIBRARY rather
than hardcoding the MSVC ABI flag.
2024-03-11 01:38:25 +00:00
Fabrice de Gans
13a16eb79c Fix various warnings in filters and headers (#1241)
Bug: #1003
2024-03-10 17:33:11 -07:00
Fabrice de Gans
69769c1bef [CI] Use proper POWERSHELL variable casing
The POWERSHELL cmake variable was sometimes used lowercase.
2024-03-10 16:24:02 -07:00
Fabrice de Gans
e998a4016a [CI] Properly inclue SDL2 directories for vbamcore (#1240)
The variable name should have been changed to SDL2_INCLUDE_DIRS
2024-03-10 16:14:52 -07:00
Fabrice de Gans
f17a9855f3 [CI] Look for pwsh in addition to powerhsell (#1239)
Newer github actions bot setup no longer include a powershell.exe
binary, only pwsh.exe
2024-03-10 15:58:25 -07:00
Rafael Kitover
85b7cf7aec translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-10 02:00:30 +00:00
Rafael Kitover
f46da1c525 build: remove our version of FindSDL2.cmake
SDL2 now comes with a cmake find_package() module, so we will use it
instead of this one that came from someone's github a decade ago.

Keep the fixup for libsamplerate with vcpkg and move it into the main
cmake code.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-08 23:41:26 +00:00
Rafael Kitover
404e9a1a55 build: add clang to ./installdeps for MSYS2
Add clang when installing for CLANG* environments in MSYS2 because this
package is no longer included by default in the set of packages we
install.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-08 23:13:32 +00:00
Rafael Kitover
3ec8960f1a translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-08 02:00:29 +00:00
Weiran Wu
613bd4038a Make menu more reasonably organized (#1230)
* Make menu more reasonably organized
* Revert name and order change of configs

---------

Co-authored-by: wuweiran <wwrnfls@126.com>
2024-03-06 18:25:42 -08:00
Rafael Kitover
ecb69a240a build: add pthreads w/vcpkg, link FAudio target
In preparation for including the finished FAudio support, link the cmake
FAudio target FAudio::FAudio when the feature is enabled.

Add pthreads to vcpkg deps and use the installed PThreads4W on Windows.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-06 21:58:43 +00:00
511 changed files with 71193 additions and 64232 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1 @@
github: rkitover

View File

@@ -11,7 +11,7 @@ body:
- type: markdown
attributes:
value: |
Please try the nightly build from: https://nightly.vba-m.com and factory resetting the emulator from the Help menu.
Please try the nightly build from: https://nightly.visualboyadvance-m.org and factory resetting the emulator from the Help menu.
On Linux build master from source or use the edge snap.
And last but not least, search for existing reports via the filters bar on the issues page.
- type: markdown

View File

@@ -1,7 +1,7 @@
blank_issues_enabled: false
contact_links:
- name: VBA-M Forum
url: https://board.vba-m.com/
url: https://board.visualboyadvance-m.org/
about: For general questions and support please join our forum or our
- name: VBA-M IRC Channel
url: https://web.libera.chat/#vba-m

View File

@@ -14,7 +14,7 @@ body:
- type: markdown
attributes:
value: |
Please try a nightly build from: https://nightly.vba-m.com to see if your idea has already been implemented.
Please try a nightly build from: https://nightly.visualboyadvance-m.org to see if your idea has already been implemented.
On Linux build master from source or use the edge snap.
And last but not least, search for existing requests via the filters bar on the issues page.
- type: textarea

33
.github/workflows/devkitpro-build.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
name: Libretro Devkitpro
on: [push, pull_request]
jobs:
build:
strategy:
matrix:
target_name: [ngc, wii, wiiu, switch]
build_type: [release, debug]
include:
- libretro_build: 'DEBUG=0'
build_type: release
- libretro_build: 'DEBUG=1'
build_type: debug
- devkit_container: 'devkitpro/devkitppc:latest'
target_name: ngc
- devkit_container: 'devkitpro/devkitppc:latest'
target_name: wii
- devkit_container: 'devkitpro/devkitppc:latest'
target_name: wiiu
- devkit_container: 'devkitpro/devkita64:latest'
target_name: switch
runs-on: ubuntu-latest
container: ${{ matrix.devkit_container }}
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
submodules: recursive
# Libretro build
- name: Build libretro core
run: make -C src/libretro ${{ matrix.libretro_build }} platform=${{ matrix.target_name }}

View File

@@ -1,27 +1,63 @@
name: macOS Latest Build
name: macOS Latest
on: [push, pull_request]
#on: workflow_dispatch
jobs:
build:
strategy:
matrix:
cmake_build: ['-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_BUILD_TYPE=Debug']
cmake_options: ['', '-DENABLE_LINK=OFF', '-DENABLE_SDL=ON']
build_type: [release, debug]
build_options: [default, link_off, translations_only, libretro]
include:
- cmake_build: '-DCMAKE_BUILD_TYPE=Release'
build_type: release
- cmake_build: '-DCMAKE_BUILD_TYPE=Debug'
build_type: debug
- cmake_options: '-DENABLE_LINK=OFF'
build_options: link_off
- cmake_options: '-DTRANSLATIONS_ONLY=ON'
build_options: translations_only
- libretro_build: 'DEBUG=0'
build_type: release
build_options: libretro
- libretro_build: 'DEBUG=1'
build_type: debug
build_options: libretro
exclude:
# Exclude debug/translations_only build
- build_type: debug
build_options: translations_only
runs-on: macos-latest
env:
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM: 1
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install nix
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Configure
# Cmake build
- if: matrix.build_options != 'libretro'
name: Configure CMake
run: >-
nix-shell --command 'cmake -B build -G Ninja ${{ matrix.cmake_build }} ${{ matrix.cmake_options }}'
- name: Build
nix-shell --command 'cmake -B build -G Ninja ${{ matrix.cmake_build }} -DENABLE_LTO=OFF ${{ matrix.cmake_options }}'
- if: matrix.build_options != 'libretro'
name: Build
run: >-
nix-shell --command 'ninja -C build'
# Libretro build
- if: matrix.build_options == 'libretro'
name: Build libretro core
run: >-
nix-shell --command 'make -C src/libretro ${{ matrix.libretro_build }}'
# Run tests
- if: matrix.build_options == 'default'
name: Run tests
run: >-
nix-shell --command 'cd build && ctest -j --output-on-failure'

View File

@@ -1,12 +1,31 @@
name: MSYS2 Build
name: MSYS2
on: [push, pull_request]
jobs:
build:
strategy:
matrix:
cmake_build: ['-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_BUILD_TYPE=Debug']
cmake_options: ['', '-DENABLE_LINK=OFF', '-DENABLE_SDL=ON']
build_type: [release, debug]
build_options: [default, link_off, translations_only, libretro]
include:
- cmake_build: '-DCMAKE_BUILD_TYPE=Release'
build_type: release
- cmake_build: '-DCMAKE_BUILD_TYPE=Debug'
build_type: debug
- cmake_options: '-DENABLE_LINK=OFF'
build_options: link_off
- cmake_options: '-DTRANSLATIONS_ONLY=ON'
build_options: translations_only
- libretro_build: 'DEBUG=0'
build_type: release
build_options: libretro
- libretro_build: 'DEBUG=1'
build_type: debug
build_options: libretro
exclude:
# Exclude debug/translations_only build
- build_type: debug
build_options: translations_only
runs-on: windows-latest
env:
MSYSTEM: CLANG64
@@ -16,7 +35,7 @@ jobs:
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup msys2
@@ -27,11 +46,19 @@ jobs:
- name: Install deps
run: >-
bash installdeps
- name: Configure
run: >-
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug ${{ matrix.cmake_build }} ${{ matrix.cmake_options }}
- name: Build
run: ninja -C build
- name: Install
# CMake build
- if: matrix.build_options != 'libretro'
name: Configure CMake
run: cmake -B build -G Ninja ${{ matrix.cmake_build }} -DENABLE_LTO=OFF ${{ matrix.cmake_options }}
- if: matrix.build_options != 'libretro'
name: Build
run: ninja -C build
- if: matrix.build_options != 'libretro'
name: Install
run: ninja -C build install
# Libretro build
- if: matrix.build_options == 'libretro'
name: Build libretro core
run: make -C src/libretro ${{ matrix.libretro_build }} CC=clang CXX=clang++

View File

@@ -1,30 +1,71 @@
name: Ubuntu Latest Build
name: Ubuntu Latest
on: [push, pull_request]
jobs:
build:
strategy:
matrix:
cmake_compiler: ['-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++', '-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++']
cmake_build: ['-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_BUILD_TYPE=Debug']
cmake_options: ['', '-DENABLE_LINK=OFF', '-DENABLE_SDL=ON']
build_compiler: [gcc, clang]
build_type: [release, debug]
build_options: [default, link_off, translations_only, libretro]
include:
- cmake_compiler: '-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++'
build_compiler: gcc
- cmake_compiler: '-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++'
build_compiler: clang
- cmake_build: '-DCMAKE_BUILD_TYPE=Release'
build_type: release
- cmake_build: '-DCMAKE_BUILD_TYPE=Debug'
build_type: debug
- cmake_options: '-DENABLE_LINK=OFF'
build_options: link_off
- cmake_options: '-DTRANSLATIONS_ONLY=ON'
build_options: translations_only
- libretro_build: 'DEBUG=0'
build_type: release
build_options: libretro
- libretro_build: 'DEBUG=1'
build_type: debug
build_options: libretro
exclude:
# Exclude debug/translations_only build
- build_type: debug
build_options: translations_only
- build_type: release
build_options: translations_only
build_compiler: clang
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Dependencies
run: >-
bash installdeps; if [ "${{ matrix.compiler }}" = clang ]; then sudo apt -y install clang; fi
bash installdeps; if [ "${{ matrix.build_compiler }}" = clang ]; then sudo apt -y install clang; fi
- name: Configure
- name: Install xvfb
run: sudo apt -y install xvfb
# CMake build
- if: matrix.build_options != 'libretro'
name: Configure CMake
run: >-
cmake -B build -G Ninja ${{ matrix.cmake_compiler }} ${{ matrix.cmake_build }} ${{ matrix.cmake_options }}
- name: Build
- if: matrix.build_options != 'libretro'
name: Build
run: ninja -C build
- name: Install
- if: matrix.build_options != 'libretro'
name: Install
run: sudo ninja -C build install
# Libretro build
- if: matrix.build_options == 'libretro'
name: Build libretro core
run: make -C src/libretro ${{ matrix.libretro_build }}
# Run tests
- if: matrix.build_options == 'default'
name: Run tests
run: cd build && xvfb-run ctest -j --output-on-failure

View File

@@ -1,36 +1,60 @@
name: Visual Studio Build
name: Visual Studio
on: [push, pull_request]
jobs:
build:
strategy:
matrix:
msvc_arch: ['x64', 'x64_x86']
msvc_arch: ['x64', 'amd64_x86', 'amd64_arm64']
# TODO: Re-add "Visual Studio 17 2022" once it's working.
cmake_generator: ['Ninja']
# cmake_generator: ['Ninja', '"Visual Studio 17 2022"']
cmake_build: ['-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_BUILD_TYPE=Debug']
cmake_options: ['', '-DENABLE_LINK=OFF', '-DENABLE_SDL=ON']
build_type: [release, debug]
build_options: [default, link_off, translations_only]
include:
- cmake_build: '-DCMAKE_BUILD_TYPE=Release'
build_type: release
- cmake_build: '-DCMAKE_BUILD_TYPE=Debug'
build_type: debug
- cmake_options: '-DENABLE_LINK=OFF'
build_options: link_off
- cmake_options: '-DTRANSLATIONS_ONLY=ON'
build_options: translations_only
- cmake_vcpkg_triplet: 'x64-windows-static'
msvc_arch: x64
- cmake_vcpkg_triplet: 'x86-windows-static'
msvc_arch: amd64_x86
- cmake_vcpkg_triplet: 'arm64-windows-static'
msvc_arch: amd64_arm64
exclude:
# Exclude debug/translations_only build
- build_type: debug
build_options: translations_only
- build_type: release
build_options: translations_only
msvc_arch: amd64_x86
- build_type: release
build_options: translations_only
msvc_arch: amd64_arm64
runs-on: windows-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
- name: Prepare Visual Studio environment
uses: ilammy/msvc-dev-cmd@v1.12.0
uses: ilammy/msvc-dev-cmd@v1.13.0
with:
arch: ${{ matrix.msvc_arch }}
- name: Configure (x64)
if: matrix.msvc_arch == 'x64'
- name: Configure
run: >-
cmake -B build -G ${{ matrix.cmake_generator }} -DVCPKG_TARGET_TRIPLET=x64-windows-static ${{ matrix.cmake_build }} ${{ matrix.cmake_options }}
- name: Configure (x86)
if: matrix.msvc_arch == 'x64_x86'
run: >-
cmake -B build -G ${{ matrix.cmake_generator }} -DVCPKG_TARGET_TRIPLET=x86-windows-static ${{ matrix.cmake_build }} ${{ matrix.cmake_options }}
cmake -B build -G ${{ matrix.cmake_generator }} -DVCPKG_TARGET_TRIPLET=${{ matrix.cmake_vcpkg_triplet }} ${{ matrix.cmake_build }} ${{ matrix.cmake_options }}
- name: Build
run: cmake --build build
# Run tests
- if: matrix.build_options == 'default' && matrix.msvc_arch != 'amd64_arm64'
name: Run tests
run: cd build && ctest -j --output-on-failure

File diff suppressed because it is too large Load Diff

View File

@@ -3,11 +3,11 @@
- [Visual Boy Advance - M](#visual-boy-advance---m)
- [System Requirements](#system-requirements)
- [Building](#building)
- [Building a Libretro core](#building-a-libretro-core)
- [Visual Studio Support](#visual-studio-support)
- [Visual Studio Code Support](#visual-studio-code-support)
- [Optional: clangd](#optional-clangd)
- [Dependencies](#dependencies)
- [Cross compiling for 32 bit on a 64 bit host](#cross-compiling-for-32-bit-on-a-64-bit-host)
- [Cross Compiling for Win32](#cross-compiling-for-win32)
@@ -57,6 +57,17 @@ the `translations.zip` to the same directory as the executable.
If you are having issues, try resetting the config file first, go to `Help ->
Factory Reset`.
## System Requirements
Windows 7, 8.1 or 10/11, Linux distro's or macOS.
2Ghz x86(or x86-64) Intel Core 2 or AMD Athlon processor with SSE, Snapdragon 835
or newer cpu compatible with Arm for Windows.
- Just a guideline, lower clock speeds and Celeron processors may be able to run at full
speed on lower settings, and Linux based ARM Operating systems have wider cpu support.
DirectX June 2010 Redist [Full](https://www.microsoft.com/en-au/download/details.aspx?id=8109) / [Websetup](https://www.microsoft.com/en-au/download/details.aspx?id=35) for Xaudio (Remember to uncheck Bing on the websetup)
## Building
The basic formula to build vba-m is:
@@ -149,7 +160,7 @@ And the following development libraries:
- [zlib](https://zlib.net/) (required)
- [mesa](https://mesa3d.org/) (if using X11 or any OpenGL otherwise)
- [ffmpeg](https://ffmpeg.org/) (optional, at least version `4.0.4`, for game recording)
- [gettext](https://www.gnu.org/software/gettext/) and gettext-tools (optional, with ENABLE_NLS)
- [gettext](https://www.gnu.org/software/gettext/) and gettext-tools
- [SDL2](https://www.libsdl.org/) (required)
- [SFML](https://www.sfml-dev.org/) (optional, for link)
- [OpenAL](https://www.openal.org/) or [openal-soft](https://kcat.strangesoft.net/openal.html) (required, a sound interface)
@@ -206,7 +217,6 @@ Here is the complete list:
| ENABLE_SDL | Build the SDL port | OFF |
| ENABLE_WX | Build the wxWidgets port | ON |
| ENABLE_DEBUGGER | Enable the debugger | ON |
| ENABLE_NLS | Enable translations | ON |
| ENABLE_ASM_CORE | Enable x86 ASM CPU cores (**BUGGY AND DANGEROUS**) | OFF |
| ENABLE_ASM | Enable the following two ASM options | ON for 32 bit builds |
| ENABLE_ASM_SCALERS | Enable x86 ASM graphic filters | ON for 32 bit builds |
@@ -219,8 +229,6 @@ Here is the complete list:
| ENABLE_GBA_LOGGING | Enable extended GBA logging | ON |
| ENABLE_DIRECT3D | Direct3D rendering for wxWidgets (Windows, **NOT IMPLEMENTED!!!**) | ON |
| ENABLE_XAUDIO2 | Enable xaudio2 sound output for wxWidgets (Windows only) | ON |
| ENABLE_OPENAL | Enable OpenAL for the wxWidgets port | AUTO |
| ENABLE_SSP | Enable gcc stack protector support (gcc only) | OFF |
| ENABLE_ASAN | Enable libasan sanitizers (by default address, only in debug mode) | OFF |
| UPSTREAM_RELEASE | Do some release tasks, like codesigning, making zip and gpg sigs. | OFF |
| BUILD_TESTING | Build the tests and enable ctest support. | ON |
@@ -228,9 +236,7 @@ Here is the complete list:
| SDL2_STATIC | Try to link static SDL2 libraries | OFF |
| SFML_STATIC_LIBRARIES | Try to link static SFML libraries | OFF |
| FFMPEG_STATIC | Try to link static ffmpeg libraries | OFF |
| SSP_STATIC | Try to link static gcc stack protector library (gcc only) | OFF except Win32 |
| OPENAL_STATIC | Try to link static OpenAL libraries | OFF |
| SSP_STATIC | Link gcc stack protecter libssp statically (gcc, with ENABLE_SSP) | OFF |
| TRANSLATIONS_ONLY | Build only the translations.zip and nothing else | OFF |
Note for distro packagers, we use the CMake module

View File

@@ -21,3 +21,32 @@ linkage:
short: Shared
long: Create shared libraries/DLLs
linkage: shared
useLink:
default: withlink
choices:
withlink:
short: WithLink
long: Enable the Link feature
settings:
ENABLE_LINK: ON
nolink:
short: NoLink
long: Disable the Link feature
settings:
ENABLE_LINK: OFF
useDebugger:
default: withdebugger
choices:
withdebugger:
short: WithDebugger
long: Enable the Debugger feature
settings:
ENABLE_DEBUGGER: ON
nodebugger:
short: NoDebugger
long: Disable the Debugger feature
settings:
ENABLE_DEBUGGER: OFF
ENABLE_SDL: OFF

View File

@@ -1,3 +1,7 @@
if(TRANSLATIONS_ONLY)
return()
endif()
if(NOT CMAKE_SYSTEM_PROCESSOR)
if(NOT CMAKE_TOOLCHAIN_FILE AND CMAKE_HOST_SYSTEM_PROCESSOR)
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
@@ -63,3 +67,8 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "[aA][aA][rR][cC][hH]|[aA][rR][mM]")
set(CMAKE_CROSSCOMPILING TRUE)
endif()
endif()
# We do not support amd64 asm yet
if(X86_64 AND (ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS OR ENABLE_MMX))
message(FATAL_ERROR "The options ASM_CORE, ASM_SCALERS and MMX are not supported on X86_64 yet.")
endif()

View File

@@ -1,54 +0,0 @@
#=============================================================================
# Copyright 2010 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# support for the nasm assembler
set(CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS nasm asm)
if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT)
if(WIN32)
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
SET(CMAKE_ASM_NASM_OBJECT_FORMAT win64)
else()
SET(CMAKE_ASM_NASM_OBJECT_FORMAT win32)
endif()
elseif(APPLE)
EXECUTE_PROCESS(COMMAND ${CMAKE_ASM_NASM_COMPILER} -v COMMAND awk "{print \$3}" OUTPUT_VARIABLE NASM_VERSION)
IF(NASM_VERSION VERSION_LESS 2.0)
IF(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
MESSAGE(FATAL_ERROR "Your nasm is too old to support AMD64, please install nasm from Homebrew or MacPorts.")
ENDIF()
SET(CMAKE_ASM_NAMS_OBJECT_FORMAT macho)
ELSE()
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
SET(CMAKE_ASM_NASM_OBJECT_FORMAT macho64)
else()
SET(CMAKE_ASM_NASM_OBJECT_FORMAT macho32)
endif()
ENDIF()
else()
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
SET(CMAKE_ASM_NASM_OBJECT_FORMAT elf64)
else()
SET(CMAKE_ASM_NASM_OBJECT_FORMAT elf32)
endif()
endif()
endif()
set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <DEFINES> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>")
# Load the generic ASMInformation file:
set(ASM_DIALECT "_NASM")
include(CMakeASMInformation)
set(ASM_DIALECT)

View File

@@ -1,27 +0,0 @@
#=============================================================================
# Copyright 2010 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# Find the nasm assembler. yasm (http://www.tortall.net/projects/yasm/) is nasm compatible
SET(CMAKE_ASM_NASM_COMPILER_INIT nasm yasm)
IF(NOT CMAKE_ASM_NASM_COMPILER)
FIND_PROGRAM(CMAKE_ASM_NASM_COMPILER nasm
"$ENV{ProgramFiles}/NASM")
ENDIF(NOT CMAKE_ASM_NASM_COMPILER)
# Load the generic DetermineASM compiler file with the DIALECT set properly:
SET(ASM_DIALECT "_NASM")
INCLUDE(CMakeDetermineASMCompiler)
SET(ASM_DIALECT)

View File

@@ -1,23 +0,0 @@
#=============================================================================
# Copyright 2010 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# This file is used by EnableLanguage in cmGlobalGenerator to
# determine that the selected ASM_NASM "compiler" works.
# For assembler this can only check whether the compiler has been found,
# because otherwise there would have to be a separate assembler source file
# for each assembler on every architecture.
SET(ASM_DIALECT "_NASM")
INCLUDE(CMakeTestASMCompiler)
SET(ASM_DIALECT)

122
cmake/Dependencies.cmake Normal file
View File

@@ -0,0 +1,122 @@
if(TRANSLATIONS_ONLY)
return()
endif()
# Look for some dependencies using CMake scripts
find_package(ZLIB REQUIRED)
set(OpenGL_GL_PREFERENCE GLVND)
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
set(OpenGL_GL_PREFERENCE LEGACY)
endif()
find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED)
# Add libsamplerate to SDL2 with vcpkg
unset(SDL2_LIBRARY_TEMP)
if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
if(WIN32)
unset(arch_suffix)
unset(path_prefix)
if(VCPKG_TARGET_TRIPLET MATCHES -static)
set(arch_suffix -static)
endif()
if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
set(path_prefix debug)
endif()
set(installed_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix}/${path_prefix})
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${installed_prefix}/lib/samplerate.lib)
else()
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} -lsamplerate)
endif()
endif()
if(VBAM_STATIC)
set(VBAM_SDL2_LIBS SDL2::SDL2-static ${SDL2_LIBRARY_TEMP})
else()
set(VBAM_SDL2_LIBS SDL2::SDL2 ${SDL2_LIBRARY_TEMP})
endif()
if(ENABLE_FFMPEG)
if(NOT FFMPEG_LIBRARIES)
message(FATAL_ERROR "ENABLE_FFMPEG was specified, but required versions of ffmpeg libraries cannot be found!")
endif()
if(APPLE)
list(APPEND FFMPEG_LDFLAGS "SHELL:-framework CoreText" "SHELL:-framework ApplicationServices")
if(UPSTREAM_RELEASE)
list(APPEND FFMPEG_LDFLAGS -lbz2 -ltiff "SHELL:-framework DiskArbitration" -lfreetype -lfontconfig -llzma -lxml2 -lharfbuzz)
endif()
elseif(WIN32)
set(WIN32_MEDIA_FOUNDATION_LIBS dxva2 evr mf mfplat mfplay mfreadwrite mfuuid amstrmid)
list(APPEND FFMPEG_LIBRARIES secur32 bcrypt ${WIN32_MEDIA_FOUNDATION_LIBS})
if(MSYS AND VBAM_STATIC)
foreach(lib tiff jbig lzma)
cygpath(lib "$ENV{MSYSTEM_PREFIX}/lib/lib${lib}.a")
list(APPEND FFMPEG_LIBRARIES "${lib}")
endforeach()
endif()
endif()
else()
add_compile_definitions(NO_FFMPEG)
endif()
if(ENABLE_LINK)
# IPC linking code needs sem_timedwait which can be either in librt or pthreads
if(NOT WIN32)
find_library(RT_LIB rt)
if(RT_LIB)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${RT_LIB})
set(VBAMCORE_LIBS ${VBAMCORE_LIBS} ${RT_LIB})
endif()
endif()
include(CheckFunctionExists)
check_function_exists(sem_timedwait SEM_TIMEDWAIT)
if(SEM_TIMEDWAIT)
add_compile_definitions(HAVE_SEM_TIMEDWAIT)
endif()
else()
add_compile_definitions(NO_LINK)
endif()
# for now, only GBALink.cpp uses gettext() directly
if(APPLE)
# use Homebrew gettext if available
if(EXISTS "/usr/local/opt/gettext")
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH};/usr/local/opt/gettext/include")
set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};/usr/local/opt/gettext/lib")
set(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};/usr/local/opt/gettext/bin")
endif()
endif()
if(ENABLE_LINK OR ENABLE_WX)
find_path(LIBINTL_INC libintl.h)
find_library(LIBINTL_LIB NAMES libintl intl)
find_library(LIBICONV_LIB NAMES libiconv iconv)
find_library(LIBCHARSET_LIB NAMES libcharset charset)
if(LIBINTL_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBINTL_LIB})
list(APPEND NLS_LIBS ${LIBINTL_LIB})
endif()
if(LIBICONV_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBICONV_LIB})
list(APPEND NLS_LIBS ${LIBICONV_LIB})
endif()
if(LIBCHARSET_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBCHARSET_LIB})
list(APPEND NLS_LIBS ${LIBCHARSET_LIB})
endif()
include(CheckFunctionExists)
check_function_exists(gettext GETTEXT_FN)
if(NOT (LIBINTL_INC OR GETTEXT_FN))
message(FATAL_ERROR "NLS requires libintl/gettext")
endif()
endif()

View File

@@ -1,231 +1,232 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.rst:
# FindGettext
# -----------
#
# Find GNU gettext tools
#
# This module looks for the GNU gettext tools. This module defines the
# following values:
#
# ::
#
# GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool.
# GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool.
# GETTEXT_FOUND: True if gettext has been found.
# GETTEXT_VERSION_STRING: the version of gettext found (since CMake 2.8.8)
#
#
#
# Additionally it provides the following macros:
#
# GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN )
#
# ::
#
# This will create a target "translations" which will convert the
# given input po files into the binary output mo file. If the
# ALL option is used, the translations will also be created when
# building the default target.
#
# GETTEXT_PROCESS_POT_FILE( <potfile> [ALL] [INSTALL_DESTINATION <destdir>]
# LANGUAGES <lang1> <lang2> ... )
#
# ::
#
# Process the given pot file to mo files.
# If INSTALL_DESTINATION is given then automatically install rules will
# be created, the language subdirectory will be taken into account
# (by default use share/locale/).
# If ALL is specified, the pot file is processed when building the all traget.
# It creates a custom target "potfile".
#
# GETTEXT_PROCESS_PO_FILES( <lang> [ALL] [INSTALL_DESTINATION <dir>]
# PO_FILES <po1> <po2> ... )
#
# ::
#
# Process the given po files to mo files for the given language.
# If INSTALL_DESTINATION is given then automatically install rules will
# be created, the language subdirectory will be taken into account
# (by default use share/locale/).
# If ALL is specified, the po files are processed when building the all traget.
# It creates a custom target "pofiles".
#
# .. note::
# If you wish to use the Gettext library (libintl), use :module:`FindIntl`.
#[=======================================================================[.rst:
FindGettext
-----------
Find GNU gettext tools
This module looks for the GNU gettext tools. This module defines the
following values:
::
GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool.
GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool.
GETTEXT_FOUND: True if gettext has been found.
GETTEXT_VERSION_STRING: the version of gettext found (since CMake 2.8.8)
Additionally it provides the following macros:
GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN )
::
This will create a target "translations" which will convert the
given input po files into the binary output mo file. If the
ALL option is used, the translations will also be created when
building the default target.
GETTEXT_PROCESS_POT_FILE( <potfile> [ALL] [INSTALL_DESTINATION <destdir>]
LANGUAGES <lang1> <lang2> ... )
::
Process the given pot file to mo files.
If INSTALL_DESTINATION is given then automatically install rules will
be created, the language subdirectory will be taken into account
(by default use share/locale/).
If ALL is specified, the pot file is processed when building the all target.
It creates a custom target "potfile".
GETTEXT_PROCESS_PO_FILES( <lang> [ALL] [INSTALL_DESTINATION <dir>]
PO_FILES <po1> <po2> ... )
::
Process the given po files to mo files for the given language.
If INSTALL_DESTINATION is given then automatically install rules will
be created, the language subdirectory will be taken into account
(by default use share/locale/).
If ALL is specified, the po files are processed when building the all target.
It creates a custom target "pofiles".
.. versionadded:: 3.2
If you wish to use the Gettext library (libintl), use :module:`FindIntl`.
#]=======================================================================]
find_program(GETTEXT_MSGMERGE_EXECUTABLE msgmerge)
find_program(GETTEXT_MSGFMT_EXECUTABLE msgfmt)
if(GETTEXT_MSGMERGE_EXECUTABLE)
execute_process(COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --version
execute_process(COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --version
OUTPUT_VARIABLE gettext_version
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
get_filename_component(msgmerge_name ${GETTEXT_MSGMERGE_EXECUTABLE} NAME)
get_filename_component(msgmerge_namewe ${GETTEXT_MSGMERGE_EXECUTABLE} NAME_WE)
if (gettext_version MATCHES "^(${msgmerge_name}|${msgmerge_namewe}) \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
set(GETTEXT_VERSION_STRING "${CMAKE_MATCH_2}")
endif()
unset(gettext_version)
unset(msgmerge_name)
unset(msgmerge_namewe)
get_filename_component(msgmerge_name ${GETTEXT_MSGMERGE_EXECUTABLE} NAME)
get_filename_component(msgmerge_namewe ${GETTEXT_MSGMERGE_EXECUTABLE} NAME_WE)
if (gettext_version MATCHES "^(${msgmerge_name}|${msgmerge_namewe}) \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
set(GETTEXT_VERSION_STRING "${CMAKE_MATCH_2}")
endif()
unset(gettext_version)
unset(msgmerge_name)
unset(msgmerge_namewe)
endif()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext
REQUIRED_VARS GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE
VERSION_VAR GETTEXT_VERSION_STRING)
function(_GETTEXT_GET_UNIQUE_TARGET_NAME _name _unique_name)
set(propertyName "_GETTEXT_UNIQUE_COUNTER_${_name}")
get_property(currentCounter GLOBAL PROPERTY "${propertyName}")
if(NOT currentCounter)
set(currentCounter 1)
endif()
set(${_unique_name} "${_name}_${currentCounter}" PARENT_SCOPE)
math(EXPR currentCounter "${currentCounter} + 1")
set_property(GLOBAL PROPERTY ${propertyName} ${currentCounter} )
set(propertyName "_GETTEXT_UNIQUE_COUNTER_${_name}")
get_property(currentCounter GLOBAL PROPERTY "${propertyName}")
if(NOT currentCounter)
set(currentCounter 1)
endif()
set(${_unique_name} "${_name}_${currentCounter}" PARENT_SCOPE)
math(EXPR currentCounter "${currentCounter} + 1")
set_property(GLOBAL PROPERTY ${propertyName} ${currentCounter} )
endfunction()
macro(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg)
# make it a real variable, so we can modify it here
set(_firstPoFile "${_firstPoFileArg}")
# make it a real variable, so we can modify it here
set(_firstPoFile "${_firstPoFileArg}")
set(_gmoFiles)
get_filename_component(_potName ${_potFile} NAME)
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
set(_gmoFiles)
get_filename_component(_potName ${_potFile} NAME)
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
set(_addToAll)
if(${_firstPoFile} STREQUAL "ALL")
set(_addToAll "ALL")
set(_firstPoFile)
endif()
set(_addToAll)
if(${_firstPoFile} STREQUAL "ALL")
set(_addToAll "ALL")
set(_firstPoFile)
endif()
foreach (_currentPoFile ${_firstPoFile} ${ARGN})
get_filename_component(_absFile ${_currentPoFile} ABSOLUTE)
get_filename_component(_abs_PATH ${_absFile} PATH)
string(REGEX REPLACE "^.*/([^/]+)(\\.[^.]+)$" "\\1" _lang ${_absFile})
set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
foreach (_currentPoFile ${_firstPoFile} ${ARGN})
get_filename_component(_absFile ${_currentPoFile} ABSOLUTE)
get_filename_component(_abs_PATH ${_absFile} PATH)
get_filename_component(_lang ${_absFile} NAME_WE)
set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
add_custom_command(
OUTPUT ${_gmoFile}
#COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
DEPENDS ${_absPotFile} ${_absFile}
)
add_custom_command(
OUTPUT ${_gmoFile}
# COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
DEPENDS ${_absPotFile} ${_absFile}
)
install(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
set(_gmoFiles ${_gmoFiles} ${_gmoFile})
install(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
set(_gmoFiles ${_gmoFiles} ${_gmoFile})
endforeach ()
endforeach ()
if(NOT TARGET translations)
add_custom_target(translations)
endif()
if(NOT TARGET translations)
add_custom_target(translations)
endif()
_GETTEXT_GET_UNIQUE_TARGET_NAME(translations uniqueTargetName)
add_custom_target(${uniqueTargetName} ${_addToAll} DEPENDS ${_gmoFiles})
add_custom_target(${uniqueTargetName} ${_addToAll} DEPENDS ${_gmoFiles})
add_dependencies(translations ${uniqueTargetName})
add_dependencies(translations ${uniqueTargetName})
endmacro()
function(GETTEXT_PROCESS_POT_FILE _potFile)
set(_gmoFiles)
set(_options ALL)
set(_oneValueArgs INSTALL_DESTINATION)
set(_multiValueArgs LANGUAGES)
set(_gmoFiles)
set(_options ALL)
set(_oneValueArgs INSTALL_DESTINATION)
set(_multiValueArgs LANGUAGES)
CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
get_filename_component(_potName ${_potFile} NAME)
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
get_filename_component(_potName ${_potFile} NAME)
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
foreach (_lang ${_parsedArguments_LANGUAGES})
set(_poFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.po")
set(_gmoFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo")
foreach (_lang ${_parsedArguments_LANGUAGES})
set(_poFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.po")
set(_gmoFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo")
add_custom_command(
OUTPUT "${_poFile}"
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_poFile} ${_absPotFile}
DEPENDS ${_absPotFile}
)
add_custom_command(
OUTPUT "${_poFile}"
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_poFile} ${_absPotFile}
DEPENDS ${_absPotFile}
)
add_custom_command(
OUTPUT "${_gmoFile}"
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_poFile}
DEPENDS ${_absPotFile} ${_poFile}
)
add_custom_command(
OUTPUT "${_gmoFile}"
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_poFile}
DEPENDS ${_absPotFile} ${_poFile}
)
if(_parsedArguments_INSTALL_DESTINATION)
install(FILES ${_gmoFile} DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
endif()
list(APPEND _gmoFiles ${_gmoFile})
endforeach ()
if(_parsedArguments_INSTALL_DESTINATION)
install(FILES ${_gmoFile} DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
endif()
list(APPEND _gmoFiles ${_gmoFile})
endforeach ()
if(NOT TARGET potfiles)
add_custom_target(potfiles)
add_custom_target(potfiles)
endif()
_GETTEXT_GET_UNIQUE_TARGET_NAME( potfiles uniqueTargetName)
if(_parsedArguments_ALL)
add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
else()
add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
endif()
if(_parsedArguments_ALL)
add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
else()
add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
endif()
add_dependencies(potfiles ${uniqueTargetName})
add_dependencies(potfiles ${uniqueTargetName})
endfunction()
function(GETTEXT_PROCESS_PO_FILES _lang)
set(_options ALL)
set(_oneValueArgs INSTALL_DESTINATION)
set(_multiValueArgs PO_FILES)
set(_gmoFiles)
set(_options ALL)
set(_oneValueArgs INSTALL_DESTINATION)
set(_multiValueArgs PO_FILES)
set(_gmoFiles)
CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
foreach(_current_PO_FILE ${_parsedArguments_PO_FILES})
get_filename_component(_name ${_current_PO_FILE} NAME)
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name})
set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo)
add_custom_command(OUTPUT ${_gmoFile}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS ${_current_PO_FILE}
)
foreach(_current_PO_FILE ${_parsedArguments_PO_FILES})
get_filename_component(_name ${_current_PO_FILE} NAME)
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name})
set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo)
add_custom_command(OUTPUT ${_gmoFile}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS ${_current_PO_FILE}
)
if(_parsedArguments_INSTALL_DESTINATION)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/ RENAME ${_basename}.mo)
endif()
list(APPEND _gmoFiles ${_gmoFile})
endforeach()
if(_parsedArguments_INSTALL_DESTINATION)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/ RENAME ${_basename}.mo)
endif()
list(APPEND _gmoFiles ${_gmoFile})
endforeach()
if(NOT TARGET pofiles)
add_custom_target(pofiles)
add_custom_target(pofiles)
endif()
_GETTEXT_GET_UNIQUE_TARGET_NAME( pofiles uniqueTargetName)
if(_parsedArguments_ALL)
add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
else()
add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
endif()
if(_parsedArguments_ALL)
add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
else()
add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
endif()
add_dependencies(pofiles ${uniqueTargetName})
add_dependencies(pofiles ${uniqueTargetName})
endfunction()

View File

@@ -1,263 +0,0 @@
# This module defines
# SDL2_LIBRARY, the name of the library to link against
# SDL2_FOUND, if false, do not try to link to SDL2
# SDL2_INCLUDE_DIR, where to find SDL.h
#
# If you have pkg-config, these extra variables are also defined:
# SDL2_DEFINITIONS, extra CFLAGS
# SDL2_EXTRA_LIBS, extra link libs
# SDL2_LINKER_FLAGS, extra link flags
#
# The latter two are automatically added to SDL2_LIBRARY
#
# To use them, add code such as:
#
# # SET(SDL2_STATIC ON) # if you want to link SDL2 statically
# FIND_PACKAGE(SDL2 REQUIRED)
# ADD_DEFINITIONS(${SDL2_DEFINITIONS})
# TARGET_LINK_LIBRARIES(your-executable-target ${SDL2_LIBRARY} ...)
#
# This module responds to the the flag:
# SDL2_BUILDING_LIBRARY
# If this is defined, then no SDL2main will be linked in because
# only applications need main().
# Otherwise, it is assumed you are building an application and this
# module will attempt to locate and set the the proper link flags
# as part of the returned SDL2_LIBRARY variable.
#
# If you want to link SDL2 statically, set SDL2_STATIC to ON.
#
# Don't forget to include SDLmain.h and SDLmain.m your project for the
# OS X framework based version. (Other versions link to -lSDL2main which
# this module will try to find on your behalf.) Also for OS X, this
# module will automatically add the -framework Cocoa on your behalf.
#
#
# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration
# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library
# (SDL2.dll, libsdl2.so, SDL2.framework, etc).
# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again.
# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
# as appropriate. These values are used to generate the final SDL2_LIBRARY
# variable, but when these values are unset, SDL2_LIBRARY does not get created.
#
#
# $SDL2DIR is an environment variable that would
# correspond to the ./configure --prefix=$SDL2DIR
# used in building SDL2.
# l.e.galup 9-20-02
#
# Modified by Eric Wing.
# Added code to assist with automated building by using environmental variables
# and providing a more controlled/consistent search behavior.
# Added new modifications to recognize OS X frameworks and
# additional Unix paths (FreeBSD, etc).
# Also corrected the header search path to follow "proper" SDL guidelines.
# Added a search for SDL2main which is needed by some platforms.
# Added a search for threads which is needed by some platforms.
# Added needed compile switches for MinGW.
#
# On OSX, this will prefer the Framework version (if found) over others.
# People will have to manually change the cache values of
# SDL2_LIBRARY to override this selection or set the CMake environment
# CMAKE_INCLUDE_PATH to modify the search paths.
#
# Note that the header path has changed from SDL3/SDL.h to just SDL.h
# This needed to change because "proper" SDL convention
# is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability
# reasons because not all systems place things in SDL2/ (see FreeBSD).
#=============================================================================
# Copyright 2003-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
SET(SDL2_SEARCH_PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local # Mac Homebrew and local installs
/usr
/sw # Fink
/opt/local # MacPorts
/opt/csw # OpenCSW (Solaris)
/opt
${SDL2_PATH}/include
${SDL2_PATH}/lib
)
FIND_PATH(SDL2_INCLUDE_DIR SDL.h
HINTS $ENV{SDL2DIR}
PATH_SUFFIXES SDL2
PATHS ${SDL2_SEARCH_PATHS}
)
SET(CURRENT_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if(SDL2_STATIC)
if(MSVC)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib)
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif()
endif()
unset(lib_suffixes)
if(MSVC)
if(VCPKG_TARGET_TRIPLET MATCHES "-static$")
list(APPEND lib_suffixes -static)
endif()
if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
list(APPEND lib_suffixes d)
endif()
endif()
# Calculate combination of possible name+suffixes.
unset(names)
set(lib_name SDL2)
set(current ${lib_name})
foreach(suffix ${lib_suffixes})
list(APPEND names "${current}${suffix}" "${lib_name}${suffix}")
set(current "${current}${suffix}")
endforeach()
# Fallback to name by itself.
list(APPEND names ${lib_name})
FIND_LIBRARY(SDL2_LIBRARY_TEMP
NAMES ${names}
HINTS $ENV{SDL2DIR}
PATH_SUFFIXES lib64 lib lib/x64 lib/x86
PATHS ${SDL2_SEARCH_PATHS}
)
if(NOT (SDL2_BUILDING_LIBRARY OR ${SDL2_INCLUDE_DIR} MATCHES ".framework"))
# Non-OS X framework versions expect you to also dynamically link to
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
# seem to provide SDL2main for compatibility even though they don't
# necessarily need it.
find_library(SDL2MAIN_LIBRARY
NAMES SDL2main${lib_suffix}
HINTS $ENV{SDL2DIR}
PATH_SUFFIXES lib64 lib lib/x64 lib/x86
PATHS ${SDL2_SEARCH_PATHS}
)
endif()
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CURRENT_FIND_LIBRARY_SUFFIXES})
UNSET(CURRENT_FIND_LIBRARY_SUFFIXES)
# SDL2 may require threads on your system.
# The Apple build may not need an explicit flag because one of the
# frameworks may already provide it.
# But for non-OSX systems, I will use the CMake Threads package.
IF(NOT APPLE)
FIND_PACKAGE(Threads)
ENDIF(NOT APPLE)
# MinGW needs an additional link flag, -mwindows (to make a GUI app)
# but we only add it when not making a Debug build.
# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -mwindows
IF(MINGW)
SET(MINGW32_LIBRARY -lmingw32 CACHE STRING "MinGW library")
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
SET(MINGW32_LIBRARY ${MINGW32_LIBRARY} -mwindows)
ENDIF()
ENDIF(MINGW)
IF(SDL2_LIBRARY_TEMP)
# For SDL2main
if(SDL2MAIN_LIBRARY AND NOT WIN32)
SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
endif()
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
# CMake doesn't display the -framework Cocoa string in the UI even
# though it actually is there if I modify a pre-used variable.
# I think it has something to do with the CACHE STRING.
# So I use a temporary variable until the end so I can set the
# "real" variable in one-shot.
IF(APPLE)
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
ENDIF(APPLE)
# For threads, as mentioned Apple doesn't need this.
# In fact, there seems to be a problem if I used the Threads package
# and try using this line, so I'm just skipping it entirely for OS X.
IF(NOT APPLE)
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
ENDIF(NOT APPLE)
# For MinGW library
IF(MINGW)
SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP} -lversion -limm32)
ENDIF(MINGW)
# Add libsamplerate with vcpkg
if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
if(WIN32)
unset(arch_suffix)
unset(path_prefix)
if(VCPKG_TARGET_TRIPLET MATCHES -static)
set(arch_suffix -static)
endif()
if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
set(path_prefix debug)
endif()
set(installed_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix}/${path_prefix})
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${installed_prefix}/lib/samplerate.lib)
else()
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} -lsamplerate)
endif()
endif()
# Add some stuff from pkg-config, if available
IF(NOT PKG_CONFIG_EXECUTABLE)
FIND_PACKAGE(PkgConfig QUIET)
ENDIF(NOT PKG_CONFIG_EXECUTABLE)
IF(PKG_CONFIG_EXECUTABLE)
# get any definitions
EXECUTE_PROCESS(COMMAND ${PKG_CONFIG_EXECUTABLE} --cflags-only-other sdl2 OUTPUT_VARIABLE SDL2_DEFINITIONS ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
SET(SDL2_DEFINITIONS ${SDL2_DEFINITIONS} CACHE STRING "Extra CFLAGS for SDL2 from pkg-config")
# get any extra stuff needed for linking
IF(NOT SDL2_STATIC)
EXECUTE_PROCESS(COMMAND ${PKG_CONFIG_EXECUTABLE} --libs-only-other sdl2 OUTPUT_VARIABLE SDL2_LINKER_FLAGS_RAW ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(COMMAND ${PKG_CONFIG_EXECUTABLE} --libs-only-l sdl2 OUTPUT_VARIABLE SDL2_EXTRA_LIBS_RAW ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
ELSE(NOT SDL2_STATIC)
EXECUTE_PROCESS(COMMAND ${PKG_CONFIG_EXECUTABLE} --static --libs-only-other sdl2 OUTPUT_VARIABLE SDL2_LINKER_FLAGS_RAW ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(COMMAND ${PKG_CONFIG_EXECUTABLE} --static --libs-only-l sdl2 OUTPUT_VARIABLE SDL2_EXTRA_LIBS_RAW ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF(NOT SDL2_STATIC)
STRING(REGEX REPLACE "[^ ]+SDL2[^ ]*" "" SDL2_EXTRA_LIBS_RAW2 "${SDL2_EXTRA_LIBS_RAW}")
STRING(REGEX REPLACE " +" ";" SDL2_EXTRA_LIBS "${SDL2_EXTRA_LIBS_RAW2}")
STRING(REGEX REPLACE " +" ";" SDL2_LINKER_FLAGS "${SDL2_LINKER_FLAGS_RAW}")
SET(SDL2_LINKER_FLAGS ${SDL2_LINKER_FLAGS} CACHE STRING "Linker flags for linking SDL2")
SET(SDL2_EXTRA_LIBS ${SDL2_EXTRA_LIBS} CACHE STRING "Extra libraries for linking SDL2")
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${SDL2_EXTRA_LIBS} ${SDL2_LINKER_FLAGS})
ENDIF(PKG_CONFIG_EXECUTABLE)
# Set the final string here so the GUI reflects the final state.
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
ENDIF(SDL2_LIBRARY_TEMP)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)

View File

@@ -57,7 +57,7 @@
# define the SFML_STATIC macro if static build was chosen
if(SFML_STATIC_LIBRARIES)
add_definitions(-DSFML_STATIC)
add_compile_definitions(SFML_STATIC)
endif()
# define the list of search paths for headers and libraries

View File

@@ -1,76 +0,0 @@
# FindSSP.cmake
#
# Find libssp necessary when using gcc with e.g. -fstack-protector=strong
#
# See: http://wiki.osdev.org/Stack_Smashing_Protector
#
# To use:
#
# put a copy into your <project_root>/cmake/
#
# In your main CMakeLists.txt do something like this:
#
# if(WIN32)
# set(SSP_STATIC ON)
# endif()
#
# find_package(SSP)
#
# if(SSP_LIBRARY)
# set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${SSP_LIBRARY}")
# set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${SSP_LIBRARY}")
# endif()
# only do this when compiling with gcc/g++
if(NOT CMAKE_COMPILER_IS_GNUCXX)
return()
endif()
function(FindSSP)
if(NOT CMAKE_CXX_COMPILER AND CMAKE_C_COMPILER)
set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER})
endif()
foreach(arg ${CMAKE_CXX_COMPILER_ARG1} ${CMAKE_CXX_COMPILER_ARG2} ${CMAKE_CXX_COMPILER_ARG3} ${CMAKE_CXX_COMPILER_ARG4} ${CMAKE_CXX_COMPILER_ARG5} ${CMAKE_CXX_COMPILER_ARG6} ${CMAKE_CXX_COMPILER_ARG7} ${CMAKE_CXX_COMPILER_ARG8} ${CMAKE_CXX_COMPILER_ARG9})
string(STRIP ${arg} arg)
set(gcc_args "${gcc_args};${arg}")
endforeach()
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${gcc_args} --print-prog-name=gcc OUTPUT_VARIABLE GCC_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE)
if(WIN32 AND NOT MSYS)
execute_process(COMMAND where.exe ${GCC_EXECUTABLE} OUTPUT_VARIABLE GCC_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
execute_process(COMMAND sh -c "command -v ${GCC_EXECUTABLE}" OUTPUT_VARIABLE GCC_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
get_filename_component(GCC_DIRNAME "${GCC_EXECUTABLE}" DIRECTORY)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${gcc_args} --print-libgcc-file-name OUTPUT_VARIABLE LIBGCC_FILE OUTPUT_STRIP_TRAILING_WHITESPACE)
get_filename_component(LIBGCC_DIRNAME "${LIBGCC_FILE}" DIRECTORY)
set(SSP_SEARCH_PATHS ${GCC_DIRNAME} ${LIBGCC_DIRNAME})
if(SSP_STATIC)
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a)
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif()
endif()
find_library(SSP_LIBRARY
NAMES ssp libssp
HINTS ${SSP_SEARCH_PATHS}
PATH_SUFFIXES lib64 lib lib/x64 lib/x86
)
set(SSP_LIBRARY PARENT_SCOPE)
endfunction()
FindSSP()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SSP REQUIRED_VARS SSP_LIBRARY)

View File

@@ -7,23 +7,6 @@
#
# Returns the refspec and sha hash of the current head revision
#
# git_describe(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the source tree, and adjusting
# the output so that it tests false if an error occurs.
#
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe --exact-match on the source tree,
# and adjusting the output so that it tests false if there was no exact
# matching tag.
#
# git_local_changes(<var>)
#
# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes.
# Uses the return code of "git diff-index --quiet HEAD --".
# Does not regard untracked files.
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
@@ -85,84 +68,3 @@ function(get_git_head_revision _refspecvar _hashvar)
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
endfunction()
function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
endif()
# TODO sanitize
#if((${ARGN}" MATCHES "&&") OR
# (ARGN MATCHES "||") OR
# (ARGN MATCHES "\\;"))
# message("Please report the following error to the project!")
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
#endif()
#message(STATUS "Arguments to execute_process: ${ARGN}")
execute_process(COMMAND
"${GIT_EXECUTABLE}"
describe
${hash}
${ARGN}
WORKING_DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN})
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_local_changes _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
endif()
execute_process(COMMAND
"${GIT_EXECUTABLE}"
diff-index --quiet HEAD --
WORKING_DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(res EQUAL 0)
set(${_var} "CLEAN" PARENT_SCOPE)
else()
set(${_var} "DIRTY" PARENT_SCOPE)
endif()
endfunction()

View File

@@ -3,7 +3,6 @@ function(git_version version revision version_release)
set(${revision} "" CACHE STRING "Latest Git Tag Revision" FORCE)
set(${version_release} 0 CACHE STRING "Is this a versioned release without revision" FORCE)
find_package(Git)
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
# get latest version from tag history
execute_process(COMMAND "${GIT_EXECUTABLE}" tag "--format=%(align:width=20)%(refname:short)%(end)%(if)%(*objectname)%(then)%(*objectname)%(else)%(objectname)%(end)" --sort=-v:refname OUTPUT_VARIABLE tags OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")

View File

@@ -1,44 +0,0 @@
function(use_llvm_toolchain)
if(CMAKE_C_COMPILER_ID STREQUAL Clang)
set(compiler "${CMAKE_C_COMPILER}")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(compiler "${CMAKE_CXX_COMPILER}")
else()
return()
endif()
foreach(tool ar ranlib ld nm objdump as)
execute_process(
COMMAND "${compiler}" -print-prog-name=llvm-${tool}
OUTPUT_VARIABLE prog_path
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# for FreeBSD
if(NOT prog_path MATCHES "^/")
get_filename_component(
abs_path ${prog_path} ABSOLUTE
BASE_DIR /usr/local/llvm-devel/bin
)
if(EXISTS ${abs_path})
set(prog_path ${abs_path})
endif()
endif()
if(prog_path MATCHES "^/")
if(tool STREQUAL ld)
set(tool linker)
elseif(tool STREQUAL as)
set(tool asm_compiler)
endif()
string(TOUPPER ${tool} utool)
set(CMAKE_${utool} "${prog_path}" PARENT_SCOPE)
set(CMAKE_${utool} "${prog_path}" CACHE FILEPATH "${tool}" FORCE)
endif()
endforeach()
endfunction()
use_llvm_toolchain()

View File

@@ -11,8 +11,8 @@
# In addition, the following commands are called with the package manager's
# paths:
#
# INCLUDE_DIRECTORIES()
# LINK_DIRECTORIES()
# include_directories()
# link_directories()
#
# The paths of package managers not currently in $ENV{PATH} are added to
# CMAKE_IGNORE_PATH .
@@ -41,68 +41,75 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IF(NOT APPLE)
RETURN()
ENDIF()
if(NOT APPLE)
return()
endif()
IF(EXISTS /usr/local/bin/brew AND $ENV{PATH} MATCHES "(^|:)/usr/local/bin/?(:|$)")
MESSAGE("-- Configuring for Mac Homebrew")
if(NOT "$ENV{IN_NIX_SHELL}" STREQUAL "")
message(STATUS "Configuring for Nix")
SET(MAC_HOMEBREW ON)
set(NIX ON)
SET(CMAKE_IGNORE_PATH /opt/local /opt/local/bin /opt/local/include /opt/local/Library/Frameworks /opt/local/lib ${CMAKE_IGNORE_PATH})
SET(CMAKE_IGNORE_PATH /sw /sw/bin /sw/include /sw/Library/Frameworks /sw/lib ${CMAKE_IGNORE_PATH})
set(CMAKE_IGNORE_PATH /opt/local /opt/local/bin /opt/local/include /opt/local/Library/Frameworks /opt/local/lib ${CMAKE_IGNORE_PATH})
set(CMAKE_IGNORE_PATH /sw /sw/bin /sw/include /sw/Library/Frameworks /sw/lib ${CMAKE_IGNORE_PATH})
elseif(EXISTS /usr/local/bin/brew AND $ENV{PATH} MATCHES "(^|:)/usr/local/bin/?(:|$)")
message(STATUS "Configuring for Mac Homebrew")
SET(CMAKE_FRAMEWORK_PATH /usr/local/Frameworks ${CMAKE_FRAMEWORK_PATH})
set(MAC_HOMEBREW ON)
SET(CMAKE_INCLUDE_PATH /usr/local/include ${CMAKE_INCLUDE_PATH})
INCLUDE_DIRECTORIES("/usr/local/include")
set(CMAKE_IGNORE_PATH /opt/local /opt/local/bin /opt/local/include /opt/local/Library/Frameworks /opt/local/lib ${CMAKE_IGNORE_PATH})
set(CMAKE_IGNORE_PATH /sw /sw/bin /sw/include /sw/Library/Frameworks /sw/lib ${CMAKE_IGNORE_PATH})
SET(CMAKE_LIBRARY_PATH /usr/local/lib ${CMAKE_LIBRARY_PATH})
LINK_DIRECTORIES("/usr/local/lib")
set(CMAKE_FRAMEWORK_PATH /usr/local/Frameworks ${CMAKE_FRAMEWORK_PATH})
SET(CMAKE_PROGRAM_PATH /usr/local/bin ${CMAKE_PROGRAM_PATH})
set(CMAKE_INCLUDE_PATH /usr/local/include ${CMAKE_INCLUDE_PATH})
include_directories("/usr/local/include")
set(CMAKE_LIBRARY_PATH /usr/local/lib ${CMAKE_LIBRARY_PATH})
link_directories("/usr/local/lib")
set(CMAKE_PROGRAM_PATH /usr/local/bin ${CMAKE_PROGRAM_PATH})
set(ZLIB_ROOT /usr/local/opt/zlib)
ELSEIF(EXISTS /opt/local/bin/port AND $ENV{PATH} MATCHES "(^|:)/opt/local/bin/?(:|$)")
MESSAGE("-- Configuring for MacPorts")
elseif(EXISTS /opt/local/bin/port AND $ENV{PATH} MATCHES "(^|:)/opt/local/bin/?(:|$)")
message(STATUS "Configuring for MacPorts")
SET(MACPORTS ON)
set(MACPORTS ON)
SET(CMAKE_IGNORE_PATH /sw /sw/bin /sw/include /sw/Library/Frameworks /sw/lib ${CMAKE_IGNORE_PATH})
set(CMAKE_IGNORE_PATH /sw /sw/bin /sw/include /sw/Library/Frameworks /sw/lib ${CMAKE_IGNORE_PATH})
SET(CMAKE_FRAMEWORK_PATH /opt/local/Library/Frameworks ${CMAKE_FRAMEWORK_PATH})
set(CMAKE_FRAMEWORK_PATH /opt/local/Library/Frameworks ${CMAKE_FRAMEWORK_PATH})
SET(CMAKE_INCLUDE_PATH /opt/local/include ${CMAKE_INCLUDE_PATH})
INCLUDE_DIRECTORIES("/opt/local/include")
set(CMAKE_INCLUDE_PATH /opt/local/include ${CMAKE_INCLUDE_PATH})
include_directories("/opt/local/include")
SET(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH})
LINK_DIRECTORIES("/opt/local/lib")
set(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH})
link_directories("/opt/local/lib")
SET(CMAKE_PROGRAM_PATH /opt/local/bin ${CMAKE_PROGRAM_PATH})
ELSEIF(EXISTS /sw/bin/fink AND $ENV{PATH} MATCHES "(^|:)/sw/bin/?(:|$)")
MESSAGE("-- Configuring for Fink")
set(CMAKE_PROGRAM_PATH /opt/local/bin ${CMAKE_PROGRAM_PATH})
elseif(EXISTS /sw/bin/fink AND $ENV{PATH} MATCHES "(^|:)/sw/bin/?(:|$)")
message(STATUS "Configuring for Fink")
SET(FINK ON)
set(FINK ON)
SET(CMAKE_IGNORE_PATH /opt/local /opt/local/bin /opt/local/include /opt/local/Library/Frameworks /opt/local/lib ${CMAKE_IGNORE_PATH})
set(CMAKE_IGNORE_PATH /opt/local /opt/local/bin /opt/local/include /opt/local/Library/Frameworks /opt/local/lib ${CMAKE_IGNORE_PATH})
SET(CMAKE_FRAMEWORK_PATH /sw/Library/Frameworks ${CMAKE_FRAMEWORK_PATH})
set(CMAKE_FRAMEWORK_PATH /sw/Library/Frameworks ${CMAKE_FRAMEWORK_PATH})
SET(CMAKE_INCLUDE_PATH /sw/include ${CMAKE_INCLUDE_PATH})
INCLUDE_DIRECTORIES("/sw/include")
set(CMAKE_INCLUDE_PATH /sw/include ${CMAKE_INCLUDE_PATH})
include_directories("/sw/include")
SET(CMAKE_LIBRARY_PATH /sw/lib ${CMAKE_LIBRARY_PATH})
LINK_DIRECTORIES("/sw/lib")
set(CMAKE_LIBRARY_PATH /sw/lib ${CMAKE_LIBRARY_PATH})
link_directories("/sw/lib")
SET(CMAKE_PROGRAM_PATH /sw/bin ${CMAKE_PROGRAM_PATH})
ELSE()
set(CMAKE_PROGRAM_PATH /sw/bin ${CMAKE_PROGRAM_PATH})
else()
# no package manager found or active, do nothing
RETURN()
ENDIF()
return()
endif()
# only ignore /usr/local if brew is installed and not in the PATH
# in other cases, it is the user's personal installations
IF(NOT MAC_HOMEBREW AND EXISTS /usr/local/bin/brew)
SET(CMAKE_IGNORE_PATH /usr/local /usr/local/bin /usr/local/include /usr/local/Library/Frameworks /usr/local/lib ${CMAKE_IGNORE_PATH})
ENDIF()
if(NOT MAC_HOMEBREW AND EXISTS /usr/local/bin/brew)
set(CMAKE_IGNORE_PATH /usr/local /usr/local/bin /usr/local/include /usr/local/Library/Frameworks /usr/local/lib /usr/local/opt/gettext/bin /usr/local/opt/gettext/lib ${CMAKE_IGNORE_PATH})
endif()

View File

@@ -10,12 +10,6 @@ if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git")
message(FATAL_ERROR "releases can only be done from a git clone")
endif()
find_package(Git)
if(NOT GIT_FOUND)
message(FATAL_ERROR "git is required to make a release")
endif()
find_program(GPG_EXECUTABLE gpg)
if(NOT GPG_EXECUTABLE)
@@ -37,7 +31,7 @@ function(make_release_commit_and_tag)
# First make sure we are on master.
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short --abbrev-ref=strict HEAD
COMMAND git rev-parse --short --abbrev-ref=strict HEAD
OUTPUT_VARIABLE git_branch
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@@ -48,7 +42,7 @@ function(make_release_commit_and_tag)
endif()
execute_process(
COMMAND ${GIT_EXECUTABLE} status --porcelain=2
COMMAND git status --porcelain=2
OUTPUT_VARIABLE git_status
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@@ -61,7 +55,7 @@ function(make_release_commit_and_tag)
endif()
execute_process(
COMMAND ${GIT_EXECUTABLE} tag --sort=-v:refname
COMMAND git tag --sort=-v:refname
OUTPUT_VARIABLE git_tags
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@@ -82,7 +76,7 @@ function(make_release_commit_and_tag)
endif()
execute_process(
COMMAND ${GIT_EXECUTABLE} log ${git_last_tag}.. "--pretty=format:* %h - %s [%aL]"
COMMAND git log ${git_last_tag}.. "--pretty=format:* %h - %s [%aL]"
OUTPUT_VARIABLE release_log
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@@ -92,17 +86,17 @@ function(make_release_commit_and_tag)
if(TAG_RELEASE STREQUAL UNDO)
execute_process(
COMMAND ${GIT_EXECUTABLE} tag -d ${git_last_tag}
COMMAND git tag -d ${git_last_tag}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
execute_process(
COMMAND ${GIT_EXECUTABLE} reset HEAD~1
COMMAND git reset HEAD~1
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
execute_process(
COMMAND ${GIT_EXECUTABLE} checkout HEAD CHANGELOG.md
COMMAND git checkout HEAD CHANGELOG.md
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
@@ -186,10 +180,12 @@ Ignore the following cmake error.
endwhile()
# Convert to UNIX line endings on Windows, just copy the file otherwise.
if(CMAKE_HOST_SYSTEM MATCHES Windows OR ((NOT DEFINED CMAKE_HOST_SYSTEM) AND WIN32))
if(NOT DEFINED POWERSHELL)
message(FATAL_ERROR "Powershell is required to convert line endings on Windows.")
endif()
execute_process(
COMMAND powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command [=[
COMMAND ${POWERSHELL} -NoLogo -NoProfile -ExecutionPolicy Bypass -Command [=[
$text = [IO.File]::ReadAllText("CHANGELOG.md.work") -replace "`r`n", "`n"
[IO.File]::WriteAllText("CHANGELOG.md", $text)
]=]
@@ -212,45 +208,37 @@ Ignore the following cmake error.
)
execute_process(
COMMAND ${GIT_EXECUTABLE} add CHANGELOG.md
COMMAND git add CHANGELOG.md
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
# Make the release commit.
message(FATAL_ERROR "
execute_process(
COMMAND ${GIT_EXECUTABLE} commit -m "release ${new_tag}" --signoff -S
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
Release prepared.
# Make release tag.
Edit CHANGELOG.md to remove any non-user-facing commits, and optionally add any
release notes.
execute_process(
COMMAND ${GIT_EXECUTABLE} tag -s -m${new_tag} ${new_tag}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
Run the following commands to commit the change:
message(FATAL_ERROR [=[
Release commit and tag generated.
**** IF YOU ARE SURE YOU WANT TO RELEASE ****
Run the following commands to push the release commit and tag:
git push
git push --tags
**** TO UNDO THE RELEASE ****
git commit -m'release ${new_tag}' --signoff -S
git tag -s -m'${new_tag}' ${new_tag}
To rollback these changes, run this command:
cmake .. -DTAG_RELEASE=UNDO
Ignore the "configuration incomplete" message following, this mode does not
==== IF YOU ARE SURE YOU WANT TO RELEASE, THIS **CANNOT** BE REVERSED ====
Run the following to push the release commit and tag:
git push
git push --tags
Ignore the 'configuration incomplete' message following, this mode does not
build anything.
]=])
")
endfunction()
make_release_commit_and_tag()

171
cmake/Options.cmake Normal file
View File

@@ -0,0 +1,171 @@
option(BUILD_TESTING "Build testing" ON)
option(BUILD_SHARED_LIBS "Build dynamic libraries" OFF)
option(TRANSLATIONS_ONLY "Build only the translations.zip" OFF)
if(TRANSLATIONS_ONLY)
set(BUILD_DEFAULT OFF)
else()
set(BUILD_DEFAULT ON)
endif()
set(ENABLE_SDL_DEFAULT ${BUILD_DEFAULT})
if(WIN32 OR APPLE)
set(ENABLE_SDL_DEFAULT OFF)
endif()
option(ENABLE_SDL "Build the SDL port" ${ENABLE_SDL_DEFAULT})
option(ENABLE_WX "Build the wxWidgets port" ${BUILD_DEFAULT})
option(ENABLE_DEBUGGER "Enable the debugger" ON)
option(ENABLE_ASAN "Enable -fsanitize=address by default. Requires debug build with GCC/Clang" OFF)
# Static linking
set(VBAM_STATIC_DEFAULT OFF)
if(VCPKG_TARGET_TRIPLET MATCHES -static OR CMAKE_TOOLCHAIN_FILE MATCHES "mxe|-static")
set(VBAM_STATIC_DEFAULT ON)
elseif(MINGW OR MSYS)
# Default to static builds on MinGW and all MSYS2 envs.
set(VBAM_STATIC_DEFAULT ON)
endif()
option(VBAM_STATIC "Try to link all libraries statically" ${VBAM_STATIC_DEFAULT})
if(VBAM_STATIC)
set(SDL2_STATIC ON)
set(SFML_STATIC_LIBRARIES ON)
set(FFMPEG_STATIC ON)
set(OPENAL_STATIC ON)
set_property(GLOBAL PROPERTY LINK_SEARCH_START_STATIC ON)
set_property(GLOBAL PROPERTY LINK_SEARCH_END_STATIC ON)
if(MSVC)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib)
else()
list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .a)
endif()
endif()
option(ENABLE_ASM "Enable x86 ASM related options" OFF)
# The ARM ASM core seems to be very buggy, see #98 and #54. Default to it being
# OFF for the time being, until it is either fixed or replaced.
option(ENABLE_ASM_CORE "Enable x86 ASM CPU cores (EXPERIMENTAL)" OFF)
set(ASM_SCALERS_DEFAULT ${ENABLE_ASM})
set(MMX_DEFAULT ${ENABLE_ASM})
option(ENABLE_ASM_SCALERS "Enable x86 ASM graphic filters" ${ASM_SCALERS_DEFAULT})
include(CMakeDependentOption)
cmake_dependent_option(ENABLE_MMX "Enable MMX" ${MMX_DEFAULT} "ENABLE_ASM_SCALERS" OFF)
option(ENABLE_LIRC "Enable LIRC support" OFF)
# Add support for Homebrew, MacPorts and Fink on macOS
option(DISABLE_MACOS_PACKAGE_MANAGERS "Set to TRUE to disable support for macOS Homebrew, MacPorts and Fink." FALSE)
if(APPLE AND NOT DISABLE_MACOS_PACKAGE_MANAGERS)
include(MacPackageManagers)
endif()
find_package(PkgConfig)
# Link / SFML
if(TRANSLATIONS_ONLY)
set(ENABLE_LINK_DEFAULT OFF)
else()
find_package(SFML 2.4 COMPONENTS network system)
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
if(SFML_STATIC_LIBRARIES AND SFML_NETWORK_LIBRARY_STATIC_DEBUG AND SFML_SYSTEM_LIBRARY_STATIC_DEBUG)
set(SFML_LIBRARIES ${SFML_NETWORK_LIBRARY_STATIC_DEBUG} ${SFML_SYSTEM_LIBRARY_STATIC_DEBUG})
elseif(SFML_NETWORK_LIBRARY_DYNAMIC_DEBUG AND SFML_SYSTEM_LIBRARY_DYNAMIC_DEBUG)
set(SFML_LIBRARIES ${SFML_NETWORK_LIBRARY_DYNAMIC_DEBUG} ${SFML_SYSTEM_LIBRARY_DYNAMIC_DEBUG})
endif()
endif()
set(ENABLE_LINK_DEFAULT OFF)
if(SFML_FOUND)
set(ENABLE_LINK_DEFAULT ON)
endif()
endif()
option(ENABLE_LINK "Enable GBA linking functionality" ${ENABLE_LINK_DEFAULT})
# FFMpeg
set(FFMPEG_DEFAULT OFF)
set(FFMPEG_COMPONENTS AVCODEC AVFORMAT SWSCALE AVUTIL SWRESAMPLE)
set(FFMPEG_COMPONENT_VERSIONS AVCODEC>=58.18.100 AVFORMAT>=58.12.100 SWSCALE>=5.1.100 AVUTIL>=56.14.100 SWRESAMPLE>=3.1.100)
if(NOT TRANSLATIONS_ONLY AND NOT DEFINED ENABLE_FFMPEG OR ENABLE_FFMPEG)
set(FFMPEG_DEFAULT ON)
find_package(FFmpeg COMPONENTS ${FFMPEG_COMPONENTS})
# check versions, but only if pkgconfig is available
if(FFMPEG_FOUND AND PKG_CONFIG_FOUND AND NOT CMAKE_TOOLCHAIN_FILE MATCHES vcpkg)
foreach(component ${FFMPEG_COMPONENT_VERSIONS})
string(REPLACE ">=" ";" parts ${component})
list(GET parts 0 name)
list(GET parts 1 version)
if((NOT DEFINED ${name}_VERSION) OR ${name}_VERSION VERSION_LESS ${version})
set(FFMPEG_FOUND OFF)
endif()
endforeach()
endif()
if(NOT FFMPEG_FOUND)
set(FFMPEG_DEFAULT OFF)
endif()
endif()
option(ENABLE_FFMPEG "Enable ffmpeg A/V recording" ${FFMPEG_DEFAULT})
# Online Updates
set(ONLINEUPDATES_DEFAULT OFF)
if(DEFINED(UPSTREAM_RELEASE) AND UPSTREAM_RELEASE)
set(ONLINEUPDATES_DEFAULT ON)
endif()
option(ENABLE_ONLINEUPDATES "Enable online update checks" ${ONLINEUPDATES_DEFAULT})
option(HTTPS "Use https URL for winsparkle" ON)
# We generally don't want LTO when debugging because it makes linking slow
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(LTO_DEFAULT OFF)
else()
set(LTO_DEFAULT ON)
endif()
option(ENABLE_LTO "Compile with Link Time Optimization" ${LTO_DEFAULT})
option(ENABLE_GBA_LOGGING "Enable extended GBA logging" ON)
option(UPSTREAM_RELEASE "do some optimizations and release automation tasks" OFF)
if(WIN32)
# not yet implemented
option(ENABLE_DIRECT3D "Enable Direct3D rendering for the wxWidgets port" OFF)
set(XAUDIO2_DEFAULT ON)
if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
# TODO: We should update the XAudio headers to build with clang-cl. See
# https://github.com/visualboyadvance-m/visualboyadvance-m/issues/1021
set(XAUDIO2_DEFAULT OFF)
endif()
option(ENABLE_XAUDIO2 "Enable xaudio2 sound output for the wxWidgets port" ${XAUDIO2_DEFAULT})
endif()
set(ENABLE_FAUDIO_DEFAULT OFF)
find_package(FAudio QUIET)
if(FAudio_FOUND AND NOT (MINGW AND X86))
set(ENABLE_FAUDIO_DEFAULT ON)
endif()
option(ENABLE_FAUDIO "Enable FAudio sound output for the wxWidgets port" ${ENABLE_FAUDIO_DEFAULT})
option(ZIP_SUFFIX [=[suffix for release zip files, e.g. "-somebranch".zip]=] OFF)
# The SDL port can't be built without debugging support
if(NOT ENABLE_DEBUGGER AND ENABLE_SDL)
message(FATAL_ERROR "The SDL port can't be built without debugging support")
endif()
if(TRANSLATIONS_ONLY AND (ENABLE_SDL OR ENABLE_WX))
message(FATAL_ERROR "The SDL and wxWidgets ports can't be built when TRANSLATIONS_ONLY is enabled")
endif()
option(GPG_SIGNATURES "Create GPG signatures for release files" OFF)

View File

@@ -1,16 +0,0 @@
function(make_path_run_wrapper cmd target)
get_filename_component(name "${target}" NAME)
get_filename_component(cmd_resolved "${cmd}" REALPATH)
get_filename_component(base_name "${cmd_resolved}" NAME)
get_filename_component(dir_name "${cmd_resolved}" DIRECTORY)
set(source "${target}.c")
configure_file(src/gcc-wrap.c.in "${source}")
include(HostCompile)
host_compile("${source}" "${target}")
add_custom_target(generate_${name} DEPENDS "${CMAKE_BINARY_DIR}/${name}")
add_dependencies(generate generate_${name})
endfunction()

View File

@@ -1,9 +1,5 @@
if(POLICY CMP0012)
cmake_policy(SET CMP0012 NEW) # Saner if() behavior.
endif()
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW) # Use timestamps from archives.
if(TRANSLATIONS_ONLY)
return()
endif()
if(NOT DEFINED VCPKG_TARGET_TRIPLET)
@@ -79,7 +75,7 @@ endfunction()
function(vcpkg_check_git_status git_status)
# The VS vcpkg component cannot be written to without elevation.
if(NOT git_status EQUAL 0 AND NOT VCPKG_ROOT MATCHES "^C:/Program Files/Microsoft Visual Studio/")
if(NOT git_status EQUAL 0 AND NOT VCPKG_ROOT MATCHES "Visual Studio")
message(FATAL_ERROR "Error updating vcpkg from git, please make sure git for windows is installed correctly, it can be installed from Visual Studio components")
endif()
endfunction()
@@ -146,7 +142,7 @@ function(vcpkg_is_installed vcpkg_exe pkg_name pkg_ver pkg_triplet powershell ou
string(REPLACE "-" "." pkg_ver ${pkg_ver})
if(NOT DEFINED VCPKG_INSTALLED_COUNT)
if(VCPKG_ROOT MATCHES "^C:/Program Files/Microsoft Visual Studio/")
if(VCPKG_ROOT MATCHES "Visual Studio")
execute_process(
COMMAND ${powershell}
-executionpolicy bypass -noprofile
@@ -277,12 +273,6 @@ function(get_binary_packages vcpkg_exe)
FetchContent_Populate(vcpkg_binpkg)
endif()
if(WIN32)
find_program(powershell powershell.exe HINTS "/Windows/System32/WindowsPowerShell/v1.0" REQUIRED)
else()
find_program(powershell pwsh REQUIRED)
endif()
unset(to_install)
foreach(pkg ${binary_packages})
if(NOT pkg MATCHES "([^_]+)_([^_]+)_([^.]+)[.]zip")
@@ -292,7 +282,7 @@ function(get_binary_packages vcpkg_exe)
set(pkg_version ${CMAKE_MATCH_2})
set(pkg_triplet ${CMAKE_MATCH_3})
vcpkg_is_installed(${vcpkg_exe} ${pkg_name} ${pkg_version} ${pkg_triplet} ${powershell} pkg_installed)
vcpkg_is_installed(${vcpkg_exe} ${pkg_name} ${pkg_version} ${pkg_triplet} ${POWERSHELL} pkg_installed)
if(NOT pkg_installed)
list(APPEND to_install ${pkg})
@@ -325,7 +315,7 @@ function(get_binary_packages vcpkg_exe)
# -command "import-module ($env:USERPROFILE + '/source/repos/vcpkg-binpkg-prototype/vcpkg-binpkg.psm1'); vcpkg-instpkg ."
execute_process(
COMMAND ${powershell}
COMMAND ${POWERSHELL}
-executionpolicy bypass -noprofile
-command "import-module '${CMAKE_BINARY_DIR}/vcpkg-binpkg/vcpkg-binpkg.psm1'; vcpkg-instpkg ."
WORKING_DIRECTORY ${bin_pkgs_dir}
@@ -356,6 +346,9 @@ function(vcpkg_remove_optional_deps vcpkg_exe)
endfunction()
function(vcpkg_set_toolchain)
if(NOT DEFINED POWERSHELL)
message(FATAL_ERROR "Powershell is required to use vcpkg binaries.")
endif()
if(NOT DEFINED ENV{VCPKG_ROOT})
get_filename_component(preferred_root ${CMAKE_SOURCE_DIR}/../vcpkg ABSOLUTE)

View File

@@ -1,44 +0,0 @@
include(VbamFunctions)
function(add_compiler_flags)
foreach(var RELEASE DEBUG RELWITHDEBINFO MINSIZEREL)
set("CMAKE_CXX_FLAGS_${var}" "" CACHE STRING "MUST BE UNSET" FORCE)
set("CMAKE_CXX_FLAGS_${var}" "" PARENT_SCOPE)
set("CMAKE_C_FLAGS_${var}" "" CACHE STRING "MUST BE UNSET" FORCE)
set("CMAKE_C_FLAGS_${var}" "" PARENT_SCOPE)
endforeach()
# Set C and CXX flags if not already set.
foreach(flag ${ARGV})
foreach(var CMAKE_CXX_FLAGS CMAKE_C_FLAGS)
# Remove any duplicates first.
remove_dupes("${${var}}" "${var}")
string(FIND "${${var}}" "${flag}" found)
if(found EQUAL -1)
set("${var}" "${${var}} ${flag}" CACHE STRING "Compiler Flags" FORCE)
set("${var}" "${${var}} ${flag}" PARENT_SCOPE)
endif()
endforeach()
endforeach()
endfunction()
function(add_linker_flags)
# Set linker flags if not already set.
foreach(flag ${ARGV})
foreach(var EXE SHARED)
set(var "CMAKE_${var}_LINKER_FLAGS")
# Remove any duplicates first.
remove_dupes("${${var}}" "${var}")
string(FIND "${${var}}" "${flag}" found)
if(found EQUAL -1)
set("${var}" "${${var}} ${flag}" CACHE STRING "Linker Flags" FORCE)
set("${var}" "${${var}} ${flag}" PARENT_SCOPE)
endif()
endforeach()
endforeach()
endfunction()

View File

@@ -0,0 +1,37 @@
if(NOT ENABLE_ASAN)
return()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
check_cxx_compiler_flag(/fsanitize=address MSVC_ASAN_SUPPORTED)
if(MSVC_ASAN_SUPPORTED)
add_compile_options(/fsanitize=address)
add_compile_definitions(_DISABLE_VECTOR_ANNOTATION _DISABLE_STRING_ANNOTATION)
else()
message(WARNING "ASAN not available for the compiler, disabling.")
set(ENABLE_ASAN OFF)
return()
endif()
else()
# ASAN does not work on non-debug builds for GCC and Clang.
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
message(WARNING "ASAN requires debug build, set -DCMAKE_BUILD_TYPE=Debug, disabling.")
set(ENABLE_ASAN OFF)
return()
endif()
# It is necessary to modify the linker flagas for the compiler check to work.
set(BACKUP_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address")
check_cxx_compiler_flag(-fsanitize=address ASAN_SUPPORTED)
set(CMAKE_EXE_LINKER_FLAGS ${BACKUP_LINKER_FLAGS})
if(ASAN_SUPPORTED)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
else()
message(WARNING "ASAN not available for the compiler, disabling.")
set(ENABLE_ASAN OFF)
return()
endif()
endif()

View File

@@ -0,0 +1,74 @@
if(X86_32 OR X86_64)
add_compile_options(-mfpmath=sse -msse2)
endif()
if(UPSTREAM_RELEASE)
if(X86_64)
# Require and optimize for Core2 level support, tune for generic.
add_compile_options(-march=core2 -mtune=generic)
elseif(X86_32)
# Optimize for pentium-mmx and tune for generic for older builds.
add_compile_options(-march=pentium-mmx -mtune=generic)
endif()
endif()
# Common flags.
add_compile_options(
-pipe
$<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-copy>
-Wformat
-Wformat-security
-fdiagnostics-color=always
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-unused-command-line-argument)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-feliminate-unused-debug-types)
endif()
# check if ssp flags are supported.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
check_cxx_compiler_flag(-fstack-protector-strong STACK_PROTECTOR_SUPPORTED)
if(STACK_PROTECTOR_SUPPORTED)
add_compile_options(-fstack-protector-strong)
check_cxx_compiler_flag("--param ssp-buffer-size=4" SSP_BUFFER_SIZE_SUPPORTED)
if(SSP_BUFFER_SIZE_SUPPORTED)
add_compile_options(--param ssp-buffer-size=4)
endif()
endif()
endif()
if(NOT ENABLE_ASM) # inline asm is not allowed with -fPIC
add_compile_options(-fPIC)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-ggdb3 -Og -fno-omit-frame-pointer -Wall -Wextra)
else()
add_compile_options(-Ofast -fomit-frame-pointer)
endif()
# for some reason this is necessary
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
include_directories(/usr/local/include)
endif()
if(VBAM_STATIC)
if(APPLE)
add_link_options(-static-libstdc++)
else()
add_link_options(-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread)
endif()
endif()
# To support LTO, this must always fail.
add_compile_options(-Werror=odr -Werror=strict-aliasing)
add_link_options( -Werror=odr -Werror=strict-aliasing)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Werror=lto-type-mismatch)
add_link_options( -Werror=lto-type-mismatch)
endif()

View File

@@ -0,0 +1,10 @@
if (NOT MINGW)
return()
endif()
# this has to run after the toolchain is initialized.
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-include")
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
# Add Winsock as the last library linked because of broken link precedence.
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -lws2_32")

View File

@@ -0,0 +1,83 @@
# Set the runtime library properly.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:DEBUG>:Debug>" CACHE INTERNAL "")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# MSVC-specific flags (not supported by clang-cl).
add_compile_options(/nologo)
if (NOT CMAKE_GENERATOR MATCHES "Ninja")
# Multi-processor compilation does not work well with Ninja.
add_compile_options(/MP)
endif()
endif()
include_directories("${CMAKE_SOURCE_DIR}/dependencies/msvc")
add_compile_definitions(
_FORCENAMELESSUNION
WIN32_LEAN_AND_MEAN
WIN32
_WINDOWS
__STDC_LIMIT_MACROS
__STDC_CONSTANT_MACROS
_CRT_SECURE_NO_WARNINGS
_UNICODE
UNICODE
WINVER=0x0A00
NTDDI_VERSION=0x0A000007
NOMINMAX
)
add_compile_options(
/W4
/GR
/EHsc
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(_DEBUG)
add_compile_options(/Ob0 /Od /RTC1)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND NOT ENABLE_ASAN)
# Use Edit and Continue with MSVC.
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "EditAndContinue" CACHE STRING "" FORCE)
else()
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase" CACHE STRING "" FORCE)
endif()
else()
add_compile_options(/MT /Oi /Gy)
add_link_options(/OPT:REF /OPT:ICF)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase" CACHE STRING "" FORCE)
if (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
add_compile_options(/O1 /Ob1)
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_compile_options(/O2 /Ob1)
else()
add_compile_options(/O2)
endif()
endif()
if(CMAKE_VERSION VERSION_LESS "3.25")
# Backwards-compatible way of setting the /Z option.
if(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT STREQUAL "EditAndContinue")
add_compile_options(/ZI)
elseif(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT STREQUAL "ProgramDatabase")
add_compile_options(/Zi)
elseif(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT STREQUAL "Embedded")
add_compile_options(/Z7)
else()
message(FATAL_ERROR "Unknown value for CMAKE_MSVC_DEBUG_INFORMATION_FORMAT: ${CMAKE_MSVC_DEBUG_INFORMATION_FORMAT}")
endif()
endif()
set(CMAKE_RC_FLAGS "-c65001 /DWIN32" CACHE STRING "" FORCE)
# We need to explicitly set all of these to override the CMake defaults.
set(CMAKE_CXX_FLAGS "" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS "" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELEASE "" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_MINSIZEREL "" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_MINSIZEREL "" CACHE STRING "" FORCE)

126
cmake/Toolchain.cmake Normal file
View File

@@ -0,0 +1,126 @@
if(TRANSLATIONS_ONLY)
return()
endif()
# Compiler stuff
include(CheckCXXCompilerFlag)
include(ProcessorCount)
ProcessorCount(num_cpus)
if(ENABLE_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT LTO_SUPPORTED)
# MINGW64 does not support LTO
if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(LTO_SUPPORTED FALSE)
endif()
if(LTO_SUPPORTED)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(WARNING "LTO is not supported by the compiler, diasabling LTO")
set(ENABLE_LTO OFF)
endif()
endif()
# Output all binaries at top level
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
if(NOT HTTPS)
add_compile_definitions(NO_HTTPS)
endif()
if(ENABLE_GBA_LOGGING)
add_compile_definitions(GBA_LOGGING )
endif()
if(ENABLE_MMX)
add_compile_definitions(MMX)
endif()
if(NOT ENABLE_ONLINEUPDATES)
add_compile_definitions(NO_ONLINEUPDATES)
endif()
# The debugger is enabled by default
if(ENABLE_DEBUGGER)
add_compile_definitions(VBAM_ENABLE_DEBUGGER)
endif()
# The ASM core is disabled by default because we don't know on which platform we are
if(NOT ENABLE_ASM_CORE)
add_compile_definitions(C_CORE)
endif()
# Set up "src" and generated directory as a global include directory.
set(VBAM_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
include_directories(
${CMAKE_SOURCE_DIR}/src
${VBAM_GENERATED_DIR}
)
# C defines
add_compile_definitions(HAVE_NETINET_IN_H HAVE_ARPA_INET_H HAVE_ZLIB_H FINAL_VERSION SDL USE_OPENGL SYSCONF_INSTALL_DIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
add_compile_definitions(PKGDATADIR="${CMAKE_INSTALL_FULL_DATADIR}/vbam")
add_compile_definitions(__STDC_FORMAT_MACROS)
add_compile_definitions(LOCALEDIR="${LOCALEDIR}")
# Common compiler settings.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(DEBUG)
else()
add_compile_definitions(NDEBUG)
endif()
if(APPLE)
add_compile_definitions(MACHO)
elseif("${CMAKE_SYSTEM}" MATCHES "Linux")
add_compile_definitions(ELF)
endif()
if(X86_64)
add_compile_definitions(__AMD64__ __X86_64__)
endif()
# Enable ASAN if requested and supported.
include(Toolchain-asan)
# MINGW/MSYS-specific settings.
include(Toolchain-mingw)
# Toolchain-specific settings.
if(MSVC)
# This also includes clang-cl.
include(Toolchain-msvc)
else()
include(Toolchain-gcc-clang)
endif()
# Assembler flags.
if(ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS)
if(MSVC)
if(NOT EXISTS ${CMAKE_BINARY_DIR}/nuget.exe)
file(DOWNLOAD "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" ${CMAKE_BINARY_DIR}/nuget.exe)
endif()
execute_process(
COMMAND nuget.exe install nasm2 -OutputDirectory ${CMAKE_BINARY_DIR}/nuget
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
file(GLOB pkg ${CMAKE_BINARY_DIR}/nuget/nasm2*)
list(APPEND CMAKE_PROGRAM_PATH ${pkg}/tools)
endif()
enable_language(ASM_NASM)
set(ASM_ENABLED ON)
endif()
if(ASM_ENABLED)
string(REGEX REPLACE "<FLAGS>" "-I${CMAKE_SOURCE_DIR}/src/filters/hq/asm/ -O1 -w-orphan-labels" CMAKE_ASM_NASM_COMPILE_OBJECT ${CMAKE_ASM_NASM_COMPILE_OBJECT})
endif()

View File

@@ -2,12 +2,6 @@
# Update version in appcast.xml to latest tag.
# Commit web-data.
find_package(Git)
if(NOT GIT_FOUND)
message(FATAL_ERROR "git is required to update the appcast")
endif()
function(update_appcast)
if(UPDATE_APPCAST STREQUAL UNDO)
file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/web-data)
@@ -81,10 +75,12 @@ Ignore the following cmake error.
endwhile()
# Convert to UNIX line endings on Windows, just copy the file otherwise.
if(CMAKE_HOST_SYSTEM MATCHES Windows OR ((NOT DEFINED CMAKE_HOST_SYSTEM) AND WIN32))
if(NOT DEFINED POWERSHELL)
message(FATAL_ERROR "Powershell is required to convert line endings on Windows.")
endif()
execute_process(
COMMAND powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command [=[
COMMAND ${POWERSHELL} -NoLogo -NoProfile -ExecutionPolicy Bypass -Command [=[
$text = [IO.File]::ReadAllText("appcast.xml.work") -replace "`r`n", "`n"
[IO.File]::WriteAllText("appcast.xml", $text)
]=]

View File

@@ -1,103 +0,0 @@
# UseGCCBinUtilsWrappers.cmake
#
# Use gcc binutils wrappers such as gcc-ar, this may be necessary for LTO.
#
# To use:
#
# put a copy into your <project_root>/CMakeScripts/
#
# In your main CMakeLists.txt add the command:
#
# INCLUDE(UseGCCBinUtilsWrappers)
#
# BSD 2-Clause License
#
# Copyright (c) 2016, Rafael Kitover
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# only do this when compiling with gcc/g++
IF(NOT (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC))
RETURN()
ENDIF()
# first try appending -util to basename of compiler
STRING(REGEX MATCH "\\.(exe|EXE)$" GCC_EXE_SUFFIX ${CMAKE_C_COMPILER})
STRING(REGEX REPLACE "\\.(exe|EXE)$" "" GCC_BASENAME ${CMAKE_C_COMPILER})
SET(GCC_AR "${GCC_BASENAME}-ar${GCC_EXE_SUFFIX}")
SET(GCC_NM "${GCC_BASENAME}-nm${GCC_EXE_SUFFIX}")
SET(GCC_RANLIB "${GCC_BASENAME}-ranlib${GCC_EXE_SUFFIX}")
# if that does not work, try looking for gcc-util in the compiler directory,
# and failing that in the PATH
GET_FILENAME_COMPONENT(GCC_DIRNAME ${CMAKE_C_COMPILER} DIRECTORY)
IF(NOT EXISTS ${GCC_AR})
UNSET(GCC_AR)
FIND_PROGRAM(GCC_AR NAMES gcc-ar gcc-ar.exe GCC-AR.EXE HINTS ${GCC_DIRNAME})
ENDIF()
IF(NOT EXISTS ${GCC_NM})
UNSET(GCC_NM)
FIND_PROGRAM(GCC_NM NAMES gcc-nm gcc-nm.exe GCC-NM.EXE HINTS ${GCC_DIRNAME})
ENDIF()
IF(NOT EXISTS ${GCC_RANLIB})
UNSET(GCC_RANLIB)
FIND_PROGRAM(GCC_RANLIB NAMES gcc-ranlib gcc-ranlib.exe GCC-RANLIB.EXE HINTS ${GCC_DIRNAME})
ENDIF()
INCLUDE(PathRun)
IF(EXISTS ${GCC_AR})
MESSAGE("-- Found gcc-ar: ${GCC_AR}")
SET(target "${CMAKE_BINARY_DIR}/gcc-ar-wrap")
MAKE_PATH_RUN_WRAPPER("${GCC_AR}" "${target}")
SET(CMAKE_AR "${target}")
ENDIF()
IF(EXISTS ${GCC_NM})
MESSAGE("-- Found gcc-nm: ${GCC_NM}")
SET(target "${CMAKE_BINARY_DIR}/gcc-nm-wrap")
MAKE_PATH_RUN_WRAPPER("${GCC_NM}" "${target}")
SET(CMAKE_NM "${target}")
ENDIF()
IF(EXISTS ${GCC_RANLIB})
MESSAGE("-- Found gcc-ranlib: ${GCC_RANLIB}")
SET(target "${CMAKE_BINARY_DIR}/gcc-ranlib-wrap")
MAKE_PATH_RUN_WRAPPER("${GCC_RANLIB}" "${target}")
SET(CMAKE_RANLIB "${target}")
ENDIF()
FOREACH(VAR "GCC_AR" "GCC_NM" "GCC_RANLIB" "GCC_DIRNAME" "GCC_BASENAME" "GCC_EXE_SUFFIX" "target")
UNSET(${VAR})
ENDFOREACH()

View File

@@ -1,48 +1,3 @@
# From: https://stackoverflow.com/a/41416298/262458
function(REMOVE_DUPES ARG_STR OUTPUT)
set(ARG_LIST ${ARG_STR})
separate_arguments(ARG_LIST)
list(REMOVE_DUPLICATES ARG_LIST)
string (REGEX REPLACE "([^\\]|^);" "\\1 " _TMP_STR "${ARG_LIST}")
string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
endfunction()
# From: https://stackoverflow.com/a/7216542
function(JOIN VALUES GLUE OUTPUT)
string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}")
string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
endfunction()
# On MSYS2 transform wx lib paths to native paths for Ninja.
function(normalize_wx_paths)
if(MSYS)
set(libs "")
foreach(lib ${wxWidgets_LIBRARIES})
if(NOT lib MATCHES "^(-Wl,|-mwindows$|-pipe$)")
if(lib MATCHES "^/")
cygpath(lib "${lib}")
endif()
if(VBAM_STATIC AND lib MATCHES "^-l(wx.*|jpeg|tiff|jbig|lzma|expat)$")
cygpath(lib "$ENV{MSYSTEM_PREFIX}/lib/lib${CMAKE_MATCH_1}.a")
endif()
list(APPEND libs "${lib}")
endif()
endforeach()
set(wxWidgets_LIBRARIES "${libs}" PARENT_SCOPE)
endif()
endfunction()
macro(cleanup_wx_vars)
if(wxWidgets_CXX_FLAGS)
list(REMOVE_ITEM wxWidgets_CXX_FLAGS -fpermissive)
endif()
endmacro()
function(cygpath var path)
execute_process(
@@ -157,5 +112,3 @@ function(find_wx_util var util)
set(${var} ${util} PARENT_SCOPE)
endforeach()
endfunction()
# vim:sw=4 sts et:

View File

@@ -1,175 +0,0 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
doctest
-----
This module defines a function to help use the doctest test framework.
The :command:`doctest_discover_tests` discovers tests by asking the compiled test
executable to enumerate its tests. This does not require CMake to be re-run
when tests change. However, it may not work in a cross-compiling environment,
and setting test properties is less convenient.
This command is intended to replace use of :command:`add_test` to register
tests, and will create a separate CTest test for each doctest test case. Note
that this is in some cases less efficient, as common set-up and tear-down logic
cannot be shared by multiple test cases executing in the same instance.
However, it provides more fine-grained pass/fail information to CTest, which is
usually considered as more beneficial. By default, the CTest test name is the
same as the doctest name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
.. command:: doctest_discover_tests
Automatically add tests with CTest by querying the compiled test executable
for available tests::
doctest_discover_tests(target
[TEST_SPEC arg1...]
[EXTRA_ARGS arg1...]
[WORKING_DIRECTORY dir]
[TEST_PREFIX prefix]
[TEST_SUFFIX suffix]
[PROPERTIES name1 value1...]
[TEST_LIST var]
)
``doctest_discover_tests`` sets up a post-build command on the test executable
that generates the list of tests by parsing the output from running the test
with the ``--list-test-cases`` argument. This ensures that the full
list of tests is obtained. Since test discovery occurs at build time, it is
not necessary to re-run CMake when the list of tests changes.
However, it requires that :prop_tgt:`CROSSCOMPILING_EMULATOR` is properly set
in order to function in a cross-compiling environment.
Additionally, setting properties on tests is somewhat less convenient, since
the tests are not available at CMake time. Additional test properties may be
assigned to the set of tests as a whole using the ``PROPERTIES`` option. If
more fine-grained test control is needed, custom content may be provided
through an external CTest script using the :prop_dir:`TEST_INCLUDE_FILES`
directory property. The set of discovered tests is made accessible to such a
script via the ``<target>_TESTS`` variable.
The options are:
``target``
Specifies the doctest executable, which must be a known CMake executable
target. CMake will substitute the location of the built executable when
running the test.
``TEST_SPEC arg1...``
Specifies test cases, wildcarded test cases, tags and tag expressions to
pass to the doctest executable with the ``--list-test-cases`` argument.
``EXTRA_ARGS arg1...``
Any extra arguments to pass on the command line to each test case.
``WORKING_DIRECTORY dir``
Specifies the directory in which to run the discovered test cases. If this
option is not provided, the current binary directory is used.
``TEST_PREFIX prefix``
Specifies a ``prefix`` to be prepended to the name of each discovered test
case. This can be useful when the same test executable is being used in
multiple calls to ``doctest_discover_tests()`` but with different
``TEST_SPEC`` or ``EXTRA_ARGS``.
``TEST_SUFFIX suffix``
Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of
every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may
be specified.
``PROPERTIES name1 value1...``
Specifies additional properties to be set on all tests discovered by this
invocation of ``doctest_discover_tests``.
``TEST_LIST var``
Make the list of tests available in the variable ``var``, rather than the
default ``<target>_TESTS``. This can be useful when the same test
executable is being used in multiple calls to ``doctest_discover_tests()``.
Note that this variable is only available in CTest.
#]=======================================================================]
#------------------------------------------------------------------------------
function(doctest_discover_tests TARGET)
cmake_parse_arguments(
""
""
"TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST"
"TEST_SPEC;EXTRA_ARGS;PROPERTIES"
${ARGN}
)
if(NOT _WORKING_DIRECTORY)
set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endif()
if(NOT _TEST_LIST)
set(_TEST_LIST ${TARGET}_TESTS)
endif()
## Generate a unique name based on the extra arguments
string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS}")
string(SUBSTRING ${args_hash} 0 7 args_hash)
# Define rule to generate test list for aforementioned test executable
set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake")
set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake")
get_property(crosscompiling_emulator
TARGET ${TARGET}
PROPERTY CROSSCOMPILING_EMULATOR
)
add_custom_command(
TARGET ${TARGET} POST_BUILD
BYPRODUCTS "${ctest_tests_file}"
COMMAND "${CMAKE_COMMAND}"
-D "TEST_TARGET=${TARGET}"
-D "TEST_EXECUTABLE=$<TARGET_FILE:${TARGET}>"
-D "TEST_EXECUTOR=${crosscompiling_emulator}"
-D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}"
-D "TEST_SPEC=${_TEST_SPEC}"
-D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}"
-D "TEST_PROPERTIES=${_PROPERTIES}"
-D "TEST_PREFIX=${_TEST_PREFIX}"
-D "TEST_SUFFIX=${_TEST_SUFFIX}"
-D "TEST_LIST=${_TEST_LIST}"
-D "CTEST_FILE=${ctest_tests_file}"
-P "${_DOCTEST_DISCOVER_TESTS_SCRIPT}"
VERBATIM
)
file(WRITE "${ctest_include_file}"
"if(EXISTS \"${ctest_tests_file}\")\n"
" include(\"${ctest_tests_file}\")\n"
"else()\n"
" add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n"
"endif()\n"
)
if(NOT CMAKE_VERSION VERSION_LESS 3.10)
# Add discovered tests to directory TEST_INCLUDE_FILES
set_property(DIRECTORY
APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}"
)
else()
# Add discovered tests as directory TEST_INCLUDE_FILE if possible
get_property(test_include_file_set DIRECTORY PROPERTY TEST_INCLUDE_FILE SET)
if(NOT ${test_include_file_set})
set_property(DIRECTORY
PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}"
)
else()
message(FATAL_ERROR
"Cannot set more than one TEST_INCLUDE_FILE"
)
endif()
endif()
endfunction()
###############################################################################
set(_DOCTEST_DISCOVER_TESTS_SCRIPT
${CMAKE_CURRENT_LIST_DIR}/doctestAddTests.cmake
)

View File

@@ -1,81 +0,0 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
set(prefix "${TEST_PREFIX}")
set(suffix "${TEST_SUFFIX}")
set(spec ${TEST_SPEC})
set(extra_args ${TEST_EXTRA_ARGS})
set(properties ${TEST_PROPERTIES})
set(script)
set(suite)
set(tests)
function(add_command NAME)
set(_args "")
foreach(_arg ${ARGN})
if(_arg MATCHES "[^-./:a-zA-Z0-9_]")
set(_args "${_args} [==[${_arg}]==]") # form a bracket_argument
else()
set(_args "${_args} ${_arg}")
endif()
endforeach()
set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE)
endfunction()
# Run test executable to get list of available tests
if(NOT EXISTS "${TEST_EXECUTABLE}")
message(FATAL_ERROR
"Specified test executable '${TEST_EXECUTABLE}' does not exist"
)
endif()
if("${spec}" MATCHES .)
set(spec "--test-case=${spec}")
endif()
execute_process(
COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-test-cases
OUTPUT_VARIABLE output
RESULT_VARIABLE result
)
if(NOT ${result} EQUAL 0)
message(FATAL_ERROR
"Error running test executable '${TEST_EXECUTABLE}':\n"
" Result: ${result}\n"
" Output: ${output}\n"
)
endif()
string(REPLACE "\n" ";" output "${output}")
# Parse output
foreach(line ${output})
if("${line}" STREQUAL "===============================================================================" OR "${line}" MATCHES [==[^\[doctest\] ]==])
continue()
endif()
set(test ${line})
# use escape commas to handle properly test cases with commas inside the name
string(REPLACE "," "\\," test_name ${test})
# ...and add to script
add_command(add_test
"${prefix}${test}${suffix}"
${TEST_EXECUTOR}
"${TEST_EXECUTABLE}"
"--test-case=${test_name}"
${extra_args}
)
add_command(set_tests_properties
"${prefix}${test}${suffix}"
PROPERTIES
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
${properties}
)
list(APPEND tests "${prefix}${test}${suffix}")
endforeach()
# Create a list of all discovered tests, which users may use to e.g. set
# properties on the tests
add_command(set ${TEST_LIST} ${tests})
# Write CTest script
file(WRITE "${CTEST_FILE}" "${script}")

View File

@@ -2,7 +2,7 @@ with import <nixpkgs> {};
stdenv.mkDerivation {
name = "visualboyadvance-m";
buildInputs = if stdenv.isDarwin then
[ ninja cmake gcc nasm gettext pkg-config zip sfml zlib openal ffmpeg wxGTK32 SDL2 pcre pcre2 darwin.apple_sdk.frameworks.IOKit darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa darwin.apple_sdk.frameworks.QuartzCore darwin.apple_sdk.frameworks.AudioToolbox darwin.apple_sdk.frameworks.OpenGL darwin.apple_sdk.frameworks.OpenAL ]
[ ninja cmake gcc nasm faudio gettext libintl pkg-config zip sfml zlib openal ffmpeg wxGTK32 SDL2 pcre pcre2 darwin.apple_sdk.frameworks.System darwin.apple_sdk.frameworks.IOKit darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa darwin.apple_sdk.frameworks.QuartzCore darwin.apple_sdk.frameworks.AudioToolbox darwin.apple_sdk.frameworks.OpenGL darwin.apple_sdk.frameworks.OpenAL llvmPackages_latest.clang llvmPackages_latest.bintools ]
else
[ ninja cmake gcc nasm gettext pkg-config zip sfml zlib openal ffmpeg wxGTK32 mesa glfw SDL2 gtk3-x11 pcre pcre2 util-linuxMinimal libselinux libsepol libthai libdatrie xorg.libXdmcp xorg.libXtst libxkbcommon epoxy dbus at-spi2-core ];
[ ninja cmake gcc nasm faudio gettext libintl pkg-config zip sfml zlib openal ffmpeg wxGTK32 libGL libGLU glfw SDL2 gtk3-x11 pcre pcre2 util-linuxMinimal libselinux libsepol libthai libdatrie xorg.libXdmcp xorg.libXtst libxkbcommon epoxy dbus at-spi2-core ];
}

View File

@@ -2,59 +2,27 @@
Developer Information File
==========================
Known preprocessor switches:
- SDL: Defined for the SDL version
- GBA_LOGGING: Enables logging for the GBA core
- FINAL_VERSION: Defined for release versions, disables additional GBA logging and completely disables GB logging. Increases the amount of CPU cycles being emulated in one go.
- BKPT_SUPPORT
- VBAM_ENABLE_DEBUGGER: Enable remote debugging support
- MMX: Enable MMX instruction set
- NO_ASM: Use C++ version of hq3x/4x filters
- RGB555: Use 16bit colors with 5bit green instead of 6bit green in hq3x/4x filters (C++ version)
- NO_OGL: Exclude OpenGL code
- NO_D3D: Exclude Direct3D code
- NO_OAL: Exclude OpenAL code
- NO_XAUDIO2: Exclude XAudio2 code (the XAudio2 interface is DirectSound's successor)
- VBAM_ENABLE_XAUDIO2: Enable XAudio2 code (the XAudio2 interface is DirectSound's successor)
- VBAM_ENABLE_FAUDIO: Enable FAudio code (the FAudio interface is an open source multiplatform re-implementation of XAudio2)
- NO_LINK: Exclude linking code (joybus, multilink, ...)
- WIN64: This macro is only defined for 64 bit builds
Download locations:
NASM: http://nasm.us/
DirectX SDK: http://msdn.microsoft.com/en-us/xna/aa937788.aspx
OpenAL SDK: http://connect.creativelabs.com/openal/default.aspx
OpenGL files: http://www.opengl.org/registry/
zlib: http://zlib.net/
libpng: http://libpng.org/pub/png/libpng.html
You can find pre-built versions of zlib & libpng at:
http://spacy51.sp.funpic.de/VBA-M/libs/
Just extract them somewhere and point Visual C++ 2008 to the include & lib folders.
They are built with the static C runtime (this is what the release builds use).
###########################
# --- Build Systems --- #
###########################
===Win32/MFC===
This is the full-featured Windows build using the MFC GUI.
The project files are located in /project/vc2008_mfc (VBA2008.sln) and /project/vs2010_mfc (VBA2010.sln).
Anyone distributing builds should be using MSVC 2010 SP1, the unpatched release has a bug where it applies SSE2 updates to mov and other instructions resulting in illegal instruction errors on cpu's only supporting SSE.
You also have to install Microsoft's DirectX SDK for Direct3D, DirectInput & XAudio2.
If you want to enable OpenAL sound output, install the OpenAL SDK. If you do not want it, add NO_OAL to the VBA-M project's preprocessor definitions.
SubWCRev.exe is used to append the svn versioning to the output executable, this as of TortoiseSVN 1.7, is only available by installing TortoiseSVN.
All other dependencies for MSVC builds may be found in the ../dependencies directory (above /trunk).
Normally, Windows users will want to checkout the root of the repository instead of just the trunk directory. Afterwards, simply opening the .sln of choice, setting preprocessor definitions, and hitting build is all that's required.
===*nix/GTK===
===src/sdl===
This is the standard build configuration on non-Windows.
Running cmake will inform you of any packages you need to install.
===*/wxw===
The wxWidgets interface is an in-development frontend meant to be more cross-platform friendly than MFC and GTK.
===src/wx===
The wxWidgets interface is an in-development frontend meant to be more cross-platform friendly than MFC and SDL.
Running cmake will inform you of any packages you need to install.
NOTE: In addition to what cmake currently checks for, you will also need the wxrc tool and libgdiplus.

View File

@@ -1,46 +0,0 @@
#Do not use this file directly. Always use the top level CMakeLists.txt file
#File extractors so the user doesn't have to extract the rom before playing it
# Source files definition
SET(SRC_FEX
7z_C/7zAlloc.c
7z_C/7zBuf.c
7z_C/7zCrc.c
7z_C/7zCrcOpt.c
7z_C/7zDec.c
7z_C/7zIn.c
7z_C/7zStream.c
7z_C/Bcj2.c
7z_C/Bra86.c
7z_C/Bra.c
7z_C/CpuArch.c
7z_C/Lzma2Dec.c
7z_C/LzmaDec.c
7z_C/Ppmd7.c
7z_C/Ppmd7Dec.c
fex/Binary_Extractor.cpp
fex/blargg_common.cpp
fex/blargg_errors.cpp
fex/Data_Reader.cpp
fex/fex.cpp
fex/File_Extractor.cpp
fex/Gzip_Extractor.cpp
fex/Gzip_Reader.cpp
fex/Rar_Extractor.cpp
fex/Zip7_Extractor.cpp
fex/Zip_Extractor.cpp
fex/Zlib_Inflater.cpp
)
INCLUDE_DIRECTORIES(
.
${ZLIB_INCLUDE_DIRS}
)
ADD_LIBRARY(
fex
STATIC
${SRC_FEX}
)
add_dependencies(fex generate)

View File

@@ -1,7 +1,6 @@
#!/bin/sh
CMAKE=cmake
ENABLE_OPENAL=1
ENABLE_FFMPEG=1
main() {
@@ -25,10 +24,6 @@ check_command_line_args() {
usage
quit 0
;;
--no-openal)
ENABLE_OPENAL=
shift
;;
--no-ffmpeg)
ENABLE_FFMPEG=
shift
@@ -355,9 +350,8 @@ debian_installdeps() {
;;
esac
pkgs="build-essential g++ nasm cmake ccache gettext zlib1g-dev libgl1-mesa-dev libgettextpo-dev libsdl2-dev $sdl_lib libglu1-mesa-dev libglu1-mesa libgles2-mesa-dev libsfml-dev $sfml_libs $glew_lib $wx_libs libgtk2.0-dev libgtk-3-dev ccache zip ninja-build"
pkgs="build-essential g++ nasm cmake ccache gettext zlib1g-dev libgl1-mesa-dev libgettextpo-dev libsdl2-dev $sdl_lib libglu1-mesa-dev libglu1-mesa libgles2-mesa-dev libsfml-dev $sfml_libs $glew_lib $wx_libs libgtk2.0-dev libgtk-3-dev ccache zip ninja-build libopenal-dev"
[ -n "$ENABLE_OPENAL" ] && pkgs="$pkgs libopenal-dev"
[ -n "$ENABLE_FFMPEG" ] && pkgs="$pkgs libavcodec-dev libavformat-dev libswscale-dev libavutil-dev $libswresample_dev"
check sudo apt-get -qy install $pkgs
@@ -407,8 +401,7 @@ debian_installdeps() {
fi
fi
deps="gcc zlib ffmpeg gettext sdl2 sfml openal wxwidgets"
[ -n "$ENABLE_OPENAL" ] && deps="$deps openal"
deps="gcc zlib ffmpeg gettext sdl2 sfml openal wxwidgets openal"
[ -n "$ENABLE_FFMPEG" ] && deps="$deps ffmpeg"
set --
@@ -510,9 +503,6 @@ fedora_installdeps() {
*ffmpeg*)
[ -z "$ENABLE_FFMPEG" ] && continue
;;
*openal*)
[ -z "$ENABLE_OPENAL" ] && continue
;;
esac
pkg_arch=
@@ -601,15 +591,9 @@ fedora_installdeps() {
;;
esac
# install static deps
for pkg in zlib gettext SDL2 wxWidgets3; do
for pkg in zlib gettext SDL2 wxWidgets3 openal-soft; do
set -- "$@" "${target}-${pkg}-static"
done
# install deps that are not available as static
if [ -n "$ENABLE_OPENAL" ]; then
for pkg in openal-soft; do
set -- "$@" "${target}-${pkg}"
done
fi
# get the necessary win32 headers
git submodule update --init --remote --recursive
@@ -707,9 +691,6 @@ rhel_installdeps() {
*ffmpeg*)
[ -z "$ENABLE_FFMPEG" ] && continue
;;
*openal*)
[ -z "$ENABLE_OPENAL" ] && continue
;;
esac
if [ -n "$amd64" ]; then
@@ -790,15 +771,9 @@ rhel_installdeps() {
;;
esac
# install static deps
for pkg in zlib gettext SDL2 wxWidgets; do
for pkg in zlib gettext SDL2 wxWidgets openal-soft; do
set -- "$@" "${target}-${pkg}-static"
done
# install deps that are not available as static
if [ -n "$ENABLE_OPENAL" ]; then
for pkg in openal-soft; do
set -- "$@" "${target}-${pkg}"
done
fi
# get the necessary win32 headers
git submodule update --init --remote --recursive
@@ -824,9 +799,8 @@ suse_installdeps() {
tools="make cmake ccache nasm gettext-tools pkg-config ccache zip sfml2-devel ninja"
libs="gcc gcc-c++ libSDL2-devel wxWidgets-3_0-devel" # ffmpeg-devel
libs="gcc gcc-c++ libSDL2-devel wxWidgets-3_0-devel openal-soft-devel" # ffmpeg-devel
[ -n "$ENABLE_OPENAL" ] && libs="$libs openal-soft-devel"
# ffmpeg requires packman repos
if [ "$target" = m32 ]; then
@@ -894,9 +868,8 @@ archlinux_installdeps() {
$pacman -Q gtk3-classic >/dev/null 2>&1 && gtk=gtk3-classic
libs="zlib mesa gettext sdl2 wxgtk3 $gtk sfml"
libs="zlib mesa gettext sdl2 wxgtk3 $gtk sfml openal"
[ -n "$ENABLE_OPENAL" ] && libs="$libs openal"
[ -n "$ENABLE_FFMPEG" ] && libs="$libs ffmpeg"
if [ -z "$target" -o "$target" = m32 ]; then
@@ -991,9 +964,7 @@ EOF
fi
done
deps="zlib gettext pkg-config sdl2 wxmsw"
[ -n "$ENABLE_OPENAL" ] && deps="$deps openal"
deps="zlib gettext pkg-config sdl2 wxmsw openal"
# and the actual deps
for p in $deps; do
@@ -1024,9 +995,7 @@ solus_installdeps() {
check sudo eopkg -y install -c system.devel
check sudo eopkg -y install git ccache ninja
set -- sdl2-devel wxwidgets-devel libgtk-2-devel libgtk-3-devel libglu-devel
[ -n "$ENABLE_OPENAL" ] && set -- "$@" openal-soft-devel
set -- sdl2-devel wxwidgets-devel libgtk-2-devel libgtk-3-devel libglu-devel openal-soft-devel
if [ -n "$amd64" -a "$target" = m32 ]; then
info_msg 'Calculating dependencies, this will take a while..'
@@ -1102,14 +1071,13 @@ gentoo_installdeps() {
sys-devel/binutils \
media-libs/libsdl2 \
media-libs/libsfml \
media-libs/openal \
x11-libs/wxGTK:$wx_slot \
sys-libs/zlib \
dev-util/pkgconf \
dev-lang/nasm \
dev-build/ninja"
[ -n "$ENABLE_OPENAL" ] && ebuilds="$ebuilds media-libs/openal"
[ -n "$ENABLE_FFMPEG" ] && ebuilds="$ebuilds media-video/ffmpeg"
check sudo emerge -vna $ebuilds
@@ -1139,10 +1107,10 @@ windows_installdeps() {
case "$target" in
*clang*)
pkgs="lldb"
pkgs="lldb clang"
;;
*)
pkgs="$pkgs gcc gcc-libs gcc-libgfortran"
pkgs="gcc gcc-libs gcc-libgfortran"
;;
esac
@@ -1152,9 +1120,14 @@ windows_installdeps() {
;;
esac
pkgs="$pkgs SDL2 sfml wxWidgets3.2 zlib binutils cmake crt-git extra-cmake-modules headers-git make pkgconf tools-git windows-default-manifest libmangle-git ninja gdb ccache"
pkgs="$pkgs SDL2 sfml FAudio wxWidgets3.2 zlib binutils cmake crt-git headers-git make pkgconf tools-git windows-default-manifest libmangle-git ninja gdb ccache openal"
case "$target" in
*x86_64)
pkgs="$pkgs extra-cmake-modules"
;;
esac
[ -n "$ENABLE_OPENAL" ] && pkgs="$pkgs openal"
[ -n "$ENABLE_FFMPEG" ] && pkgs="$pkgs ffmpeg"
set --
@@ -1219,7 +1192,7 @@ brew_installdeps() {
check brew -v update
brews="nasm cmake ccache gettext pkg-config sdl2 wxwidgets ccache ninja"
brews="nasm cmake ccache gettext pkg-config sdl2 wxwidgets faudio ccache ninja zlib"
[ -n "$ENABLE_FFMPEG" ] && brews="$brews ffmpeg"

View File

@@ -1,4 +0,0 @@
IF(ENABLE_WX)
add_subdirectory(wxvbam)
ENDIF(ENABLE_WX)

View File

@@ -1,8 +1,7 @@
if(NOT TRANSLATIONS_ONLY AND NOT ENABLE_WX)
return()
endif()
file(GLOB po_files "${CMAKE_CURRENT_SOURCE_DIR}/*.po")
gettext_create_translations(
wxvbam.pot
${po_files}
)
add_dependencies(visualboyadvance-m translations)
gettext_create_translations(wxvbam.pot ${po_files})

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

3886
po/wxvbam/ja_JP.po Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

3820
po/wxvbam/ur_PK.po Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -51,7 +51,6 @@ parts:
- libopenal-dev
- libwxgtk3.0-gtk3-dev
cmake-parameters:
- -DENABLE_OPENAL=ON
- -DENABLE_SDL=OFF
- -DCMAKE_INSTALL_PREFIX=/usr

View File

@@ -1,29 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __AUTOBUILD_H__
#define __AUTOBUILD_H__
#include "version.h"
// change the FALSE to TRUE for autoincrement of build number
#define INCREMENT_VERSION FALSE
#define FILEVER 2, 0, 0, 600
#define PRODUCTVER 2, 0, 0, 600
#define STRFILEVER "2, 0, 0, 600\0"
#define STRPRODUCTVER "2, 0, 0, 600\0"
#endif //__AUTOBUILD_H__

View File

@@ -1,910 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#ifndef _WIN32
#include <sys/stat.h>
#include <unistd.h>
#else // _WIN32
#include <direct.h>
#include <io.h>
#endif // _WIN32
#include <zlib.h>
#define STB_IMAGE_IMPLEMENTATION
extern "C" {
#include "stb_image.h"
}
#define STBI_MSC_SECURE_CRT
#define STB_IMAGE_WRITE_IMPLEMENTATION
extern "C" {
#include "stb_image_write.h"
}
#include "NLS.h"
#include "System.h"
#include "Util.h"
#include "common/Port.h"
#include "gba/Flash.h"
#include "gba/GBA.h"
#include "gba/Globals.h"
#include "gba/RTC.h"
#include "fex/fex.h"
extern "C" {
#include "common/memgzio.h"
}
#include "gb/gbGlobals.h"
#include "gba/gbafilter.h"
#ifndef _MSC_VER
#define _stricmp strcasecmp
#endif // ! _MSC_VER
extern int systemColorDepth;
extern int systemRedShift;
extern int systemGreenShift;
extern int systemBlueShift;
extern uint16_t systemColorMap16[0x10000];
extern uint32_t systemColorMap32[0x10000];
static int(ZEXPORT *utilGzWriteFunc)(gzFile, const voidp, unsigned int) = NULL;
static int(ZEXPORT *utilGzReadFunc)(gzFile, voidp, unsigned int) = NULL;
static int(ZEXPORT *utilGzCloseFunc)(gzFile) = NULL;
static z_off_t(ZEXPORT *utilGzSeekFunc)(gzFile, z_off_t, int) = NULL;
#define MAX_CART_SIZE 0x8000000 // 128MB
bool FileExists(const char *filename)
{
#ifdef _WIN32
return (_access(filename, 0) != -1);
#else
struct stat buffer;
return (stat(filename, &buffer) == 0);
#endif
}
#ifdef _WIN32
#include <windows.h>
wchar_t* utf8ToUtf16(const char *utf8)
{
wchar_t *utf16 = nullptr;
size_t size = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL , 0);
if (size == 0) return nullptr; // error
utf16 = new wchar_t[size];
size = MultiByteToWideChar(CP_UTF8, 0, utf8 , -1, utf16, size);
if (size == 0) {
delete[] utf16;
return nullptr; // error
}
return utf16;
}
#endif // _WIN32
FILE* utilOpenFile(const char *filename, const char *mode)
{
FILE *f = NULL;
#ifdef _WIN32
wchar_t *wfilename = utf8ToUtf16(filename);
if (!wfilename) return nullptr;
wchar_t *wmode = utf8ToUtf16(mode);
if (!wmode) {
delete[] wfilename;
return nullptr;
}
f = _wfopen(wfilename, wmode);
delete[] wfilename;
delete[] wmode;
#else
f = fopen(filename, mode);
#endif // _WIN32
return f;
}
// Get user-specific config dir manually.
// apple: ~/Library/Application Support/
// windows: %APPDATA%/
// unix: ${XDG_CONFIG_HOME:-~/.config}/
std::string get_xdg_user_config_home()
{
std::string path;
#ifdef __APPLE__
std::string home(getenv("HOME"));
path = home + "/Library/Application Support";
#elif _WIN32
char *app_data_env = getenv("LOCALAPPDATA");
if (!app_data_env) app_data_env = getenv("APPDATA");
std::string app_data(app_data_env);
path = app_data;
#else // Unix
char *xdg_var = getenv("XDG_CONFIG_HOME");
if (!xdg_var || !*xdg_var)
{
std::string xdg_default(getenv("HOME"));
path = xdg_default + "/.config";
}
else
{
path = xdg_var;
}
#endif
return path + FILE_SEP;
}
// Get user-specific data dir manually.
// apple: ~/Library/Application Support/
// windows: %APPDATA%/
// unix: ${XDG_DATA_HOME:-~/.local/share}/
std::string get_xdg_user_data_home()
{
std::string path;
#ifdef __APPLE__
std::string home(getenv("HOME"));
path = home + "/Library/Application Support";
#elif _WIN32
char *app_data_env = getenv("LOCALAPPDATA");
if (!app_data_env) app_data_env = getenv("APPDATA");
std::string app_data(app_data_env);
path = app_data;
#else // Unix
char *xdg_var = getenv("XDG_DATA_HOME");
if (!xdg_var || !*xdg_var)
{
std::string xdg_default(getenv("HOME"));
path = xdg_default + "/.local/share";
}
else
{
path = xdg_var;
}
#endif
return path + FILE_SEP;
}
void utilReadScreenPixels(uint8_t *dest, int w, int h)
{
uint8_t *b = dest;
int sizeX = w;
int sizeY = h;
switch (systemColorDepth) {
case 16: {
uint16_t *p = (uint16_t *)(pix + (w + 2) * 2); // skip first black line
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
uint16_t v = *p++;
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B
}
p++; // skip black pixel for filters
p++; // skip black pixel for filters
}
} break;
case 24: {
uint8_t *pixU8 = (uint8_t *)pix;
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
if (systemRedShift < systemBlueShift) {
*b++ = *pixU8++; // R
*b++ = *pixU8++; // G
*b++ = *pixU8++; // B
} else {
int blue = *pixU8++;
int green = *pixU8++;
int red = *pixU8++;
*b++ = red;
*b++ = green;
*b++ = blue;
}
}
}
} break;
case 32: {
uint32_t *pixU32 = (uint32_t *)(pix + 4 * (w + 1));
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
uint32_t v = *pixU32++;
*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
}
pixU32++;
}
} break;
}
}
#define CHANNEL_NUM 3 // RGB
bool utilWritePNGFile(const char *fileName, int w, int h, uint8_t *pix)
{
uint8_t *writeBuffer = new uint8_t[w * h * CHANNEL_NUM];
uint8_t *b = writeBuffer;
int sizeX = w;
int sizeY = h;
switch (systemColorDepth)
{
case 16: {
uint16_t *p = (uint16_t *)(pix + (w + 2) * 2); // skip first black line
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
uint16_t v = *p++;
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B
}
p++; // skip black pixel for filters
p++; // skip black pixel for filters
}
} break;
case 24: {
uint8_t *pixU8 = (uint8_t *)pix;
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
if (systemRedShift < systemBlueShift) {
*b++ = *pixU8++; // R
*b++ = *pixU8++; // G
*b++ = *pixU8++; // B
} else {
int blue = *pixU8++;
int green = *pixU8++;
int red = *pixU8++;
*b++ = red;
*b++ = green;
*b++ = blue;
}
}
}
} break;
case 32: {
uint32_t *pixU32 = (uint32_t *)(pix + 4 * (w + 1));
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
uint32_t v = *pixU32++;
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
}
pixU32++;
}
} break;
}
bool ret = (0 != stbi_write_png(fileName, w, h, CHANNEL_NUM, writeBuffer, w * CHANNEL_NUM));
delete[] writeBuffer;
return ret;
}
void utilPutDword(uint8_t *p, uint32_t value)
{
*p++ = value & 255;
*p++ = (value >> 8) & 255;
*p++ = (value >> 16) & 255;
*p = (value >> 24) & 255;
}
void utilPutWord(uint8_t *p, uint16_t value)
{
*p++ = value & 255;
*p = (value >> 8) & 255;
}
#ifndef __LIBRETRO__
bool utilWriteBMPFile(const char *fileName, int w, int h, uint8_t *pix)
{
uint8_t writeBuffer[512 * 3];
FILE *fp = fopen(fileName, "wb");
if (!fp) {
systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), fileName);
return false;
}
struct {
uint8_t ident[2];
uint8_t filesize[4];
uint8_t reserved[4];
uint8_t dataoffset[4];
uint8_t headersize[4];
uint8_t width[4];
uint8_t height[4];
uint8_t planes[2];
uint8_t bitsperpixel[2];
uint8_t compression[4];
uint8_t datasize[4];
uint8_t hres[4];
uint8_t vres[4];
uint8_t colors[4];
uint8_t importantcolors[4];
// uint8_t pad[2];
} bmpheader;
memset(&bmpheader, 0, sizeof(bmpheader));
bmpheader.ident[0] = 'B';
bmpheader.ident[1] = 'M';
uint32_t fsz = sizeof(bmpheader) + w * h * 3;
utilPutDword(bmpheader.filesize, fsz);
utilPutDword(bmpheader.dataoffset, 0x36);
utilPutDword(bmpheader.headersize, 0x28);
utilPutDword(bmpheader.width, w);
utilPutDword(bmpheader.height, h);
utilPutDword(bmpheader.planes, 1);
utilPutDword(bmpheader.bitsperpixel, 24);
utilPutDword(bmpheader.datasize, 3 * w * h);
fwrite(&bmpheader, 1, sizeof(bmpheader), fp);
uint8_t *b = writeBuffer;
int sizeX = w;
int sizeY = h;
switch (systemColorDepth) {
case 16: {
uint16_t *p = (uint16_t *)(pix + (w + 2) * (h)*2); // skip first black line
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
uint16_t v = *p++;
*b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
}
p++; // skip black pixel for filters
p++; // skip black pixel for filters
p -= 2 * (w + 2);
fwrite(writeBuffer, 1, 3 * w, fp);
b = writeBuffer;
}
} break;
case 24: {
uint8_t *pixU8 = (uint8_t *)pix + 3 * w * (h - 1);
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
if (systemRedShift > systemBlueShift) {
*b++ = *pixU8++; // B
*b++ = *pixU8++; // G
*b++ = *pixU8++; // R
} else {
int red = *pixU8++;
int green = *pixU8++;
int blue = *pixU8++;
*b++ = blue;
*b++ = green;
*b++ = red;
}
}
pixU8 -= 2 * 3 * w;
fwrite(writeBuffer, 1, 3 * w, fp);
b = writeBuffer;
}
} break;
case 32: {
uint32_t *pixU32 = (uint32_t *)(pix + 4 * (w + 1) * (h));
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
uint32_t v = *pixU32++;
*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
}
pixU32++;
pixU32 -= 2 * (w + 1);
fwrite(writeBuffer, 1, 3 * w, fp);
b = writeBuffer;
}
} break;
}
fclose(fp);
return true;
}
#endif /* !__LIBRETRO__ */
bool utilIsGBAImage(const char *file)
{
coreOptions.cpuIsMultiBoot = false;
if (strlen(file) > 4) {
const char *p = strrchr(file, '.');
if (p != NULL) {
if ((_stricmp(p, ".agb") == 0) || (_stricmp(p, ".gba") == 0) ||
(_stricmp(p, ".bin") == 0) || (_stricmp(p, ".elf") == 0))
return true;
if (_stricmp(p, ".mb") == 0) {
coreOptions.cpuIsMultiBoot = true;
return true;
}
}
}
return false;
}
bool utilIsGBImage(const char *file)
{
if (strlen(file) > 4) {
const char *p = strrchr(file, '.');
if (p != NULL) {
if ((_stricmp(p, ".dmg") == 0) || (_stricmp(p, ".gb") == 0) ||
(_stricmp(p, ".gbc") == 0) || (_stricmp(p, ".cgb") == 0) ||
(_stricmp(p, ".sgb") == 0))
return true;
}
}
return false;
}
bool utilIsGzipFile(const char *file)
{
if (strlen(file) > 3) {
const char *p = strrchr(file, '.');
if (p != NULL) {
if (_stricmp(p, ".gz") == 0)
return true;
if (_stricmp(p, ".z") == 0)
return true;
}
}
return false;
}
// strip .gz or .z off end
void utilStripDoubleExtension(const char *file, char *buffer)
{
if (buffer != file) // allows conversion in place
strcpy(buffer, file);
if (utilIsGzipFile(file)) {
char *p = strrchr(buffer, '.');
if (p)
*p = 0;
}
}
// Opens and scans archive using accept(). Returns fex_t if found.
// If error or not found, displays message and returns NULL.
static fex_t *scan_arc(const char *file, bool (*accept)(const char *), char (&buffer)[2048])
{
fex_t *fe;
fex_err_t err = fex_open(&fe, file);
if (!fe) {
systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s: %s"), file, err);
return NULL;
}
// Scan filenames
bool found = false;
while (!fex_done(fe)) {
strncpy(buffer, fex_name(fe), sizeof buffer);
buffer[sizeof buffer - 1] = '\0';
utilStripDoubleExtension(buffer, buffer);
if (accept(buffer)) {
found = true;
break;
}
fex_err_t err = fex_next(fe);
if (err) {
systemMessage(MSG_BAD_ZIP_FILE,
N_("Cannot read archive %s: %s"),
file,
err);
fex_close(fe);
return NULL;
}
}
if (!found) {
systemMessage(MSG_NO_IMAGE_ON_ZIP, N_("No image found in file %s"), file);
fex_close(fe);
return NULL;
}
return fe;
}
static bool utilIsImage(const char *file)
{
return utilIsGBAImage(file) || utilIsGBImage(file);
}
IMAGE_TYPE utilFindType(const char *file, char (&buffer)[2048]);
IMAGE_TYPE utilFindType(const char *file)
{
char buffer[2048];
return utilFindType(file, buffer);
}
IMAGE_TYPE utilFindType(const char *file, char (&buffer)[2048])
{
#ifdef WIN32
DWORD dwNum = MultiByteToWideChar(CP_ACP, 0, file, -1, NULL, 0);
wchar_t *pwText;
pwText = new wchar_t[dwNum];
if (!pwText) {
return IMAGE_UNKNOWN;
}
MultiByteToWideChar(CP_ACP, 0, file, -1, pwText, dwNum);
//char *file_conv = fex_wide_to_path(file);
char *file_conv = (char *)file;
// if ( !utilIsImage( file_conv ) ) // TODO: utilIsArchive() instead?
// {
fex_t *fe = scan_arc(file_conv, utilIsImage, buffer);
if (!fe)
return IMAGE_UNKNOWN;
fex_close(fe);
file = buffer;
// }
//free(file_conv);
#else
// if ( !utilIsImage( file ) ) // TODO: utilIsArchive() instead?
// {
fex_t *fe = scan_arc(file, utilIsImage, buffer);
if (!fe)
return IMAGE_UNKNOWN;
fex_close(fe);
file = buffer;
// }
#endif
return utilIsGBAImage(file) ? IMAGE_GBA : IMAGE_GB;
}
static int utilGetSize(int size)
{
int res = 1;
while (res < size)
res <<= 1;
return res;
}
uint8_t *utilLoad(const char *file, bool (*accept)(const char *), uint8_t *data, int &size)
{
// find image file
char buffer[2048];
#ifdef WIN32
DWORD dwNum = MultiByteToWideChar(CP_ACP, 0, file, -1, NULL, 0);
wchar_t *pwText;
pwText = new wchar_t[dwNum];
if (!pwText) {
return NULL;
}
MultiByteToWideChar(CP_ACP, 0, file, -1, pwText, dwNum);
//char *file_conv = fex_wide_to_path(file);
char *file_conv = (char *)file;
delete[] pwText;
fex_t *fe = scan_arc(file_conv, accept, buffer);
if (!fe)
return NULL;
//free(file_conv);
#else
fex_t *fe = scan_arc(file, accept, buffer);
if (!fe)
return NULL;
#endif
// Allocate space for image
fex_err_t err = fex_stat(fe);
int fileSize = fex_size(fe);
if (size == 0)
size = fileSize;
if (size > MAX_CART_SIZE)
return NULL;
uint8_t *image = data;
if (image == NULL) {
// allocate buffer memory if none was passed to the function
image = (uint8_t *)malloc(utilGetSize(size));
if (image == NULL) {
fex_close(fe);
systemMessage(MSG_OUT_OF_MEMORY,
N_("Failed to allocate memory for %s"),
"data");
return NULL;
}
size = fileSize;
}
// Read image
int read = fileSize <= size ? fileSize : size; // do not read beyond file
err = fex_read(fe, image, read);
fex_close(fe);
if (err) {
systemMessage(MSG_ERROR_READING_IMAGE,
N_("Error reading image from %s: %s"),
buffer,
err);
if (data == NULL)
free(image);
return NULL;
}
size = fileSize;
return image;
}
void replaceAll(std::string &str, const std::string &from, const std::string &to)
{
if (from.empty())
return;
size_t start_pos = 0;
while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
str.replace(start_pos, from.length(), to);
start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with
// 'yx'
}
}
void utilExtract(const char *filepath, const char *filename)
{
fex_t *fex;
std::string archive_name(filepath);
archive_name.append(filename);
fex_open(&fex, archive_name.c_str());
while (!fex_done(fex)) {
std::string extracted_filename(filepath);
extracted_filename.append(fex_name(fex));
#ifdef WIN32
replaceAll(extracted_filename, "/", "\\");
#endif
std::string new_dir(filepath);
new_dir.append(fex_name(fex));
#ifdef WIN32
replaceAll(new_dir, "/", "\\");
#endif
new_dir = new_dir.substr(0, new_dir.find_last_of("\\"));
if (!FileExists(new_dir.c_str()))
mkdir(new_dir.c_str()
#ifndef WIN32
,
0777
#endif
);
if (FileExists(extracted_filename.c_str())) {
std::string new_name(filepath);
new_name.append("old-");
new_name.append(fex_name(fex));
#ifdef WIN32
replaceAll(new_name, "/", "\\");
#endif
remove(new_name.c_str());
rename(extracted_filename.c_str(), new_name.c_str());
}
FILE *extracted_file = fopen(extracted_filename.c_str(), "wb");
const void *p;
fex_data(fex, &p);
fwrite(p, fex_size(fex), 1, extracted_file);
fclose(extracted_file);
fex_next(fex);
}
fex_close(fex);
}
void utilWriteInt(gzFile gzFile, int i)
{
utilGzWrite(gzFile, &i, sizeof(int));
}
int utilReadInt(gzFile gzFile)
{
int i = 0;
utilGzRead(gzFile, &i, sizeof(int));
return i;
}
void utilReadData(gzFile gzFile, variable_desc *data)
{
while (data->address) {
utilGzRead(gzFile, data->address, data->size);
data++;
}
}
void utilReadDataSkip(gzFile gzFile, variable_desc *data)
{
while (data->address) {
utilGzSeek(gzFile, data->size, SEEK_CUR);
data++;
}
}
void utilWriteData(gzFile gzFile, variable_desc *data)
{
while (data->address) {
utilGzWrite(gzFile, data->address, data->size);
data++;
}
}
gzFile utilAutoGzOpen(const char *file, const char *mode)
{
#ifdef _WIN32
wchar_t *wfile = utf8ToUtf16(file);
if (!wfile) return nullptr;
gzFile handler = gzopen_w(wfile, mode);
delete[] wfile;
return handler;
#else
return gzopen(file, mode);
#endif
}
gzFile utilGzOpen(const char *file, const char *mode)
{
utilGzWriteFunc = (int(ZEXPORT *)(gzFile, void *const, unsigned int))gzwrite;
utilGzReadFunc = gzread;
utilGzCloseFunc = gzclose;
utilGzSeekFunc = gzseek;
return utilAutoGzOpen(file, mode);
}
gzFile utilMemGzOpen(char *memory, int available, const char *mode)
{
utilGzWriteFunc = memgzwrite;
utilGzReadFunc = memgzread;
utilGzCloseFunc = memgzclose;
utilGzSeekFunc = memgzseek;
return memgzopen(memory, available, mode);
}
int utilGzWrite(gzFile file, const voidp buffer, unsigned int len)
{
return utilGzWriteFunc(file, buffer, len);
}
int utilGzRead(gzFile file, voidp buffer, unsigned int len)
{
return utilGzReadFunc(file, buffer, len);
}
int utilGzClose(gzFile file)
{
return utilGzCloseFunc(file);
}
z_off_t utilGzSeek(gzFile file, z_off_t offset, int whence)
{
return utilGzSeekFunc(file, offset, whence);
}
long utilGzMemTell(gzFile file)
{
return memtell(file);
}
void utilGBAFindSave(const int size)
{
uint32_t *p = (uint32_t *)&rom[0];
uint32_t *end = (uint32_t *)(&rom[0] + size);
int detectedSaveType = 0;
int flashSize = 0x10000;
bool rtcFound = false;
while (p < end) {
uint32_t d = READ32LE(p);
if (d == 0x52504545) {
if (memcmp(p, "EEPROM_", 7) == 0) {
if (detectedSaveType == 0 || detectedSaveType == 4)
detectedSaveType = 1;
}
} else if (d == 0x4D415253) {
if (memcmp(p, "SRAM_", 5) == 0) {
if (detectedSaveType == 0 || detectedSaveType == 1 ||
detectedSaveType == 4)
detectedSaveType = 2;
}
} else if (d == 0x53414C46) {
if (memcmp(p, "FLASH1M_", 8) == 0) {
if (detectedSaveType == 0) {
detectedSaveType = 3;
flashSize = 0x20000;
}
} else if (memcmp(p, "FLASH512_", 9) == 0) {
if (detectedSaveType == 0) {
detectedSaveType = 3;
flashSize = 0x10000;
}
} else if (memcmp(p, "FLASH", 5) == 0) {
if (detectedSaveType == 0) {
detectedSaveType = 4;
flashSize = 0x10000;
}
}
} else if (d == 0x52494953) {
if (memcmp(p, "SIIRTC_V", 8) == 0)
rtcFound = true;
}
p++;
}
// if no matches found, then set it to NONE
if (detectedSaveType == 0) {
detectedSaveType = 5;
}
if (detectedSaveType == 4) {
detectedSaveType = 3;
}
rtcEnable(rtcFound);
rtcEnableRumble(!rtcFound);
coreOptions.saveType = detectedSaveType;
flashSetSize(flashSize);
}
void utilUpdateSystemColorMaps(bool lcd)
{
switch (systemColorDepth) {
case 16: {
for (int i = 0; i < 0x10000; i++) {
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
(((i & 0x3e0) >> 5) << systemGreenShift) |
(((i & 0x7c00) >> 10) << systemBlueShift);
}
if (lcd)
gbafilter_pal(systemColorMap16, 0x10000);
} break;
case 24:
case 32: {
for (int i = 0; i < 0x10000; i++) {
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
(((i & 0x3e0) >> 5) << systemGreenShift) |
(((i & 0x7c00) >> 10) << systemBlueShift);
}
if (lcd)
gbafilter_pal32(systemColorMap32, 0x10000);
} break;
}
}
// Check for existence of file.
bool utilFileExists(const char *filename)
{
FILE *f = fopen(filename, "r");
if (f == NULL) {
return false;
} else {
fclose(f);
return true;
}
}

View File

@@ -1,11 +0,0 @@
#ifndef VBAM_BSD_H
#define VBAM_BSD_H
#define fopen64 fopen
#define fseeko64 fseeko
#define fseek64 fseek
#define ftell64 ftell
#define ftello64 ftello
#endif // VBAM_BSD_H

View File

@@ -1,9 +0,0 @@
#ifndef PATCH_H
#define PATCH_H
#include "../Util.h"
#include "Types.h"
bool applyPatch(const char *patchname, uint8_t **rom, int *size);
#endif // PATCH_H

View File

@@ -1,64 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 2015 VBA-M development team
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_SOUND_DRIVER_H__
#define __VBA_SOUND_DRIVER_H__
#include <stdint.h> // for uint16_t
/**
* Sound driver abstract interface for the core to use to output sound.
* Subclass this to implement a new sound driver.
*/
class SoundDriver
{
public:
/**
* Destructor. Free the resources allocated by the sound driver.
*/
virtual ~SoundDriver(){};
/**
* Initialize the sound driver.
* @param sampleRate In Hertz
*/
virtual bool init(long sampleRate) = 0;
/**
* Tell the driver that the sound stream has paused
*/
virtual void pause() = 0;
/**
* Reset the sound driver
*/
virtual void reset() = 0;
/**
* Tell the driver that the sound stream has resumed
*/
virtual void resume() = 0;
/**
* Write length bytes of data from the finalWave buffer to the driver output buffer.
*/
virtual void write(uint16_t *finalWave, int length) = 0;
virtual void setThrottle(unsigned short throttle) = 0;
};
#endif // __VBA_SOUND_DRIVER_H__

View File

@@ -1,28 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 2008 VBA-M development team
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_TYPES_H__
#define __VBA_TYPES_H__
#ifdef __LIBRETRO__
#include <stdint.h>
#else
#include <zlib.h>
#include "cstdint.h"
#endif
#endif // __VBA_TYPES_H__

View File

@@ -1,10 +0,0 @@
#ifndef CONTAINS_HPP_
#define CONTAINS_HPP_
template <class C, class V>
bool contains(const C& container, const V& val)
{
return (container.find(val) != container.end());
}
#endif /* CONTAINS_HPP_ */

View File

@@ -1,18 +0,0 @@
#ifndef CSTDINT_H
#define CSTDINT_H
#if defined(__has_include)
# if __has_include(<cstdint>)
# include <cstdint>
// necessary on Mac OS X Lion 10.7 or any clang <= 3.0
# elif __has_include(<tr1/cstdint>)
# include <tr1/cstdint>
# else
// throw error
# include <cstdint>
# endif
#else
# include <cstdint>
#endif
#endif // CSTDINT_H

View File

@@ -1,669 +0,0 @@
/*
Range
=====
Copyright (c) 2009-2011 Khaled Alshaya
Distributed under the Boost Software License, version 1.0
(See the license at: http://www.boost.org/license_1_0.txt).
*/
/*
Rationale
=========
In Python, there is a beautiful function called "range".
"range" allows the programmer to iterate over a range elegantly.
This concept is not as general as "for-loops" in C++,
but non the less, it expresses the intent of the programmer
clearer than the general "for-loops" in many cases.
Design
======
Range is made to be STL-like library. In fact, it is
built on top of the concepts of STL. The library is designed to
work with STL algorithms as well. Range is more flexible
than the Python "range", because:
Range is an "immutable ordered random access container"
Specifications
==============
Range satisfies the following requirements:
* Immutable.
* Random Access Container.
* Random Access Iterator Interface.
* Constant Time Complexity Operations.
Range models an ordered sequence of elements,
where a range is defined by:
[begin, end)
* begin: the first element in the range. (Inclusive)
* end : the last element in the range. (Exclusive)
* step : the distance between two consecutive elements in a range.
where each element in the range is defined by:
element = begin + step * i
* i: is the index of the element in range.
The following precondition must be met for the sequence
to be a valid range:
step != 0
&&
(
begin <= end && step > 0
||
begin >= end && step < 0
)
Portability
===========
Range Generator is written in standard C++ (C++98). It depends
-only- on the standard C++ library.
*/
#ifndef range_h__
#define range_h__
// using std::range
// using std::size_t from <cstddef>
// using std::ceil from <cmath>
#include <iterator>
#include <stdexcept>
#include <cstddef>
#include <cmath>
namespace Range
{
template <class IntegerType>
struct basic_range
{
struct const_iterator_impl
{
typedef IntegerType value_type;
typedef std::size_t size_type;
typedef IntegerType difference_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef
std::random_access_iterator_tag
iterator_category;
const_iterator_impl(): r(0), index(0)
{ }
const_iterator_impl(const const_iterator_impl& rhs)
: r(rhs.r), index(rhs.index)
{ }
const_iterator_impl(basic_range<IntegerType> const * p_range, size_type p_index)
:r(p_range), index(p_index)
{ }
const_iterator_impl& operator=(const const_iterator_impl& rhs)
{
r = rhs.r;
index = rhs.index;
return *this;
}
bool operator==(const const_iterator_impl& rhs) const
{
return *r == *(rhs.r) && index == rhs.index;
}
bool operator!=(const const_iterator_impl& rhs) const
{
return !(*this == rhs);
}
bool operator<(const const_iterator_impl& rhs) const
{
return index < rhs.index;
}
bool operator>(const const_iterator_impl& rhs) const
{
return index > rhs.index;
}
bool operator<=(const const_iterator_impl& rhs) const
{
return index <= rhs.index;
}
bool operator>=(const const_iterator_impl& rhs) const
{
return index >= rhs.index;
}
value_type operator*() const
{
return r->m_first_element + r->m_step*index;
}
// operator->
// is not implemented because the value_type is an integer type
// and primitive types in C++ don't define member functions.
const_iterator_impl& operator++()
{
++index;
return *this;
}
const_iterator_impl operator++(int)
{
const_iterator_impl temp = *this;
++index;
return temp;
}
const_iterator_impl& operator--()
{
--index;
return *this;
}
const_iterator_impl operator--(int)
{
const_iterator_impl temp = *this;
--index;
return temp;
}
const_iterator_impl& operator+=(difference_type increment)
{
index += increment;
return *this;
}
// operator+
// is friend operator but operator-
// is not, because we want to allow the following for "+":
// iterator+5
// 5+iterator
// For the "-" it is not correct to do so, because
// iterator-5 != 5-iterator
friend const_iterator_impl operator+
(const const_iterator_impl& lhs, difference_type increment)
{
const_iterator_impl sum;
sum.r = lhs.r;
sum.index = lhs.index + increment;
return sum;
}
const_iterator_impl& operator-=(difference_type decrement)
{
index -= decrement;
return *this;
}
const_iterator_impl operator-(difference_type decrement) const
{
const_iterator_impl shifted_iterator;
shifted_iterator.r = r;
shifted_iterator.index = index - decrement;
return shifted_iterator;
}
difference_type operator-(const const_iterator_impl& rhs) const
{
return index - rhs.index;
}
value_type operator[](difference_type offset) const
{
size_type new_index = index + offset;
return r->m_first_element + r->m_step*new_index;
}
private:
basic_range<IntegerType> const * r;
size_type index;
};
struct const_reverse_iterator_impl
{
typedef IntegerType value_type;
typedef std::size_t size_type;
typedef IntegerType difference_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef
std::random_access_iterator_tag
iterator_category;
const_reverse_iterator_impl(): r(0), index(0)
{ }
const_reverse_iterator_impl(const const_reverse_iterator_impl& rhs)
: r(rhs.r), index(rhs.index)
{ }
const_reverse_iterator_impl(basic_range<IntegerType> const * p_range, size_type p_index)
:r(p_range), index(p_index)
{ }
const_reverse_iterator_impl& operator=(const const_reverse_iterator_impl& rhs)
{
r = rhs.r;
index = rhs.index;
return *this;
}
bool operator==(const const_reverse_iterator_impl& rhs) const
{
return *r == *(rhs.r) && index == rhs.index;
}
bool operator!=(const const_reverse_iterator_impl& rhs) const
{
return !(*this == rhs);
}
bool operator<(const const_reverse_iterator_impl& rhs) const
{
return index < rhs.index;
}
bool operator>(const const_reverse_iterator_impl& rhs) const
{
return index > rhs.index;
}
bool operator<=(const const_reverse_iterator_impl& rhs) const
{
return index <= rhs.index;
}
bool operator>=(const const_reverse_iterator_impl& rhs) const
{
return index >= rhs.index;
}
value_type operator*() const
{
size_type reverse_index
= (r->m_element_count - 1) - index;
return r->m_first_element + r->m_step*reverse_index;
}
// operator->
// is not implemented because the value_type is integer type
// and primitive types in C++ don't define member functions.
const_reverse_iterator_impl& operator++()
{
++index;
return *this;
}
const_reverse_iterator_impl operator++(int)
{
const_reverse_iterator_impl temp = *this;
++index;
return temp;
}
const_reverse_iterator_impl& operator--()
{
--index;
return *this;
}
const_reverse_iterator_impl operator--(int)
{
const_reverse_iterator_impl temp = *this;
--index;
return temp;
}
const_reverse_iterator_impl& operator+=(difference_type increment)
{
index += increment;
return *this;
}
// operator+
// is friend operator but operator-
// is not, because we want to allow the following for "+":
// iterator+5
// 5+iterator
// For the "-" it is not correct to do so, because
// iterator-5 != 5-iterator
friend const_reverse_iterator_impl operator+
(const const_reverse_iterator_impl& lhs, difference_type increment)
{
const_reverse_iterator_impl sum;
sum.r = lhs.r;
sum.index = lhs.index + increment;
return sum;
}
const_reverse_iterator_impl& operator-=(difference_type decrement)
{
index -= decrement;
return *this;
}
const_reverse_iterator_impl operator-(difference_type decrement) const
{
const_reverse_iterator_impl shifted_iterator;
shifted_iterator.r = r;
shifted_iterator.index = index - decrement;
return shifted_iterator;
}
difference_type operator-(const const_reverse_iterator_impl& rhs) const
{
return index - rhs.index;
}
value_type operator[](difference_type offset) const
{
size_type new_reverse_index
= (r->m_element_count - 1) - (index + offset);
return r->m_first_element + r->m_step*new_reverse_index;
}
private:
basic_range<IntegerType> const * r;
size_type index;
};
typedef IntegerType value_type;
typedef const_iterator_impl iterator;
typedef const_iterator_impl const_iterator;
typedef const_reverse_iterator_impl reverse_iterator;
typedef const_reverse_iterator_impl const_reverse_iterator;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef value_type* pointer;
typedef IntegerType difference_type;
typedef std::size_t size_type;
// In the case of default construction,
// the range is considered as an empty range with no elements.
// step can be anything other than 0. 1 is
// an implementation convention, and it doesn't have
// a significance in this case because the range is empty.
basic_range(): m_first_element(0), m_element_count(0), m_step(1)
{ }
// first_element: is begin in specifications.
// last_element: is end in specifications.
basic_range(value_type first_element, value_type last_element, value_type step)
: m_first_element(first_element),
m_step(step)
{
// We need to count the number of elements.
// The only case where a range is invalid,
// when the step=0. It means that the range
// is infinite, because the number of elements
// in a range, is the length of that range
// divided by the difference between
// every two successive elements.
if(step == 0)
throw std::out_of_range("Invalid Range: step can't be equal to zero!");
if(first_element < last_element && step < 0)
throw std::out_of_range("Invalid Range: step can't be backward, while the range is forward!");
if(first_element > last_element && step > 0)
throw std::out_of_range("Invalid Range: step can't be forward, while the range is backward!");
m_element_count = (last_element-first_element)/step;
if( (last_element-first_element)%step != 0 )
++m_element_count;
}
// The following constructor, determines the step
// automatically. If the range is forward, then
// step will be one. If the range is backward,
// step will be minus one. If the begin is equal
// to end, then the step must not equal to zero
// and it is set to one as a convention.
basic_range(value_type first_element, value_type last_element)
: m_first_element(first_element)
{
if(last_element >= first_element) *this = basic_range<IntegerType>(first_element, last_element, 1);
else *this = basic_range<IntegerType>(first_element, last_element, -1);
}
// The following constructor is a shortcut
// if you want the first element as zero.
// the step is determined automatically, based
// on the last element. If the last element is
// positive, then step is one, but if it is negative
// then step is minus one.
basic_range<IntegerType>(value_type last_element)
: m_first_element(0)
{
if(last_element >= m_first_element) *this = basic_range<IntegerType>(m_first_element, last_element, 1);
else *this = basic_range<IntegerType>(m_first_element, last_element, -1);
}
basic_range<IntegerType>(const basic_range<IntegerType>& r)
: m_first_element(r.m_first_element),
m_element_count(r.m_element_count),
m_step(r.m_step)
{ }
basic_range<IntegerType>& operator=(const basic_range<IntegerType>& r)
{
m_first_element = r.m_first_element;
m_element_count = r.m_element_count;
m_step = r.m_step;
return *this;
}
bool operator==(const basic_range<IntegerType>& r) const
{
return m_first_element == r.m_first_element
&&
m_element_count == r.m_element_count
&&
m_step == r.m_step;
}
bool operator!=(const basic_range<IntegerType>& r) const
{
return !(*this == r);
}
// The following four functions enable the user to compare
// ranges using ( <, >, <=, >=).
// The comparison between two ranges is a simple lexicographical
// comparison(element by element). By convention, if two ranges
// R1, R2 where R1 has a smaller number of elements. Then if
// R1 contains more elements but all R1 elements are found in R2
// R1 is considered less than R2.
bool operator<(const basic_range<IntegerType>& r) const
{
// ********** This function needs refactoring.
if(m_element_count == 0 && r.m_element_count == 0)
return false;
if(m_element_count == 0 && r.m_element_count > 0)
return true;
if(m_element_count > 0 && r.m_element_count == 0)
return false;
// At this point, both has at least one element.
if(m_first_element < r.m_first_element)
return true;
if(m_first_element > r.m_first_element)
return false;
// At this point, the first element of both are equal.
if(m_element_count == 1 && r.m_element_count == 1)
return false;
if(m_element_count == 1 && r.m_element_count > 1)
return true;
if(m_element_count > 1 && r.m_element_count == 1)
return false;
// At this point, both have at least two elements with
// a similar first element. Note than the final answer
// in this case depends on the second element only, because
// we don't need to compare the elements further.
// Note that the second element is at (index == 1), because
// the first element is at (index == 0).
if(m_first_element+m_step*1 < r.m_first_element+r.m_step*1)
return true;
if(m_first_element+m_step*1 > r.m_first_element+r.m_step*1)
return false;
// if the first two elements of both ranges are equal, then
// they are co-linear ranges(because the step is constant).
// In that case, they comparison depends only on
// the size of the ranges by convention.
return m_element_count < r.m_element_count;
}
bool operator>(const basic_range<IntegerType>& r) const
{
// ********** This function needs refactoring.
if(m_element_count == 0 && r.m_element_count == 0)
return false;
if(m_element_count == 0 && r.m_element_count > 0)
return false;
if(m_element_count > 0 && r.m_element_count == 0)
return true;
// At this point, both has at least one element.
if(m_first_element < r.m_first_element)
return false;
if(m_first_element > r.m_first_element)
return true;
// At this point, the first element of both are equal.
if(m_element_count == 1 && r.m_element_count == 1)
return false;
if(m_element_count == 1 && r.m_element_count > 1)
return false;
if(m_element_count > 1 && r.m_element_count == 1)
return true;
// At this point, both have at least two elements with
// a similar first element. Note than the final answer
// in this case depends on the second element only, because
// we don't need to compare the elements further.
// Note that the second element is at (index == 1), because
// the first element is at (index == 0).
if(m_first_element+m_step*1 < r.m_first_element+r.m_step*1)
return false;
if(m_first_element+m_step*1 > r.m_first_element+r.m_step*1)
return true;
// if the first two elements of both ranges are equal, then
// they are co-linear ranges(because the step is constant).
// In that case, they comparison depends only on
// the size of the ranges by convention.
return m_element_count > r.m_element_count;
}
bool operator <=(const basic_range<IntegerType>& r) const
{
return !(*this > r);
}
bool operator >=(const basic_range<IntegerType>& r) const
{
return !(*this < r);
}
const_iterator begin() const
{
return const_iterator(this, 0);
}
const_iterator end() const
{
return const_iterator(this, m_element_count);
}
const_reverse_iterator rbegin() const
{
return const_reverse_iterator(this, 0);
}
const_reverse_iterator rend() const
{
return const_reverse_iterator(this, m_element_count);
}
size_type size() const
{
return m_element_count;
}
size_type max_size() const
{
// Because this is an immutable container,
// max_size() == size()
return m_element_count;
}
bool empty() const
{
return m_element_count == 0;
}
// exist() and find() are similar except that
// find() returns the index of the element.
iterator find(value_type element) const
{
value_type element_index = (element - m_first_element) / m_step;
bool in_range = element_index >= 0 && element_index < m_element_count &&
(element - m_first_element) % m_step == 0;
if(in_range)
return begin() + element_index;
return end();
}
bool exist(value_type element) const
{
return find(element) != end();
}
// In the standard, the operator[]
// should return a const reference.
// Because Range Generator doesn't store its elements
// internally, we return a copy of the value.
// In any case, this doesn't affect the semantics of the operator.
value_type operator[](size_type index) const
{
return m_first_element + m_step*index;
}
private:
// m_first_element: begin (see specifications).
// m_element_count: (end - begin) / step
value_type m_first_element, m_element_count, m_step;
};
// This is the default type of range!
typedef basic_range<int> range;
}
#endif // range_h__

View File

@@ -1,6 +0,0 @@
#include "version_cpp.h"
#include "version.h"
const char* const vba_name_and_subversion = VBA_NAME_AND_SUBVERSION;
const char* const vbam_version = VBAM_VERSION;

View File

@@ -1,8 +0,0 @@
#ifndef VBAM_VERSION_CPP_H
#define VBAM_VERSION_CPP_H
extern const char* const vba_name_and_subversion;
extern const char* const vbam_version;
#endif /* VBAM_VERSION_CPP_H */

View File

@@ -0,0 +1,6 @@
add_subdirectory(av_recording)
add_subdirectory(draw_text)
add_subdirectory(filters)
add_subdirectory(filters_agb)
add_subdirectory(filters_interframe)
add_subdirectory(user_config)

View File

@@ -0,0 +1,18 @@
if(NOT ENABLE_FFMPEG)
return()
endif()
add_library(vbam-components-av-recording OBJECT)
target_sources(vbam-components-av-recording
PRIVATE av_recording.cpp
PUBLIC av_recording.h
)
target_include_directories(vbam-components-av-recording
PUBLIC ${FFMPEG_INCLUDE_DIRS}
)
target_link_libraries(vbam-components-av-recording
PUBLIC ${FFMPEG_LIBRARIES}
)

View File

@@ -1,9 +1,28 @@
#include "ffmpeg.h"
#include "components/av_recording/av_recording.h"
#define STREAM_FRAME_RATE 60
#define STREAM_PIXEL_FORMAT AV_PIX_FMT_YUV420P
#define IN_SOUND_FORMAT AV_SAMPLE_FMT_S16
namespace {
// Wrapper around an AVPacket that frees the underlying packet on destruction.
class ScopedAVPacket {
public:
ScopedAVPacket() : av_packet_(av_packet_alloc()) {}
~ScopedAVPacket() {
av_packet_free(&av_packet_);
}
AVPacket* operator->() { return av_packet_; }
AVPacket* get() { return av_packet_; }
private:
AVPacket* av_packet_;
};
} // namespace
struct supportedCodecs {
AVCodecID codecId;
char const *longName;
@@ -118,18 +137,12 @@ recording::MediaRet recording::MediaRecorder::setup_audio_stream()
}
}
if (!isSupported && acodec->supported_samplerates) return MRET_ERR_NOCODEC;
aenc->channels = av_get_channel_layout_nb_channels(aenc->channel_layout);
#if LIBAVCODEC_VERSION_MAJOR >= 60
av_channel_layout_from_mask(&(aenc->ch_layout), AV_CH_LAYOUT_STEREO);
#else
aenc->channel_layout = AV_CH_LAYOUT_STEREO;
if (acodec->channel_layouts)
{
aenc->channel_layout = acodec->channel_layouts[0];
for (int i = 0; acodec->channel_layouts[i]; ++i)
{
if (acodec->channel_layouts[i] == AV_CH_LAYOUT_STEREO)
aenc->channel_layout = AV_CH_LAYOUT_STEREO;
}
}
aenc->channels = av_get_channel_layout_nb_channels(aenc->channel_layout);
aenc->channels = 2;
#endif
aenc->time_base = { 1, aenc->sample_rate };
ast->time_base = { 1, STREAM_FRAME_RATE };
// open and use codec on stream
@@ -150,7 +163,11 @@ recording::MediaRet recording::MediaRecorder::setup_audio_stream()
audioframeTmp = av_frame_alloc();
if (!audioframeTmp) return MRET_ERR_BUFSIZE;
audioframeTmp->format = IN_SOUND_FORMAT;
audioframeTmp->channel_layout = aenc->channel_layout;
#if LIBAVCODEC_VERSION_MAJOR >= 60
audioframeTmp->ch_layout = aenc->ch_layout;
#else
audioframeTmp->channel_layout = AV_CH_LAYOUT_STEREO;
#endif
audioframeTmp->sample_rate = aenc->sample_rate;
audioframeTmp->nb_samples = nb_samples;
if (nb_samples)
@@ -162,7 +179,11 @@ recording::MediaRet recording::MediaRecorder::setup_audio_stream()
audioframe = av_frame_alloc();
if (!audioframe) return MRET_ERR_BUFSIZE;
audioframe->format = aenc->sample_fmt;
audioframe->channel_layout = aenc->channel_layout;
#if LIBAVCODEC_VERSION_MAJOR >= 60
audioframe->ch_layout = aenc->ch_layout;
#else
audioframe->channel_layout = AV_CH_LAYOUT_STEREO;
#endif
audioframe->sample_rate = aenc->sample_rate;
audioframe->nb_samples = nb_samples;
if (nb_samples)
@@ -176,10 +197,15 @@ recording::MediaRet recording::MediaRecorder::setup_audio_stream()
{
return MRET_ERR_BUFSIZE;
}
av_opt_set_int (swr, "in_channel_count", aenc->channels, 0);
#if LIBAVCODEC_VERSION_MAJOR >= 60
av_opt_set_chlayout (swr, "in_chlayout", &(aenc->ch_layout),0);
av_opt_set_chlayout (swr, "out_chlayout", &(aenc->ch_layout),0);
#else
av_opt_set_int (swr, "in_channel_count", 2, 0);
av_opt_set_int (swr, "out_channel_count", 2, 0);
#endif
av_opt_set_int (swr, "in_sample_rate", aenc->sample_rate, 0);
av_opt_set_sample_fmt(swr, "in_sample_fmt", IN_SOUND_FORMAT, 0);
av_opt_set_int (swr, "out_channel_count", aenc->channels, 0);
av_opt_set_int (swr, "out_sample_rate", aenc->sample_rate, 0);
av_opt_set_sample_fmt(swr, "out_sample_fmt", aenc->sample_fmt, 0);
if (swr_init(swr) < 0)
@@ -188,8 +214,8 @@ recording::MediaRet recording::MediaRecorder::setup_audio_stream()
return MRET_ERR_BUFSIZE;
}
// auxiliary buffer for setting up frames for encode
audioBufferSize = nb_samples * aenc->channels * sizeof(uint16_t);
audioBuffer = (uint16_t *) calloc(nb_samples * aenc->channels, sizeof(uint16_t));
audioBufferSize = nb_samples * 2 * sizeof(uint16_t);
audioBuffer = (uint16_t *) calloc(nb_samples * 2, sizeof(uint16_t));
if (!audioBuffer) return MRET_ERR_BUFSIZE;
samplesInAudioBuffer = 0;
posInAudioBuffer = 0;
@@ -377,10 +403,9 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint8_t *vid)
if (!isRecording) return MRET_OK;
// fill and encode frame variables
int got_packet = 0, ret = 0;
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
ScopedAVPacket pkt;
pkt->data = NULL;
pkt->size = 0;
// fill frame with current pic
ret = av_image_fill_arrays(frameIn->data, frameIn->linesize,
(uint8_t *)vid + tbord * (linesize + pixsize * rbord),
@@ -393,17 +418,17 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint8_t *vid)
// set valid pts for frame
frameOut->pts = npts++;
// finally, encode frame
got_packet = avcodec_receive_packet(enc, &pkt);
got_packet = avcodec_receive_packet(enc, pkt.get());
ret = avcodec_send_frame(enc, frameOut);
if (ret < 0) return MRET_ERR_RECORDING;
if (!got_packet)
{
// rescale output packet timestamp values from codec
// to stream timebase
av_packet_rescale_ts(&pkt, enc->time_base, st->time_base);
pkt.stream_index = st->index;
//log_packet(oc, &pkt);
ret = av_interleaved_write_frame(oc, &pkt);
av_packet_rescale_ts(pkt.get(), enc->time_base, st->time_base);
pkt->stream_index = st->index;
//log_packet(oc, pkt.get());
ret = av_interleaved_write_frame(oc, pkt.get());
if (ret < 0) return MRET_ERR_RECORDING;
}
return MRET_OK;
@@ -547,7 +572,7 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint16_t *aud, int
{
if (!isRecording) return MRET_OK;
AVCodecContext *c = aenc;
int samples_size = av_samples_get_buffer_size(NULL, c->channels, audioframeTmp->nb_samples, IN_SOUND_FORMAT, 1);
int samples_size = av_samples_get_buffer_size(NULL, 2, audioframeTmp->nb_samples, IN_SOUND_FORMAT, 1);
int realLength = length / sizeof *aud;
bool isMissing = false;
@@ -584,12 +609,11 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint16_t *aud, int
}
int got_packet;
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
ScopedAVPacket pkt;
pkt->data = NULL;
pkt->size = 0;
if (avcodec_fill_audio_frame(audioframeTmp, c->channels, IN_SOUND_FORMAT, (const uint8_t *)audioBuffer, samples_size, 1) < 0)
if (avcodec_fill_audio_frame(audioframeTmp, 2, IN_SOUND_FORMAT, (const uint8_t *)audioBuffer, samples_size, 1) < 0)
{
return MRET_ERR_RECORDING;
}
@@ -604,17 +628,17 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint16_t *aud, int
audioframe->pts = av_rescale_q(samplesCount, {1, c->sample_rate}, c->time_base);
samplesCount += dst_nb_samples;
got_packet = avcodec_receive_packet(c, &pkt);
got_packet = avcodec_receive_packet(c, pkt.get());
if (avcodec_send_frame(c, audioframe) < 0)
{
return MRET_ERR_RECORDING;
}
if (!got_packet)
{
av_packet_rescale_ts(&pkt, { 1, c->sample_rate }, ast->time_base);
pkt.stream_index = ast->index;
//log_packet(oc, &pkt);
if (av_interleaved_write_frame(oc, &pkt) < 0)
av_packet_rescale_ts(pkt.get(), { 1, c->sample_rate }, ast->time_base);
pkt->stream_index = ast->index;
//log_packet(oc, pkt.get());
if (av_interleaved_write_frame(oc, pkt.get()) < 0)
{
return MRET_ERR_RECORDING;
}
@@ -637,11 +661,10 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint16_t *aud, int
// "X frames left in the queue on closing"
void recording::MediaRecorder::flush_frames()
{
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
ScopedAVPacket pkt;
pkt->data = NULL;
pkt->size = 0;
// flush last audio frames
while (avcodec_receive_packet(aenc, &pkt) >= 0)
while (avcodec_receive_packet(aenc, pkt.get()) >= 0)
avcodec_send_frame(aenc, NULL);
}

View File

@@ -1,16 +1,12 @@
#ifndef WX_FFMPEG_H
#define WX_FFMPEG_H
#ifndef VBAM_COMPONENTS_AV_RECORDING_AV_RECORDING_H_
#define VBAM_COMPONENTS_AV_RECORDING_AV_RECORDING_H_
// simplified interface for recording audio and/or video from emulator
// required for ffmpeg
#define __STDC_LIMIT_MACROS
#define __STDC_CONSTANT_MACROS
extern "C" {
/* From: http://redino.net/blog/2013/12/uint64_c-defined-including-libavformatavformat-h-vs-2008/ */
#include <stdint.h>
#include <cstdint>
#ifndef INT64_C
#define INT64_C(c) (c ## LL)
@@ -33,7 +29,6 @@ extern "C" {
}
#include <vector>
#include <string>
namespace recording {
@@ -131,4 +126,4 @@ class MediaRecorder
}
#endif /* WX_FFMPEG_H */
#endif // VBAM_COMPONENTS_AV_RECORDING_AV_RECORDING_H_

View File

@@ -0,0 +1,10 @@
add_library(vbam-components-draw-text OBJECT)
target_sources(vbam-components-draw-text
PRIVATE draw_text.cpp
PUBLIC draw_text.h
)
target_link_libraries(vbam-components-draw-text
PRIVATE vbam-core-base
)

View File

@@ -20,7 +20,9 @@
/* Code originally from fceu/drawing.h file, adapted by Forgotten
*/
#include "../System.h"
#include "components/draw_text/draw_text.h"
#include "core/base/system.h"
extern int RGB_LOW_BITS_MASK;

View File

@@ -17,4 +17,11 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef VBAM_COMPONENTS_DRAW_TEXT_DRAW_TEXT_H_
#define VBAM_COMPONENTS_DRAW_TEXT_DRAW_TEXT_H_
#include <cstdint>
extern void drawText(uint8_t*, int, int, int, const char*, bool);
#endif // VBAM_COMPONENTS_DRAW_TEXT_DRAW_TEXT_H_

View File

@@ -0,0 +1,47 @@
add_library(vbam-components-filters OBJECT)
target_sources(vbam-components-filters
PRIVATE
internal/2xSaI.cpp
internal/admame.cpp
internal/bilinear.cpp
internal/hq2x.cpp
internal/hq2x.h
internal/interp.h
internal/lq2x.h
internal/pixel.cpp
internal/scanline.cpp
internal/simpleFilter.cpp
internal/xBRZ/xbrz.cpp
internal/xBRZ/xbrz.h
internal/xBRZ/xbrz_config.h
internal/xBRZ/xbrz_tools.h
internal/xbrzfilter.cpp
PUBLIC
filters.h
)
if(ENABLE_ASM_SCALERS)
target_sources(vbam-components-filters
PRIVATE
internal/hq/asm/hq3x_16.asm
internal/hq/asm/hq3x_32.asm
internal/hq/asm/hq4x_16.asm
internal/hq/asm/hq4x_32.asm
internal/hq/asm/hq3x32.cpp
internal/hq/asm/macros.mac
)
if(ENABLE_MMX)
set(SRC_FILTERS ${SRC_FILTERS} internal/2xSaImmx.asm)
endif()
else()
target_sources(vbam-components-filters
PRIVATE
internal/hq/c/hq3x_pattern.h
internal/hq/c/hq4x_pattern.h
internal/hq/c/hq_base.h
internal/hq/c/hq_implementation.cpp
internal/hq/c/hq_shared.h
)
endif()

View File

@@ -1,14 +1,12 @@
#ifndef FILTERS_H
#define FILTERS_H
#ifndef VBAM_COMPONENTS_FILTERS_FILTERS_H_
#define VBAM_COMPONENTS_FILTERS_FILTERS_H_
#include <cstdint>
// FIXME: these should be in a system header included by all users and all
// files which define these functions
// most 16-bit filters require space in src rounded up to uint32_t
// those that take delta take 1 src line of pixels, rounded up to uint32_t size
// initial value appears to be all-0xff
#include "../filters/interframe.hpp"
void Pixelate32(uint8_t* src, uint32_t spitch, uint8_t*, uint8_t* dst, uint32_t dstp, int w, int h);
void Pixelate(uint8_t* src, uint32_t spitch, uint8_t* delta, uint8_t* dst, uint32_t dstp, int w, int h);
// next 3*2 use Init_2xSaI(555|565) and do not take into account
@@ -71,4 +69,4 @@ void xbrz4x32(uint8_t* src, uint32_t spitch, uint8_t*, uint8_t* dst, uint32_t ds
void xbrz5x32(uint8_t* src, uint32_t spitch, uint8_t*, uint8_t* dst, uint32_t dstp, int w, int h);
void xbrz6x32(uint8_t* src, uint32_t spitch, uint8_t*, uint8_t* dst, uint32_t dstp, int w, int h);
#endif /* FILTERS_H */
#endif // VBAM_COMPONENTS_FILTERS_FILTERS_H_

View File

@@ -1,4 +1,4 @@
#include "../System.h"
#include "core/base/system.h"
extern int RGB_LOW_BITS_MASK;

View File

@@ -35,7 +35,7 @@
* - the whole source code of the program is released with the binary.
*/
#include "../System.h"
#include <cstdint>
#ifdef MMX
extern "C" bool cpu_mmx;

Some files were not shown because too many files have changed in this diff Show More