get last changes of master

This commit is contained in:
Andrei Yankovich 2019-12-26 17:08:56 +03:00
parent 201e18ce1c
commit 43faebf752
4 changed files with 127 additions and 139 deletions

View File

@ -1,164 +1,155 @@
# This Python file uses the following encoding: utf-8 # This Python file uses the following encoding: utf-8
import BuildBotLib.basemodule as base from BuildBotLib.basemodule import BaseModule
from buildbot.plugins import util, steps from buildbot.plugins import util, steps
import os import os
from pathlib import Path from pathlib import Path
LAST_FORMAT = [""]
AndroidBaseDir = str(Path.home()) + "/Android" class AsssetsInstaller(BaseModule):
MULTIPLE_SH_COMMAND = ["/bin/bash", "-c"] def __init__(self):
BaseModule.__init__(self)
format = ""
def isInit(step): AndroidBaseDir = str(Path.home()) + "/Android"
return step.getProperty('module') == 'init'
def isInit(self, step):
return step.getProperty('module') == 'init'
@util.renderer @util.renderer
def RemoveOldData(props): def RemoveOldData(self, props):
cmd = "mkdir -p " + AndroidBaseDir cmd = "mkdir -p " + self.AndroidBaseDir
if os.path.exists(AndroidBaseDir): if os.path.exists(self.AndroidBaseDir):
cmd = "rm -rdf " + AndroidBaseDir + " ; " + cmd cmd = "rm -rdf " + self.AndroidBaseDir + " ; " + cmd
return MULTIPLE_SH_COMMAND + [cmd] return self.generateCmd(cmd)
@util.renderer
def NDKDownloadCMD(self, props):
link = props.getProperty("link")
@util.renderer self.format = link[link.rfind('.'):].lower()
def NDKDownloadCMD(props):
link = props.getProperty("link")
format = link[link.rfind('.'):].lower() return ["curl",
LAST_FORMAT[0] = format link,
"--output",
self.AndroidBaseDir + "/temp" + self.format]
return ["curl", link, "--output", AndroidBaseDir + "/temp" + format] @util.renderer
def ExtractCMD(self, props):
res = ["echo", "format '" + format + "' not supported"]
@util.renderer if format == ".zip":
def ExtractCMD(props): res = ["unzip", self.AndroidBaseDir + "/temp" + self.format,
"-d", self.AndroidBaseDir]
format = LAST_FORMAT[0] return res
res = ["echo", "format '" + format + "' not supported"] @util.renderer
def InstallCMD(self, props):
if format == ".zip": module = props.getProperty("module")
res = ["unzip", AndroidBaseDir + "/temp" + format, version = props.getProperty("version")
"-d", AndroidBaseDir]
return res unit_to_multiplier = {
'SDK': 'platform-tools;tools;platforms;android-'+version,
'NDK': 'ndk-bundle'
}
return ["sdkmanager", unit_to_multiplier.get(module, "--list")]
@util.renderer @util.renderer
def InstallCMD(props): def ConfigureCMD(self, props):
module = props.getProperty("module") res = ["echo", "Configure failed"]
version = props.getProperty("version")
unit_to_multiplier = { if format == ".zip":
'SDK': 'platform-tools;tools;platforms;android-'+version,
'NDK': 'ndk-bundle'
}
return ["sdkmanager", unit_to_multiplier.get(module, "--list")] all_subdirs = self.allSubdirsOf(self.AndroidBaseDir)
latest_subdir = max(all_subdirs, key=os.path.getmtime)
res = "mv " + latest_subdir + " " + self.AndroidBaseDir + "/tools"
res += " ; ln -sf "
res += self.AndroidBaseDir + "/tools/bin/sdkmanager "
res += self.home + "/.local/bin/sdkmanager"
res += " ; yes | sdkmanager --licenses"
return self.generateCmd(res)
@util.renderer def getFactory(self):
def ConfigureCMD(props): factory = super().getFactory()
format = LAST_FORMAT[0] factory.addStep(
steps.ShellCommand(
res = ["echo", "Configure failed"] command=self.RemoveOldData,
name='rm old item',
if format == ".zip": doStepIf=self.isInit,
description='rm old',
all_subdirs = base.allSubdirsOf(AndroidBaseDir) haltOnFailure=True,
latest_subdir = max(all_subdirs, key=os.path.getmtime) )
res = "mv " + latest_subdir + " " + AndroidBaseDir + "/tools"
res += " ; ln -sf " + AndroidBaseDir + "/tools/bin/sdkmanager "
res += str(Path.home()) + "/.local/bin/sdkmanager"
res += " ; yes | sdkmanager --licenses"
return MULTIPLE_SH_COMMAND + [res]
def getFactory():
factory = base.getFactory()
factory.addStep(
steps.ShellCommand(
command=RemoveOldData,
name='rm old item',
doStepIf=isInit,
description='rm old',
haltOnFailure=True,
) )
)
factory.addStep( factory.addStep(
steps.ShellCommand( steps.ShellCommand(
command=NDKDownloadCMD, command=self.NDKDownloadCMD,
name='download new item', name='download new item',
doStepIf=isInit, doStepIf=self.isInit,
description='download new item', description='download new item',
haltOnFailure=True, haltOnFailure=True,
)
) )
)
factory.addStep( factory.addStep(
steps.ShellCommand( steps.ShellCommand(
command=ExtractCMD, command=self.ExtractCMD,
name='extract new item', name='extract new item',
doStepIf=isInit, doStepIf=self.isInit,
description='extract new item', description='extract new item',
haltOnFailure=True, haltOnFailure=True,
)
) )
)
factory.addStep( factory.addStep(
steps.ShellCommand( steps.ShellCommand(
command=ConfigureCMD, command=self.ConfigureCMD,
name='configure new item', name='configure new item',
doStepIf=isInit, doStepIf=self.isInit,
description='configure new item', description='configure new item',
haltOnFailure=True, haltOnFailure=True,
)
) )
)
factory.addStep( factory.addStep(
steps.ShellCommand( steps.ShellCommand(
command=InstallCMD, command=self.InstallCMD,
name='install module', name='install module',
doStepIf=lambda step: not isInit(step), doStepIf=lambda step: not self.isInit(step),
description='configure new item', description='configure new item',
haltOnFailure=True, haltOnFailure=True,
)
) )
)
return factory return factory
def getPropertyes(self):
return [
util.ChoiceStringParameter(
name='module',
choices=["init", "SDK", "NDK"],
default="init"
),
def getRepo(): util.StringParameter(
return "" name='link',
label="url to download item",
default=""
def getPropertyes(): ),
return [ util.StringParameter(
util.ChoiceStringParameter( name='version',
name='module', label="Version",
choices=["init", "SDK", "NDK"], default=""
default="init" ),
), ]
util.StringParameter(
name='link',
label="url to download item",
default=""
),
util.StringParameter(
name='version',
label="Version",
default=""
),
]

