aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/thinlto_cache.py
diff options
context:
space:
mode:
authorspreis <spreis@yandex-team.com>2024-07-10 07:48:05 +0300
committerspreis <spreis@yandex-team.com>2024-07-10 07:59:28 +0300
commite16b329fb8d258f106d4f5345195d1fba93cf09c (patch)
treec23841b2b8fcf1a848a286ee0024389407aca828 /build/scripts/thinlto_cache.py
parent7724c3dfc71cbaab5961f87addef86833d079723 (diff)
downloadydb-e16b329fb8d258f106d4f5345195d1fba93cf09c.tar.gz
,Support thinlto caches
ac03c8c8d7beb99b5a8fcda8c0c6bf948ca2bb2e
Diffstat (limited to 'build/scripts/thinlto_cache.py')
-rw-r--r--build/scripts/thinlto_cache.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/build/scripts/thinlto_cache.py b/build/scripts/thinlto_cache.py
new file mode 100644
index 0000000000..35ab755262
--- /dev/null
+++ b/build/scripts/thinlto_cache.py
@@ -0,0 +1,27 @@
+import os
+import tarfile
+
+
+CACHE_DIR_NAME='thinlto_cache_dir'
+
+
+def add_options(parser):
+ parser.add_option('--thinlto-cache')
+ parser.add_option('--thinlto-cache-write', action='store_true')
+
+def preprocess(opts, cmd):
+ if opts.thinlto_cache:
+ cache_dir = os.path.join(opts.build_root, CACHE_DIR_NAME)
+ cmd +=['-Wl,--thinlto-cache-dir={}'.format(cache_dir)]
+ if opts.thinlto_cache_write:
+ os.mkdir(cache_dir)
+ else:
+ with tarfile.open(opts.thinlto_cache, 'r') as tar:
+ tar.extractall(opts.build_root)
+
+def postprocess(opts):
+ if opts.thinlto_cache:
+ cache_dir = os.path.join(opts.build_root, CACHE_DIR_NAME)
+ if opts.thinlto_cache_write:
+ with tarfile.open(opts.thinlto_cache, 'w:gz') as tar:
+ tar.add(cache_dir, arcname=os.path.basename(cache_dir))