Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-54914

Add Copy function action handler to ninja

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Backlog
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      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 {}, "
      

        Attachments

          Activity

            People

            Assignee:
            backlog-server-devplatform Backlog - Server Development Platform Team (SDP)
            Reporter:
            daniel.moody Daniel Moody
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: