-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Preliminary support of meson builds. #488
base: master
Are you sure you want to change the base?
Conversation
Tried on windows with msvc but it fails, here's the log:
Also I'm not sure to understand, is this also going to generate a visual studio project file? |
@Gillou68310 Thanks for giving a try :) By default, meson uses the ninja backend, but you can also tell it to generate a vs project file using the --backend {vs,vs2010,vs2015,vs2017} As for your error about missing pkg-config, I'll need to look a bit deeper into it. Indeed, meson rely on pkg-config to find dependencies. This works well in linux, but in windows, no so much. Two solution here: either we go the source route and use wrap files, or we go the prebuild binary way [2]. [1] http://mesonbuild.com/Using-with-Visual-Studio.html |
My initial thought on this is that I don't like it. Makefiles and MSVC project files are "native" on linux/bsd/windows, so generally they're easiest to use for end users. Adding another system on top adds new things to break and additional dependencies, plus a new thing for developers to learn and maintain. I think having separate project/make files for linux and windows is not as much of a hassle for developers as the fact that we have so many different modules, each with their own build system. So if a developer is working on a single module, like for instance RSP-HLE, and he or she adds a new file, this only requires changes in 2 places. But if a developer makes a general build system change (like, adding a new unix-like target system to the makefile) it requires changes to N files in N repositories, which is a bigger pain. Going to meson isn't necessarily going to address this issue. Some projects do have success with other system like cmake, so I'm not saying that I would never accept this type of change. But it's going to be difficult, because at a minimum we need it to support all of the systems on which we currently build, and not introduce any additional complexity. |
@richard42 Thanks for joining the discussion meson can generate ninja files (equivalent to Makefiles), VS solutions (2010, 2015 and 2017) files and XCode files. So normally each developer should get something native on their plateform. Then adding/removing/moving a file is just a matter of editing the meson.build file (eg just as easy as what it is with our current Makefile, and much easier than editing manually a vs project+filter file). Learning meson is not that hard. I've made this work in less than a week, working on it while commuting. The documentation is okay and in case of doubt there are many unit tests to learn from. The point you raise about having many repo for each plugin is valid and I think here meson can help a little bit : if we have only 1 meson.build to edit per repo, that's half what we have to edit now (1 Makefile, 1vsproj). Also because meson.build files are "composable" (you can embed projects inside another) we might be able to switch to a single top repo with all core+ui+plugins as subprojects and factor some common build logic in the top project. This could maybe address the current maintenance issue. Also some benefits I see with this transition :
Anyway, we don't have to switch to meson overnight. It can coexists (eventually in a separate branch if you don't wan't it in master yet) for some time until it has proven its value to other devs. |
meson.build
Outdated
# Add math library portably (see meson FAQ) | ||
libm = cc.find_library('m', required : false) | ||
# Use minizip when available, use embedded version otherwise | ||
# XXX: use the dependency fallback mecanism ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“mechanism”
meson.build
Outdated
# Apparently FreeBSD needs this | ||
if host_system == 'bsd' | ||
cflags += ['-DIOAPI_NO_64'] | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #85
'src/osal/files_unix.c'] | ||
# On unix platforms we also need libdl | ||
libdl = cc.find_library('dl') | ||
extra_dep += libdl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell libdl is not required by POSIX, and the BSDs (and likely others) do not have it. This should be wrapped in “if linux”.
meson.build
Outdated
endif | ||
if with_dbg_timing | ||
cflags += ['-DPROFILE'] | ||
extra_dep += cc.find_library('rt') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OpenBSD keeps librt entirely in libc, so there is no librt to find. It’s the odd one out in this regard, so this should be wrapped in “if not openbsd”.
meson.build
Outdated
endif | ||
|
||
# Select appropriate format | ||
if 'linux bsd'.contains(host_system) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not match OpenBSD (“openbsd” does).
meson.build
Outdated
elif host_system == 'windows' | ||
nasm_fmt = 'win' + (host_cpu.endswith('64') ? '64' : '32') | ||
else | ||
error('Unsupported system') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A warning would be more friendly than an error here. Is nasm a hard dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nasm is a hard dependency (provided that you enable dynarecs), so erroring is the right thing.
There are some interesting potential advantages there. However I would suggest moving the meson files into a sibling directory of the other projects, ie /project/meson/, instead of the root, to avoid cluttering up the base folder. |
Rebased against master. Tried to use the fallback parameter for dependencies. Tried to fix some concerns from @bentley. Moved some "external" files outside of src dir, but didn't update Makefile and VisualStudio. So build failures with them is expected. |
meson.build
Outdated
endif | ||
|
||
# Select appropriate format | ||
if 'linux bsd openbsd'.contains(host_system) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt “bsd” picks up FreeBSD either, but I don’t use FreeBSD so I can’t verify. You probably want to bring [email protected] into this discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I default now to ELF format so I can avoid this comparison
# Disable 64-bit IO on bsd | ||
if host_machine.system() == 'bsd' | ||
c_args += ['-DIOAPI_NO_64'] | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same BSD detection problem as before. I would reword the comment to “non‐Linux systems don’t require nonstandard API for 64-bit I/O”, and switch the conditional to “if not Linux”.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
meson.build
Outdated
endif | ||
|
||
# XXX: linking flags to export api symbols | ||
library('mupen64plus-core', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The library is called “libmupen64plus”, not “libmupen64plus-core”. Also, this should be shared_library(), not library() (see next comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to mupen64plus. However I kept library, as you can change this using the 'default_library' option.
meson.build
Outdated
link_args : vflag, | ||
link_depends : vscript, | ||
dependencies : [libm, zlib, libpng, sdl, minizip, md5, xxhash, extra_dep], | ||
version : meson.project_version(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version needs to be overrideable. This requires two things:
- A version variable early in meson.build,
libmupen64plus_version = meson.project_version()
- This line to be changed to
version : libmupen64plus_version,
You can test that you have it right by running “env LIBmupen64plus_VERSION=0.0 meson”. If it works, instead of libmupen64plus.so, libmupen64plus.so.2, libmupen64plus.so.2.5.0, you will get a single file libmupen64plus.so.0.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did what you suggested, but couldn't override using env variables
Rebased against master, addressed some concerns from @bentley, and tried to update CI files, but it looks like meson documentation is not up-to-date (http://mesonbuild.com/Continuous-Integration.html). Will look into that later. |
545c24b
to
121c5a6
Compare
3473cd6
to
34c5a54
Compare
I think I've now reached parity with Makefile+VS2013 projects as both now build on Appveyor and TravisCI. I could still do some more cleanings and refinements here and there, but I feel like asking for some feedback first could be beneficial. My porting to meson has been quite good overall even if a bit hard at times :
So yeah, now is a good time to test this PR, so I can fix the remaining concerns. |
|
I've also had some success building using meson on my Raspberry Pi 3 (aarch64). There are still some stuff that are not supported (no_asm=1) and some dependencies still have some troubles getting compiled as subprojects from meson ( update: PR pending for libpng (mesonbuild/libpng#9) |
This reverts commit a2c3549. Causes build failure on Windows LINK : fatal error LNK1181: cannot open input file 'subprojects\\xxHash-0.6.5\\xxhash.lib' Will investigate later.
I'm messing with a little side project that consumes mupen64plus and just want to register my support for this change, though I know it's an old one! Being able to reference this as a meson subproject would greatly simplify my build. Were there any significant blockers to getting this merged, or does it just need some help across the finish line? |
it's not just a little piece of work to get it across the finish line; it's more like we need a champion to take this on and commit to maintaining it in the future, because I'm happy enough just continuing with the MSVC and makefile build systems. I don't have interest in learning and maintaining an entirely different build system at this point. |
In order to lower the maintenance burden of the build system (eg. keeping in sync both Makefile and Visual studio files) I've explored the possibility of migrating to the meson build system [1].
So, I've ported the original Makefile to meson with some minor arrangements to fit in the new paradigm.
What I'm looking for now is feedback from other developers to see if there is interest in that work and what can be done to ease the eventual transition to it. I've tested this on my machine (linux, x64) and I'd like to know if it works in other platforms (windows, bsd, mac), cpu (arm, x86, mips?, ppc?) and dev env (cross-compilation, msvc).
In order to test (assuming the use of the ninja backend):
You can also inspect and change build options with
Note that this build system relies on python3 which might not be available by default in windows (should we add it to win32-deps repo ?).
Please report any issue, feedback or comment.
When/If we get this repo into shape with meson, I'll also port other repo to it (should be more easy).
cc: @richard42
[1] http://mesonbuild.com/