-
Notifications
You must be signed in to change notification settings - Fork 66
[legacy] build: Add CI_BUILD_MODE to reduce disk usage
#578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dennisklein
wants to merge
1
commit into
FairRootGroup:dev
Choose a base branch
from
dennisklein:ci-build-mode
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # reclaim-diskspace.cmake | ||
| # Remove package build/source directories after install to reclaim disk space | ||
| # Expected variables: PACKAGE_NAME, PKG_BUILD_DIR, PKG_SOURCE_DIR, CMAKE_BINARY_DIR | ||
dennisklein marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if(NOT DEFINED PACKAGE_NAME OR NOT DEFINED PKG_BUILD_DIR OR NOT DEFINED PKG_SOURCE_DIR) | ||
| message(FATAL_ERROR "PACKAGE_NAME, PKG_BUILD_DIR, and PKG_SOURCE_DIR must be defined") | ||
| endif() | ||
|
|
||
| # Helper function to measure directory size in MB | ||
| function(measure_dir_size_mb dir out_var out_success) | ||
| set(${out_success} FALSE PARENT_SCOPE) | ||
| set(${out_var} 0 PARENT_SCOPE) | ||
| if(UNIX) | ||
| find_program(DU_EXECUTABLE du) | ||
| if(DU_EXECUTABLE) | ||
| execute_process( | ||
| COMMAND ${DU_EXECUTABLE} -sk "${dir}" | ||
| OUTPUT_VARIABLE du_output | ||
| ERROR_QUIET | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ) | ||
| if(du_output) | ||
| string(REGEX REPLACE "^([0-9]+).*" "\\1" size_kb "${du_output}") | ||
| math(EXPR size_mb "${size_kb} / 1024") | ||
| set(${out_var} ${size_mb} PARENT_SCOPE) | ||
| set(${out_success} TRUE PARENT_SCOPE) | ||
| endif() | ||
| endif() | ||
| endif() | ||
| endfunction() | ||
|
|
||
| # Measure sizes before removal | ||
| measure_dir_size_mb("${PKG_BUILD_DIR}" build_mb build_ok) | ||
| measure_dir_size_mb("${PKG_SOURCE_DIR}" source_mb source_ok) | ||
|
|
||
| if(build_ok AND source_ok) | ||
| math(EXPR total_mb "${build_mb} + ${source_mb}") | ||
| message(STATUS "[${PACKAGE_NAME}] Reclaiming ~${total_mb} MB (build: ${build_mb}, source: ${source_mb})") | ||
| elseif(build_ok) | ||
| message(STATUS "[${PACKAGE_NAME}] Reclaiming ~${build_mb} MB") | ||
| elseif(source_ok) | ||
| message(STATUS "[${PACKAGE_NAME}] Reclaiming ~${source_mb} MB") | ||
| else() | ||
| message(STATUS "[${PACKAGE_NAME}] Removing package directories...") | ||
| endif() | ||
|
|
||
| # Remove package directories | ||
| execute_process(COMMAND ${CMAKE_COMMAND} -E rm -rf "${PKG_BUILD_DIR}" RESULT_VARIABLE build_rm) | ||
| execute_process(COMMAND ${CMAKE_COMMAND} -E rm -rf "${PKG_SOURCE_DIR}" RESULT_VARIABLE source_rm) | ||
|
|
||
| if(NOT build_rm EQUAL 0) | ||
| message(WARNING "[${PACKAGE_NAME}] Failed to remove package build directory") | ||
| endif() | ||
| if(NOT source_rm EQUAL 0) | ||
| message(WARNING "[${PACKAGE_NAME}] Failed to remove package source directory") | ||
| endif() | ||
|
|
||
| # Report total build tree size | ||
| if(DEFINED CMAKE_BINARY_DIR) | ||
| measure_dir_size_mb("${CMAKE_BINARY_DIR}" tree_mb tree_ok) | ||
| if(tree_ok) | ||
| message(STATUS "[${PACKAGE_NAME}] Build tree size: ${tree_mb} MB") | ||
| endif() | ||
| endif() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fuhlig1 also documented here