aboutsummaryrefslogtreecommitdiffstats
path: root/build/plugins/copy_files_to_build_prefix.py
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /build/plugins/copy_files_to_build_prefix.py
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'build/plugins/copy_files_to_build_prefix.py')
-rw-r--r--build/plugins/copy_files_to_build_prefix.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/build/plugins/copy_files_to_build_prefix.py b/build/plugins/copy_files_to_build_prefix.py
new file mode 100644
index 0000000000..c8a6e07511
--- /dev/null
+++ b/build/plugins/copy_files_to_build_prefix.py
@@ -0,0 +1,36 @@
+from _common import sort_by_keywords
+
+
+SOURCE_ROOT = '${ARCADIA_ROOT}/'
+BUILD_ROOT = '${ARCADIA_BUILD_ROOT}/'
+CURDIR = '${CURDIR}/'
+BINDIR = '${BINDIR}/'
+
+
+def oncopy_files_to_build_prefix(unit, *args):
+ keywords = {'PREFIX': 1, 'GLOBAL': 0}
+ # NB! keyword 'GLOBAL' is a way to skip this word from the list of files
+
+ flat_args, spec_args = sort_by_keywords(keywords, args)
+ prefix = spec_args['PREFIX'][0] if 'PREFIX' in spec_args else ''
+
+ if len(prefix) > 0:
+ build_prefix = '/'.join([BUILD_ROOT, prefix])
+ else:
+ build_prefix = BUILD_ROOT
+
+ for arg in flat_args:
+ if arg.startswith(build_prefix):
+ # nothing to do
+ pass
+ elif len(prefix) > 0 and arg.startswith(BUILD_ROOT):
+ unit.oncopy_file([arg, '{}/{}'.format(build_prefix, arg[len(BUILD_ROOT):])])
+ elif arg.startswith(SOURCE_ROOT):
+ unit.oncopy_file([arg, '{}/{}'.format(build_prefix, arg[len(SOURCE_ROOT):])])
+ else:
+ offset = 0
+ if arg.startswith(BINDIR):
+ offset = len(BINDIR)
+ elif arg.startswith(CURDIR):
+ offset = len(CURDIR)
+ unit.oncopy_file([arg, '{}/{}/{}'.format(build_prefix, unit.get(['MODDIR']), arg[offset:])])