[SERVER-54914] Add Copy function action handler to ninja Created: 03/Mar/21  Updated: 29/Aug/23  Resolved: 29/Aug/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Daniel Moody Assignee: [DO NOT ASSIGN] Backlog - Server Development Platform Team (SDP) (Inactive)
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-64664 ninja tool should not consider instal... Closed
Assigned Teams:
Server Development Platform
Participants:

 Description   

In SERVER-48203, a SCons Copy function action handler was added to ninja then removed to avoid scope creep. This should be added back in, and one place where we could switch to using Copy Function again is in the copy of wiredtiger_ext.h in the third_party/wiredtiger/SConscript. In SERVER-48203 it was switched to Substfile which prevented need to change ninja stable, but it suboptimally performs a copy sending io through python where shutil.copy2 from the real Copy function action would be faster. Add the patch code below and switch wiredtiger_ext.h to use Copy:

index 6448bf428b..d95d6f8c40 100644
--- a/site_scons/site_tools/ninja.py
+++ b/site_scons/site_tools/ninja.py
@@ -102,6 +102,17 @@ def _lib_symlink_action_function(_env, node):
         "implicit": get_dependencies(node),
     }
 
+def _copy_action_function(env, node):
+    output_node = get_outputs(node)[0]
+    input_node = get_inputs(node)[0]
+    return {
+        "outputs": [output_node],
+        "inputs": [input_node],
+        "rule": "CMD",
+        "variables": {
+            "cmd": f"$COPY {input_node} {output_node}",
+        },
+    }
 
 def is_valid_dependent_node(node):
     """
@@ -254,6 +265,7 @@ class SConsToNinjaTranslator:
             "installFunc": _install_action_function,
             "MkdirFunc": _mkdir_action_function,
             "LibSymlinksActionFunction": _lib_symlink_action_function,
+            "Copy": _copy_action_function
         }
 
         self.loaded_custom = False
@@ -322,6 +334,11 @@ class SConsToNinjaTranslator:
         handler = self.func_handlers.get(name, None)
         if handler is not None:
             return handler(node.env if node.env else self.env, node)
+        elif name == "ActionCaller":
+            action_to_call = str(action).split('(')[0].strip()
+            handler = self.func_handlers.get(action_to_call, None)
+            if handler is not None:
+                return handler(node.env if node.env else self.env, node)
 
         raise Exception(
             "Found unhandled function action {}, "


Generated at Thu Feb 08 05:34:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.