Commit bf72f25d authored by Corentin Noël's avatar Corentin Noël

toolchain: add the IdeToolchain object

parent 2c341158
......@@ -209,6 +209,7 @@ ide_buildconfig_configuration_provider_create (IdeBuildconfigConfigurationProvid
load_string (config, self->key_file, config_id, "name", "display-name");
load_string (config, self->key_file, config_id, "run-opts", "run-opts");
load_string (config, self->key_file, config_id, "runtime", "runtime-id");
load_string (config, self->key_file, config_id, "toolchain", "toolchain-id");
load_string (config, self->key_file, config_id, "prefix", "prefix");
load_string (config, self->key_file, config_id, "app-id", "app-id");
load_strv (config, self->key_file, config_id, "prebuild", "prebuild");
......@@ -296,6 +297,7 @@ add_default:
"display-name", "Default",
"id", "default",
"runtime-id", "host",
"toolchain-id", "default",
NULL);
ide_configuration_set_dirty (fallback, FALSE);
ide_configuration_provider_emit_added (provider, fallback);
......@@ -426,6 +428,7 @@ ide_buildconfig_configuration_provider_save_async (IdeConfigurationProvider *pro
PERSIST_STRING_KEY ("name", get_display_name);
PERSIST_STRING_KEY ("runtime", get_runtime_id);
PERSIST_STRING_KEY ("toolchain", get_toolchain_id);
PERSIST_STRING_KEY ("config-opts", get_config_opts);
PERSIST_STRING_KEY ("run-opts", get_run_opts);
PERSIST_STRING_KEY ("prefix", get_prefix);
......@@ -590,6 +593,7 @@ ide_buildconfig_configuration_provider_delete (IdeConfigurationProvider *provide
"display-name", "Default",
"id", "default",
"runtime-id", "host",
"toolchain-id", "default",
NULL);
/*
......
......@@ -41,6 +41,8 @@
#include "runtimes/ide-runtime-manager.h"
#include "runtimes/ide-runtime-private.h"
#include "threading/ide-task.h"
#include "toolchain/ide-toolchain-manager.h"
#include "toolchain/ide-toolchain-private.h"
#include "vcs/ide-vcs.h"
/**
......@@ -327,11 +329,11 @@ ide_build_manager_pipeline_finished (IdeBuildManager *self,
}
static void
ide_build_manager_ensure_runtime_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
ide_build_manager_ensure_toolchain_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
IdeRuntimeManager *runtime_manager = (IdeRuntimeManager *)object;
IdeToolchainManager *toolchain_manager = (IdeToolchainManager *)object;
g_autoptr(GError) error = NULL;
g_autoptr(IdeTask) task = user_data;
IdeBuildPipeline *pipeline;
......@@ -340,7 +342,7 @@ ide_build_manager_ensure_runtime_cb (GObject *object,
IDE_ENTRY;
g_assert (IDE_IS_RUNTIME_MANAGER (runtime_manager));
g_assert (IDE_IS_TOOLCHAIN_MANAGER (toolchain_manager));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (IDE_IS_TASK (task));
......@@ -350,9 +352,9 @@ ide_build_manager_ensure_runtime_cb (GObject *object,
g_assert (IDE_IS_BUILD_MANAGER (self));
g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
if (!_ide_runtime_manager_prepare_finish (runtime_manager, result, &error))
if (!_ide_toolchain_manager_prepare_finish (toolchain_manager, result, &error))
{
g_message ("Failed to prepare runtime: %s", error->message);
g_message ("Failed to prepare toolchain: %s", error->message);
IDE_GOTO (failure);
}
......@@ -382,6 +384,72 @@ ide_build_manager_ensure_runtime_cb (GObject *object,
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PIPELINE]);
ide_task_return_boolean (task, TRUE);
IDE_EXIT;
failure:
if (error != NULL)
ide_task_return_error (task, g_steal_pointer (&error));
else
ide_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_FAILED,
"Failed to setup build pipeline");
IDE_EXIT;
}
static void
ide_build_manager_ensure_runtime_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
IdeRuntimeManager *runtime_manager = (IdeRuntimeManager *)object;
g_autoptr(GError) error = NULL;
g_autoptr(IdeTask) task = user_data;
IdeBuildPipeline *pipeline;
IdeBuildManager *self;
IdeToolchainManager *toolchain_manager;
IdeContext *context;
IDE_ENTRY;
g_assert (IDE_IS_RUNTIME_MANAGER (runtime_manager));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (IDE_IS_TASK (task));
self = ide_task_get_source_object (task);
pipeline = ide_task_get_task_data (task);
g_assert (IDE_IS_BUILD_MANAGER (self));
g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
if (!_ide_runtime_manager_prepare_finish (runtime_manager, result, &error))
{
g_message ("Failed to prepare runtime: %s", error->message);
IDE_GOTO (failure);
}
if (pipeline != self->pipeline)
{
IDE_TRACE_MSG ("pipeline is no longer active, ignoring");
IDE_GOTO (failure);
}
if (ide_task_return_error_if_cancelled (task))
IDE_GOTO (failure);
context = ide_object_get_context (IDE_OBJECT (pipeline));
g_assert (IDE_IS_CONTEXT (context));
toolchain_manager = ide_context_get_toolchain_manager (context);
g_assert (IDE_IS_TOOLCHAIN_MANAGER (toolchain_manager));
_ide_toolchain_manager_prepare_async (toolchain_manager,
pipeline,
ide_task_get_cancellable (task),
ide_build_manager_ensure_toolchain_cb,
g_object_ref (task));
IDE_EXIT;
......@@ -435,7 +503,7 @@ ide_build_manager_device_get_info_cb (GObject *object,
IDE_EXIT;
}
_ide_build_pipeline_set_device_info (pipeline, info);
_ide_build_pipeline_check_toolchain (pipeline, info);
_ide_runtime_manager_prepare_async (runtime_manager,
pipeline,
......
......@@ -50,6 +50,8 @@
#include "projects/ide-project.h"
#include "runtimes/ide-runtime.h"
#include "terminal/ide-terminal-util.h"
#include "toolchain/ide-toolchain-manager.h"
#include "toolchain/ide-toolchain.h"
#include "util/ide-line-reader.h"
#include "util/ide-posix.h"
#include "util/ptyintercept.h"
......@@ -158,6 +160,13 @@ struct _IdeBuildPipeline
*/
IdeRuntime *runtime;
/*
* The toolchain we're using to build. This may be different than what
* is specified in the IdeConfiguration, as the @device could alter
* what architecture we're building for (and/or cross-compiling).
*/
IdeToolchain *toolchain;
/*
* The IdeBuildLog is a private implementation that we use to
* log things from addins via observer callbacks.
......@@ -172,13 +181,6 @@ struct _IdeBuildPipeline
gchar *builddir;
gchar *srcdir;
/*
* This is some general information about our build device that
* the pipeline addins may want to use to tweak how the execute
* the build.
*/
IdeTriplet *host_triplet;
/*
* This is an array of PipelineEntry, which contain information we
* need about the stage and an identifier that addins can use to
......@@ -1172,35 +1174,6 @@ ide_build_pipeline_load (IdeBuildPipeline *self)
IDE_EXIT;
}
void
_ide_build_pipeline_set_device_info (IdeBuildPipeline *self,
IdeDeviceInfo *info)
{
IdeTriplet *triplet;
IDE_ENTRY;
g_assert (IDE_IS_BUILD_PIPELINE (self));
g_assert (IDE_IS_DEVICE_INFO (info));
triplet = ide_device_info_get_host_triplet (info);
if (triplet != self->host_triplet)
{
g_clear_pointer (&self->host_triplet, ide_triplet_unref);
self->host_triplet = triplet ? ide_triplet_ref (triplet) : NULL;
}
if (self->host_triplet == NULL)
self->host_triplet = ide_triplet_new_from_system ();
g_debug ("Pipeline [%p] host is now %s",
self,
ide_triplet_get_full_name (self->host_triplet));
IDE_EXIT;
}
static void
ide_build_pipeline_load_get_info_cb (GObject *object,
GAsyncResult *result,
......@@ -1226,7 +1199,7 @@ ide_build_pipeline_load_get_info_cb (GObject *object,
if (g_cancellable_is_cancelled (self->cancellable))
IDE_EXIT;
_ide_build_pipeline_set_device_info (self, info);
_ide_build_pipeline_check_toolchain (self, info);
ide_build_pipeline_load (self);
}
......@@ -1243,7 +1216,8 @@ ide_build_pipeline_begin_load (IdeBuildPipeline *self)
* The first thing we need to do is get some information from the
* configured device. We want to know the arch/kernel/system triplet
* for the device as some pipeline addins may need that. We can also
* use that to ensure that we load the proper runtime for the device.
* use that to ensure that we load the proper runtime and toolchain
* for the device.
*
* We have to load this information asynchronously, as the device might
* be remote (and we need to connect to it to get the information).
......@@ -1322,9 +1296,9 @@ ide_build_pipeline_finalize (GObject *object)
g_clear_object (&self->log);
g_clear_object (&self->device);
g_clear_object (&self->runtime);
g_clear_object (&self->toolchain);
g_clear_object (&self->configuration);
g_clear_pointer (&self->pipeline, g_array_unref);
g_clear_pointer (&self->host_triplet, ide_triplet_unref);
g_clear_pointer (&self->srcdir, g_free);
g_clear_pointer (&self->builddir, g_free);
g_clear_pointer (&self->errfmts, g_array_unref);
......@@ -1442,6 +1416,7 @@ ide_build_pipeline_constructed (GObject *object)
IdeContext *context;
IdeVcs *vcs;
GFile *workdir;
IdeToolchainManager *toolchain_manager;
IDE_ENTRY;
......@@ -1455,6 +1430,8 @@ ide_build_pipeline_constructed (GObject *object)
self->srcdir = g_file_get_path (workdir);
toolchain_manager = ide_context_get_toolchain_manager (context);
self->toolchain = ide_toolchain_manager_get_toolchain (toolchain_manager, "default");
IDE_EXIT;
}
......@@ -2729,6 +2706,24 @@ ide_build_pipeline_get_runtime (IdeBuildPipeline *self)
return self->runtime;
}
/**
* ide_build_pipeline_get_toolchain:
* @self: An #IdeBuildPipeline
*
* A convenience function to get the toolchain for a build pipeline.
*
* Returns: (transfer none): An #IdeToolchain
*
* Since: 3.30
*/
IdeToolchain *
ide_build_pipeline_get_toolchain (IdeBuildPipeline *self)
{
g_return_val_if_fail (IDE_IS_BUILD_PIPELINE (self), NULL);
return self->toolchain;
}
/**
* ide_build_pipeline_create_launcher:
* @self: An #IdeBuildPipeline
......@@ -3757,63 +3752,73 @@ _ide_build_pipeline_set_runtime (IdeBuildPipeline *self,
}
}
/**
* ide_build_pipeline_get_device:
* @self: a #IdeBuildPipeline
*
* Gets the device that the pipeline is building for.
*
* Returns: (transfer none): an #IdeDevice.
*
* Since: 3.28
*/
IdeDevice *
ide_build_pipeline_get_device (IdeBuildPipeline *self)
void
_ide_build_pipeline_set_toolchain (IdeBuildPipeline *self,
IdeToolchain *toolchain)
{
g_return_val_if_fail (IDE_IS_BUILD_PIPELINE (self), NULL);
g_return_if_fail (IDE_IS_BUILD_PIPELINE (self));
g_return_if_fail (!toolchain || IDE_IS_TOOLCHAIN (toolchain));
return self->device;
if (g_set_object (&self->toolchain, toolchain))
ide_configuration_set_toolchain (self->configuration, toolchain);
}
/**
* ide_build_pipeline_get_host_triplet:
* @self: a #IdeBuildPipeline
*
* Gets the architecture, kernel, and system that the pipeline is building for,
* once that has been discovered from the device.
*
* Returns: (nullable) (transfer full): an #IdeTriplet describing the system
* where the compiled application will run, or %NULL if that is not yet
* known.
*
* Since: 3.30
*/
IdeTriplet *
ide_build_pipeline_get_host_triplet (IdeBuildPipeline *self)
void
_ide_build_pipeline_check_toolchain (IdeBuildPipeline *self,
IdeDeviceInfo *info)
{
g_return_val_if_fail (IDE_IS_BUILD_PIPELINE (self), NULL);
g_autoptr(IdeToolchain) toolchain = NULL;
g_autoptr(IdeTriplet) toolchain_triplet = NULL;
IdeContext *context;
IdeRuntime *runtime;
IdeTriplet *device_triplet;
IdeToolchainManager *toolchain_manager;
g_return_if_fail (IDE_IS_BUILD_PIPELINE (self));
g_return_if_fail (IDE_IS_DEVICE_INFO (info));
context = ide_object_get_context (IDE_OBJECT (self));
g_return_if_fail (IDE_IS_CONTEXT (context));
toolchain_manager = ide_context_get_toolchain_manager (context);
g_return_if_fail (IDE_IS_TOOLCHAIN_MANAGER (toolchain_manager));
/* Don't try to initialize too early */
if (ide_toolchain_manager_is_loaded (toolchain_manager))
return;
return ide_triplet_ref (self->host_triplet);
toolchain = ide_configuration_get_toolchain (self->configuration);
runtime = ide_configuration_get_runtime (self->configuration);
device_triplet = ide_device_info_get_host_triplet (info);
toolchain_triplet = ide_toolchain_get_host_triplet (toolchain);
// TODO fallback to the most compatible toolchain instead of the default one
if (toolchain == NULL ||
g_strcmp0 (ide_triplet_get_arch (device_triplet), ide_triplet_get_arch (toolchain_triplet)) != 0 ||
!ide_runtime_supports_toolchain (runtime, toolchain))
{
g_autoptr(IdeToolchain) default_toolchain = ide_toolchain_manager_get_toolchain (toolchain_manager, "default");
_ide_build_pipeline_set_toolchain (self, default_toolchain);
}
}
/**
* ide_build_pipeline_is_native:
* ide_build_pipeline_get_device:
* @self: a #IdeBuildPipeline
*
* Checks to see if the pipeline is building for the native architecture,
* kernel, and system of the host.
* Gets the device that the pipeline is building for.
*
* This is equivalent to checking if ide_get_system_type() matches the
* device-triplet property of the pipeline.
* Returns: (transfer none): an #IdeDevice.
*
* Returns: %TRUE if this is a native build, otherwise %FALSE
* Since: 3.28
*/
gboolean
ide_build_pipeline_is_native (IdeBuildPipeline *self)
IdeDevice *
ide_build_pipeline_get_device (IdeBuildPipeline *self)
{
g_return_val_if_fail (IDE_IS_BUILD_PIPELINE (self), FALSE);
g_return_val_if_fail (IDE_IS_BUILD_PIPELINE (self), NULL);
return ide_triplet_is_system (self->host_triplet);
return self->device;
}
/**
......
......@@ -69,12 +69,12 @@ IDE_AVAILABLE_IN_3_28
IdeDevice *ide_build_pipeline_get_device (IdeBuildPipeline *self);
IDE_AVAILABLE_IN_3_28
IdeRuntime *ide_build_pipeline_get_runtime (IdeBuildPipeline *self);
IDE_AVAILABLE_IN_3_30
IdeToolchain *ide_build_pipeline_get_toolchain (IdeBuildPipeline *self);
IDE_AVAILABLE_IN_ALL
const gchar *ide_build_pipeline_get_builddir (IdeBuildPipeline *self);
IDE_AVAILABLE_IN_ALL
const gchar *ide_build_pipeline_get_srcdir (IdeBuildPipeline *self);
IDE_AVAILABLE_IN_3_30
IdeTriplet *ide_build_pipeline_get_host_triplet (IdeBuildPipeline *self);
IDE_AVAILABLE_IN_ALL
gchar *ide_build_pipeline_get_message (IdeBuildPipeline *self);
IDE_AVAILABLE_IN_ALL
......@@ -184,7 +184,5 @@ IDE_AVAILABLE_IN_3_28
gboolean ide_build_pipeline_has_configured (IdeBuildPipeline *self);
IDE_AVAILABLE_IN_3_28
IdeBuildPhase ide_build_pipeline_get_requested_phase (IdeBuildPipeline *self);
IDE_AVAILABLE_IN_3_28
gboolean ide_build_pipeline_is_native (IdeBuildPipeline *self);
G_END_DECLS
......@@ -29,10 +29,12 @@ G_BEGIN_DECLS
void _ide_build_pipeline_cancel (IdeBuildPipeline *self);
void _ide_build_pipeline_set_runtime (IdeBuildPipeline *self,
IdeRuntime *runtime);
void _ide_build_pipeline_set_toolchain (IdeBuildPipeline *self,
IdeToolchain *toolchain);
void _ide_build_pipeline_set_message (IdeBuildPipeline *self,
const gchar *message);
void _ide_build_pipeline_mark_broken (IdeBuildPipeline *self);
void _ide_build_pipeline_set_device_info (IdeBuildPipeline *pipeline,
void _ide_build_pipeline_check_toolchain (IdeBuildPipeline *self,
IdeDeviceInfo *info);
void _ide_build_pipeline_set_pty_size (IdeBuildPipeline *self,
guint rows,
......
......@@ -722,3 +722,31 @@ ide_build_system_get_build_flags_for_dir_finish (IdeBuildSystem *self,
return ide_task_propagate_pointer (IDE_TASK (result), error);
}
/**
* ide_build_system_supports_toolchain:
* @self: an #IdeBuildSystem
* @toolchain: a #IdeToolchain
*
* Checks whether the build system supports the given toolchain.
*
* Returns: %TRUE if the toolchain is supported by the build system, %FALSE otherwise
*/
gboolean
ide_build_system_supports_toolchain (IdeBuildSystem *self,
IdeToolchain *toolchain)
{
const gchar *toolchain_id;
g_return_val_if_fail (IDE_IS_BUILD_SYSTEM (self), FALSE);
g_return_val_if_fail (IDE_IS_TOOLCHAIN (toolchain), FALSE);
toolchain_id = ide_toolchain_get_id (toolchain);
if (g_strcmp0 (toolchain_id, "default") == 0)
return TRUE;
if (IDE_BUILD_SYSTEM_GET_IFACE (self)->supports_toolchain)
return IDE_BUILD_SYSTEM_GET_IFACE (self)->supports_toolchain (self, toolchain);
return FALSE;
}
......@@ -56,6 +56,8 @@ struct _IdeBuildSystemInterface
IdeBuildPipeline *pipeline);
gchar *(*get_id) (IdeBuildSystem *self);
gchar *(*get_display_name) (IdeBuildSystem *self);
gboolean (*supports_toolchain) (IdeBuildSystem *self,
IdeToolchain *toolchain);
};
IDE_AVAILABLE_IN_ALL
......@@ -109,5 +111,8 @@ GHashTable *ide_build_system_get_build_flags_for_dir_finish (IdeBuildSyst
GError **error);
void _ide_build_system_set_project_file (IdeBuildSystem *self,
GFile *project_file) G_GNUC_INTERNAL;
IDE_AVAILABLE_IN_3_30
gboolean ide_build_system_supports_toolchain (IdeBuildSystem *self,
IdeToolchain *toolchain);
G_END_DECLS
......@@ -33,6 +33,7 @@
#include "runtimes/ide-runtime-manager.h"
#include "runtimes/ide-runtime.h"
#include "subprocess/ide-subprocess-launcher.h"
#include "toolchain/ide-toolchain-manager.h"
typedef struct
{
......@@ -45,6 +46,7 @@ typedef struct
gchar *prefix;
gchar *run_opts;
gchar *runtime_id;
gchar *toolchain_id;
gchar *append_path;
GFile *build_commands_dir;
......@@ -93,6 +95,8 @@ enum {
PROP_READY,
PROP_RUNTIME,
PROP_RUNTIME_ID,
PROP_TOOLCHAIN_ID,
PROP_TOOLCHAIN,
PROP_RUN_OPTS,
N_PROPS
};
......@@ -345,6 +349,14 @@ ide_configuration_get_property (GObject *object,
g_value_set_string (value, ide_configuration_get_runtime_id (self));
break;
case PROP_TOOLCHAIN:
g_value_take_object (value, ide_configuration_get_toolchain (self));
break;
case PROP_TOOLCHAIN_ID:
g_value_set_string (value, ide_configuration_get_toolchain_id (self));
break;
case PROP_RUN_OPTS:
g_value_set_string (value, ide_configuration_get_run_opts (self));
break;
......@@ -424,6 +436,14 @@ ide_configuration_set_property (GObject *object,
ide_configuration_set_runtime_id (self, g_value_get_string (value));
break;
case PROP_TOOLCHAIN:
ide_configuration_set_toolchain (self, g_value_get_object (value));
break;
case PROP_TOOLCHAIN_ID:
ide_configuration_set_toolchain_id (self, g_value_get_string (value));
break;
case PROP_RUN_OPTS:
ide_configuration_set_run_opts (self, g_value_get_string (value));
break;
......@@ -571,6 +591,20 @@ ide_configuration_class_init (IdeConfigurationClass *klass)
"host",
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
properties [PROP_TOOLCHAIN] =
g_param_spec_object ("toolchain",
"Toolchain",
"Toolchain",
IDE_TYPE_TOOLCHAIN,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
properties [PROP_TOOLCHAIN_ID] =
g_param_spec_string ("toolchain-id",
"Toolchain Id",
"The identifier of the toolchain",
"default",
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
properties [PROP_APP_ID] =
g_param_spec_string ("app-id",
"App ID",
......@@ -602,6 +636,7 @@ ide_configuration_init (IdeConfiguration *self)
g_autoptr(IdeEnvironment) env = ide_environment_new ();
priv->runtime_id = g_strdup ("host");
priv->toolchain_id = g_strdup ("default");
priv->debug = TRUE;
priv->parallelism = -1;
priv->locality = IDE_BUILD_LOCALITY_DEFAULT;
......@@ -692,6 +727,59 @@ ide_configuration_set_runtime_id (IdeConfiguration *self,
}
}
/**
* ide_configuration_get_toolchain_id:
* @self: An #IdeConfiguration
*
* Gets the toolchain id for the configuration.
*
* Returns: (transfer none) (nullable): The id of an #IdeToolchain or %NULL
*
* Since: 3.30
*/
const gchar *
ide_configuration_get_toolchain_id (IdeConfiguration *self)
{
IdeConfigurationPrivate *priv = ide_configuration_get_instance_private (self);
g_return_val_if_fail (IDE_IS_CONFIGURATION (self), NULL);
return priv->toolchain_id;
}
/**
* ide_configuration_set_toolchain_id:
* @self: An #IdeConfiguration
* @toolchain_id: The id of an #IdeToolchain
*
* Sets the toolchain id for the configuration.
*
* Since: 3.30
*/
void
ide_configuration_set_toolchain_id (IdeConfiguration *self,
const gchar *toolchain_id)
{
IdeConfigurationPrivate *priv = ide_configuration_get_instance_private (self);
g_return_if_fail (IDE_IS_CONFIGURATION (self));
if (toolchain_id == NULL)
toolchain_id = "default";
if (g_strcmp0 (toolchain_id, priv->toolchain_id) != 0)
{
g_free (priv->toolchain_id);
priv->toolchain_id = g_strdup (toolchain_id);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TOOLCHAIN_ID]);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TOOLCHAIN]);
ide_configuration_set_dirty (self, TRUE);
ide_configuration_emit_changed (self);
}
}
/**
* ide_configuration_get_runtime:
* @self: An #IdeConfiguration
......@@ -718,6 +806,60 @@ ide_configuration_set_runtime (IdeConfiguration *self,
IDE_CONFIGURATION_GET_CLASS (self)->set_runtime (self, runtime);
}
/**
* ide_configuration_get_toolchain:
* @self: An #IdeConfiguration
*
* Gets the toolchain for the configuration.
*
* Returns: (transfer full) (nullable): An #IdeToolchain
*
* Since: 3.30
*/
IdeToolchain *
ide_configuration_get_toolchain (IdeConfiguration *self)
{
IdeConfigurationPrivate *priv = ide_configuration_get_instance_private (self);
g_return_val_if_fail (IDE_IS_CONFIGURATION (self), NULL);
if (priv->toolchain_id != NULL)
{
IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
IdeToolchainManager *toolchain_manager = ide_context_get_toolchain_manager (context);
g_autoptr (IdeToolchain) toolchain = ide_toolchain_manager_get_toolchain (toolchain_manager, priv->toolchain_id);
if (toolchain != NULL)
return g_steal_pointer (&toolchain);
}
return NULL;
}
/**
* ide_configuration_set_toolchain:
* @self: An #IdeConfiguration
* @toolchain: (nullable): An #IdeToolchain or %NULL to use the default one
*
* Sets the toolchain for the configuration.
*
* Since: 3.30
*/
void
ide_configuration_set_toolchain (IdeConfiguration *self,
IdeToolchain *toolchain)
{
const gchar *toolchain_id = "default";
g_return_if_fail (IDE_IS_CONFIGURATION (self));
g_return_if_fail (!toolchain || IDE_IS_TOOLCHAIN (toolchain));
if (toolchain != NULL)
toolchain_id = ide_toolchain_get_id (toolchain);
ide_configuration_set_toolchain_id (self, toolchain_id);
}
/**
* ide_configuration_get_environ:
* @self: An #IdeConfiguration
......
......@@ -65,6 +65,11 @@ const gchar *ide_configuration_get_runtime_id (IdeConfigurat
IDE_AVAILABLE_IN_ALL
void ide_configuration_set_runtime_id (IdeConfiguration *self,
const gchar *runtime_id);
IDE_AVAILABLE_IN_3_30
const gchar *ide_configuration_get_toolchain_id (IdeConfiguration *self);
IDE_AVAILABLE_IN_3_30
void ide_configuration_set_toolchain_id (IdeConfiguration *self,
const gchar *toolchain_id);
IDE_AVAILABLE_IN_ALL
gboolean ide_configuration_get_dirty (IdeConfiguration *self);
IDE_AVAILABLE_IN_ALL
......@@ -87,6 +92,11 @@ IdeRuntime *ide_configuration_get_runtime (IdeConfigurat
IDE_AVAILABLE_IN_ALL
void ide_configuration_set_runtime (IdeConfiguration *self,
IdeRuntime *runtime);