Probe from travis config.
This commit is contained in:
parent
7b6fecc2ac
commit
bd1d18a890
1 changed files with 38 additions and 16 deletions
|
@ -79,6 +79,14 @@ class BuildSystem(object):
|
||||||
def get_declared_outputs(self):
|
def get_declared_outputs(self):
|
||||||
raise NotImplementedError(self.get_declared_outputs)
|
raise NotImplementedError(self.get_declared_outputs)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def probe(cls, path):
|
||||||
|
return None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def probe_from_travis(cls, path, data):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class Pear(BuildSystem):
|
class Pear(BuildSystem):
|
||||||
|
|
||||||
|
@ -766,22 +774,19 @@ class Golang(BuildSystem):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def probe(cls, path):
|
def probe(cls, path):
|
||||||
if os.path.exists(os.path.join(path, ".travis.yml")):
|
|
||||||
import ruamel.yaml.reader
|
|
||||||
|
|
||||||
with open(os.path.join(path, ".travis.yml"), "rb") as f:
|
|
||||||
try:
|
|
||||||
data = ruamel.yaml.load(f, ruamel.yaml.SafeLoader)
|
|
||||||
except ruamel.yaml.reader.ReaderError as e:
|
|
||||||
warnings.warn("Unable to parse .travis.yml: %s" % (e,))
|
|
||||||
else:
|
|
||||||
language = data.get("language")
|
|
||||||
if language == "go":
|
|
||||||
return Golang(path)
|
|
||||||
|
|
||||||
for entry in os.scandir(path):
|
for entry in os.scandir(path):
|
||||||
if entry.name.endswith(".go"):
|
if entry.name.endswith(".go"):
|
||||||
return Golang(path)
|
return Golang(path)
|
||||||
|
if entry.is_dir():
|
||||||
|
for entry in os.scandir(entry.path):
|
||||||
|
if entry.name.endswith(".go"):
|
||||||
|
return Golang(path)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def probe_from_travis(cls, path, data):
|
||||||
|
language = data.get("language")
|
||||||
|
if language == "go":
|
||||||
|
return cls(path)
|
||||||
|
|
||||||
|
|
||||||
class Maven(BuildSystem):
|
class Maven(BuildSystem):
|
||||||
|
@ -871,15 +876,32 @@ class PerlBuildTiny(BuildSystem):
|
||||||
return cls(path)
|
return cls(path)
|
||||||
|
|
||||||
|
|
||||||
|
BUILDSYSTEM_CLSES = [
|
||||||
|
Pear, SetupPy, Npm, Waf, Cargo, Meson, Cabal, Gradle, Maven,
|
||||||
|
DistInkt, Gem, Make, PerlBuildTiny, Golang]
|
||||||
|
|
||||||
|
|
||||||
def detect_buildsystems(path, trust_package=False):
|
def detect_buildsystems(path, trust_package=False):
|
||||||
"""Detect build systems."""
|
"""Detect build systems."""
|
||||||
for bs_cls in [
|
for bs_cls in BUILDSYSTEM_CLSES:
|
||||||
Pear, SetupPy, Npm, Waf, Cargo, Meson, Cabal, Gradle, Maven,
|
|
||||||
DistInkt, Gem, Make, PerlBuildTiny, Golang]:
|
|
||||||
bs = bs_cls.probe(path)
|
bs = bs_cls.probe(path)
|
||||||
if bs is not None:
|
if bs is not None:
|
||||||
yield bs
|
yield bs
|
||||||
|
|
||||||
|
if os.path.exists(os.path.join(path, ".travis.yml")):
|
||||||
|
import ruamel.yaml.reader
|
||||||
|
|
||||||
|
with open(os.path.join(path, ".travis.yml"), "rb") as f:
|
||||||
|
try:
|
||||||
|
data = ruamel.yaml.load(f, ruamel.yaml.SafeLoader)
|
||||||
|
except ruamel.yaml.reader.ReaderError as e:
|
||||||
|
warnings.warn("Unable to parse .travis.yml: %s" % (e,))
|
||||||
|
else:
|
||||||
|
for bs_cls in BUILDSYSTEM_CLSES:
|
||||||
|
bs = bs_cls.probe_from_travis(path, data)
|
||||||
|
if bs is not None:
|
||||||
|
yield bs
|
||||||
|
|
||||||
|
|
||||||
def get_buildsystem(path, trust_package=False):
|
def get_buildsystem(path, trust_package=False):
|
||||||
for buildsystem in detect_buildsystems(path, trust_package=trust_package):
|
for buildsystem in detect_buildsystems(path, trust_package=trust_package):
|
||||||
|
|
Loading…
Add table
Reference in a new issue