View File

@ -63,14 +63,14 @@ class BaseModule:
return res return res
def allSubdirsOf(b='.'): def allSubdirsOf(self, b='.'):
result = [] result = []
for d in os.listdir(b): for d in os.listdir(b):
bd = os.path.join(b, d) bd = os.path.join(b, d)
if os.path.isdir(bd): if os.path.isdir(bd):
result.append(bd) result.append(bd)
return result return result
@util.renderer @util.renderer
def makeCommand(self, props): def makeCommand(self, props):

View File

@ -284,7 +284,4 @@ class QtUpdater(Make):
label='disable build and install qt (confugure only)', label='disable build and install qt (confugure only)',
default=False default=False
) )
return list;
] ]

View File

@ -6,7 +6,7 @@ from BuildBotLib.buildbot import *
from buildbot.www import authz, auth from buildbot.www import authz, auth
from BuildBotLib.cmake import CMake from BuildBotLib.cmake import CMake
from BuildBotLib.qmake import QMake from BuildBotLib.qmake import QMake
from BuildBotLib.NPM import NPM from BuildBotLib.asssetsinstaller import AsssetsInstaller
from BuildBotLib.qtUpdater import QtUpdater from BuildBotLib.qtUpdater import QtUpdater
# This is a sample buildmaster config file. It must be installed as # This is a sample buildmaster config file. It must be installed as
@ -16,16 +16,16 @@ from BuildBotLib.qtUpdater import QtUpdater
# a shorter alias to save typing. # a shorter alias to save typing.
bot = BuildBot(); bot = BuildBot()
qmake = QMake(); qmake = QMake()
asssetsinstaller = Asssetsinstaller(); asssetsinstaller = AsssetsInstaller()
qtUpdater = QtUpdater(); qtUpdater = QtUpdater()
bot.addBuilder("github-worker", qmake); bot.addBuilder("github-worker", qmake)
bot.addBuilder("Tester", qmake); bot.addBuilder("Tester", qmake)
bot.addBuilder("qtBuilder", qtUpdater); bot.addBuilder("qtBuilder", qtUpdater)
bot.addBuilder("assets-builder", asssetsinstaller); bot.addBuilder("assets-builder", asssetsinstaller)
c = BuildmasterConfig = bot.getMaster() c = BuildmasterConfig = bot.getMaster()