-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bugfix/reproducible_builds_improvements' into 'master'
build system: reproducible build improvements Closes IDFGH-12690 See merge request espressif/esp-idf!32734
- Loading branch information
Showing
18 changed files
with
246 additions
and
206 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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,54 @@ | ||
# Utilities for remapping path prefixes | ||
# | ||
# __generate_prefix_map | ||
# Prepares the list of compiler flags for remapping various paths | ||
# to fixed names. This is used when reproducible builds are required. | ||
# This function also creates a gdbinit file for the debugger to | ||
# remap the substituted paths back to the real paths in the filesystem. | ||
function(__generate_prefix_map compile_options_var) | ||
set(compile_options) | ||
idf_build_get_property(idf_path IDF_PATH) | ||
idf_build_get_property(build_components BUILD_COMPONENTS) | ||
|
||
if(CONFIG_COMPILER_HIDE_PATHS_MACROS) | ||
list(APPEND compile_options "-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=.") | ||
list(APPEND compile_options "-fmacro-prefix-map=${idf_path}=/IDF") | ||
endif() | ||
|
||
if(CONFIG_APP_REPRODUCIBLE_BUILD) | ||
list(APPEND compile_options "-fdebug-prefix-map=${idf_path}=/IDF") | ||
list(APPEND compile_options "-fdebug-prefix-map=${PROJECT_DIR}=/IDF_PROJECT") | ||
list(APPEND compile_options "-fdebug-prefix-map=${BUILD_DIR}=/IDF_BUILD") | ||
|
||
# Generate mapping for component paths | ||
set(gdbinit_file_lines) | ||
foreach(component_name ${build_components}) | ||
idf_component_get_property(component_dir ${component_name} COMPONENT_DIR) | ||
|
||
string(TOUPPER ${component_name} component_name_uppercase) | ||
set(substituted_path "/COMPONENT_${component_name_uppercase}_DIR") | ||
list(APPEND compile_options "-fdebug-prefix-map=${component_dir}=${substituted_path}") | ||
string(APPEND gdbinit_file_lines "set substitute-path ${substituted_path} ${component_dir}\n") | ||
endforeach() | ||
|
||
# Mapping for toolchain path | ||
execute_process( | ||
COMMAND ${CMAKE_C_COMPILER} -print-sysroot | ||
OUTPUT_VARIABLE compiler_sysroot | ||
) | ||
if(compiler_sysroot STREQUAL "") | ||
message(FATAL_ERROR "Failed to determine toolchain sysroot") | ||
endif() | ||
string(STRIP "${compiler_sysroot}" compiler_sysroot) | ||
get_filename_component(compiler_sysroot "${compiler_sysroot}/.." REALPATH) | ||
list(APPEND compile_options "-fdebug-prefix-map=${compiler_sysroot}=/TOOLCHAIN") | ||
string(APPEND gdbinit_file_lines "set substitute-path /TOOLCHAIN ${compiler_sysroot}\n") | ||
|
||
# Write the final gdbinit file | ||
set(gdbinit_path "${BUILD_DIR}/prefix_map_gdbinit") | ||
file(WRITE "${gdbinit_path}" "${gdbinit_file_lines}") | ||
idf_build_set_property(DEBUG_PREFIX_MAP_GDBINIT "${gdbinit_path}") | ||
endif() | ||
|
||
set(${compile_options_var} ${compile_options} PARENT_SCOPE) | ||
endfunction() |
This file was deleted.
Oops, something went wrong.
This file contains 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
29 changes: 22 additions & 7 deletions
29
tools/test_build_system/test_build_system_helpers/__init__.py
This file contains 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 |
---|---|---|
@@ -1,15 +1,30 @@ | ||
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from .build_constants import ALL_ARTIFACTS, APP_BINS, BOOTLOADER_BINS, JSON_METADATA, PARTITION_BIN | ||
from .editing import append_to_file, replace_in_file | ||
from .idf_utils import (EXT_IDF_PATH, EnvDict, IdfPyFunc, bin_file_contains, file_contains, find_python, | ||
get_idf_build_env, run_cmake, run_cmake_and_build, run_idf_py) | ||
from .snapshot import Snapshot, get_snapshot | ||
from .build_constants import ALL_ARTIFACTS | ||
from .build_constants import APP_BINS | ||
from .build_constants import BOOTLOADER_BINS | ||
from .build_constants import JSON_METADATA | ||
from .build_constants import PARTITION_BIN | ||
from .file_utils import append_to_file | ||
from .file_utils import bin_file_contains | ||
from .file_utils import bin_files_differ | ||
from .file_utils import file_contains | ||
from .file_utils import replace_in_file | ||
from .idf_utils import EnvDict | ||
from .idf_utils import EXT_IDF_PATH | ||
from .idf_utils import find_python | ||
from .idf_utils import get_idf_build_env | ||
from .idf_utils import IdfPyFunc | ||
from .idf_utils import run_cmake | ||
from .idf_utils import run_cmake_and_build | ||
from .idf_utils import run_idf_py | ||
from .snapshot import get_snapshot | ||
from .snapshot import Snapshot | ||
|
||
__all__ = [ | ||
'append_to_file', 'replace_in_file', | ||
'get_idf_build_env', 'run_idf_py', 'EXT_IDF_PATH', 'EnvDict', 'IdfPyFunc', | ||
'Snapshot', 'get_snapshot', 'run_cmake', 'APP_BINS', 'BOOTLOADER_BINS', | ||
'PARTITION_BIN', 'JSON_METADATA', 'ALL_ARTIFACTS', | ||
'run_cmake_and_build', 'find_python', 'file_contains', 'bin_file_contains' | ||
'run_cmake_and_build', 'find_python', 'file_contains', 'bin_file_contains', 'bin_files_differ' | ||
] |
17 changes: 0 additions & 17 deletions
17
tools/test_build_system/test_build_system_helpers/editing.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.