cue: cachedir -> ci[]; move cache inside project on GitLab
This commit is contained in:
@@ -8,8 +8,9 @@
|
|||||||
image: ubuntu:bionic
|
image: ubuntu:bionic
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
|
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
||||||
paths:
|
paths:
|
||||||
- /root/.cache
|
- .cache/
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
GIT_SUBMODULE_STRATEGY: "recursive"
|
GIT_SUBMODULE_STRATEGY: "recursive"
|
||||||
|
|||||||
32
cue-test.py
32
cue-test.py
@@ -122,7 +122,7 @@ class TestSourceSet(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class TestUpdateReleaseLocal(unittest.TestCase):
|
class TestUpdateReleaseLocal(unittest.TestCase):
|
||||||
release_local = os.path.join(cue.cachedir, 'RELEASE.local')
|
release_local = os.path.join(cue.ci['cachedir'], 'RELEASE.local')
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if os.path.exists(self.release_local):
|
if os.path.exists(self.release_local):
|
||||||
@@ -190,16 +190,21 @@ class TestUpdateReleaseLocal(unittest.TestCase):
|
|||||||
|
|
||||||
class TestAddDependencyUpToDateCheck(unittest.TestCase):
|
class TestAddDependencyUpToDateCheck(unittest.TestCase):
|
||||||
hash_3_15_6 = "ce7943fb44beb22b453ddcc0bda5398fadf72096"
|
hash_3_15_6 = "ce7943fb44beb22b453ddcc0bda5398fadf72096"
|
||||||
location = os.path.join(cue.cachedir, 'base-R3.15.6')
|
location = ''
|
||||||
licensefile = os.path.join(location, 'LICENSE')
|
licensefile = ''
|
||||||
checked_file = os.path.join(location, 'checked_out')
|
checked_file = ''
|
||||||
release_file = os.path.join(location, 'configure', 'RELEASE')
|
release_file = ''
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
os.environ['SETUP_PATH'] = '.:appveyor'
|
os.environ['SETUP_PATH'] = '.:appveyor'
|
||||||
|
cue.clear_lists()
|
||||||
|
cue.detect_context()
|
||||||
|
self.location = os.path.join(cue.ci['cachedir'], 'base-R3.15.6')
|
||||||
|
self.licensefile = os.path.join(self.location, 'LICENSE')
|
||||||
|
self.checked_file = os.path.join(self.location, 'checked_out')
|
||||||
|
self.release_file = os.path.join(self.location, 'configure', 'RELEASE')
|
||||||
if os.path.exists(self.location):
|
if os.path.exists(self.location):
|
||||||
shutil.rmtree(self.location, onerror=cue.remove_readonly)
|
shutil.rmtree(self.location, onerror=cue.remove_readonly)
|
||||||
cue.clear_lists()
|
|
||||||
os.chdir(builddir)
|
os.chdir(builddir)
|
||||||
cue.source_set('defaults')
|
cue.source_set('defaults')
|
||||||
cue.complete_setup('BASE')
|
cue.complete_setup('BASE')
|
||||||
@@ -253,15 +258,18 @@ def is_shallow_repo(place):
|
|||||||
|
|
||||||
|
|
||||||
class TestAddDependencyOptions(unittest.TestCase):
|
class TestAddDependencyOptions(unittest.TestCase):
|
||||||
location = os.path.join(cue.cachedir, 'mcoreutils-master')
|
location = ''
|
||||||
testfile = os.path.join(location, '.ci', 'LICENSE')
|
testfile = ''
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
os.environ['SETUP_PATH'] = '.'
|
os.environ['SETUP_PATH'] = '.'
|
||||||
if os.path.exists(cue.cachedir):
|
|
||||||
shutil.rmtree(cue.cachedir, onerror=cue.remove_readonly)
|
|
||||||
cue.clear_lists()
|
cue.clear_lists()
|
||||||
cue.detect_context()
|
cue.detect_context()
|
||||||
|
if os.path.exists(cue.ci['cachedir']):
|
||||||
|
shutil.rmtree(cue.ci['cachedir'], onerror=cue.remove_readonly)
|
||||||
|
self.location = os.path.join(cue.ci['cachedir'], 'mcoreutils-master')
|
||||||
|
self.testfile = os.path.join(self.location, '.ci', 'LICENSE')
|
||||||
|
os.path.join(cue.ci['cachedir'], 'mcoreutils-master')
|
||||||
cue.source_set('defaults')
|
cue.source_set('defaults')
|
||||||
cue.complete_setup('MCoreUtils')
|
cue.complete_setup('MCoreUtils')
|
||||||
cue.setup['MCoreUtils'] = 'master'
|
cue.setup['MCoreUtils'] = 'master'
|
||||||
@@ -292,7 +300,7 @@ class TestAddDependencyOptions(unittest.TestCase):
|
|||||||
def test_AddMsiTo314(self):
|
def test_AddMsiTo314(self):
|
||||||
cue.complete_setup('BASE')
|
cue.complete_setup('BASE')
|
||||||
cue.setup['BASE'] = 'R3.14.12.1'
|
cue.setup['BASE'] = 'R3.14.12.1'
|
||||||
msifile = os.path.join(cue.cachedir, 'base-R3.14.12.1', 'src', 'dbtools', 'msi.c')
|
msifile = os.path.join(cue.ci['cachedir'], 'base-R3.14.12.1', 'src', 'dbtools', 'msi.c')
|
||||||
cue.add_dependency('BASE')
|
cue.add_dependency('BASE')
|
||||||
self.assertTrue(os.path.exists(msifile), 'MSI was not added to Base 3.14')
|
self.assertTrue(os.path.exists(msifile), 'MSI was not added to Base 3.14')
|
||||||
|
|
||||||
@@ -838,7 +846,7 @@ class TestSetupForBuild(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class TestHooks(unittest.TestCase):
|
class TestHooks(unittest.TestCase):
|
||||||
location = os.path.join(cue.cachedir, 'hook_test')
|
location = os.path.join(cue.ci['cachedir'], 'hook_test')
|
||||||
bla_file = os.path.join(location, 'bla.txt')
|
bla_file = os.path.join(location, 'bla.txt')
|
||||||
new_file = os.path.join(location, 'dd', 'new.txt')
|
new_file = os.path.join(location, 'dd', 'new.txt')
|
||||||
|
|
||||||
|
|||||||
35
cue.py
35
cue.py
@@ -16,7 +16,11 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
# Detect the service and set up context hash accordingly
|
# Detect the service and set up context hash accordingly
|
||||||
def detect_context():
|
def detect_context():
|
||||||
|
global homedir
|
||||||
|
|
||||||
buildconfig = 'default'
|
buildconfig = 'default'
|
||||||
|
ci['cachedir'] = os.path.join(homedir, '.cache')
|
||||||
|
|
||||||
if 'TRAVIS' in os.environ:
|
if 'TRAVIS' in os.environ:
|
||||||
ci['service'] = 'travis'
|
ci['service'] = 'travis'
|
||||||
ci['os'] = os.environ['TRAVIS_OS_NAME']
|
ci['os'] = os.environ['TRAVIS_OS_NAME']
|
||||||
@@ -33,7 +37,8 @@ def detect_context():
|
|||||||
ci['service'] = 'gitlab'
|
ci['service'] = 'gitlab'
|
||||||
ci['os'] = 'linux'
|
ci['os'] = 'linux'
|
||||||
ci['platform'] = 'x64'
|
ci['platform'] = 'x64'
|
||||||
ci['sudo'] = [] # No sudo in GitLab Docker containers
|
ci['sudo'] = [] # No sudo in GitLab Docker containers
|
||||||
|
ci['cachedir'] = os.path.join(curdir, '.cache') # No caches outside project directory
|
||||||
if 'CMP' in os.environ:
|
if 'CMP' in os.environ:
|
||||||
ci['compiler'] = os.environ['CMP']
|
ci['compiler'] = os.environ['CMP']
|
||||||
if 'BCFG' in os.environ:
|
if 'BCFG' in os.environ:
|
||||||
@@ -90,6 +95,9 @@ def detect_context():
|
|||||||
|
|
||||||
ci['scriptsdir'] = os.path.abspath(os.path.dirname(sys.argv[0]))
|
ci['scriptsdir'] = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||||
|
|
||||||
|
if 'CACHEDIR' in os.environ:
|
||||||
|
ci['cachedir'] = os.environ['CACHEDIR']
|
||||||
|
|
||||||
if 'CHOCO' in os.environ:
|
if 'CHOCO' in os.environ:
|
||||||
ci['choco'].extend(os.environ['CHOCO'].split())
|
ci['choco'].extend(os.environ['CHOCO'].split())
|
||||||
|
|
||||||
@@ -154,6 +162,7 @@ def clear_lists():
|
|||||||
ci['debug'] = False
|
ci['debug'] = False
|
||||||
ci['configuration'] = '<unknown>'
|
ci['configuration'] = '<unknown>'
|
||||||
ci['scriptsdir'] = ''
|
ci['scriptsdir'] = ''
|
||||||
|
ci['cachedir'] = ''
|
||||||
ci['choco'] = ['make']
|
ci['choco'] = ['make']
|
||||||
ci['apt'] = []
|
ci['apt'] = []
|
||||||
ci['homebrew'] = []
|
ci['homebrew'] = []
|
||||||
@@ -215,13 +224,9 @@ if 'HomeDrive' in os.environ:
|
|||||||
homedir = os.path.join(os.getenv('HomeDrive'), os.getenv('HomePath'))
|
homedir = os.path.join(os.getenv('HomeDrive'), os.getenv('HomePath'))
|
||||||
elif 'HOME' in os.environ:
|
elif 'HOME' in os.environ:
|
||||||
homedir = os.getenv('HOME')
|
homedir = os.getenv('HOME')
|
||||||
cachedir = os.path.join(homedir, '.cache')
|
|
||||||
toolsdir = os.path.join(homedir, '.tools')
|
toolsdir = os.path.join(homedir, '.tools')
|
||||||
rtemsdir = r'/home/travis/.rtems' # Preliminary, until the next generation of toolchain
|
rtemsdir = r'/home/travis/.rtems' # Preliminary, until the next generation of toolchain
|
||||||
|
|
||||||
if 'CACHEDIR' in os.environ:
|
|
||||||
cachedir = os.environ['CACHEDIR']
|
|
||||||
|
|
||||||
|
|
||||||
vcvars_table = {
|
vcvars_table = {
|
||||||
# https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#History
|
# https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#History
|
||||||
@@ -333,14 +338,14 @@ def source_set(name):
|
|||||||
# - otherwise add "$var=$location" line and possibly move EPICS_BASE=... line to the end
|
# - otherwise add "$var=$location" line and possibly move EPICS_BASE=... line to the end
|
||||||
# Set places[var] = location
|
# Set places[var] = location
|
||||||
def update_release_local(var, location):
|
def update_release_local(var, location):
|
||||||
release_local = os.path.join(cachedir, 'RELEASE.local')
|
release_local = os.path.join(ci['cachedir'], 'RELEASE.local')
|
||||||
updated_line = '{0}={1}'.format(var, location.replace('\\', '/'))
|
updated_line = '{0}={1}'.format(var, location.replace('\\', '/'))
|
||||||
places[var] = location
|
places[var] = location
|
||||||
|
|
||||||
if not os.path.exists(release_local):
|
if not os.path.exists(release_local):
|
||||||
logger.debug('RELEASE.local does not exist, creating it')
|
logger.debug('RELEASE.local does not exist, creating it')
|
||||||
try:
|
try:
|
||||||
os.makedirs(cachedir)
|
os.makedirs(ci['cachedir'])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
touch = open(release_local, 'w')
|
touch = open(release_local, 'w')
|
||||||
@@ -495,7 +500,7 @@ def add_dependency(dep):
|
|||||||
.format(ANSI_RED, tag, dep, setup[dep + '_REPOURL'], ANSI_RESET))
|
.format(ANSI_RED, tag, dep, setup[dep + '_REPOURL'], ANSI_RESET))
|
||||||
|
|
||||||
dirname = setup[dep + '_DIRNAME'] + '-{0}'.format(tag)
|
dirname = setup[dep + '_DIRNAME'] + '-{0}'.format(tag)
|
||||||
place = os.path.join(cachedir, dirname)
|
place = os.path.join(ci['cachedir'], dirname)
|
||||||
checked_file = os.path.join(place, "checked_out")
|
checked_file = os.path.join(place, "checked_out")
|
||||||
|
|
||||||
if os.path.isdir(place):
|
if os.path.isdir(place):
|
||||||
@@ -517,14 +522,14 @@ def add_dependency(dep):
|
|||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
if not os.path.isdir(place):
|
if not os.path.isdir(place):
|
||||||
if not os.path.isdir(cachedir):
|
if not os.path.isdir(ci['cachedir']):
|
||||||
os.makedirs(cachedir)
|
os.makedirs(ci['cachedir'])
|
||||||
# clone dependency
|
# clone dependency
|
||||||
print('Cloning {0} of dependency {1} into {2}'
|
print('Cloning {0} of dependency {1} into {2}'
|
||||||
.format(tag, dep, place))
|
.format(tag, dep, place))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
call_git(['clone', '--quiet'] + deptharg + recursearg + ['--branch', tag, setup[dep + '_REPOURL'], dirname],
|
call_git(['clone', '--quiet'] + deptharg + recursearg + ['--branch', tag, setup[dep + '_REPOURL'], dirname],
|
||||||
cwd=cachedir)
|
cwd=ci['cachedir'])
|
||||||
|
|
||||||
sp.check_call(['git', 'log', '-n1'], cwd=place)
|
sp.check_call(['git', 'log', '-n1'], cwd=place)
|
||||||
logger.debug('Setting do_recompile = True (all following modules will be recompiled')
|
logger.debug('Setting do_recompile = True (all following modules will be recompiled')
|
||||||
@@ -645,7 +650,7 @@ def setup_for_build(args):
|
|||||||
|
|
||||||
# Find BASE location
|
# Find BASE location
|
||||||
if not building_base:
|
if not building_base:
|
||||||
with open(os.path.join(cachedir, 'RELEASE.local'), 'r') as f:
|
with open(os.path.join(ci['cachedir'], 'RELEASE.local'), 'r') as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
(mod, place) = line.strip().split('=')
|
(mod, place) = line.strip().split('=')
|
||||||
@@ -660,7 +665,7 @@ def setup_for_build(args):
|
|||||||
|
|
||||||
if ci['os'] == 'windows':
|
if ci['os'] == 'windows':
|
||||||
if not building_base:
|
if not building_base:
|
||||||
with open(os.path.join(cachedir, 'RELEASE.local'), 'r') as f:
|
with open(os.path.join(ci['cachedir'], 'RELEASE.local'), 'r') as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
(mod, place) = line.strip().split('=')
|
(mod, place) = line.strip().split('=')
|
||||||
@@ -764,7 +769,7 @@ def prepare(args):
|
|||||||
targetdir = 'configure'
|
targetdir = 'configure'
|
||||||
else:
|
else:
|
||||||
targetdir = '.'
|
targetdir = '.'
|
||||||
shutil.copy(os.path.join(cachedir, 'RELEASE.local'), targetdir)
|
shutil.copy(os.path.join(ci['cachedir'], 'RELEASE.local'), targetdir)
|
||||||
|
|
||||||
fold_end('check.out.dependencies', 'Checking/cloning dependencies')
|
fold_end('check.out.dependencies', 'Checking/cloning dependencies')
|
||||||
|
|
||||||
@@ -987,7 +992,7 @@ PERL = C:/Strawberry/perl/bin/perl -CSD'''
|
|||||||
print("%-10s %-12s %-11s %s" % (mod, setup[mod], stat, commit))
|
print("%-10s %-12s %-11s %s" % (mod, setup[mod], stat, commit))
|
||||||
|
|
||||||
print('{0}Contents of RELEASE.local{1}'.format(ANSI_CYAN, ANSI_RESET))
|
print('{0}Contents of RELEASE.local{1}'.format(ANSI_CYAN, ANSI_RESET))
|
||||||
with open(os.path.join(cachedir, 'RELEASE.local'), 'r') as f:
|
with open(os.path.join(ci['cachedir'], 'RELEASE.local'), 'r') as f:
|
||||||
print(f.read().strip())
|
print(f.read().strip())
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user