From c9060e984d974b4e9df6d88a6dd54030a7c0b09b Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 29 Apr 2020 16:54:26 +0200 Subject: [PATCH] Add another flag for enabling a bit bridge build --- cross-wine.conf | 16 +++++++++ cross-wine64.conf | 17 --------- meson.build | 67 ++++++++++++++++++++++++----------- meson_options.txt | 10 +++++- src/common/config/config.h.in | 30 ++++++++++++++++ src/common/config/meson.build | 13 +++++++ src/plugin/host-bridge.cpp | 8 ++--- 7 files changed, 118 insertions(+), 43 deletions(-) create mode 100644 cross-wine.conf delete mode 100644 cross-wine64.conf create mode 100644 src/common/config/config.h.in diff --git a/cross-wine.conf b/cross-wine.conf new file mode 100644 index 00000000..2253803c --- /dev/null +++ b/cross-wine.conf @@ -0,0 +1,16 @@ +[binaries] +c = 'winegcc' +cpp = 'wineg++' +ar = 'ar' +strip = 'strip' + +[properties] +# These would be the arguments for 64-bit compilation. We'll set the `-m64` flag +# (or `-m32`) in our meson.build to allow the 32-bit bitbridge to be built in +# the same build directory as the plugin and the regular 64-bit version of the +# host application to ensure that they are always in sync. +# c_args = ['-m64'] +# cpp_args = ['-m64'] +# cpp_link_args = ['-m64', '-mwindows'] +cpp_link_args = ['-mwindows'] +needs_exe_wrapper = true diff --git a/cross-wine64.conf b/cross-wine64.conf deleted file mode 100644 index fa7247e4..00000000 --- a/cross-wine64.conf +++ /dev/null @@ -1,17 +0,0 @@ -[binaries] -c = 'winegcc' -cpp = 'wineg++' -ar = 'ar' -strip = 'strip' - -[properties] -c_args=['-m64'] -cpp_args=['-m64'] -cpp_link_args=['-m64', '-mwindows'] -needs_exe_wrapper = true - -[host_machine] -system = 'linux' -cpu_family = 'x86_64' -cpu = 'x86_64' -endian = 'little' diff --git a/meson.build b/meson.build index aee1352b..6c05d81e 100644 --- a/meson.build +++ b/meson.build @@ -12,9 +12,19 @@ winelib_check = '''#ifndef __WINE__ #error 1 #endif''' if not meson.get_compiler('cpp').compiles(winelib_check) - error('You need to set up a cross compiler, check the README for more information.') + error('You need to set up a cross compiler, check the README for compilation instructions.') endif +# Depending on the `use-bitbridge` flag we'll enable building a second 32-bit +# host application that can act as a bit bridge for using 32-bit Windows plugins +# in 64-bit Linux VST hsots. The plugin will determine which host application to +# use based on the `.dll` file it's trying to load. +# This setup is necessary until Meson provides a way to have multiple +# cross-builds for a single build directory: +# https://github.com/mesonbuild/meson/issues/5125 +host_name_64bit = 'yabridge-host' +host_name_32bit = 'yabridge-host-32' + # This provides an easy way to start the Wine VST host using winedbg since it # can be quite a pain to set up compiler_options = [] @@ -22,13 +32,8 @@ if get_option('use-winedbg') compiler_options += '-DUSE_WINEDBG' endif -# The application consists of a VST plugin (yabridge) that calls a winelib -# program (yabridge-host) that can host Windows VST plugins. More information -# about the way these two components work together can be found in the readme -# file. - # Generate header files for configuration variables such as the current git tag -# and the last commit hash +# and the name of the host binary subdir('src/common/config') boost_dep = dependency('boost', modules : ['filesystem']) @@ -40,6 +45,11 @@ xcb_dep = dependency('xcb') include_dir = include_directories('src/include') +# The application consists of a VST plugin (yabridge) that calls a winelib +# program (yabridge-host) that can host Windows VST plugins. More information +# about the way these two components work together can be found in the readme +# file. + shared_library( 'yabridge', [ @@ -56,21 +66,38 @@ shared_library( link_args : ['-ldl'] ) +host_sources = [ + 'src/common/logging.cpp', + 'src/common/serialization.cpp', + 'src/wine-host/editor.cpp', + 'src/wine-host/editor.cpp', + 'src/wine-host/plugin-bridge.cpp', + 'src/wine-host/vst-host.cpp', + 'src/wine-host/utils.cpp', + version_header, +] + executable( - 'yabridge-host', - [ - 'src/common/logging.cpp', - 'src/common/serialization.cpp', - 'src/wine-host/editor.cpp', - 'src/wine-host/editor.cpp', - 'src/wine-host/plugin-bridge.cpp', - 'src/wine-host/vst-host.cpp', - 'src/wine-host/utils.cpp', - version_header, - ], + host_name_64bit, + host_sources, native : false, include_directories : include_dir, dependencies : [boost_dep, bitsery_dep, wine_threads_dep, xcb_dep], - cpp_args : compiler_options, - link_args : [] + cpp_args : compiler_options + ['-m64'], + link_args : ['-m64'] ) + +if get_option('use-bitbridge') + compiler_options += '-DUSE_BITBRIDGE' + + # TODO: Use 32 bit libraries + executable( + host_name_32bit, + host_sources, + native : false, + include_directories : include_dir, + dependencies : [boost_dep, bitsery_dep, wine_threads_dep, xcb_dep], + cpp_args : compiler_options + ['-m32'], + link_args : ['-m32'] + ) +endif diff --git a/meson_options.txt b/meson_options.txt index 0cf248c6..fab1ccee 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,6 +1,14 @@ +option( + 'use-bitbridge', + type : 'boolean', + value : false, + description : '''Build a 32-bit host application for hosting 32-bit plugins. + See the readme for full instructions on how to use this.''' +) + option( 'use-winedbg', type : 'boolean', value : false, - description: 'Whether to run the Wien VST host with GDB attached. Might not always be reliable.' + description : 'Whether to run the Wien VST host with GDB attached. Might not always be reliable.' ) diff --git a/src/common/config/config.h.in b/src/common/config/config.h.in new file mode 100644 index 00000000..8f225016 --- /dev/null +++ b/src/common/config/config.h.in @@ -0,0 +1,30 @@ +// yabridge: a Wine VST bridge +// Copyright (C) 2020 Robbert van der Helm +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#pragma once + +/** + * The name of the wine host name, e.g. `yabridge-host.exe` for the regular 64 + * bit build. + */ +constexpr char yabridge_wine_host_name[] = "@host_binary_64bit@"; + +/** + * The name of the 32-bit wine host name, e.g. `yabridge-host-32.exe`.` This is + * used as a bitbridge to be able to load legacy 32-bit only Windows plugins + * from a 64-bit Linux host. + */ +constexpr char yabridge_wine_host_name_32bit[] = "@host_binary_32bit@"; diff --git a/src/common/config/meson.build b/src/common/config/meson.build index 5513065a..eb2cd4f6 100644 --- a/src/common/config/meson.build +++ b/src/common/config/meson.build @@ -1,3 +1,16 @@ +# Contains constants determined while configuring the build. As an alternative +# to preprocessor macros. +config_header = configure_file( + input : 'config.h.in', + output : 'config.h', + configuration : configuration_data( + { + 'host_binary_32bit': host_name_32bit + '.exe', + 'host_binary_64bit': host_name_64bit + '.exe', + } + ) +) + # Generate a file containing the last annotated git tag and possibly also the # amount of commits since then and the hash of the last commit version_header = vcs_tag( diff --git a/src/plugin/host-bridge.cpp b/src/plugin/host-bridge.cpp index 6398dff5..4165e13d 100644 --- a/src/plugin/host-bridge.cpp +++ b/src/plugin/host-bridge.cpp @@ -30,6 +30,7 @@ #endif // Generated inside of build directory +#include #include #include "../common/communication.h" @@ -40,11 +41,6 @@ namespace bp = boost::process; // boost::filesystem namespace fs = boost::filesystem; -/** - * The name of the wine VST host binary. - */ -constexpr auto yabridge_wine_host_name = "yabridge-host.exe"; - /** * Used for generating random identifiers. */ @@ -500,6 +496,8 @@ fs::path find_wine_vst_host() { return host_path; } + // TODO: First, check whether the plugin is 32-bit or 64-bit, and then + // search for the correct binary accordingly // Bosot will return an empty path if the file could not be found in the // search path const fs::path vst_host_path = bp::search_path(yabridge_wine_host_name);