3

我正在用 gnome-builder 和 flatpak 构建一个 Vala 程序。我不想连接到 mySQL 数据库。这就是为什么我需要运行mysql_config以获得正确的编译器标志。

所以我添加mysql_config = find_program('mysql_config')到我的 meson.build 文件中。

当我尝试编译时,我得到meson.build:7:0: ERROR: Program(s) ['mysql_config'] not found or not executable.

当我whereis mysql_config在命令行上运行时,我得到了预期的结果mysql_config: /usr/bin/mysql_config。我也可以从命令行运行mysql_config --cflags预期的结果-I/usr/include/mysql -I/usr/include/mysql

这就是为什么我认为问题在于我正在使用 flatpak-builder 进行构建。

我的./meson.build:

project('zeiterfassunggtk', ['c', 'vala'],        version: '0.1.0',
  meson_version: '>= 0.40.0',
)

i18n = import('i18n')

mysql_config = find_program('mysql_config')
mysql_vapi = meson.get_compiler('vala').find_library('mysql')
mysql_dep = declare_dependency(c_args: run_command([mysql_config, '--cflags']).stdout().split(),
                               link_args: run_command([mysql_config, '--libs']).stdout().split(),
dependencies: [mysql_vapi])

subdir('data')
subdir('src')
subdir('po')

meson.add_install_script('build-aux/meson/postinstall.py')

我的 ./src/meson.build

zeiterfassunggtk_sources = [
  'main.vala',
  'window.vala',
  'mysql.vala',
]

zeiterfassunggtk_deps = [
  dependency('gio-2.0', version: '>= 2.50'),
  dependency('gtk+-3.0', version: '>= 3.22'),
]

gnome = import('gnome')

zeiterfassunggtk_sources += gnome.compile_resources('zeiterfassunggtk-resources',
  'zeiterfassunggtk.gresource.xml',
  c_name: 'zeiterfassunggtk'
)

executable('zeiterfassunggtk', zeiterfassunggtk_sources,
  vala_args: '--target-glib=2.50',  dependencies: zeiterfassunggtk_deps,
  install: true,
)

构建过程的完整输出:

flatpak build --env=LANG=de_AT.UTF-8 --env=USER=g.zehetner --env=HOME=/home/g.zehetner --env=PATH=/usr/bin:/bin --env=TERM=xterm-256color --env=V=0 --env=CCACHE_DIR=/home/g.zehetner/.cache/gnome-builder/flatpak-builder/ccache --env=PATH=/app/bin:/usr/bin --build-dir=/home/g.zehetner/.cache/gnome-builder/projects/ZeiterfassungGtk/builds/org.gnome.Zeiterfassunggtk.json-flatpak-org.gnome.Platform-x86_64-3.26-master --share=network --nofilesystem=host --filesystem=/home/g.zehetner/.cache/gnome-builder --filesystem=/home/g.zehetner/Projekte/ZeiterfassungGtk --filesystem=/home/g.zehetner/.cache/gnome-builder/projects/ZeiterfassungGtk/builds/org.gnome.Zeiterfassunggtk.json-flatpak-org.gnome.Platform-x86_64-3.26-master --env=V=1 '--env=CFLAGS=-O2 -g' '--env=CXXFLAGS=-O2 -g' --env=NOCONFIGURE=1 /home/g.zehetner/.cache/gnome-builder/projects/ZeiterfassungGtk/flatpak/staging/x86_64-master ninja
[0/1] Regenerating build files.
The Meson build system
Version: 0.46.0
Source dir: /home/g.zehetner/Projekte/ZeiterfassungGtk
Build dir: /home/g.zehetner/.cache/gnome-builder/projects/ZeiterfassungGtk/builds/org.gnome.Zeiterfassunggtk.json-flatpak-org.gnome.Platform-x86_64-3.26-master
Build type: native build
Project name: zeiterfassunggtk
Native C compiler: ccache cc (gcc 6.2.0 "cc (GCC) 6.2.0")
Appending CFLAGS from environment: '-O2 -g'
Appending LDFLAGS from environment: '-L/app/lib '
Native Vala compiler: valac (valac 0.38.2)
Appending LDFLAGS from environment: '-L/app/lib '
Build machine cpu family: x86_64
Build machine cpu: x86_64
Program mysql_config found: NO

meson.build:7:0: ERROR:  Program(s) ['mysql_config'] not found or not executable

A full log can be found at /home/g.zehetner/.cache/gnome-builder/projects/ZeiterfassungGtk/builds/org.gnome.Zeiterfassunggtk.json-flatpak-org.gnome.Platform-x86_64-3.26-master/meson-logs/meson-log.txt
FAILED: build.ninja 
/usr/bin/python3 /usr/bin/meson --internal regenerate /home/g.zehetner/Projekte/ZeiterfassungGtk /home/g.zehetner/.cache/gnome-builder/projects/ZeiterfassungGtk/builds/org.gnome.Zeiterfassunggtk.json-flatpak-org.gnome.Platform-x86_64-3.26-master --backend ninja
ninja: error: rebuilding 'build.ninja': subcommand failed

你可以在Github.com找到完整的代码

4

0 回答 0