summaryrefslogtreecommitdiffstats
path: root/build/scripts/thinlto_cache.py
diff options
context:
space:
mode:
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 00000000000..35ab7552620
--- /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))