Commit 7de49e6a authored by Christian Hergert's avatar Christian Hergert
Browse files

buildsystem: give buildsystem pipeline to get builddir

When figuring out the build directory, we need access to the
pipeline. This gives us more flexibility in case we need more
stuff in the future.

It does mean we need to delay when we get the builddir, but that
is a bit easier now.
parent 83d4109d
......@@ -1325,7 +1325,6 @@ static void
ide_build_pipeline_constructed (GObject *object)
{
IdeBuildPipeline *self = IDE_BUILD_PIPELINE (object);
IdeBuildSystem *build_system;
IdeContext *context;
IdeVcs *vcs;
GFile *workdir;
......@@ -1337,12 +1336,10 @@ ide_build_pipeline_constructed (GObject *object)
g_assert (IDE_IS_CONFIGURATION (self->configuration));
context = ide_object_get_context (IDE_OBJECT (self));
build_system = ide_context_get_build_system (context);
vcs = ide_context_get_vcs (context);
workdir = ide_vcs_get_working_directory (vcs);
self->srcdir = g_file_get_path (workdir);
self->builddir = ide_build_system_get_builddir (build_system, self->configuration, self->device);
IDE_EXIT;
}
......@@ -3631,7 +3628,17 @@ _ide_build_pipeline_set_runtime (IdeBuildPipeline *self,
g_return_if_fail (IDE_IS_BUILD_PIPELINE (self));
g_return_if_fail (!runtime || IDE_IS_RUNTIME (runtime));
g_set_object (&self->runtime, runtime);
if (g_set_object (&self->runtime, runtime))
{
IdeBuildSystem *build_system;
IdeContext *context;
context = ide_object_get_context (IDE_OBJECT (self));
build_system = ide_context_get_build_system (context);
g_clear_pointer (&self->builddir, g_free);
self->builddir = ide_build_system_get_builddir (build_system, self);
}
}
/**
......
......@@ -513,42 +513,41 @@ ide_build_system_get_build_flags_for_files_finish (IdeBuildSystem *self,
gchar *
ide_build_system_get_builddir (IdeBuildSystem *self,
IdeConfiguration *configuration,
IdeDevice *device)
IdeBuildPipeline *pipeline)
{
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);
g_return_val_if_fail (IDE_IS_DEVICE (device), NULL);
g_return_val_if_fail (IDE_IS_BUILD_PIPELINE (pipeline), NULL);
if (IDE_BUILD_SYSTEM_GET_IFACE (self)->get_builddir)
ret = IDE_BUILD_SYSTEM_GET_IFACE (self)->get_builddir (self, configuration, device);
ret = IDE_BUILD_SYSTEM_GET_IFACE (self)->get_builddir (self, pipeline);
if (ret == NULL)
{
g_autofree gchar *name = NULL;
g_autofree gchar *branch = NULL;
IdeConfiguration *config;
const gchar *config_id;
const gchar *device_id;
const gchar *runtime_id;
IdeRuntime *runtime;
IdeContext *context;
IdeVcs *vcs;
context = ide_object_get_context (IDE_OBJECT (self));
vcs = ide_context_get_vcs (context);
config_id = ide_configuration_get_id (configuration);
device_id = ide_device_get_id (device);
runtime_id = ide_configuration_get_runtime_id (configuration);
config = ide_build_pipeline_get_configuration (pipeline);
config_id = ide_configuration_get_id (config);
runtime = ide_build_pipeline_get_runtime (pipeline);
runtime_id = ide_runtime_get_id (runtime);
branch = ide_vcs_get_branch_name (vcs);
if (branch != NULL)
name = g_strdup_printf ("%s-%s-%s-%s", config_id, device_id, runtime_id, branch);
name = g_strdup_printf ("%s-%s-%s", config_id, runtime_id, branch);
else
name = g_strdup_printf ("%s-%s-%s", config_id, device_id, runtime_id);
name = g_strdup_printf ("%s-%s", config_id, runtime_id);
g_strdelimit (name, "@:/", '-');
......
......@@ -52,8 +52,7 @@ struct _IdeBuildSystemInterface
GAsyncResult *result,
GError **error);
gchar *(*get_builddir) (IdeBuildSystem *self,
IdeConfiguration *configuration,
IdeDevice *device);
IdeBuildPipeline *pipeline);
gchar *(*get_id) (IdeBuildSystem *self);
gchar *(*get_display_name) (IdeBuildSystem *self);
};
......@@ -76,8 +75,7 @@ IDE_AVAILABLE_IN_ALL
gint ide_build_system_get_priority (IdeBuildSystem *self);
IDE_AVAILABLE_IN_3_28
gchar *ide_build_system_get_builddir (IdeBuildSystem *self,
IdeConfiguration *configuration,
IdeDevice *device);
IdeBuildPipeline *pipeline);
IDE_AVAILABLE_IN_ALL
void ide_build_system_get_build_flags_async (IdeBuildSystem *self,
IdeFile *file,
......
......@@ -494,8 +494,7 @@ ide_autotools_build_system_get_build_flags_finish (IdeBuildSystem *build_system
static gchar *
ide_autotools_build_system_get_builddir (IdeBuildSystem *build_system,
IdeConfiguration *configuration,
IdeDevice *device)
IdeBuildPipeline *pipeline)
{
IdeAutotoolsBuildSystem *self = (IdeAutotoolsBuildSystem *)build_system;
g_autoptr(GFile) makefile = NULL;
......@@ -504,8 +503,7 @@ ide_autotools_build_system_get_builddir (IdeBuildSystem *build_system,
GFile *workdir;
g_assert (IDE_IS_AUTOTOOLS_BUILD_SYSTEM (self));
g_assert (IDE_IS_CONFIGURATION (configuration));
g_assert (IDE_IS_DEVICE (device));
g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
/*
* If there is a Makefile in the build directory, then the project has been
......
......@@ -65,7 +65,7 @@ class MakeBuildSystem(Ide.Object, Ide.BuildSystem, Gio.AsyncInitable):
def do_get_priority(self):
return 0
def do_get_builddir(self, config, device):
def do_get_builddir(self, pipeline):
context = self.get_context()
return context.get_vcs().get_working_directory().get_path()
......@@ -103,7 +103,7 @@ class MakePipelineAddin(Ide.Object, Ide.BuildPipelineAddin):
make = config.getenv('MAKE') or "make"
srcdir = context.get_vcs().get_working_directory().get_path()
builddir = build_system.get_builddir(config)
builddir = pipeline.get_builddir()
# Register the build launcher which will perform the incremental
# build of the project when the Ide.BuildPhase.BUILD phase is
......
......@@ -625,22 +625,22 @@ gbp_meson_build_system_get_build_flags_for_files_finish (IdeBuildSystem *build_
static gchar *
gbp_meson_build_system_get_builddir (IdeBuildSystem *build_system,
IdeConfiguration *configuration,
IdeDevice *device)
IdeBuildPipeline *pipeline)
{
GbpMesonBuildSystem *self = (GbpMesonBuildSystem *)build_system;
IdeConfiguration *config;
IdeBuildLocality locality;
g_assert (GBP_IS_MESON_BUILD_SYSTEM (self));
g_assert (IDE_IS_CONFIGURATION (configuration));
g_assert (IDE_IS_DEVICE (device));
g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
/*
* If the build configuration requires that we do an in tree build (yuck),
* then use "_build" as our build directory to build in-tree.
*/
locality = ide_configuration_get_locality (configuration);
config = ide_build_pipeline_get_configuration (pipeline);
locality = ide_configuration_get_locality (config);
if ((locality & IDE_BUILD_LOCALITY_OUT_OF_TREE) == 0)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment