-
Notifications
You must be signed in to change notification settings - Fork 201
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 meson build-system support #153
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
libexample_commoncxx = static_library('common', 'scpi-def.cpp', | ||
include_directories : [ inc, include_directories('.') ], | ||
) | ||
|
||
libexample_commoncxx_dep = declare_dependency( | ||
include_directories : [ inc, include_directories('.') ], | ||
link_with : libexample_commoncxx, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
libexample_common = static_library('common', 'scpi-def.c', | ||
include_directories : [ inc, include_directories('.') ], | ||
) | ||
|
||
libexample_common_dep = declare_dependency( | ||
include_directories : [ inc, include_directories('.') ], | ||
link_with : libexample_common, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
subdir('common') | ||
subdir('common-cxx') | ||
|
||
subdir('test-interactive') | ||
subdir('test-interactive-cxx') | ||
subdir('test-parser') | ||
|
||
subdir('test-tcp') | ||
subdir('test-tcp-srq') | ||
|
||
##subdir('test-CVI_w_GUI') | ||
##subdir('test-LwIP-netconn') | ||
subdir('test-vxi11') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
executable('test-interactive', 'main.cpp', dependencies: [ libscpi_static_dep, libexample_commoncxx_dep ]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
executable('test-interactive', 'main.c', dependencies: [ libscpi_static_dep, libexample_common_dep ]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
executable('test-parser', 'main.c', dependencies: [ libscpi_static_dep, libexample_common_dep ]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
executable('test-tcp-srq', 'main.c', dependencies: [ libscpi_static_dep, libexample_common_dep ]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
executable('test-tcp', 'main.c', dependencies: [ libscpi_static_dep, libexample_common_dep ]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
vxi11_dep = dependency('vxi11', required: false) | ||
tirpc_dep = dependency('libtirpc', required: false) | ||
|
||
if vxi11_dep.found() and tirpc_dep.found() | ||
executable('test-vxi11', | ||
[ 'main.c', 'vxi11_xdr.c' ], | ||
dependencies: [ | ||
libscpi_static_dep, | ||
libexample_common_dep, | ||
tirpc_dep, vxi11_dep, | ||
] | ||
) | ||
endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
inc = include_directories('.') | ||
|
||
headers = files([ | ||
'scpi/cc.h', | ||
'scpi/config.h', | ||
'scpi/constants.h', | ||
'scpi/error.h', | ||
'scpi/expression.h', | ||
'scpi/ieee488.h', | ||
'scpi/minimal.h', | ||
'scpi/parser.h', | ||
'scpi/scpi.h', | ||
'scpi/types.h', | ||
'scpi/units.h', | ||
'scpi/utils.h', | ||
]) | ||
|
||
install_headers(headers, subdir: 'scpi') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
subdir('inc') | ||
subdir('src') | ||
subdir('test') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 'scpi.g' | ||
sources = files([ | ||
'error.c', | ||
'expression.c', | ||
'fifo.c', | ||
'ieee488.c', | ||
'lexer.c', | ||
'minimal.c', | ||
'parser.c', | ||
'units.c', | ||
'utils.c', | ||
]) | ||
|
||
inc_private = include_directories( '.' ) | ||
|
||
libscpi = both_libraries('scpi', | ||
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. Instead of both_libraries, I would generally recommend using library() but setting the meson project option This allows end users to decide which ones they need, if they really want to. Unless there's a technical reason why the software requires that all users have both of them. |
||
sources, | ||
soversion: meson.project_version(), | ||
include_directories: [ inc, inc_private ], | ||
install: true, | ||
) | ||
|
||
libscpi_dynamic_dep = declare_dependency( | ||
include_directories: inc, | ||
link_with: libscpi.get_shared_lib(), | ||
) | ||
|
||
libscpi_static_dep = declare_dependency( | ||
include_directories: inc, | ||
link_with: libscpi.get_static_lib(), | ||
) | ||
|
||
pkg = import('pkgconfig') | ||
pkg.generate(libscpi, | ||
name: 'libscpi', | ||
description : 'SCPI parser library', | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
cunit_dep = dependency('cunit', required: false) | ||
if cunit_dep.found() | ||
deps = [ libscpi_static_dep, cunit_dep ] | ||
|
||
test('fifo', | ||
executable('fifo', 'test_fifo.c', dependencies: deps) | ||
) | ||
|
||
test('lexer_parser', | ||
executable('lexer_parser', 'test_lexer_parser.c', dependencies: deps) | ||
) | ||
|
||
test('parser', | ||
executable('parser', 'test_parser.c', dependencies: deps) | ||
) | ||
|
||
test('scpi_utils', | ||
executable('scpi_utils', 'test_scpi_utils.c', dependencies: deps) | ||
) | ||
endif | ||
Comment on lines
+6
to
+21
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. You could probably do all this with a foreach loop, too. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
project('scpi-parser', [ 'c', 'cpp' ], | ||
version : '2.2', | ||
license : 'BSD', | ||
meson_version : '>= 0.60', | ||
default_options : [ | ||
'warning_level=3', | ||
'buildtype=debugoptimized', | ||
] | ||
) | ||
|
||
|
||
c_args = [] | ||
cpp_args = [] | ||
|
||
cc = meson.get_compiler('c') | ||
|
||
install_data(files(['LICENSE', 'README.md'])) | ||
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 Makefile doesn't install README.md anywhere... I wonder how generally useful this is? The LICENSE file, since meson 1.1.0, can be handled via https://mesonbuild.com/Reference-manual_functions.html#project_license_files |
||
|
||
subdir('libscpi') | ||
subdir('examples') |
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.
Since meson 0.50 (you specified an 0.60 minimum requirement), the arguments to
include_directories: [...]
can be a string, and it is automatically converted as though theinclude_directories()
function was used. The function is still useful for e.g. defining theinc
variable in one directory and using it in another. :)That being said,
implicit_include_directories: true
is the default and means that executables/libraries already, implicitly, have'.'
as an include directory. So this is redundant.(You still need it down below for declare_dependency. :))