mingw build fixes (tested with i686-w64-mingw32 on linux-x86_64)

This commit is contained in:
Robin Gareus 2014-03-04 15:25:58 +01:00
parent 3e250d5f06
commit 912f07b919
24 changed files with 147 additions and 79 deletions

View File

@ -18,19 +18,17 @@
*/
#include <math.h>
#include <iostream>
#include <cmath>
#ifdef COMPILER_MSVC
#include <float.h>
/* isinf() & isnan() are C99 standards, which older MSVC doesn't provide */
#define isinf(val) !((bool)_finite((double)val))
#define isnan(val) (bool)_isnan((double)val)
#endif
#ifdef __APPLE__
#define isinf(val) std::isinf((val))
#define isnan(val) std::isnan((val))
#define ISINF(val) !((bool)_finite((double)val))
#define ISNAN(val) (bool)_isnan((double)val)
#else
#define ISINF(val) std::isinf((val))
#define ISNAN(val) std::isnan((val))
#endif
#include <gtkmm/box.h>
@ -777,13 +775,13 @@ PluginEqGui::plot_signal_amplitude_difference(Gtk::Widget *w, cairo_t *cr)
}
*/
if (isinf(power)) {
if (ISINF(power)) {
if (power < 0) {
power = _min_dB - 1.0;
} else {
power = _max_dB - 1.0;
}
} else if (isnan(power)) {
} else if (ISNAN(power)) {
power = _min_dB - 1.0;
}

View File

@ -64,6 +64,10 @@ using Gtkmm2ext::Keyboard;
sigc::signal<void> DPIReset;
#ifdef PLATFORM_WINDOWS
#define random() rand()
#endif
/** Add an element to a menu, settings its sensitivity.
* @param m Menu to add to.

View File

@ -17,10 +17,18 @@
*/
#include <gtkmm.h>
#include "ardour/vst_plugin.h"
#include "ardour/vst_types.h"
#include "vst_plugin_ui.h"
#ifdef PLATFORM_WINDOWS
#include <gdk/gdkwin32.h>
#elif defined __APPLE__
// TODO
#else
#include <gdk/gdkx.h>
#endif
VSTPluginUI::VSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> insert, boost::shared_ptr<ARDOUR::VSTPlugin> plugin)
: PlugUIBase (insert)

View File

