Skip to content

Commit 60b5653

Browse files
committed
generator
1 parent e4a0c62 commit 60b5653

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

bin/lib/compiler_utils.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,26 @@ def __init__(self, logger, platform: LibraryPlatform = None):
455455
self.logger = logger
456456
self.platform = platform or LibraryPlatform.Linux
457457

458+
def get_cmake_generator(self, make_utility: str = "make") -> List[str]:
459+
"""
460+
Get CMake generator arguments based on platform and make utility.
461+
462+
This follows the same logic as library_builder.py:
463+
- Windows: Always use Ninja
464+
- Linux: Use Ninja if make_utility is "ninja"
465+
466+
Args:
467+
make_utility: The make utility to use (e.g., "make", "ninja")
468+
469+
Returns:
470+
List of CMake arguments for generator selection (empty if default)
471+
"""
472+
if self.platform == LibraryPlatform.Windows:
473+
return ["-G", "Ninja"]
474+
elif self.platform == LibraryPlatform.Linux and make_utility == "ninja":
475+
return ["-G", "Ninja"]
476+
return []
477+
458478
def resolve_compiler_path(self, compiler_path: str) -> Optional[str]:
459479
"""Resolve compiler path to full path."""
460480
if not compiler_path:
@@ -556,7 +576,14 @@ def run_cmake_configuration(self, build_dir: Path, env: Dict[str, str]) -> Tuple
556576
try:
557577
self.logger.info("Running CMake to detect compiler...")
558578

559-
cmd = ["cmake", ".."]
579+
# Use the same generator logic as library_builder.py
580+
generator_args = self.get_cmake_generator("ninja") # Default to ninja for cache extraction
581+
582+
cmd = ["cmake"] + generator_args + [".."]
583+
584+
if generator_args:
585+
self.logger.info(f"Using CMake generator: {' '.join(generator_args)}")
586+
560587
result = subprocess.run(cmd, cwd=build_dir, env=env, capture_output=True, text=True, timeout=300)
561588

562589
if result.returncode != 0:

bin/lib/library_builder.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from lib.amazon import get_ssm_param
2222
from lib.amazon_properties import get_properties_compilers_and_libraries, get_specific_library_version_details
2323
from lib.binary_info import BinaryInfo
24-
from lib.compiler_utils import CompilerInfo, PlatformEnvironmentManager
24+
from lib.compiler_utils import CMakeCacheExtractor, CompilerInfo, PlatformEnvironmentManager
2525
from lib.installation_context import FetchFailure, PostFailure
2626
from lib.library_build_config import LibraryBuildConfig
2727
from lib.library_build_history import LibraryBuildHistory
@@ -119,6 +119,9 @@ def __init__(
119119
# Initialize shared environment manager
120120
self.env_manager = PlatformEnvironmentManager(self.platform)
121121

122+
# Initialize CMake cache extractor for generator logic
123+
self.cmake_extractor = CMakeCacheExtractor(self.logger, self.platform)
124+
122125
self.history = LibraryBuildHistory(self.logger)
123126

124127
if self.language in _propsandlibs:
@@ -603,12 +606,9 @@ def writebuildscript(
603606
'"-DBOOST_IOSTREAMS_ENABLE_ZSTD=OFF" "-DBOOST_LOCALE_ENABLE_ICU=OFF" '
604607
)
605608

606-
generator = ""
607-
if self.platform == LibraryPlatform.Linux:
608-
if make_utility == "ninja":
609-
generator = "-GNinja"
610-
elif self.platform == LibraryPlatform.Windows:
611-
generator = "-GNinja"
609+
# Use shared generator logic from CMakeCacheExtractor
610+
generator_args = self.cmake_extractor.get_cmake_generator(make_utility)
611+
generator = " ".join(generator_args)
612612

613613
for line in self.buildconfig.prebuild_script:
614614
expanded_line = self.expand_build_script_line(

0 commit comments

Comments
 (0)