MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-ValidationLayers / CMakeConfig

Method CMakeConfig

scripts/update_deps.py:580–656  ·  view source on GitHub ↗

Build CMake command for the configuration phase and execute it

(self, repos)

Source from the content-addressed store, hash-verified

578 command_output(shlex.split(cmd), self.repo_dir)
579
580 def CMakeConfig(self, repos):
581 """Build CMake command for the configuration phase and execute it"""
582 if self._args.do_clean_build:
583 if os.path.isdir(self.build_dir):
584 shutil.rmtree(self.build_dir, onerror=on_rm_error)
585 if self._args.do_clean_install:
586 if os.path.isdir(self.install_dir):
587 shutil.rmtree(self.install_dir, onerror=on_rm_error)
588
589 # Create and change to build directory
590 make_or_exist_dirs(self.build_dir)
591 os.chdir(self.build_dir)
592
593 cmake_cmd = [
594 'cmake', self.repo_dir,
595 '-DCMAKE_INSTALL_PREFIX=' + self.install_dir
596 ]
597
598 # Allow users to pass in arbitrary cache variables
599 for cmake_var in self._args.cmake_var:
600 pieces = cmake_var.split('=', 1)
601 cmake_cmd.append('-D{}={}'.format(pieces[0], pieces[1]))
602
603 # For each repo this repo depends on, generate a CMake variable
604 # definitions for "...INSTALL_DIR" that points to that dependent
605 # repo's install dir.
606 for d in self.deps:
607 dep_commit = [r for r in repos if r.name == d['repo_name']]
608 if len(dep_commit) and dep_commit[0].on_build_platform and dep_commit[0].on_build_architecture:
609 cmake_cmd.append('-D{var_name}={install_dir}'.format(
610 var_name=d['var_name'],
611 install_dir=dep_commit[0].install_dir))
612
613 # Add any CMake options
614 for option in self.cmake_options:
615 cmake_cmd.append(escape(option.format(**self.__dict__)))
616
617 # Set build config for single-configuration generators (this is a no-op on multi-config generators)
618 cmake_cmd.append(f'-D CMAKE_BUILD_TYPE={CONFIG_MAP[self._args.config]}')
619
620 # Optionally build dependencies with ASAN enabled
621 if self._args.asan:
622 cmake_cmd.append(f'-D CMAKE_CXX_FLAGS=-fsanitize=address')
623 cmake_cmd.append(f'-D CMAKE_C_FLAGS=-fsanitize=address')
624 if platform.system() != 'Windows':
625 os.environ['LDFLAGS'] = '-fsanitize=address'
626
627 # Optionally build dependencies with UBSAN enabled
628 if self._args.ubsan:
629 cmake_cmd.append('-D CMAKE_CXX_FLAGS=-fsanitize=undefined -fno-sanitize=enum')
630 cmake_cmd.append('-D CMAKE_C_FLAGS=-fsanitize=undefined')
631 cmake_cmd.append('-D ENABLE_RTTI=ON')
632 os.environ['LDFLAGS'] = '-fsanitize=undefined'
633
634 # Use the CMake -A option to select the platform architecture
635 # without needing a Visual Studio generator.
636 if platform.system() == 'Windows' and self._args.generator != "Ninja":
637 cmake_cmd.append('-A')

Callers 1

BuildMethod · 0.95

Calls 4

make_or_exist_dirsFunction · 0.85
escapeFunction · 0.85
run_cmake_commandFunction · 0.85
splitMethod · 0.45

Tested by

no test coverage detected