[gnome-builder] mingw: add mingw device provider and device implementation
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] mingw: add mingw device provider and device implementation
- Date: Fri, 24 Apr 2015 00:07:45 +0000 (UTC)
commit b39ef5063494c372272b402de111fa86969ccd42
Author: Christian Hergert <christian hergert me>
Date: Thu Apr 23 17:05:45 2015 -0700
mingw: add mingw device provider and device implementation
This is pretty bare bones, but get's things started.
./ide-list-devices should show you additional devices if you have various
mingw installations.
libide/Makefile.am | 5 +
libide/ide.c | 6 ++
libide/mingw/ide-mingw-device-provider.c | 135 ++++++++++++++++++++++++++++++
libide/mingw/ide-mingw-device-provider.h | 33 +++++++
libide/mingw/ide-mingw-device.c | 82 ++++++++++++++++++
libide/mingw/ide-mingw-device.h | 37 ++++++++
6 files changed, 298 insertions(+), 0 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index 7920d6f..661c2b6 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -193,6 +193,10 @@ libide_1_0_la_public_sources = \
libide/ide.h \
libide/local/ide-local-device.c \
libide/local/ide-local-device.h \
+ libide/mingw/ide-mingw-device.c \
+ libide/mingw/ide-mingw-device.h \
+ libide/mingw/ide-mingw-device-provider.c \
+ libide/mingw/ide-mingw-device-provider.h \
libide/pygobject/ide-pygobject-script.c \
libide/pygobject/ide-pygobject-script.h \
libide/python/ide-python-indenter.c \
@@ -318,6 +322,7 @@ libide_1_0_la_includes = \
-I$(top_srcdir)/libide/gsettings \
-I$(top_srcdir)/libide/html \
-I$(top_srcdir)/libide/local \
+ -I$(top_srcdir)/libide/mingw \
-I$(top_srcdir)/libide/modelines \
-I$(top_srcdir)/libide/pygobject \
-I$(top_srcdir)/libide/python \
diff --git a/libide/ide.c b/libide/ide.c
index 8885491..af76811 100644
--- a/libide/ide.c
+++ b/libide/ide.c
@@ -39,6 +39,7 @@
#include "ide-gjs-script.h"
#include "ide-gsettings-file-settings.h"
#include "ide-html-language.h"
+#include "ide-mingw-device-provider.h"
#include "ide-internal.h"
#include "ide-project-miner.h"
#include "ide-pygobject-script.h"
@@ -108,6 +109,11 @@ ide_init_ctor (void)
IDE_BUILD_SYSTEM_EXTENSION_POINT".directory",
-200);
+ g_io_extension_point_implement (IDE_DEVICE_PROVIDER_EXTENSION_POINT,
+ IDE_TYPE_MINGW_DEVICE_PROVIDER,
+ IDE_BUILD_SYSTEM_EXTENSION_POINT".mingw",
+ 0);
+
g_io_extension_point_implement (IDE_FILE_SETTINGS_EXTENSION_POINT,
IDE_TYPE_EDITORCONFIG_FILE_SETTINGS,
IDE_FILE_SETTINGS_EXTENSION_POINT".editorconfig",
diff --git a/libide/mingw/ide-mingw-device-provider.c b/libide/mingw/ide-mingw-device-provider.c
new file mode 100644
index 0000000..7b0a77a
--- /dev/null
+++ b/libide/mingw/ide-mingw-device-provider.c
@@ -0,0 +1,135 @@
+/* ide-mingw-device-provider.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "ide-context.h"
+#include "ide-mingw-device.h"
+#include "ide-mingw-device-provider.h"
+
+struct _IdeMingwDeviceProvider
+{
+ IdeDeviceProvider parent_instance;
+};
+
+G_DEFINE_TYPE (IdeMingwDeviceProvider, ide_mingw_device_provider, IDE_TYPE_DEVICE_PROVIDER)
+
+static void
+ide_mingw_device_provider_discover_worker (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
+{
+ IdeMingwDeviceProvider *self = source_object;
+ GPtrArray *devices;
+ IdeContext *context;
+
+ g_assert (G_IS_TASK (task));
+ g_assert (IDE_IS_MINGW_DEVICE_PROVIDER (self));
+
+ devices = g_ptr_array_new_with_free_func (g_object_unref);
+
+ context = ide_object_get_context (IDE_OBJECT (self));
+
+ g_assert (IDE_IS_CONTEXT (context));
+
+ /*
+ * FIXME:
+ *
+ * I'm almost certain this is not the proper way to check for mingw support.
+ * Someone that knows how this works, please fix this up!
+ */
+
+ if (g_file_test ("/usr/bin/x86_64-w64-mingw32-gcc", G_FILE_TEST_EXISTS))
+ {
+ IdeDevice *device;
+
+ /* add 64-bit mingw device */
+ device = ide_mingw_device_new (context,
+ _("MinGW (64-bit)"),
+ "local-i686-w64-mingw32",
+ "i686-w64-mingw32");
+ g_ptr_array_add (devices, device);
+ }
+
+ if (g_file_test ("/usr/bin/i686-w64-mingw32-gcc", G_FILE_TEST_EXISTS))
+ {
+ IdeDevice *device;
+
+ /* add 32-bit mingw device */
+ device = ide_mingw_device_new (context,
+ _("MinGW (32-bit)"),
+ "local-i686-w64-mingw32",
+ "i686-w64-mingw32");
+ g_ptr_array_add (devices, device);
+ }
+
+ g_task_return_pointer (task, devices, (GDestroyNotify)g_ptr_array_unref);
+}
+
+static void
+load_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ IdeMingwDeviceProvider *self = (IdeMingwDeviceProvider *)object;
+ GTask *task = (GTask *)result;
+ g_autoptr(GPtrArray) devices = NULL;
+ gsize i;
+
+ g_assert (IDE_IS_MINGW_DEVICE_PROVIDER (self));
+ g_assert (G_IS_TASK (task));
+
+ devices = g_task_propagate_pointer (task, NULL);
+
+ if (devices)
+ {
+ for (i = 0; i < devices->len; i++)
+ {
+ IdeDevice *device;
+
+ device = g_ptr_array_index (devices, i);
+ ide_device_provider_device_added (IDE_DEVICE_PROVIDER (self), device);
+ }
+ }
+}
+
+static void
+ide_mingw_device_provider_constructed (GObject *object)
+{
+ IdeMingwDeviceProvider *self = (IdeMingwDeviceProvider *)object;
+ g_autoptr(GTask) task = NULL;
+
+ g_assert (IDE_IS_MINGW_DEVICE_PROVIDER (self));
+
+ task = g_task_new (self, NULL, load_cb, NULL);
+ g_task_run_in_thread (task, ide_mingw_device_provider_discover_worker);
+}
+
+static void
+ide_mingw_device_provider_class_init (IdeMingwDeviceProviderClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructed = ide_mingw_device_provider_constructed;
+}
+
+static void
+ide_mingw_device_provider_init (IdeMingwDeviceProvider *self)
+{
+}
diff --git a/libide/mingw/ide-mingw-device-provider.h b/libide/mingw/ide-mingw-device-provider.h
new file mode 100644
index 0000000..0a7b929
--- /dev/null
+++ b/libide/mingw/ide-mingw-device-provider.h
@@ -0,0 +1,33 @@
+/* ide-mingw-device-provider.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_MINGW_DEVICE_PROVIDER_H
+#define IDE_MINGW_DEVICE_PROVIDER_H
+
+#include "ide-device-provider.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_MINGW_DEVICE_PROVIDER (ide_mingw_device_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeMingwDeviceProvider,ide_mingw_device_provider, IDE, MINGW_DEVICE_PROVIDER,
+ IdeDeviceProvider)
+
+G_END_DECLS
+
+#endif /* IDE_MINGW_DEVICE_PROVIDER_H */
diff --git a/libide/mingw/ide-mingw-device.c b/libide/mingw/ide-mingw-device.c
new file mode 100644
index 0000000..4320946
--- /dev/null
+++ b/libide/mingw/ide-mingw-device.c
@@ -0,0 +1,82 @@
+/* ide-mingw-device.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ide-mingw-device.h"
+
+struct _IdeMingwDevice
+{
+ IdeDevice parent_instance;
+ gchar *system_type;
+};
+
+G_DEFINE_TYPE (IdeMingwDevice, ide_mingw_device, IDE_TYPE_DEVICE)
+
+IdeDevice *
+ide_mingw_device_new (IdeContext *context,
+ const gchar *display_name,
+ const gchar *id,
+ const gchar *system_type)
+{
+ IdeMingwDevice *self;
+
+ self = g_object_new (IDE_TYPE_MINGW_DEVICE,
+ "context", context,
+ "display-name", display_name,
+ "id", system_type,
+ NULL);
+
+ self->system_type = g_strdup (system_type);
+
+ return IDE_DEVICE (self);
+}
+
+static const gchar *
+ide_mingw_device_get_system_type (IdeDevice *device)
+{
+ IdeMingwDevice *self = (IdeMingwDevice *)device;
+
+ g_assert (IDE_IS_MINGW_DEVICE (self));
+
+ return self->system_type;
+}
+
+static void
+ide_mingw_device_finalize (GObject *object)
+{
+ IdeMingwDevice *self = (IdeMingwDevice *)object;
+
+ g_clear_pointer (&self->system_type, g_free);
+
+ G_OBJECT_CLASS (ide_mingw_device_parent_class)->finalize (object);
+}
+
+static void
+ide_mingw_device_class_init (IdeMingwDeviceClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ IdeDeviceClass *device_class = IDE_DEVICE_CLASS (klass);
+
+ object_class->finalize = ide_mingw_device_finalize;
+
+ device_class->get_system_type = ide_mingw_device_get_system_type;
+}
+
+static void
+ide_mingw_device_init (IdeMingwDevice *self)
+{
+}
diff --git a/libide/mingw/ide-mingw-device.h b/libide/mingw/ide-mingw-device.h
new file mode 100644
index 0000000..80803f1
--- /dev/null
+++ b/libide/mingw/ide-mingw-device.h
@@ -0,0 +1,37 @@
+/* ide-mingw-device.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_MINGW_DEVICE_H
+#define IDE_MINGW_DEVICE_H
+
+#include "ide-device.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_MINGW_DEVICE (ide_mingw_device_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeMingwDevice, ide_mingw_device, IDE, MINGW_DEVICE, IdeDevice)
+
+IdeDevice *ide_mingw_device_new (IdeContext *context,
+ const gchar *display_name,
+ const gchar *id,
+ const gchar *system_type);
+
+G_END_DECLS
+
+#endif /* IDE_MINGW_DEVICE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]