-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
224 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from multiprocessing import cpu_count | ||
from subprocess import run | ||
from .Base import plugin, BasePlugin, PluginSupport | ||
|
||
@plugin | ||
class AutotoolsPlugin(BasePlugin): | ||
|
||
def build(self, settings): | ||
"""compiles the source code or a subset thereof""" | ||
|
||
if not (settings['repo_base'].value / "configure").exists() and (settings['repo_base'].value / "autogen.sh").exists(): | ||
run(["./autogen.sh"], cwd=settings['repo_base'].value) | ||
|
||
if not (settings['repo_base'].value / "configure").exists() and (settings['repo_base'].value / "configure").exists(): | ||
run(["./configure"], cwd=settings['repo_base'].value) | ||
|
||
run(["make", "-j", str(cpu_count())], cwd=settings['repo_base'].value) | ||
|
||
def test(self, settings): | ||
"""runs automated tests on source code or a subset there of""" | ||
run(["make", "-j", str(cpu_count()), "check"], cwd=settings['repo_base'].value) | ||
|
||
def clean(self, settings): | ||
"""cleans source code or a subset there of""" | ||
run(["make", "-j", str(cpu_count()), "clean"], cwd=settings['repo_base'].value) | ||
|
||
def install(self, settings): | ||
"""cleans source code or a subset there of""" | ||
run(["make", "-j", str(cpu_count()), "install"], cwd=settings['repo_base'].value) | ||
|
||
|
||
@staticmethod | ||
def _supported(settings): | ||
"""returns a dictionary of supported functions""" | ||
if 'repo_base' in settings and ( | ||
(settings['repo_base'].value / "autogen.sh").exists() or | ||
(settings['repo_base'].value / "configure").exists() or | ||
(settings['repo_base'].value / "Makefile").exists() or | ||
(settings['repo_base'].value / "makefile").exists() | ||
): | ||
state = PluginSupport.DEFAULT_MAIN | ||
else: | ||
state = PluginSupport.NOT_ENABLED_BY_REPOSITORY | ||
|
||
|
||
return { | ||
"build": state, | ||
"test": state, | ||
"clean": state, | ||
"install": state | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from subprocess import run | ||
from .Base import plugin, BasePlugin, PluginSupport | ||
|
||
@plugin | ||
class MesonPlugin(BasePlugin): | ||
|
||
def configure(self, settings): | ||
"""configure the build directory""" | ||
if not self.is_configured(settings): | ||
settings['build_dir'].value.mkdir(exist_ok=True) | ||
run(["meson", str(settings['build_dir'].value)], cwd=settings['repo_base'].value) | ||
|
||
def is_configured(self, settings): | ||
"""test if the build directory is configured""" | ||
return settings['build_dir'].value.exists() and ( | ||
(settings['build_dir'].value / "build.ninja").exists() | ||
) | ||
|
||
def build(self, settings): | ||
"""compiles the source code or a subset thereof""" | ||
self.configure(settings) | ||
|
||
if self.is_configured(settings): | ||
print("m[1]: Entering directory", str(settings['build_dir'].value)) | ||
run(["ninja","-C", str(settings['build_dir'].value), *settings['cmdline'].value], cwd=settings['repo_base'].value) | ||
else: | ||
print("failed to configure") | ||
|
||
def test(self, settings): | ||
"""runs automated tests on source code or a subset there of""" | ||
self.configure(settings) | ||
|
||
if self.is_configured(settings): | ||
print("m[1]: Entering directory", str(settings['build_dir'].value)) | ||
run(["meson", "test", *settings['cmdline'].value], cwd=settings['build_dir'].value) | ||
else: | ||
print("failed to configure") | ||
|
||
def clean(self, settings): | ||
"""cleans source code or a subset there of""" | ||
self.configure(settings) | ||
|
||
if self.is_configured(settings): | ||
print("m[1]: Entering directory", str(settings['build_dir'].value)) | ||
run(["ninja", "clean"], cwd=settings['build_dir'].value) | ||
else: | ||
print("failed to configure") | ||
|
||
def install(self, settings): | ||
"""cleans source code or a subset there of""" | ||
self.configure(settings) | ||
|
||
if self.is_configured(settings): | ||
print("m[1]: Entering directory", str(settings['build_dir'].value)) | ||
run(["ninja", "install"], cwd=settings['build_dir'].value) | ||
else: | ||
print("failed to configure") | ||
|
||
|
||
@staticmethod | ||
def _supported(settings): | ||
"""returns a dictionary of supported functions""" | ||
if 'repo_base' in settings and (settings['repo_base'].value / "meson.build").exists(): | ||
state = PluginSupport.DEFAULT_MAIN | ||
else: | ||
state = PluginSupport.NOT_ENABLED_BY_REPOSITORY | ||
|
||
|
||
return { | ||
"build": state, | ||
"test": state, | ||
"clean": state, | ||
"install": state | ||
} | ||
|