问题 运行 bash meson.build 中的脚本

problem running bash script in meson.build

我有一个heder文件vproj.h

#ifndef verVERSION
#define verVERSION "B.32.0"
#endif

和一个 bash 脚本“getVer”来提取版本,所以从 cmd 行

/home/../getVer  verVERSION vproj.h
B.32.0

现在我想用 run_command

将它嵌入我的 meson.build
version = run_command('getVer', 'verVERSION','vproj.h').stdout().strip()

但是当我尝试共同配置项目时出现以下错误

Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 227, in run return options.run_func(options) File "/usr/local/lib/python3.6/site-packages/mesonbuild/msetup.py", line 281, in run app.generate() File "/usr/local/lib/python3.6/site-packages/mesonbuild/msetup.py", line 184, in generate self._generate(env) File "/usr/local/lib/python3.6/site-packages/mesonbuild/msetup.py", line 223, in _generate intr.run() File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter/interpreter.py", line 2476, in run super().run() File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 132, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 157, in evaluate_codeblock raise e File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 150, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 165, in evaluate_statement self.assignment(cur) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 912, in assignment value = self.evaluate_statement(node.value) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 179, in evaluate_statement return self.evaluate_arraystatement(cur) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 215, in evaluate_arraystatement (arguments, kwargs) = self.reduce_arguments(cur.args) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 877, in reduce_arguments reduced_pos: T.List[T.Union[TYPE_var, InterpreterObject]] = [self.evaluate_statement(arg) for arg in args.arguments] File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 877, in reduced_pos: T.List[T.Union[TYPE_var, InterpreterObject]] = [self.evaluate_statement(arg) for arg in args.arguments] File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 163, in evaluate_statement return self.function_call(cur) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 554, in function_call res = func(node, func_args, kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/decorators.py", line 643, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/decorators.py", line 643, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/decorators.py", line 643, in wrapped return f(*wrapped_args, **wrapped_kwargs) [Previous line repeated 5 more times] File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/decorators.py", line 87, in wrapped ret = f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/decorators.py", line 106, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/decorators.py", line 224, in wrapper return f(*nargs, **wrapped_kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter/interpreter.py", line 1569, in func_dependency d = df.lookup(kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter/dependencyfallbacks.py", line 334, in lookup dep = func(kwargs, func_args, func_kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter/dependencyfallbacks.py", line 122, in _do_subproject self.interpreter.do_subproject(subp_name, 'meson', func_kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter/interpreter.py", line 909, in do_subproject raise e File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter/interpreter.py", line 893, in do_subproject return self._do_subproject_meson(subp_name, subdir, default_options, kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter/interpreter.py", line 932, in _do_subproject_meson subi.run() File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter/interpreter.py", line 2476, in run super().run() File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 132, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 157, in evaluate_codeblock raise e File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 150, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 165, in evaluate_statement self.assignment(cur) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 912, in assignment value = self.evaluate_statement(node.value) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 167, in evaluate_statement return self.method_call(cur) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 567, in method_call obj = self.evaluate_statement(invokable) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 167, in evaluate_statement return self.method_call(cur) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 567, in method_call obj = self.evaluate_statement(invokable) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 163, in evaluate_statement return self.function_call(cur) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 554, in function_call res = func(node, func_args, kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/decorators.py", line 643, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/decorators.py", line 643, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase/decorators.py", line 106, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter/interpreter.py", line 749, in func_run_command return self.run_command_impl(node, args, kwargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter/interpreter.py", line 817, in run_command_impl in_builddir=in_builddir, check=check, capture=capture) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter/interpreterobjects.py", line 166, in init self.returncode, self.stdout, self.stderr = self.run_command(cmd, args, env, source_dir, build_dir, subdir, mesonintrospect, in_builddir, check) File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter/interpreterobjects.py", line 198, in run_command p, o, e = Popen_safe(command_array, stdout=stdout, env=child_env, cwd=cwd) File "/usr/local/lib/python3.6/site-packages/mesonbuild/mesonlib/universal.py", line 1398, in Popen_safe stdout=stdout, stderr=stderr, **kwargs) File "/usr/lib64/python3.6/subprocess.py", line 729, in init restore_signals, start_new_session) File "/usr/lib64/python3.6/subprocess.py", line 1364, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) OSError: [Errno 8] Exec format error: '/home/.../getVer' FAILED: build.ninja

run_command 用法有什么问题?

我终于通过插入

开始工作了
#!/bin/bash

在脚本开头。

虽然我在猜测 getVER 包含什么,但你的也适用于我。