From f0fa74fde742b23f7de007140bd6c380550a513f Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Tue, 10 May 2022 14:23:01 +0300
Subject: [PATCH] SL-17376 Do not fail build if vcruntime140_1 is missing

If there is no vcruntime140_1 in the build system, it is likely that file is not required for the viewer to run.
---
 indra/lib/python/indra/util/llmanifest.py | 43 +++++++++++++++++++++++
 indra/newview/viewer_manifest.py          |  4 +--
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/indra/lib/python/indra/util/llmanifest.py b/indra/lib/python/indra/util/llmanifest.py
index 30b72282891..aedd3b7ee45 100755
--- a/indra/lib/python/indra/util/llmanifest.py
+++ b/indra/lib/python/indra/util/llmanifest.py
@@ -881,6 +881,49 @@ def try_path(src):
         # particular, let caller notice 0.
         return count
 
+    def path_optional(self, src, dst=None):
+        sys.stdout.flush()
+        if src == None:
+            raise ManifestError("No source file, dst is " + dst)
+        if dst == None:
+            dst = src
+        dst = os.path.join(self.get_dst_prefix(), dst)
+        sys.stdout.write("Processing %s => %s ... " % (src, self._relative_dst_path(dst)))
+
+        def try_path(src):
+            # expand globs
+            count = 0
+            if self.wildcard_pattern.search(src):
+                for s,d in self.expand_globs(src, dst):
+                    assert(s != d)
+                    count += self.process_file(s, d)
+            else:
+                # if we're specifying a single path (not a glob),
+                # we should error out if it doesn't exist
+                self.check_file_exists(src)
+                count += self.process_either(src, dst)
+            return count
+
+        try_prefixes = [self.get_src_prefix(), self.get_artwork_prefix(), self.get_build_prefix()]
+        for pfx in try_prefixes:
+            try:
+                count = try_path(os.path.join(pfx, src))
+            except MissingError:
+                # if we produce MissingError, just try the next prefix
+                continue
+            # If we actually found nonzero files, stop looking
+            if count:
+                break
+        else:
+            sys.stdout.write("Skipping %s\n" % (src))
+            return 0
+
+        print("%d files" % count)
+
+        # Let caller check whether we processed as many files as expected. In
+        # particular, let caller notice 0.
+        return count
+
     def do(self, *actions):
         self.actions = actions
         self.construct()
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 0f940dfa646..de5ac5ed3da 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -527,7 +527,7 @@ def construct(self):
             # See http://msdn.microsoft.com/en-us/library/ms235291(VS.80).aspx
             self.path("msvcp140.dll")
             self.path("vcruntime140.dll")
-            self.path("vcruntime140_1.dll")
+            self.path_optional("vcruntime140_1.dll")
 
             # SLVoice executable
             with self.prefix(src=os.path.join(pkgdir, 'bin', 'release')):
@@ -605,7 +605,7 @@ def construct(self):
                                               'sharedlibs', 'Release')):
                 self.path("msvcp140.dll")
                 self.path("vcruntime140.dll")
-                self.path("vcruntime140_1.dll")
+                self.path_optional("vcruntime140_1.dll")
 
             # CEF files common to all configurations
             with self.prefix(src=os.path.join(pkgdir, 'resources')):
-- 
GitLab