Commit 33a04096 authored by Matthew Leeds's avatar Matthew Leeds Committed by Christian Hergert

make: Add makefile plugin

This commit adds a plugin to provide very basic support for projects
with Makefiles but without autotools. It essentially just knows how to
run "make", "make clean", and "make install" in the source directory,
but doesn't know how to find build targets (so the Run button doesn't
work).

https://bugzilla.gnome.org/show_bug.cgi?id=779684
parent fdf926d1
......@@ -315,6 +315,7 @@ m4_include([plugins/html-completion/configure.ac])
m4_include([plugins/html-preview/configure.ac])
m4_include([plugins/jedi/configure.ac])
m4_include([plugins/jhbuild/configure.ac])
m4_include([plugins/make/configure.ac])
m4_include([plugins/meson/configure.ac])
m4_include([plugins/meson-templates/configure.ac])
m4_include([plugins/mingw/configure.ac])
......@@ -598,6 +599,7 @@ echo " GNOME Code Assistance ................ : ${enable_gnome_code_assistance_
echo " HTML Autocompletion .................. : ${enable_html_completion_plugin}"
echo " HTML and Markdown Preview ............ : ${enable_html_preview_plugin}"
echo " JHBuild .............................. : ${enable_jhbuild_plugin}"
echo " Make ................................. : ${enable_make_plugin}"
echo " Meson ................................ : ${enable_meson_plugin}"
echo " MinGW ................................ : ${enable_mingw_plugin}"
echo " Project Creation ..................... : ${enable_create_project_plugin}"
......
......@@ -23,6 +23,7 @@ SUBDIRS = \
html-preview \
jedi \
jhbuild \
make \
mingw \
meson \
meson-templates \
......
if ENABLE_MAKE_PLUGIN
EXTRA_DIST = $(plugin_DATA)
plugindir = $(libdir)/gnome-builder/plugins
dist_plugin_DATA = make.plugin
moduledir = $(libdir)/gnome-builder/plugins/make_plugin
dist_module_DATA = make_plugin/__init__.py
endif
include $(top_srcdir)/plugins/Makefile.plugin
-include $(top_srcdir)/git.mk
# --enable-make-plugin=yes/no
AC_ARG_ENABLE([make-plugin],
[AS_HELP_STRING([--enable-make-plugin=@<:@yes/no@:>@],
[Build with support for Makefile integration.])],
[enable_make_plugin=$enableval],
[enable_make_plugin=yes])
# for if ENABLE_MAKE_PLUGIN in Makefile.am
AM_CONDITIONAL(ENABLE_MAKE_PLUGIN, test x$enable_make_plugin = xyes)
# Ensure our make is generated by autoconf
AC_CONFIG_FILES([plugins/make/Makefile])
[Plugin]
Module=make_plugin
Loader=python3
Name=Make
Description=Provides support for Makefile projects without autotools
Authors=Matthew Leeds <mleeds@redhat.com>
Copyright=Copyright © 2017 Matthew Leeds
Builtin=true
Hidden=true
X-Project-File-Filter-Pattern=Makefile
X-Project-File-Filter-Name=Makefile Project
# __init__.py
#
# Copyright (C) 2017 Matthew Leeds <mleeds@redhat.com>
#
# 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/>.
import gi
gi.require_version('Ide', '1.0')
from gi.repository import (
GObject,
Gio,
Ide
)
_ = Ide.gettext
class MakeBuildSystem(Ide.Object, Ide.BuildSystem, Gio.AsyncInitable):
project_file = GObject.Property(type=Gio.File)
def do_init_async(self, priority, cancel, callback, data=None):
task = Gio.Task.new(self, cancel, callback)
task.set_priority(priority)
# TODO: Be async here also
project_file = self.get_context().get_project_file()
if project_file.get_basename() == 'Makefile':
task.return_boolean(True)
else:
child = project_file.get_child('Makefile')
exists = child.query_exists(cancel)
if exists:
self.props.project_file = child
task.return_boolean(exists)
def do_init_finish(self, result):
return result.propagate_boolean()
def do_get_priority(self):
return -400 # Lower priority than Autotools and Meson
def do_get_builddir(self, config):
context = self.get_context()
return context.get_vcs().get_working_directory().get_path()
def do_get_build_flags_async(self, ifile, cancellable, callback, data=None):
task = Gio.Task.new(self, cancellable, callback)
task.ifile = ifile
task.build_flags = []
task.return_boolean(True)
def do_get_build_flags_finish(self, result):
if result.propagate_boolean():
return result.build_flags
def do_get_build_targets_async(self, cancellable, callback, data=None):
task = Gio.Task.new(self, cancellable, callback)
task.build_targets = []
task.return_boolean(True)
def do_get_build_targets_finish(self, result):
if result.propagate_boolean():
return result.build_targets
class MakePipelineAddin(Ide.Object, Ide.BuildPipelineAddin):
"""
The MakePipelineAddin registers stages to be executed when various
phases of the build pipeline are requested.
"""
def do_load(self, pipeline):
context = pipeline.get_context()
build_system = context.get_build_system()
# Only register stages if we are a makefile project
if type(build_system) != MakeBuildSystem:
return
config = pipeline.get_configuration()
runtime = config.get_runtime()
srcdir = context.get_vcs().get_working_directory().get_path()
builddir = build_system.get_builddir(config)
# Register the build launcher which will perform the incremental
# build of the project when the Ide.BuildPhase.BUILD phase is
# requested of the pipeline.
build_launcher = pipeline.create_launcher()
build_launcher.push_argv('make')
if config.props.parallelism > 0:
build_launcher.push_argv('-j{}'.format(config.props.parallelism))
clean_launcher = pipeline.create_launcher()
clean_launcher.push_argv('make')
clean_launcher.push_argv('clean')
build_stage = Ide.BuildStageLauncher.new(context, build_launcher)
build_stage.set_clean_launcher(clean_launcher)
build_stage.connect('query', self._query)
self.track(pipeline.connect(Ide.BuildPhase.BUILD, 0, build_stage))
# Register the install launcher which will perform our
# "make install" when the Ide.BuildPhase.INSTALL phase
# is requested of the pipeline.
install_launcher = pipeline.create_launcher()
install_launcher.push_argv('make')
install_launcher.push_argv('install')
install_stage = Ide.BuildStageLauncher.new(context, install_launcher)
self.track(pipeline.connect(Ide.BuildPhase.INSTALL, 0, install_stage))
def _query(self, stage, pipeline, cancellable):
stage.set_completed(False)
if get_option('with_make')
install_data('make.plugin', install_dir: plugindir)
install_data('make_plugin/__init__.py', install_dir: join_paths(plugindir, 'make_plugin'))
endif
......@@ -34,6 +34,7 @@ subdir('html-completion')
subdir('html-preview')
subdir('jedi')
subdir('jhbuild')
subdir('make')
subdir('meson')
subdir('meson-templates')
subdir('mingw')
......
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