summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2024-03-23 19:05:39 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2024-03-24 02:16:04 +0530
commitb2ca3a156e01360db31b3afb887f7a34369a7b7a (patch)
tree0b25990d15b9110e0f924537d8c24f9f19183a44
parent2e6c6ef708c6d05dadf186e98938eafaf38093d3 (diff)
cerbero: Add cache relocation for macos and windows
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1423>
-rw-r--r--cerbero/commands/cache.py49
1 files changed, 31 insertions, 18 deletions
diff --git a/cerbero/commands/cache.py b/cerbero/commands/cache.py
index 2560b7d2..8e9ab348 100644
--- a/cerbero/commands/cache.py
+++ b/cerbero/commands/cache.py
@@ -33,8 +33,6 @@ from cerbero.utils import messages as m
class BaseCache(Command):
base_url = 'https://artifacts.gstreamer-foundation.net/cerbero-deps/%s/%s/%s'
ssh_address = 'cerbero-deps-uploader@artifacts.gstreamer-foundation.net'
- # FIXME: fetch this value from CI env vars
- build_dir = '/builds/%s/cerbero/cerbero-build'
deps_filename = 'cerbero-deps.tar.xz'
log_filename = 'cerbero-deps.log'
log_size = 10
@@ -50,6 +48,25 @@ class BaseCache(Command):
)
Command.__init__(self, args)
+ def get_ci_builds_dir(self, config):
+ if 'CI_BUILDS_DIR' in os.environ:
+ return os.environ['CI_BUILDS_DIR'].replace('\\', '/')
+ # For the convenience of people downloading the cache by hand
+ if config.platform == Platform.DARWIN:
+ return '/private/tmp/builds'
+ elif config.platform == Platform.WINDOWS:
+ return 'C:/Users/Administrator/runner/builds'
+ return '/builds'
+
+ def get_cache_home_dir(self, config, namespace):
+ ci_builds_dir = self.get_ci_builds_dir(config)
+ return f'{ci_builds_dir}/{namespace}/cerbero/cerbero-build'
+
+ def get_gnu_sed(self, config):
+ if config.platform == Platform.DARWIN:
+ return os.path.join(config.build_tools_prefix, 'bin', 'sed')
+ return 'sed'
+
# FIXME: move this to utils
def checksum(self, fname):
h = sha256()
@@ -87,9 +104,9 @@ class BaseCache(Command):
target_arch = config.target_arch
if distro == Distro.REDHAT:
distro = 'fedora'
- if distro == Distro.OS_X:
+ elif distro == Distro.OS_X:
distro = 'macos'
- if distro == Distro.WINDOWS:
+ elif distro == Distro.WINDOWS:
# When targeting Windows, we need to differentiate between mingw,
# msvc, and uwp (debug/release) jobs. When cross-compiling this
# will always be 'cross-windows-mingw' right now, but that might
@@ -169,20 +186,16 @@ class FetchCache(BaseCache):
m.action('Unpack complete, deleting artifact')
os.remove(dep_path)
- # Don't need to relocate on Windows and macOS since we build
- # pkg-config with --enable-define-prefix.
- # In case this needs to be re-enabled at some point, note that the
- # current self.build_dir value is hard-coded and is wrong on macOS
- # and Windows. It should instead be derived from CI env vars.
- if config.platform == Platform.LINUX:
- origin = self.build_dir % namespace
- m.action('Relocating from %s to %s' % (origin, config.home_dir))
- # FIXME: Just a quick hack for now
- shell.call(
- ('grep -lnrIU %(origin)s | xargs ' 'sed "s#%(origin)s#%(dest)s#g" -i')
- % {'origin': origin, 'dest': config.home_dir},
- config.home_dir,
- )
+ # We need to relocate pc files that weren't generated by meson and
+ # python programs installed with pip because the shebang set by the
+ # virtualenv python uses an absolute path.
+ origin = self.get_cache_home_dir(config, namespace)
+ dest = config.home_dir
+ if origin != dest:
+ m.action(f'Relocating text files from {origin} to {dest}')
+ sed = self.get_gnu_sed(config)
+ # This is hacky, but fast enough
+ shell.call(f'grep -lrIe {origin} {dest} | xargs {sed} "s#{origin}#{dest}#g" -i', verbose=True)
except FatalError as e:
m.warning('Could not retrieve dependencies for commit %s: %s' % (dep['commit'], e.msg))