@ -18,6 +18,7 @@
*/
#include <fst.h>
#include <gtkmm.h>
#include <gtk/gtk.h>
#include <gtk/gtksocket.h>
#include "ardour/plugin_insert.h"
@ -25,12 +26,12 @@
#include "windows_vst_plugin_ui.h"
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#elif defined GDK_WINDOWING_WIN32
#ifdef PLATFORM_WINDOWS
#include <gdk/gdkwin32.h>
#elif defined GDK_WINDOWING_QUARTZ
/* not yet supported */
#elif defined __APPLE__
// TODO
#else
#include <gdk/gdkx.h>
#endif
using namespace Gtk;
@ -42,17 +43,21 @@ WindowsVSTPluginUI::WindowsVSTPluginUI (boost::shared_ptr<PluginInsert> pi, boos
{
#ifdef GDK_WINDOWING_WIN32
GtkWindow* wobj = win->gobj();
#if 0 // TODO verify window vs vbox-widget WRT to plugin_analysis_expander
GtkWindow* wobj = GTK_WINDOW(gtk_widget_get_toplevel(this->gobj()));
#else
GtkVBox* wobj = this->gobj();
#endif
gtk_widget_realize(GTK_WIDGET(wobj));
void* hWndHost = gdk_win32_drawable_get_handle(GTK_WIDGET(wobj)->window);
fst_run_editor (_vst->state(), hWndHost);
#else
fst_run_editor (_vst->state(), NULL);
#endif
pack_start (plugin_analysis_expander, true, true);
#endif
}
WindowsVSTPluginUI::~WindowsVSTPluginUI ()

View File

@ -398,14 +398,11 @@ def build(bld):
obj.source = gtk2_ardour_sources
obj.target = 'ardour-' + bld.env['VERSION']
obj.includes = ['.']
obj.ldflags = ['-no-undefined']
if bld.is_defined('WINDOWS_VST_SUPPORT'):
# Windows VST support mingw
obj.source += (
'../libs/fst/fst.c',
'../libs/fst/vstwin.c',
'../vst/winmain.c',
)
obj.source += [ '../vst/winmain.c' ]
obj.includes += [ '../libs/fst' ]
# at this point, "obj" refers to either the normal native executable
@ -459,7 +456,8 @@ def build(bld):
if bld.is_defined('WINDOWS_VST_SUPPORT'):
obj.source += [ 'windows_vst_plugin_ui.cc' ]
obj.defines += [ 'WINDOWS_VST_SUPPORT' ]
obj.use += [ 'X11' ]
if bld.env['build_target'] != 'mingw':
obj.use += [ 'X11' ]
if bld.is_defined('LXVST_SUPPORT'):
obj.source += [ 'linux_vst_gui_support.cc', 'lxvst_plugin_ui.cc' ]

View File

@ -16,6 +16,10 @@ using namespace std;
using namespace ARDOUR;
using namespace PBD;
#ifdef PLATFORM_WINDOWS
#define sleep(X) Sleep((X) * 1000)
#endif
static const char* localedir = LOCALEDIR;
TestReceiver test_receiver;

View File

@ -20,6 +20,7 @@
#ifndef __ardour_vst_types_h__
#define __ardour_vst_types_h__
#include <pthread.h>
#include "ardour/libardour_visibility.h"
#include "ardour/vestige/aeffectx.h"

View File

@ -351,29 +351,7 @@ VSTPlugin::load_plugin_preset (PresetRecord r)
#else
sscanf (r.uri.c_str(), "VST:%d:%d", &id, &index);
#endif
#ifdef PLATFORM_WINDOWS
int const vst_version = _plugin->dispatcher (_plugin, effGetVstVersion, 0, 0, NULL, 0);
if (vst_version >= 2) {
_plugin->dispatcher (_plugin, effBeginSetProgram, 0, 0, NULL, 0);
}
_plugin->dispatcher (_plugin, effSetProgram, 0, index, NULL, 0);
if (vst_version >= 2) {
_plugin->dispatcher (_plugin, effEndSetProgram, 0, 0, NULL, 0);
}
//unfortunately, we don't get any opcodes back from the plugin when this happens (?!)
//so we have to manually update param values from the plugin to our listeners
for (int n = 0; n < parameter_count(); n++ ) {
float p = get_parameter(n); //ask the plugin what its new setting is
Plugin::set_parameter (which, newval);
}
#else
_state->want_program = index;
#endif
return true;
}

View File

