Commit f318efc5 authored by Christian Hergert's avatar Christian Hergert Committed by Matthew Leeds
Browse files

build-manager: port to IdeBuildPipeline

This moves the build manager to use the new IdeBuildPipeline. We can drop
a bunch of things such as IdeBuildResult and IdeBuilder with this design.
parent 7b9075ea
......@@ -40,16 +40,12 @@ libide_1_0_la_public_headers = \
buildsystem/ide-build-stage-launcher.h \
buildsystem/ide-build-stage-mkdirs.h \
buildsystem/ide-build-stage-transfer.h \
buildsystem/ide-build-result-addin.h \
buildsystem/ide-build-result.h \
buildsystem/ide-build-system.h \
buildsystem/ide-build-target.h \
buildsystem/ide-builder.h \
buildsystem/ide-configuration-manager.h \
buildsystem/ide-configuration.h \
buildsystem/ide-environment-variable.h \
buildsystem/ide-environment.h \
buildsystem/ide-simple-builder.h \
devices/ide-device-manager.h \
devices/ide-device-provider.h \
devices/ide-device.h \
......@@ -215,16 +211,12 @@ libide_1_0_la_public_sources = \
buildsystem/ide-build-stage-launcher.c \
buildsystem/ide-build-stage-mkdirs.c \
buildsystem/ide-build-stage-transfer.c \
buildsystem/ide-build-result-addin.c \
buildsystem/ide-build-result.c \
buildsystem/ide-build-system.c \
buildsystem/ide-build-target.c \
buildsystem/ide-builder.c \
buildsystem/ide-configuration-manager.c \
buildsystem/ide-configuration.c \
buildsystem/ide-environment-variable.c \
buildsystem/ide-environment.c \
buildsystem/ide-simple-builder.c \
devices/ide-device-manager.c \
devices/ide-device-provider.c \
devices/ide-device.c \
......@@ -621,7 +613,6 @@ glib_enum_headers = \
buffers/ide-buffer.h \
buildsystem/ide-build-log.h \
buildsystem/ide-build-pipeline.h \
buildsystem/ide-build-result.h \
devices/ide-device.h \
diagnostics/ide-diagnostic.h \
doap/ide-doap.h \
......
This diff is collapsed.
......@@ -23,7 +23,7 @@
#include "ide-object.h"
#include "buildsystem/ide-builder.h"
#include "buildsystem/ide-build-pipeline.h"
G_BEGIN_DECLS
......@@ -31,27 +31,36 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (IdeBuildManager, ide_build_manager, IDE, BUILD_MANAGER, IdeObject)
gboolean ide_build_manager_get_busy (IdeBuildManager *self);
gchar *ide_build_manager_get_message (IdeBuildManager *self);
GDateTime *ide_build_manager_get_last_build_time (IdeBuildManager *self);
GTimeSpan ide_build_manager_get_running_time (IdeBuildManager *self);
void ide_build_manager_cancel (IdeBuildManager *self);
void ide_build_manager_build_async (IdeBuildManager *self,
IdeBuildTarget *build_target,
IdeBuilderBuildFlags build_flags,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean ide_build_manager_build_finish (IdeBuildManager *self,
GAsyncResult *result,
GError **error);
void ide_build_manager_install_async (IdeBuildManager *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean ide_build_manager_install_finish (IdeBuildManager *self,
GAsyncResult *result,
GError **error);
gboolean ide_build_manager_get_busy (IdeBuildManager *self);
gchar *ide_build_manager_get_message (IdeBuildManager *self);
GDateTime *ide_build_manager_get_last_build_time (IdeBuildManager *self);
GTimeSpan ide_build_manager_get_running_time (IdeBuildManager *self);
void ide_build_manager_cancel (IdeBuildManager *self);
IdeBuildPipeline *ide_build_manager_get_pipeline (IdeBuildManager *self);
void ide_build_manager_rebuild_async (IdeBuildManager *self,
IdeBuildPhase phase,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean ide_build_manager_rebuild_finish (IdeBuildManager *self,
GAsyncResult *result,
GError **error);
void ide_build_manager_execute_async (IdeBuildManager *self,
IdeBuildPhase phase,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean ide_build_manager_execute_finish (IdeBuildManager *self,
GAsyncResult *result,
GError **error);
void ide_build_manager_clean_async (IdeBuildManager *self,
IdeBuildPhase phase,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean ide_build_manager_clean_finish (IdeBuildManager *self,
GAsyncResult *result,
GError **error);
G_END_DECLS
......
/* ide-build-result-addin.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-build-result-addin.h"
G_DEFINE_INTERFACE (IdeBuildResultAddin, ide_build_result_addin, G_TYPE_OBJECT)
static void
ide_build_result_addin_real_load (IdeBuildResultAddin *self,
IdeBuildResult *result)
{
}
static void
ide_build_result_addin_real_unload (IdeBuildResultAddin *self,
IdeBuildResult *result)
{
}
static void
ide_build_result_addin_default_init (IdeBuildResultAddinInterface *iface)
{
iface->load = ide_build_result_addin_real_load;
iface->unload = ide_build_result_addin_real_unload;
}
void
ide_build_result_addin_load (IdeBuildResultAddin *self,
IdeBuildResult *result)
{
g_return_if_fail (IDE_IS_BUILD_RESULT_ADDIN (self));
g_return_if_fail (IDE_IS_BUILD_RESULT (result));
IDE_BUILD_RESULT_ADDIN_GET_IFACE (self)->load (self, result);
}
void
ide_build_result_addin_unload (IdeBuildResultAddin *self,
IdeBuildResult *result)
{
g_return_if_fail (IDE_IS_BUILD_RESULT_ADDIN (self));
g_return_if_fail (IDE_IS_BUILD_RESULT (result));
IDE_BUILD_RESULT_ADDIN_GET_IFACE (self)->unload (self, result);
}
/* ide-build-result-addin.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_BUILD_RESULT_ADDIN_H
#define IDE_BUILD_RESULT_ADDIN_H
#include "ide-build-result.h"
G_BEGIN_DECLS
#define IDE_TYPE_BUILD_RESULT_ADDIN (ide_build_result_addin_get_type ())
G_DECLARE_INTERFACE (IdeBuildResultAddin, ide_build_result_addin, IDE, BUILD_RESULT_ADDIN, GObject)
struct _IdeBuildResultAddinInterface
{
GTypeInterface parent;
void (*load) (IdeBuildResultAddin *self,
IdeBuildResult *result);
void (*unload) (IdeBuildResultAddin *self,
IdeBuildResult *result);
};
void ide_build_result_addin_load (IdeBuildResultAddin *self,
IdeBuildResult *result);
void ide_build_result_addin_unload (IdeBuildResultAddin *self,
IdeBuildResult *result);
G_END_DECLS
#endif /* IDE_BUILD_RESULT_ADDIN_H */
This diff is collapsed.
/* ide-build-result.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_BUILD_RESULT_H
#define IDE_BUILD_RESULT_H
#include <gio/gio.h>
#include "ide-object.h"
#include "diagnostics/ide-diagnostic.h"
G_BEGIN_DECLS
#define IDE_TYPE_BUILD_RESULT (ide_build_result_get_type())
G_DECLARE_DERIVABLE_TYPE (IdeBuildResult, ide_build_result, IDE, BUILD_RESULT, IdeObject)
typedef enum
{
IDE_BUILD_RESULT_LOG_STDOUT,
IDE_BUILD_RESULT_LOG_STDERR,
} IdeBuildResultLog;
struct _IdeBuildResultClass
{
IdeObjectClass parent;
void (*diagnostic) (IdeBuildResult *self,
IdeDiagnostic *diagnostic);
void (*log) (IdeBuildResult *self,
IdeBuildResultLog log,
const gchar *message);
gpointer _reserved1;
gpointer _reserved2;
gpointer _reserved3;
gpointer _reserved4;
gpointer _reserved5;
gpointer _reserved6;
gpointer _reserved7;
gpointer _reserved8;
};
GInputStream *ide_build_result_get_stdout_stream (IdeBuildResult *result);
GInputStream *ide_build_result_get_stderr_stream (IdeBuildResult *result);
void ide_build_result_log_subprocess (IdeBuildResult *result,
IdeSubprocess *subprocess);
GTimeSpan ide_build_result_get_running_time (IdeBuildResult *self);
gboolean ide_build_result_get_running (IdeBuildResult *self);
void ide_build_result_set_running (IdeBuildResult *self,
gboolean running);
gboolean ide_build_result_get_failed (IdeBuildResult *self);
void ide_build_result_set_failed (IdeBuildResult *self,
gboolean failed);
void ide_build_result_emit_diagnostic (IdeBuildResult *self,
IdeDiagnostic *diagnostic);
gchar *ide_build_result_get_mode (IdeBuildResult *self);
void ide_build_result_set_mode (IdeBuildResult *self,
const gchar *mode);
void ide_build_result_log_stdout (IdeBuildResult *result,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
void ide_build_result_log_stderr (IdeBuildResult *result,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
void ide_build_result_log_stdout_literal(IdeBuildResult *result,
const gchar *str);
void ide_build_result_log_stderr_literal(IdeBuildResult *result,
const gchar *str);
G_END_DECLS
#endif /* IDE_BUILD_RESULT_H */
......@@ -19,13 +19,13 @@
#define G_LOG_DOMAIN "ide-build-system"
#include "ide-context.h"
#include "ide-debug.h"
#include "ide-object.h"
#include "buildsystem/ide-build-system.h"
#include "buildsystem/ide-builder.h"
#include "buildsystem/ide-configuration.h"
#include "buildsystem/ide-configuration-manager.h"
#include "files/ide-file.h"
#include "projects/ide-project.h"
G_DEFINE_INTERFACE (IdeBuildSystem, ide_build_system, IDE_TYPE_OBJECT)
......@@ -53,27 +53,61 @@ ide_build_system_get_priority (IdeBuildSystem *self)
return 0;
}
static IdeBuilder *
ide_build_system_real_get_builder (IdeBuildSystem *self,
IdeConfiguration *configuration,
GError **error)
static void
ide_build_system_real_get_build_flags_async (IdeBuildSystem *self,
IdeFile *file,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_assert (IDE_IS_BUILD_SYSTEM (self));
g_assert (IDE_IS_CONFIGURATION (configuration));
g_task_report_new_error (self,
callback,
user_data,
ide_build_system_real_get_build_flags_async,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
"Fetching build flags is not supported");
}
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
"%s() is not supported on %s build system.",
G_STRFUNC, G_OBJECT_TYPE_NAME (self));
static gchar **
ide_build_system_real_get_build_flags_finish (IdeBuildSystem *self,
GAsyncResult *result,
GError **error)
{
return g_task_propagate_pointer (G_TASK (result), error);
}
return NULL;
static void
ide_build_system_real_get_build_targets_async (IdeBuildSystem *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_task_report_new_error (self,
callback,
user_data,
ide_build_system_real_get_build_targets_async,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
"Fetching build targets is not supported");
}
static GPtrArray *
ide_build_system_real_get_build_targets_finish (IdeBuildSystem *self,
GAsyncResult *result,
GError **error)
{
return g_task_propagate_pointer (G_TASK (result), error);
}
static void
ide_build_system_default_init (IdeBuildSystemInterface *iface)
{
iface->get_builder = ide_build_system_real_get_builder;
iface->get_build_flags_async = ide_build_system_real_get_build_flags_async;
iface->get_build_flags_finish = ide_build_system_real_get_build_flags_finish;
iface->get_build_targets_finish = ide_build_system_real_get_build_targets_finish;
iface->get_build_targets_async = ide_build_system_real_get_build_targets_async;
iface->get_build_targets_finish = ide_build_system_real_get_build_targets_finish;
properties [PROP_PROJECT_FILE] =
g_param_spec_object ("project-file",
......@@ -161,81 +195,6 @@ ide_build_system_new_finish (GAsyncResult *result,
return ret ? IDE_BUILD_SYSTEM (ret) : NULL;
}
/**
* ide_build_system_get_builder:
* @system: The #IdeBuildSystem to perform the build.
* @configuration: An #IdeConfiguration.
*
* This function returns an #IdeBuilder that can be used to perform a
* build of the project using the configuration specified.
*
* See ide_builder_build_async() for more information.
*
* Returns: (transfer full): An #IdeBuilder or %NULL and @error is set.
*/
IdeBuilder *
ide_build_system_get_builder (IdeBuildSystem *system,
IdeConfiguration *configuration,
GError **error)
{
IdeBuilder *ret;
g_return_val_if_fail (IDE_IS_BUILD_SYSTEM (system), NULL);
g_return_val_if_fail (IDE_IS_CONFIGURATION (configuration), NULL);
ret = IDE_BUILD_SYSTEM_GET_IFACE (system)->get_builder (system, configuration, error);
if (ret != NULL)
{
IdeContext *context;
context = ide_object_get_context (IDE_OBJECT (system));
ide_context_hold_for_object (context, ret);
}
return ret;
}
static IdeBuilder *
get_default_builder (IdeBuildSystem *self,
GError **error)
{
IdeConfigurationManager *config_manager;
IdeConfiguration *config;
IdeContext *context;
g_assert (IDE_IS_BUILD_SYSTEM (self));
context = ide_object_get_context (IDE_OBJECT (self));
g_assert (IDE_IS_CONTEXT (context));
config_manager = ide_context_get_configuration_manager (context);
g_assert (IDE_IS_CONFIGURATION_MANAGER (config_manager));
config = ide_configuration_manager_get_current (config_manager);
g_assert (IDE_IS_CONFIGURATION (config));
return ide_build_system_get_builder (IDE_BUILD_SYSTEM (self), config, error);
}
static void
ide_build_system_get_build_flags_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
IdeBuilder *builder = (IdeBuilder *)object;
g_autoptr(GTask) task = user_data;
g_autoptr(GError) error = NULL;
g_auto(GStrv) flags = NULL;
g_assert (IDE_IS_BUILDER (builder));
if (NULL == (flags = ide_builder_get_build_flags_finish (builder, result, &error)))
g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_pointer (task, g_steal_pointer (&flags), (GDestroyNotify)g_strfreev);
}
void
ide_build_system_get_build_flags_async (IdeBuildSystem *self,
IdeFile *file,
......@@ -243,28 +202,15 @@ ide_build_system_get_build_flags_async (IdeBuildSystem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
g_autoptr(IdeBuilder) builder = NULL;
g_autoptr(GError) error = NULL;
IDE_ENTRY;
g_return_if_fail (IDE_IS_BUILD_SYSTEM (self));
g_return_if_fail (IDE_IS_FILE (file));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, ide_build_system_get_build_flags_async);
IDE_BUILD_SYSTEM_GET_IFACE (self)->get_build_flags_async (self, file, cancellable, callback, user_data);
if (NULL == (builder = get_default_builder (self, &error)))
{
g_task_return_error (task, g_steal_pointer (&error));
return;
}
ide_builder_get_build_flags_async (builder,
file,
cancellable,
ide_build_system_get_build_flags_cb,
g_steal_pointer (&task));
IDE_EXIT;
}
/**
......@@ -277,28 +223,16 @@ ide_build_system_get_build_flags_finish (IdeBuildSystem *self,
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (IDE_IS_BUILD_SYSTEM (self), NULL);
g_return_val_if_fail (G_IS_TASK (result), NULL);
gchar **ret;
return g_task_propagate_pointer (G_TASK (result), error);
}
IDE_ENTRY;
static void
ide_build_system_get_build_targets_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
IdeBuilder *builder = (IdeBuilder *)object;
g_autoptr(GTask) task = user_data;
g_autoptr(GPtrArray) targets = NULL;
g_autoptr(GError) error = NULL;
g_return_val_if_fail (IDE_IS_BUILD_SYSTEM (self), NULL);
g_return_val_if_fail (G_IS_TASK (result), NULL);
g_assert (IDE_IS_BUILDER (builder));
ret = IDE_BUILD_SYSTEM_GET_IFACE (self)->get_build_flags_finish (self, result, error);
if (NULL == (targets = ide_builder_get_build_targets_finish (builder, result, &error)))
g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_pointer (task, g_steal_pointer (&targets), (GDestroyNotify)g_ptr_array_unref);
IDE_RETURN (ret);
}
void
......@@ -307,26 +241,14 @@ ide_build_system_get_build_targets_async (IdeBuildSystem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
g_autoptr(IdeBuilder) builder = NULL;
g_autoptr(GError) error = NULL;
IDE_ENTRY;
g_return_if_fail (IDE_IS_BUILD_SYSTEM (self));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, ide_build_system_get_build_targets_async);
if (NULL == (builder = get_default_builder (self, &error)))
{
g_task_return_error (task, g_steal_pointer (&error));
return;
}
IDE_BUILD_SYSTEM_GET_IFACE (self)->get_build_targets_async (self, cancellable, callback, user_data);
ide_builder_get_build_targets_async (builder,
cancellable,
ide_build_system_get_build_targets_cb,
g_steal_pointer (&task));
IDE_EXIT;
}
/**
......@@ -340,8 +262,58 @@ ide_build_system_get_build_targets_finish (IdeBuildSystem *self,
GAsyncResult *result,
GError **error)
{
GPtrArray *ret;
IDE_ENTRY;
g_return_val_if_fail (IDE_IS_BUILD_SYSTEM (self), NULL);
g_return_val_if_fail (G_IS_TASK (result), NULL);
return g_task_propagate_pointer (G_TASK (result), error);
ret = IDE_BUILD_SYSTEM_GET_IFACE (self)->get_build_targets_finish (self, result, error);
IDE_RETURN (ret);
}
gchar *
ide_build_system_get_builddir (IdeBuildSystem *self,
IdeConfiguration *configuration)
{
gchar *ret = NULL;
IDE_ENTRY;
g_return_val_if_fail (IDE_IS_BUILD_SYSTEM (self), NULL);
g_return_val_if_fail (IDE_IS_CONFIGURATION (configuration), NULL);
if (IDE_BUILD_SYSTEM_GET_IFACE (self)->get_builddir)
ret = IDE_BUILD_SYSTEM_GET_IFACE (self)->get_builddir (self, configuration);
if (ret == NULL)
{
g_autofree gchar *name = NULL;