[SCM] suil/master: Imported Upstream version 0.6.6~dfsg0
alessio at users.alioth.debian.org
alessio at users.alioth.debian.org
Thu Nov 22 02:05:02 UTC 2012
The following commit has been merged in the master branch:
commit a76af6998374cc45d32564a5539067349a288ebf
Author: Alessio Treglia <alessio at debian.org>
Date: Thu Nov 22 01:58:17 2012 +0000
Imported Upstream version 0.6.6~dfsg0
diff --git a/COPYING b/COPYING
index 73bf8fe..4e344ca 100644
--- a/COPYING
+++ b/COPYING
@@ -1,4 +1,4 @@
-Copyright 2007-2011 David Robillard <http://drobilla.net>
+Copyright 2007-2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/NEWS b/NEWS
index e47c5e7..3c6854c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,14 @@
+suil (0.6.6) stable;
+
+ * Fix embedding Gtk in Qt as a child widget (support reparenting)
+ * Support for wrapping native Windows UIs in Gtk2
+ * Gracefully handle UIs with no port_event method
+ * Replace host provided features that match Suil implemented features, rather
+ than passing UIs duplicate features
+ * Disable timestamps in HTML documentation for reproducible build
+
+ -- David Robillard <d at drobilla.net> Wed, 14 Nov 2012 11:17:03 -0500
+
suil (0.6.4) stable;
* Correctly handle resizing for Gtk2 in Qt4
diff --git a/doc/reference.doxygen.in b/doc/reference.doxygen.in
index 9d74133..f1ce6ac 100644
--- a/doc/reference.doxygen.in
+++ b/doc/reference.doxygen.in
@@ -583,7 +583,7 @@ FILE_VERSION_FILTER =
# You can optionally specify a file name after the option, if omitted
# DoxygenLayout.xml will be used as the name of the layout file.
-LAYOUT_FILE = doc/layout.xml
+LAYOUT_FILE = @SUIL_SRCDIR@/doc/layout.xml
# The CITE_BIB_FILES tag can be used to specify one or more bib files
# containing the references data. This must be a list of .bib files. The
@@ -899,7 +899,7 @@ HTML_FOOTER =
# the style sheet file to the HTML output directory, so don't put your own
# style sheet in the HTML output directory as well, or it will be erased!
-HTML_STYLESHEET = doc/style.css
+HTML_STYLESHEET = @SUIL_SRCDIR@/doc/style.css
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
@@ -939,7 +939,7 @@ HTML_COLORSTYLE_GAMMA = 80
# page will contain the date and time when the page was generated. Setting
# this to NO can help when comparing the output of multiple runs.
-HTML_TIMESTAMP = YES
+HTML_TIMESTAMP = NO
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# documentation will contain sections that can be hidden and shown after the
diff --git a/src/gtk2_in_qt4.cpp b/src/gtk2_in_qt4.cpp
index bb58dfb..731a4d8 100644
--- a/src/gtk2_in_qt4.cpp
+++ b/src/gtk2_in_qt4.cpp
@@ -1,5 +1,5 @@
/*
- Copyright 2011 David Robillard <http://drobilla.net>
+ Copyright 2011-2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -25,6 +25,14 @@
extern "C" {
+typedef struct _SuilGtk2InQt4Wrapper SuilGtk2InQt4Wrapper;
+
+struct _SuilGtk2InQt4Wrapper {
+ QX11EmbedContainer* host_widget;
+ QWidget* parent;
+ GtkWidget* plug;
+};
+
static void
on_size_request(GtkWidget* widget,
GtkRequisition* requisition,
@@ -43,13 +51,31 @@ on_size_allocate(GtkWidget* widget,
wrap->resize(allocation->width, allocation->height);
}
+static void
+wrapper_free(SuilWrapper* wrapper)
+{
+ SuilGtk2InQt4Wrapper* impl = (SuilGtk2InQt4Wrapper*)wrapper->impl;
+
+ if (impl->plug) {
+ gtk_widget_destroy(impl->plug);
+ }
+
+ if (impl->host_widget) {
+ delete impl->host_widget;
+ }
+
+ free(impl);
+}
+
static int
wrapper_wrap(SuilWrapper* wrapper,
SuilInstance* instance)
{
- QX11EmbedContainer* const wrap = new QX11EmbedContainer();
- GtkWidget* const plug = gtk_plug_new(wrap->winId());
- GtkWidget* const widget = (GtkWidget*)instance->ui_widget;
+ SuilGtk2InQt4Wrapper* const impl = (SuilGtk2InQt4Wrapper*)wrapper->impl;
+ QWidget* root = static_cast<QWidget*>(impl->parent);
+ QX11EmbedContainer* const wrap = new QX11EmbedContainer(root);
+ GtkWidget* const plug = gtk_plug_new(wrap->winId());
+ GtkWidget* const widget = (GtkWidget*)instance->ui_widget;
gtk_container_add(GTK_CONTAINER(plug), widget);
gtk_widget_show_all(plug);
@@ -68,17 +94,20 @@ wrapper_wrap(SuilWrapper* wrapper,
g_signal_connect(
G_OBJECT(plug), "size-allocate", G_CALLBACK(on_size_allocate), wrap);
+ impl->host_widget = wrap;
+ impl->plug = plug;
instance->host_widget = wrap;
return 0;
}
-SUIL_API
+SUIL_LIB_EXPORT
SuilWrapper*
suil_wrapper_new(SuilHost* host,
const char* host_type_uri,
const char* ui_type_uri,
- LV2_Feature*** features)
+ LV2_Feature*** features,
+ unsigned n_features)
{
/* We have to open libgtk here, so Gtk type symbols are present and will be
found by the introspection stuff. This is required at least to make
@@ -96,10 +125,24 @@ suil_wrapper_new(SuilHost* host,
gtk_init(NULL, NULL);
}
+ /* Create wrapper implementation. */
+ SuilGtk2InQt4Wrapper* const impl = (SuilGtk2InQt4Wrapper*)
+ malloc(sizeof(SuilGtk2InQt4Wrapper));
+ impl->host_widget = NULL;
+ impl->parent = NULL;
+ impl->plug = NULL;
+
+ /* Set parent widget if given. */
+ for (unsigned i = 0; i < n_features; ++i) {
+ if (!strcmp((*features)[i]->URI, LV2_UI__parent)) {
+ impl->parent = static_cast<QWidget*>((*features)[i]->data);
+ }
+ }
+
SuilWrapper* wrapper = (SuilWrapper*)malloc(sizeof(SuilWrapper));
wrapper->wrap = wrapper_wrap;
- wrapper->free = NULL;
- wrapper->impl = NULL;
+ wrapper->free = wrapper_free;
+ wrapper->impl = impl;
return wrapper;
}
diff --git a/src/host.c b/src/host.c
index 6a2bda8..264d044 100644
--- a/src/host.c
+++ b/src/host.c
@@ -23,7 +23,7 @@ suil_host_new(SuilPortWriteFunc write_func,
SuilPortSubscribeFunc subscribe_func,
SuilPortUnsubscribeFunc unsubscribe_func)
{
- SuilHost* host = malloc(sizeof(struct SuilHostImpl));
+ SuilHost* host = (SuilHost*)malloc(sizeof(struct SuilHostImpl));
host->write_func = write_func;
host->index_func = index_func;
host->subscribe_func = subscribe_func;
diff --git a/src/instance.c b/src/instance.c
index 2f68692..617280e 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -15,7 +15,6 @@
*/
#include <assert.h>
-#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -26,6 +25,7 @@
#define GTK2_UI_URI LV2_UI__GtkUI
#define QT4_UI_URI LV2_UI__Qt4UI
#define X11_UI_URI LV2_UI__X11UI
+#define WIN_UI_URI LV2_UI_PREFIX "WindowsUI"
SUIL_API
unsigned
@@ -45,6 +45,8 @@ suil_ui_supported(const char* container_type_uri,
&& !strcmp(ui_type_uri, GTK2_UI_URI))
|| (!strcmp(container_type_uri, GTK2_UI_URI)
&& !strcmp(ui_type_uri, X11_UI_URI))
+ || (!strcmp(container_type_uri, GTK2_UI_URI)
+ && !strcmp(ui_type_uri, WIN_UI_URI))
|| (!strcmp(container_type_uri, QT4_UI_URI)
&& !strcmp(ui_type_uri, X11_UI_URI))) {
return SUIL_WRAPPING_EMBEDDED;
@@ -67,16 +69,19 @@ open_wrapper(SuilHost* host,
const char* module_name = NULL;
if (!strcmp(container_type_uri, QT4_UI_URI)
&& !strcmp(ui_type_uri, GTK2_UI_URI)) {
- module_name = "libsuil_gtk2_in_qt4";
+ module_name = "suil_gtk2_in_qt4";
} else if (!strcmp(container_type_uri, GTK2_UI_URI)
&& !strcmp(ui_type_uri, QT4_UI_URI)) {
- module_name = "libsuil_qt4_in_gtk2";
+ module_name = "suil_qt4_in_gtk2";
} else if (!strcmp(container_type_uri, GTK2_UI_URI)
&& !strcmp(ui_type_uri, X11_UI_URI)) {
- module_name = "libsuil_x11_in_gtk2";
+ module_name = "suil_x11_in_gtk2";
+ } else if (!strcmp(container_type_uri, GTK2_UI_URI)
+ && !strcmp(ui_type_uri, WIN_UI_URI)) {
+ module_name = "suil_win_in_gtk2";
} else if (!strcmp(container_type_uri, QT4_UI_URI)
&& !strcmp(ui_type_uri, X11_UI_URI)) {
- module_name = "libsuil_x11_in_qt4";
+ module_name = "suil_x11_in_qt4";
}
if (!module_name) {
@@ -89,13 +94,14 @@ open_wrapper(SuilHost* host,
const char* const mod_dir = env_dir ? env_dir : SUIL_MODULE_DIR;
const size_t path_len = strlen(mod_dir)
+ + strlen(SUIL_DIR_SEP SUIL_MODULE_PREFIX SUIL_MODULE_EXT)
+ strlen(module_name)
- + strlen(SUIL_MODULE_EXT)
+ 2;
- char* const path = calloc(path_len, 1);
- snprintf(path, path_len, "%s%s%s%s",
- mod_dir, SUIL_DIR_SEP, module_name, SUIL_MODULE_EXT);
+ char* const path = (char*)calloc(path_len, 1);
+ snprintf(path, path_len, "%s%s%s%s%s",
+ mod_dir, SUIL_DIR_SEP,
+ SUIL_MODULE_PREFIX, module_name, SUIL_MODULE_EXT);
// Open wrap module
dlerror();
@@ -178,7 +184,7 @@ suil_instance_new(SuilHost* host,
}
// Create SuilInstance
- SuilInstance* instance = calloc(1, sizeof(struct SuilInstanceImpl));
+ SuilInstance* instance = (SuilInstance*)calloc(1, sizeof(SuilInstance));
if (!instance) {
SUIL_ERRORF("Failed to allocate memory for <%s> instance\n", ui_uri);
dlclose(lib);
@@ -193,30 +199,31 @@ suil_instance_new(SuilHost* host,
instance->features[0] = NULL;
// Copy user provided features
- unsigned n_features = 0;
- for (; features && features[n_features]; ++n_features) {
- const LV2_Feature* f = features[n_features];
- suil_add_feature(&instance->features, n_features, f->URI, f->data);
+ const LV2_Feature* const* fi = features;
+ unsigned n_features = 0;
+ while (fi && *fi) {
+ const LV2_Feature* f = *fi++;
+ suil_add_feature(&instance->features, &n_features, f->URI, f->data);
}
// Add additional features implemented by SuilHost functions
if (host->index_func) {
instance->port_map.handle = controller;
instance->port_map.port_index = host->index_func;
- suil_add_feature(&instance->features, n_features++,
+ suil_add_feature(&instance->features, &n_features,
LV2_UI__portMap, &instance->port_map);
}
if (host->subscribe_func && host->unsubscribe_func) {
instance->port_subscribe.handle = controller;
instance->port_subscribe.subscribe = host->subscribe_func;
instance->port_subscribe.unsubscribe = host->unsubscribe_func;
- suil_add_feature(&instance->features, n_features++,
+ suil_add_feature(&instance->features, &n_features,
LV2_UI__portSubscribe, &instance->port_subscribe);
}
if (host->touch_func) {
instance->touch.handle = controller;
instance->touch.touch = host->touch_func;
- suil_add_feature(&instance->features, n_features++,
+ suil_add_feature(&instance->features, &n_features,
LV2_UI__touch, &instance->touch);
}
@@ -301,11 +308,13 @@ suil_instance_port_event(SuilInstance* instance,
uint32_t format,
const void* buffer)
{
- instance->descriptor->port_event(instance->handle,
- port_index,
- buffer_size,
- format,
- buffer);
+ if (instance->descriptor->port_event) {
+ instance->descriptor->port_event(instance->handle,
+ port_index,
+ buffer_size,
+ format,
+ buffer);
+ }
}
SUIL_API
diff --git a/src/qt4_in_gtk2.cpp b/src/qt4_in_gtk2.cpp
index 4722413..4bd61a2 100644
--- a/src/qt4_in_gtk2.cpp
+++ b/src/qt4_in_gtk2.cpp
@@ -128,12 +128,13 @@ wrapper_free(SuilWrapper* wrapper)
}
}
-SUIL_API
+SUIL_LIB_EXPORT
SuilWrapper*
suil_wrapper_new(SuilHost* host,
const char* host_type_uri,
const char* ui_type_uri,
- LV2_Feature*** features)
+ LV2_Feature*** features,
+ unsigned n_features)
{
SuilWrapper* wrapper = (SuilWrapper*)malloc(sizeof(SuilWrapper));
wrapper->wrap = wrapper_wrap;
diff --git a/src/suil_internal.h b/src/suil_internal.h
index cca12fa..67f1412 100644
--- a/src/suil_internal.h
+++ b/src/suil_internal.h
@@ -19,12 +19,14 @@
#include <assert.h>
#include <stdlib.h>
+#include <string.h>
#ifdef _WIN32
#include <windows.h>
#define dlopen(path, flags) LoadLibrary(path)
-#define dlclose(lib) FreeLibrary(lib)
-#define dlsym GetProcAddress
+#define dlclose(lib) FreeLibrary((HMODULE)lib)
+#define inline __inline
+#define snprintf _snprintf
static inline char* dlerror(void) { return "Unknown error"; }
#else
#include <dlfcn.h>
@@ -34,8 +36,11 @@ static inline char* dlerror(void) { return "Unknown error"; }
#include "suil/suil.h"
-#define SUIL_ERRORF(fmt, ...) fprintf(stderr, "error: %s: " fmt, \
- __func__, __VA_ARGS__)
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SUIL_ERRORF(fmt, ...) fprintf(stderr, "suil error: " fmt, __VA_ARGS__)
struct SuilHostImpl {
SuilPortWriteFunc write_func;
@@ -87,31 +92,56 @@ typedef SuilWrapper* (*SuilWrapperNewFunc)(SuilHost* host,
LV2_Feature*** features,
unsigned n_features);
-typedef void (*SuilVoidFunc)();
+/** Prototype for suil_wrapper_new in each module. */
+SUIL_LIB_EXPORT
+SuilWrapper*
+suil_wrapper_new(SuilHost* host,
+ const char* host_type_uri,
+ const char* ui_type_uri,
+ LV2_Feature*** features,
+ unsigned n_features);
+
+typedef void (*SuilVoidFunc)(void);
/** dlsym wrapper to return a function pointer (without annoying warning) */
static inline SuilVoidFunc
suil_dlfunc(void* handle, const char* symbol)
{
+#ifdef _WIN32
+ return (SuilVoidFunc)GetProcAddress((HMODULE)handle, symbol);
+#else
typedef SuilVoidFunc (*VoidFuncGetter)(void*, const char*);
VoidFuncGetter dlfunc = (VoidFuncGetter)dlsym;
return dlfunc(handle, symbol);
+#endif
}
/** Add a feature to a (mutable) LV2 feature array. */
static inline void
suil_add_feature(LV2_Feature*** features,
- unsigned n,
+ unsigned* n,
const char* uri,
void* data)
{
+ for (unsigned i = 0; i < *n && (*features)[i]; ++i) {
+ if (!strcmp((*features)[i]->URI, uri)) {
+ (*features)[i]->data = data;
+ return;
+ }
+ }
+
*features = (LV2_Feature**)realloc(*features,
- sizeof(LV2_Feature*) * (n + 2));
+ sizeof(LV2_Feature*) * (*n + 2));
- (*features)[n] = (LV2_Feature*)malloc(sizeof(LV2_Feature));
- (*features)[n]->URI = uri;
- (*features)[n]->data = data;
- (*features)[n + 1] = NULL;
+ (*features)[*n] = (LV2_Feature*)malloc(sizeof(LV2_Feature));
+ (*features)[*n]->URI = uri;
+ (*features)[*n]->data = data;
+ (*features)[*n + 1] = NULL;
+ *n += 1;
}
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
#endif // SUIL_INTERNAL_H
diff --git a/src/win_in_gtk2.cpp b/src/win_in_gtk2.cpp
new file mode 100644
index 0000000..a4466ce
--- /dev/null
+++ b/src/win_in_gtk2.cpp
@@ -0,0 +1,165 @@
+/*
+ Copyright 2011-2012 David Robillard <http://drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#include <string.h>
+
+#include <gtk/gtk.h>
+#include <gdk/gdkwin32.h>
+
+#include "./suil_internal.h"
+
+extern "C" {
+
+#define SUIL_TYPE_WIN_WRAPPER (suil_win_wrapper_get_type())
+#define SUIL_WIN_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SUIL_TYPE_WIN_WRAPPER, SuilWinWrapper))
+
+typedef struct _SuilWinWrapper SuilWinWrapper;
+typedef struct _SuilWinWrapperClass SuilWinWrapperClass;
+
+struct _SuilWinWrapper {
+ GtkDrawingArea area;
+ SuilWrapper* wrapper;
+ SuilInstance* instance;
+};
+
+struct _SuilWinWrapperClass {
+ GtkDrawingAreaClass parent_class;
+};
+
+GType suil_win_wrapper_get_type(void); // Accessor for SUIL_TYPE_WIN_WRAPPER
+
+G_DEFINE_TYPE(SuilWinWrapper, suil_win_wrapper, GTK_TYPE_DRAWING_AREA)
+
+static void
+suil_win_wrapper_finalize(GObject* gobject)
+{
+ SuilWinWrapper* const self = SUIL_WIN_WRAPPER(gobject);
+
+ self->wrapper->impl = NULL;
+
+ G_OBJECT_CLASS(suil_win_wrapper_parent_class)->finalize(gobject);
+}
+
+static void
+suil_win_wrapper_class_init(SuilWinWrapperClass* klass)
+{
+ GObjectClass* const gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->finalize = suil_win_wrapper_finalize;
+}
+
+static void
+suil_win_wrapper_init(SuilWinWrapper* self)
+{
+ self->instance = NULL;
+}
+
+static int
+wrapper_resize(LV2UI_Feature_Handle handle, int width, int height)
+{
+ gtk_drawing_area_size(GTK_DRAWING_AREA(handle), width, height);
+ return 0;
+}
+
+static int
+wrapper_wrap(SuilWrapper* wrapper,
+ SuilInstance* instance)
+{
+ SuilWinWrapper* const wrap = SUIL_WIN_WRAPPER(wrapper->impl);
+
+ instance->host_widget = GTK_WIDGET(wrap);
+ wrap->wrapper = wrapper;
+ wrap->instance = instance;
+
+ return 0;
+}
+
+static void
+wrapper_free(SuilWrapper* wrapper)
+{
+ if (wrapper->impl) {
+ SuilWinWrapper* const wrap = SUIL_WIN_WRAPPER(wrapper->impl);
+ gtk_object_destroy(GTK_OBJECT(wrap));
+ }
+}
+
+static GdkFilterReturn
+event_filter(GdkXEvent* xevent, GdkEvent* event, gpointer data)
+{
+ SuilWinWrapper* wrap = (SuilWinWrapper*)data;
+ MSG* msg = (MSG*)xevent;
+ if (msg->message == WM_KEYDOWN || msg->message == WM_KEYUP) {
+ // Forward keyboard events to UI window
+ PostMessage((HWND)wrap->instance->ui_widget,
+ msg->message, msg->wParam, msg->lParam);
+ }
+ return GDK_FILTER_CONTINUE;
+}
+
+SUIL_LIB_EXPORT
+SuilWrapper*
+suil_wrapper_new(SuilHost* host,
+ const char* host_type_uri,
+ const char* ui_type_uri,
+ LV2_Feature*** features,
+ unsigned n_features)
+{
+ GtkWidget* parent = NULL;
+ for (unsigned i = 0; i < n_features; ++i) {
+ if (!strcmp((*features)[i]->URI, LV2_UI__parent)) {
+ parent = (GtkWidget*)(*features)[i]->data;
+ }
+ }
+
+ if (!GTK_CONTAINER(parent)) {
+ SUIL_ERRORF("No GtkContainer parent given for %s UI\n",
+ ui_type_uri);
+ return NULL;
+ }
+
+ SuilWrapper* wrapper = (SuilWrapper*)malloc(sizeof(SuilWrapper));
+ wrapper->wrap = wrapper_wrap;
+ wrapper->free = wrapper_free;
+
+ SuilWinWrapper* const wrap = SUIL_WIN_WRAPPER(
+ g_object_new(SUIL_TYPE_WIN_WRAPPER, NULL));
+
+ wrap->wrapper = NULL;
+
+ wrapper->impl = wrap;
+ wrapper->resize.handle = wrap;
+ wrapper->resize.ui_resize = wrapper_resize;
+
+ gtk_container_add(GTK_CONTAINER(parent), GTK_WIDGET(wrap));
+ gtk_widget_set_can_focus(GTK_WIDGET(wrap), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(wrap), TRUE);
+ gtk_widget_realize(GTK_WIDGET(wrap));
+
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(wrap));
+ GdkWindow* parent_window = gtk_widget_get_window(parent);
+ gdk_window_add_filter(parent_window, event_filter, wrap);
+ gdk_window_add_filter(window, event_filter, wrap);
+
+ suil_add_feature(features, &n_features, LV2_UI__parent,
+ GDK_WINDOW_HWND(window));
+
+ suil_add_feature(features, &n_features, LV2_UI__resize,
+ &wrapper->resize);
+
+ return wrapper;
+}
+
+} // extern "C"
diff --git a/src/x11_in_gtk2.c b/src/x11_in_gtk2.c
index 14b0ea2..cc33992 100644
--- a/src/x11_in_gtk2.c
+++ b/src/x11_in_gtk2.c
@@ -17,6 +17,7 @@
#include <string.h>
#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
#include "./suil_internal.h"
@@ -129,7 +130,20 @@ wrapper_free(SuilWrapper* wrapper)
}
}
-SUIL_API
+static GdkFilterReturn
+event_filter(GdkXEvent* xevent, GdkEvent* event, gpointer data)
+{
+ SuilX11Wrapper* wrap = (SuilX11Wrapper*)data;
+ XEvent* ev = (XEvent*)xevent;
+ if (wrap->instance->handle && (ev->type == KeyPress || ev->type == KeyRelease)) {
+ // Forward keyboard events to UI window
+ XSendEvent(ev->xkey.display, (Window)wrap->instance->ui_widget, 1, 0, ev);
+ XSync(ev->xkey.display, TRUE);
+ }
+ return GDK_FILTER_CONTINUE;
+}
+
+SUIL_LIB_EXPORT
SuilWrapper*
suil_wrapper_new(SuilHost* host,
const char* host_type_uri,
@@ -150,10 +164,13 @@ suil_wrapper_new(SuilHost* host,
wrapper->resize.handle = wrap;
wrapper->resize.ui_resize = wrapper_resize;
- suil_add_feature(features, n_features++, LV2_UI__parent,
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(wrap));
+ gdk_window_add_filter(window, event_filter, wrap);
+
+ suil_add_feature(features, &n_features, LV2_UI__parent,
(void*)(intptr_t)gtk_plug_get_id(wrap->plug));
- suil_add_feature(features, n_features++, LV2_UI__resize,
+ suil_add_feature(features, &n_features, LV2_UI__resize,
&wrapper->resize);
return wrapper;
diff --git a/src/x11_in_qt4.cpp b/src/x11_in_qt4.cpp
index dafb384..a39ba28 100644
--- a/src/x11_in_qt4.cpp
+++ b/src/x11_in_qt4.cpp
@@ -44,7 +44,7 @@ wrapper_resize(LV2UI_Feature_Handle handle, int width, int height)
return 0;
}
-SUIL_API
+SUIL_LIB_EXPORT
SuilWrapper*
suil_wrapper_new(SuilHost* host,
const char* host_type_uri,
@@ -62,10 +62,10 @@ suil_wrapper_new(SuilHost* host,
wrapper->resize.handle = ew;
wrapper->resize.ui_resize = wrapper_resize;
- suil_add_feature(features, n_features++, LV2_UI__parent,
+ suil_add_feature(features, &n_features, LV2_UI__parent,
(void*)(intptr_t)ew->winId());
- suil_add_feature(features, n_features++, LV2_UI__resize,
+ suil_add_feature(features, &n_features, LV2_UI__resize,
&wrapper->resize);
return wrapper;
diff --git a/suil/suil.h b/suil/suil.h
index ae228c4..6d6981d 100644
--- a/suil/suil.h
+++ b/suil/suil.h
@@ -1,5 +1,5 @@
/*
- Copyright 2011 David Robillard <http://drobilla.net>
+ Copyright 2011-2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -21,19 +21,19 @@
#ifndef SUIL_SUIL_H
#define SUIL_SUIL_H
-#include <stdbool.h>
#include <stdint.h>
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
+#ifdef _WIN32
+# define SUIL_LIB_IMPORT __declspec(dllimport)
+# define SUIL_LIB_EXPORT __declspec(dllexport)
+#else
+# define SUIL_LIB_IMPORT __attribute__((visibility("default")))
+# define SUIL_LIB_EXPORT __attribute__((visibility("default")))
+#endif
+
#ifdef SUIL_SHARED
-# ifdef _WIN32
-# define SUIL_LIB_IMPORT __declspec(dllimport)
-# define SUIL_LIB_EXPORT __declspec(dllexport)
-# else
-# define SUIL_LIB_IMPORT __attribute__((visibility("default")))
-# define SUIL_LIB_EXPORT __attribute__((visibility("default")))
-# endif
# ifdef SUIL_INTERNAL
# define SUIL_API SUIL_LIB_EXPORT
# else
@@ -45,6 +45,8 @@
#ifdef __cplusplus
extern "C" {
+#else
+# include <stdbool.h>
#endif
/**
@@ -172,6 +174,11 @@ suil_ui_supported(const char* host_type_uri,
place, but this can be changed at run-time via the environment variable
SUIL_MODULE_DIR. This makes it possible to bundle suil with an application.
+ Note that some situations (Gtk in Qt, Windows in Gtk) require a parent
+ container to be passed as a feature with URI LV2_UI__parent
+ (http://lv2plug.in/ns/extensions/ui#ui) in order to work correctly. The
+ data must point to a single child container of the host widget set.
+
@param host Host descriptor.
@param controller Opaque host controller pointer.
@param container_type_uri URI of the desired host container widget type.
diff --git a/waf b/waf
index 68c672c..9fd8031 100755
--- a/waf
+++ b/waf
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# encoding: ISO8859-1
-# Thomas Nagy, 2005-2011
+# Thomas Nagy, 2005-2012
"""
Redistribution and use in source and binary forms, with or without
@@ -32,11 +32,11 @@ POSSIBILITY OF SUCH DAMAGE.
import os, sys
-VERSION="1.6.11"
-REVISION="e2124cdbf2920a11363ea9be238c0b67"
+VERSION="1.7.2"
+REVISION="2a5368230ea584c8941023e56c5fe737"
INSTALL=''
-C1='#,'
-C2='#+'
+C1='#('
+C2='#%'
cwd = os.getcwd()
join = os.path.join
@@ -74,13 +74,13 @@ def unpack_wafdir(dir):
for x in ['Tools', 'extras']:
os.makedirs(join(dir, 'waflib', x))
except OSError:
- err("Cannot unpack waf lib into %s\nMove waf into a writeable directory" % dir)
+ err("Cannot unpack waf lib into %s\nMove waf in a writable directory" % dir)
os.chdir(dir)
tmp = 't.bz2'
t = open(tmp,'wb')
- t.write(txt)
- t.close()
+ try: t.write(txt)
+ finally: t.close()
try:
t = tarfile.open(tmp)
@@ -95,8 +95,10 @@ def unpack_wafdir(dir):
except OSError: pass
err("Waf cannot be unpacked, check that bzip2 support is present")
- for x in t: t.extract(x)
- t.close()
+ try:
+ for x in t: t.extract(x)
+ finally:
+ t.close()
for x in ['Tools', 'extras']:
os.chmod(join('waflib',x), 493)
diff --git a/waflib/Build.py b/waflib/Build.py
index 58d781b..84aa564 100644
--- a/waflib/Build.py
+++ b/waflib/Build.py
@@ -3,8 +3,10 @@
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
import os,sys,errno,re,shutil
-try:import cPickle
-except:import pickle as cPickle
+try:
+ import cPickle
+except ImportError:
+ import pickle as cPickle
from waflib import Runner,TaskGen,Utils,ConfigSet,Task,Logs,Options,Context,Errors
import waflib.Node
CACHE_DIR='c4che'
@@ -159,7 +161,7 @@ class BuildContext(Context.Context):
f=None
try:
f=open(db+'.tmp','wb')
- cPickle.dump(data,f)
+ cPickle.dump(data,f,-1)
finally:
if f:
f.close()
@@ -203,13 +205,18 @@ class BuildContext(Context.Context):
self.all_envs[self.variant]=val
env=property(get_env,set_env)
def add_manual_dependency(self,path,value):
+ if path is None:
+ raise ValueError('Invalid input')
if isinstance(path,waflib.Node.Node):
node=path
elif os.path.isabs(path):
node=self.root.find_resource(path)
else:
node=self.path.find_resource(path)
- self.deps_man[id(node)].append(value)
+ if isinstance(value,list):
+ self.deps_man[id(node)].extend(value)
+ else:
+ self.deps_man[id(node)].append(value)
def launch_node(self):
try:
return self.p_ln
@@ -347,6 +354,11 @@ class BuildContext(Context.Context):
elif m==min_grp:
to_post.append(tg)
return(min_grp,to_post)
+ def get_all_task_gen(self):
+ lst=[]
+ for g in self.groups:
+ lst.extend(g)
+ return lst
def post_group(self):
if self.targets=='*':
for tg in self.groups[self.cur]:
@@ -370,6 +382,12 @@ class BuildContext(Context.Context):
tg.post()
else:
ln=self.launch_node()
+ if ln.is_child_of(self.bldnode):
+ Logs.warn('Building from the build directory, forcing --targets=*')
+ ln=self.srcnode
+ elif not ln.is_child_of(self.srcnode):
+ Logs.warn('CWD %s is not under %s, forcing --targets=* (run distclean?)'%(ln.abspath(),self.srcnode.abspath()))
+ ln=self.srcnode
for tg in self.groups[self.cur]:
try:
f=tg.post
@@ -381,10 +399,10 @@ class BuildContext(Context.Context):
def get_tasks_group(self,idx):
tasks=[]
for tg in self.groups[idx]:
- if isinstance(tg,Task.TaskBase):
- tasks.append(tg)
- else:
+ try:
tasks.extend(tg.tasks)
+ except AttributeError:
+ tasks.append(tg)
return tasks
def get_build_iterator(self):
self.cur=0
@@ -411,6 +429,9 @@ class BuildContext(Context.Context):
yield[]
class inst(Task.Task):
color='CYAN'
+ def uid(self):
+ lst=[self.dest,self.path]+self.source
+ return Utils.h_list(repr(lst))
def post(self):
buf=[]
for x in self.source:
@@ -628,7 +649,7 @@ class CleanContext(BuildContext):
Logs.debug('build: clean called')
if self.bldnode!=self.srcnode:
lst=[self.root.find_or_declare(f)for f in self.env[CFG_FILES]]
- for n in self.bldnode.ant_glob('**/*',excl='lock* *conf_check_*/** config.log c4che/*',quiet=True):
+ for n in self.bldnode.ant_glob('**/*',excl='.lock* *conf_check_*/** config.log c4che/*',quiet=True):
if n in lst:
continue
n.delete()
@@ -655,7 +676,7 @@ class ListContext(BuildContext):
f()
try:
self.get_tgen_by_name('')
- except:
+ except Exception:
pass
lst=list(self.task_gen_cache_names.keys())
lst.sort()
@@ -672,8 +693,13 @@ class StepContext(BuildContext):
Logs.warn('Add a pattern for the debug build, for example "waf step --files=main.c,app"')
BuildContext.compile(self)
return
+ targets=None
+ if self.targets and self.targets!='*':
+ targets=self.targets.split(',')
for g in self.groups:
for tg in g:
+ if targets and tg.name not in targets:
+ continue
try:
f=tg.post
except AttributeError:
diff --git a/waflib/ConfigSet.py b/waflib/ConfigSet.py
index fa55135..b42b9ca 100644
--- a/waflib/ConfigSet.py
+++ b/waflib/ConfigSet.py
@@ -2,8 +2,6 @@
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-import sys
-if sys.hexversion < 0x020400f0: from sets import Set as set
import copy,re,os
from waflib import Logs,Utils
re_imp=re.compile('^(#)*?([^#=]*?)\ =\ (.*?)$',re.M)
@@ -136,7 +134,7 @@ class ConfigSet(object):
f.close()
def load(self,filename):
tbl=self.table
- code=Utils.readf(filename)
+ code=Utils.readf(filename,m='rU')
for m in re_imp.finditer(code):
g=m.group
tbl[g(2)]=eval(g(3))
diff --git a/waflib/Configure.py b/waflib/Configure.py
index bd004c6..705bfa8 100644
--- a/waflib/Configure.py
+++ b/waflib/Configure.py
@@ -6,7 +6,7 @@ import os,shlex,sys,time
from waflib import ConfigSet,Utils,Options,Logs,Context,Build,Errors
try:
from urllib import request
-except:
+except ImportError:
from urllib import urlopen
else:
urlopen=request.urlopen
@@ -35,16 +35,16 @@ def download_tool(tool,force=False,ctx=None):
continue
else:
tmp=ctx.root.make_node(os.sep.join((Context.waf_dir,'waflib','extras',tool+'.py')))
- tmp.write(web.read())
+ tmp.write(web.read(),'wb')
Logs.warn('Downloaded %s from %s'%(tool,url))
download_check(tmp)
try:
module=Context.load_tool(tool)
- except:
+ except Exception:
Logs.warn('The tool %s from %s is unusable'%(tool,url))
try:
tmp.delete()
- except:
+ except Exception:
pass
continue
return module
@@ -219,15 +219,17 @@ def conf(f):
del kw['mandatory']
try:
return f(*k,**kw)
- except Errors.ConfigurationError ,e:
+ except Errors.ConfigurationError:
if mandatory:
- raise e
+ raise
setattr(ConfigurationContext,f.__name__,fun)
setattr(Build.BuildContext,f.__name__,fun)
return f
+ at conf
def add_os_flags(self,var,dest=None):
try:self.env.append_value(dest or var,shlex.split(self.environ[var]))
except KeyError:pass
+ at conf
def cmd_to_list(self,cmd):
if isinstance(cmd,str)and cmd.find(' '):
try:
@@ -237,7 +239,8 @@ def cmd_to_list(self,cmd):
else:
return[cmd]
return cmd
-def check_waf_version(self,mini='1.6.0',maxi='1.7.0'):
+ at conf
+def check_waf_version(self,mini='1.6.99',maxi='1.8.0'):
self.start_msg('Checking for waf version in %s-%s'%(str(mini),str(maxi)))
ver=Context.HEXVERSION
if Utils.num2ver(mini)>ver:
@@ -245,6 +248,7 @@ def check_waf_version(self,mini='1.6.0',maxi='1.7.0'):
if Utils.num2ver(maxi)<ver:
self.fatal('waf version should be at most %r (%r found)'%(Utils.num2ver(maxi),ver))
self.end_msg('ok')
+ at conf
def find_file(self,filename,path_list=[]):
for n in Utils.to_list(filename):
for d in Utils.to_list(path_list):
@@ -252,6 +256,7 @@ def find_file(self,filename,path_list=[]):
if os.path.exists(p):
return p
self.fatal('Could not find %r'%filename)
+ at conf
def find_program(self,filename,**kw):
exts=kw.get('exts',Utils.is_win32 and'.exe,.com,.bat,.cmd'or',.sh,.pl,.py')
environ=kw.get('environ',os.environ)
@@ -295,10 +300,11 @@ def find_program(self,filename,**kw):
if var:
self.env[var]=ret
return ret
+ at conf
def find_perl_program(self,filename,path_list=[],var=None,environ=None,exts=''):
try:
app=self.find_program(filename,path_list=path_list,var=var,environ=environ,exts=exts)
- except:
+ except Exception:
self.find_program('perl',var='PERL')
app=self.find_file(filename,os.environ['PATH'].split(os.pathsep))
if not app:
@@ -306,10 +312,3 @@ def find_perl_program(self,filename,path_list=[],var=None,environ=None,exts=''):
if var:
self.env[var]=Utils.to_list(self.env['PERL'])+[app]
self.msg('Checking for %r'%filename,app)
-
-conf(add_os_flags)
-conf(cmd_to_list)
-conf(check_waf_version)
-conf(find_file)
-conf(find_program)
-conf(find_perl_program)
\ No newline at end of file
diff --git a/waflib/Context.py b/waflib/Context.py
index a16af30..4d7d14a 100644
--- a/waflib/Context.py
+++ b/waflib/Context.py
@@ -5,11 +5,11 @@
import os,imp,sys
from waflib import Utils,Errors,Logs
import waflib.Node
-HEXVERSION=0x1060b00
-WAFVERSION="1.6.11"
+HEXVERSION=0x1070200
+WAFVERSION="1.7.2"
WAFREVISION="a7e69d6b81b04729804754c4d5214da063779a65"
ABI=98
-DBFILE='.wafpickle-%d'%ABI
+DBFILE='.wafpickle-%s-%d-%d'%(sys.platform,sys.hexversion,ABI)
APPNAME='APPNAME'
VERSION='VERSION'
TOP='top'
@@ -96,7 +96,7 @@ class Context(ctx):
def recurse(self,dirs,name=None,mandatory=True,once=True):
try:
cache=self.recurse_cache
- except:
+ except AttributeError:
cache=self.recurse_cache={}
for d in Utils.to_list(dirs):
if not os.path.isabs(d):
@@ -137,22 +137,37 @@ class Context(ctx):
kw['shell']=isinstance(cmd,str)
Logs.debug('runner: %r'%cmd)
Logs.debug('runner_env: kw=%s'%kw)
+ if self.logger:
+ self.logger.info(cmd)
+ if'stdout'not in kw:
+ kw['stdout']=subprocess.PIPE
+ if'stderr'not in kw:
+ kw['stderr']=subprocess.PIPE
try:
- if self.logger:
- self.logger.info(cmd)
- kw['stdout']=kw['stderr']=subprocess.PIPE
+ if kw['stdout']or kw['stderr']:
p=subprocess.Popen(cmd,**kw)
(out,err)=p.communicate()
- if out:
- self.logger.debug('out: %s'%out.decode(sys.stdout.encoding or'iso8859-1'))
- if err:
- self.logger.error('err: %s'%err.decode(sys.stdout.encoding or'iso8859-1'))
- return p.returncode
+ ret=p.returncode
else:
- p=subprocess.Popen(cmd,**kw)
- return p.wait()
- except OSError:
- return-1
+ out,err=(None,None)
+ ret=subprocess.Popen(cmd,**kw).wait()
+ except Exception ,e:
+ raise Errors.WafError('Execution failure: %s'%str(e),ex=e)
+ if out:
+ if not isinstance(out,str):
+ out=out.decode(sys.stdout.encoding or'iso8859-1')
+ if self.logger:
+ self.logger.debug('out: %s'%out)
+ else:
+ sys.stdout.write(out)
+ if err:
+ if not isinstance(err,str):
+ err=err.decode(sys.stdout.encoding or'iso8859-1')
+ if self.logger:
+ self.logger.error('err: %s'%err)
+ else:
+ sys.stderr.write(err)
+ return ret
def cmd_and_log(self,cmd,**kw):
subprocess=Utils.subprocess
kw['shell']=isinstance(cmd,str)
@@ -199,7 +214,7 @@ class Context(ctx):
self.logger.info('from %s: %s'%(self.path.abspath(),msg))
try:
msg='%s\n(complete log in %s)'%(msg,self.logger.handlers[0].baseFilename)
- except:
+ except Exception:
pass
raise self.errors.ConfigurationError(msg,ex=ex)
def to_log(self,msg):
@@ -220,7 +235,7 @@ class Context(ctx):
if self.in_msg:
self.in_msg+=1
return
- except:
+ except AttributeError:
self.in_msg=0
self.in_msg+=1
try:
@@ -268,9 +283,12 @@ def load_module(path):
cache_modules[path]=module
return module
def load_tool(tool,tooldir=None):
- tool=tool.replace('++','xx')
- tool=tool.replace('java','javaw')
- tool=tool.replace('compiler_cc','compiler_c')
+ if tool=='java':
+ tool='javaw'
+ elif tool=='compiler_cc':
+ tool='compiler_c'
+ else:
+ tool=tool.replace('++','xx')
if tooldir:
assert isinstance(tooldir,list)
sys.path=tooldir+sys.path
@@ -286,13 +304,15 @@ def load_tool(tool,tooldir=None):
global waf_dir
try:
os.stat(os.path.join(waf_dir,'waflib','extras',tool+'.py'))
- d='waflib.extras.%s'%tool
- except:
+ except OSError:
try:
os.stat(os.path.join(waf_dir,'waflib','Tools',tool+'.py'))
- d='waflib.Tools.%s'%tool
- except:
+ except OSError:
d=tool
+ else:
+ d='waflib.Tools.%s'%tool
+ else:
+ d='waflib.extras.%s'%tool
__import__(d)
ret=sys.modules[d]
Context.tools[tool]=ret
diff --git a/waflib/Logs.py b/waflib/Logs.py
index 2ba46d2..d6d4ddd 100644
--- a/waflib/Logs.py
+++ b/waflib/Logs.py
@@ -3,12 +3,39 @@
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
import os,re,traceback,sys
-_nocolor=os.environ.get('NOCOLOR','no')not in('no','0','false')
try:
- if not _nocolor:
- import waflib.ansiterm
-except:
+ import threading
+except ImportError:
pass
+else:
+ wlock=threading.Lock()
+ class sync_stream(object):
+ def __init__(self,stream):
+ self.stream=stream
+ self.encoding=self.stream.encoding
+ def write(self,txt):
+ try:
+ wlock.acquire()
+ self.stream.write(txt)
+ self.stream.flush()
+ finally:
+ wlock.release()
+ def fileno(self):
+ return self.stream.fileno()
+ def flush(self):
+ self.stream.flush()
+ def isatty(self):
+ return self.stream.isatty()
+ _nocolor=os.environ.get('NOCOLOR','no')not in('no','0','false')
+ try:
+ if not _nocolor:
+ import waflib.ansiterm
+ except ImportError:
+ pass
+ if not os.environ.get('NOSYNC',False):
+ if id(sys.stdout)==id(sys.__stdout__):
+ sys.stdout=sync_stream(sys.stdout)
+ sys.stderr=sync_stream(sys.stderr)
import logging
LOG_FORMAT="%(asctime)s %(c1)s%(zone)s%(c2)s %(message)s"
HOUR_FORMAT="%H:%M:%S"
@@ -18,7 +45,7 @@ colors_lst={'USE':True,'BOLD':'\x1b[01;1m','RED':'\x1b[01;31m','GREEN':'\x1b[32m
got_tty=not os.environ.get('TERM','dumb')in['dumb','emacs']
if got_tty:
try:
- got_tty=sys.stderr.isatty()
+ got_tty=sys.stderr.isatty()and sys.stdout.isatty()
except AttributeError:
got_tty=False
if(not got_tty and os.environ.get('TERM','dumb')!='msys')or _nocolor:
@@ -36,7 +63,7 @@ else:
return cols
try:
get_term_cols_real()
- except:
+ except Exception:
pass
else:
get_term_cols=get_term_cols_real
@@ -87,7 +114,7 @@ class formatter(logging.Formatter):
if rec.levelno>=logging.WARNING or rec.levelno==logging.INFO:
try:
msg=rec.msg.decode('utf-8')
- except:
+ except Exception:
msg=rec.msg
return'%s%s%s'%(rec.c1,msg,rec.c2)
return logging.Formatter.format(self,rec)
diff --git a/waflib/Node.py b/waflib/Node.py
index 9a86b22..3cf7103 100644
--- a/waflib/Node.py
+++ b/waflib/Node.py
@@ -2,8 +2,6 @@
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-import sys
-if sys.hexversion < 0x020400f0: from sets import Set as set
import os,re,sys,shutil
from waflib import Utils,Errors
exclude_regs='''
@@ -83,16 +81,10 @@ class Node(object):
return id(self)==id(node)
def __copy__(self):
raise Errors.WafError('nodes are not supposed to be copied')
- def read(self,flags='r'):
- return Utils.readf(self.abspath(),flags)
- def write(self,data,flags='w'):
- f=None
- try:
- f=open(self.abspath(),flags)
- f.write(data)
- finally:
- if f:
- f.close()
+ def read(self,flags='r',encoding='ISO8859-1'):
+ return Utils.readf(self.abspath(),flags,encoding)
+ def write(self,data,flags='w',encoding='ISO8859-1'):
+ Utils.writef(self.abspath(),data,flags,encoding)
def chmod(self,val):
os.chmod(self.abspath(),val)
def delete(self):
@@ -101,12 +93,11 @@ class Node(object):
shutil.rmtree(self.abspath())
else:
os.unlink(self.abspath())
- except:
- pass
- try:
- delattr(self,'children')
- except:
+ except OSError:
pass
+ self.evict()
+ def evict(self):
+ del self.parent.children[self.name]
def suffix(self):
k=max(0,self.name.rfind('.'))
return self.name[k:]
@@ -126,7 +117,7 @@ class Node(object):
return
try:
self.parent.mkdir()
- except:
+ except OSError:
pass
if self.name:
try:
@@ -137,7 +128,7 @@ class Node(object):
raise Errors.WafError('Could not create the directory %s'%self.abspath())
try:
self.children
- except:
+ except AttributeError:
self.children={}
self.cache_isdir=True
def find_node(self,lst):
@@ -149,22 +140,26 @@ class Node(object):
cur=cur.parent or cur
continue
try:
- if x in cur.children:
+ ch=cur.children
+ except AttributeError:
+ cur.children={}
+ else:
+ try:
cur=cur.children[x]
continue
- except:
- cur.children={}
+ except KeyError:
+ pass
cur=self.__class__(x,cur)
try:
os.stat(cur.abspath())
- except:
- del cur.parent.children[x]
+ except OSError:
+ cur.evict()
return None
ret=cur
try:
os.stat(ret.abspath())
- except:
- del ret.parent.children[ret.name]
+ except OSError:
+ ret.evict()
return None
try:
while not getattr(cur.parent,'cache_isdir',None):
@@ -189,19 +184,19 @@ class Node(object):
cur.children={}
cur=self.__class__(x,cur)
return cur
- def search(self,lst):
+ def search_node(self,lst):
if isinstance(lst,str):
lst=[x for x in split_path(lst)if x and x!='.']
cur=self
- try:
- for x in lst:
- if x=='..':
- cur=cur.parent or cur
- else:
+ for x in lst:
+ if x=='..':
+ cur=cur.parent or cur
+ else:
+ try:
cur=cur.children[x]
- return cur
- except:
- pass
+ except(AttributeError,KeyError):
+ return None
+ return cur
def path_from(self,node):
c1=self
c2=node
@@ -229,7 +224,7 @@ class Node(object):
def abspath(self):
try:
return self.cache_abspath
- except:
+ except AttributeError:
pass
if os.sep=='/':
if not self.parent:
@@ -259,11 +254,12 @@ class Node(object):
dircont.sort()
try:
lst=set(self.children.keys())
+ except AttributeError:
+ self.children={}
+ else:
if remove:
for x in lst-set(dircont):
- del self.children[x]
- except:
- self.children={}
+ self.children[x].evict()
for name in dircont:
npats=accept(name,pats)
if npats and npats[0]:
@@ -288,6 +284,7 @@ class Node(object):
dir=kw.get('dir',False)
excl=kw.get('excl',exclude_regs)
incl=k and k[0]or kw.get('incl','**')
+ reflags=kw.get('ignorecase',0)and re.I
def to_pat(s):
lst=Utils.to_list(s)
ret=[]
@@ -304,7 +301,7 @@ class Node(object):
k=k.replace('.','[.]').replace('*','.*').replace('?','.').replace('+','\\+')
k='^%s$'%k
try:
- accu.append(re.compile(k))
+ accu.append(re.compile(k,flags=reflags))
except Exception ,e:
raise Errors.WafError("Invalid pattern: %s"%k,e)
ret.append(accu)
@@ -334,31 +331,6 @@ class Node(object):
if kw.get('flat',False):
return' '.join([x.path_from(self)for x in ret])
return ret
- def find_nodes(self,find_dirs=True,find_files=True,match_fun=lambda x:True):
- x="""
- Recursively finds nodes::
-
- def configure(cnf):
- cnf.find_nodes()
-
- :param find_dirs: whether to return directories
- :param find_files: whether to return files
- :param match_fun: matching function, taking a node as parameter
- :rtype generator
- :return: a generator that iterates over all the requested files
- """
- files=self.listdir()
- for f in files:
- node=self.make_node([f])
- if os.path.isdir(node.abspath()):
- if find_dirs and match_fun(node):
- yield node
- gen=node.find_nodes(find_dirs,find_files,match_fun)
- for g in gen:
- yield g
- else:
- if find_files and match_fun(node):
- yield node
def is_src(self):
cur=self
x=id(self.ctx.srcnode)
@@ -412,38 +384,29 @@ class Node(object):
def find_resource(self,lst):
if isinstance(lst,str):
lst=[x for x in split_path(lst)if x and x!='.']
- node=self.get_bld().search(lst)
+ node=self.get_bld().search_node(lst)
if not node:
self=self.get_src()
node=self.find_node(lst)
- try:
- pat=node.abspath()
- if os.path.isdir(pat):
+ if node:
+ if os.path.isdir(node.abspath()):
return None
- except:
- pass
return node
def find_or_declare(self,lst):
if isinstance(lst,str):
lst=[x for x in split_path(lst)if x and x!='.']
- node=self.get_bld().search(lst)
+ node=self.get_bld().search_node(lst)
if node:
if not os.path.isfile(node.abspath()):
node.sig=None
- try:
- node.parent.mkdir()
- except:
- pass
+ node.parent.mkdir()
return node
self=self.get_src()
node=self.find_node(lst)
if node:
if not os.path.isfile(node.abspath()):
node.sig=None
- try:
- node.parent.mkdir()
- except:
- pass
+ node.parent.mkdir()
return node
node=self.get_bld().make_node(lst)
node.parent.mkdir()
@@ -501,6 +464,7 @@ class Node(object):
self.sig=Utils.h_file(self.abspath())
self.ctx.hash_cache[id(self)]=ret=self.sig
return ret
+ search=search_node
pickle_lock=Utils.threading.Lock()
class Nod3(Node):
pass
diff --git a/waflib/Options.py b/waflib/Options.py
index 2149b1b..21f4254 100644
--- a/waflib/Options.py
+++ b/waflib/Options.py
@@ -48,6 +48,7 @@ class opt_parser(optparse.OptionParser):
self.add_option_group(gr)
gr.add_option('--destdir',help='installation root [default: %r]'%default_destdir,default=default_destdir,dest='destdir')
gr.add_option('-f','--force',dest='force',default=False,action='store_true',help='force file installation')
+ gr.add_option('--distcheck-args',help='arguments to pass to distcheck',default=None,action='store')
def get_usage(self):
cmds_str={}
for cls in Context.classes:
@@ -105,11 +106,11 @@ class OptionsContext(Context.Context):
count=1024
return count
def add_option(self,*k,**kw):
- self.parser.add_option(*k,**kw)
+ return self.parser.add_option(*k,**kw)
def add_option_group(self,*k,**kw):
try:
gr=self.option_groups[k[0]]
- except:
+ except KeyError:
gr=self.parser.add_option_group(*k,**kw)
self.option_groups[k[0]]=gr
return gr
diff --git a/waflib/Runner.py b/waflib/Runner.py
index 6f64fed..15b6a27 100644
--- a/waflib/Runner.py
+++ b/waflib/Runner.py
@@ -5,7 +5,7 @@
import random,atexit
try:
from queue import Queue
-except:
+except ImportError:
from Queue import Queue
from waflib import Utils,Task,Errors,Logs
GAP=10
@@ -18,7 +18,7 @@ class TaskConsumer(Utils.threading.Thread):
def run(self):
try:
self.loop()
- except:
+ except Exception:
pass
def loop(self):
while 1:
@@ -31,7 +31,7 @@ pool=Queue()
def get_pool():
try:
return pool.get(False)
- except:
+ except Exception:
return TaskConsumer()
def put_pool(x):
pool.put(x)
@@ -77,7 +77,7 @@ class Parallel(object):
elif self.frozen:
try:
cond=self.deadlock==self.processed
- except:
+ except AttributeError:
pass
else:
if cond:
@@ -133,7 +133,7 @@ class Parallel(object):
self.out.put(self)
try:
pool=self.pool
- except:
+ except AttributeError:
pass
else:
for x in pool:
diff --git a/waflib/Scripting.py b/waflib/Scripting.py
index 9a5d2e9..0f22ce7 100644
--- a/waflib/Scripting.py
+++ b/waflib/Scripting.py
@@ -2,7 +2,7 @@
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-import os,shutil,traceback,errno,sys,stat
+import os,shlex,shutil,traceback,errno,sys,stat
from waflib import Utils,Configure,Logs,Options,ConfigSet,Context,Errors,Build,Node
build_dir_override=None
no_climb_commands=['configure']
@@ -45,7 +45,7 @@ def waf_entry_point(current_directory,version,wafdir):
else:
try:
ino2=os.stat(x)[stat.ST_INO]
- except:
+ except OSError:
pass
else:
if ino==ino2:
@@ -100,6 +100,8 @@ def waf_entry_point(current_directory,version,wafdir):
Logs.pprint('RED',e.verbose_msg)
Logs.error(e.msg)
sys.exit(1)
+ except SystemExit:
+ raise
except Exception ,e:
traceback.print_exc(file=sys.stdout)
sys.exit(2)
@@ -138,6 +140,7 @@ def parse_options():
Logs.zones=['*']
def run_command(cmd_name):
ctx=Context.create_context(cmd_name)
+ ctx.log_timer=Utils.Timer()
ctx.options=Options.options
ctx.cmd=cmd_name
ctx.execute()
@@ -147,11 +150,8 @@ def run_commands():
run_command('init')
while Options.commands:
cmd_name=Options.commands.pop(0)
- timer=Utils.Timer()
- run_command(cmd_name)
- if not Options.options.progress_bar:
- elapsed=' (%s)'%str(timer)
- Logs.info('%r finished successfully%s'%(cmd_name,elapsed))
+ ctx=run_command(cmd_name)
+ Logs.info('%r finished successfully (%s)'%(cmd_name,str(ctx.log_timer)))
run_command('shutdown')
def _can_distclean(name):
for k in'.o .moc .exe'.split():
@@ -165,16 +165,16 @@ def distclean_dir(dirname):
fname=root+os.sep+f
try:
os.unlink(fname)
- except:
+ except OSError:
Logs.warn('could not remove %r'%fname)
for x in[Context.DBFILE,'config.log']:
try:
os.unlink(x)
- except:
+ except OSError:
pass
try:
shutil.rmtree('c4che')
- except:
+ except OSError:
pass
def distclean(ctx):
'''removes the build directory'''
@@ -183,7 +183,7 @@ def distclean(ctx):
if f==Options.lockfile:
try:
proj=ConfigSet.ConfigSet(f)
- except:
+ except IOError:
Logs.warn('could not read %r'%f)
continue
if proj['out_dir']!=proj['top_dir']:
@@ -205,6 +205,7 @@ def distclean(ctx):
if f.startswith('.waf')and not Options.commands:
shutil.rmtree(f,ignore_errors=True)
class Dist(Context.Context):
+ '''creates an archive containing the project source code'''
cmd='dist'
fun='dist'
algo='tar.bz2'
@@ -217,12 +218,12 @@ class Dist(Context.Context):
arch_name=self.get_arch_name()
try:
self.base_path
- except:
+ except AttributeError:
self.base_path=self.path
node=self.base_path.make_node(arch_name)
try:
node.delete()
- except:
+ except Exception:
pass
files=self.get_files()
if self.algo.startswith('tar.'):
@@ -245,7 +246,7 @@ class Dist(Context.Context):
from sha import sha
try:
digest=" (sha=%r)"%sha(node.read()).hexdigest()
- except:
+ except Exception:
digest=''
Logs.info('New archive created: %s%s'%(self.arch_name,digest))
def get_tar_path(self,node):
@@ -267,18 +268,18 @@ class Dist(Context.Context):
def get_tar_prefix(self):
try:
return self.tar_prefix
- except:
+ except AttributeError:
return self.get_base_name()
def get_arch_name(self):
try:
self.arch_name
- except:
+ except AttributeError:
self.arch_name=self.get_base_name()+'.'+self.ext_algo.get(self.algo,self.algo)
return self.arch_name
def get_base_name(self):
try:
self.base_name
- except:
+ except AttributeError:
appname=getattr(Context.g_module,Context.APPNAME,'noname')
version=getattr(Context.g_module,Context.VERSION,'1.0')
self.base_name=appname+'-'+version
@@ -286,8 +287,8 @@ class Dist(Context.Context):
def get_excl(self):
try:
return self.excl
- except:
- self.excl=Node.exclude_regs+' **/waf-1.6.* **/.waf-1.6* **/waf3-1.6.* **/.waf3-1.6* **/*~ **/*.rej **/*.orig **/*.pyc **/*.pyo **/*.bak **/*.swp **/.lock-w*'
+ except AttributeError:
+ self.excl=Node.exclude_regs+' **/waf-1.7.* **/.waf-1.7* **/waf3-1.7.* **/.waf3-1.7* **/*~ **/*.rej **/*.orig **/*.pyc **/*.pyo **/*.bak **/*.swp **/.lock-w*'
nd=self.root.find_node(Context.out_dir)
if nd:
self.excl+=' '+nd.path_from(self.base_path)
@@ -295,7 +296,7 @@ class Dist(Context.Context):
def get_files(self):
try:
files=self.files
- except:
+ except AttributeError:
files=self.base_path.ant_glob('**/*',excl=self.get_excl())
return files
def dist(ctx):
@@ -318,8 +319,13 @@ class DistCheck(Dist):
finally:
if t:
t.close()
+ cfg=[]
+ if Options.options.distcheck_args:
+ cfg=shlex.split(Options.options.distcheck_args)
+ else:
+ cfg=[x for x in sys.argv if x.startswith('-')]
instdir=tempfile.mkdtemp('.inst',self.get_base_name())
- ret=Utils.subprocess.Popen([sys.argv[0],'configure','install','uninstall','--destdir='+instdir],cwd=self.get_base_name()).wait()
+ ret=Utils.subprocess.Popen([sys.argv[0],'configure','install','uninstall','--destdir='+instdir]+cfg,cwd=self.get_base_name()).wait()
if ret:
raise Errors.WafError('distcheck failed with code %i'%ret)
if os.path.exists(instdir):
diff --git a/waflib/Task.py b/waflib/Task.py
index 1678a10..1b54a54 100644
--- a/waflib/Task.py
+++ b/waflib/Task.py
@@ -2,8 +2,6 @@
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-import sys
-if sys.hexversion < 0x020400f0: from sets import Set as set
import os,shutil,re,tempfile
from waflib import Utils,Logs,Errors
NOT_RUN=0
@@ -77,7 +75,7 @@ class store_task_type(type):
cls.hcode=Utils.h_fun(cls.run)
if not getattr(cls,'nocache',None):
cls=cache_outputs(cls)
- classes[name]=cls
+ getattr(cls,'register',classes)[name]=cls
evil=store_task_type('evil',(object,),{})
class TaskBase(evil):
color='GREEN'
@@ -117,7 +115,7 @@ class TaskBase(evil):
return
try:
del self.generator.bld.task_sigs[self.uid()]
- except:
+ except KeyError:
pass
try:
self.generator.bld.returned_tasks.append(self)
@@ -235,13 +233,19 @@ class Task(TaskBase):
self.run_after=set([])
def __str__(self):
env=self.env
- src_str=' '.join([a.nice_path(env)for a in self.inputs])
- tgt_str=' '.join([a.nice_path(env)for a in self.outputs])
+ src_str=' '.join([a.nice_path()for a in self.inputs])
+ tgt_str=' '.join([a.nice_path()for a in self.outputs])
if self.outputs:sep=' -> '
else:sep=''
return'%s: %s%s%s\n'%(self.__class__.__name__.replace('_task',''),src_str,sep,tgt_str)
def __repr__(self):
- return"".join(['\n\t{task %r: '%id(self),self.__class__.__name__," ",",".join([x.name for x in self.inputs])," -> ",",".join([x.name for x in self.outputs]),'}'])
+ try:
+ ins=",".join([x.name for x in self.inputs])
+ outs=",".join([x.name for x in self.outputs])
+ except AttributeError:
+ ins=",".join([str(x)for x in self.inputs])
+ outs=",".join([str(x)for x in self.outputs])
+ return"".join(['\n\t{task %r: '%id(self),self.__class__.__name__," ",ins," -> ",outs,'}'])
def uid(self):
try:
return self.uid_
@@ -357,15 +361,15 @@ class Task(TaskBase):
try:
if prev==self.compute_sig_implicit_deps():
return prev
- except:
+ except Exception:
for x in bld.node_deps.get(self.uid(),[]):
if x.is_child_of(bld.srcnode):
try:
os.stat(x.abspath())
- except:
+ except OSError:
try:
del x.parent.children[x.name]
- except:
+ except KeyError:
pass
del bld.task_sigs[(key,'imp')]
raise Errors.TaskRescan('rescan')
@@ -377,12 +381,12 @@ class Task(TaskBase):
self.are_implicit_nodes_ready()
try:
bld.task_sigs[(key,'imp')]=sig=self.compute_sig_implicit_deps()
- except:
+ except Exception:
if Logs.verbose:
for k in bld.node_deps.get(self.uid(),[]):
try:
k.get_bld_sig()
- except:
+ except Exception:
Logs.warn('Missing signature for node %r (may cause rebuilds)'%k)
else:
return sig
@@ -397,7 +401,7 @@ class Task(TaskBase):
bld=self.generator.bld
try:
cache=bld.dct_implicit_nodes
- except:
+ except AttributeError:
bld.dct_implicit_nodes=cache={}
try:
dct=cache[bld.cur]
@@ -456,7 +460,7 @@ class Task(TaskBase):
tmpdir=tempfile.mkdtemp(prefix=self.generator.bld.cache_global+os.sep+'waf')
try:
shutil.rmtree(dname)
- except:
+ except Exception:
pass
try:
for node in self.outputs:
@@ -465,7 +469,7 @@ class Task(TaskBase):
except(OSError,IOError):
try:
shutil.rmtree(tmpdir)
- except:
+ except Exception:
pass
else:
try:
@@ -473,12 +477,12 @@ class Task(TaskBase):
except OSError:
try:
shutil.rmtree(tmpdir)
- except:
+ except Exception:
pass
else:
try:
os.chmod(dname,Utils.O755)
- except:
+ except Exception:
pass
def is_before(t1,t2):
to_list=Utils.to_list
@@ -521,8 +525,9 @@ def set_precedence_constraints(tasks):
b=i
else:
continue
+ aval=set(cstr_groups[keys[a]])
for x in cstr_groups[keys[b]]:
- x.run_after.update(cstr_groups[keys[a]])
+ x.run_after.update(aval)
def funex(c):
dc={}
exec(c,dc)
@@ -566,7 +571,7 @@ def compile_fun_shell(line):
if parm:parm="%% (%s) "%(',\n\t\t'.join(parm))
else:parm=''
c=COMPILE_TEMPLATE_SHELL%(line,parm)
- Logs.debug('action: %s'%c)
+ Logs.debug('action: %s'%c.strip().splitlines())
return(funex(c),dvars)
def compile_fun_noshell(line):
extr=[]
@@ -612,7 +617,7 @@ def compile_fun_noshell(line):
if params[-1]:
app("lst.extend(%r)"%params[-1].split())
fun=COMPILE_TEMPLATE_NOSHELL%"\n\t".join(buf)
- Logs.debug('action: %s'%fun)
+ Logs.debug('action: %s'%fun.strip().splitlines())
return(funex(fun),dvars)
def compile_fun(line,shell=False):
if line.find('<')>0 or line.find('>')>0 or line.find('&&')>0:
diff --git a/waflib/TaskGen.py b/waflib/TaskGen.py
index 8d8f26d..68e998e 100644
--- a/waflib/TaskGen.py
+++ b/waflib/TaskGen.py
@@ -2,10 +2,8 @@
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-import sys
-if sys.hexversion < 0x020400f0: from sets import Set as set
import copy,re,os
-from waflib import Task,Utils,Logs,Errors,ConfigSet
+from waflib import Task,Utils,Logs,Errors,ConfigSet,Node
feats=Utils.defaultdict(set)
class task_gen(object):
mappings={}
@@ -80,6 +78,7 @@ class task_gen(object):
if a in x:break
else:
tmp.append(a)
+ tmp.sort()
out=[]
while tmp:
e=tmp.pop()
@@ -154,7 +153,7 @@ def declare_chain(name='',rule=None,reentrant=None,color='BLUE',ext_in=[],ext_ou
_ext_in=ext_in[0]
tsk=self.create_task(name,node)
cnt=0
- keys=self.mappings.keys()+self.__class__.mappings.keys()
+ keys=list(self.mappings.keys())+list(self.__class__.mappings.keys())
for x in ext:
k=node.change_ext(x,ext_in=_ext_in)
tsk.outputs.append(k)
@@ -208,6 +207,7 @@ def extension(*k):
task_gen.mappings[x]=func
return func
return deco
+ at taskgen_method
def to_nodes(self,lst,path=None):
tmp=[]
path=path or self.path
@@ -223,15 +223,49 @@ def to_nodes(self,lst,path=None):
raise Errors.WafError("source not found: %r in %r"%(x,self))
tmp.append(node)
return tmp
+ at feature('*')
def process_source(self):
self.source=self.to_nodes(getattr(self,'source',[]))
for node in self.source:
self.get_hook(node)(self,node)
+ at feature('*')
+ at before_method('process_source')
def process_rule(self):
if not getattr(self,'rule',None):
return
name=str(getattr(self,'name',None)or self.target or self.rule)
- cls=Task.task_factory(name,self.rule,getattr(self,'vars',[]),shell=getattr(self,'shell',True),color=getattr(self,'color','BLUE'))
+ try:
+ cache=self.bld.cache_rule_attr
+ except AttributeError:
+ cache=self.bld.cache_rule_attr={}
+ cls=None
+ if getattr(self,'cache_rule','True'):
+ try:
+ cls=cache[(name,self.rule)]
+ except KeyError:
+ pass
+ if not cls:
+ cls=Task.task_factory(name,self.rule,getattr(self,'vars',[]),shell=getattr(self,'shell',True),color=getattr(self,'color','BLUE'),scan=getattr(self,'scan',None))
+ if getattr(self,'scan',None):
+ cls.scan=self.scan
+ elif getattr(self,'deps',None):
+ def scan(self):
+ nodes=[]
+ for x in self.generator.to_list(getattr(self.generator,'deps',None)):
+ node=self.generator.path.find_resource(x)
+ if not node:
+ self.generator.bld.fatal('Could not find %r (was it declared?)'%x)
+ nodes.append(node)
+ return[nodes,[]]
+ cls.scan=scan
+ if getattr(self,'update_outputs',None):
+ Task.update_outputs(cls)
+ if getattr(self,'always',None):
+ Task.always_run(cls)
+ for x in['after','before','ext_in','ext_out']:
+ setattr(cls,x,getattr(self,x,[]))
+ if getattr(self,'cache_rule','True'):
+ cache[(name,self.rule)]=cls
tsk=self.create_task(name)
if getattr(self,'target',None):
if isinstance(self.target,str):
@@ -249,26 +283,9 @@ def process_rule(self):
if getattr(self,'source',None):
tsk.inputs=self.to_nodes(self.source)
self.source=[]
- if getattr(self,'scan',None):
- cls.scan=self.scan
- elif getattr(self,'deps',None):
- def scan(self):
- nodes=[]
- for x in self.generator.to_list(self.generator.deps):
- node=self.generator.path.find_resource(x)
- if not node:
- self.generator.bld.fatal('Could not find %r (was it declared?)'%x)
- nodes.append(node)
- return[nodes,[]]
- cls.scan=scan
if getattr(self,'cwd',None):
tsk.cwd=self.cwd
- if getattr(self,'update_outputs',None)or getattr(self,'on_results',None):
- Task.update_outputs(cls)
- if getattr(self,'always',None):
- Task.always_run(cls)
- for x in['after','before','ext_in','ext_out']:
- setattr(cls,x,getattr(self,x,[]))
+ at feature('seq')
def sequence_order(self):
if self.meths and self.meths[-1]!='sequence_order':
self.meths.append('sequence_order')
@@ -284,7 +301,12 @@ def sequence_order(self):
re_m4=re.compile('@(\w+)@',re.M)
class subst_pc(Task.Task):
def run(self):
- code=self.inputs[0].read()
+ if getattr(self.generator,'is_copy',None):
+ self.outputs[0].write(self.inputs[0].read('rb'),'wb')
+ if getattr(self.generator,'chmod',None):
+ os.chmod(self.outputs[0].abspath(),self.generator.chmod)
+ return
+ code=self.inputs[0].read(encoding=getattr(self.generator,'encoding','ISO8859-1'))
code=code.replace('%','%%')
lst=[]
def repl(match):
@@ -301,7 +323,8 @@ class subst_pc(Task.Task):
for x in lst:
tmp=getattr(self.generator,x,'')or self.env.get_flat(x)or self.env.get_flat(x.upper())
d[x]=str(tmp)
- self.outputs[0].write(code%d)
+ code=code%d
+ self.outputs[0].write(code,encoding=getattr(self.generator,'encoding','ISO8859-1'))
self.generator.bld.raw_deps[self.uid()]=self.dep_vars=lst
try:delattr(self,'cache_sig')
except AttributeError:pass
@@ -317,37 +340,54 @@ class subst_pc(Task.Task):
lst=[getattr(self.generator,x,'')for x in vars]
upd(Utils.h_list(lst))
return self.m.digest()
+ at extension('.pc.in')
def add_pcfile(self,node):
tsk=self.create_task('subst_pc',node,node.change_ext('.pc','.pc.in'))
self.bld.install_files(getattr(self,'install_path','${LIBDIR}/pkgconfig/'),tsk.outputs)
class subst(subst_pc):
pass
+ at feature('subst')
+ at before_method('process_source','process_rule')
def process_subst(self):
- src=self.to_nodes(getattr(self,'source',[]))
- tgt=getattr(self,'target',[])
- if isinstance(tgt,self.path.__class__):
+ src=Utils.to_list(getattr(self,'source',[]))
+ if isinstance(src,Node.Node):
+ src=[src]
+ tgt=Utils.to_list(getattr(self,'target',[]))
+ if isinstance(tgt,Node.Node):
tgt=[tgt]
- tgt=[isinstance(x,self.path.__class__)and x or self.path.find_or_declare(x)for x in Utils.to_list(tgt)]
if len(src)!=len(tgt):
- raise Errors.WafError('invalid source or target for %r'%self)
+ raise Errors.WafError('invalid number of source/target for %r'%self)
for x,y in zip(src,tgt):
- if not(x and y):
- raise Errors.WafError('invalid source or target for %r'%self)
- tsk=self.create_task('subst',x,y)
- for a in('after','before','ext_in','ext_out'):
- val=getattr(self,a,None)
+ if not x or not y:
+ raise Errors.WafError('null source or target for %r'%self)
+ a,b=None,None
+ if isinstance(x,str)and isinstance(y,str)and x==y:
+ a=self.path.find_node(x)
+ b=self.path.get_bld().make_node(y)
+ if not os.path.isfile(b.abspath()):
+ b.sig=None
+ b.parent.mkdir()
+ else:
+ if isinstance(x,str):
+ a=self.path.find_resource(x)
+ elif isinstance(x,Node.Node):
+ a=x
+ if isinstance(y,str):
+ b=self.path.find_or_declare(y)
+ elif isinstance(y,Node.Node):
+ b=y
+ if not a:
+ raise Errors.WafError('cound not find %r for %r'%(x,self))
+ has_constraints=False
+ tsk=self.create_task('subst',a,b)
+ for k in('after','before','ext_in','ext_out'):
+ val=getattr(self,k,None)
if val:
- setattr(tsk,a,val)
- inst_to=getattr(self,'install_path',None)
- if inst_to:
- self.bld.install_files(inst_to,tgt,chmod=getattr(self,'chmod',Utils.O644))
+ has_constraints=True
+ setattr(tsk,k,val)
+ if not has_constraints and b.name.endswith('.h'):
+ tsk.before=[k for k in('c','cxx')if k in Task.classes]
+ inst_to=getattr(self,'install_path',None)
+ if inst_to:
+ self.bld.install_files(inst_to,b,chmod=getattr(self,'chmod',Utils.O644))
self.source=[]
-
-taskgen_method(to_nodes)
-feature('*')(process_source)
-feature('*')(process_rule)
-before_method('process_source')(process_rule)
-feature('seq')(sequence_order)
-extension('.pc.in')(add_pcfile)
-feature('subst')(process_subst)
-before_method('process_source','process_rule')(process_subst)
\ No newline at end of file
diff --git a/waflib/Tools/ar.py b/waflib/Tools/ar.py
index fd0b7d5..7a16dfe 100644
--- a/waflib/Tools/ar.py
+++ b/waflib/Tools/ar.py
@@ -3,10 +3,9 @@
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
from waflib.Configure import conf
+ at conf
def find_ar(conf):
conf.load('ar')
def configure(conf):
conf.find_program('ar',var='AR')
conf.env.ARFLAGS='rcs'
-
-conf(find_ar)
\ No newline at end of file
diff --git a/waflib/Tools/asm.py b/waflib/Tools/asm.py
deleted file mode 100644
index d78dff5..0000000
--- a/waflib/Tools/asm.py
+++ /dev/null
@@ -1,25 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import os,sys
-from waflib import Task,Utils
-import waflib.Task
-from waflib.Tools.ccroot import link_task,stlink_task
-from waflib.TaskGen import extension,feature
-class asm(Task.Task):
- color='BLUE'
- run_str='${AS} ${ASFLAGS} ${CPPPATH_ST:INCPATHS} ${AS_SRC_F}${SRC} ${AS_TGT_F}${TGT}'
-def asm_hook(self,node):
- return self.create_compiled_task('asm',node)
-class asmprogram(link_task):
- run_str='${ASLINK} ${ASLINKFLAGS} ${ASLNK_TGT_F}${TGT} ${ASLNK_SRC_F}${SRC}'
- ext_out=['.bin']
- inst_to='${BINDIR}'
- chmod=Utils.O755
-class asmshlib(asmprogram):
- inst_to='${LIBDIR}'
-class asmstlib(stlink_task):
- pass
-
-extension('.s','.S','.asm','.ASM','.spp','.SPP')(asm_hook)
\ No newline at end of file
diff --git a/waflib/Tools/bison.py b/waflib/Tools/bison.py
deleted file mode 100644
index a354e3e..0000000
--- a/waflib/Tools/bison.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-from waflib import Task
-from waflib.TaskGen import extension
-class bison(Task.Task):
- color='BLUE'
- run_str='${BISON} ${BISONFLAGS} ${SRC[0].abspath()} -o ${TGT[0].name}'
- ext_out=['.h']
-def big_bison(self,node):
- has_h='-d'in self.env['BISONFLAGS']
- outs=[]
- if node.name.endswith('.yc'):
- outs.append(node.change_ext('.tab.cc'))
- if has_h:
- outs.append(node.change_ext('.tab.hh'))
- else:
- outs.append(node.change_ext('.tab.c'))
- if has_h:
- outs.append(node.change_ext('.tab.h'))
- tsk=self.create_task('bison',node,outs)
- tsk.cwd=node.parent.get_bld().abspath()
- self.source.append(outs[0])
-def configure(conf):
- conf.find_program('bison',var='BISON')
- conf.env.BISONFLAGS=['-d']
-
-extension('.y','.yc','.yy')(big_bison)
\ No newline at end of file
diff --git a/waflib/Tools/c.py b/waflib/Tools/c.py
index 3c941de..4d8cbd5 100644
--- a/waflib/Tools/c.py
+++ b/waflib/Tools/c.py
@@ -5,6 +5,7 @@
from waflib import TaskGen,Task,Utils
from waflib.Tools import c_preproc
from waflib.Tools.ccroot import link_task,stlink_task
+ at TaskGen.extension('.c')
def c_hook(self,node):
return self.create_compiled_task('c',node)
class c(Task.Task):
@@ -12,16 +13,12 @@ class c(Task.Task):
vars=['CCDEPS']
ext_in=['.h']
scan=c_preproc.scan
-Task.classes['cc']=cc=c
class cprogram(link_task):
run_str='${LINK_CC} ${LINKFLAGS} ${CCLNK_SRC_F}${SRC} ${CCLNK_TGT_F}${TGT[0].abspath()} ${RPATH_ST:RPATH} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${FRAMEWORK_ST:FRAMEWORK} ${ARCH_ST:ARCH} ${STLIB_MARKER} ${STLIBPATH_ST:STLIBPATH} ${STLIB_ST:STLIB} ${SHLIB_MARKER} ${LIBPATH_ST:LIBPATH} ${LIB_ST:LIB}'
ext_out=['.bin']
vars=['LINKDEPS']
inst_to='${BINDIR}'
- chmod=Utils.O755
class cshlib(cprogram):
inst_to='${LIBDIR}'
class cstlib(stlink_task):
pass
-
-TaskGen.extension('.c')(c_hook)
\ No newline at end of file
diff --git a/waflib/Tools/c_aliases.py b/waflib/Tools/c_aliases.py
index f21fb9e..a3a2bb9 100644
--- a/waflib/Tools/c_aliases.py
+++ b/waflib/Tools/c_aliases.py
@@ -12,7 +12,7 @@ def get_extensions(lst):
if not isinstance(x,str):
x=x.name
ret.append(x[x.rfind('.')+1:])
- except:
+ except Exception:
pass
return ret
def sniff_features(**kw):
@@ -37,20 +37,19 @@ def sniff_features(**kw):
def set_features(kw,_type):
kw['_type']=_type
kw['features']=Utils.to_list(kw.get('features',[]))+Utils.to_list(sniff_features(**kw))
+ at conf
def program(bld,*k,**kw):
set_features(kw,'program')
return bld(*k,**kw)
+ at conf
def shlib(bld,*k,**kw):
set_features(kw,'shlib')
return bld(*k,**kw)
+ at conf
def stlib(bld,*k,**kw):
set_features(kw,'stlib')
return bld(*k,**kw)
+ at conf
def objects(bld,*k,**kw):
set_features(kw,'objects')
return bld(*k,**kw)
-
-conf(program)
-conf(shlib)
-conf(stlib)
-conf(objects)
\ No newline at end of file
diff --git a/waflib/Tools/c_config.py b/waflib/Tools/c_config.py
index d10e630..965e4ce 100644
--- a/waflib/Tools/c_config.py
+++ b/waflib/Tools/c_config.py
@@ -2,11 +2,9 @@
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-import sys
-if sys.hexversion < 0x020400f0: from sets import Set as set
-import os,imp,sys,re,shlex,shutil
-from waflib import Build,Utils,Configure,Task,Options,Logs,TaskGen,Errors,ConfigSet,Runner
-from waflib.TaskGen import before_method,after_method,feature
+import os,re,shlex,sys
+from waflib import Build,Utils,Task,Options,Logs,Errors,ConfigSet,Runner
+from waflib.TaskGen import after_method,feature
from waflib.Configure import conf
WAF_CONFIG_H='config.h'
DEFKEYS='define_key'
@@ -25,11 +23,6 @@ int main() {
if (sizeof (%(type_name)s)) return 0;
}
'''
-SNIP_CLASS='''
-int main() {
- if (
-}
-'''
SNIP_EMPTY_PROGRAM='''
int main() {
return 0;
@@ -44,7 +37,8 @@ int main() {
'''
MACRO_TO_DESTOS={'__linux__':'linux','__GNU__':'gnu','__FreeBSD__':'freebsd','__NetBSD__':'netbsd','__OpenBSD__':'openbsd','__sun':'sunos','__hpux':'hpux','__sgi':'irix','_AIX':'aix','__CYGWIN__':'cygwin','__MSYS__':'msys','_UWIN':'uwin','_WIN64':'win32','_WIN32':'win32','__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__':'darwin','__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__':'darwin','__QNX__':'qnx','__native_client__':'nacl'}
MACRO_TO_DEST_CPU={'__x86_64__':'x86_64','__i386__':'x86','__ia64__':'ia','__mips__':'mips','__sparc__':'sparc','__alpha__':'alpha','__arm__':'arm','__hppa__':'hppa','__powerpc__':'powerpc',}
-def parse_flags(self,line,uselib,env=None,force_static=False):
+ at conf
+def parse_flags(self,line,uselib_store,env=None,force_static=False):
assert(isinstance(line,str))
env=env or self.env
app=env.append_value
@@ -53,6 +47,7 @@ def parse_flags(self,line,uselib,env=None,force_static=False):
lex.whitespace_split=True
lex.commenters=''
lst=list(lex)
+ uselib=uselib_store
while lst:
x=lst.pop(0)
st=x[:2]
@@ -64,7 +59,7 @@ def parse_flags(self,line,uselib,env=None,force_static=False):
tmp=[x,lst.pop(0)]
app('CFLAGS',tmp)
app('CXXFLAGS',tmp)
- elif st=='-D'or(self.env.CXX_NAME=='msvc'and st=='/D'):
+ elif st=='-D'or(env.CXX_NAME=='msvc'and st=='/D'):
if not ot:ot=lst.pop(0)
app('DEFINES_'+uselib,[ot])
elif st=='-l':
@@ -99,10 +94,12 @@ def parse_flags(self,line,uselib,env=None,force_static=False):
app('LINKFLAGS_'+uselib,tmp)
elif x.endswith('.a')or x.endswith('.so')or x.endswith('.dylib'):
appu('LINKFLAGS_'+uselib,[x])
+ at conf
def ret_msg(self,f,kw):
if isinstance(f,str):
return f
return f(kw)
+ at conf
def validate_cfg(self,kw):
if not'path'in kw:
if not self.env.PKGCONFIG:
@@ -130,6 +127,7 @@ def validate_cfg(self,kw):
return
if not'msg'in kw:
kw['msg']='Checking for %r'%(kw['package']or kw['path'])
+ at conf
def exec_cfg(self,kw):
if'atleast_pkgconfig_version'in kw:
cmd=[kw['path'],'--atleast-pkgconfig-version=%s'%kw['atleast_pkgconfig_version']]
@@ -155,8 +153,6 @@ def exec_cfg(self,kw):
defi=self.env.PKG_CONFIG_DEFINES or{}
for key,val in defi.items():
lst.append('--define-variable=%s=%s'%(key,val))
- if kw['package']:
- lst.extend(Utils.to_list(kw['package']))
if'variables'in kw:
env=kw.get('env',self.env)
uselib=kw.get('uselib_store',kw['package'].upper())
@@ -174,12 +170,14 @@ def exec_cfg(self,kw):
if'--static'in args or'--static-libs'in args:
static=True
lst+=args
+ lst.extend(Utils.to_list(kw['package']))
ret=self.cmd_and_log(lst)
if not'okmsg'in kw:
kw['okmsg']='yes'
self.define(self.have_define(kw.get('uselib_store',kw['package'])),1,0)
self.parse_flags(ret,kw.get('uselib_store',kw['package'].upper()),kw.get('env',self.env),force_static=static)
return ret
+ at conf
def check_cfg(self,*k,**kw):
if k:
lst=k[0].split()
@@ -191,7 +189,7 @@ def check_cfg(self,*k,**kw):
ret=None
try:
ret=self.exec_cfg(kw)
- except self.errors.WafError ,e:
+ except self.errors.WafError:
if'errmsg'in kw:
self.end_msg(kw['errmsg'],'YELLOW')
if Logs.verbose>1:
@@ -203,6 +201,7 @@ def check_cfg(self,*k,**kw):
if'okmsg'in kw:
self.end_msg(self.ret_msg(kw['okmsg'],kw))
return ret
+ at conf
def validate_c(self,kw):
if not'env'in kw:
kw['env']=self.env.derive()
@@ -320,6 +319,7 @@ def validate_c(self,kw):
if'define_name'in kw:
self.undefine(kw['define_name'])
assert'msg'in kw,'invalid parameters, read http://freehackers.org/~tnagy/wafbook/single.html#config_helpers_c'
+ at conf
def post_check(self,*k,**kw):
is_success=0
if kw['execute']:
@@ -332,7 +332,6 @@ def post_check(self,*k,**kw):
is_success=(kw['success']==0)
if'define_name'in kw:
if'header_name'in kw or'function_name'in kw or'type_name'in kw or'fragment'in kw:
- nm=kw['define_name']
if kw['execute']and kw.get('define_ret',None)and isinstance(is_success,str):
self.define(kw['define_name'],is_success,quote=kw.get('quote',1))
else:
@@ -358,13 +357,14 @@ def post_check(self,*k,**kw):
val=val.rstrip(os.path.sep)
self.env.append_unique(k+'_'+kw['uselib_store'],val)
return is_success
+ at conf
def check(self,*k,**kw):
self.validate_c(kw)
self.start_msg(kw['msg'])
ret=None
try:
ret=self.run_c_code(*k,**kw)
- except self.errors.ConfigurationError ,e:
+ except self.errors.ConfigurationError:
self.end_msg(kw['errmsg'],'YELLOW')
if Logs.verbose>1:
raise
@@ -372,10 +372,12 @@ def check(self,*k,**kw):
self.fatal('The configuration failed')
else:
kw['success']=ret
- self.end_msg(self.ret_msg(kw['okmsg'],kw))
ret=self.post_check(*k,**kw)
if not ret:
+ self.end_msg(kw['errmsg'],'YELLOW')
self.fatal('The configuration failed %r'%ret)
+ else:
+ self.end_msg(self.ret_msg(kw['okmsg'],kw))
return ret
class test_exec(Task.Task):
color='PINK'
@@ -394,30 +396,33 @@ class test_exec(Task.Task):
self.generator.bld.retval=self.generator.bld.cmd_and_log([self.inputs[0].abspath()],env=env)
else:
self.generator.bld.retval=self.generator.bld.exec_command([self.inputs[0].abspath()],env=env)
+ at feature('test_exec')
+ at after_method('apply_link')
def test_exec_fun(self):
self.create_task('test_exec',self.link_task.outputs[0])
CACHE_RESULTS=1
COMPILE_ERRORS=2
+ at conf
def run_c_code(self,*k,**kw):
lst=[str(v)for(p,v)in kw.items()if p!='env']
h=Utils.h_list(lst)
dir=self.bldnode.abspath()+os.sep+(not Utils.is_win32 and'.'or'')+'conf_check_'+Utils.to_hex(h)
try:
os.makedirs(dir)
- except:
+ except OSError:
pass
try:
os.stat(dir)
- except:
+ except OSError:
self.fatal('cannot use the configuration test folder %r'%dir)
cachemode=getattr(Options.options,'confcache',None)
if cachemode==CACHE_RESULTS:
try:
proj=ConfigSet.ConfigSet(os.path.join(dir,'cache_run_c_code'))
- ret=proj['cache_run_c_code']
- except:
+ except OSError:
pass
else:
+ ret=proj['cache_run_c_code']
if isinstance(ret,str)and ret.startswith('Test does not build'):
self.fatal(ret)
return ret
@@ -453,14 +458,21 @@ def run_c_code(self,*k,**kw):
proj['cache_run_c_code']=ret
proj.store(os.path.join(dir,'cache_run_c_code'))
return ret
+ at conf
def check_cxx(self,*k,**kw):
kw['compiler']='cxx'
return self.check(*k,**kw)
+ at conf
def check_cc(self,*k,**kw):
kw['compiler']='c'
return self.check(*k,**kw)
+ at conf
def define(self,key,val,quote=True):
assert key and isinstance(key,str)
+ if val is True:
+ val=1
+ elif val in(False,None):
+ val=0
if isinstance(val,int)or isinstance(val,float):
s='%s=%s'
else:
@@ -475,18 +487,21 @@ def define(self,key,val,quote=True):
else:
self.env.append_value('DEFINES',app)
self.env.append_unique(DEFKEYS,key)
+ at conf
def undefine(self,key):
assert key and isinstance(key,str)
ban=key+'='
lst=[x for x in self.env['DEFINES']if not x.startswith(ban)]
self.env['DEFINES']=lst
self.env.append_unique(DEFKEYS,key)
+ at conf
def define_cond(self,key,val):
assert key and isinstance(key,str)
if val:
self.define(key,1)
else:
self.undefine(key)
+ at conf
def is_defined(self,key):
assert key and isinstance(key,str)
ban=key+'='
@@ -494,6 +509,7 @@ def is_defined(self,key):
if x.startswith(ban):
return True
return False
+ at conf
def get_define(self,key):
assert key and isinstance(key,str)
ban=key+'='
@@ -501,26 +517,30 @@ def get_define(self,key):
if x.startswith(ban):
return x[len(ban):]
return None
+ at conf
def have_define(self,key):
- return self.__dict__.get('HAVE_PAT','HAVE_%s')%Utils.quote_define_name(key)
-def write_config_header(self,configfile='',guard='',top=False,env=None,defines=True,headers=False,remove=True):
+ return(self.env.HAVE_PAT or'HAVE_%s')%Utils.quote_define_name(key)
+ at conf
+def write_config_header(self,configfile='',guard='',top=False,env=None,defines=True,headers=False,remove=True,define_prefix=''):
+ if env:
+ Logs.warn('Cannot pass env to write_config_header')
if not configfile:configfile=WAF_CONFIG_H
- waf_guard=guard or'_%s_WAF'%Utils.quote_define_name(configfile)
+ waf_guard=guard or'W_%s_WAF'%Utils.quote_define_name(configfile)
node=top and self.bldnode or self.path.get_bld()
node=node.make_node(configfile)
node.parent.mkdir()
lst=['/* WARNING! All changes made to this file will be lost! */\n']
lst.append('#ifndef %s\n#define %s\n'%(waf_guard,waf_guard))
- lst.append(self.get_config_header(defines,headers))
+ lst.append(self.get_config_header(defines,headers,define_prefix=define_prefix))
lst.append('\n#endif /* %s */\n'%waf_guard)
node.write('\n'.join(lst))
- env=env or self.env
- env.append_unique(Build.CFG_FILES,[node.abspath()])
+ self.env.append_unique(Build.CFG_FILES,[node.abspath()])
if remove:
for key in self.env[DEFKEYS]:
self.undefine(key)
self.env[DEFKEYS]=[]
-def get_config_header(self,defines=True,headers=False):
+ at conf
+def get_config_header(self,defines=True,headers=False,define_prefix=''):
lst=[]
if headers:
for x in self.env[INCKEYS]:
@@ -529,27 +549,33 @@ def get_config_header(self,defines=True,headers=False):
for x in self.env[DEFKEYS]:
if self.is_defined(x):
val=self.get_define(x)
- lst.append('#define %s %s'%(x,val))
+ lst.append('#define %s %s'%(define_prefix+x,val))
else:
- lst.append('/* #undef %s */'%x)
+ lst.append('/* #undef %s */'%(define_prefix+x))
return"\n".join(lst)
+ at conf
def cc_add_flags(conf):
conf.add_os_flags('CPPFLAGS','CFLAGS')
conf.add_os_flags('CFLAGS')
+ at conf
def cxx_add_flags(conf):
conf.add_os_flags('CPPFLAGS','CXXFLAGS')
conf.add_os_flags('CXXFLAGS')
+ at conf
def link_add_flags(conf):
conf.add_os_flags('LINKFLAGS')
conf.add_os_flags('LDFLAGS','LINKFLAGS')
+ at conf
def cc_load_tools(conf):
if not conf.env.DEST_OS:
conf.env.DEST_OS=Utils.unversioned_sys_platform()
conf.load('c')
+ at conf
def cxx_load_tools(conf):
if not conf.env.DEST_OS:
conf.env.DEST_OS=Utils.unversioned_sys_platform()
conf.load('cxx')
+ at conf
def get_cc_version(conf,cc,gcc=False,icc=False):
cmd=cc+['-dM','-E','-']
env=conf.env.env or None
@@ -557,10 +583,10 @@ def get_cc_version(conf,cc,gcc=False,icc=False):
p=Utils.subprocess.Popen(cmd,stdin=Utils.subprocess.PIPE,stdout=Utils.subprocess.PIPE,stderr=Utils.subprocess.PIPE,env=env)
p.stdin.write('\n')
out=p.communicate()[0]
- except:
+ except Exception:
conf.fatal('Could not determine the compiler version %r'%cmd)
if not isinstance(out,str):
- out=out.decode(sys.stdout.encoding)
+ out=out.decode(sys.stdout.encoding or'iso8859-1')
if gcc:
if out.find('__INTEL_COMPILER')>=0:
conf.fatal('The intel compiler pretends to be gcc')
@@ -570,7 +596,7 @@ def get_cc_version(conf,cc,gcc=False,icc=False):
conf.fatal('Not icc/icpc')
k={}
if icc or gcc:
- out=out.split('\n')
+ out=out.splitlines()
for line in out:
lst=shlex.split(line)
if len(lst)>2:
@@ -612,19 +638,23 @@ def get_cc_version(conf,cc,gcc=False,icc=False):
else:
conf.env['CC_VERSION']=(k['__GNUC__'],k['__GNUC_MINOR__'],k['__GNUC_PATCHLEVEL__'])
return k
+ at conf
def get_xlc_version(conf,cc):
- version_re=re.compile(r"IBM XL C/C\+\+.*, V(?P<major>\d*)\.(?P<minor>\d*)",re.I).search
cmd=cc+['-qversion']
try:
out,err=conf.cmd_and_log(cmd,output=0)
except Errors.WafError:
conf.fatal('Could not find xlc %r'%cmd)
- if out:match=version_re(out)
- else:match=version_re(err)
- if not match:
+ for v in(r"IBM XL C/C\+\+.* V(?P<major>\d*)\.(?P<minor>\d*)"):
+ version_re=re.compile(v,re.I).search
+ match=version_re(out or err)
+ if match:
+ k=match.groupdict()
+ conf.env['CC_VERSION']=(k['major'],k['minor'])
+ break
+ else:
conf.fatal('Could not determine the XLC version.')
- k=match.groupdict()
- conf.env['CC_VERSION']=(k['major'],k['minor'])
+ at conf
def add_as_needed(self):
if self.env.DEST_BINFMT=='elf'and'gcc'in(self.env.CXX_NAME,self.env.CC_NAME):
self.env.append_unique('LINKFLAGS','--as-needed')
@@ -633,6 +663,8 @@ class cfgtask(Task.TaskBase):
return''
def runnable_status(self):
return Task.RUN_ME
+ def uid(self):
+ return Utils.SIG_NIL
def run(self):
conf=self.conf
bld=Build.BuildContext(top_dir=conf.srcnode.abspath(),out_dir=conf.bldnode.abspath())
@@ -642,8 +674,9 @@ class cfgtask(Task.TaskBase):
bld.logger=self.logger
try:
bld.check(**self.args)
- except:
+ except Exception:
return 1
+ at conf
def multicheck(self,*k,**kw):
self.start_msg(kw.get('msg','Executing %d configuration tests'%len(k)))
class par(object):
@@ -652,6 +685,7 @@ def multicheck(self,*k,**kw):
self.cache_global=Options.cache_global
self.nocache=Options.options.nocache
self.returned_tasks=[]
+ self.task_sigs={}
def total(self):
return len(tasks)
def to_log(self,*k,**kw):
@@ -680,34 +714,3 @@ def multicheck(self,*k,**kw):
self.end_msg(kw.get('errmsg','no'),color='YELLOW')
self.fatal(kw.get('fatalmsg',None)or'One of the tests has failed, see the config.log for more information')
self.end_msg('ok')
-
-conf(parse_flags)
-conf(ret_msg)
-conf(validate_cfg)
-conf(exec_cfg)
-conf(check_cfg)
-conf(validate_c)
-conf(post_check)
-conf(check)
-feature('test_exec')(test_exec_fun)
-after_method('apply_link')(test_exec_fun)
-conf(run_c_code)
-conf(check_cxx)
-conf(check_cc)
-conf(define)
-conf(undefine)
-conf(define_cond)
-conf(is_defined)
-conf(get_define)
-conf(have_define)
-conf(write_config_header)
-conf(get_config_header)
-conf(cc_add_flags)
-conf(cxx_add_flags)
-conf(link_add_flags)
-conf(cc_load_tools)
-conf(cxx_load_tools)
-conf(get_cc_version)
-conf(get_xlc_version)
-conf(add_as_needed)
-conf(multicheck)
\ No newline at end of file
diff --git a/waflib/Tools/c_osx.py b/waflib/Tools/c_osx.py
index 92e39c5..579b2a7 100644
--- a/waflib/Tools/c_osx.py
+++ b/waflib/Tools/c_osx.py
@@ -23,12 +23,14 @@ app_info='''
</dict>
</plist>
'''
+ at feature('c','cxx')
def set_macosx_deployment_target(self):
if self.env['MACOSX_DEPLOYMENT_TARGET']:
os.environ['MACOSX_DEPLOYMENT_TARGET']=self.env['MACOSX_DEPLOYMENT_TARGET']
elif'MACOSX_DEPLOYMENT_TARGET'not in os.environ:
if Utils.unversioned_sys_platform()=='darwin':
os.environ['MACOSX_DEPLOYMENT_TARGET']='.'.join(platform.mac_ver()[0].split('.')[:2])
+ at taskgen_method
def create_bundle_dirs(self,name,out):
bld=self.bld
dir=out.parent.find_or_declare(name)
@@ -44,6 +46,8 @@ def bundle_name_for_output(out):
else:
name=name+'.app'
return name
+ at feature('cprogram','cxxprogram')
+ at after_method('apply_link')
def create_task_macapp(self):
if self.env['MACAPP']or getattr(self,'mac_app',False):
out=self.link_task.outputs[0]
@@ -71,6 +75,8 @@ def create_task_macapp(self):
self.bld.install_as(inst_to+'/%s'%rel,node)
if getattr(self.bld,'is_install',None):
self.install_task.hasrun=Task.SKIP_ME
+ at feature('cprogram','cxxprogram')
+ at after_method('apply_link')
def create_task_macplist(self):
if self.env['MACAPP']or getattr(self,'mac_app',False):
out=self.link_task.outputs[0]
@@ -88,6 +94,8 @@ def create_task_macplist(self):
plisttask.code=app_info%self.link_task.outputs[0].name
inst_to=getattr(self,'install_path','/Applications')+'/%s/Contents/'%name
self.bld.install_files(inst_to,n1)
+ at feature('cshlib','cxxshlib')
+ at before_method('apply_link','propagate_uselib_vars')
def apply_bundle(self):
if self.env['MACBUNDLE']or getattr(self,'mac_bundle',False):
self.env['LINKFLAGS_cshlib']=self.env['LINKFLAGS_cxxshlib']=[]
@@ -110,12 +118,3 @@ class macplist(Task.Task):
else:
txt=self.inputs[0].read()
self.outputs[0].write(txt)
-
-feature('c','cxx')(set_macosx_deployment_target)
-taskgen_method(create_bundle_dirs)
-feature('cprogram','cxxprogram')(create_task_macapp)
-after_method('apply_link')(create_task_macapp)
-feature('cprogram','cxxprogram')(create_task_macplist)
-after_method('apply_link')(create_task_macplist)
-feature('cshlib','cxxshlib')(apply_bundle)
-before_method('apply_link','propagate_uselib_vars')(apply_bundle)
\ No newline at end of file
diff --git a/waflib/Tools/c_preproc.py b/waflib/Tools/c_preproc.py
index 4cb99ef..9dfd8ca 100644
--- a/waflib/Tools/c_preproc.py
+++ b/waflib/Tools/c_preproc.py
@@ -2,10 +2,8 @@
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-import sys
-if sys.hexversion < 0x020400f0: from sets import Set as set
-import re,sys,os,string,traceback
-from waflib import Logs,Build,Utils,Errors
+import re,string,traceback
+from waflib import Logs,Utils,Errors
from waflib.Logs import debug,error
class PreprocError(Errors.WafError):
pass
@@ -118,6 +116,7 @@ def get_num(lst):
num,lst=get_num(lst[1:])
return(int(not int(num)),lst)
elif v=='~':
+ num,lst=get_num(lst[1:])
return(~int(num),lst)
else:
raise PreprocError("Invalid op token %r for get_num"%lst)
@@ -134,11 +133,7 @@ def get_term(lst):
return(num,[])
(p,v)=lst[0]
if p==OP:
- if v=='&&'and not num:
- return(num,[])
- elif v=='||'and num:
- return(num,[])
- elif v==',':
+ if v==',':
return get_term(lst[1:])
elif v=='?':
count_par=0
@@ -224,8 +219,10 @@ def reduce_tokens(lst,defs,ban=[]):
to_add=macro_def[1]
if isinstance(macro_def[0],list):
del lst[i]
- for x in range(len(to_add)):
- lst.insert(i,to_add[x])
+ accu=to_add[:]
+ reduce_tokens(accu,defs,ban+[v])
+ for x in range(len(accu)):
+ lst.insert(i,accu[x])
i+=1
else:
args=[]
@@ -400,6 +397,9 @@ def parse_char(txt):
try:return chr_esc[c]
except KeyError:raise PreprocError("could not parse char literal '%s'"%txt)
def tokenize(s):
+ return tokenize_private(s)[:]
+ at Utils.run_once
+def tokenize_private(s):
ret=[]
for match in re_clexer.finditer(s):
m=match.group
@@ -431,6 +431,7 @@ def tokenize(s):
ret.append((name,v))
break
return ret
+ at Utils.run_once
def define_name(line):
return re_mac.match(line).group(0)
class c_parser(object):
@@ -451,7 +452,7 @@ class c_parser(object):
def cached_find_resource(self,node,filename):
try:
nd=node.ctx.cache_nd
- except:
+ except AttributeError:
nd=node.ctx.cache_nd={}
tup=(node,filename)
try:
@@ -462,7 +463,7 @@ class c_parser(object):
if getattr(ret,'children',None):
ret=None
elif ret.is_child_of(node.ctx.bldnode):
- tmp=node.ctx.srcnode.search(ret.path_from(node.ctx.bldnode))
+ tmp=node.ctx.srcnode.search_node(ret.path_from(node.ctx.bldnode))
if tmp and getattr(tmp,'children',None):
ret=None
nd[tup]=ret
@@ -574,7 +575,7 @@ class c_parser(object):
elif token=='define':
try:
self.defs[define_name(line)]=line
- except:
+ except Exception:
raise PreprocError("Invalid define line %s"%line)
elif token=='undef':
m=re_mac.match(line)
@@ -593,7 +594,7 @@ def scan(task):
except AttributeError:
raise Errors.WafError('%r is missing a feature such as "c", "cxx" or "includes": '%task.generator)
if go_absolute:
- nodepaths=incn+standard_includes
+ nodepaths=incn+[task.generator.bld.root.find_dir(x)for x in standard_includes]
else:
nodepaths=[x for x in incn if x.is_child_of(x.ctx.srcnode)or x.is_child_of(x.ctx.bldnode)]
tmp=c_parser(nodepaths)
@@ -601,6 +602,3 @@ def scan(task):
if Logs.verbose:
debug('deps: deps for %r: %r; unresolved %r'%(task.inputs,tmp.nodes,tmp.names))
return(tmp.nodes,tmp.names)
-
-Utils.run_once(tokenize)
-Utils.run_once(define_name)
\ No newline at end of file
diff --git a/waflib/Tools/c_tests.py b/waflib/Tools/c_tests.py
index 30f92c5..b08e7e4 100644
--- a/waflib/Tools/c_tests.py
+++ b/waflib/Tools/c_tests.py
@@ -23,6 +23,8 @@ MAIN_CODE='''
testEXPORT int lib_func(void);
int main(void) {return !(lib_func() == 9);}
'''
+ at feature('link_lib_test')
+ at before_method('process_source')
def link_lib_test_fun(self):
def write_test_file(task):
task.outputs[0].write(task.generator.code)
@@ -37,6 +39,7 @@ def link_lib_test_fun(self):
bld(rule=write_test_file,target='main.'+mode,code=MAIN_CODE)
bld(features='%sshlib'%m,source='test.'+mode,target='test')
bld(features='%sprogram %s'%(m,ex),source='main.'+mode,target='app',use='test',rpath=rpath)
+ at conf
def check_library(self,mode=None,test_exec=True):
if not mode:
mode='c'
@@ -51,6 +54,7 @@ static %s foo_t static_foo () {return 0; }
}
'''
INLINE_VALUES=['inline','__inline__','__inline']
+ at conf
def check_inline(self,**kw):
self.start_msg('Checking for inline')
if not'define_name'in kw:
@@ -73,6 +77,7 @@ def check_inline(self,**kw):
return x
self.fatal('could not use inline functions')
LARGE_FRAGMENT='#include <unistd.h>\nint main() { return !(sizeof(off_t) >= 8); }\n'
+ at conf
def check_large_file(self,**kw):
if not'define_name'in kw:
kw['define_name']='HAVE_LARGEFILE'
@@ -127,20 +132,14 @@ class grep_for_endianness(Task.Task):
self.generator.tmp.append('big')
else:
return-1
+ at feature('grep_for_endianness')
+ at after_method('process_source')
def grep_for_endianness_fun(self):
self.create_task('grep_for_endianness',self.compiled_tasks[0].outputs[0])
+ at conf
def check_endianness(self):
tmp=[]
def check_msg(self):
return tmp[0]
self.check(fragment=ENDIAN_FRAGMENT,features='c grep_for_endianness',msg="Checking for endianness",define='ENDIANNESS',tmp=tmp,okmsg=check_msg)
return tmp[0]
-
-feature('link_lib_test')(link_lib_test_fun)
-before_method('process_source')(link_lib_test_fun)
-conf(check_library)
-conf(check_inline)
-conf(check_large_file)
-feature('grep_for_endianness')(grep_for_endianness_fun)
-after_method('process_source')(grep_for_endianness_fun)
-conf(check_endianness)
\ No newline at end of file
diff --git a/waflib/Tools/ccroot.py b/waflib/Tools/ccroot.py
index e95f793..df98eb9 100644
--- a/waflib/Tools/ccroot.py
+++ b/waflib/Tools/ccroot.py
@@ -2,14 +2,12 @@
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-import sys
-if sys.hexversion < 0x020400f0: from sets import Set as set
import os,sys,re
from waflib import TaskGen,Task,Utils,Logs,Build,Options,Node,Errors
-from waflib.Logs import error,debug,warn
from waflib.TaskGen import after_method,before_method,feature,taskgen_method,extension
from waflib.Tools import c_aliases,c_preproc,c_config,c_osx,c_tests
from waflib.Configure import conf
+SYSTEM_LIB_PATHS=['/usr/lib64','/usr/lib','/usr/local/lib64','/usr/local/lib']
USELIB_VARS=Utils.defaultdict(set)
USELIB_VARS['c']=set(['INCLUDES','FRAMEWORKPATH','DEFINES','CPPFLAGS','CCDEPS','CFLAGS','ARCH'])
USELIB_VARS['cxx']=set(['INCLUDES','FRAMEWORKPATH','DEFINES','CPPFLAGS','CXXDEPS','CXXFLAGS','ARCH'])
@@ -20,9 +18,8 @@ USELIB_VARS['cstlib']=USELIB_VARS['cxxstlib']=set(['ARFLAGS','LINKDEPS'])
USELIB_VARS['dprogram']=set(['LIB','STLIB','LIBPATH','STLIBPATH','LINKFLAGS','RPATH','LINKDEPS'])
USELIB_VARS['dshlib']=set(['LIB','STLIB','LIBPATH','STLIBPATH','LINKFLAGS','RPATH','LINKDEPS'])
USELIB_VARS['dstlib']=set(['ARFLAGS','LINKDEPS'])
-USELIB_VARS['go']=set(['GOCFLAGS'])
-USELIB_VARS['goprogram']=set(['GOLFLAGS'])
USELIB_VARS['asm']=set(['ASFLAGS'])
+ at taskgen_method
def create_compiled_task(self,name,node):
out='%s.%d.o'%(node.name,self.idx)
task=self.create_task(name,node,node.parent.find_or_declare(out))
@@ -31,6 +28,7 @@ def create_compiled_task(self,name,node):
except AttributeError:
self.compiled_tasks=[task]
return task
+ at taskgen_method
def to_incnodes(self,inlst):
lst=[]
seen=set([])
@@ -55,6 +53,8 @@ def to_incnodes(self,inlst):
lst.append(p)
lst.append(v)
return lst
+ at feature('c','cxx','d','asm','fc','includes')
+ at after_method('propagate_uselib_vars','process_source')
def apply_incpaths(self):
lst=self.to_incnodes(self.to_list(getattr(self,'includes',[]))+self.env['INCLUDES'])
self.includes_nodes=lst
@@ -62,7 +62,7 @@ def apply_incpaths(self):
class link_task(Task.Task):
color='YELLOW'
inst_to=None
- chmod=Utils.O644
+ chmod=Utils.O755
def add_target(self,target):
if isinstance(target,str):
pattern=self.env[self.__class__.__name__+'_PATTERN']
@@ -85,6 +85,8 @@ def rm_tgt(cls):
return old(self)
setattr(cls,'run',wrap)
rm_tgt(stlink_task)
+ at feature('c','cxx','d','fc','asm')
+ at after_method('process_source')
def apply_link(self):
for x in self.features:
if x=='cprogram'and'cxx'in self.features:
@@ -106,6 +108,7 @@ def apply_link(self):
inst_to=self.link_task.__class__.inst_to
if inst_to:
self.install_task=self.bld.install_files(inst_to,self.link_task.outputs[:],env=self.env,chmod=self.link_task.chmod)
+ at taskgen_method
def use_rec(self,name,**kw):
if name in self.tmp_use_not or name in self.tmp_use_seen:
return
@@ -134,9 +137,12 @@ def use_rec(self,name,**kw):
for x in self.to_list(getattr(y,'use',[])):
try:
p[x].append(name)
- except:
+ except KeyError:
p[x]=[name]
self.use_rec(x,objects=objects,stlib=stlib)
+ at feature('c','cxx','d','use','fc')
+ at before_method('apply_incpaths','propagate_uselib_vars')
+ at after_method('apply_link','process_source')
def process_use(self):
use_not=self.tmp_use_not=set([])
use_seen=self.tmp_use_seen=[]
@@ -193,13 +199,17 @@ def process_use(self):
for x in names:
try:
y=self.bld.get_tgen_by_name(x)
- except:
+ except Exception:
if not self.env['STLIB_'+x]and not x in self.uselib:
self.uselib.append(x)
else:
for k in self.to_list(getattr(y,'uselib',[])):
if not self.env['STLIB_'+k]and not k in self.uselib:
self.uselib.append(k)
+ at taskgen_method
+def accept_node_to_link(self,node):
+ return not node.name.endswith('.pdb')
+ at taskgen_method
def add_objects_from_tgen(self,tg):
try:
link_task=self.link_task
@@ -208,14 +218,17 @@ def add_objects_from_tgen(self,tg):
else:
for tsk in getattr(tg,'compiled_tasks',[]):
for x in tsk.outputs:
- if x.name.endswith('.o')or x.name.endswith('.obj'):
+ if self.accept_node_to_link(x):
link_task.inputs.append(x)
+ at taskgen_method
def get_uselib_vars(self):
_vars=set([])
for x in self.features:
if x in USELIB_VARS:
_vars|=USELIB_VARS[x]
return _vars
+ at feature('c','cxx','d','fc','javac','cs','uselib','asm')
+ at after_method('process_use')
def propagate_uselib_vars(self):
_vars=self.get_uselib_vars()
env=self.env
@@ -229,6 +242,8 @@ def propagate_uselib_vars(self):
for x in self.to_list(getattr(self,'uselib',[])):
for v in _vars:
env.append_value(v,env[v+'_'+x])
+ at feature('cshlib','cxxshlib','fcshlib')
+ at after_method('apply_link')
def apply_implib(self):
if not self.env.DEST_BINFMT=='pe':
return
@@ -257,6 +272,8 @@ def apply_implib(self):
if not inst_to:
return
self.implib_install_task=self.bld.install_as('${PREFIX}/lib/%s'%implib.name,implib,self.env)
+ at feature('cshlib','cxxshlib','dshlib','fcshlib','vnum')
+ at after_method('apply_link')
def apply_vnum(self):
if not getattr(self,'vnum','')or os.name!='posix'or self.env.DEST_BINFMT not in('elf','mac-o'):
return
@@ -316,15 +333,18 @@ class fake_stlib(stlink_task):
for x in self.outputs:
x.sig=Utils.h_file(x.abspath())
return Task.SKIP_ME
+ at conf
def read_shlib(self,name,paths=[]):
return self(name=name,features='fake_lib',lib_paths=paths,lib_type='shlib')
+ at conf
def read_stlib(self,name,paths=[]):
return self(name=name,features='fake_lib',lib_paths=paths,lib_type='stlib')
-lib_patterns={'shlib':['lib%s.so','%s.so','lib%s.dll','%s.dll'],'stlib':['lib%s.a','%s.a','lib%s.dll','%s.dll','lib%s.lib','%s.lib'],}
+lib_patterns={'shlib':['lib%s.so','%s.so','lib%s.dylib','lib%s.dll','%s.dll'],'stlib':['lib%s.a','%s.a','lib%s.dll','%s.dll','lib%s.lib','%s.lib'],}
+ at feature('fake_lib')
def process_lib(self):
node=None
names=[x%self.name for x in lib_patterns[self.lib_type]]
- for x in self.lib_paths+[self.path,'/usr/lib64','/usr/lib','/usr/local/lib64','/usr/local/lib']:
+ for x in self.lib_paths+[self.path]+SYSTEM_LIB_PATHS:
if not isinstance(x,Node.Node):
x=self.bld.root.find_node(x)or self.path.find_node(x)
if not x:
@@ -344,32 +364,21 @@ def process_lib(self):
class fake_o(Task.Task):
def runnable_status(self):
return Task.SKIP_ME
+ at extension('.o','.obj')
def add_those_o_files(self,node):
tsk=self.create_task('fake_o',[],node)
try:
self.compiled_tasks.append(tsk)
except AttributeError:
self.compiled_tasks=[tsk]
-
-taskgen_method(create_compiled_task)
-taskgen_method(to_incnodes)
-feature('c','cxx','d','go','asm','fc','includes')(apply_incpaths)
-after_method('propagate_uselib_vars','process_source')(apply_incpaths)
-feature('c','cxx','d','go','fc','asm')(apply_link)
-after_method('process_source')(apply_link)
-taskgen_method(use_rec)
-feature('c','cxx','d','use','fc')(process_use)
-before_method('apply_incpaths','propagate_uselib_vars')(process_use)
-after_method('apply_link','process_source')(process_use)
-taskgen_method(add_objects_from_tgen)
-taskgen_method(get_uselib_vars)
-feature('c','cxx','d','fc','javac','cs','uselib')(propagate_uselib_vars)
-after_method('process_use')(propagate_uselib_vars)
-feature('cshlib','cxxshlib','fcshlib')(apply_implib)
-after_method('apply_link')(apply_implib)
-feature('cshlib','cxxshlib','dshlib','fcshlib','vnum')(apply_vnum)
-after_method('apply_link')(apply_vnum)
-conf(read_shlib)
-conf(read_stlib)
-feature('fake_lib')(process_lib)
-extension('.o','.obj')(add_those_o_files)
\ No newline at end of file
+ at feature('fake_obj')
+ at before_method('process_source')
+def process_objs(self):
+ for node in self.to_nodes(self.source):
+ self.add_those_o_files(node)
+ self.source=[]
+ at conf
+def read_object(self,obj):
+ if not isinstance(obj,self.path.__class__):
+ obj=self.path.find_resource(obj)
+ return self(features='fake_obj',source=obj,name=obj.name)
diff --git a/waflib/Tools/compiler_d.py b/waflib/Tools/compiler_d.py
deleted file mode 100644
index b5396b0..0000000
--- a/waflib/Tools/compiler_d.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import os,sys,imp,types
-from waflib import Utils,Configure,Options,Logs
-def configure(conf):
- for compiler in conf.options.dcheck.split(','):
- conf.env.stash()
- conf.start_msg('Checking for %r (d compiler)'%compiler)
- try:
- conf.load(compiler)
- except conf.errors.ConfigurationError ,e:
- conf.env.revert()
- conf.end_msg(False)
- Logs.debug('compiler_cxx: %r'%e)
- else:
- if conf.env.D:
- conf.end_msg(conf.env.get_flat('D'))
- conf.env['COMPILER_D']=compiler
- conf.env.D_COMPILER=conf.env.D
- break
- conf.end_msg(False)
- else:
- conf.fatal('no suitable d compiler was found')
-def options(opt):
- d_compiler_opts=opt.add_option_group('D Compiler Options')
- d_compiler_opts.add_option('--check-d-compiler',default='gdc,dmd',action='store',help='check for the compiler [Default:gdc,dmd]',dest='dcheck')
- for d_compiler in['gdc','dmd']:
- opt.load('%s'%d_compiler)
diff --git a/waflib/Tools/compiler_fc.py b/waflib/Tools/compiler_fc.py
deleted file mode 100644
index ec5d2ea..0000000
--- a/waflib/Tools/compiler_fc.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import os,sys,imp,types
-from waflib import Utils,Configure,Options,Logs,Errors
-from waflib.Tools import fc
-fc_compiler={'win32':['gfortran','ifort'],'darwin':['gfortran','g95','ifort'],'linux':['gfortran','g95','ifort'],'java':['gfortran','g95','ifort'],'default':['gfortran'],'aix':['gfortran']}
-def __list_possible_compiler(platform):
- try:
- return fc_compiler[platform]
- except KeyError:
- return fc_compiler["default"]
-def configure(conf):
- try:test_for_compiler=conf.options.check_fc
- except AttributeError:conf.fatal("Add options(opt): opt.load('compiler_fc')")
- for compiler in test_for_compiler.split():
- conf.env.stash()
- conf.start_msg('Checking for %r (fortran compiler)'%compiler)
- try:
- conf.load(compiler)
- except conf.errors.ConfigurationError ,e:
- conf.env.revert()
- conf.end_msg(False)
- Logs.debug('compiler_fortran: %r'%e)
- else:
- if conf.env['FC']:
- conf.end_msg(conf.env.get_flat('FC'))
- conf.env.COMPILER_FORTRAN=compiler
- break
- conf.end_msg(False)
- else:
- conf.fatal('could not configure a fortran compiler!')
-def options(opt):
- opt.load_special_tools('fc_*.py')
- build_platform=Utils.unversioned_sys_platform()
- detected_platform=Options.platform
- possible_compiler_list=__list_possible_compiler(detected_platform)
- test_for_compiler=' '.join(possible_compiler_list)
- fortran_compiler_opts=opt.add_option_group("Fortran Compiler Options")
- fortran_compiler_opts.add_option('--check-fortran-compiler',default="%s"%test_for_compiler,help='On this platform (%s) the following Fortran Compiler will be checked by default: "%s"'%(detected_platform,test_for_compiler),dest="check_fc")
- for compiler in test_for_compiler.split():
- opt.load('%s'%compiler)
diff --git a/waflib/Tools/cs.py b/waflib/Tools/cs.py
deleted file mode 100644
index 0fdf761..0000000
--- a/waflib/Tools/cs.py
+++ /dev/null
@@ -1,98 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import sys
-if sys.hexversion < 0x020400f0: from sets import Set as set
-from waflib import Utils,Task,Options,Logs,Errors
-from waflib.TaskGen import before_method,after_method,feature
-from waflib.Tools import ccroot
-from waflib.Configure import conf
-ccroot.USELIB_VARS['cs']=set(['CSFLAGS','ASSEMBLIES','RESOURCES'])
-ccroot.lib_patterns['csshlib']=['%s']
-def apply_cs(self):
- cs_nodes=[]
- no_nodes=[]
- for x in self.to_nodes(self.source):
- if x.name.endswith('.cs'):
- cs_nodes.append(x)
- else:
- no_nodes.append(x)
- self.source=no_nodes
- bintype=getattr(self,'type',self.gen.endswith('.dll')and'library'or'exe')
- self.cs_task=tsk=self.create_task('mcs',cs_nodes,self.path.find_or_declare(self.gen))
- tsk.env.CSTYPE='/target:%s'%bintype
- tsk.env.OUT='/out:%s'%tsk.outputs[0].abspath()
- inst_to=getattr(self,'install_path',bintype=='exe'and'${BINDIR}'or'${LIBDIR}')
- if inst_to:
- mod=getattr(self,'chmod',bintype=='exe'and Utils.O755 or Utils.O644)
- self.install_task=self.bld.install_files(inst_to,self.cs_task.outputs[:],env=self.env,chmod=mod)
-def use_cs(self):
- names=self.to_list(getattr(self,'use',[]))
- get=self.bld.get_tgen_by_name
- for x in names:
- try:
- y=get(x)
- except Errors.WafError:
- self.cs_task.env.append_value('CSFLAGS','/reference:%s'%x)
- continue
- y.post()
- tsk=getattr(y,'cs_task',None)or getattr(y,'link_task',None)
- if not tsk:
- self.bld.fatal('cs task has no link task for use %r'%self)
- self.cs_task.dep_nodes.extend(tsk.outputs)
- self.cs_task.set_run_after(tsk)
- self.cs_task.env.append_value('CSFLAGS','/reference:%s'%tsk.outputs[0].abspath())
-def debug_cs(self):
- csdebug=getattr(self,'csdebug',self.env.CSDEBUG)
- if not csdebug:
- return
- node=self.cs_task.outputs[0]
- if self.env.CS_NAME=='mono':
- out=node.parent.find_or_declare(node.name+'.mdb')
- else:
- out=node.change_ext('.pdb')
- self.cs_task.outputs.append(out)
- try:
- self.install_task.source.append(out)
- except AttributeError:
- pass
- if csdebug=='pdbonly':
- val=['/debug+','/debug:pdbonly']
- elif csdebug=='full':
- val=['/debug+','/debug:full']
- else:
- val=['/debug-']
- self.cs_task.env.append_value('CSFLAGS',val)
-class mcs(Task.Task):
- color='YELLOW'
- run_str='${MCS} ${CSTYPE} ${CSFLAGS} ${ASS_ST:ASSEMBLIES} ${RES_ST:RESOURCES} ${OUT} ${SRC}'
-def configure(conf):
- csc=getattr(Options.options,'cscbinary',None)
- if csc:
- conf.env.MCS=csc
- conf.find_program(['csc','mcs','gmcs'],var='MCS')
- conf.env.ASS_ST='/r:%s'
- conf.env.RES_ST='/resource:%s'
- conf.env.CS_NAME='csc'
- if str(conf.env.MCS).lower().find('mcs')>-1:
- conf.env.CS_NAME='mono'
-def options(opt):
- opt.add_option('--with-csc-binary',type='string',dest='cscbinary')
-class fake_csshlib(Task.Task):
- color='YELLOW'
- inst_to=None
- def runnable_status(self):
- for x in self.outputs:
- x.sig=Utils.h_file(x.abspath())
- return Task.SKIP_ME
-def read_csshlib(self,name,paths=[]):
- return self(name=name,features='fake_lib',lib_paths=paths,lib_type='csshlib')
-
-feature('cs')(apply_cs)
-before_method('process_source')(apply_cs)
-feature('cs')(use_cs)
-after_method('apply_cs')(use_cs)
-feature('cs')(debug_cs)
-after_method('apply_cs','use_cs')(debug_cs)
-conf(read_csshlib)
\ No newline at end of file
diff --git a/waflib/Tools/cxx.py b/waflib/Tools/cxx.py
index e378383..b744a8d 100644
--- a/waflib/Tools/cxx.py
+++ b/waflib/Tools/cxx.py
@@ -5,9 +5,9 @@
from waflib import TaskGen,Task,Utils
from waflib.Tools import c_preproc
from waflib.Tools.ccroot import link_task,stlink_task
+ at TaskGen.extension('.cpp','.cc','.cxx','.C','.c++')
def cxx_hook(self,node):
return self.create_compiled_task('cxx',node)
-TaskGen.extension('.cpp','.cc','.cxx','.C','.c++')(cxx_hook)
if not'.c'in TaskGen.task_gen.mappings:
TaskGen.task_gen.mappings['.c']=TaskGen.task_gen.mappings['.cpp']
class cxx(Task.Task):
@@ -20,7 +20,6 @@ class cxxprogram(link_task):
vars=['LINKDEPS']
ext_out=['.bin']
inst_to='${BINDIR}'
- chmod=Utils.O755
class cxxshlib(cxxprogram):
inst_to='${LIBDIR}'
class cxxstlib(stlink_task):
diff --git a/waflib/Tools/d.py b/waflib/Tools/d.py
deleted file mode 100644
index b56f3dd..0000000
--- a/waflib/Tools/d.py
+++ /dev/null
@@ -1,56 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-from waflib import Utils,Task,Errors
-from waflib.TaskGen import taskgen_method,feature,extension
-from waflib.Tools import d_scan,d_config
-from waflib.Tools.ccroot import link_task,stlink_task
-class d(Task.Task):
- color='GREEN'
- run_str='${D} ${DFLAGS} ${DINC_ST:INCPATHS} ${D_SRC_F:SRC} ${D_TGT_F:TGT}'
- scan=d_scan.scan
-class d_with_header(d):
- run_str='${D} ${DFLAGS} ${DINC_ST:INCPATHS} ${D_HDR_F:tgt.outputs[1].bldpath()} ${D_SRC_F:SRC} ${D_TGT_F:tgt.outputs[0].bldpath()}'
-class d_header(Task.Task):
- color='BLUE'
- run_str='${D} ${D_HEADER} ${SRC}'
-class dprogram(link_task):
- run_str='${D_LINKER} ${LINKFLAGS} ${DLNK_SRC_F}${SRC} ${DLNK_TGT_F:TGT} ${RPATH_ST:RPATH} ${DSTLIB_MARKER} ${DSTLIBPATH_ST:STLIBPATH} ${DSTLIB_ST:STLIB} ${DSHLIB_MARKER} ${DLIBPATH_ST:LIBPATH} ${DSHLIB_ST:LIB}'
- inst_to='${BINDIR}'
- chmod=Utils.O755
-class dshlib(dprogram):
- inst_to='${LIBDIR}'
-class dstlib(stlink_task):
- pass
-def d_hook(self,node):
- ext=Utils.destos_to_binfmt(self.env.DEST_OS)=='pe'and'obj'or'o'
- out='%s.%d.%s'%(node.name,self.idx,ext)
- def create_compiled_task(self,name,node):
- task=self.create_task(name,node,node.parent.find_or_declare(out))
- try:
- self.compiled_tasks.append(task)
- except AttributeError:
- self.compiled_tasks=[task]
- return task
- if getattr(self,'generate_headers',None):
- tsk=create_compiled_task(self,'d_with_header',node)
- tsk.outputs.append(node.change_ext(self.env['DHEADER_ext']))
- else:
- tsk=create_compiled_task(self,'d',node)
- return tsk
-def generate_header(self,filename,install_path=None):
- try:
- self.header_lst.append([filename,install_path])
- except AttributeError:
- self.header_lst=[[filename,install_path]]
-def process_header(self):
- for i in getattr(self,'header_lst',[]):
- node=self.path.find_resource(i[0])
- if not node:
- raise Errors.WafError('file %r not found on d obj'%i[0])
- self.create_task('d_header',node,node.change_ext('.di'))
-
-extension('.d','.di','.D')(d_hook)
-taskgen_method(generate_header)
-feature('d')(process_header)
\ No newline at end of file
diff --git a/waflib/Tools/d_config.py b/waflib/Tools/d_config.py
deleted file mode 100644
index a61ac80..0000000
--- a/waflib/Tools/d_config.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-from waflib import Utils
-from waflib.Configure import conf
-def d_platform_flags(self):
- v=self.env
- if not v.DEST_OS:
- v.DEST_OS=Utils.unversioned_sys_platform()
- if Utils.destos_to_binfmt(self.env.DEST_OS)=='pe':
- v['dprogram_PATTERN']='%s.exe'
- v['dshlib_PATTERN']='lib%s.dll'
- v['dstlib_PATTERN']='lib%s.a'
- else:
- v['dprogram_PATTERN']='%s'
- v['dshlib_PATTERN']='lib%s.so'
- v['dstlib_PATTERN']='lib%s.a'
-DLIB='''
-version(D_Version2) {
- import std.stdio;
- int main() {
- writefln("phobos2");
- return 0;
- }
-} else {
- version(Tango) {
- import tango.stdc.stdio;
- int main() {
- printf("tango");
- return 0;
- }
- } else {
- import std.stdio;
- int main() {
- writefln("phobos1");
- return 0;
- }
- }
-}
-'''
-def check_dlibrary(self):
- ret=self.check_cc(features='d dprogram',fragment=DLIB,compile_filename='test.d',execute=True,define_ret=True)
- self.env.DLIBRARY=ret.strip()
-
-conf(d_platform_flags)
-conf(check_dlibrary)
\ No newline at end of file
diff --git a/waflib/Tools/d_scan.py b/waflib/Tools/d_scan.py
deleted file mode 100644
index ee80c5f..0000000
--- a/waflib/Tools/d_scan.py
+++ /dev/null
@@ -1,133 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import re
-from waflib import Utils,Logs
-def filter_comments(filename):
- txt=Utils.readf(filename)
- i=0
- buf=[]
- max=len(txt)
- begin=0
- while i<max:
- c=txt[i]
- if c=='"'or c=="'":
- buf.append(txt[begin:i])
- delim=c
- i+=1
- while i<max:
- c=txt[i]
- if c==delim:break
- elif c=='\\':
- i+=1
- i+=1
- i+=1
- begin=i
- elif c=='/':
- buf.append(txt[begin:i])
- i+=1
- if i==max:break
- c=txt[i]
- if c=='+':
- i+=1
- nesting=1
- c=None
- while i<max:
- prev=c
- c=txt[i]
- if prev=='/'and c=='+':
- nesting+=1
- c=None
- elif prev=='+'and c=='/':
- nesting-=1
- if nesting==0:break
- c=None
- i+=1
- elif c=='*':
- i+=1
- c=None
- while i<max:
- prev=c
- c=txt[i]
- if prev=='*'and c=='/':break
- i+=1
- elif c=='/':
- i+=1
- while i<max and txt[i]!='\n':
- i+=1
- else:
- begin=i-1
- continue
- i+=1
- begin=i
- buf.append(' ')
- else:
- i+=1
- buf.append(txt[begin:])
- return buf
-class d_parser(object):
- def __init__(self,env,incpaths):
- self.allnames=[]
- self.re_module=re.compile("module\s+([^;]+)")
- self.re_import=re.compile("import\s+([^;]+)")
- self.re_import_bindings=re.compile("([^:]+):(.*)")
- self.re_import_alias=re.compile("[^=]+=(.+)")
- self.env=env
- self.nodes=[]
- self.names=[]
- self.incpaths=incpaths
- def tryfind(self,filename):
- found=0
- for n in self.incpaths:
- found=n.find_resource(filename.replace('.','/')+'.d')
- if found:
- self.nodes.append(found)
- self.waiting.append(found)
- break
- if not found:
- if not filename in self.names:
- self.names.append(filename)
- def get_strings(self,code):
- self.module=''
- lst=[]
- mod_name=self.re_module.search(code)
- if mod_name:
- self.module=re.sub('\s+','',mod_name.group(1))
- import_iterator=self.re_import.finditer(code)
- if import_iterator:
- for import_match in import_iterator:
- import_match_str=re.sub('\s+','',import_match.group(1))
- bindings_match=self.re_import_bindings.match(import_match_str)
- if bindings_match:
- import_match_str=bindings_match.group(1)
- matches=import_match_str.split(',')
- for match in matches:
- alias_match=self.re_import_alias.match(match)
- if alias_match:
- match=alias_match.group(1)
- lst.append(match)
- return lst
- def start(self,node):
- self.waiting=[node]
- while self.waiting:
- nd=self.waiting.pop(0)
- self.iter(nd)
- def iter(self,node):
- path=node.abspath()
- code="".join(filter_comments(path))
- names=self.get_strings(code)
- for x in names:
- if x in self.allnames:continue
- self.allnames.append(x)
- self.tryfind(x)
-def scan(self):
- env=self.env
- gruik=d_parser(env,self.generator.includes_nodes)
- node=self.inputs[0]
- gruik.start(node)
- nodes=gruik.nodes
- names=gruik.names
- if Logs.verbose:
- Logs.debug('deps: deps for %s: %r; unresolved %r'%(str(node),nodes,names))
- return(nodes,names)
diff --git a/waflib/Tools/dbus.py b/waflib/Tools/dbus.py
deleted file mode 100644
index 9204da8..0000000
--- a/waflib/Tools/dbus.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-from waflib import Task,Errors
-from waflib.TaskGen import taskgen_method,before_method
-def add_dbus_file(self,filename,prefix,mode):
- if not hasattr(self,'dbus_lst'):
- self.dbus_lst=[]
- if not'process_dbus'in self.meths:
- self.meths.append('process_dbus')
- self.dbus_lst.append([filename,prefix,mode])
-def process_dbus(self):
- for filename,prefix,mode in getattr(self,'dbus_lst',[]):
- node=self.path.find_resource(filename)
- if not node:
- raise Errors.WafError('file not found '+filename)
- tsk=self.create_task('dbus_binding_tool',node,node.change_ext('.h'))
- tsk.env.DBUS_BINDING_TOOL_PREFIX=prefix
- tsk.env.DBUS_BINDING_TOOL_MODE=mode
-class dbus_binding_tool(Task.Task):
- color='BLUE'
- ext_out=['.h']
- run_str='${DBUS_BINDING_TOOL} --prefix=${DBUS_BINDING_TOOL_PREFIX} --mode=${DBUS_BINDING_TOOL_MODE} --output=${TGT} ${SRC}'
- shell=True
-def configure(conf):
- dbus_binding_tool=conf.find_program('dbus-binding-tool',var='DBUS_BINDING_TOOL')
-
-taskgen_method(add_dbus_file)
-before_method('apply_core')(process_dbus)
\ No newline at end of file
diff --git a/waflib/Tools/dmd.py b/waflib/Tools/dmd.py
deleted file mode 100644
index 7d3f7df..0000000
--- a/waflib/Tools/dmd.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import sys
-from waflib.Tools import ar,d
-from waflib.Configure import conf
-def find_dmd(conf):
- conf.find_program(['dmd','ldc'],var='D')
-def common_flags_ldc(conf):
- v=conf.env
- v['DFLAGS']=['-d-version=Posix']
- v['LINKFLAGS']=[]
- v['DFLAGS_dshlib']=['-relocation-model=pic']
-def common_flags_dmd(conf):
- v=conf.env
- v['D_SRC_F']=['-c']
- v['D_TGT_F']='-of%s'
- v['D_LINKER']=v['D']
- v['DLNK_SRC_F']=''
- v['DLNK_TGT_F']='-of%s'
- v['DINC_ST']='-I%s'
- v['DSHLIB_MARKER']=v['DSTLIB_MARKER']=''
- v['DSTLIB_ST']=v['DSHLIB_ST']='-L-l%s'
- v['DSTLIBPATH_ST']=v['DLIBPATH_ST']='-L-L%s'
- v['LINKFLAGS_dprogram']=['-quiet']
- v['DFLAGS_dshlib']=['-fPIC']
- v['LINKFLAGS_dshlib']=['-L-shared']
- v['DHEADER_ext']='.di'
- v.DFLAGS_d_with_header=['-H','-Hf']
- v['D_HDR_F']='%s'
-def configure(conf):
- conf.find_dmd()
- if sys.platform=='win32':
- out=conf.cmd_and_log([conf.env.D,'--help'])
- if out.find("D Compiler v2.")>-1:
- conf.fatal('dmd2 on Windows is not supported, use gdc or ldc instead')
- conf.load('ar')
- conf.load('d')
- conf.common_flags_dmd()
- conf.d_platform_flags()
- if str(conf.env.D).find('ldc')>-1:
- conf.common_flags_ldc()
-
-conf(find_dmd)
-conf(common_flags_ldc)
-conf(common_flags_dmd)
\ No newline at end of file
diff --git a/waflib/Tools/errcheck.py b/waflib/Tools/errcheck.py
index 93cb6c3..3b06493 100644
--- a/waflib/Tools/errcheck.py
+++ b/waflib/Tools/errcheck.py
@@ -2,9 +2,7 @@
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-import sys
-if sys.hexversion < 0x020400f0: from sets import Set as set
-typos={'feature':'features','sources':'source','targets':'target','include':'includes','export_include':'export_includes','define':'defines','importpath':'includes','installpath':'install_path',}
+typos={'feature':'features','sources':'source','targets':'target','include':'includes','export_include':'export_includes','define':'defines','importpath':'includes','installpath':'install_path','iscopy':'is_copy',}
meths_typos=['__call__','program','shlib','stlib','objects']
from waflib import Logs,Build,Node,Task,TaskGen,ConfigSet,Errors,Utils
import waflib.Tools.ccroot
@@ -18,7 +16,7 @@ def check_same_targets(self):
mp[node].append(tsk)
try:
uids[tsk.uid()].append(tsk)
- except:
+ except KeyError:
uids[tsk.uid()]=[tsk]
for g in self.groups:
for tg in g:
@@ -31,7 +29,7 @@ def check_same_targets(self):
for(k,v)in mp.items():
if len(v)>1:
dupe=True
- msg='* Node %r is created by more than once%s. The task generators are:'%(k,Logs.verbose==1 and" (full message on 'waf -v -v')"or"")
+ msg='* Node %r is created more than once%s. The task generators are:'%(k,Logs.verbose==1 and" (full message on 'waf -v -v')"or"")
Logs.error(msg)
for x in v:
if Logs.verbose>1:
@@ -41,7 +39,7 @@ def check_same_targets(self):
if not dupe:
for(k,v)in uids.items():
if len(v)>1:
- Logs.error('* Several tasks use the same identifier. Please check the information on\n http://waf.googlecode.com/git/docs/apidocs/Task.html#waflib.Task.Task.uid')
+ Logs.error('* Several tasks use the same identifier. Please check the information on\n http://docs.waf.googlecode.com/git/apidocs_16/Task.html#waflib.Task.Task.uid')
for tsk in v:
Logs.error(' - object %r (%r) defined in %r'%(tsk.__class__.__name__,tsk,tsk.generator))
def check_invalid_constraints(self):
@@ -70,6 +68,8 @@ def replace(m):
ret=oldcall(self,*k,**kw)
for x in typos:
if x in kw:
+ if x=='iscopy'and'subst'in getattr(self,'features',''):
+ continue
err=True
Logs.error('Fix the typo %r -> %r on %r'%(x,typos[x],ret))
return ret
@@ -108,7 +108,7 @@ def enhance_lib():
Logs.error('%r features is probably missing %r'%(self,x))
TaskGen.feature('*')(check_err_features)
def check_err_order(self):
- if not hasattr(self,'rule'):
+ if not hasattr(self,'rule')and not'subst'in Utils.to_list(self.features):
for x in('before','after','ext_in','ext_out'):
if hasattr(self,x):
Logs.warn('Erroneous order constraint %r on non-rule based task generator %r'%(x,self))
@@ -116,7 +116,7 @@ def enhance_lib():
for x in('before','after'):
for y in self.to_list(getattr(self,x,[])):
if not Task.classes.get(y,None):
- Logs.error('Erroneous order constraint %s=%r on %r'%(x,y,self))
+ Logs.error('Erroneous order constraint %s=%r on %r (no such class)'%(x,y,self))
TaskGen.feature('*')(check_err_order)
def check_compile(self):
check_invalid_constraints(self)
diff --git a/waflib/Tools/fc.py b/waflib/Tools/fc.py
deleted file mode 100644
index 30b1b48..0000000
--- a/waflib/Tools/fc.py
+++ /dev/null
@@ -1,123 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import sys
-if sys.hexversion < 0x020400f0: from sets import Set as set
-import re
-from waflib import Utils,Task,TaskGen,Logs
-from waflib.Tools import ccroot,fc_config,fc_scan
-from waflib.TaskGen import feature,before_method,after_method,extension
-from waflib.Configure import conf
-ccroot.USELIB_VARS['fc']=set(['FCFLAGS','DEFINES','INCLUDES'])
-ccroot.USELIB_VARS['fcprogram_test']=ccroot.USELIB_VARS['fcprogram']=set(['LIB','STLIB','LIBPATH','STLIBPATH','LINKFLAGS','RPATH','LINKDEPS'])
-ccroot.USELIB_VARS['fcshlib']=set(['LIB','STLIB','LIBPATH','STLIBPATH','LINKFLAGS','RPATH','LINKDEPS'])
-ccroot.USELIB_VARS['fcstlib']=set(['ARFLAGS','LINKDEPS'])
-def dummy(self):
- pass
-def fc_hook(self,node):
- return self.create_compiled_task('fc',node)
-def modfile(conf,name):
- return{'lower':name.lower()+'.mod','lower.MOD':name.upper()+'.MOD','UPPER.mod':name.upper()+'.mod','UPPER':name.upper()+'.MOD'}[conf.env.FC_MOD_CAPITALIZATION or'lower']
-def get_fortran_tasks(tsk):
- bld=tsk.generator.bld
- tasks=bld.get_tasks_group(bld.get_group_idx(tsk.generator))
- return[x for x in tasks if isinstance(x,fc)and not getattr(x,'nomod',None)and not getattr(x,'mod_fortran_done',None)]
-class fc(Task.Task):
- color='GREEN'
- run_str='${FC} ${FCFLAGS} ${FCINCPATH_ST:INCPATHS} ${FCDEFINES_ST:DEFINES} ${_FCMODOUTFLAGS} ${FC_TGT_F}${TGT[0].abspath()} ${FC_SRC_F}${SRC[0].abspath()}'
- vars=["FORTRANMODPATHFLAG"]
- def scan(self):
- tmp=fc_scan.fortran_parser(self.generator.includes_nodes)
- tmp.task=self
- tmp.start(self.inputs[0])
- if Logs.verbose:
- Logs.debug('deps: deps for %r: %r; unresolved %r'%(self.inputs,tmp.nodes,tmp.names))
- return(tmp.nodes,tmp.names)
- def runnable_status(self):
- if getattr(self,'mod_fortran_done',None):
- return super(fc,self).runnable_status()
- bld=self.generator.bld
- lst=get_fortran_tasks(self)
- for tsk in lst:
- tsk.mod_fortran_done=True
- for tsk in lst:
- ret=tsk.runnable_status()
- if ret==Task.ASK_LATER:
- for x in lst:
- x.mod_fortran_done=None
- return Task.ASK_LATER
- ins=Utils.defaultdict(set)
- outs=Utils.defaultdict(set)
- for tsk in lst:
- key=tsk.uid()
- for x in bld.raw_deps[key]:
- if x.startswith('MOD@'):
- name=bld.modfile(x.replace('MOD@',''))
- node=bld.srcnode.find_or_declare(name)
- tsk.set_outputs(node)
- outs[id(node)].add(tsk)
- for tsk in lst:
- key=tsk.uid()
- for x in bld.raw_deps[key]:
- if x.startswith('USE@'):
- name=bld.modfile(x.replace('USE@',''))
- node=bld.srcnode.find_resource(name)
- if node and node not in tsk.outputs:
- if not node in bld.node_deps[key]:
- bld.node_deps[key].append(node)
- ins[id(node)].add(tsk)
- for k in ins.keys():
- for a in ins[k]:
- a.run_after.update(outs[k])
- tmp=[]
- for t in outs[k]:
- tmp.extend(t.outputs)
- a.dep_nodes.extend(tmp)
- try:
- a.dep_nodes.sort(key=lambda x:x.abspath())
- except:
- a.dep_nodes.sort(lambda x,y:cmp(x.abspath(),y.abspath()))
- for tsk in lst:
- try:
- delattr(tsk,'cache_sig')
- except AttributeError:
- pass
- return super(fc,self).runnable_status()
-class fcprogram(ccroot.link_task):
- color='YELLOW'
- run_str='${FC} ${LINKFLAGS} ${FCLNK_SRC_F}${SRC} ${FCLNK_TGT_F}${TGT[0].abspath()} ${RPATH_ST:RPATH} ${FCSTLIB_MARKER} ${FCSTLIBPATH_ST:STLIBPATH} ${FCSTLIB_ST:STLIB} ${FCSHLIB_MARKER} ${FCLIBPATH_ST:LIBPATH} ${FCLIB_ST:LIB}'
- inst_to='${BINDIR}'
- chmod=Utils.O755
-class fcshlib(fcprogram):
- inst_to='${LIBDIR}'
-class fcprogram_test(fcprogram):
- def can_retrieve_cache(self):
- return False
- def runnable_status(self):
- ret=super(fcprogram_test,self).runnable_status()
- if ret==Task.SKIP_ME:
- ret=Task.RUN_ME
- return ret
- def exec_command(self,cmd,**kw):
- bld=self.generator.bld
- kw['shell']=isinstance(cmd,str)
- kw['stdout']=kw['stderr']=Utils.subprocess.PIPE
- kw['cwd']=bld.variant_dir
- bld.out=bld.err=''
- bld.to_log('command: %s\n'%cmd)
- kw['output']=0
- try:
- (bld.out,bld.err)=bld.cmd_and_log(cmd,**kw)
- except Exception ,e:
- return-1
- if bld.out:
- bld.to_log("out: %s\n"%bld.out)
- if bld.err:
- bld.to_log("err: %s\n"%bld.err)
-class fcstlib(ccroot.stlink_task):
- pass
-
-feature('fcprogram','fcshlib','fcstlib','fcprogram_test')(dummy)
-extension('.f','.f90','.F','.F90','.for','.FOR')(fc_hook)
-conf(modfile)
\ No newline at end of file
diff --git a/waflib/Tools/fc_config.py b/waflib/Tools/fc_config.py
deleted file mode 100644
index f9c97fa..0000000
--- a/waflib/Tools/fc_config.py
+++ /dev/null
@@ -1,283 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import re,shutil,os,sys,string,shlex
-from waflib.Configure import conf
-from waflib.TaskGen import feature,after_method,before_method
-from waflib import Build,Utils
-FC_FRAGMENT=' program main\n end program main\n'
-FC_FRAGMENT2=' PROGRAM MAIN\n END\n'
-def fc_flags(conf):
- v=conf.env
- v['FC_SRC_F']=[]
- v['FC_TGT_F']=['-c','-o']
- v['FCINCPATH_ST']='-I%s'
- v['FCDEFINES_ST']='-D%s'
- if not v['LINK_FC']:v['LINK_FC']=v['FC']
- v['FCLNK_SRC_F']=[]
- v['FCLNK_TGT_F']=['-o']
- v['FCFLAGS_fcshlib']=['-fpic']
- v['LINKFLAGS_fcshlib']=['-shared']
- v['fcshlib_PATTERN']='lib%s.so'
- v['fcstlib_PATTERN']='lib%s.a'
- v['FCLIB_ST']='-l%s'
- v['FCLIBPATH_ST']='-L%s'
- v['FCSTLIB_ST']='-l%s'
- v['FCSTLIBPATH_ST']='-L%s'
- v['FCSTLIB_MARKER']='-Wl,-Bstatic'
- v['FCSHLIB_MARKER']='-Wl,-Bdynamic'
- v['SONAME_ST']='-Wl,-h,%s'
-def check_fortran(self,*k,**kw):
- self.check_cc(fragment=FC_FRAGMENT,compile_filename='test.f',features='fc fcprogram',msg='Compiling a simple fortran app')
-def check_fc(self,*k,**kw):
- kw['compiler']='fc'
- if not'compile_mode'in kw:
- kw['compile_mode']='fc'
- if not'type'in kw:
- kw['type']='fcprogram'
- if not'compile_filename'in kw:
- kw['compile_filename']='test.f90'
- if not'code'in kw:
- kw['code']=FC_FRAGMENT
- return self.check(*k,**kw)
-def fortran_modifier_darwin(conf):
- v=conf.env
- v['FCFLAGS_fcshlib']=['-fPIC','-compatibility_version','1','-current_version','1']
- v['LINKFLAGS_fcshlib']=['-dynamiclib']
- v['fcshlib_PATTERN']='lib%s.dylib'
- v['FRAMEWORKPATH_ST']='-F%s'
- v['FRAMEWORK_ST']='-framework %s'
- v['LINKFLAGS_fcstlib']=[]
- v['FCSHLIB_MARKER']=''
- v['FCSTLIB_MARKER']=''
- v['SONAME_ST']=''
-def fortran_modifier_win32(conf):
- v=conf.env
- v['fcprogram_PATTERN']=v['fcprogram_test_PATTERN']='%s.exe'
- v['fcshlib_PATTERN']='%s.dll'
- v['implib_PATTERN']='lib%s.dll.a'
- v['IMPLIB_ST']='-Wl,--out-implib,%s'
- v['FCFLAGS_fcshlib']=[]
- v.append_value('FCFLAGS_fcshlib',['-DDLL_EXPORT'])
- v.append_value('LINKFLAGS',['-Wl,--enable-auto-import'])
-def fortran_modifier_cygwin(conf):
- fortran_modifier_win32(conf)
- v=conf.env
- v['fcshlib_PATTERN']='cyg%s.dll'
- v.append_value('LINKFLAGS_fcshlib',['-Wl,--enable-auto-image-base'])
- v['FCFLAGS_fcshlib']=[]
-def check_fortran_dummy_main(self,*k,**kw):
- if not self.env.CC:
- self.fatal('A c compiler is required for check_fortran_dummy_main')
- lst=['MAIN__','__MAIN','_MAIN','MAIN_','MAIN']
- lst.extend([m.lower()for m in lst])
- lst.append('')
- self.start_msg('Detecting whether we need a dummy main')
- for main in lst:
- kw['fortran_main']=main
- try:
- self.check_cc(fragment='int %s() { return 0; }\n'%(main or'test'),features='c fcprogram',mandatory=True)
- if not main:
- self.env.FC_MAIN=-1
- self.end_msg('no')
- else:
- self.env.FC_MAIN=main
- self.end_msg('yes %s'%main)
- break
- except self.errors.ConfigurationError:
- pass
- else:
- self.end_msg('not found')
- self.fatal('could not detect whether fortran requires a dummy main, see the config.log')
-GCC_DRIVER_LINE=re.compile('^Driving:')
-POSIX_STATIC_EXT=re.compile('\S+\.a')
-POSIX_LIB_FLAGS=re.compile('-l\S+')
-def is_link_verbose(self,txt):
- assert isinstance(txt,str)
- for line in txt.splitlines():
- if not GCC_DRIVER_LINE.search(line):
- if POSIX_STATIC_EXT.search(line)or POSIX_LIB_FLAGS.search(line):
- return True
- return False
-def check_fortran_verbose_flag(self,*k,**kw):
- self.start_msg('fortran link verbose flag')
- for x in['-v','--verbose','-verbose','-V']:
- try:
- self.check_cc(features='fc fcprogram_test',fragment=FC_FRAGMENT2,compile_filename='test.f',linkflags=[x],mandatory=True)
- except self.errors.ConfigurationError:
- pass
- else:
- if self.is_link_verbose(self.test_bld.err)or self.is_link_verbose(self.test_bld.out):
- self.end_msg(x)
- break
- else:
- self.end_msg('failure')
- self.fatal('Could not obtain the fortran link verbose flag (see config.log)')
- self.env.FC_VERBOSE_FLAG=x
- return x
-LINKFLAGS_IGNORED=[r'-lang*',r'-lcrt[a-zA-Z0-9\.]*\.o',r'-lc$',r'-lSystem',r'-libmil',r'-LIST:*',r'-LNO:*']
-if os.name=='nt':
- LINKFLAGS_IGNORED.extend([r'-lfrt*',r'-luser32',r'-lkernel32',r'-ladvapi32',r'-lmsvcrt',r'-lshell32',r'-lmingw',r'-lmoldname'])
-else:
- LINKFLAGS_IGNORED.append(r'-lgcc*')
-RLINKFLAGS_IGNORED=[re.compile(f)for f in LINKFLAGS_IGNORED]
-def _match_ignore(line):
- for i in RLINKFLAGS_IGNORED:
- if i.match(line):
- return True
- return False
-def parse_fortran_link(lines):
- final_flags=[]
- for line in lines:
- if not GCC_DRIVER_LINE.match(line):
- _parse_flink_line(line,final_flags)
- return final_flags
-SPACE_OPTS=re.compile('^-[LRuYz]$')
-NOSPACE_OPTS=re.compile('^-[RL]')
-def _parse_flink_line(line,final_flags):
- lexer=shlex.shlex(line,posix=True)
- lexer.whitespace_split=True
- t=lexer.get_token()
- tmp_flags=[]
- while t:
- def parse(token):
- if _match_ignore(token):
- pass
- elif token.startswith('-lkernel32')and sys.platform=='cygwin':
- tmp_flags.append(token)
- elif SPACE_OPTS.match(token):
- t=lexer.get_token()
- if t.startswith('P,'):
- t=t[2:]
- for opt in t.split(os.pathsep):
- tmp_flags.append('-L%s'%opt)
- elif NOSPACE_OPTS.match(token):
- tmp_flags.append(token)
- elif POSIX_LIB_FLAGS.match(token):
- tmp_flags.append(token)
- else:
- pass
- t=lexer.get_token()
- return t
- t=parse(t)
- final_flags.extend(tmp_flags)
- return final_flags
-def check_fortran_clib(self,autoadd=True,*k,**kw):
- if not self.env.FC_VERBOSE_FLAG:
- self.fatal('env.FC_VERBOSE_FLAG is not set: execute check_fortran_verbose_flag?')
- self.start_msg('Getting fortran runtime link flags')
- try:
- self.check_cc(fragment=FC_FRAGMENT2,compile_filename='test.f',features='fc fcprogram_test',linkflags=[self.env.FC_VERBOSE_FLAG])
- except:
- self.end_msg(False)
- if kw.get('mandatory',True):
- conf.fatal('Could not find the c library flags')
- else:
- out=self.test_bld.err
- flags=parse_fortran_link(out.splitlines())
- self.end_msg('ok (%s)'%' '.join(flags))
- self.env.LINKFLAGS_CLIB=flags
- return flags
- return[]
-def getoutput(conf,cmd,stdin=False):
- if stdin:
- stdin=Utils.subprocess.PIPE
- else:
- stdin=None
- env=conf.env.env or None
- try:
- p=Utils.subprocess.Popen(cmd,stdin=stdin,stdout=Utils.subprocess.PIPE,stderr=Utils.subprocess.PIPE,env=env)
- if stdin:
- p.stdin.write('\n')
- stdout,stderr=p.communicate()
- except:
- conf.fatal('could not determine the compiler version %r'%cmd)
- else:
- if not isinstance(stdout,str):
- stdout=stdout.decode(sys.stdout.encoding)
- if not isinstance(stderr,str):
- stderr=stderr.decode(sys.stdout.encoding)
- return stdout,stderr
-ROUTINES_CODE="""\
- subroutine foobar()
- return
- end
- subroutine foo_bar()
- return
- end
-"""
-MAIN_CODE="""
-void %(dummy_func_nounder)s(void);
-void %(dummy_func_under)s(void);
-int %(main_func_name)s() {
- %(dummy_func_nounder)s();
- %(dummy_func_under)s();
- return 0;
-}
-"""
-def link_main_routines_tg_method(self):
- def write_test_file(task):
- task.outputs[0].write(task.generator.code)
- bld=self.bld
- bld(rule=write_test_file,target='main.c',code=MAIN_CODE%self.__dict__)
- bld(rule=write_test_file,target='test.f',code=ROUTINES_CODE)
- bld(features='fc fcstlib',source='test.f',target='test')
- bld(features='c fcprogram',source='main.c',target='app',use='test')
-def mangling_schemes():
- for u in['_','']:
- for du in['','_']:
- for c in["lower","upper"]:
- yield(u,du,c)
-def mangle_name(u,du,c,name):
- return getattr(name,c)()+u+(name.find('_')!=-1 and du or'')
-def check_fortran_mangling(self,*k,**kw):
- if not self.env.CC:
- self.fatal('A c compiler is required for link_main_routines')
- if not self.env.FC:
- self.fatal('A fortran compiler is required for link_main_routines')
- if not self.env.FC_MAIN:
- self.fatal('Checking for mangling requires self.env.FC_MAIN (execute "check_fortran_dummy_main" first?)')
- self.start_msg('Getting fortran mangling scheme')
- for(u,du,c)in mangling_schemes():
- try:
- self.check_cc(compile_filename=[],features='link_main_routines_func',msg='nomsg',errmsg='nomsg',mandatory=True,dummy_func_nounder=mangle_name(u,du,c,"foobar"),dummy_func_under=mangle_name(u,du,c,"foo_bar"),main_func_name=self.env.FC_MAIN)
- except self.errors.ConfigurationError:
- pass
- else:
- self.end_msg("ok ('%s', '%s', '%s-case')"%(u,du,c))
- self.env.FORTRAN_MANGLING=(u,du,c)
- break
- else:
- self.end_msg(False)
- self.fatal('mangler not found')
- return(u,du,c)
-def set_lib_pat(self):
- self.env['fcshlib_PATTERN']=self.env['pyext_PATTERN']
-def detect_openmp(self):
- for x in['-fopenmp','-openmp','-mp','-xopenmp','-omp','-qsmp=omp']:
- try:
- self.check_fc(msg='Checking for OpenMP flag %s'%x,fragment='program main\n call omp_get_num_threads()\nend program main',fcflags=x,linkflags=x,uselib_store='OPENMP')
- except self.errors.ConfigurationError:
- pass
- else:
- break
- else:
- self.fatal('Could not find OpenMP')
-
-conf(fc_flags)
-conf(check_fortran)
-conf(check_fc)
-conf(fortran_modifier_darwin)
-conf(fortran_modifier_win32)
-conf(fortran_modifier_cygwin)
-conf(check_fortran_dummy_main)
-conf(is_link_verbose)
-conf(check_fortran_verbose_flag)
-conf(check_fortran_clib)
-feature('link_main_routines_func')(link_main_routines_tg_method)
-before_method('process_source')(link_main_routines_tg_method)
-conf(check_fortran_mangling)
-feature('pyext')(set_lib_pat)
-before_method('propagate_uselib_vars','apply_link')(set_lib_pat)
-conf(detect_openmp)
\ No newline at end of file
diff --git a/waflib/Tools/fc_scan.py b/waflib/Tools/fc_scan.py
deleted file mode 100644
index 48e06b5..0000000
--- a/waflib/Tools/fc_scan.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import re
-from waflib import Utils,Task,TaskGen,Logs
-from waflib.TaskGen import feature,before_method,after_method,extension
-from waflib.Configure import conf
-INC_REGEX="""(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])"""
-USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)"""
-MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)"""
-re_inc=re.compile(INC_REGEX,re.I)
-re_use=re.compile(USE_REGEX,re.I)
-re_mod=re.compile(MOD_REGEX,re.I)
-class fortran_parser(object):
- def __init__(self,incpaths):
- self.seen=[]
- self.nodes=[]
- self.names=[]
- self.incpaths=incpaths
- def find_deps(self,node):
- txt=node.read()
- incs=[]
- uses=[]
- mods=[]
- for line in txt.splitlines():
- m=re_inc.search(line)
- if m:
- incs.append(m.group(1))
- m=re_use.search(line)
- if m:
- uses.append(m.group(1))
- m=re_mod.search(line)
- if m:
- mods.append(m.group(1))
- return(incs,uses,mods)
- def start(self,node):
- self.waiting=[node]
- while self.waiting:
- nd=self.waiting.pop(0)
- self.iter(nd)
- def iter(self,node):
- path=node.abspath()
- incs,uses,mods=self.find_deps(node)
- for x in incs:
- if x in self.seen:
- continue
- self.seen.append(x)
- self.tryfind_header(x)
- for x in uses:
- name="USE@%s"%x
- if not name in self.names:
- self.names.append(name)
- for x in mods:
- name="MOD@%s"%x
- if not name in self.names:
- self.names.append(name)
- def tryfind_header(self,filename):
- found=None
- for n in self.incpaths:
- found=n.find_resource(filename)
- if found:
- self.nodes.append(found)
- self.waiting.append(found)
- break
- if not found:
- if not filename in self.names:
- self.names.append(filename)
diff --git a/waflib/Tools/flex.py b/waflib/Tools/flex.py
deleted file mode 100644
index d5f4367..0000000
--- a/waflib/Tools/flex.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import waflib.TaskGen
-def decide_ext(self,node):
- if'cxx'in self.features:
- return['.lex.cc']
- return['.lex.c']
-def flexfun(tsk):
- env=tsk.env
- bld=tsk.generator.bld
- wd=bld.variant_dir
- def to_list(xx):
- if isinstance(xx,str):return[xx]
- return xx
- tsk.last_cmd=lst=[]
- lst.extend(to_list(env['FLEX']))
- lst.extend(to_list(env['FLEXFLAGS']))
- lst.extend([a.path_from(bld.bldnode)for a in tsk.inputs])
- lst=[x for x in lst if x]
- txt=bld.cmd_and_log(lst,cwd=wd,env=env.env or None,quiet=0)
- tsk.outputs[0].write(txt)
-waflib.TaskGen.declare_chain(name='flex',rule=flexfun,ext_in='.l',decider=decide_ext,)
-def configure(conf):
- conf.find_program('flex',var='FLEX')
- conf.env.FLEXFLAGS=['-t']
diff --git a/waflib/Tools/g95.py b/waflib/Tools/g95.py
deleted file mode 100644
index a2bb542..0000000
--- a/waflib/Tools/g95.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import re
-from waflib import Utils
-from waflib.Tools import fc,fc_config,fc_scan
-from waflib.Configure import conf
-def find_g95(conf):
- fc=conf.find_program('g95',var='FC')
- fc=conf.cmd_to_list(fc)
- conf.get_g95_version(fc)
- conf.env.FC_NAME='G95'
-def g95_flags(conf):
- v=conf.env
- v['FCFLAGS_fcshlib']=['-fPIC']
- v['FORTRANMODFLAG']=['-fmod=','']
- v['FCFLAGS_DEBUG']=['-Werror']
-def g95_modifier_win32(conf):
- fc_config.fortran_modifier_win32(conf)
-def g95_modifier_cygwin(conf):
- fc_config.fortran_modifier_cygwin(conf)
-def g95_modifier_darwin(conf):
- fc_config.fortran_modifier_darwin(conf)
-def g95_modifier_platform(conf):
- dest_os=conf.env['DEST_OS']or Utils.unversioned_sys_platform()
- g95_modifier_func=getattr(conf,'g95_modifier_'+dest_os,None)
- if g95_modifier_func:
- g95_modifier_func()
-def get_g95_version(conf,fc):
- version_re=re.compile(r"g95\s*(?P<major>\d*)\.(?P<minor>\d*)").search
- cmd=fc+['--version']
- out,err=fc_config.getoutput(conf,cmd,stdin=False)
- if out:
- match=version_re(out)
- else:
- match=version_re(err)
- if not match:
- conf.fatal('cannot determine g95 version')
- k=match.groupdict()
- conf.env['FC_VERSION']=(k['major'],k['minor'])
-def configure(conf):
- conf.find_g95()
- conf.find_ar()
- conf.fc_flags()
- conf.g95_flags()
- conf.g95_modifier_platform()
-
-conf(find_g95)
-conf(g95_flags)
-conf(g95_modifier_win32)
-conf(g95_modifier_cygwin)
-conf(g95_modifier_darwin)
-conf(g95_modifier_platform)
-conf(get_g95_version)
\ No newline at end of file
diff --git a/waflib/Tools/gas.py b/waflib/Tools/gas.py
deleted file mode 100644
index 0aef0c4..0000000
--- a/waflib/Tools/gas.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import waflib.Tools.asm
-from waflib.Tools import ar
-def configure(conf):
- conf.find_program(['gas','as','gcc'],var='AS')
- conf.env.AS_TGT_F=['-o']
- conf.env.ASLNK_TGT_F=['-o']
- conf.find_ar()
diff --git a/waflib/Tools/gcc.py b/waflib/Tools/gcc.py
index 5734b76..adf11da 100644
--- a/waflib/Tools/gcc.py
+++ b/waflib/Tools/gcc.py
@@ -6,12 +6,14 @@ import os,sys
from waflib import Configure,Options,Utils
from waflib.Tools import ccroot,ar
from waflib.Configure import conf
+ at conf
def find_gcc(conf):
cc=conf.find_program(['gcc','cc'],var='CC')
cc=conf.cmd_to_list(cc)
conf.get_cc_version(cc,gcc=True)
conf.env.CC_NAME='gcc'
conf.env.CC=cc
+ at conf
def gcc_common_flags(conf):
v=conf.env
v['CC_SRC_F']=[]
@@ -38,6 +40,7 @@ def gcc_common_flags(conf):
v['LINKFLAGS_MACBUNDLE']=['-bundle','-undefined','dynamic_lookup']
v['CFLAGS_MACBUNDLE']=['-fPIC']
v['macbundle_PATTERN']='%s.bundle'
+ at conf
def gcc_modifier_win32(conf):
v=conf.env
v['cprogram_PATTERN']='%s.exe'
@@ -45,14 +48,15 @@ def gcc_modifier_win32(conf):
v['implib_PATTERN']='lib%s.dll.a'
v['IMPLIB_ST']='-Wl,--out-implib,%s'
v['CFLAGS_cshlib']=[]
- v.append_value('CFLAGS_cshlib',['-DDLL_EXPORT'])
v.append_value('LINKFLAGS',['-Wl,--enable-auto-import'])
+ at conf
def gcc_modifier_cygwin(conf):
gcc_modifier_win32(conf)
v=conf.env
v['cshlib_PATTERN']='cyg%s.dll'
v.append_value('LINKFLAGS_cshlib',['-Wl,--enable-auto-image-base'])
v['CFLAGS_cshlib']=[]
+ at conf
def gcc_modifier_darwin(conf):
v=conf.env
v['CFLAGS_cshlib']=['-fPIC','-compatibility_version','1','-current_version','1']
@@ -65,16 +69,20 @@ def gcc_modifier_darwin(conf):
v['SHLIB_MARKER']=[]
v['STLIB_MARKER']=[]
v['SONAME_ST']=[]
+ at conf
def gcc_modifier_aix(conf):
v=conf.env
v['LINKFLAGS_cprogram']=['-Wl,-brtl']
v['LINKFLAGS_cshlib']=['-shared','-Wl,-brtl,-bexpfull']
v['SHLIB_MARKER']=[]
+ at conf
def gcc_modifier_hpux(conf):
v=conf.env
v['SHLIB_MARKER']=[]
+ v['STLIB_MARKER']='-Bstatic'
v['CFLAGS_cshlib']=['-fPIC','-DPIC']
v['cshlib_PATTERN']='lib%s.sl'
+ at conf
def gcc_modifier_platform(conf):
gcc_modifier_func=getattr(conf,'gcc_modifier_'+conf.env.DEST_OS,None)
if gcc_modifier_func:
@@ -87,12 +95,3 @@ def configure(conf):
conf.cc_load_tools()
conf.cc_add_flags()
conf.link_add_flags()
-
-conf(find_gcc)
-conf(gcc_common_flags)
-conf(gcc_modifier_win32)
-conf(gcc_modifier_cygwin)
-conf(gcc_modifier_darwin)
-conf(gcc_modifier_aix)
-conf(gcc_modifier_hpux)
-conf(gcc_modifier_platform)
\ No newline at end of file
diff --git a/waflib/Tools/gdc.py b/waflib/Tools/gdc.py
deleted file mode 100644
index ff8a8ab..0000000
--- a/waflib/Tools/gdc.py
+++ /dev/null
@@ -1,34 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import sys
-from waflib.Tools import ar,d
-from waflib.Configure import conf
-def find_gdc(conf):
- conf.find_program('gdc',var='D')
-def common_flags_gdc(conf):
- v=conf.env
- v['DFLAGS']=[]
- v['D_SRC_F']=['-c']
- v['D_TGT_F']='-o%s'
- v['D_LINKER']=v['D']
- v['DLNK_SRC_F']=''
- v['DLNK_TGT_F']='-o%s'
- v['DINC_ST']='-I%s'
- v['DSHLIB_MARKER']=v['DSTLIB_MARKER']=''
- v['DSTLIB_ST']=v['DSHLIB_ST']='-l%s'
- v['DSTLIBPATH_ST']=v['DLIBPATH_ST']='-L%s'
- v['LINKFLAGS_dshlib']=['-shared']
- v['DHEADER_ext']='.di'
- v.DFLAGS_d_with_header='-fintfc'
- v['D_HDR_F']='-fintfc-file=%s'
-def configure(conf):
- conf.find_gdc()
- conf.load('ar')
- conf.load('d')
- conf.common_flags_gdc()
- conf.d_platform_flags()
-
-conf(find_gdc)
-conf(common_flags_gdc)
\ No newline at end of file
diff --git a/waflib/Tools/gfortran.py b/waflib/Tools/gfortran.py
deleted file mode 100644
index 6dc1da1..0000000
--- a/waflib/Tools/gfortran.py
+++ /dev/null
@@ -1,69 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import re
-from waflib import Utils
-from waflib.Tools import fc,fc_config,fc_scan
-from waflib.Configure import conf
-def find_gfortran(conf):
- fc=conf.find_program(['gfortran','g77'],var='FC')
- fc=conf.cmd_to_list(fc)
- conf.get_gfortran_version(fc)
- conf.env.FC_NAME='GFORTRAN'
-def gfortran_flags(conf):
- v=conf.env
- v['FCFLAGS_fcshlib']=['-fPIC']
- v['FORTRANMODFLAG']=['-J','']
- v['FCFLAGS_DEBUG']=['-Werror']
-def gfortran_modifier_win32(conf):
- fc_config.fortran_modifier_win32(conf)
-def gfortran_modifier_cygwin(conf):
- fc_config.fortran_modifier_cygwin(conf)
-def gfortran_modifier_darwin(conf):
- fc_config.fortran_modifier_darwin(conf)
-def gfortran_modifier_platform(conf):
- dest_os=conf.env['DEST_OS']or Utils.unversioned_sys_platform()
- gfortran_modifier_func=getattr(conf,'gfortran_modifier_'+dest_os,None)
- if gfortran_modifier_func:
- gfortran_modifier_func()
-def get_gfortran_version(conf,fc):
- version_re=re.compile(r"GNU\s*Fortran",re.I).search
- cmd=fc+['--version']
- out,err=fc_config.getoutput(conf,cmd,stdin=False)
- if out:match=version_re(out)
- else:match=version_re(err)
- if not match:
- conf.fatal('Could not determine the compiler type')
- cmd=fc+['-dM','-E','-']
- out,err=fc_config.getoutput(conf,cmd,stdin=True)
- if out.find('__GNUC__')<0:
- conf.fatal('Could not determine the compiler type')
- k={}
- out=out.split('\n')
- import shlex
- for line in out:
- lst=shlex.split(line)
- if len(lst)>2:
- key=lst[1]
- val=lst[2]
- k[key]=val
- def isD(var):
- return var in k
- def isT(var):
- return var in k and k[var]!='0'
- conf.env['FC_VERSION']=(k['__GNUC__'],k['__GNUC_MINOR__'],k['__GNUC_PATCHLEVEL__'])
-def configure(conf):
- conf.find_gfortran()
- conf.find_ar()
- conf.fc_flags()
- conf.gfortran_flags()
- conf.gfortran_modifier_platform()
-
-conf(find_gfortran)
-conf(gfortran_flags)
-conf(gfortran_modifier_win32)
-conf(gfortran_modifier_cygwin)
-conf(gfortran_modifier_darwin)
-conf(gfortran_modifier_platform)
-conf(get_gfortran_version)
\ No newline at end of file
diff --git a/waflib/Tools/glib2.py b/waflib/Tools/glib2.py
deleted file mode 100644
index 0d79e52..0000000
--- a/waflib/Tools/glib2.py
+++ /dev/null
@@ -1,174 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import os
-from waflib import Task,Utils,Options,Errors,Logs
-from waflib.TaskGen import taskgen_method,before_method,after_method,feature
-def add_marshal_file(self,filename,prefix):
- if not hasattr(self,'marshal_list'):
- self.marshal_list=[]
- self.meths.append('process_marshal')
- self.marshal_list.append((filename,prefix))
-def process_marshal(self):
- for f,prefix in getattr(self,'marshal_list',[]):
- node=self.path.find_resource(f)
- if not node:
- raise Errors.WafError('file not found %r'%f)
- h_node=node.change_ext('.h')
- c_node=node.change_ext('.c')
- task=self.create_task('glib_genmarshal',node,[h_node,c_node])
- task.env.GLIB_GENMARSHAL_PREFIX=prefix
- self.source=self.to_nodes(getattr(self,'source',[]))
- self.source.append(c_node)
-class glib_genmarshal(Task.Task):
- def run(self):
- bld=self.inputs[0].__class__.ctx
- get=self.env.get_flat
- cmd1="%s %s --prefix=%s --header > %s"%(get('GLIB_GENMARSHAL'),self.inputs[0].srcpath(),get('GLIB_GENMARSHAL_PREFIX'),self.outputs[0].abspath())
- ret=bld.exec_command(cmd1)
- if ret:return ret
- c='''#include "%s"\n'''%self.outputs[0].name
- self.outputs[1].write(c)
- cmd2="%s %s --prefix=%s --body >> %s"%(get('GLIB_GENMARSHAL'),self.inputs[0].srcpath(),get('GLIB_GENMARSHAL_PREFIX'),self.outputs[1].abspath())
- return bld.exec_command(cmd2)
- vars=['GLIB_GENMARSHAL_PREFIX','GLIB_GENMARSHAL']
- color='BLUE'
- ext_out=['.h']
-def add_enums_from_template(self,source='',target='',template='',comments=''):
- if not hasattr(self,'enums_list'):
- self.enums_list=[]
- self.meths.append('process_enums')
- self.enums_list.append({'source':source,'target':target,'template':template,'file-head':'','file-prod':'','file-tail':'','enum-prod':'','value-head':'','value-prod':'','value-tail':'','comments':comments})
-def add_enums(self,source='',target='',file_head='',file_prod='',file_tail='',enum_prod='',value_head='',value_prod='',value_tail='',comments=''):
- if not hasattr(self,'enums_list'):
- self.enums_list=[]
- self.meths.append('process_enums')
- self.enums_list.append({'source':source,'template':'','target':target,'file-head':file_head,'file-prod':file_prod,'file-tail':file_tail,'enum-prod':enum_prod,'value-head':value_head,'value-prod':value_prod,'value-tail':value_tail,'comments':comments})
-def process_enums(self):
- for enum in getattr(self,'enums_list',[]):
- task=self.create_task('glib_mkenums')
- env=task.env
- inputs=[]
- source_list=self.to_list(enum['source'])
- if not source_list:
- raise Errors.WafError('missing source '+str(enum))
- source_list=[self.path.find_resource(k)for k in source_list]
- inputs+=source_list
- env['GLIB_MKENUMS_SOURCE']=[k.abspath()for k in source_list]
- if not enum['target']:
- raise Errors.WafError('missing target '+str(enum))
- tgt_node=self.path.find_or_declare(enum['target'])
- if tgt_node.name.endswith('.c'):
- self.source.append(tgt_node)
- env['GLIB_MKENUMS_TARGET']=tgt_node.abspath()
- options=[]
- if enum['template']:
- template_node=self.path.find_resource(enum['template'])
- options.append('--template %s'%(template_node.abspath()))
- inputs.append(template_node)
- params={'file-head':'--fhead','file-prod':'--fprod','file-tail':'--ftail','enum-prod':'--eprod','value-head':'--vhead','value-prod':'--vprod','value-tail':'--vtail','comments':'--comments'}
- for param,option in params.items():
- if enum[param]:
- options.append('%s %r'%(option,enum[param]))
- env['GLIB_MKENUMS_OPTIONS']=' '.join(options)
- task.set_inputs(inputs)
- task.set_outputs(tgt_node)
-class glib_mkenums(Task.Task):
- run_str='${GLIB_MKENUMS} ${GLIB_MKENUMS_OPTIONS} ${GLIB_MKENUMS_SOURCE} > ${GLIB_MKENUMS_TARGET}'
- color='PINK'
- ext_out=['.h']
-def add_settings_schemas(self,filename_list):
- if not hasattr(self,'settings_schema_files'):
- self.settings_schema_files=[]
- if not isinstance(filename_list,list):
- filename_list=[filename_list]
- self.settings_schema_files.extend(filename_list)
-def add_settings_enums(self,namespace,filename_list):
- if hasattr(self,'settings_enum_namespace'):
- raise Errors.WafError("Tried to add gsettings enums to '%s' more than once"%self.name)
- self.settings_enum_namespace=namespace
- if type(filename_list)!='list':
- filename_list=[filename_list]
- self.settings_enum_files=filename_list
-def r_change_ext(self,ext):
- name=self.name
- k=name.rfind('.')
- if k>=0:
- name=name[:k]+ext
- else:
- name=name+ext
- return self.parent.find_or_declare([name])
-def process_settings(self):
- enums_tgt_node=[]
- install_files=[]
- settings_schema_files=getattr(self,'settings_schema_files',[])
- if settings_schema_files and not self.env['GLIB_COMPILE_SCHEMAS']:
- raise Errors.WafError("Unable to process GSettings schemas - glib-compile-schemas was not found during configure")
- if hasattr(self,'settings_enum_files'):
- enums_task=self.create_task('glib_mkenums')
- source_list=self.settings_enum_files
- source_list=[self.path.find_resource(k)for k in source_list]
- enums_task.set_inputs(source_list)
- enums_task.env['GLIB_MKENUMS_SOURCE']=[k.abspath()for k in source_list]
- target=self.settings_enum_namespace+'.enums.xml'
- tgt_node=self.path.find_or_declare(target)
- enums_task.set_outputs(tgt_node)
- enums_task.env['GLIB_MKENUMS_TARGET']=tgt_node.abspath()
- enums_tgt_node=[tgt_node]
- install_files.append(tgt_node)
- options='--comments "<!-- @comment@ -->" --fhead "<schemalist>" --vhead " <@type@ id=\\"%s. at EnumName@\\">" --vprod " <value nick=\\"@valuenick@\\" value=\\"@valuenum@\\"/>" --vtail " </@type@>" --ftail "</schemalist>" '%(self.settings_enum_namespace)
- enums_task.env['GLIB_MKENUMS_OPTIONS']=options
- for schema in settings_schema_files:
- schema_task=self.create_task('glib_validate_schema')
- schema_node=self.path.find_resource(schema)
- if not schema_node:
- raise Errors.WafError("Cannot find the schema file '%s'"%schema)
- install_files.append(schema_node)
- source_list=enums_tgt_node+[schema_node]
- schema_task.set_inputs(source_list)
- schema_task.env['GLIB_COMPILE_SCHEMAS_OPTIONS']=[("--schema-file="+k.abspath())for k in source_list]
- target_node=r_change_ext(schema_node,'.xml.valid')
- schema_task.set_outputs(target_node)
- schema_task.env['GLIB_VALIDATE_SCHEMA_OUTPUT']=target_node.abspath()
- def compile_schemas_callback(bld):
- if not bld.is_install:return
- Logs.pprint('YELLOW','Updating GSettings schema cache')
- command=Utils.subst_vars("${GLIB_COMPILE_SCHEMAS} ${GSETTINGSSCHEMADIR}",bld.env)
- ret=self.bld.exec_command(command)
- if self.bld.is_install:
- if not self.env['GSETTINGSSCHEMADIR']:
- raise Errors.WafError('GSETTINGSSCHEMADIR not defined (should have been set up automatically during configure)')
- if install_files:
- self.bld.install_files(self.env['GSETTINGSSCHEMADIR'],install_files)
- if not hasattr(self.bld,'_compile_schemas_registered'):
- self.bld.add_post_fun(compile_schemas_callback)
- self.bld._compile_schemas_registered=True
-class glib_validate_schema(Task.Task):
- run_str='rm -f ${GLIB_VALIDATE_SCHEMA_OUTPUT} && ${GLIB_COMPILE_SCHEMAS} --dry-run ${GLIB_COMPILE_SCHEMAS_OPTIONS} && touch ${GLIB_VALIDATE_SCHEMA_OUTPUT}'
- color='PINK'
-def configure(conf):
- conf.find_program('glib-genmarshal',var='GLIB_GENMARSHAL')
- conf.find_perl_program('glib-mkenums',var='GLIB_MKENUMS')
- conf.find_program('glib-compile-schemas',var='GLIB_COMPILE_SCHEMAS',mandatory=False)
- def getstr(varname):
- return getattr(Options.options,varname,getattr(conf.env,varname,''))
- gsettingsschemadir=getstr('GSETTINGSSCHEMADIR')
- if not gsettingsschemadir:
- datadir=getstr('DATADIR')
- if not datadir:
- prefix=conf.env['PREFIX']
- datadir=os.path.join(prefix,'share')
- gsettingsschemadir=os.path.join(datadir,'glib-2.0','schemas')
- conf.env['GSETTINGSSCHEMADIR']=gsettingsschemadir
-def options(opt):
- opt.add_option('--gsettingsschemadir',help='GSettings schema location [Default: ${datadir}/glib-2.0/schemas]',default='',dest='GSETTINGSSCHEMADIR')
-
-taskgen_method(add_marshal_file)
-before_method('process_source')(process_marshal)
-taskgen_method(add_enums_from_template)
-taskgen_method(add_enums)
-before_method('process_source')(process_enums)
-taskgen_method(add_settings_schemas)
-taskgen_method(add_settings_enums)
-feature('glib2')(process_settings)
\ No newline at end of file
diff --git a/waflib/Tools/gnu_dirs.py b/waflib/Tools/gnu_dirs.py
deleted file mode 100644
index e698170..0000000
--- a/waflib/Tools/gnu_dirs.py
+++ /dev/null
@@ -1,65 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import os
-from waflib import Utils,Options,Context
-_options=[x.split(', ')for x in'''
-bindir, user executables, ${EXEC_PREFIX}/bin
-sbindir, system admin executables, ${EXEC_PREFIX}/sbin
-libexecdir, program executables, ${EXEC_PREFIX}/libexec
-sysconfdir, read-only single-machine data, ${PREFIX}/etc
-sharedstatedir, modifiable architecture-independent data, ${PREFIX}/com
-localstatedir, modifiable single-machine data, ${PREFIX}/var
-libdir, object code libraries, ${EXEC_PREFIX}/lib
-includedir, C header files, ${PREFIX}/include
-oldincludedir, C header files for non-gcc, /usr/include
-datarootdir, read-only arch.-independent data root, ${PREFIX}/share
-datadir, read-only architecture-independent data, ${DATAROOTDIR}
-infodir, info documentation, ${DATAROOTDIR}/info
-localedir, locale-dependent data, ${DATAROOTDIR}/locale
-mandir, man documentation, ${DATAROOTDIR}/man
-docdir, documentation root, ${DATAROOTDIR}/doc/${PACKAGE}
-htmldir, html documentation, ${DOCDIR}
-dvidir, dvi documentation, ${DOCDIR}
-pdfdir, pdf documentation, ${DOCDIR}
-psdir, ps documentation, ${DOCDIR}
-'''.split('\n')if x]
-def configure(conf):
- def get_param(varname,default):
- return getattr(Options.options,varname,'')or default
- env=conf.env
- conf.env.LIBDIR=conf.env.BINDIR=[]
- env['EXEC_PREFIX']=get_param('EXEC_PREFIX',env['PREFIX'])
- env['PACKAGE']=getattr(Context.g_module,'APPNAME',None)or env['PACKAGE']
- complete=False
- iter=0
- while not complete and iter<len(_options)+1:
- iter+=1
- complete=True
- for name,help,default in _options:
- name=name.upper()
- if not env[name]:
- try:
- env[name]=Utils.subst_vars(get_param(name,default).replace('/',os.sep),env)
- except TypeError:
- complete=False
- if not complete:
- lst=[name for name,_,_ in _options if not env[name.upper()]]
- raise conf.errors.WafError('Variable substitution failure %r'%lst)
-def options(opt):
- inst_dir=opt.add_option_group('Installation directories','By default, "waf install" will put the files in\
- "/usr/local/bin", "/usr/local/lib" etc. An installation prefix other\
- than "/usr/local" can be given using "--prefix", for example "--prefix=$HOME"')
- for k in('--prefix','--destdir'):
- option=opt.parser.get_option(k)
- if option:
- opt.parser.remove_option(k)
- inst_dir.add_option(option)
- inst_dir.add_option('--exec-prefix',help='installation prefix [Default: ${PREFIX}]',default='',dest='EXEC_PREFIX')
- dirs_options=opt.add_option_group('Pre-defined installation directories','')
- for name,help,default in _options:
- option_name='--'+name
- str_default=default
- str_help='%s [Default: %s]'%(help,str_default)
- dirs_options.add_option(option_name,help=str_help,default='',dest=name.upper())
diff --git a/waflib/Tools/gxx.py b/waflib/Tools/gxx.py
index 647008d..8257017 100644
--- a/waflib/Tools/gxx.py
+++ b/waflib/Tools/gxx.py
@@ -6,12 +6,14 @@ import os,sys
from waflib import Configure,Options,Utils
from waflib.Tools import ccroot,ar
from waflib.Configure import conf
+ at conf
def find_gxx(conf):
cxx=conf.find_program(['g++','c++'],var='CXX')
cxx=conf.cmd_to_list(cxx)
conf.get_cc_version(cxx,gcc=True)
conf.env.CXX_NAME='gcc'
conf.env.CXX=cxx
+ at conf
def gxx_common_flags(conf):
v=conf.env
v['CXX_SRC_F']=[]
@@ -38,6 +40,7 @@ def gxx_common_flags(conf):
v['LINKFLAGS_MACBUNDLE']=['-bundle','-undefined','dynamic_lookup']
v['CXXFLAGS_MACBUNDLE']=['-fPIC']
v['macbundle_PATTERN']='%s.bundle'
+ at conf
def gxx_modifier_win32(conf):
v=conf.env
v['cxxprogram_PATTERN']='%s.exe'
@@ -45,14 +48,15 @@ def gxx_modifier_win32(conf):
v['implib_PATTERN']='lib%s.dll.a'
v['IMPLIB_ST']='-Wl,--out-implib,%s'
v['CXXFLAGS_cxxshlib']=[]
- v.append_value('CXXFLAGS_cxxshlib',['-DDLL_EXPORT'])
v.append_value('LINKFLAGS',['-Wl,--enable-auto-import'])
+ at conf
def gxx_modifier_cygwin(conf):
gxx_modifier_win32(conf)
v=conf.env
v['cxxshlib_PATTERN']='cyg%s.dll'
v.append_value('LINKFLAGS_cxxshlib',['-Wl,--enable-auto-image-base'])
v['CXXFLAGS_cxxshlib']=[]
+ at conf
def gxx_modifier_darwin(conf):
v=conf.env
v['CXXFLAGS_cxxshlib']=['-fPIC','-compatibility_version','1','-current_version','1']
@@ -65,16 +69,20 @@ def gxx_modifier_darwin(conf):
v['SHLIB_MARKER']=[]
v['STLIB_MARKER']=[]
v['SONAME_ST']=[]
+ at conf
def gxx_modifier_aix(conf):
v=conf.env
v['LINKFLAGS_cxxprogram']=['-Wl,-brtl']
v['LINKFLAGS_cxxshlib']=['-shared','-Wl,-brtl,-bexpfull']
v['SHLIB_MARKER']=[]
+ at conf
def gxx_modifier_hpux(conf):
v=conf.env
v['SHLIB_MARKER']=[]
+ v['STLIB_MARKER']='-Bstatic'
v['CFLAGS_cxxshlib']=['-fPIC','-DPIC']
v['cxxshlib_PATTERN']='lib%s.sl'
+ at conf
def gxx_modifier_platform(conf):
gxx_modifier_func=getattr(conf,'gxx_modifier_'+conf.env.DEST_OS,None)
if gxx_modifier_func:
@@ -87,12 +95,3 @@ def configure(conf):
conf.cxx_load_tools()
conf.cxx_add_flags()
conf.link_add_flags()
-
-conf(find_gxx)
-conf(gxx_common_flags)
-conf(gxx_modifier_win32)
-conf(gxx_modifier_cygwin)
-conf(gxx_modifier_darwin)
-conf(gxx_modifier_aix)
-conf(gxx_modifier_hpux)
-conf(gxx_modifier_platform)
\ No newline at end of file
diff --git a/waflib/Tools/icc.py b/waflib/Tools/icc.py
index eaac1cd..7c75e18 100644
--- a/waflib/Tools/icc.py
+++ b/waflib/Tools/icc.py
@@ -5,6 +5,7 @@
import os,sys
from waflib.Tools import ccroot,ar,gcc
from waflib.Configure import conf
+ at conf
def find_icc(conf):
if sys.platform=='cygwin':
conf.fatal('The Intel compiler does not work on Cygwin')
@@ -27,5 +28,3 @@ def configure(conf):
conf.cc_load_tools()
conf.cc_add_flags()
conf.link_add_flags()
-
-conf(find_icc)
\ No newline at end of file
diff --git a/waflib/Tools/icpc.py b/waflib/Tools/icpc.py
index 6a222ff..14a5325 100644
--- a/waflib/Tools/icpc.py
+++ b/waflib/Tools/icpc.py
@@ -5,6 +5,7 @@
import os,sys
from waflib.Tools import ccroot,ar,gxx
from waflib.Configure import conf
+ at conf
def find_icpc(conf):
if sys.platform=='cygwin':
conf.fatal('The Intel compiler does not work on Cygwin')
@@ -26,5 +27,3 @@ def configure(conf):
conf.cxx_load_tools()
conf.cxx_add_flags()
conf.link_add_flags()
-
-conf(find_icpc)
\ No newline at end of file
diff --git a/waflib/Tools/ifort.py b/waflib/Tools/ifort.py
deleted file mode 100644
index e9ad686..0000000
--- a/waflib/Tools/ifort.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import re
-from waflib import Utils
-from waflib.Tools import fc,fc_config,fc_scan
-from waflib.Configure import conf
-def find_ifort(conf):
- fc=conf.find_program('ifort',var='FC')
- fc=conf.cmd_to_list(fc)
- conf.get_ifort_version(fc)
- conf.env.FC_NAME='IFORT'
-def ifort_modifier_cygwin(conf):
- raise NotImplementedError("Ifort on cygwin not yet implemented")
-def ifort_modifier_win32(conf):
- fc_config.fortran_modifier_win32(conf)
-def ifort_modifier_darwin(conf):
- fc_config.fortran_modifier_darwin(conf)
-def ifort_modifier_platform(conf):
- dest_os=conf.env['DEST_OS']or Utils.unversioned_sys_platform()
- ifort_modifier_func=getattr(conf,'ifort_modifier_'+dest_os,None)
- if ifort_modifier_func:
- ifort_modifier_func()
-def get_ifort_version(conf,fc):
- version_re=re.compile(r"ifort\s*\(IFORT\)\s*(?P<major>\d*)\.(?P<minor>\d*)",re.I).search
- cmd=fc+['--version']
- out,err=fc_config.getoutput(conf,cmd,stdin=False)
- if out:
- match=version_re(out)
- else:
- match=version_re(err)
- if not match:
- conf.fatal('cannot determine ifort version.')
- k=match.groupdict()
- conf.env['FC_VERSION']=(k['major'],k['minor'])
-def configure(conf):
- conf.find_ifort()
- conf.find_program('xiar',var='AR')
- conf.env.ARFLAGS='rcs'
- conf.fc_flags()
- conf.ifort_modifier_platform()
-
-conf(find_ifort)
-conf(ifort_modifier_cygwin)
-conf(ifort_modifier_win32)
-conf(ifort_modifier_darwin)
-conf(ifort_modifier_platform)
-conf(get_ifort_version)
\ No newline at end of file
diff --git a/waflib/Tools/intltool.py b/waflib/Tools/intltool.py
deleted file mode 100644
index 54cb3a2..0000000
--- a/waflib/Tools/intltool.py
+++ /dev/null
@@ -1,78 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import os,re
-from waflib import Configure,TaskGen,Task,Utils,Runner,Options,Build,Logs
-import waflib.Tools.ccroot
-from waflib.TaskGen import feature,before_method
-from waflib.Logs import error
-def apply_intltool_in_f(self):
- try:self.meths.remove('process_source')
- except ValueError:pass
- if not self.env.LOCALEDIR:
- self.env.LOCALEDIR=self.env.PREFIX+'/share/locale'
- for i in self.to_list(self.source):
- node=self.path.find_resource(i)
- podir=getattr(self,'podir','po')
- podirnode=self.path.find_dir(podir)
- if not podirnode:
- error("could not find the podir %r"%podir)
- continue
- cache=getattr(self,'intlcache','.intlcache')
- self.env['INTLCACHE']=os.path.join(self.path.bldpath(),podir,cache)
- self.env['INTLPODIR']=podirnode.bldpath()
- self.env['INTLFLAGS']=getattr(self,'flags',['-q','-u','-c'])
- task=self.create_task('intltool',node,node.change_ext(''))
- inst=getattr(self,'install_path','${LOCALEDIR}')
- if inst:
- self.bld.install_files(inst,task.outputs)
-def apply_intltool_po(self):
- try:self.meths.remove('process_source')
- except ValueError:pass
- if not self.env.LOCALEDIR:
- self.env.LOCALEDIR=self.env.PREFIX+'/share/locale'
- appname=getattr(self,'appname','set_your_app_name')
- podir=getattr(self,'podir','')
- inst=getattr(self,'install_path','${LOCALEDIR}')
- linguas=self.path.find_node(os.path.join(podir,'LINGUAS'))
- if linguas:
- file=open(linguas.abspath())
- langs=[]
- for line in file.readlines():
- if not line.startswith('#'):
- langs+=line.split()
- file.close()
- re_linguas=re.compile('[-a-zA-Z_ at .]+')
- for lang in langs:
- if re_linguas.match(lang):
- node=self.path.find_resource(os.path.join(podir,re_linguas.match(lang).group()+'.po'))
- task=self.create_task('po',node,node.change_ext('.mo'))
- if inst:
- filename=task.outputs[0].name
- (langname,ext)=os.path.splitext(filename)
- inst_file=inst+os.sep+langname+os.sep+'LC_MESSAGES'+os.sep+appname+'.mo'
- self.bld.install_as(inst_file,task.outputs[0],chmod=getattr(self,'chmod',Utils.O644),env=task.env)
- else:
- Logs.pprint('RED',"Error no LINGUAS file found in po directory")
-class po(Task.Task):
- run_str='${MSGFMT} -o ${TGT} ${SRC}'
- color='BLUE'
-class intltool(Task.Task):
- run_str='${INTLTOOL} ${INTLFLAGS} ${INTLCACHE} ${INTLPODIR} ${SRC} ${TGT}'
- color='BLUE'
-def configure(conf):
- conf.find_program('msgfmt',var='MSGFMT')
- conf.find_perl_program('intltool-merge',var='INTLTOOL')
- prefix=conf.env.PREFIX
- datadir=conf.env.DATADIR
- if not datadir:
- datadir=os.path.join(prefix,'share')
- conf.define('LOCALEDIR',os.path.join(datadir,'locale').replace('\\','\\\\'))
- conf.define('DATADIR',datadir.replace('\\','\\\\'))
- if conf.env.CC or conf.env.CXX:
- conf.check(header_name='locale.h')
-
-before_method('process_source')(apply_intltool_in_f)
-feature('intltool_in')(apply_intltool_in_f)
-feature('intltool_po')(apply_intltool_po)
\ No newline at end of file
diff --git a/waflib/Tools/irixcc.py b/waflib/Tools/irixcc.py
index bae88c9..8dbdfca 100644
--- a/waflib/Tools/irixcc.py
+++ b/waflib/Tools/irixcc.py
@@ -6,6 +6,7 @@ import os
from waflib import Utils
from waflib.Tools import ccroot,ar
from waflib.Configure import conf
+ at conf
def find_irixcc(conf):
v=conf.env
cc=None
@@ -16,10 +17,11 @@ def find_irixcc(conf):
cc=conf.cmd_to_list(cc)
try:
conf.cmd_and_log(cc+['-version'])
- except:
+ except Exception:
conf.fatal('%r -version could not be executed'%cc)
v['CC']=cc
v['CC_NAME']='irix'
+ at conf
def irixcc_common_flags(conf):
v=conf.env
v['CC_SRC_F']=''
@@ -44,6 +46,3 @@ def configure(conf):
conf.cc_load_tools()
conf.cc_add_flags()
conf.link_add_flags()
-
-conf(find_irixcc)
-conf(irixcc_common_flags)
\ No newline at end of file
diff --git a/waflib/Tools/javaw.py b/waflib/Tools/javaw.py
deleted file mode 100644
index 26ff560..0000000
--- a/waflib/Tools/javaw.py
+++ /dev/null
@@ -1,275 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import sys
-if sys.hexversion < 0x020400f0: from sets import Set as set
-import os,re,tempfile,shutil
-from waflib.Configure import conf
-from waflib import TaskGen,Task,Utils,Options,Build,Errors,Node,Logs
-from waflib.TaskGen import feature,before_method,after_method
-from waflib.Tools import ccroot
-ccroot.USELIB_VARS['javac']=set(['CLASSPATH','JAVACFLAGS'])
-SOURCE_RE='**/*.java'
-JAR_RE='**/*'
-class_check_source='''
-public class Test {
- public static void main(String[] argv) {
- Class lib;
- if (argv.length < 1) {
- System.err.println("Missing argument");
- System.exit(77);
- }
- try {
- lib = Class.forName(argv[0]);
- } catch (ClassNotFoundException e) {
- System.err.println("ClassNotFoundException");
- System.exit(1);
- }
- lib = null;
- System.exit(0);
- }
-}
-'''
-def apply_java(self):
- Utils.def_attrs(self,jarname='',classpath='',sourcepath='.',srcdir='.',jar_mf_attributes={},jar_mf_classpath=[])
- nodes_lst=[]
- outdir=getattr(self,'outdir',None)
- if outdir:
- if not isinstance(outdir,Node.Node):
- outdir=self.path.get_bld().make_node(self.outdir)
- else:
- outdir=self.path.get_bld()
- outdir.mkdir()
- self.outdir=outdir
- self.env['OUTDIR']=outdir.abspath()
- self.javac_task=tsk=self.create_task('javac')
- tmp=[]
- srcdir=getattr(self,'srcdir','')
- if isinstance(srcdir,Node.Node):
- srcdir=[srcdir]
- for x in Utils.to_list(srcdir):
- if isinstance(x,Node.Node):
- y=x
- else:
- y=self.path.find_dir(x)
- if not y:
- self.bld.fatal('Could not find the folder %s from %s'%(x,self.path))
- tmp.append(y)
- tsk.srcdir=tmp
- if getattr(self,'compat',None):
- tsk.env.append_value('JAVACFLAGS',['-source',self.compat])
- if hasattr(self,'sourcepath'):
- fold=[isinstance(x,Node.Node)and x or self.path.find_dir(x)for x in self.to_list(self.sourcepath)]
- names=os.pathsep.join([x.srcpath()for x in fold])
- else:
- names=[x.srcpath()for x in tsk.srcdir]
- if names:
- tsk.env.append_value('JAVACFLAGS',['-sourcepath',names])
-def use_javac_files(self):
- lst=[]
- self.uselib=self.to_list(getattr(self,'uselib',[]))
- names=self.to_list(getattr(self,'use',[]))
- get=self.bld.get_tgen_by_name
- for x in names:
- try:
- y=get(x)
- except:
- self.uselib.append(x)
- else:
- y.post()
- lst.append(y.jar_task.outputs[0].abspath())
- self.javac_task.set_run_after(y.jar_task)
- if lst:
- self.env.append_value('CLASSPATH',lst)
-def set_classpath(self):
- self.env.append_value('CLASSPATH',getattr(self,'classpath',[]))
- for x in self.tasks:
- x.env.CLASSPATH=os.pathsep.join(self.env.CLASSPATH)+os.pathsep
-def jar_files(self):
- destfile=getattr(self,'destfile','test.jar')
- jaropts=getattr(self,'jaropts',[])
- manifest=getattr(self,'manifest',None)
- basedir=getattr(self,'basedir',None)
- if basedir:
- if not isinstance(self.basedir,Node.Node):
- basedir=self.path.get_bld().make_node(basedir)
- else:
- basedir=self.path.get_bld()
- if not basedir:
- self.bld.fatal('Could not find the basedir %r for %r'%(self.basedir,self))
- self.jar_task=tsk=self.create_task('jar_create')
- if manifest:
- jarcreate=getattr(self,'jarcreate','cfm')
- node=self.path.find_node(manifest)
- tsk.dep_nodes.append(node)
- jaropts.insert(0,node.abspath())
- else:
- jarcreate=getattr(self,'jarcreate','cf')
- if not isinstance(destfile,Node.Node):
- destfile=self.path.find_or_declare(destfile)
- if not destfile:
- self.bld.fatal('invalid destfile %r for %r'%(destfile,self))
- tsk.set_outputs(destfile)
- tsk.basedir=basedir
- jaropts.append('-C')
- jaropts.append(basedir.bldpath())
- jaropts.append('.')
- tsk.env['JAROPTS']=jaropts
- tsk.env['JARCREATE']=jarcreate
- if getattr(self,'javac_task',None):
- tsk.set_run_after(self.javac_task)
-def use_jar_files(self):
- lst=[]
- self.uselib=self.to_list(getattr(self,'uselib',[]))
- names=self.to_list(getattr(self,'use',[]))
- get=self.bld.get_tgen_by_name
- for x in names:
- try:
- y=get(x)
- except:
- self.uselib.append(x)
- else:
- y.post()
- self.jar_task.run_after.update(y.tasks)
-class jar_create(Task.Task):
- color='GREEN'
- run_str='${JAR} ${JARCREATE} ${TGT} ${JAROPTS}'
- def runnable_status(self):
- for t in self.run_after:
- if not t.hasrun:
- return Task.ASK_LATER
- if not self.inputs:
- global JAR_RE
- try:
- self.inputs=[x for x in self.basedir.ant_glob(JAR_RE,remove=False)if id(x)!=id(self.outputs[0])]
- except:
- raise Errors.WafError('Could not find the basedir %r for %r'%(self.basedir,self))
- return super(jar_create,self).runnable_status()
-class javac(Task.Task):
- color='BLUE'
- nocache=True
- vars=['CLASSPATH','JAVACFLAGS','JAVAC','OUTDIR']
- def runnable_status(self):
- for t in self.run_after:
- if not t.hasrun:
- return Task.ASK_LATER
- if not self.inputs:
- global SOURCE_RE
- self.inputs=[]
- for x in self.srcdir:
- self.inputs.extend(x.ant_glob(SOURCE_RE,remove=False))
- return super(javac,self).runnable_status()
- def run(self):
- env=self.env
- gen=self.generator
- bld=gen.bld
- wd=bld.bldnode.abspath()
- def to_list(xx):
- if isinstance(xx,str):return[xx]
- return xx
- cmd=[]
- cmd.extend(to_list(env['JAVAC']))
- cmd.extend(['-classpath'])
- cmd.extend(to_list(env['CLASSPATH']))
- cmd.extend(['-d'])
- cmd.extend(to_list(env['OUTDIR']))
- cmd.extend(to_list(env['JAVACFLAGS']))
- files=[a.path_from(bld.bldnode)for a in self.inputs]
- tmp=None
- try:
- if len(str(files))+len(str(cmd))>8192:
- (fd,tmp)=tempfile.mkstemp(dir=bld.bldnode.abspath())
- try:
- os.write(fd,'\n'.join(files))
- finally:
- if tmp:
- os.close(fd)
- if Logs.verbose:
- Logs.debug('runner: %r'%(cmd+files))
- cmd.append('@'+tmp)
- else:
- cmd+=files
- ret=self.exec_command(cmd,cwd=wd,env=env.env or None)
- finally:
- if tmp:
- os.unlink(tmp)
- return ret
- def post_run(self):
- for n in self.generator.outdir.ant_glob('**/*.class'):
- n.sig=Utils.h_file(n.abspath())
- self.generator.bld.task_sigs[self.uid()]=self.cache_sig
-def configure(self):
- java_path=self.environ['PATH'].split(os.pathsep)
- v=self.env
- if'JAVA_HOME'in self.environ:
- java_path=[os.path.join(self.environ['JAVA_HOME'],'bin')]+java_path
- self.env['JAVA_HOME']=[self.environ['JAVA_HOME']]
- for x in'javac java jar'.split():
- self.find_program(x,var=x.upper(),path_list=java_path)
- self.env[x.upper()]=self.cmd_to_list(self.env[x.upper()])
- if'CLASSPATH'in self.environ:
- v['CLASSPATH']=self.environ['CLASSPATH']
- if not v['JAR']:self.fatal('jar is required for making java packages')
- if not v['JAVAC']:self.fatal('javac is required for compiling java classes')
- v['JARCREATE']='cf'
- v['JAVACFLAGS']=[]
-def check_java_class(self,classname,with_classpath=None):
- javatestdir='.waf-javatest'
- classpath=javatestdir
- if self.env['CLASSPATH']:
- classpath+=os.pathsep+self.env['CLASSPATH']
- if isinstance(with_classpath,str):
- classpath+=os.pathsep+with_classpath
- shutil.rmtree(javatestdir,True)
- os.mkdir(javatestdir)
- java_file=open(os.path.join(javatestdir,'Test.java'),'w')
- java_file.write(class_check_source)
- java_file.close()
- self.exec_command(self.env['JAVAC']+[os.path.join(javatestdir,'Test.java')],shell=False)
- cmd=self.env['JAVA']+['-cp',classpath,'Test',classname]
- self.to_log("%s\n"%str(cmd))
- found=self.exec_command(cmd,shell=False)
- self.msg('Checking for java class %s'%classname,not found)
- shutil.rmtree(javatestdir,True)
- return found
-def check_jni_headers(conf):
- if not conf.env.CC_NAME and not conf.env.CXX_NAME:
- conf.fatal('load a compiler first (gcc, g++, ..)')
- if not conf.env.JAVA_HOME:
- conf.fatal('set JAVA_HOME in the system environment')
- javaHome=conf.env['JAVA_HOME'][0]
- dir=conf.root.find_dir(conf.env.JAVA_HOME[0]+'/include')
- if dir is None:
- conf.fatal('JAVA_HOME does not seem to be set properly')
- f=dir.ant_glob('**/(jni|jni_md).h')
- incDirs=[x.parent.abspath()for x in f]
- dir=conf.root.find_dir(conf.env.JAVA_HOME[0])
- f=dir.ant_glob('**/*jvm.(so|dll|dylib)')
- libDirs=[x.parent.abspath()for x in f]or[javaHome]
- f=dir.ant_glob('**/*jvm.(lib)')
- if f:
- libDirs=[[x,y.parent.abspath()]for x in libDirs for y in f]
- for d in libDirs:
- try:
- conf.check(header_name='jni.h',define_name='HAVE_JNI_H',lib='jvm',libpath=d,includes=incDirs,uselib_store='JAVA',uselib='JAVA')
- except:
- pass
- else:
- break
- else:
- conf.fatal('could not find lib jvm in %r (see config.log)'%libDirs)
-
-feature('javac')(apply_java)
-before_method('process_source')(apply_java)
-feature('javac')(use_javac_files)
-after_method('apply_java')(use_javac_files)
-feature('javac')(set_classpath)
-after_method('apply_java','propagate_uselib_vars','use_javac_files')(set_classpath)
-feature('jar')(jar_files)
-after_method('apply_java','use_javac_files')(jar_files)
-before_method('process_source')(jar_files)
-feature('jar')(use_jar_files)
-after_method('jar_files')(use_jar_files)
-conf(check_java_class)
-conf(check_jni_headers)
\ No newline at end of file
diff --git a/waflib/Tools/kde4.py b/waflib/Tools/kde4.py
deleted file mode 100644
index e4a8a92..0000000
--- a/waflib/Tools/kde4.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import os,sys,re
-from waflib import Options,TaskGen,Task,Utils
-from waflib.TaskGen import feature,after_method
-def apply_msgfmt(self):
- for lang in self.to_list(self.langs):
- node=self.path.find_resource(lang+'.po')
- task=self.create_task('msgfmt',node,node.change_ext('.mo'))
- langname=lang.split('/')
- langname=langname[-1]
- inst=getattr(self,'install_path','${KDE4_LOCALE_INSTALL_DIR}')
- self.bld.install_as(inst+os.sep+langname+os.sep+'LC_MESSAGES'+os.sep+getattr(self,'appname','set_your_appname')+'.mo',task.outputs[0],chmod=getattr(self,'chmod',Utils.O644))
-class msgfmt(Task.Task):
- color='BLUE'
- run_str='${MSGFMT} ${SRC} -o ${TGT}'
-def configure(self):
- kdeconfig=self.find_program('kde4-config')
- prefix=self.cmd_and_log('%s --prefix'%kdeconfig).strip()
- fname='%s/share/apps/cmake/modules/KDELibsDependencies.cmake'%prefix
- try:os.stat(fname)
- except OSError:
- fname='%s/share/kde4/apps/cmake/modules/KDELibsDependencies.cmake'%prefix
- try:os.stat(fname)
- except OSError:self.fatal('could not open %s'%fname)
- try:
- txt=Utils.readf(fname)
- except(OSError,IOError):
- self.fatal('could not read %s'%fname)
- txt=txt.replace('\\\n','\n')
- fu=re.compile('#(.*)\n')
- txt=fu.sub('',txt)
- setregexp=re.compile('([sS][eE][tT]\s*\()\s*([^\s]+)\s+\"([^"]+)\"\)')
- found=setregexp.findall(txt)
- for(_,key,val)in found:
- self.env[key]=val
- self.env['LIB_KDECORE']=['kdecore']
- self.env['LIB_KDEUI']=['kdeui']
- self.env['LIB_KIO']=['kio']
- self.env['LIB_KHTML']=['khtml']
- self.env['LIB_KPARTS']=['kparts']
- self.env['LIBPATH_KDECORE']=[self.env['KDE4_LIB_INSTALL_DIR']]
- self.env['INCLUDES_KDECORE']=[self.env['KDE4_INCLUDE_INSTALL_DIR']]
- self.env.append_value('INCLUDES_KDECORE',[self.env['KDE4_INCLUDE_INSTALL_DIR']+os.sep+'KDE'])
- self.find_program('msgfmt',var='MSGFMT')
-
-feature('msgfmt')(apply_msgfmt)
\ No newline at end of file
diff --git a/waflib/Tools/lua.py b/waflib/Tools/lua.py
deleted file mode 100644
index 0d48d4f..0000000
--- a/waflib/Tools/lua.py
+++ /dev/null
@@ -1,19 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-from waflib.TaskGen import extension
-from waflib import Task,Utils
-def add_lua(self,node):
- tsk=self.create_task('luac',node,node.change_ext('.luac'))
- inst_to=getattr(self,'install_path',self.env.LUADIR and'${LUADIR}'or None)
- if inst_to:
- self.bld.install_files(inst_to,tsk.outputs)
- return tsk
-class luac(Task.Task):
- run_str='${LUAC} -s -o ${TGT} ${SRC}'
- color='PINK'
-def configure(conf):
- conf.find_program('luac',var='LUAC')
-
-extension('.lua')(add_lua)
\ No newline at end of file
diff --git a/waflib/Tools/msvc.py b/waflib/Tools/msvc.py
index 1ec9bb6..bea7230 100644
--- a/waflib/Tools/msvc.py
+++ b/waflib/Tools/msvc.py
@@ -3,16 +3,9 @@
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
import os,sys,re,tempfile
-try:
- import _winreg
-except:
- try:
- import winreg as _winreg
- except:
- _winreg=None
-from waflib import Utils,TaskGen,Runner,Configure,Task,Options
-from waflib.Logs import debug,info,warn,error
-from waflib.TaskGen import after_method,before_method,feature
+from waflib import Utils,Task,Logs,Options
+from waflib.Logs import debug,warn
+from waflib.TaskGen import after_method,feature
from waflib.Configure import conf
from waflib.Tools import ccroot,c,cxx,ar,winres
g_msvc_systemlibs='''
@@ -60,6 +53,7 @@ def setup_msvc(conf,versions):
except KeyError:continue
except KeyError:continue
conf.fatal('msvc: Impossible to find a valid architecture for building (in setup_msvc)')
+ at conf
def get_msvc_version(conf,compiler,version,target,vcvars):
debug('msvc: get_msvc_version: %r %r %r',compiler,version,target)
batfile=conf.bldnode.make_node('waf-print-msvc.bat')
@@ -73,14 +67,21 @@ echo LIB=%%LIB%%
"""%(vcvars,target))
sout=conf.cmd_and_log(['cmd','/E:on','/V:on','/C',batfile.abspath()])
lines=sout.splitlines()
- if not lines[0]:lines=lines[1:]
- for x in('Setting environment','Setting SDK environment','Intel(R) C++ Compiler','Intel Parallel Studio'):
- if lines[0].find(x)!=-1:
- break
+ if not lines[0]:
+ lines.pop(0)
+ if version=='11.0':
+ if lines[0].startswith('Error'):
+ conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_1)')
else:
- debug('msvc: get_msvc_version: %r %r %r -> not found',compiler,version,target)
- conf.fatal('msvc: Impossible to find a valid architecture for building (in get_msvc_version)')
- for line in lines[1:]:
+ for x in('Setting environment','Setting SDK environment','Intel(R) C++ Compiler','Intel Parallel Studio'):
+ if lines[0].find(x)>-1:
+ lines.pop(0)
+ break
+ else:
+ debug('msvc: get_msvc_version: %r %r %r -> not found',compiler,version,target)
+ conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_2)')
+ MSVC_PATH=MSVC_INCDIR=MSVC_LIBDIR=None
+ for line in lines:
if line.startswith('PATH='):
path=line[5:]
MSVC_PATH=path.split(';')
@@ -88,8 +89,9 @@ echo LIB=%%LIB%%
MSVC_INCDIR=[i for i in line[8:].split(';')if i]
elif line.startswith('LIB='):
MSVC_LIBDIR=[i for i in line[4:].split(';')if i]
- env={}
- env.update(os.environ)
+ if None in(MSVC_PATH,MSVC_INCDIR,MSVC_LIBDIR):
+ conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_3)')
+ env=dict(os.environ)
env.update(PATH=path)
compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler)
cxx=conf.find_program(compiler_name,path_list=MSVC_PATH)
@@ -108,27 +110,28 @@ echo LIB=%%LIB%%
finally:
conf.env[compiler_name]=''
return(MSVC_PATH,MSVC_INCDIR,MSVC_LIBDIR)
+ at conf
def gather_wsdk_versions(conf,versions):
version_pattern=re.compile('^v..?.?\...?.?')
try:
- all_versions=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Wow6432node\\Microsoft\\Microsoft SDKs\\Windows')
+ all_versions=Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Wow6432node\\Microsoft\\Microsoft SDKs\\Windows')
except WindowsError:
try:
- all_versions=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows')
+ all_versions=Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows')
except WindowsError:
return
index=0
while 1:
try:
- version=_winreg.EnumKey(all_versions,index)
+ version=Utils.winreg.EnumKey(all_versions,index)
except WindowsError:
break
index=index+1
if not version_pattern.match(version):
continue
try:
- msvc_version=_winreg.OpenKey(all_versions,version)
- path,type=_winreg.QueryValueEx(msvc_version,'InstallationFolder')
+ msvc_version=Utils.winreg.OpenKey(all_versions,version)
+ path,type=Utils.winreg.QueryValueEx(msvc_version,'InstallationFolder')
except WindowsError:
continue
if os.path.isfile(os.path.join(path,'bin','SetEnv.cmd')):
@@ -142,10 +145,10 @@ def gather_wsdk_versions(conf,versions):
def gather_wince_supported_platforms():
supported_wince_platforms=[]
try:
- ce_sdk=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Wow6432node\\Microsoft\\Windows CE Tools\\SDKs')
+ ce_sdk=Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Wow6432node\\Microsoft\\Windows CE Tools\\SDKs')
except WindowsError:
try:
- ce_sdk=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Microsoft\\Windows CE Tools\\SDKs')
+ ce_sdk=Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Microsoft\\Windows CE Tools\\SDKs')
except WindowsError:
ce_sdk=''
if not ce_sdk:
@@ -153,16 +156,16 @@ def gather_wince_supported_platforms():
ce_index=0
while 1:
try:
- sdk_device=_winreg.EnumKey(ce_sdk,ce_index)
+ sdk_device=Utils.winreg.EnumKey(ce_sdk,ce_index)
except WindowsError:
break
ce_index=ce_index+1
- sdk=_winreg.OpenKey(ce_sdk,sdk_device)
+ sdk=Utils.winreg.OpenKey(ce_sdk,sdk_device)
try:
- path,type=_winreg.QueryValueEx(sdk,'SDKRootDir')
+ path,type=Utils.winreg.QueryValueEx(sdk,'SDKRootDir')
except WindowsError:
try:
- path,type=_winreg.QueryValueEx(sdk,'SDKInformation')
+ path,type=Utils.winreg.QueryValueEx(sdk,'SDKInformation')
path,xml=os.path.split(path)
except WindowsError:
continue
@@ -183,17 +186,17 @@ def gather_msvc_detected_versions():
for vcver,vcvar in[('VCExpress','Exp'),('VisualStudio','')]:
try:
prefix='SOFTWARE\\Wow6432node\\Microsoft\\'+vcver
- all_versions=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,prefix)
+ all_versions=Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE,prefix)
except WindowsError:
try:
prefix='SOFTWARE\\Microsoft\\'+vcver
- all_versions=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,prefix)
+ all_versions=Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE,prefix)
except WindowsError:
continue
index=0
while 1:
try:
- version=_winreg.EnumKey(all_versions,index)
+ version=Utils.winreg.EnumKey(all_versions,index)
except WindowsError:
break
index=index+1
@@ -205,11 +208,9 @@ def gather_msvc_detected_versions():
detected_versions.append((versionnumber,version+vcvar,prefix+"\\"+version))
def fun(tup):
return tup[0]
- try:
- detected_versions.sort(key=fun)
- except:
- detected_versions.sort(lambda x,y:cmp(x[0],y[0]))
+ detected_versions.sort(key=fun)
return detected_versions
+ at conf
def gather_msvc_targets(conf,versions,version,vc_path):
targets=[]
if os.path.isfile(os.path.join(vc_path,'vcvarsall.bat')):
@@ -229,6 +230,7 @@ def gather_msvc_targets(conf,versions,version,vc_path):
except conf.errors.ConfigurationError:
pass
versions.append(('msvc '+version,targets))
+ at conf
def gather_wince_targets(conf,versions,version,vc_path,vsvars,supported_platforms):
for device,platforms in supported_platforms:
cetargets=[]
@@ -247,15 +249,16 @@ def gather_wince_targets(conf,versions,version,vc_path,vsvars,supported_platform
cetargets.append((platform,(platform,(bindirs,incdirs,libdirs))))
if cetargets:
versions.append((device+' '+version,cetargets))
+ at conf
def gather_msvc_versions(conf,versions):
vc_paths=[]
for(v,version,reg)in gather_msvc_detected_versions():
try:
try:
- msvc_version=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,reg+"\\Setup\\VC")
+ msvc_version=Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE,reg+"\\Setup\\VC")
except WindowsError:
- msvc_version=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,reg+"\\Setup\\Microsoft Visual C++")
- path,type=_winreg.QueryValueEx(msvc_version,'ProductDir')
+ msvc_version=Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE,reg+"\\Setup\\Microsoft Visual C++")
+ path,type=Utils.winreg.QueryValueEx(msvc_version,'ProductDir')
vc_paths.append((version,os.path.abspath(str(path))))
except WindowsError:
continue
@@ -268,19 +271,20 @@ def gather_msvc_versions(conf,versions):
for version,vc_path in vc_paths:
vs_path=os.path.dirname(vc_path)
conf.gather_msvc_targets(versions,version,vc_path)
+ at conf
def gather_icl_versions(conf,versions):
version_pattern=re.compile('^...?.?\....?.?')
try:
- all_versions=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Wow6432node\\Intel\\Compilers\\C++')
+ all_versions=Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Wow6432node\\Intel\\Compilers\\C++')
except WindowsError:
try:
- all_versions=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Intel\\Compilers\\C++')
+ all_versions=Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Intel\\Compilers\\C++')
except WindowsError:
return
index=0
while 1:
try:
- version=_winreg.EnumKey(all_versions,index)
+ version=Utils.winreg.EnumKey(all_versions,index)
except WindowsError:
break
index=index+1
@@ -291,9 +295,9 @@ def gather_icl_versions(conf,versions):
try:
if target=='intel64':targetDir='EM64T_NATIVE'
else:targetDir=target
- _winreg.OpenKey(all_versions,version+'\\'+targetDir)
- icl_version=_winreg.OpenKey(all_versions,version)
- path,type=_winreg.QueryValueEx(icl_version,'ProductDir')
+ Utils.winreg.OpenKey(all_versions,version+'\\'+targetDir)
+ icl_version=Utils.winreg.OpenKey(all_versions,version)
+ path,type=Utils.winreg.QueryValueEx(icl_version,'ProductDir')
if os.path.isfile(os.path.join(path,'bin','iclvars.bat')):
try:
targets.append((target,(arch,conf.get_msvc_version('intel',version,target,os.path.join(path,'bin','iclvars.bat')))))
@@ -303,8 +307,8 @@ def gather_icl_versions(conf,versions):
pass
for target,arch in all_icl_platforms:
try:
- icl_version=_winreg.OpenKey(all_versions,version+'\\'+target)
- path,type=_winreg.QueryValueEx(icl_version,'ProductDir')
+ icl_version=Utils.winreg.OpenKey(all_versions,version+'\\'+target)
+ path,type=Utils.winreg.QueryValueEx(icl_version,'ProductDir')
if os.path.isfile(os.path.join(path,'bin','iclvars.bat')):
try:
targets.append((target,(arch,conf.get_msvc_version('intel',version,target,os.path.join(path,'bin','iclvars.bat')))))
@@ -314,6 +318,7 @@ def gather_icl_versions(conf,versions):
continue
major=version[0:2]
versions.append(('intel '+major,targets))
+ at conf
def get_msvc_versions(conf):
if not conf.env['MSVC_INSTALLED_VERSIONS']:
lst=[]
@@ -322,14 +327,17 @@ def get_msvc_versions(conf):
conf.gather_msvc_versions(lst)
conf.env['MSVC_INSTALLED_VERSIONS']=lst
return conf.env['MSVC_INSTALLED_VERSIONS']
+ at conf
def print_all_msvc_detected(conf):
for version,targets in conf.env['MSVC_INSTALLED_VERSIONS']:
- info(version)
+ Logs.info(version)
for target,l in targets:
- info("\t"+target)
+ Logs.info("\t"+target)
+ at conf
def detect_msvc(conf):
versions=get_msvc_versions(conf)
return setup_msvc(conf,versions)
+ at conf
def find_lt_names_msvc(self,libname,is_static=False):
lt_names=['lib%s.la'%libname,'%s.la'%libname,]
for path in self.env['LIBPATH']:
@@ -357,6 +365,7 @@ def find_lt_names_msvc(self,libname,is_static=False):
else:
raise self.errors.WafError('invalid libtool object file: %s'%laf)
return(None,None,None)
+ at conf
def libname_msvc(self,libname,is_static=False):
lib=libname.lower()
lib=re.sub('\.lib$','',lib)
@@ -385,6 +394,7 @@ def libname_msvc(self,libname,is_static=False):
return re.sub('\.lib$','',libn)
self.fatal("The library %r could not be found"%libname)
return re.sub('\.lib$','',libname)
+ at conf
def check_lib_msvc(self,libname,is_static=False,uselib_store=None):
libn=self.libname_msvc(libname,is_static)
if not uselib_store:
@@ -393,6 +403,7 @@ def check_lib_msvc(self,libname,is_static=False,uselib_store=None):
self.env['STLIB_'+uselib_store]=[libn]
else:
self.env['LIB_'+uselib_store]=[libn]
+ at conf
def check_libs_msvc(self,libnames,is_static=False):
for libname in Utils.to_list(libnames):
self.check_lib_msvc(libname,is_static)
@@ -406,9 +417,11 @@ def configure(conf):
conf.cxx_add_flags()
conf.link_add_flags()
conf.visual_studio_add_flags()
+ at conf
def no_autodetect(conf):
conf.env.NO_MSVC_DETECT=1
configure(conf)
+ at conf
def autodetect(conf):
v=conf.env
if v.NO_MSVC_DETECT:
@@ -420,7 +433,7 @@ def autodetect(conf):
v['MSVC_COMPILER']=compiler
try:
v['MSVC_VERSION']=float(version)
- except:
+ except Exception:
v['MSVC_VERSION']=float(version[:-3])
def _get_prog_names(conf,compiler):
if compiler=='intel':
@@ -432,6 +445,7 @@ def _get_prog_names(conf,compiler):
linker_name='LINK'
lib_name='LIB'
return compiler_name,linker_name,lib_name
+ at conf
def find_msvc(conf):
if sys.platform=='cygwin':
conf.fatal('MSVC module does not work under cygwin Python!')
@@ -464,17 +478,19 @@ def find_msvc(conf):
if not stliblink:return
v['ARFLAGS']=['/NOLOGO']
if v.MSVC_MANIFEST:
- mt=conf.find_program('MT',path_list=path,var='MT')
+ conf.find_program('MT',path_list=path,var='MT')
v['MTFLAGS']=['/NOLOGO']
conf.load('winres')
if not conf.env['WINRC']:
warn('Resource compiler not found. Compiling resource file is disabled')
+ at conf
def visual_studio_add_flags(self):
v=self.env
- try:v.prepend_value('INCLUDES',self.environ['INCLUDE'].split(';'))
- except:pass
- try:v.prepend_value('LIBPATH',self.environ['LIB'].split(';'))
- except:pass
+ try:v.prepend_value('INCLUDES',[x for x in self.environ['INCLUDE'].split(';')if x])
+ except Exception:pass
+ try:v.prepend_value('LIBPATH',[x for x in self.environ['LIB'].split(';')if x])
+ except Exception:pass
+ at conf
def msvc_common_flags(conf):
v=conf.env
v['DEST_BINFMT']='pe'
@@ -502,7 +518,7 @@ def msvc_common_flags(conf):
v['CFLAGS_CRT_MULTITHREADED_DLL_DBG']=v['CXXFLAGS_CRT_MULTITHREADED_DLL_DBG']=['/MDd']
v['LIB_ST']='%s.lib'
v['LIBPATH_ST']='/LIBPATH:%s'
- v['STLIB_ST']='lib%s.lib'
+ v['STLIB_ST']='%s.lib'
v['STLIBPATH_ST']='/LIBPATH:%s'
v.append_value('LINKFLAGS',['/NOLOGO'])
if v['MSVC_MANIFEST']:
@@ -514,8 +530,10 @@ def msvc_common_flags(conf):
v['implib_PATTERN']='%s.lib'
v['IMPLIB_ST']='/IMPLIB:%s'
v['LINKFLAGS_cstlib']=[]
- v['cstlib_PATTERN']=v['cxxstlib_PATTERN']='lib%s.lib'
+ v['cstlib_PATTERN']=v['cxxstlib_PATTERN']='%s.lib'
v['cprogram_PATTERN']=v['cxxprogram_PATTERN']='%s.exe'
+ at after_method('apply_link')
+ at feature('c','cxx')
def apply_flags_msvc(self):
if self.env.CC_NAME!='msvc'or not getattr(self,'link_task',None):
return
@@ -536,6 +554,8 @@ def apply_flags_msvc(self):
except AttributeError:
pass
break
+ at feature('cprogram','cshlib','cxxprogram','cxxshlib')
+ at after_method('apply_link')
def apply_manifest(self):
if self.env.CC_NAME=='msvc'and self.env.MSVC_MANIFEST and getattr(self,'link_task',None):
out_node=self.link_task.outputs[0]
@@ -593,7 +613,7 @@ def exec_response_command(self,cmd,**kw):
if tmp:
try:
os.remove(tmp)
- except:
+ except OSError:
pass
return ret
def exec_command_msvc(self,*k,**kw):
@@ -609,7 +629,7 @@ def exec_command_msvc(self,*k,**kw):
carry=''
k=[lst]
if self.env['PATH']:
- env=dict(os.environ)
+ env=self.env.env or dict(os.environ)
env.update(PATH=';'.join(self.env['PATH']))
kw['env']=env
bld=self.generator.bld
@@ -629,26 +649,3 @@ for k in'c cxx cprogram cxxprogram cshlib cxxshlib cstlib cxxstlib'.split():
cls.exec_response_command=exec_response_command
cls.quote_response_command=quote_response_command
cls.exec_mf=exec_mf
-
-conf(get_msvc_version)
-conf(gather_wsdk_versions)
-conf(gather_msvc_targets)
-conf(gather_wince_targets)
-conf(gather_msvc_versions)
-conf(gather_icl_versions)
-conf(get_msvc_versions)
-conf(print_all_msvc_detected)
-conf(detect_msvc)
-conf(find_lt_names_msvc)
-conf(libname_msvc)
-conf(check_lib_msvc)
-conf(check_libs_msvc)
-conf(no_autodetect)
-conf(autodetect)
-conf(find_msvc)
-conf(visual_studio_add_flags)
-conf(msvc_common_flags)
-after_method('apply_link')(apply_flags_msvc)
-feature('c','cxx')(apply_flags_msvc)
-feature('cprogram','cshlib','cxxprogram','cxxshlib')(apply_manifest)
-after_method('apply_link')(apply_manifest)
\ No newline at end of file
diff --git a/waflib/Tools/nasm.py b/waflib/Tools/nasm.py
deleted file mode 100644
index 22717d3..0000000
--- a/waflib/Tools/nasm.py
+++ /dev/null
@@ -1,14 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import waflib.Tools.asm
-from waflib.TaskGen import feature
-def apply_nasm_vars(self):
- self.env.append_value('ASFLAGS',self.to_list(getattr(self,'nasm_flags',[])))
-def configure(conf):
- nasm=conf.find_program(['nasm','yasm'],var='AS')
- conf.env.AS_TGT_F=['-o']
- conf.env.ASLNK_TGT_F=['-o']
-
-feature('asm')(apply_nasm_vars)
\ No newline at end of file
diff --git a/waflib/Tools/perl.py b/waflib/Tools/perl.py
deleted file mode 100644
index 0f66333..0000000
--- a/waflib/Tools/perl.py
+++ /dev/null
@@ -1,81 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import os
-from waflib import Task,Options,Utils
-from waflib.Configure import conf
-from waflib.TaskGen import extension,feature,before_method
-def init_perlext(self):
- self.uselib=self.to_list(getattr(self,'uselib',[]))
- if not'PERLEXT'in self.uselib:self.uselib.append('PERLEXT')
- self.env['cshlib_PATTERN']=self.env['cxxshlib_PATTERN']=self.env['perlext_PATTERN']
-def xsubpp_file(self,node):
- outnode=node.change_ext('.c')
- self.create_task('xsubpp',node,outnode)
- self.source.append(outnode)
-class xsubpp(Task.Task):
- run_str='${PERL} ${XSUBPP} -noprototypes -typemap ${EXTUTILS_TYPEMAP} ${SRC} > ${TGT}'
- color='BLUE'
- ext_out=['.h']
-def check_perl_version(self,minver=None):
- res=True
- if minver:
- cver='.'.join(map(str,minver))
- else:
- cver=''
- self.start_msg('Checking for minimum perl version %s'%cver)
- perl=getattr(Options.options,'perlbinary',None)
- if not perl:
- perl=self.find_program('perl',var='PERL')
- if not perl:
- self.end_msg("Perl not found",color="YELLOW")
- return False
- self.env['PERL']=perl
- version=self.cmd_and_log([perl,"-e",'printf \"%vd\", $^V'])
- if not version:
- res=False
- version="Unknown"
- elif not minver is None:
- ver=tuple(map(int,version.split(".")))
- if ver<minver:
- res=False
- self.end_msg(version,color=res and"GREEN"or"YELLOW")
- return res
-def check_perl_module(self,module):
- cmd=[self.env['PERL'],'-e','use %s'%module]
- self.start_msg('perl module %s'%module)
- try:
- r=self.cmd_and_log(cmd)
- except:
- self.end_msg(False)
- return None
- self.end_msg(r or True)
- return r
-def check_perl_ext_devel(self):
- env=self.env
- perl=env.PERL
- if not perl:
- self.fatal('find perl first')
- def read_out(cmd):
- return Utils.to_list(self.cmd_and_log(perl+cmd))
- env['LINKFLAGS_PERLEXT']=read_out(" -MConfig -e'print $Config{lddlflags}'")
- env['INCLUDES_PERLEXT']=read_out(" -MConfig -e'print \"$Config{archlib}/CORE\"'")
- env['CFLAGS_PERLEXT']=read_out(" -MConfig -e'print \"$Config{ccflags} $Config{cccdlflags}\"'")
- env['XSUBPP']=read_out(" -MConfig -e'print \"$Config{privlib}/ExtUtils/xsubpp$Config{exe_ext}\"'")
- env['EXTUTILS_TYPEMAP']=read_out(" -MConfig -e'print \"$Config{privlib}/ExtUtils/typemap\"'")
- if not getattr(Options.options,'perlarchdir',None):
- env['ARCHDIR_PERL']=self.cmd_and_log(perl+" -MConfig -e'print $Config{sitearch}'")
- else:
- env['ARCHDIR_PERL']=getattr(Options.options,'perlarchdir')
- env['perlext_PATTERN']='%s.'+self.cmd_and_log(perl+" -MConfig -e'print $Config{dlext}'")
-def options(opt):
- opt.add_option('--with-perl-binary',type='string',dest='perlbinary',help='Specify alternate perl binary',default=None)
- opt.add_option('--with-perl-archdir',type='string',dest='perlarchdir',help='Specify directory where to install arch specific files',default=None)
-
-before_method('apply_incpaths','apply_link','propagate_uselib_vars')(init_perlext)
-feature('perlext')(init_perlext)
-extension('.xs')(xsubpp_file)
-conf(check_perl_version)
-conf(check_perl_module)
-conf(check_perl_ext_devel)
\ No newline at end of file
diff --git a/waflib/Tools/python.py b/waflib/Tools/python.py
index cdaff84..13bd64b 100644
--- a/waflib/Tools/python.py
+++ b/waflib/Tools/python.py
@@ -3,8 +3,7 @@
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
import os,sys
-from waflib import Utils,Options,Errors
-from waflib.Logs import debug,warn,info,error
+from waflib import Utils,Options,Errors,Logs
from waflib.TaskGen import extension,before_method,after_method,feature
from waflib.Configure import conf
FRAG='''
@@ -29,11 +28,12 @@ import sys, py_compile
py_compile.compile(sys.argv[1], sys.argv[2], sys.argv[3])
'''
DISTUTILS_IMP=['from distutils.sysconfig import get_config_var, get_python_lib']
+ at extension('.py')
def process_py(self,node):
try:
if not self.bld.is_install:
return
- except:
+ except AttributeError:
return
try:
if not self.install_path:
@@ -51,7 +51,7 @@ def install_pyfile(self,node,install_from=None):
tsk=self.bld.install_as(self.install_path+'/'+node.path_from(from_node),node,postpone=False)
path=tsk.get_install_path()
if self.bld.is_install<0:
- info("+ removing byte compiled python files")
+ Logs.info("+ removing byte compiled python files")
for x in'co':
try:
os.remove(path+x)
@@ -60,8 +60,8 @@ def install_pyfile(self,node,install_from=None):
if self.bld.is_install>0:
try:
st1=os.stat(path)
- except:
- error('The python file is missing, this should not happen')
+ except OSError:
+ Logs.error('The python file is missing, this should not happen')
for x in['c','o']:
do_inst=self.env['PY'+x.upper()]
try:
@@ -75,30 +75,39 @@ def install_pyfile(self,node,install_from=None):
lst=(x=='o')and[self.env['PYFLAGS_OPT']]or[]
(a,b,c)=(path,path+x,tsk.get_install_path(destdir=False)+x)
argv=self.env['PYTHON']+lst+['-c',INST,a,b,c]
- info('+ byte compiling %r'%(path+x))
+ Logs.info('+ byte compiling %r'%(path+x))
env=self.env.env or None
ret=Utils.subprocess.Popen(argv,env=env).wait()
if ret:
raise Errors.WafError('py%s compilation failed %r'%(x,path))
+ at feature('py')
def feature_py(self):
pass
+ at feature('pyext')
+ at before_method('propagate_uselib_vars','apply_link')
+ at after_method('apply_bundle')
def init_pyext(self):
+ self.uselib=self.to_list(getattr(self,'uselib',[]))
+ if not'PYEXT'in self.uselib:
+ self.uselib.append('PYEXT')
+ self.env['cshlib_PATTERN']=self.env['cxxshlib_PATTERN']=self.env['macbundle_PATTERN']=self.env['pyext_PATTERN']
try:
if not self.install_path:
return
except AttributeError:
self.install_path='${PYTHONARCHDIR}'
- self.uselib=self.to_list(getattr(self,'uselib',[]))
- if not'PYEXT'in self.uselib:
- self.uselib.append('PYEXT')
- self.env['cshlib_PATTERN']=self.env['cxxshlib_PATTERN']=self.env['macbundle_PATTERN']=self.env['pyext_PATTERN']
+ at feature('pyext')
+ at before_method('apply_link','apply_bundle')
def set_bundle(self):
if Utils.unversioned_sys_platform()=='darwin':
self.mac_bundle=True
+ at before_method('propagate_uselib_vars')
+ at feature('pyembed')
def init_pyembed(self):
self.uselib=self.to_list(getattr(self,'uselib',[]))
if not'PYEMBED'in self.uselib:
self.uselib.append('PYEMBED')
+ at conf
def get_python_variables(self,variables,imports=None):
if not imports:
try:
@@ -118,6 +127,7 @@ def get_python_variables(self,variables,imports=None):
out=self.cmd_and_log(self.env.PYTHON+['-c','\n'.join(program)],env=os_env)
except Errors.WafError:
self.fatal('The distutils module is unusable: install "python-devel"?')
+ self.to_log(out)
return_values=[]
for s in out.split('\n'):
s=s.strip()
@@ -125,21 +135,22 @@ def get_python_variables(self,variables,imports=None):
continue
if s=='None':
return_values.append(None)
- elif s[0]=="'"and s[-1]=="'":
- return_values.append(s[1:-1])
+ elif(s[0]=="'"and s[-1]=="'")or(s[0]=='"'and s[-1]=='"'):
+ return_values.append(eval(s))
elif s[0].isdigit():
return_values.append(int(s))
else:break
return return_values
+ at conf
def check_python_headers(conf):
- if not conf.env['CC_NAME']and not conf.env['CXX_NAME']:
+ env=conf.env
+ if not env['CC_NAME']and not env['CXX_NAME']:
conf.fatal('load a compiler first (gcc, g++, ..)')
- if not conf.env['PYTHON_VERSION']:
+ if not env['PYTHON_VERSION']:
conf.check_python_version()
- env=conf.env
pybin=conf.env.PYTHON
if not pybin:
- conf.fatal('could not find the python executable')
+ conf.fatal('Could not find the python executable')
v='prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS'.split()
try:
lst=conf.get_python_variables(["get_config_var('%s') or ''"%x for x in v])
@@ -185,7 +196,7 @@ def check_python_headers(conf):
env['LIBPATH_PYEXT']=env['LIBPATH_PYEMBED']
env['LIB_PYEXT']=env['LIB_PYEMBED']
num='.'.join(env['PYTHON_VERSION'].split('.')[:2])
- conf.find_program(['python%s-config'%num,'python-config-%s'%num,'python%sm-config'%num],var='PYTHON_CONFIG',mandatory=False)
+ conf.find_program([''.join(pybin)+'-config','python%s-config'%num,'python-config-%s'%num,'python%sm-config'%num],var='PYTHON_CONFIG',mandatory=False)
includes=[]
if conf.env.PYTHON_CONFIG:
for incstr in conf.cmd_and_log([conf.env.PYTHON_CONFIG,'--includes']).strip().split():
@@ -214,17 +225,21 @@ def check_python_headers(conf):
env.append_value('CXXFLAGS_PYEXT',dist_compiler.compile_options)
env.append_value('LINKFLAGS_PYEXT',dist_compiler.ldflags_shared)
try:
- conf.check(header_name='Python.h',define_name='HAVE_PYTHON_H',uselib='PYEMBED',fragment=FRAG,errmsg='Could not find the python development headers')
+ conf.check(header_name='Python.h',define_name='HAVE_PYTHON_H',uselib='PYEMBED',fragment=FRAG,errmsg=':-(')
except conf.errors.ConfigurationError:
- conf.check_cfg(path=conf.env.PYTHON_CONFIG,package='',uselib_store='PYEMBED',args=['--cflags','--libs'])
- conf.check(header_name='Python.h',define_name='HAVE_PYTHON_H',msg='Getting the python flags from python-config',uselib='PYEMBED',fragment=FRAG,errmsg='Could not find the python development headers elsewhere')
+ xx=conf.env.CXX_NAME and'cxx'or'c'
+ conf.check_cfg(msg='Asking python-config for the flags (pyembed)',path=conf.env.PYTHON_CONFIG,package='',uselib_store='PYEMBED',args=['--cflags','--libs','--ldflags'])
+ conf.check(header_name='Python.h',define_name='HAVE_PYTHON_H',msg='Getting pyembed flags from python-config',fragment=FRAG,errmsg='Could not build a python embedded interpreter',features='%s %sprogram pyembed'%(xx,xx))
+ conf.check_cfg(msg='Asking python-config for the flags (pyext)',path=conf.env.PYTHON_CONFIG,package='',uselib_store='PYEXT',args=['--cflags','--libs','--ldflags'])
+ conf.check(header_name='Python.h',define_name='HAVE_PYTHON_H',msg='Getting pyext flags from python-config',features='%s %sshlib pyext'%(xx,xx),fragment=FRAG,errmsg='Could not build python extensions')
+ at conf
def check_python_version(conf,minver=None):
assert minver is None or isinstance(minver,tuple)
pybin=conf.env['PYTHON']
if not pybin:
conf.fatal('could not find the python executable')
cmd=pybin+['-c','import sys\nfor x in sys.version_info: print(str(x))']
- debug('python: Running python command %r'%cmd)
+ Logs.debug('python: Running python command %r'%cmd)
lines=conf.cmd_and_log(cmd).split()
assert len(lines)==5,"found %i lines, expected 5: %r"%(len(lines),lines)
pyver_tuple=(int(lines[0]),int(lines[1]),int(lines[2]),lines[3],int(lines[4]))
@@ -272,6 +287,7 @@ if version is not None:
else:
print('unknown version')
'''
+ at conf
def check_python_module(conf,module_name,condition=''):
msg='Python module %s'%module_name
if condition:
@@ -306,10 +322,10 @@ def configure(conf):
try:
conf.find_program('python',var='PYTHON')
except conf.errors.ConfigurationError:
- warn("could not find a python executable, setting to sys.executable '%s'"%sys.executable)
+ Logs.warn("could not find a python executable, setting to sys.executable '%s'"%sys.executable)
conf.env.PYTHON=sys.executable
if conf.env.PYTHON!=sys.executable:
- warn("python executable '%s' different from sys.executable '%s'"%(conf.env.PYTHON,sys.executable))
+ Logs.warn("python executable %r differs from system %r"%(conf.env.PYTHON,sys.executable))
conf.env.PYTHON=conf.cmd_to_list(conf.env.PYTHON)
v=conf.env
v['PYCMD']='"import sys, py_compile;py_compile.compile(sys.argv[1], sys.argv[2])"'
@@ -320,17 +336,3 @@ def configure(conf):
def options(opt):
opt.add_option('--nopyc',action='store_false',default=1,help='Do not install bytecode compiled .pyc files (configuration) [Default:install]',dest='pyc')
opt.add_option('--nopyo',action='store_false',default=1,help='Do not install optimised compiled .pyo files (configuration) [Default:install]',dest='pyo')
-
-extension('.py')(process_py)
-feature('py')(feature_py)
-feature('pyext')(init_pyext)
-before_method('propagate_uselib_vars','apply_link')(init_pyext)
-after_method('apply_bundle')(init_pyext)
-feature('pyext')(set_bundle)
-before_method('apply_link','apply_bundle')(set_bundle)
-before_method('propagate_uselib_vars')(init_pyembed)
-feature('pyembed')(init_pyembed)
-conf(get_python_variables)
-conf(check_python_headers)
-conf(check_python_version)
-conf(check_python_module)
\ No newline at end of file
diff --git a/waflib/Tools/qt4.py b/waflib/Tools/qt4.py
deleted file mode 100644
index 1ee9724..0000000
--- a/waflib/Tools/qt4.py
+++ /dev/null
@@ -1,434 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import sys
-if sys.hexversion < 0x020400f0: from sets import Set as set
-try:
- from xml.sax import make_parser
- from xml.sax.handler import ContentHandler
-except ImportError:
- has_xml=False
- ContentHandler=object
-else:
- has_xml=True
-import os,sys
-from waflib.Tools import c_preproc,cxx
-from waflib import Task,Utils,Options,Errors
-from waflib.TaskGen import feature,after_method,extension
-from waflib.Configure import conf
-from waflib import Logs
-MOC_H=['.h','.hpp','.hxx','.hh']
-EXT_RCC=['.qrc']
-EXT_UI=['.ui']
-EXT_QT4=['.cpp','.cc','.cxx','.C']
-QT4_LIBS="QtCore QtGui QtUiTools QtNetwork QtOpenGL QtSql QtSvg QtTest QtXml QtXmlPatterns QtWebKit Qt3Support QtHelp QtScript QtDeclarative"
-class qxx(cxx.cxx):
- def __init__(self,*k,**kw):
- Task.Task.__init__(self,*k,**kw)
- self.moc_done=0
- def scan(self):
- (nodes,names)=c_preproc.scan(self)
- for x in nodes:
- if x.name.endswith('.moc'):
- nodes.remove(x)
- names.append(x.path_from(self.inputs[0].parent.get_bld()))
- return(nodes,names)
- def runnable_status(self):
- if self.moc_done:
- return Task.Task.runnable_status(self)
- else:
- for t in self.run_after:
- if not t.hasrun:
- return Task.ASK_LATER
- self.add_moc_tasks()
- return Task.Task.runnable_status(self)
- def add_moc_tasks(self):
- node=self.inputs[0]
- bld=self.generator.bld
- try:
- self.signature()
- except KeyError:
- pass
- else:
- delattr(self,'cache_sig')
- moctasks=[]
- mocfiles=[]
- try:
- tmp_lst=bld.raw_deps[self.uid()]
- bld.raw_deps[self.uid()]=[]
- except KeyError:
- tmp_lst=[]
- for d in tmp_lst:
- if not d.endswith('.moc'):
- continue
- if d in mocfiles:
- Logs.error("paranoia owns")
- continue
- mocfiles.append(d)
- h_node=None
- try:ext=Options.options.qt_header_ext.split()
- except AttributeError:pass
- if not ext:ext=MOC_H
- base2=d[:-4]
- for x in[node.parent]+self.generator.includes_nodes:
- for e in ext:
- h_node=x.find_node(base2+e)
- if h_node:
- break
- if h_node:
- m_node=h_node.change_ext('.moc')
- break
- else:
- for k in EXT_QT4:
- if base2.endswith(k):
- for x in[node.parent]+self.generator.includes_nodes:
- h_node=x.find_node(base2)
- if h_node:
- break
- if h_node:
- m_node=h_node.change_ext(k+'.moc')
- break
- if not h_node:
- raise Errors.WafError('no header found for %r which is a moc file'%d)
- bld.node_deps[(self.inputs[0].parent.abspath(),m_node.name)]=h_node
- task=Task.classes['moc'](env=self.env,generator=self.generator)
- task.set_inputs(h_node)
- task.set_outputs(m_node)
- gen=bld.producer
- gen.outstanding.insert(0,task)
- gen.total+=1
- moctasks.append(task)
- tmp_lst=bld.raw_deps[self.uid()]=mocfiles
- lst=bld.node_deps.get(self.uid(),())
- for d in lst:
- name=d.name
- if name.endswith('.moc'):
- task=Task.classes['moc'](env=self.env,generator=self.generator)
- task.set_inputs(bld.node_deps[(self.inputs[0].parent.abspath(),name)])
- task.set_outputs(d)
- gen=bld.producer
- gen.outstanding.insert(0,task)
- gen.total+=1
- moctasks.append(task)
- self.run_after.update(set(moctasks))
- self.moc_done=1
- run=Task.classes['cxx'].__dict__['run']
-class trans_update(Task.Task):
- run_str='${QT_LUPDATE} ${SRC} -ts ${TGT}'
- color='BLUE'
-Task.update_outputs(trans_update)
-class XMLHandler(ContentHandler):
- def __init__(self):
- self.buf=[]
- self.files=[]
- def startElement(self,name,attrs):
- if name=='file':
- self.buf=[]
- def endElement(self,name):
- if name=='file':
- self.files.append(str(''.join(self.buf)))
- def characters(self,cars):
- self.buf.append(cars)
-def create_rcc_task(self,node):
- rcnode=node.change_ext('_rc.cpp')
- rcctask=self.create_task('rcc',node,rcnode)
- cpptask=self.create_task('cxx',rcnode,rcnode.change_ext('.o'))
- try:
- self.compiled_tasks.append(cpptask)
- except AttributeError:
- self.compiled_tasks=[cpptask]
- return cpptask
-def create_uic_task(self,node):
- uictask=self.create_task('ui4',node)
- uictask.outputs=[self.path.find_or_declare(self.env['ui_PATTERN']%node.name[:-3])]
-def add_lang(self,node):
- self.lang=self.to_list(getattr(self,'lang',[]))+[node]
-def apply_qt4(self):
- if getattr(self,'lang',None):
- qmtasks=[]
- for x in self.to_list(self.lang):
- if isinstance(x,str):
- x=self.path.find_resource(x+'.ts')
- qmtasks.append(self.create_task('ts2qm',x,x.change_ext('.qm')))
- if getattr(self,'update',None)and Options.options.trans_qt4:
- cxxnodes=[a.inputs[0]for a in self.compiled_tasks]+[a.inputs[0]for a in self.tasks if getattr(a,'inputs',None)and a.inputs[0].name.endswith('.ui')]
- for x in qmtasks:
- self.create_task('trans_update',cxxnodes,x.inputs)
- if getattr(self,'langname',None):
- qmnodes=[x.outputs[0]for x in qmtasks]
- rcnode=self.langname
- if isinstance(rcnode,str):
- rcnode=self.path.find_or_declare(rcnode+'.qrc')
- t=self.create_task('qm2rcc',qmnodes,rcnode)
- k=create_rcc_task(self,t.outputs[0])
- self.link_task.inputs.append(k.outputs[0])
- lst=[]
- for flag in self.to_list(self.env['CXXFLAGS']):
- if len(flag)<2:continue
- f=flag[0:2]
- if f in['-D','-I','/D','/I']:
- if(f[0]=='/'):
- lst.append('-'+flag[1:])
- else:
- lst.append(flag)
- self.env['MOC_FLAGS']=lst
-def cxx_hook(self,node):
- return self.create_compiled_task('qxx',node)
-class rcc(Task.Task):
- color='BLUE'
- run_str='${QT_RCC} -name ${SRC[0].name} ${SRC[0].abspath()} ${RCC_ST} -o ${TGT}'
- ext_out=['.h']
- def scan(self):
- node=self.inputs[0]
- if not has_xml:
- Logs.error('no xml support was found, the rcc dependencies will be incomplete!')
- return([],[])
- parser=make_parser()
- curHandler=XMLHandler()
- parser.setContentHandler(curHandler)
- fi=open(self.inputs[0].abspath())
- parser.parse(fi)
- fi.close()
- nodes=[]
- names=[]
- root=self.inputs[0].parent
- for x in curHandler.files:
- nd=root.find_resource(x)
- if nd:nodes.append(nd)
- else:names.append(x)
- return(nodes,names)
-class moc(Task.Task):
- color='BLUE'
- run_str='${QT_MOC} ${MOC_FLAGS} ${MOCCPPPATH_ST:INCPATHS} ${MOCDEFINES_ST:DEFINES} ${SRC} ${MOC_ST} ${TGT}'
-class ui4(Task.Task):
- color='BLUE'
- run_str='${QT_UIC} ${SRC} -o ${TGT}'
- ext_out=['.h']
-class ts2qm(Task.Task):
- color='BLUE'
- run_str='${QT_LRELEASE} ${QT_LRELEASE_FLAGS} ${SRC} -qm ${TGT}'
-class qm2rcc(Task.Task):
- color='BLUE'
- after='ts2qm'
- def run(self):
- txt='\n'.join(['<file>%s</file>'%k.path_from(self.outputs[0].parent)for k in self.inputs])
- code='<!DOCTYPE RCC><RCC version="1.0">\n<qresource>\n%s\n</qresource>\n</RCC>'%txt
- self.outputs[0].write(code)
-def configure(self):
- self.find_qt4_binaries()
- self.set_qt4_libs_to_check()
- self.find_qt4_libraries()
- self.add_qt4_rpath()
- self.simplify_qt4_libs()
-def find_qt4_binaries(self):
- env=self.env
- opt=Options.options
- qtdir=getattr(opt,'qtdir','')
- qtbin=getattr(opt,'qtbin','')
- paths=[]
- if qtdir:
- qtbin=os.path.join(qtdir,'bin')
- if not qtdir:
- qtdir=self.environ.get('QT4_ROOT','')
- qtbin=os.path.join(qtdir,'bin')
- if qtbin:
- paths=[qtbin]
- if not qtdir:
- paths=os.environ.get('PATH','').split(os.pathsep)
- paths.append('/usr/share/qt4/bin/')
- try:
- lst=Utils.listdir('/usr/local/Trolltech/')
- except OSError:
- pass
- else:
- if lst:
- lst.sort()
- lst.reverse()
- qtdir='/usr/local/Trolltech/%s/'%lst[0]
- qtbin=os.path.join(qtdir,'bin')
- paths.append(qtbin)
- cand=None
- prev_ver=['4','0','0']
- for qmk in['qmake-qt4','qmake4','qmake']:
- try:
- qmake=self.find_program(qmk,path_list=paths)
- except self.errors.ConfigurationError:
- pass
- else:
- try:
- version=self.cmd_and_log([qmake,'-query','QT_VERSION']).strip()
- except self.errors.ConfigurationError:
- pass
- else:
- if version:
- new_ver=version.split('.')
- if new_ver>prev_ver:
- cand=qmake
- prev_ver=new_ver
- if cand:
- self.env.QMAKE=cand
- else:
- self.fatal('Could not find qmake for qt4')
- qtbin=self.cmd_and_log([self.env.QMAKE,'-query','QT_INSTALL_BINS']).strip()+os.sep
- def find_bin(lst,var):
- for f in lst:
- try:
- ret=self.find_program(f,path_list=paths)
- except self.errors.ConfigurationError:
- pass
- else:
- env[var]=ret
- break
- find_bin(['uic-qt3','uic3'],'QT_UIC3')
- find_bin(['uic-qt4','uic'],'QT_UIC')
- if not env['QT_UIC']:
- self.fatal('cannot find the uic compiler for qt4')
- try:
- uicver=self.cmd_and_log(env['QT_UIC']+" -version 2>&1").strip()
- except self.errors.ConfigurationError:
- self.fatal('this uic compiler is for qt3, add uic for qt4 to your path')
- uicver=uicver.replace('Qt User Interface Compiler ','').replace('User Interface Compiler for Qt','')
- self.msg('Checking for uic version','%s'%uicver)
- if uicver.find(' 3.')!=-1:
- self.fatal('this uic compiler is for qt3, add uic for qt4 to your path')
- find_bin(['moc-qt4','moc'],'QT_MOC')
- find_bin(['rcc'],'QT_RCC')
- find_bin(['lrelease-qt4','lrelease'],'QT_LRELEASE')
- find_bin(['lupdate-qt4','lupdate'],'QT_LUPDATE')
- env['UIC3_ST']='%s -o %s'
- env['UIC_ST']='%s -o %s'
- env['MOC_ST']='-o'
- env['ui_PATTERN']='ui_%s.h'
- env['QT_LRELEASE_FLAGS']=['-silent']
- env.MOCCPPPATH_ST='-I%s'
- env.MOCDEFINES_ST='-D%s'
-def find_qt4_libraries(self):
- qtlibs=getattr(Options.options,'qtlibs','')
- if not qtlibs:
- try:
- qtlibs=self.cmd_and_log([self.env.QMAKE,'-query','QT_INSTALL_LIBS']).strip()
- except Errors.WafError:
- qtdir=self.cmd_and_log([self.env.QMAKE,'-query','QT_INSTALL_PREFIX']).strip()+os.sep
- qtlibs=os.path.join(qtdir,'lib')
- self.msg('Found the Qt4 libraries in',qtlibs)
- qtincludes=self.cmd_and_log([self.env.QMAKE,'-query','QT_INSTALL_HEADERS']).strip()
- env=self.env
- if not'PKG_CONFIG_PATH'in os.environ:
- os.environ['PKG_CONFIG_PATH']='%s:%s/pkgconfig:/usr/lib/qt4/lib/pkgconfig:/opt/qt4/lib/pkgconfig:/usr/lib/qt4/lib:/opt/qt4/lib'%(qtlibs,qtlibs)
- try:
- self.check_cfg(atleast_pkgconfig_version='0.1')
- except self.errors.ConfigurationError:
- for i in self.qt4_vars:
- uselib=i.upper()
- if Utils.unversioned_sys_platform()=="darwin":
- frameworkName=i+".framework"
- qtDynamicLib=os.path.join(qtlibs,frameworkName,i)
- if os.path.exists(qtDynamicLib):
- env.append_unique('FRAMEWORK_'+uselib,i)
- self.msg('Checking for %s'%i,qtDynamicLib,'GREEN')
- else:
- self.msg('Checking for %s'%i,False,'YELLOW')
- env.append_unique('INCLUDES_'+uselib,os.path.join(qtlibs,frameworkName,'Headers'))
- elif sys.platform!="win32":
- qtDynamicLib=os.path.join(qtlibs,"lib"+i+".so")
- qtStaticLib=os.path.join(qtlibs,"lib"+i+".a")
- if os.path.exists(qtDynamicLib):
- env.append_unique('LIB_'+uselib,i)
- self.msg('Checking for %s'%i,qtDynamicLib,'GREEN')
- elif os.path.exists(qtStaticLib):
- env.append_unique('LIB_'+uselib,i)
- self.msg('Checking for %s'%i,qtStaticLib,'GREEN')
- else:
- self.msg('Checking for %s'%i,False,'YELLOW')
- env.append_unique('LIBPATH_'+uselib,qtlibs)
- env.append_unique('INCLUDES_'+uselib,qtincludes)
- env.append_unique('INCLUDES_'+uselib,os.path.join(qtincludes,i))
- else:
- for k in("lib%s.a","lib%s4.a","%s.lib","%s4.lib"):
- lib=os.path.join(qtlibs,k%i)
- if os.path.exists(lib):
- env.append_unique('LIB_'+uselib,i+k[k.find("%s")+2:k.find('.')])
- self.msg('Checking for %s'%i,lib,'GREEN')
- break
- else:
- self.msg('Checking for %s'%i,False,'YELLOW')
- env.append_unique('LIBPATH_'+uselib,qtlibs)
- env.append_unique('INCLUDES_'+uselib,qtincludes)
- env.append_unique('INCLUDES_'+uselib,os.path.join(qtincludes,i))
- uselib=i.upper()+"_debug"
- for k in("lib%sd.a","lib%sd4.a","%sd.lib","%sd4.lib"):
- lib=os.path.join(qtlibs,k%i)
- if os.path.exists(lib):
- env.append_unique('LIB_'+uselib,i+k[k.find("%s")+2:k.find('.')])
- self.msg('Checking for %s'%i,lib,'GREEN')
- break
- else:
- self.msg('Checking for %s'%i,False,'YELLOW')
- env.append_unique('LIBPATH_'+uselib,qtlibs)
- env.append_unique('INCLUDES_'+uselib,qtincludes)
- env.append_unique('INCLUDES_'+uselib,os.path.join(qtincludes,i))
- else:
- for i in self.qt4_vars_debug+self.qt4_vars:
- self.check_cfg(package=i,args='--cflags --libs',mandatory=False)
-def simplify_qt4_libs(self):
- env=self.env
- def process_lib(vars_,coreval):
- for d in vars_:
- var=d.upper()
- if var=='QTCORE':
- continue
- value=env['LIBPATH_'+var]
- if value:
- core=env[coreval]
- accu=[]
- for lib in value:
- if lib in core:
- continue
- accu.append(lib)
- env['LIBPATH_'+var]=accu
- process_lib(self.qt4_vars,'LIBPATH_QTCORE')
- process_lib(self.qt4_vars_debug,'LIBPATH_QTCORE_DEBUG')
-def add_qt4_rpath(self):
- env=self.env
- if Options.options.want_rpath:
- def process_rpath(vars_,coreval):
- for d in vars_:
- var=d.upper()
- value=env['LIBPATH_'+var]
- if value:
- core=env[coreval]
- accu=[]
- for lib in value:
- if var!='QTCORE':
- if lib in core:
- continue
- accu.append('-Wl,--rpath='+lib)
- env['RPATH_'+var]=accu
- process_rpath(self.qt4_vars,'LIBPATH_QTCORE')
- process_rpath(self.qt4_vars_debug,'LIBPATH_QTCORE_DEBUG')
-def set_qt4_libs_to_check(self):
- if not hasattr(self,'qt4_vars'):
- self.qt4_vars=QT4_LIBS
- self.qt4_vars=Utils.to_list(self.qt4_vars)
- if not hasattr(self,'qt4_vars_debug'):
- self.qt4_vars_debug=[a+'_debug'for a in self.qt4_vars]
- self.qt4_vars_debug=Utils.to_list(self.qt4_vars_debug)
-def options(opt):
- opt.add_option('--want-rpath',action='store_true',default=False,dest='want_rpath',help='enable the rpath for qt libraries')
- opt.add_option('--header-ext',type='string',default='',help='header extension for moc files',dest='qt_header_ext')
- for i in'qtdir qtbin qtlibs'.split():
- opt.add_option('--'+i,type='string',default='',dest=i)
- opt.add_option('--translate',action="store_true",help="collect translation strings",dest="trans_qt4",default=False)
-
-extension(*EXT_RCC)(create_rcc_task)
-extension(*EXT_UI)(create_uic_task)
-extension('.ts')(add_lang)
-feature('qt4')(apply_qt4)
-after_method('apply_link')(apply_qt4)
-extension(*EXT_QT4)(cxx_hook)
-conf(find_qt4_binaries)
-conf(find_qt4_libraries)
-conf(simplify_qt4_libs)
-conf(add_qt4_rpath)
-conf(set_qt4_libs_to_check)
\ No newline at end of file
diff --git a/waflib/Tools/ruby.py b/waflib/Tools/ruby.py
deleted file mode 100644
index df21a31..0000000
--- a/waflib/Tools/ruby.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import os
-from waflib import Task,Options,Utils
-from waflib.TaskGen import before_method,feature,after_method,Task,extension
-from waflib.Configure import conf
-def init_rubyext(self):
- self.install_path='${ARCHDIR_RUBY}'
- self.uselib=self.to_list(getattr(self,'uselib',''))
- if not'RUBY'in self.uselib:
- self.uselib.append('RUBY')
- if not'RUBYEXT'in self.uselib:
- self.uselib.append('RUBYEXT')
-def apply_ruby_so_name(self):
- self.env['cshlib_PATTERN']=self.env['cxxshlib_PATTERN']=self.env['rubyext_PATTERN']
-def check_ruby_version(self,minver=()):
- if Options.options.rubybinary:
- self.env.RUBY=Options.options.rubybinary
- else:
- self.find_program('ruby',var='RUBY')
- ruby=self.env.RUBY
- try:
- version=self.cmd_and_log([ruby,'-e','puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip()
- except:
- self.fatal('could not determine ruby version')
- self.env.RUBY_VERSION=version
- try:
- ver=tuple(map(int,version.split(".")))
- except:
- self.fatal('unsupported ruby version %r'%version)
- cver=''
- if minver:
- if ver<minver:
- self.fatal('ruby is too old %r'%ver)
- cver='.'.join([str(x)for x in minver])
- else:
- cver=ver
- self.msg('Checking for ruby version %s'%str(minver or''),cver)
-def check_ruby_ext_devel(self):
- if not self.env.RUBY:
- self.fatal('ruby detection is required first')
- if not self.env.CC_NAME and not self.env.CXX_NAME:
- self.fatal('load a c/c++ compiler first')
- version=tuple(map(int,self.env.RUBY_VERSION.split(".")))
- def read_out(cmd):
- return Utils.to_list(self.cmd_and_log([self.env.RUBY,'-rrbconfig','-e',cmd]))
- def read_config(key):
- return read_out('puts Config::CONFIG[%r]'%key)
- ruby=self.env['RUBY']
- archdir=read_config('archdir')
- cpppath=archdir
- if version>=(1,9,0):
- ruby_hdrdir=read_config('rubyhdrdir')
- cpppath+=ruby_hdrdir
- cpppath+=[os.path.join(ruby_hdrdir[0],read_config('arch')[0])]
- self.check(header_name='ruby.h',includes=cpppath,errmsg='could not find ruby header file')
- self.env.LIBPATH_RUBYEXT=read_config('libdir')
- self.env.LIBPATH_RUBYEXT+=archdir
- self.env.INCLUDES_RUBYEXT=cpppath
- self.env.CFLAGS_RUBYEXT=read_config('CCDLFLAGS')
- self.env.rubyext_PATTERN='%s.'+read_config('DLEXT')[0]
- flags=read_config('LDSHARED')
- while flags and flags[0][0]!='-':
- flags=flags[1:]
- if len(flags)>1 and flags[1]=="ppc":
- flags=flags[2:]
- self.env.LINKFLAGS_RUBYEXT=flags
- self.env.LINKFLAGS_RUBYEXT+=read_config('LIBS')
- self.env.LINKFLAGS_RUBYEXT+=read_config('LIBRUBYARG_SHARED')
- if Options.options.rubyarchdir:
- self.env.ARCHDIR_RUBY=Options.options.rubyarchdir
- else:
- self.env.ARCHDIR_RUBY=read_config('sitearchdir')[0]
- if Options.options.rubylibdir:
- self.env.LIBDIR_RUBY=Options.options.rubylibdir
- else:
- self.env.LIBDIR_RUBY=read_config('sitelibdir')[0]
-def check_ruby_module(self,module_name):
- self.start_msg('Ruby module %s'%module_name)
- try:
- self.cmd_and_log([self.env['RUBY'],'-e','require \'%s\';puts 1'%module_name])
- except:
- self.end_msg(False)
- self.fatal('Could not find the ruby module %r'%module_name)
- self.end_msg(True)
-def process(self,node):
- tsk=self.create_task('run_ruby',node)
-class run_ruby(Task.Task):
- run_str='${RUBY} ${RBFLAGS} -I ${SRC[0].parent.abspath()} ${SRC}'
-def options(opt):
- opt.add_option('--with-ruby-archdir',type='string',dest='rubyarchdir',help='Specify directory where to install arch specific files')
- opt.add_option('--with-ruby-libdir',type='string',dest='rubylibdir',help='Specify alternate ruby library path')
- opt.add_option('--with-ruby-binary',type='string',dest='rubybinary',help='Specify alternate ruby binary')
-
-feature('rubyext')(init_rubyext)
-before_method('apply_incpaths','apply_lib_vars','apply_bundle','apply_link')(init_rubyext)
-feature('rubyext')(apply_ruby_so_name)
-before_method('apply_link','propagate_uselib')(apply_ruby_so_name)
-conf(check_ruby_version)
-conf(check_ruby_ext_devel)
-conf(check_ruby_module)
-extension('.rb')(process)
\ No newline at end of file
diff --git a/waflib/Tools/suncc.py b/waflib/Tools/suncc.py
index fcc61d1..edd24cd 100644
--- a/waflib/Tools/suncc.py
+++ b/waflib/Tools/suncc.py
@@ -6,6 +6,7 @@ import os
from waflib import Utils
from waflib.Tools import ccroot,ar
from waflib.Configure import conf
+ at conf
def find_scc(conf):
v=conf.env
cc=None
@@ -16,10 +17,11 @@ def find_scc(conf):
cc=conf.cmd_to_list(cc)
try:
conf.cmd_and_log(cc+['-flags'])
- except:
+ except Exception:
conf.fatal('%r is not a Sun compiler'%cc)
v['CC']=cc
v['CC_NAME']='sun'
+ at conf
def scc_common_flags(conf):
v=conf.env
v['CC_SRC_F']=[]
@@ -49,6 +51,3 @@ def configure(conf):
conf.cc_load_tools()
conf.cc_add_flags()
conf.link_add_flags()
-
-conf(find_scc)
-conf(scc_common_flags)
\ No newline at end of file
diff --git a/waflib/Tools/suncxx.py b/waflib/Tools/suncxx.py
index c604cd2..4b8b931 100644
--- a/waflib/Tools/suncxx.py
+++ b/waflib/Tools/suncxx.py
@@ -6,6 +6,7 @@ import os
from waflib import Utils
from waflib.Tools import ccroot,ar
from waflib.Configure import conf
+ at conf
def find_sxx(conf):
v=conf.env
cc=None
@@ -17,10 +18,11 @@ def find_sxx(conf):
cc=conf.cmd_to_list(cc)
try:
conf.cmd_and_log(cc+['-flags'])
- except:
+ except Exception:
conf.fatal('%r is not a Sun compiler'%cc)
v['CXX']=cc
v['CXX_NAME']='sun'
+ at conf
def sxx_common_flags(conf):
v=conf.env
v['CXX_SRC_F']=[]
@@ -50,6 +52,3 @@ def configure(conf):
conf.cxx_load_tools()
conf.cxx_add_flags()
conf.link_add_flags()
-
-conf(find_sxx)
-conf(sxx_common_flags)
\ No newline at end of file
diff --git a/waflib/Tools/tex.py b/waflib/Tools/tex.py
deleted file mode 100644
index 4a26c43..0000000
--- a/waflib/Tools/tex.py
+++ /dev/null
@@ -1,242 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import os,re
-from waflib import Utils,Task,Errors
-from waflib.TaskGen import feature,before_method
-from waflib.Logs import error,warn,debug
-re_bibunit=re.compile(r'\\(?P<type>putbib)\[(?P<file>[^\[\]]*)\]',re.M)
-def bibunitscan(self):
- node=self.inputs[0]
- nodes=[]
- if not node:return nodes
- code=Utils.readf(node.abspath())
- for match in re_bibunit.finditer(code):
- path=match.group('file')
- if path:
- for k in['','.bib']:
- debug('tex: trying %s%s'%(path,k))
- fi=node.parent.find_resource(path+k)
- if fi:
- nodes.append(fi)
- else:
- debug('tex: could not find %s'%path)
- debug("tex: found the following bibunit files: %s"%nodes)
- return nodes
-exts_deps_tex=['','.ltx','.tex','.bib','.pdf','.png','.eps','.ps']
-exts_tex=['.ltx','.tex']
-re_tex=re.compile(r'\\(?P<type>include|bibliography|putbib|includegraphics|input|import|bringin|lstinputlisting)(\[[^\[\]]*\])?{(?P<file>[^{}]*)}',re.M)
-g_bibtex_re=re.compile('bibdata',re.M)
-class tex(Task.Task):
- bibtex_fun,_=Task.compile_fun('${BIBTEX} ${BIBTEXFLAGS} ${SRCFILE}',shell=False)
- bibtex_fun.__doc__="""
- Execute the program **bibtex**
- """
- makeindex_fun,_=Task.compile_fun('${MAKEINDEX} ${MAKEINDEXFLAGS} ${SRCFILE}',shell=False)
- makeindex_fun.__doc__="""
- Execute the program **makeindex**
- """
- def scan_aux(self,node):
- nodes=[node]
- re_aux=re.compile(r'\\@input{(?P<file>[^{}]*)}',re.M)
- def parse_node(node):
- code=node.read()
- for match in re_aux.finditer(code):
- path=match.group('file')
- found=node.parent.find_or_declare(path)
- if found and found not in nodes:
- debug('tex: found aux node '+found.abspath())
- nodes.append(found)
- parse_node(found)
- parse_node(node)
- return nodes
- def scan(self):
- node=self.inputs[0]
- nodes=[]
- names=[]
- seen=[]
- if not node:return(nodes,names)
- def parse_node(node):
- if node in seen:
- return
- seen.append(node)
- code=node.read()
- global re_tex
- for match in re_tex.finditer(code):
- for path in match.group('file').split(','):
- if path:
- add_name=True
- found=None
- for k in exts_deps_tex:
- debug('tex: trying %s%s'%(path,k))
- found=node.parent.find_resource(path+k)
- if found and not found in self.outputs:
- nodes.append(found)
- add_name=False
- for ext in exts_tex:
- if found.name.endswith(ext):
- parse_node(found)
- break
- if add_name:
- names.append(path)
- parse_node(node)
- for x in nodes:
- x.parent.get_bld().mkdir()
- debug("tex: found the following : %s and names %s"%(nodes,names))
- return(nodes,names)
- def check_status(self,msg,retcode):
- if retcode!=0:
- raise Errors.WafError("%r command exit status %r"%(msg,retcode))
- def bibfile(self):
- need_bibtex=False
- try:
- for aux_node in self.aux_nodes:
- ct=aux_node.read()
- if g_bibtex_re.findall(ct):
- need_bibtex=True
- break
- except(OSError,IOError):
- error('error bibtex scan')
- else:
- if need_bibtex:
- warn('calling bibtex')
- self.env.env={}
- self.env.env.update(os.environ)
- self.env.env.update({'BIBINPUTS':self.TEXINPUTS,'BSTINPUTS':self.TEXINPUTS})
- self.env.SRCFILE=self.aux_nodes[0].name[:-4]
- self.check_status('error when calling bibtex',self.bibtex_fun())
- def bibunits(self):
- try:
- bibunits=bibunitscan(self)
- except FSError:
- error('error bibunitscan')
- else:
- if bibunits:
- fn=['bu'+str(i)for i in xrange(1,len(bibunits)+1)]
- if fn:
- warn('calling bibtex on bibunits')
- for f in fn:
- self.env.env={'BIBINPUTS':self.TEXINPUTS,'BSTINPUTS':self.TEXINPUTS}
- self.env.SRCFILE=f
- self.check_status('error when calling bibtex',self.bibtex_fun())
- def makeindex(self):
- try:
- idx_path=self.idx_node.abspath()
- os.stat(idx_path)
- except OSError:
- warn('index file %s absent, not calling makeindex'%idx_path)
- else:
- warn('calling makeindex')
- self.env.SRCFILE=self.idx_node.name
- self.env.env={}
- self.check_status('error when calling makeindex %s'%idx_path,self.makeindex_fun())
- def run(self):
- env=self.env
- if not env['PROMPT_LATEX']:
- env.append_value('LATEXFLAGS','-interaction=batchmode')
- env.append_value('PDFLATEXFLAGS','-interaction=batchmode')
- env.append_value('XELATEXFLAGS','-interaction=batchmode')
- fun=self.texfun
- node=self.inputs[0]
- srcfile=node.abspath()
- texinputs=self.env.TEXINPUTS or''
- self.TEXINPUTS=node.parent.get_bld().abspath()+os.pathsep+node.parent.get_src().abspath()+os.pathsep+texinputs+os.pathsep
- self.aux_node=node.change_ext('.aux')
- self.cwd=self.inputs[0].parent.get_bld().abspath()
- warn('first pass on %s'%self.__class__.__name__)
- self.env.env={}
- self.env.env.update(os.environ)
- self.env.env.update({'TEXINPUTS':self.TEXINPUTS})
- self.env.SRCFILE=srcfile
- self.check_status('error when calling latex',fun())
- self.aux_nodes=self.scan_aux(node.change_ext('.aux'))
- self.idx_node=node.change_ext('.idx')
- self.bibfile()
- self.bibunits()
- self.makeindex()
- hash=''
- for i in range(10):
- prev_hash=hash
- try:
- hashes=[Utils.h_file(x.abspath())for x in self.aux_nodes]
- hash=Utils.h_list(hashes)
- except(OSError,IOError):
- error('could not read aux.h')
- pass
- if hash and hash==prev_hash:
- break
- warn('calling %s'%self.__class__.__name__)
- self.env.env={}
- self.env.env.update(os.environ)
- self.env.env.update({'TEXINPUTS':self.TEXINPUTS})
- self.env.SRCFILE=srcfile
- self.check_status('error when calling %s'%self.__class__.__name__,fun())
-class latex(tex):
- texfun,vars=Task.compile_fun('${LATEX} ${LATEXFLAGS} ${SRCFILE}',shell=False)
-class pdflatex(tex):
- texfun,vars=Task.compile_fun('${PDFLATEX} ${PDFLATEXFLAGS} ${SRCFILE}',shell=False)
-class xelatex(tex):
- texfun,vars=Task.compile_fun('${XELATEX} ${XELATEXFLAGS} ${SRCFILE}',shell=False)
-class dvips(Task.Task):
- run_str='${DVIPS} ${DVIPSFLAGS} ${SRC} -o ${TGT}'
- color='BLUE'
- after=['latex','pdflatex','xelatex']
-class dvipdf(Task.Task):
- run_str='${DVIPDF} ${DVIPDFFLAGS} ${SRC} ${TGT}'
- color='BLUE'
- after=['latex','pdflatex','xelatex']
-class pdf2ps(Task.Task):
- run_str='${PDF2PS} ${PDF2PSFLAGS} ${SRC} ${TGT}'
- color='BLUE'
- after=['latex','pdflatex','xelatex']
-def apply_tex(self):
- if not getattr(self,'type',None)in['latex','pdflatex','xelatex']:
- self.type='pdflatex'
- tree=self.bld
- outs=Utils.to_list(getattr(self,'outs',[]))
- self.env['PROMPT_LATEX']=getattr(self,'prompt',1)
- deps_lst=[]
- if getattr(self,'deps',None):
- deps=self.to_list(self.deps)
- for filename in deps:
- n=self.path.find_resource(filename)
- if not n in deps_lst:deps_lst.append(n)
- for node in self.to_nodes(self.source):
- if self.type=='latex':
- task=self.create_task('latex',node,node.change_ext('.dvi'))
- elif self.type=='pdflatex':
- task=self.create_task('pdflatex',node,node.change_ext('.pdf'))
- elif self.type=='xelatex':
- task=self.create_task('xelatex',node,node.change_ext('.pdf'))
- task.env=self.env
- if deps_lst:
- try:
- lst=tree.node_deps[task.uid()]
- for n in deps_lst:
- if not n in lst:
- lst.append(n)
- except KeyError:
- tree.node_deps[task.uid()]=deps_lst
- if self.type=='latex':
- if'ps'in outs:
- tsk=self.create_task('dvips',task.outputs,node.change_ext('.ps'))
- tsk.env.env={'TEXINPUTS':node.parent.abspath()+os.pathsep+self.path.abspath()+os.pathsep+self.path.get_bld().abspath()}
- if'pdf'in outs:
- tsk=self.create_task('dvipdf',task.outputs,node.change_ext('.pdf'))
- tsk.env.env={'TEXINPUTS':node.parent.abspath()+os.pathsep+self.path.abspath()+os.pathsep+self.path.get_bld().abspath()}
- elif self.type=='pdflatex':
- if'ps'in outs:
- self.create_task('pdf2ps',task.outputs,node.change_ext('.ps'))
- self.source=[]
-def configure(self):
- v=self.env
- for p in'tex latex pdflatex xelatex bibtex dvips dvipdf ps2pdf makeindex pdf2ps'.split():
- try:
- self.find_program(p,var=p.upper())
- except self.errors.ConfigurationError:
- pass
- v['DVIPSFLAGS']='-Ppdf'
-
-feature('tex')(apply_tex)
-before_method('process_source')(apply_tex)
\ No newline at end of file
diff --git a/waflib/Tools/vala.py b/waflib/Tools/vala.py
deleted file mode 100644
index ff422ef..0000000
--- a/waflib/Tools/vala.py
+++ /dev/null
@@ -1,216 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import os.path,shutil,re
-from waflib import Context,Task,Utils,Logs,Options,Errors
-from waflib.TaskGen import extension
-from waflib.Configure import conf
-class valac(Task.Task):
- vars=["VALAC","VALAC_VERSION","VALAFLAGS"]
- ext_out=['.h']
- def run(self):
- env=self.env
- cmd=[env['VALAC'],'-C','--quiet']
- cmd.extend(Utils.to_list(env['VALAFLAGS']))
- if self.threading:
- cmd.append('--thread')
- if self.profile:
- cmd.append('--profile=%s'%self.profile)
- if self.target_glib:
- cmd.append('--target-glib=%s'%self.target_glib)
- if self.is_lib:
- cmd.append('--library='+self.target)
- for x in self.outputs:
- if x.name.endswith('.h'):
- cmd.append('--header='+x.name)
- if self.gir:
- cmd.append('--gir=%s.gir'%self.gir)
- for vapi_dir in self.vapi_dirs:
- cmd.append('--vapidir=%s'%vapi_dir)
- for package in self.packages:
- cmd.append('--pkg=%s'%package)
- for package in self.packages_private:
- cmd.append('--pkg=%s'%package)
- for define in self.vala_defines:
- cmd.append('--define=%s'%define)
- cmd.extend([a.abspath()for a in self.inputs])
- ret=self.exec_command(cmd,cwd=self.outputs[0].parent.abspath())
- if ret:
- return ret
- for x in self.outputs:
- if id(x.parent)!=id(self.outputs[0].parent):
- shutil.move(self.outputs[0].parent.abspath()+os.sep+x.name,x.abspath())
- if self.packages and getattr(self,'deps_node',None):
- self.deps_node.write('\n'.join(self.packages))
- return ret
-def vala_file(self,node):
- valatask=getattr(self,"valatask",None)
- if not valatask:
- def _get_api_version():
- api_version='1.0'
- if hasattr(Context.g_module,'API_VERSION'):
- version=Context.g_module.API_VERSION.split(".")
- if version[0]=="0":
- api_version="0."+version[1]
- else:
- api_version=version[0]+".0"
- return api_version
- valatask=self.create_task('valac')
- self.valatask=valatask
- self.includes=Utils.to_list(getattr(self,'includes',[]))
- self.uselib=self.to_list(getattr(self,'uselib',[]))
- valatask.packages=[]
- valatask.packages_private=Utils.to_list(getattr(self,'packages_private',[]))
- valatask.vapi_dirs=[]
- valatask.target=self.target
- valatask.threading=False
- valatask.install_path=getattr(self,'install_path','')
- valatask.profile=getattr(self,'profile','gobject')
- valatask.vala_defines=getattr(self,'vala_defines',[])
- valatask.target_glib=None
- valatask.gir=getattr(self,'gir',None)
- valatask.gir_path=getattr(self,'gir_path','${DATAROOTDIR}/gir-1.0')
- valatask.vapi_path=getattr(self,'vapi_path','${DATAROOTDIR}/vala/vapi')
- valatask.pkg_name=getattr(self,'pkg_name',self.env['PACKAGE'])
- valatask.header_path=getattr(self,'header_path','${INCLUDEDIR}/%s-%s'%(valatask.pkg_name,_get_api_version()))
- valatask.install_binding=getattr(self,'install_binding',True)
- valatask.is_lib=False
- if not'cprogram'in self.features:
- valatask.is_lib=True
- packages=Utils.to_list(getattr(self,'packages',[]))
- vapi_dirs=Utils.to_list(getattr(self,'vapi_dirs',[]))
- includes=[]
- if hasattr(self,'use'):
- local_packages=Utils.to_list(self.use)[:]
- seen=[]
- while len(local_packages)>0:
- package=local_packages.pop()
- if package in seen:
- continue
- seen.append(package)
- try:
- package_obj=self.bld.get_tgen_by_name(package)
- except Errors.WafError:
- continue
- package_name=package_obj.target
- package_node=package_obj.path
- package_dir=package_node.path_from(self.path)
- for task in package_obj.tasks:
- for output in task.outputs:
- if output.name==package_name+".vapi":
- valatask.set_run_after(task)
- if package_name not in packages:
- packages.append(package_name)
- if package_dir not in vapi_dirs:
- vapi_dirs.append(package_dir)
- if package_dir not in includes:
- includes.append(package_dir)
- if hasattr(package_obj,'use'):
- lst=self.to_list(package_obj.use)
- lst.reverse()
- local_packages=[pkg for pkg in lst if pkg not in seen]+local_packages
- valatask.packages=packages
- for vapi_dir in vapi_dirs:
- try:
- valatask.vapi_dirs.append(self.path.find_dir(vapi_dir).abspath())
- valatask.vapi_dirs.append(self.path.find_dir(vapi_dir).get_bld().abspath())
- except AttributeError:
- Logs.warn("Unable to locate Vala API directory: '%s'"%vapi_dir)
- self.includes.append(self.bld.srcnode.abspath())
- self.includes.append(self.bld.bldnode.abspath())
- for include in includes:
- try:
- self.includes.append(self.path.find_dir(include).abspath())
- self.includes.append(self.path.find_dir(include).get_bld().abspath())
- except AttributeError:
- Logs.warn("Unable to locate include directory: '%s'"%include)
- if valatask.profile=='gobject':
- if hasattr(self,'target_glib'):
- Logs.warn('target_glib on vala tasks is not supported --vala-target-glib=MAJOR.MINOR from the vala tool options')
- if getattr(Options.options,'vala_target_glib',None):
- valatask.target_glib=Options.options.vala_target_glib
- if not'GOBJECT'in self.uselib:
- self.uselib.append('GOBJECT')
- if hasattr(self,'threading'):
- if valatask.profile=='gobject':
- valatask.threading=self.threading
- if not'GTHREAD'in self.uselib:
- self.uselib.append('GTHREAD')
- else:
- Logs.warn("Profile %s does not have threading support"%valatask.profile)
- if valatask.is_lib:
- valatask.outputs.append(self.path.find_or_declare('%s.h'%self.target))
- valatask.outputs.append(self.path.find_or_declare('%s.vapi'%self.target))
- if valatask.gir:
- valatask.outputs.append(self.path.find_or_declare('%s.gir'%self.gir))
- if valatask.packages:
- d=self.path.find_or_declare('%s.deps'%self.target)
- valatask.outputs.append(d)
- valatask.deps_node=d
- valatask.inputs.append(node)
- c_node=node.change_ext('.c')
- valatask.outputs.append(c_node)
- self.source.append(c_node)
- if valatask.is_lib and valatask.install_binding:
- headers_list=[o for o in valatask.outputs if o.suffix()==".h"]
- try:
- self.install_vheader.source=headers_list
- except AttributeError:
- self.install_vheader=self.bld.install_files(valatask.header_path,headers_list,self.env)
- vapi_list=[o for o in valatask.outputs if(o.suffix()in(".vapi",".deps"))]
- try:
- self.install_vapi.source=vapi_list
- except AttributeError:
- self.install_vapi=self.bld.install_files(valatask.vapi_path,vapi_list,self.env)
- gir_list=[o for o in valatask.outputs if o.suffix()==".gir"]
- try:
- self.install_gir.source=gir_list
- except AttributeError:
- self.install_gir=self.bld.install_files(valatask.gir_path,gir_list,self.env)
-valac=Task.update_outputs(valac)
-def find_valac(self,valac_name,min_version):
- valac=self.find_program(valac_name,var='VALAC')
- try:
- output=self.cmd_and_log(valac+' --version')
- except Exception:
- valac_version=None
- else:
- ver=re.search(r'\d+.\d+.\d+',output).group(0).split('.')
- valac_version=tuple([int(x)for x in ver])
- self.msg('Checking for %s version >= %r'%(valac_name,min_version),valac_version,valac_version and valac_version>=min_version)
- if valac and valac_version<min_version:
- self.fatal("%s version %r is too old, need >= %r"%(valac_name,valac_version,min_version))
- self.env['VALAC_VERSION']=valac_version
- return valac
-def check_vala(self,min_version=(0,8,0),branch=None):
- if not branch:
- branch=min_version[:2]
- try:
- find_valac(self,'valac-%d.%d'%(branch[0],branch[1]),min_version)
- except self.errors.ConfigurationError:
- find_valac(self,'valac',min_version)
-def check_vala_deps(self):
- if not self.env['HAVE_GOBJECT']:
- pkg_args={'package':'gobject-2.0','uselib_store':'GOBJECT','args':'--cflags --libs'}
- if getattr(Options.options,'vala_target_glib',None):
- pkg_args['atleast_version']=Options.options.vala_target_glib
- self.check_cfg(**pkg_args)
- if not self.env['HAVE_GTHREAD']:
- pkg_args={'package':'gthread-2.0','uselib_store':'GTHREAD','args':'--cflags --libs'}
- if getattr(Options.options,'vala_target_glib',None):
- pkg_args['atleast_version']=Options.options.vala_target_glib
- self.check_cfg(**pkg_args)
-def configure(self):
- self.load('gnu_dirs')
- self.check_vala_deps()
- self.check_vala()
-def options(opt):
- opt.load('gnu_dirs')
- valaopts=opt.add_option_group('Vala Compiler Options')
- valaopts.add_option('--vala-target-glib',default=None,dest='vala_target_glib',metavar='MAJOR.MINOR',help='Target version of glib for Vala GObject code generation')
-
-extension('.vala','.gs')(vala_file)
-conf(find_valac)
-conf(check_vala)
-conf(check_vala_deps)
\ No newline at end of file
diff --git a/waflib/Tools/waf_unit_test.py b/waflib/Tools/waf_unit_test.py
deleted file mode 100644
index 850e713..0000000
--- a/waflib/Tools/waf_unit_test.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-
-import os,sys
-from waflib.TaskGen import feature,after_method
-from waflib import Utils,Task,Logs,Options
-testlock=Utils.threading.Lock()
-def make_test(self):
- if getattr(self,'link_task',None):
- self.create_task('utest',self.link_task.outputs)
-class utest(Task.Task):
- color='PINK'
- after=['vnum','inst']
- vars=[]
- def runnable_status(self):
- ret=super(utest,self).runnable_status()
- if ret==Task.SKIP_ME:
- if getattr(Options.options,'all_tests',False):
- return Task.RUN_ME
- return ret
- def run(self):
- filename=self.inputs[0].abspath()
- self.ut_exec=getattr(self,'ut_exec',[filename])
- if getattr(self.generator,'ut_fun',None):
- self.generator.ut_fun(self)
- try:
- fu=getattr(self.generator.bld,'all_test_paths')
- except AttributeError:
- fu=os.environ.copy()
- self.generator.bld.all_test_paths=fu
- lst=[]
- for g in self.generator.bld.groups:
- for tg in g:
- if getattr(tg,'link_task',None):
- lst.append(tg.link_task.outputs[0].parent.abspath())
- def add_path(dct,path,var):
- dct[var]=os.pathsep.join(Utils.to_list(path)+[os.environ.get(var,'')])
- if Utils.is_win32:
- add_path(fu,lst,'PATH')
- elif Utils.unversioned_sys_platform()=='darwin':
- add_path(fu,lst,'DYLD_LIBRARY_PATH')
- add_path(fu,lst,'LD_LIBRARY_PATH')
- else:
- add_path(fu,lst,'LD_LIBRARY_PATH')
- cwd=getattr(self.generator,'ut_cwd','')or self.inputs[0].parent.abspath()
- proc=Utils.subprocess.Popen(self.ut_exec,cwd=cwd,env=fu,stderr=Utils.subprocess.PIPE,stdout=Utils.subprocess.PIPE)
- (stdout,stderr)=proc.communicate()
- tup=(filename,proc.returncode,stdout,stderr)
- self.generator.utest_result=tup
- testlock.acquire()
- try:
- bld=self.generator.bld
- Logs.debug("ut: %r",tup)
- try:
- bld.utest_results.append(tup)
- except AttributeError:
- bld.utest_results=[tup]
- finally:
- testlock.release()
-def summary(bld):
- lst=getattr(bld,'utest_results',[])
- if lst:
- Logs.pprint('CYAN','execution summary')
- total=len(lst)
- tfail=len([x for x in lst if x[1]])
- Logs.pprint('CYAN',' tests that pass %d/%d'%(total-tfail,total))
- for(f,code,out,err)in lst:
- if not code:
- Logs.pprint('CYAN',' %s'%f)
- Logs.pprint('CYAN',' tests that fail %d/%d'%(tfail,total))
- for(f,code,out,err)in lst:
- if code:
- Logs.pprint('CYAN',' %s'%f)
-def options(opt):
- opt.add_option('--alltests',action='store_true',default=False,help='Exec all unit tests',dest='all_tests')
-
-feature('test')(make_test)
-after_method('apply_link')(make_test)
\ No newline at end of file
diff --git a/waflib/Tools/winres.py b/waflib/Tools/winres.py
index 93dd4f2..88904af 100644
--- a/waflib/Tools/winres.py
+++ b/waflib/Tools/winres.py
@@ -2,8 +2,11 @@
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
-from waflib import Task
+import re,traceback
+from waflib import Task,Logs,Utils
from waflib.TaskGen import extension
+from waflib.Tools import c_preproc
+ at extension('.rc')
def rc_file(self,node):
obj_ext='.rc.o'
if self.env['WINRC_TGT_F']=='/fo':
@@ -13,9 +16,59 @@ def rc_file(self,node):
self.compiled_tasks.append(rctask)
except AttributeError:
self.compiled_tasks=[rctask]
+re_lines=re.compile('(?:^[ \t]*(#|%:)[ \t]*(ifdef|ifndef|if|else|elif|endif|include|import|define|undef|pragma)[ \t]*(.*?)\s*$)|''(?:^\w+[ \t]*(ICON|BITMAP|CURSOR|HTML|FONT|MESSAGETABLE|TYPELIB|REGISTRY|D3DFX)[ \t]*(.*?)\s*$)',re.IGNORECASE|re.MULTILINE)
+class rc_parser(c_preproc.c_parser):
+ def filter_comments(self,filepath):
+ code=Utils.readf(filepath)
+ if c_preproc.use_trigraphs:
+ for(a,b)in c_preproc.trig_def:code=code.split(a).join(b)
+ code=c_preproc.re_nl.sub('',code)
+ code=c_preproc.re_cpp.sub(c_preproc.repl,code)
+ ret=[]
+ for m in re.finditer(re_lines,code):
+ if m.group(2):
+ ret.append((m.group(2),m.group(3)))
+ else:
+ ret.append(('include',m.group(5)))
+ return ret
+ def addlines(self,node):
+ self.currentnode_stack.append(node.parent)
+ filepath=node.abspath()
+ self.count_files+=1
+ if self.count_files>c_preproc.recursion_limit:
+ raise c_preproc.PreprocError("recursion limit exceeded")
+ pc=self.parse_cache
+ Logs.debug('preproc: reading file %r',filepath)
+ try:
+ lns=pc[filepath]
+ except KeyError:
+ pass
+ else:
+ self.lines.extend(lns)
+ return
+ try:
+ lines=self.filter_comments(filepath)
+ lines.append((c_preproc.POPFILE,''))
+ lines.reverse()
+ pc[filepath]=lines
+ self.lines.extend(lines)
+ except IOError:
+ raise c_preproc.PreprocError("could not read the file %s"%filepath)
+ except Exception:
+ if Logs.verbose>0:
+ Logs.error("parsing %s failed"%filepath)
+ traceback.print_exc()
class winrc(Task.Task):
run_str='${WINRC} ${WINRCFLAGS} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${WINRC_TGT_F} ${TGT} ${WINRC_SRC_F} ${SRC}'
color='BLUE'
+ def scan(self):
+ tmp=rc_parser(self.generator.includes_nodes)
+ tmp.start(self.inputs[0],self.env)
+ nodes=tmp.nodes
+ names=tmp.names
+ if Logs.verbose:
+ Logs.debug('deps: deps for %s: %r; unresolved %r'%(str(self),nodes,names))
+ return(nodes,names)
def configure(conf):
v=conf.env
v['WINRC_TGT_F']='-o'
@@ -30,5 +83,3 @@ def configure(conf):
if not conf.env.WINRC:
conf.fatal('winrc was not found!')
v['WINRCFLAGS']=[]
-
-extension('.rc')(rc_file)
\ No newline at end of file
diff --git a/waflib/Tools/xlc.py b/waflib/Tools/xlc.py
index c2a9982..fbf0fcf 100644
--- a/waflib/Tools/xlc.py
+++ b/waflib/Tools/xlc.py
@@ -4,12 +4,14 @@
from waflib.Tools import ccroot,ar
from waflib.Configure import conf
+ at conf
def find_xlc(conf):
cc=conf.find_program(['xlc_r','xlc'],var='CC')
cc=conf.cmd_to_list(cc)
conf.get_xlc_version(cc)
conf.env.CC_NAME='xlc'
conf.env.CC=cc
+ at conf
def xlc_common_flags(conf):
v=conf.env
v['CC_SRC_F']=[]
@@ -41,6 +43,3 @@ def configure(conf):
conf.cc_load_tools()
conf.cc_add_flags()
conf.link_add_flags()
-
-conf(find_xlc)
-conf(xlc_common_flags)
\ No newline at end of file
diff --git a/waflib/Tools/xlcxx.py b/waflib/Tools/xlcxx.py
index bfbe01e..b7efb23 100644
--- a/waflib/Tools/xlcxx.py
+++ b/waflib/Tools/xlcxx.py
@@ -4,12 +4,14 @@
from waflib.Tools import ccroot,ar
from waflib.Configure import conf
+ at conf
def find_xlcxx(conf):
cxx=conf.find_program(['xlc++_r','xlc++'],var='CXX')
cxx=conf.cmd_to_list(cxx)
conf.get_xlc_version(cxx)
conf.env.CXX_NAME='xlc++'
conf.env.CXX=cxx
+ at conf
def xlcxx_common_flags(conf):
v=conf.env
v['CXX_SRC_F']=[]
@@ -41,6 +43,3 @@ def configure(conf):
conf.cxx_load_tools()
conf.cxx_add_flags()
conf.link_add_flags()
-
-conf(find_xlcxx)
-conf(xlcxx_common_flags)
\ No newline at end of file
diff --git a/waflib/Utils.py b/waflib/Utils.py
index 25fa3f0..706ab20 100644
--- a/waflib/Utils.py
+++ b/waflib/Utils.py
@@ -3,13 +3,7 @@
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
import os,sys,errno,traceback,inspect,re,shutil,datetime,gc
-try:
- import subprocess
-except:
- try:
- import waflib.extras.subprocess as subprocess
- except:
- print("The subprocess module is missing (python2.3?):\n try calling 'waf update --files=subprocess'\n or add a copy of subprocess.py to the python libraries")
+import subprocess
try:
from collections import deque
except ImportError:
@@ -18,26 +12,26 @@ except ImportError:
return self.pop(0)
try:
import _winreg as winreg
-except:
+except ImportError:
try:
import winreg
- except:
+ except ImportError:
winreg=None
from waflib import Errors
try:
from collections import UserDict
-except:
+except ImportError:
from UserDict import UserDict
try:
from hashlib import md5
-except:
+except ImportError:
try:
from md5 import md5
- except:
+ except ImportError:
pass
try:
import threading
-except:
+except ImportError:
class threading(object):
pass
class Lock(object):
@@ -53,7 +47,7 @@ else:
run_old(*args,**kwargs)
except(KeyboardInterrupt,SystemExit):
raise
- except:
+ except Exception:
sys.excepthook(*sys.exc_info())
threading.Thread.run=run
SIG_NIL='iluvcuteoverload'
@@ -79,26 +73,104 @@ is_win32=sys.platform in('win32','cli')
indicator='\x1b[K%s%s%s\r'
if is_win32 and'NOCOLOR'in os.environ:
indicator='%s%s%s\r'
-def readf(fname,m='r'):
+def readf(fname,m='r',encoding='ISO8859-1'):
+ if sys.hexversion>0x3000000 and not'b'in m:
+ m+='b'
+ f=open(fname,m)
+ try:
+ txt=f.read()
+ finally:
+ f.close()
+ txt=txt.decode(encoding)
+ else:
+ f=open(fname,m)
+ try:
+ txt=f.read()
+ finally:
+ f.close()
+ return txt
+def writef(fname,data,m='w',encoding='ISO8859-1'):
+ if sys.hexversion>0x3000000 and not'b'in m:
+ data=data.encode(encoding)
+ m+='b'
f=open(fname,m)
try:
- txt=f.read()
+ f.write(data)
finally:
f.close()
- return txt
-def h_file(filename):
- f=open(filename,'rb')
+def h_file(fname):
+ f=open(fname,'rb')
m=md5()
try:
- while filename:
- filename=f.read(100000)
- m.update(filename)
+ while fname:
+ fname=f.read(200000)
+ m.update(fname)
finally:
f.close()
return m.digest()
+if hasattr(os,'O_NOINHERIT'):
+ def readf_win32(f,m='r',encoding='ISO8859-1'):
+ flags=os.O_NOINHERIT|os.O_RDONLY|os.O_BINARY
+ if'+'in m:
+ flags|=os.O_RDWR
+ try:
+ fd=os.open(f,flags)
+ except OSError:
+ raise IOError('Cannot read from %r'%f)
+ if sys.hexversion>0x3000000 and not'b'in m:
+ m+='b'
+ f=open(f,m)
+ try:
+ txt=f.read()
+ finally:
+ f.close()
+ txt=txt.decode(encoding)
+ else:
+ f=os.fdopen(fd,m)
+ try:
+ txt=f.read()
+ finally:
+ f.close()
+ return txt
+ def writef_win32(f,data,m='w',encoding='ISO8859-1'):
+ if sys.hexversion>0x3000000 and not'b'in m:
+ data=data.encode(encoding)
+ m+='b'
+ flags=os.O_CREAT|os.O_TRUNC|os.O_WRONLY|os.O_NOINHERIT|os.O_BINARY
+ if'+'in m:
+ flags|=os.O_RDWR
+ try:
+ fd=os.open(f,flags)
+ except OSError:
+ raise IOError('Cannot write to %r'%f)
+ f=os.fdopen(fd,m)
+ try:
+ f.write(data)
+ finally:
+ f.close()
+ def h_file_win32(fname):
+ try:
+ fd=os.open(fname,os.O_BINARY|os.O_RDONLY|os.O_NOINHERIT)
+ except OSError:
+ raise IOError('Cannot read from %r'%fname)
+ f=os.fdopen(fd,'rb')
+ m=md5()
+ try:
+ while fname:
+ fname=f.read(200000)
+ m.update(fname)
+ finally:
+ f.close()
+ return m.digest()
+ readf_old=readf
+ writef_old=writef
+ h_file_old=h_file
+ readf=readf_win32
+ writef=writef_win32
+ h_file=h_file_win32
try:
x=''.encode('hex')
-except:
+except LookupError:
import binascii
def to_hex(s):
ret=binascii.hexlify(s)
@@ -120,18 +192,18 @@ if is_win32:
if not s:
try:
import ctypes
- except:
+ except ImportError:
return[x+':\\'for x in list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')]
else:
dlen=4
maxdrives=26
buf=ctypes.create_string_buffer(maxdrives*dlen)
- ndrives=ctypes.windll.kernel32.GetLogicalDriveStringsA(maxdrives,ctypes.byref(buf))
- return[buf.raw[4*i:4*i+3].decode('ascii')for i in range(int(ndrives/dlen))]
+ ndrives=ctypes.windll.kernel32.GetLogicalDriveStringsA(maxdrives*dlen,ctypes.byref(buf))
+ return[str(buf.raw[4*i:4*i+2].decode('ascii'))for i in range(int(ndrives/dlen))]
if len(s)==2 and s[1]==":":
s+=os.sep
if not os.path.isdir(s):
- e=OSError()
+ e=OSError('%s is not a directory'%s)
e.errno=errno.ENOENT
raise e
return os.listdir(s)
diff --git a/waflib/ansiterm.py b/waflib/ansiterm.py
index 485d033..0de6171 100644
--- a/waflib/ansiterm.py
+++ b/waflib/ansiterm.py
@@ -28,7 +28,7 @@ else:
is_vista=getattr(sys,"getwindowsversion",None)and sys.getwindowsversion()[0]>=6
try:
_type=unicode
- except:
+ except NameError:
_type=str
to_int=lambda number,default:number and int(number)or default
wlock=threading.Lock()
diff --git a/waflib/extras/autowaf.py b/waflib/extras/autowaf.py
index 52a92a1..7055189 100644
--- a/waflib/extras/autowaf.py
+++ b/waflib/extras/autowaf.py
@@ -2,16 +2,18 @@
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+import glob
import os
import subprocess
import sys
-import glob
from waflib import Configure,Context,Logs,Node,Options,Task,Utils
from waflib.TaskGen import feature,before,after
global g_is_child
g_is_child=False
global g_step
g_step=0
+ at feature('c','cxx')
+ at after('apply_incpaths')
def include_config_h(self):
self.env.append_value('INCPATHS',self.bld.bldnode.abspath())
def set_options(opt,debug_by_default=False):
@@ -32,19 +34,17 @@ def set_options(opt,debug_by_default=False):
dirs_options.add_option('--mandir',type='string',help="Manual pages [Default: DATADIR/man]")
dirs_options.add_option('--docdir',type='string',help="HTML documentation [Default: DATADIR/doc]")
if debug_by_default:
- opt.add_option('--optimize',action='store_false',default=True,dest='debug',help="Build optimized binaries [Default: False]")
- else:
- opt.add_option('--debug',action='store_true',default=False,dest='debug',help="Build debuggable binaries [Default: False]")
- opt.add_option('--grind',action='store_true',default=False,dest='grind',help="Run tests in valgrind [Default: False]")
- opt.add_option('--strict',action='store_true',default=False,dest='strict',help="Use strict compiler flags and show all warnings [Default: False]")
- opt.add_option('--docs',action='store_true',default=False,dest='docs',help="Build documentation - requires doxygen [Default: False]")
- opt.add_option('--lv2-user',action='store_true',default=False,dest='lv2_user',help="Install LV2 bundles to user-local location [Default: False]")
- if sys.platform=="darwin":
- opt.add_option('--lv2dir',type='string',help="LV2 bundles [Default: /Library/Audio/Plug-Ins/LV2]")
- elif sys.platform=="win32":
- opt.add_option('--lv2dir',type='string',help="LV2 bundles [Default: C:\Program Files\LV2]")
+ opt.add_option('--optimize',action='store_false',default=True,dest='debug',help="Build optimized binaries")
else:
- opt.add_option('--lv2dir',type='string',help="LV2 bundles [Default: LIBDIR/lv2]")
+ opt.add_option('--debug',action='store_true',default=False,dest='debug',help="Build debuggable binaries")
+ opt.add_option('--pardebug',action='store_true',default=False,dest='pardebug',help="Build parallel-installable debuggable libraries with D suffix")
+ opt.add_option('--grind',action='store_true',default=False,dest='grind',help="Run tests in valgrind")
+ opt.add_option('--strict',action='store_true',default=False,dest='strict',help="Use strict compiler flags and show all warnings")
+ opt.add_option('--ultra-strict',action='store_true',default=False,dest='ultra_strict',help="Use even stricter compiler flags (likely to trigger many warnings in library headers)")
+ opt.add_option('--docs',action='store_true',default=False,dest='docs',help="Build documentation - requires doxygen")
+ opt.add_option('--lv2-user',action='store_true',default=False,dest='lv2_user',help="Install LV2 bundles to user location")
+ opt.add_option('--lv2-system',action='store_true',default=False,dest='lv2_system',help="Install LV2 bundles to system location")
+ dirs_options.add_option('--lv2dir',type='string',help="LV2 bundles [Default: LIBDIR/lv2]")
g_step=1
def check_header(conf,lang,name,define='',mandatory=True):
includes=''
@@ -82,7 +82,20 @@ def check_pkg(conf,name,**args):
if not check and mandatory and conf.env[var_name]==CheckType.OPTIONAL:
check=True;
if check:
- conf.check_cfg(package=name,args="--cflags --libs",**args)
+ found=None
+ pkg_var_name='PKG_'+name.replace('-','_')
+ pkg_name=name
+ if conf.env.PARDEBUG:
+ args['mandatory']=False
+ found=conf.check_cfg(package=pkg_name+'D',args="--cflags --libs",**args)
+ if found:
+ pkg_name+='D'
+ if mandatory:
+ args['mandatory']=True
+ if not found:
+ found=conf.check_cfg(package=pkg_name,args="--cflags --libs",**args)
+ if found:
+ conf.env[pkg_var_name]=pkg_name
if'atleast_version'in args:
conf.env['VERSION_'+name]=args['atleast_version']
if mandatory:
@@ -91,26 +104,24 @@ def check_pkg(conf,name,**args):
conf.env[var_name]=CheckType.OPTIONAL
def normpath(path):
if sys.platform=='win32':
- return os.path.normpath(path).replace('\\','\\\\')
+ return os.path.normpath(path).replace('\\','/')
else:
return os.path.normpath(path)
def configure(conf):
global g_step
if g_step>1:
return
- def append_cxx_flags(vals):
- conf.env.append_value('CFLAGS',vals.split())
- conf.env.append_value('CXXFLAGS',vals.split())
+ def append_cxx_flags(flags):
+ conf.env.append_value('CFLAGS',flags)
+ conf.env.append_value('CXXFLAGS',flags)
print('')
display_header('Global Configuration')
if Options.options.docs:
conf.load('doxygen')
conf.env['DOCS']=Options.options.docs
- conf.env['DEBUG']=Options.options.debug
- conf.env['STRICT']=Options.options.strict
- conf.env['PREFIX']=os.path.normpath(os.path.abspath(os.path.expanduser(conf.env['PREFIX'])))
- if sys.platform=='win32':
- conf.env['PREFIX']=conf.env['PREFIX'].replace('\\','\\\\')
+ conf.env['DEBUG']=Options.options.debug or Options.options.pardebug
+ conf.env['PARDEBUG']=Options.options.pardebug
+ conf.env['PREFIX']=normpath(os.path.abspath(os.path.expanduser(conf.env['PREFIX'])))
def config_dir(var,opt,default):
if opt:
conf.env[var]=normpath(opt)
@@ -127,21 +138,23 @@ def configure(conf):
config_dir('DOCDIR',opts.docdir,os.path.join(conf.env['DATADIR'],'doc'))
if Options.options.lv2dir:
conf.env['LV2DIR']=Options.options.lv2dir
- else:
- if Options.options.lv2_user:
- if sys.platform=="darwin":
- conf.env['LV2DIR']=os.path.join(os.getenv('HOME'),'Library/Audio/Plug-Ins/LV2')
- elif sys.platform=="win32":
- conf.env['LV2DIR']=os.path.join(os.getenv('APPDATA'),'LV2')
- else:
- conf.env['LV2DIR']=os.path.join(os.getenv('HOME'),'.lv2')
+ elif Options.options.lv2_user:
+ if sys.platform=="darwin":
+ conf.env['LV2DIR']=os.path.join(os.getenv('HOME'),'Library/Audio/Plug-Ins/LV2')
+ elif sys.platform=="win32":
+ conf.env['LV2DIR']=os.path.join(os.getenv('APPDATA'),'LV2')
+ else:
+ conf.env['LV2DIR']=os.path.join(os.getenv('HOME'),'.lv2')
+ elif Options.options.lv2_system:
+ if sys.platform=="darwin":
+ conf.env['LV2DIR']='/Library/Audio/Plug-Ins/LV2'
+ elif sys.platform=="win32":
+ conf.env['LV2DIR']=os.path.join(os.getenv('COMMONPROGRAMFILES'),'LV2')
else:
- if sys.platform=="darwin":
- conf.env['LV2DIR']='/Library/Audio/Plug-Ins/LV2'
- elif sys.platform=="win32":
- conf.env['LV2DIR']=os.path.join(os.getenv('COMMONPROGRAMFILES'),'LV2')
- else:
- conf.env['LV2DIR']=os.path.join(conf.env['LIBDIR'],'lv2')
+ conf.env['LV2DIR']=os.path.join(conf.env['LIBDIR'],'lv2')
+ else:
+ conf.env['LV2DIR']=os.path.join(conf.env['LIBDIR'],'lv2')
+ conf.env['LV2DIR']=normpath(conf.env['LV2DIR'])
if Options.options.docs:
doxygen=conf.find_program('doxygen')
if not doxygen:
@@ -150,24 +163,42 @@ def configure(conf):
if not dot:
conf.fatal("Graphviz (dot) is required to build with --docs")
if Options.options.debug:
- conf.env['CFLAGS']=['-O0','-g']
- conf.env['CXXFLAGS']=['-O0','-g']
+ if conf.env['MSVC_COMPILER']:
+ conf.env['CFLAGS']=['/Od','/Zi','/D_DEBUG']
+ conf.env['CXXFLAGS']=['/Od','/Zi','/D_DEBUG']
+ conf.env['LINKFLAGS']=['/DEBUG']
+ else:
+ conf.env['CFLAGS']=['-O0','-g']
+ conf.env['CXXFLAGS']=['-O0','-g']
else:
- append_cxx_flags('-DNDEBUG')
+ append_cxx_flags(['-DNDEBUG'])
+ if Options.options.ultra_strict:
+ Options.options.strict=True
+ conf.env.append_value('CFLAGS',['-Wredundant-decls','-Wstrict-prototypes','-Wmissing-prototypes'])
if Options.options.strict:
- conf.env.append_value('CFLAGS',['-std=c99','-pedantic'])
- conf.env.append_value('CXXFLAGS',['-ansi','-Woverloaded-virtual','-Wnon-virtual-dtor'])
- append_cxx_flags('-Wall -Wextra -Wno-unused-parameter')
+ conf.env.append_value('CFLAGS',['-pedantic','-Wshadow'])
+ conf.env.append_value('CXXFLAGS',['-ansi','-Wnon-virtual-dtor','-Woverloaded-virtual'])
+ append_cxx_flags(['-Wall','-Wcast-align','-Wextra','-Wmissing-declarations','-Wno-unused-parameter','-Wstrict-overflow','-Wundef','-Wwrite-strings','-fstrict-overflow'])
+ if not conf.check_cc(fragment='''
+#ifndef __clang__
+#error
+#endif
+int main() { return 0; }''',features='c',mandatory=False,execute=False,msg='Checking for clang'):
+ append_cxx_flags(['-Wlogical-op','-Wsuggest-attribute=noreturn','-Wunsafe-loop-optimizations'])
if not conf.env['MSVC_COMPILER']:
- append_cxx_flags('-fshow-column')
+ append_cxx_flags(['-fshow-column'])
conf.env.prepend_value('CFLAGS','-I'+os.path.abspath('.'))
conf.env.prepend_value('CXXFLAGS','-I'+os.path.abspath('.'))
display_msg(conf,"Install prefix",conf.env['PREFIX'])
display_msg(conf,"Debuggable build",str(conf.env['DEBUG']))
- display_msg(conf,"Strict compiler flags",str(conf.env['STRICT']))
display_msg(conf,"Build documentation",str(conf.env['DOCS']))
print('')
g_step=2
+def set_c99_mode(conf):
+ if conf.env.MSVC_COMPILER:
+ conf.env.append_unique('CFLAGS',['-TP','-MD'])
+ else:
+ conf.env.append_unique('CFLAGS','-std=c99')
def set_local_lib(conf,name,has_objects):
var_name='HAVE_'+nameify(name.upper())
define(conf,var_name,1)
@@ -200,6 +231,27 @@ def use_lib(bld,obj,libs):
bld.env.prepend_value(f,inc_flag)
else:
append_property(obj,'uselib',' '+l)
+ at feature('c','cxx')
+ at before('apply_link')
+def version_lib(self):
+ if sys.platform=='win32':
+ self.vnum=None
+ if self.env['PARDEBUG']:
+ applicable=['cshlib','cxxshlib','cstlib','cxxstlib']
+ if[x for x in applicable if x in self.features]:
+ self.target=self.target+'D'
+def set_lib_env(conf,name,version):
+ 'Set up environment for local library as if found via pkg-config.'
+ NAME=name.upper()
+ major_ver=version.split('.')[0]
+ pkg_var_name='PKG_'+name.replace('-','_')
+ lib_name='%s-%s'%(name,major_ver)
+ if conf.env.PARDEBUG:
+ lib_name+='D'
+ conf.env[pkg_var_name]=lib_name
+ conf.env['INCLUDES_'+NAME]=['${INCLUDEDIR}/%s-%s'%(name,major_ver)]
+ conf.env['LIBPATH_'+NAME]=[conf.env.LIBDIR]
+ conf.env['LIB_'+NAME]=[lib_name]
def display_header(title):
Logs.pprint('BOLD',title)
def display_msg(conf,msg,status=None,color=None):
@@ -235,6 +287,8 @@ def build_pc(bld,name,version,version_suffix,libs,subst_dict={}):
target=name.lower()
if version_suffix!='':
target+='-'+version_suffix
+ if bld.env['PARDEBUG']:
+ target+='D'
target+='.pc'
libdir=bld.env['LIBDIR']
if libdir.startswith(pkg_prefix):
@@ -283,7 +337,7 @@ def make_simple_dox(name):
os.chdir(top)
except Exception ,e:
Logs.error("Failed to fix up %s documentation: %s"%(name,e))
-def build_dox(bld,name,version,srcdir,blddir):
+def build_dox(bld,name,version,srcdir,blddir,outdir=''):
if not bld.env['DOCS']:
return
if is_child():
@@ -298,7 +352,7 @@ def build_dox(bld,name,version,srcdir,blddir):
subst_tg.post()
docs=bld(features='doxygen',doxyfile='doc/reference.doxygen')
docs.post()
- bld.install_files('${DOCDIR}/%s/html'%name.lower(),bld.path.get_bld().ant_glob('doc/html/*'))
+ bld.install_files(os.path.join('${DOCDIR}',name.lower(),outdir,'html'),bld.path.get_bld().ant_glob('doc/html/*'))
for i in range(1,8):
bld.install_files('${MANDIR}/man%d'%i,bld.path.get_bld().ant_glob('doc/man/man%d/*'%i,excl='**/_*'))
def build_version_files(header_path,source_path,domain,major,minor,micro):
@@ -453,7 +507,7 @@ def run_ldconfig(ctx):
ctx.env['RAN_LDCONFIG']=True
except:
pass
-def write_news(name,in_files,out_file):
+def write_news(name,in_files,out_file,top_entries=None):
import rdflib
import textwrap
from time import strftime,strptime
@@ -480,10 +534,16 @@ def write_news(name,in_files,out_file):
date=m.value(release,doap.created,None)
blamee=m.value(release,dcs.blame,None)
changeset=m.value(release,dcs.changeset,None)
+ dist=m.value(release,doap['file-release'],None)
if revision and date and blamee and changeset:
entry='%s (%s) stable;\n'%(name,revision)
for i in m.triples([changeset,dcs.item,None]):
- entry+='\n * '+'\n '.join(textwrap.wrap(m.value(i[2],rdfs.label,None),width=79))
+ item=textwrap.wrap(m.value(i[2],rdfs.label,None),width=79)
+ entry+='\n * '+'\n '.join(item)
+ if dist and top_entries is not None:
+ if not str(dist)in top_entries:
+ top_entries[str(dist)]=[]
+ top_entries[str(dist)]+=['%s: %s'%(name,'\n '.join(item))]
entry+='\n\n --'
blamee_name=m.value(blamee,foaf.name,None)
blamee_mbox=m.value(blamee,foaf.mbox,None)
@@ -498,6 +558,3 @@ def write_news(name,in_files,out_file):
for e in sorted(entries.keys(),reverse=True):
news.write(entries[e])
news.close()
-
-feature('c','cxx')(include_config_h)
-after('apply_incpaths')(include_config_h)
\ No newline at end of file
diff --git a/waflib/extras/doxygen.py b/waflib/extras/doxygen.py
index 2fc9ddd..3e88c75 100644
--- a/waflib/extras/doxygen.py
+++ b/waflib/extras/doxygen.py
@@ -35,7 +35,10 @@ class doxygen(Task.Task):
if not self.pars.get('INPUT'):
self.pars['INPUT']=self.inputs[0].parent.abspath()
if not getattr(self,'output_dir',None):
- self.output_dir=self.generator.bld.root.find_dir(self.pars['OUTPUT_DIRECTORY'])
+ bld=self.generator.bld
+ self.output_dir=bld.root.find_dir(self.pars['OUTPUT_DIRECTORY'])
+ if not self.output_dir:
+ self.output_dir=bld.path.find_or_declare(self.pars['OUTPUT_DIRECTORY'])
self.signature()
return Task.Task.runnable_status(self)
def scan(self):
@@ -64,7 +67,7 @@ class doxygen(Task.Task):
code=code
cmd=Utils.subst_vars(DOXY_STR,self.env)
env=self.env.env or None
- proc=Utils.subprocess.Popen(cmd,shell=True,stdin=Utils.subprocess.PIPE,env=env)
+ proc=Utils.subprocess.Popen(cmd,shell=True,stdin=Utils.subprocess.PIPE,env=env,cwd=self.generator.bld.path.get_bld().abspath())
proc.communicate(code)
return proc.returncode
def post_run(self):
@@ -91,6 +94,7 @@ class tar(Task.Task):
def __str__(self):
tgt_str=' '.join([a.nice_path(self.env)for a in self.outputs])
return'%s: %s\n'%(self.__class__.__name__,tgt_str)
+ at feature('doxygen')
def process_doxy(self):
if not getattr(self,'doxyfile',None):
self.generator.bld.fatal('no doxyfile??')
@@ -113,5 +117,3 @@ def process_doxy(self):
def configure(conf):
conf.find_program('doxygen',var='DOXYGEN')
conf.find_program('tar',var='TAR')
-
-feature('doxygen')(process_doxy)
\ No newline at end of file
diff --git a/waflib/extras/swig.py b/waflib/extras/swig.py
index 1430019..181e23a 100644
--- a/waflib/extras/swig.py
+++ b/waflib/extras/swig.py
@@ -90,17 +90,21 @@ def swig_c(self):
self.outputs.append(out_node)
if not'-o'in self.env['SWIGFLAGS']:
self.env.append_value('SWIGFLAGS',['-o',self.outputs[0].abspath()])
+ at swigf
def swig_python(tsk):
tsk.set_outputs(tsk.inputs[0].parent.find_or_declare(tsk.module+'.py'))
+ at swigf
def swig_ocaml(tsk):
tsk.set_outputs(tsk.inputs[0].parent.find_or_declare(tsk.module+'.ml'))
tsk.set_outputs(tsk.inputs[0].parent.find_or_declare(tsk.module+'.mli'))
+ at extension(*SWIG_EXTS)
def i_file(self,node):
tsk=self.create_task('swig')
tsk.set_inputs(node)
tsk.module=getattr(self,'swig_module',None)
flags=self.to_list(getattr(self,'swig_flags',[]))
tsk.env.append_value('SWIGFLAGS',flags)
+ at conf
def check_swig_version(self):
reg_swig=re.compile(r'SWIG Version\s(.*)',re.M)
swig_out=self.cmd_and_log('%s -version'%self.env['SWIG'])
@@ -112,8 +116,3 @@ def check_swig_version(self):
def configure(conf):
swig=conf.find_program('swig',var='SWIG')
conf.env.SWIGPATH_ST='-I%s'
-
-swigf(swig_python)
-swigf(swig_ocaml)
-extension(*SWIG_EXTS)(i_file)
-conf(check_swig_version)
\ No newline at end of file
diff --git a/waflib/fixpy2.py b/waflib/fixpy2.py
index 2e6962b..98f7036 100644
--- a/waflib/fixpy2.py
+++ b/waflib/fixpy2.py
@@ -21,12 +21,16 @@ def modif(dir,name,fun):
return
filename=os.path.join(dir,name)
f=open(filename,'r')
- txt=f.read()
- f.close()
+ try:
+ txt=f.read()
+ finally:
+ f.close()
txt=fun(txt)
f=open(filename,'w')
- f.write(txt)
- f.close()
+ try:
+ f.write(txt)
+ finally:
+ f.close()
def subst(*k):
def do_subst(fun):
global all_modifs
@@ -37,14 +41,13 @@ def subst(*k):
all_modifs[x]=[fun]
return fun
return do_subst
+ at subst('*')
def r1(code):
code=code.replace(',e:',',e:')
code=code.replace("",'')
code=code.replace('','')
return code
+ at subst('Runner.py')
def r4(code):
code=code.replace('next(self.biter)','self.biter.next()')
return code
-
-subst('*')(r1)
-subst('Runner.py')(r4)
\ No newline at end of file
diff --git a/wscript b/wscript
index 3cf2bb4..1dc9778 100644
--- a/wscript
+++ b/wscript
@@ -2,33 +2,30 @@
import os
import subprocess
import sys
+import waflib.Options as Options
+import waflib.extras.autowaf as autowaf
-from waflib.extras import autowaf as autowaf
-import waflib.Logs as Logs, waflib.Options as Options
-
-# Version of this package (even if built as a child)
-SUIL_VERSION = '0.6.4'
-SUIL_MAJOR_VERSION = '0'
-
-# Library version (UNIX style major, minor, micro)
+# Library and package version (UNIX style major, minor, micro)
# major increment <=> incompatible changes
# minor increment <=> compatible changes (additions)
# micro increment <=> no interface changes
-# Suil uses the same version number for both library and package
-SUIL_LIB_VERSION = SUIL_VERSION
-
-# Variables for 'waf dist'
-APPNAME = 'suil'
-VERSION = SUIL_VERSION
+SUIL_VERSION = '0.6.6'
+SUIL_MAJOR_VERSION = '0'
-# Mandatory variables
-top = '.'
-out = 'build'
+# Mandatory waf variables
+APPNAME = 'suil' # Package name for waf dist
+VERSION = SUIL_VERSION # Package version for waf dist
+top = '.' # Source directory
+out = 'build' # Build directory
def options(opt):
opt.load('compiler_c')
opt.load('compiler_cxx')
autowaf.set_options(opt)
+ opt.add_option('--static', action='store_true', dest='static',
+ help="Build static library")
+ opt.add_option('--no-shared', action='store_true', dest='no_shared',
+ help='Do not build shared library')
opt.add_option('--gtk2-lib-name', type='string', dest='gtk2_lib_name',
default="libgtk-x11-2.0.so",
help="Gtk2 library name [Default: libgtk-x11-2.0.so]")
@@ -38,44 +35,64 @@ def configure(conf):
conf.load('compiler_cxx')
conf.line_just = 40
autowaf.configure(conf)
+ autowaf.set_c99_mode(conf)
autowaf.display_header('Suil Configuration')
- conf.env.append_unique('CFLAGS', '-std=c99')
+ conf.env.BUILD_SHARED = not Options.options.no_shared
+ conf.env.BUILD_STATIC = Options.options.static
+
+ if not conf.env.BUILD_SHARED and not conf.env.BUILD_STATIC:
+ conf.fatal('Neither a shared nor a static build requested')
+
+ conf.env.NODELETE_FLAGS = []
+ if (not conf.env.MSVC_COMPILER and
+ conf.check(linkflags = ['-Wl,-z,nodelete'],
+ msg = 'Checking for link flags -Wl,-z,-nodelete',
+ mandatory = False)):
+ conf.env.NODELETE_FLAGS = ['-Wl,-z,nodelete']
autowaf.check_pkg(conf, 'lv2', atleast_version='1.0.0', uselib_store='LV2')
autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK2',
atleast_version='2.18.0', mandatory=False)
- if not conf.env['HAVE_GTK2']:
+ if not conf.env.HAVE_GTK2:
autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK2',
atleast_version='2.0.0', mandatory=False)
- if conf.env['HAVE_GTK']:
+ if conf.env.HAVE_GTK:
autowaf.define('SUIL_OLD_GTK', 1)
+ autowaf.check_pkg(conf, 'gtk+-x11-2.0', uselib_store='GTK2_X11',
+ atleast_version='2.0.0', mandatory=False)
+
autowaf.check_pkg(conf, 'QtGui', uselib_store='QT4',
atleast_version='4.0.0', mandatory=False)
- conf.env['NODELETE_FLAGS'] = []
- if conf.check(linkflags = ['-Wl,-z,nodelete'],
- msg = 'Checking for link flags -Wl,-z,-nodelete',
- mandatory = False):
- conf.env['NODELETE_FLAGS'] = ['-Wl,-z,nodelete']
-
autowaf.define(conf, 'SUIL_VERSION', SUIL_VERSION)
autowaf.define(conf, 'SUIL_MODULE_DIR',
- conf.env['LIBDIR'] + '/suil-' + SUIL_MAJOR_VERSION)
+ conf.env.LIBDIR + '/suil-' + SUIL_MAJOR_VERSION)
autowaf.define(conf, 'SUIL_DIR_SEP', '/')
- autowaf.define(conf, 'SUIL_MODULE_EXT', '.so')
autowaf.define(conf, 'SUIL_GTK2_LIB_NAME', Options.options.gtk2_lib_name);
- conf.env['LIB_SUIL'] = ['suil-%s' % SUIL_MAJOR_VERSION]
+ module_prefix = ''
+ module_ext = ''
+ if conf.env.PARDEBUG:
+ module_ext += 'D'
+ if Options.platform == 'win32':
+ module_ext += '.dll'
+ else:
+ module_prefix = 'lib'
+ module_ext += '.so'
+ autowaf.define(conf, 'SUIL_MODULE_PREFIX', module_prefix)
+ autowaf.define(conf, 'SUIL_MODULE_EXT', module_ext)
+
+ autowaf.set_lib_env(conf, 'suil', SUIL_VERSION)
conf.write_config_header('suil_config.h', remove=False)
autowaf.display_msg(conf, "Gtk2 Support",
conf.is_defined('HAVE_GTK2'))
autowaf.display_msg(conf, "Gtk2 Library Name",
- conf.env['SUIL_GTK2_LIB_NAME'])
+ conf.env.SUIL_GTK2_LIB_NAME)
autowaf.display_msg(conf, "Qt4 Support",
conf.is_defined('HAVE_QT4'))
print('')
@@ -89,53 +106,91 @@ def build(bld):
autowaf.build_pc(bld, 'SUIL', SUIL_VERSION, SUIL_MAJOR_VERSION, [],
{'SUIL_MAJOR_VERSION' : SUIL_MAJOR_VERSION})
- cflags = [ '-DSUIL_SHARED', '-DSUIL_INTERNAL' ]
+ cflags = []
lib = []
- if sys.platform != 'win32':
- cflags += [ '-fvisibility=hidden' ]
- lib += [ 'dl' ]
+ modlib = []
+ if sys.platform == 'win32':
+ modlib += ['user32']
+ else:
+ cflags += ['-fvisibility=hidden']
+ lib += ['dl']
module_dir = '${LIBDIR}/suil-' + SUIL_MAJOR_VERSION
- # Library
- obj = bld(features = 'c cshlib',
- export_includes = ['.'],
- source = 'src/host.c src/instance.c',
- target = 'suil-%s' % SUIL_MAJOR_VERSION,
- includes = ['.'],
- name = 'libsuil',
- vnum = SUIL_LIB_VERSION,
- install_path = '${LIBDIR}',
- cflags = cflags,
- lib = lib,
- uselib = 'LV2')
+ # Shared Library
+ if bld.env.BUILD_SHARED:
+ obj = bld(features = 'c cshlib',
+ export_includes = ['.'],
+ source = 'src/host.c src/instance.c',
+ target = 'suil-%s' % SUIL_MAJOR_VERSION,
+ includes = ['.'],
+ defines = ['SUIL_SHARED', 'SUIL_INTERNAL'],
+ name = 'libsuil',
+ vnum = SUIL_VERSION,
+ install_path = '${LIBDIR}',
+ cflags = cflags,
+ lib = lib,
+ uselib = 'LV2')
+
+ # Static library
+ if bld.env.BUILD_STATIC:
+ obj = bld(features = 'c cstlib',
+ export_includes = ['.'],
+ source = 'src/host.c src/instance.c',
+ target = 'suil-%s' % SUIL_MAJOR_VERSION,
+ includes = ['.'],
+ defines = ['SUIL_INTERNAL'],
+ name = 'libsuil_static',
+ vnum = SUIL_VERSION,
+ install_path = '${LIBDIR}',
+ cflags = cflags,
+ lib = lib,
+ uselib = 'LV2')
if bld.is_defined('HAVE_GTK2') and bld.is_defined('HAVE_QT4'):
obj = bld(features = 'cxx cxxshlib',
source = 'src/gtk2_in_qt4.cpp',
target = 'suil_gtk2_in_qt4',
includes = ['.'],
+ defines = ['SUIL_SHARED', 'SUIL_INTERNAL'],
install_path = module_dir,
- cflags = cflags)
+ cflags = cflags,
+ lib = modlib)
autowaf.use_lib(bld, obj, 'GTK2 QT4 LV2')
obj = bld(features = 'cxx cxxshlib',
source = 'src/qt4_in_gtk2.cpp',
target = 'suil_qt4_in_gtk2',
includes = ['.'],
+ defines = ['SUIL_SHARED', 'SUIL_INTERNAL'],
install_path = module_dir,
cflags = cflags,
- linkflags = bld.env['NODELETE_FLAGS'])
+ lib = modlib,
+ linkflags = bld.env.NODELETE_FLAGS)
autowaf.use_lib(bld, obj, 'GTK2 QT4 LV2')
- if bld.is_defined('HAVE_GTK2'):
+ if bld.is_defined('HAVE_GTK2') and bld.is_defined('HAVE_GTK2_X11'):
obj = bld(features = 'c cshlib',
source = 'src/x11_in_gtk2.c',
target = 'suil_x11_in_gtk2',
includes = ['.'],
+ defines = ['SUIL_SHARED', 'SUIL_INTERNAL'],
+ install_path = module_dir,
+ cflags = cflags,
+ lib = modlib,
+ linkflags = bld.env.NODELETE_FLAGS)
+ autowaf.use_lib(bld, obj, 'GTK2 GTK2_X11 LV2')
+
+ if bld.is_defined('HAVE_GTK2') and sys.platform == 'win32':
+ obj = bld(features = 'cxx cxxshlib',
+ source = 'src/win_in_gtk2.cpp',
+ target = 'suil_win_in_gtk2',
+ includes = ['.'],
+ defines = ['SUIL_SHARED', 'SUIL_INTERNAL'],
install_path = module_dir,
cflags = cflags,
- linkflags = bld.env['NODELETE_FLAGS'])
+ lib = modlib,
+ linkflags = bld.env.NODELETE_FLAGS)
autowaf.use_lib(bld, obj, 'GTK2 LV2')
if bld.is_defined('HAVE_QT4'):
@@ -143,15 +198,17 @@ def build(bld):
source = 'src/x11_in_qt4.cpp',
target = 'suil_x11_in_qt4',
includes = ['.'],
+ defines = ['SUIL_SHARED', 'SUIL_INTERNAL'],
install_path = module_dir,
- cflags = cflags)
+ cflags = cflags,
+ lib = modlib)
autowaf.use_lib(bld, obj, 'QT4 LV2')
# Documentation
autowaf.build_dox(bld, 'SUIL', SUIL_VERSION, top, out)
bld.add_post_fun(autowaf.run_ldconfig)
- if bld.env['DOCS']:
+ if bld.env.DOCS:
bld.add_post_fun(fix_docs)
def fix_docs(ctx):
--
suil packaging
More information about the pkg-multimedia-commits
mailing list