@ -24,6 +24,8 @@
#ifdef PLATFORM_WINDOWS
#include <windows.h>
#include <shlobj.h> // CSIDL_*
#include "pbd/windows_special_dirs.h"
namespace ARDOUR {
@ -56,7 +58,7 @@ vst_search_path ()
if (p == 0) {
char *pVSTx86 = 0;
char *pProgFilesX86 = get_win_special_folder (CSIDL_PROGRAM_FILESX86);
char *pProgFilesX86 = PBD::get_win_special_folder (CSIDL_PROGRAM_FILESX86);
if (pProgFilesX86) {
// Look for a VST folder under C:\Program Files (x86)
@ -75,7 +77,7 @@ vst_search_path ()
if (p == 0) {
// Look for a VST folder under C:\Program Files
char *pVST = 0;
char *pProgFiles = get_win_special_folder (CSIDL_PROGRAM_FILES);
char *pProgFiles = PBD::get_win_special_folder (CSIDL_PROGRAM_FILES);
if (pProgFiles) {
if (pVST = g_build_filename (pProgFiles, "Steinberg", "VSTPlugins", 0)) {
@ -92,7 +94,7 @@ vst_search_path ()
if (p == 0) {
// If all else failed, assume the plugins are under "My Documents"
user_home = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
user_home = (char*) g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
if (user_home) {
p = g_build_filename (user_home, "Plugins", "VST", 0);
} else {
@ -103,7 +105,7 @@ vst_search_path ()
} else {
// Concatenate the registry path with the user's personal path
user_home = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
user_home = (char*) g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
if (user_home) {
p = g_build_path (";", p, g_build_filename(user_home, "Plugins", "VST", 0), 0);

View File

@ -294,7 +294,7 @@ def configure(conf):
# controls whether we actually use it in preference to soundtouch
# Note: as of 2104, soundtouch (WSOLA) has been out-of-use for years.
conf.define('USE_RUBBERBAND', 1)
conf.define('USE_RUBBERBAND', 1)
conf.define('CURRENT_SESSION_FILE_VERSION', CURRENT_SESSION_FILE_VERSION)
@ -315,6 +315,11 @@ def configure(conf):
autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
autowaf.check_header(conf, 'cxx', 'boost/scoped_ptr.hpp')
autowaf.check_header(conf, 'cxx', 'boost/ptr_container/ptr_list.hpp')
if conf.env['WINDOWS_VST_SUPPORT'] == True and Options.options.dist_target == 'mingw':
conf.check(compiler='cxx',
lib='gdi32',
mandatory=True,
uselib_store='GDI32')
def build(bld):
@ -341,11 +346,13 @@ def build(bld):
obj.target = 'ardour'
obj.uselib = ['GLIBMM','GTHREAD','AUBIO','SIGCPP','XML','UUID',
'SNDFILE','SAMPLERATE','LRDF','AUDIOUNITS',
'OSX','BOOST','CURL','DL','TAGLIB','VAMPSDK','VAMPHOSTSDK','RUBBERBAND']
'OSX','BOOST','CURL','TAGLIB','VAMPSDK','VAMPHOSTSDK','RUBBERBAND']
obj.use = ['libpbd','libmidipp','libevoral',
'libaudiographer',
'libaudiographer',
'libtimecode',
]
if bld.env['build_target'] != 'mingw':
obj.uselib += ['DL']
if bld.is_defined('USE_EXTERNAL_LIBS'):
obj.uselib.extend(['VAMPSDK', 'LIBLTC'])
else:
@ -367,7 +374,7 @@ def build(bld):
#obj.add_objects = 'default/libs/surfaces/control_protocol/smpte_1.o'
if bld.is_defined('HAVE_LILV') :
obj.source += ['lv2_plugin.cc', 'lv2_evbuf.c', 'uri_map.cc']
obj.source += ['lv2_plugin.cc', 'lv2_evbuf.c', 'uri_map.cc']
obj.uselib += ['LILV']
if bld.is_defined('HAVE_SUIL'):
obj.uselib += ['SUIL']
@ -377,7 +384,8 @@ def build(bld):
obj.includes += [ '../fst' ]
obj.defines += [ 'WINDOWS_VST_SUPPORT' ]
if bld.env['build_target'] == 'mingw':
obj.source += [ '../fst/vstwin.c']
obj.source += [ '../fst/vstwin.c', '../fst/fst.c']
obj.uselib += ['GDI32']
if bld.is_defined('LXVST_SUPPORT'):
obj.source += [ 'lxvst_plugin.cc', 'linux_vst_support.cc' ]

View File

@ -58,6 +58,7 @@ ArdourCanvas::checkpoint (string group, string message)
map<string, struct timeval>::iterator last = last_time.find (group);
if (last != last_time.end ()) {
#if 0
time_t seconds = now.tv_sec - last->second.tv_sec;
suseconds_t useconds = now.tv_usec - last->second.tv_usec;
if (useconds < 0) {
@ -65,6 +66,7 @@ ArdourCanvas::checkpoint (string group, string message)
--seconds;
}
cout << (now.tv_sec + ((double) now.tv_usec / 1e6)) << " [" << (seconds + ((double) useconds / 1e6)) << "]: " << message << "\n";
#endif
} else {
cout << message << "\n";
}

View File

@ -4,7 +4,9 @@
#include <vector>
#include "ardour/filesystem_paths.h"
#ifdef LXVST_SUPPORT
#include "ardour/linux_vst_support.h"
#endif
#include "ardour/vst_info_file.h"
/* make stupid waf happy.
@ -16,7 +18,9 @@
* ...but waf does track include dependencies.
*/
#include "../ardour/vst_info_file.cc"
#ifdef LXVST_SUPPORT
#include "../ardour/linux_vst_support.cc"
#endif
#include "../ardour/filesystem_paths.cc"
#include "../ardour/directory_names.cc"
#include "../pbd/error.cc"

View File

@ -4,9 +4,9 @@
#ifdef PLATFORM_WINDOWS
#include <ardourext/misc.h>
#include <ardourext/pthread.h>
#include <pthread.h>
static UINT_PTR idle_timer_id = 0;
extern char *basename(char *path);
#else /* linux + wine */
@ -116,9 +116,9 @@ idle_hands(
}
}
pthread_mutex_lock (&fst->lock);
#ifndef PLATFORM_WINDOWS /* linux + wine */
/* Dispatch messages to send keypresses to the plugin */
pthread_mutex_lock (&fst->lock);
int i;
for (i = 0; i < fst->n_pending_keys; ++i) {
@ -141,6 +141,7 @@ idle_hands(
}
fst->n_pending_keys = 0;
#endif
/* See comment for maybe_set_program call below */
maybe_set_program (fst);
@ -158,7 +159,6 @@ idle_hands(
maybe_set_program (fst);
fst->program_set_without_editor = 1;
}
#endif
pthread_mutex_unlock (&fst->lock);
}

View File

@ -27,6 +27,11 @@ def configure(conf):
conf.load('misc')
conf.load('compiler_cxx')
autowaf.configure(conf)
if conf.env['WINDOWS_VST_SUPPORT'] == True and bld.env['build_target'] == 'mingw':
conf.check(compiler='cxx',
lib='gdi32',
mandatory=True,
uselib_store='GDI32')
# Add a waf `feature' to allow compilation of things using winegcc
from waflib.TaskGen import feature
@ -59,9 +64,15 @@ def build(bld):
)
obj.linkflags = ['-mwindows', '-Wl,--export-dynamic']
obj.target = 'ardour-vst-scanner.exe.so'
obj.uselib = ['GIOMM', 'DL']
else:
obj = bld (features = 'cxx c cxxprogram')
obj.source = ( 'scanner.cc' )
if bld.is_defined('WINDOWS_VST_SUPPORT'):
obj.source = ( 'scanner.cc', 'fst.c', 'vstwin.c' )
obj.uselib = ['GIOMM', 'DL', 'GDI32']
else:
obj.source = ( 'scanner.cc' )
obj.uselib = ['GIOMM', 'DL']
obj.target = 'ardour-vst-scanner'
obj.includes = [ '../pbd/', '../ardour/', '.' ]
@ -72,4 +83,3 @@ def build(bld):
'PACKAGE="' + I18N_PACKAGE + '"',
]
obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3/fst')
obj.uselib = ['GIOMM', 'DL']

View File

@ -39,3 +39,19 @@ localtime_r(const time_t *const timep, struct tm *p_tm)
}
#endif
#ifdef __MINGW64__
struct tm *
__cdecl localtime(const long int *_Time)
{
if (_Time == NULL)
{
return localtime((const time_t *const)NULL); // Unpredictable behavior in case of _Time == NULL;
}
else
{
const time_t tempTime = *_Time;
return localtime(&tempTime);
}
}
#endif

View File

@ -75,7 +75,7 @@ class ABSTRACT_UI_API AbstractUI : public BaseUI
};
typedef typename RequestBuffer::rw_vector RequestBufferVector;
#if defined(__MINGW32__) && !defined (__MINGW64__)
#ifdef COMPILER_MSVC // ?? (not needed for ming32 nor mingw64)
struct pthread_cmp
{

View File

@ -3,11 +3,22 @@
#include <time.h>
#ifdef COMPILER_MSVC
#define localtime_r( _clock, _result ) \
( *(_result) = *localtime( (_clock) ), \
(_result) )
#else
extern struct tm *localtime_r(const time_t *const timep, struct tm *p_tm);
#define localtime_r( _clock, _result ) \
( *(_result) = *localtime( (_clock) ), (_result) )
#elif defined __MINGW64__
# ifdef (localtime_r)
# undef localtime_r
# endif
// As in 64 bit time_t is 64 bit integer, compiler breaks compilation
// everytime implicit cast from long int* to time_t* worked in
// the past (32 bit). To unblock such a cast we added the localtime below:
extern struct tm *localtime(const long int *_Time);
extern struct tm *localtime_r(const time_t *const timep, struct tm *p_tm);
#endif
#endif

View File

@ -30,7 +30,7 @@
#define STDERR_FILENO 2
#endif
#if defined (__MINGW64__)
#ifdef PLATFORM_WINDOWS
#include <windows.h>
#ifdef interface

View File

@ -40,7 +40,7 @@
//
char *
get_win_special_folder (int csidl)
PBD::get_win_special_folder (int csidl)
{
wchar_t path[PATH_MAX+1];
HRESULT hr;

View File

@ -106,9 +106,14 @@ def configure(conf):
# Boost headers
autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
if conf.env['WINDOWS_VST_SUPPORT'] == True and Options.options.dist_target == 'mingw':
conf.check(compiler='cxx',
lib='ole32',
mandatory=True,
uselib_store='OLE')
def build(bld):
# Make signals_generated.h using signals.py
bld(rule = 'python ${SRC} ${TGT}', source = 'pbd/signals.py', target = 'pbd/signals_generated.h')
@ -143,14 +148,14 @@ def build(bld):
obj.vnum = LIBPBD_LIB_VERSION
obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
obj.defines += [ 'PACKAGE="' + I18N_PACKAGE + '"',
'PROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"'
'PROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"'
]
if bld.env['build_target'] == 'x86_64':
obj.defines += [ 'USE_X86_64_ASM' ]
if bld.env['build_target'] == 'mingw':
obj.source += [ 'windows_special_dirs.cc' ]
obj.linkflags = ['-lole']
obj.uselib += ' OLE'
if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'):
# Unit tests

View File

@ -100,7 +100,7 @@ instantiate(const LV2_Descriptor* descriptor,
self->synth = synth_alloc();
synth_init(self->synth, rate);
#ifndef PLATFORM_WINDOWS // easter egg is for sane platforms with native support for localtime_r only
struct tm date;
time_t now;
time(&now);
@ -109,6 +109,7 @@ instantiate(const LV2_Descriptor* descriptor,
printf("reasonable synth.lv2 says: happy holidays!\n");
self->xmas = true;
}
#endif
return (LV2_Handle)self;
}

View File

@ -58,6 +58,19 @@ using namespace std;
using namespace ARDOUR;
using namespace PBD;
#ifndef timeradd /// only avail with __USE_BSD
#define timeradd(a,b,result) \
do { \
(result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
if ((result)->tv_usec >= 1000000) \
{ \
++(result)->tv_sec; \
(result)->tv_usec -= 1000000; \
} \
} while (0)
#endif
#define ui_context() MackieControlProtocol::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
Strip::Strip (Surface& s, const std::string& name, int index, const map<Button::ID,StripButtonInfo>& strip_buttons)

View File

@ -24,7 +24,6 @@
#include <cerrno>
#include <algorithm>
#include <sys/poll.h>
#include <unistd.h>
#include <fcntl.h>

View File

@ -740,9 +740,10 @@ def configure(conf):
if opts.windows_vst:
conf.define('WINDOWS_VST_SUPPORT', 1)
conf.env['WINDOWS_VST_SUPPORT'] = True
conf.env.append_value('CFLAGS', '-I' + Options.options.wine_include)
conf.env.append_value('CXXFLAGS', '-I' + Options.options.wine_include)
autowaf.check_header(conf, 'cxx', 'windows.h', mandatory = True)
if not Options.options.dist_target == 'mingw':
conf.env.append_value('CFLAGS', '-I' + Options.options.wine_include)
conf.env.append_value('CXXFLAGS', '-I' + Options.options.wine_include)
autowaf.check_header(conf, 'cxx', 'windows.h', mandatory = True)
if opts.lxvst:
if sys.platform == 'darwin':
conf.env['LXVST_SUPPORT'] = False