Skip to content

Commit

Permalink
Always print output when refreshing cache (#177)
Browse files Browse the repository at this point in the history
* Print output when refreshing cache

* Add backwards compatibility
  • Loading branch information
thomas-bc authored Nov 27, 2023
1 parent bcfba3e commit a764e07
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions src/fprime/fbuild/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ def get_project_relative_path(self, path, build_dir):
Returns:
path string that is relative to some root of the project. i.e. used for target suffix names
"""
if path is None:
path = os.getcwd()
# Get module name from the relative path to include root
include_root = self.get_include_info(path, build_dir)[1]
return os.path.relpath(path, include_root)
Expand Down Expand Up @@ -341,6 +343,17 @@ def get_available_targets(self, build_dir, path):
if make.startswith(prefix)
]

def is_target_supported(self, build_dir: str, target: str):
"""Checks if a target is supported by the current build directory
Args:
build_dir: build directory to use for detecting targets
target: target name to check
"""
# Load in self.cached_help_targets
self.get_available_targets(build_dir, None)
return target in self.cached_help_targets

@staticmethod
def purge(build_dir):
"""
Expand Down Expand Up @@ -425,7 +438,7 @@ def cmake_refresh_cache(self, build_dir, full=False):
for before the utility gives up and produces.
:param build_dir: directory to build in
:param full: full re-generate of the cache. Default: false, attempt to build 'noop' target instead
:param full: full re-generate of the cache. Default: false, attempt to build 'refresh_cache' target instead
"""
if full:
environment = {}
Expand All @@ -439,19 +452,30 @@ def cmake_refresh_cache(self, build_dir, full=False):
run_args,
write_override=True,
environment=environment,
print_output=self.verbose,
print_output=True,
)
else:
if self.verbose:
print("[CMAKE] Checking CMake cache for rebuild")
self.execute_known_target(
"noop",
build_dir,
None,
top_target=True,
full_cache_rebuild=True,
print_output=self.verbose,
)
# Backwards compatibility: refresh_cache was named noop until v3.3.x
if self.is_target_supported(build_dir, "noop"):
self.execute_known_target(
"noop",
build_dir,
None,
top_target=True,
full_cache_rebuild=True,
print_output=True,
)
else:
self.execute_known_target(
"refresh_cache",
build_dir,
None,
top_target=True,
full_cache_rebuild=True,
print_output=True,
)

def _run_cmake(
self,
Expand Down

0 comments on commit a764e07

Please sign in to comment.