-
Notifications
You must be signed in to change notification settings - Fork 254
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
Add ability to build minmea with meson #28
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
*~ | ||
*.diff | ||
.*.swp | ||
minmea | ||
tests | ||
example | ||
minmea/tests | ||
minmea/example | ||
*.exe | ||
build | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
project( | ||
'minmea', | ||
'c', | ||
default_options: ['c_std=c99', 'buildtype=debug'], | ||
) | ||
|
||
add_project_arguments( | ||
'-Wall', '-Wextra', '-Werror', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meson will warn you not to do this, and suggest instead that you set default_options to include This will guarantee that it works cross-platform and on any compiler, and it also means that when GCC adds new warnings to -Wextra, which it often does, users can still build the project by passing |
||
'-D_POSIX_C_SOURCE=199309L', '-D_BSD_SOURCE', '-D_DEFAULT_SOURCE', | ||
'-D_DARWIN_C_SOURCE', | ||
language: 'c', | ||
) | ||
|
||
if host_machine.system() == 'windows' | ||
add_project_arguments('DMINMEA_INCLUDE_COMPAT') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is missing a leading |
||
endif | ||
|
||
c_args = [] | ||
|
||
if get_option('buildtype') == 'debug' | ||
c_args += '-ggdb' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The debug buildtype already sets -g, why do you need to enforce -ggdb (which the Makefile doesn't do anyway)? |
||
endif | ||
|
||
minmea_includes = include_directories('.') | ||
|
||
minmea_sources = ['minmea/minmea.c'] | ||
|
||
minmea_dependencies = [] | ||
|
||
minmea_lib = library( | ||
'minmea', | ||
minmea_sources, | ||
include_directories: minmea_includes, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current directory is an implicit include, you still need to use it for declare_dependency, but you don't need it for defining the library. Minus one line. |
||
dependencies: minmea_dependencies, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an empty array, is it just future proofing? The project should confirm whether it's worth the additional lines for something that may have a definite development policy to never utilize. In fact this seems likely to be the case, the project goals state that it is lightweight/minimal, and mention the bullet point:
So it sounds like they would not be willing to add dependencies in the future, which means you don't need to plan ahead for dependencies. |
||
c_args: c_args, | ||
) | ||
|
||
minmea_dep = declare_dependency( | ||
include_directories: minmea_includes, | ||
dependencies: minmea_dependencies, | ||
link_with: minmea_lib, | ||
) | ||
|
||
if get_option('example') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would not bother with this option, just always define the example to be built. It's a single compile rule with no dependencies, it doesn't add any complexity to building, so there's no cost to always building it. If you just don't want to run an extraneous build rule when using this as a wrap, set this executable to |
||
minmea_example_sources = [ | ||
'minmea/example.c', | ||
] | ||
|
||
minmea_example_dependencies = [ | ||
minmea_dep, | ||
] | ||
|
||
minmea_example = executable( | ||
'example', | ||
minmea_example_sources, | ||
dependencies: minmea_example_dependencies, | ||
) | ||
endif | ||
|
||
if get_option('tests') | ||
check = dependency('check') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would use a feature option for this these days, you can do Then, you can check whether the dependency was found and only when it is found, define the tests. |
||
|
||
minmea_test_sources = [ | ||
'minmea/tests.c', | ||
] | ||
|
||
minmea_test_dependencies = [ | ||
check, | ||
minmea_dep, | ||
] | ||
|
||
minmea_test = executable( | ||
'tests', | ||
minmea_test_sources, | ||
dependencies: minmea_test_dependencies, | ||
) | ||
|
||
test('tests', minmea_test) | ||
endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
option('tests', type: 'boolean', value: true) | ||
option('example', type: 'boolean', value: true) |
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 is not necessary:
it may be named anything and a popular convention is
builddir/
, orbuilddir-release/
andbuilddir-debug/
, so this gitignore entry likely won't take effectMeson knows at the time of creating
builddir/
that it is a build directory, and that no files in there should be added to git, so it createsbuilddir/.gitignore
which ignores*
, so that you don't have to. This just magically works.Admittedly, this was implemented in December 2020 via mesonbuild/meson@7437d98 and released in Meson 0.57.0, so back when you originally submitted this PR that was not the case, but still... it is long past December 2020, so you can remove this now. :)