Providing header dependency in meson - idl

I am using meson build system 0.49.0 on ubuntu 18.04. My project has some idl files and i want to include header files from another folder. How do I add provide include_directories in meson.
idl_compiler = find_program('widl')
idl_generator = generator(idl_compiler,
output : [ '#BASENAME#.h' ],
arguments : [ '-h', '-o', '#OUTPUT#', '#INPUT#' ])
idl_files = [ .... ]
header_files = idl_generator.process(idl_files)

You can add include directories directly to generator() arguments:
idl_generator = generator(idl_compiler,
output : '#BASENAME#.h',
arguments : [
'-h',
'-o', '#OUTPUT#',
'-I', '#0#/src/'.format(meson.current_source_dir()),
'#INPUT#' ])
I added -I option which according to docs can be used to
Add a header search directory to path. Multiple search directories are
allowed.
and used meson's string formatting together with meson's object method current_source_dir() which
returns a string to the current source directory.
Note also that output argument is string, not list.
Or, for example, if you have several of them and need to use them as dependency later, you can have array:
my_inc_dirs = ['.', 'include/xxx', 'include']
generate args for generator:
idl_gen_args = [ '-h', '-o', '#OUTPUT#', '#INPUT#' ]
foreach dir : my_inc_dirs
idl_gen_args += ['-I', '#0#/#1#'.format(meson.current_source_dir(), dir)]
endforeach
idl_generator = generator(idl_compiler,
output : '#BASENAME#.h',
arguments : idl_gen_args)
and use later for dependency:
my_exe = executable(
...
include_directories : [my_inc_dirs],
...)

Related

How to make gir look only on local bindings

When I try to generate Rust FFI via gir, it always seems to try to find used dependencies.
So I have a Gir.toml like that:
[options]
girs_directories = ["../foo_gir"]
library = "Foo"
version = "0.1"
target_path = "."
min_cfg_version = "0.1"
external_libraries = [
"GLib-2.0",
"GObject",
]
work_mode = "sys"
and was expecting gir to then handle GLib-2.0 automagically.
When I however execute gir it complains
Error: "Couldn't find GLib-2.0..."

Self-referential values in an R config file

Using the config package, I'd like elements to reference other elements,
like how path_file_a references path_directory.
config.yml file in the working directory:
default:
path_directory : "data-public"
path_file_a : "{path_directory}/a.csv"
path_file_b : "{path_directory}/b.csv"
path_file_c : "{path_directory}/c.csv"
# recursive : !expr file.path(config::get("path_directory"), "c.csv")
Code:
config <- config::get()
config$path_file_a
# Returns: "{path_directory}/a.csv"
glue::glue(config$path_file_a, .envir = config)
# Returns: "data-public/a.csv"
I can use something like glue::glue() on the value returned by config$path_file_a.
But I'd prefer to have the value already substituted so config$path_file_a contains the actual value (not the template for the value).
As you might expect, uncommenting the recursive line creates an endless self-referential loop.
Are there better alternatives to glue::glue(config$path_file_a, .envir = config)?
I came across the same problem and I've written a wrapper around config and glue.
The package is called gonfig and has been submitted to CRAN.
With it you would have:
config.yml
default:
path_directory : "data-public"
path_file_a : "{path_directory}/a.csv"
path_file_b : "{path_directory}/b.csv"
path_file_c : "{path_directory}/c.csv"
And in your R script:
config <- gonfig::get()
config$path_file_c
#> "data-public/c.csv"

qmake variable reference in project file

I am trying to use qmake to include all files in a directory (this project is an external subversion project with hundreds of files). I am using qmake version 3.1.
What I tried was something like:
server_files = $$files($$PWD/server)
SOURCES += server_files(*.cpp, true)
The first line does not give any error but the second line gives:
:-1: warning: Failure to find: server_files(*.cpp,
:-1: warning: Failure to find: true)
Putting a $ sign in front of the variable as SOURCES += $server_files(*.cpp, true) gives the same error.
The following example function takes a variable name as its only argument, extracts a list of values from the variable with the eval() built-in function, and compiles a list of files:
defineReplace(headersAndSources) {
variable = $$1
names = $$eval($$variable)
headers =
sources =
for(name, names) {
header = $${name}.h
exists($$header) {
headers += $$header
}
source = $${name}.cpp
exists($$source) {
sources += $$source
}
}
return($$headers $$sources)
}
Variable Processing Functions

qmake: Nested function call in .pro files

Given the following code contained in a qmake project file:
QWT_LIB_BINARY=/usr/lib/libqwt-qt4.so
TEMP1 = $$basename(QWT_LIB_BINARY)
TEMP2 = $$replace(TEMP1, .so, )
QWT_LIB_NAME = $$replace(TEMP2, lib, )
message(QWT library name = $$QWT_LIB_NAME)
Eliminates the path, the 'lib' prefix and the '.so' suffix of the string
contained in the QWT_LIB_BINARY variable. When compiling, the 'make' command
outputs the following line:
Project MESSAGE: QWT library name = qwt-qt4
When the temporary variable assignations are eliminated, like this:
QWT_LIB_BINARY=/usr/lib/libqwt-qt4.so
QWT_LIB_NAME = $$replace($$replace($$basename(QWT_LIB_BINARY), .so, ), lib, )
message(QWT library name = $$QWT_LIB_NAME)
The 'make' command outputs the message:
Project MESSAGE: QWT library name =
Indicating that the last code is not working correctly. Is it possible to
nest function calls in '.pro' files in some other way, so it can work?

How do I pass parameters to a jar file at the time of execution?

How do I pass parameters to a JAR file at the time of execution?
To pass arguments to the jar:
java -jar myjar.jar one two
You can access them in the main() method of "Main-Class" (mentioned in the manifest.mf file of a JAR).
String one = args[0];
String two = args[1];
The JAVA Documentation says:
java [ options ] -jar file.jar [
argument ... ]
and
... Non-option arguments after the
class name or JAR file name are passed
to the main function...
Maybe you have to put the arguments in single quotes.
You can do it with something like this, so if no arguments are specified it will continue anyway:
public static void main(String[] args) {
try {
String one = args[0];
String two = args[1];
}
catch (ArrayIndexOutOfBoundsException e){
System.out.println("ArrayIndexOutOfBoundsException caught");
}
finally {
}
}
And then launch the application:
java -jar myapp.jar arg1 arg2
java [ options ] -jar file.jar [ argument ... ]
if you need to pass the log4j properties file use the below option
-Dlog4j.configurationFile=directory/file.xml
java -Dlog4j.configurationFile=directory/file.xml -jar <JAR FILE> [arguments ...]
Incase arguments have spaces in it, you can pass like shown below.
java -jar myjar.jar 'first argument' 'second argument'

Resources