Skip to content

Conversation

@soerengrunewald
Copy link

Although the Makefile works perfectly fine as it is right now, it is somewhat dated. Also it makes cross-compiling and packaging a bit tedious.

So this will allow to build the library and some of the examples with meson.

[Why]
Although the Makefile works perfectly fine as it is right now. It is
somewhat dated. Also it makes cross-compiling and packaging a bit
tedious.

Signed-off-by: Soeren Grunewald <soeren.grunewald@desy.de>
@@ -0,0 +1,8 @@
libexample_commoncxx = static_library('common', 'scpi-def.cpp',
include_directories : [ inc, include_directories('.') ],

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 the include_directories() function was used. The function is still useful for e.g. defining the inc 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. :))


inc_private = include_directories( '.' )

libscpi = both_libraries('scpi',

Choose a reason for hiding this comment

The 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 default_options: ['default_library=both'].

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.

Comment on lines +6 to +21
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably do all this with a foreach loop, too.


cc = meson.get_compiler('c')

install_data(files(['LICENSE', 'README.md']))

Choose a reason for hiding this comment

The 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

@crvux
Copy link

crvux commented Jul 9, 2025

@soerengrunewald Do you plan to finish this pull request? :) I want to add a library into wrapdb. If you don't plan to, I could continue for you.

@j123b567 What do you think about using meson in the project? You don't mind this?

@j123b567
Copy link
Owner

@crvux

  • This project was never menat to be used as a separate buildable library. Yes, there are fragments in the Makefile, but it was never tested. The makefile is here mainly for testing purpose and to run examples and unit tests. The main usage of this project was expected, that you copy/reference this repo in your own project using your own build system probably other then make.
  • I'm not sure if meson is the right tool for this project. What I would like to see personally is support for PlatformIO. Or cmake, which can generate files for build system of your choice (not meson, though)
  • I'm no longer using this project and no longer programming in C so I don't know the comunity. If there is some standard library index for C like PyPI for python, cargo for rust and similar indexes for JavaScipt, C#, Golang, ... I would be happier to put the library there but I don't know about anything usable.

So instead of switching the build system (which makes no sense for me personally), I would prefere a tutorial and examples, how to intergrate this code with some other build tools of users projects, like make, meson, cmake, PlatformIO, Visual Studio, LabWindows, SCons, Ninja, ... Which would be much more useful then forcing others to use just another build system that is popular today.

@crvux
Copy link

crvux commented Jul 10, 2025

@j123b567

Got it. Then I'll try adding the library to wrapdb (this is a package manager in meson). If it works, then we can add new information about the integration to the readme.

@eli-schwartz
Copy link

Or cmake, which can generate files for build system of your choice (not meson, though)

Nope, cmake is a build system, it doesn't generate them. It configures itself and then generates Makefiles to handle parallelism, but the Makefiles execute the cmake binary. Meson and GNU autotools are similar to cmake here.

I'm no longer using this project and no longer programming in C so I don't know the comunity. If there is some standard library index for C like PyPI for python, cargo for rust and similar indexes for JavaScipt, C#, Golang, ...

No real index other than Linux distros, but there's a standard way to ask if a library is available: pkg-config. (This PR includes the creation of a pkg-config file.)

@j123b567
Copy link
Owner

j123b567 commented Jul 11, 2025

Or cmake, which can generate files for build system of your choice (not meson, though)

Nope, cmake is a build system, it doesn't generate them. It configures itself and then generates Makefiles to handle parallelism, but the Makefiles execute the cmake binary. Meson and GNU autotools are similar to cmake here.

Just to note that CMake is really just a generator or meta-build system like meson and autotools. (It is also a scripting enging cmake -P and a toolbox cmake -E, though.). With more mature build targets like ninja, the output is similar to meson's ninja output and the hard work is done by ninja without involving cmake nor meson. In Makefile case, there are many calls to cmake binary but just to show nice progres and run the install script, the build is managed by make itself. In meson case, you probably don't know abut the ninja under the hood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants