Skip to content

Commit e180cbf

Browse files
committed
scripts: add command line options to override googletest build options
These new command line options can be used for CI without having to configure googletest's optons in the known-good.json. Useful when building vkconfig staticly for CI. scripts/update_deps.py: - add 2 new options `---gtest-shared-libs` and `--gtest-force-shared-crt` that allows a user to specify values for googletest cmake build options "BUILD_SHARED_LIBS" and/or "gtest_force_shared_crt"
1 parent 640f35d commit e180cbf

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

scripts/update_deps.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,14 @@ def CMakeConfig(self, repos):
482482
var_name=d['var_name'],
483483
install_dir=dep_commit[0].install_dir))
484484

485+
if self.name == "googletest" and (self._args.gtest_shared_libs or self._args.gtest_force_shared_crt):
486+
for index,option in enumerate(self.cmake_options):
487+
if self._args.gtest_shared_libs and 'build_shared_libs' in option.lower():
488+
self.cmake_options[index] = f"-DBUILD_SHARED_LIBS={str(self._args.gtest_shared_libs)}"
489+
print(f'INFO: Setting googletest option: -DBUILD_SHARED_LIBS={str(self._args.gtest_shared_libs)}')
490+
if self._args.gtest_force_shared_crt and 'gtest_force_shared_crt' in option.lower():
491+
self.cmake_options[index] = f"-Dgtest_force_shared_crt={str(self._args.gtest_force_shared_crt)}"
492+
print(f'INFO: Setting googletest option: -Dgtest_force_shared_crt={str(self._args.gtest_force_shared_crt)}')
485493
# Add any CMake options
486494
for option in self.cmake_options:
487495
cmake_cmd.append(escape(option.format(**self.__dict__)))
@@ -713,6 +721,18 @@ def main():
713721
metavar='VAR[=VALUE]',
714722
help="Add CMake command line option -D'VAR'='VALUE' to the CMake generation command line; may be used multiple times",
715723
default=[])
724+
parser.add_argument(
725+
'--gtest-shared-libs',
726+
dest='gtest_shared_libs',
727+
type=str.upper,
728+
choices=['ON','OFF','YES','NO','TRUE','FALSE'],
729+
help="Set googletest's BUILD_SHARED_LIBS option (overrides known-good.json values)")
730+
parser.add_argument(
731+
'--gtest-force-shared-crt',
732+
dest='gtest_force_shared_crt',
733+
type=str.upper,
734+
choices=['ON','OFF','YES','NO','TRUE','FALSE'],
735+
help="Set googletest's gtest_force_shared_crt option (overrides known-good.json values)")
716736

717737
args = parser.parse_args()
718738
save_cwd = os.getcwd()
@@ -794,4 +814,4 @@ def main():
794814

795815

796816
if __name__ == '__main__':
797-
main()
817+
main()

0 commit comments

Comments
 (0)