aboutsummaryrefslogtreecommitdiffstats
path: root/build/plugins/cp.py
diff options
context:
space:
mode:
authoralexv-smirnov <alex@ydb.tech>2023-06-13 11:05:01 +0300
committeralexv-smirnov <alex@ydb.tech>2023-06-13 11:05:01 +0300
commitbf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0 (patch)
tree1d1df72c0541a59a81439842f46d95396d3e7189 /build/plugins/cp.py
parent8bfdfa9a9bd19bddbc58d888e180fbd1218681be (diff)
downloadydb-bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0.tar.gz
add ymake export to ydb
Diffstat (limited to 'build/plugins/cp.py')
-rw-r--r--build/plugins/cp.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/build/plugins/cp.py b/build/plugins/cp.py
new file mode 100644
index 0000000000..5c663a3bdd
--- /dev/null
+++ b/build/plugins/cp.py
@@ -0,0 +1,30 @@
+import os
+
+from _common import sort_by_keywords
+
+
+def oncopy(unit, *args):
+ keywords = {'RESULT': 1, 'KEEP_DIR_STRUCT': 0, 'DESTINATION': 1, 'FROM': 1}
+
+ flat_args, spec_args = sort_by_keywords(keywords, args)
+
+ dest_dir = spec_args['DESTINATION'][0] if 'DESTINATION' in spec_args else ''
+ from_dir = spec_args['FROM'][0] if 'FROM' in spec_args else ''
+ keep_struct = 'KEEP_DIR_STRUCT' in spec_args
+ save_in_var = 'RESULT' in spec_args
+ targets = []
+
+ for source in flat_args:
+ rel_path = ''
+ path_list = source.split(os.sep)
+ filename = path_list[-1]
+ if keep_struct:
+ if path_list[:-1]:
+ rel_path = os.path.join(*path_list[:-1])
+ source_path = os.path.join(from_dir, rel_path, filename)
+ target_path = os.path.join(dest_dir, rel_path, filename)
+ if save_in_var:
+ targets.append(target_path)
+ unit.oncopy_file([source_path, target_path])
+ if save_in_var:
+ unit.set([spec_args["RESULT"][0], " ".join(targets)])