Refactor build flags handling and add tool alias management
- Introduced a new method `apply_default_string` to streamline the application of default values for string fields in build flags. - Enhanced `apply_flags_table` to utilize the new method for setting various build flags, improving code readability and maintainability. - Added support for additional build flags: `fuse_ld`, `ranlib`, `strip`, `nm`, `objcopy`, `objdump`, and `readelf`. - Implemented a new command `set` to manage tool aliases for compilers, linkers, and shells, allowing users to set preferred tools in the build environment. - Improved error handling and validation for tool alias configuration, ensuring that existing non-symlink files are not replaced. - Added tests to verify the correct behavior of tool alias management and build flag application.
This commit is contained in:
@@ -5,10 +5,17 @@
|
||||
# apply everywhere without crowding the main /etc/depot.toml.
|
||||
|
||||
# Toolchain selection.
|
||||
# tool_dir = "/usr/bin"
|
||||
cc = "clang"
|
||||
# cxx = "clang++"
|
||||
# ar = "ar"
|
||||
# ld = "ld.lld"
|
||||
# cxx = "$TOOL_DIR/clang++"
|
||||
# ar = "$TOOL_DIR/ar"
|
||||
# ranlib = "$TOOL_DIR/ranlib"
|
||||
# strip = "$TOOL_DIR/strip"
|
||||
# ld = "$TOOL_DIR/ld.lld"
|
||||
# nm = "$TOOL_DIR/nm"
|
||||
# objcopy = "$TOOL_DIR/objcopy"
|
||||
# objdump = "$TOOL_DIR/objdump"
|
||||
# readelf = "$TOOL_DIR/readelf"
|
||||
|
||||
# Compiler defaults. These are merged with package-level flags unless a package
|
||||
# explicitly replaces them.
|
||||
@@ -18,6 +25,8 @@ cflags += ["-pipe"]
|
||||
|
||||
# Linker defaults.
|
||||
ldflags = ["-Wl,-O1"]
|
||||
# Select a linker through compiler drivers such as clang/gcc.
|
||||
# fuse_ld = "lld"
|
||||
|
||||
# Link-time optimization policy.
|
||||
ltoflags = ["-flto=auto"]
|
||||
|
||||
+12
-5
@@ -16,15 +16,20 @@ prefix = "/usr"
|
||||
|
||||
# Default toolchain commands. These are passed through to builders that honor
|
||||
# CC/CXX/AR and related variables.
|
||||
# tool_dir = "/usr/bin"
|
||||
cc = "clang"
|
||||
ar = "ar"
|
||||
|
||||
# Optional examples:
|
||||
# cxx = "clang++"
|
||||
# ld = "ld.lld"
|
||||
# cpp = "cpp"
|
||||
# strip = "strip"
|
||||
# ranlib = "ranlib"
|
||||
# cxx = "$TOOL_DIR/clang++"
|
||||
# ld = "$TOOL_DIR/ld.lld"
|
||||
# cpp = "$TOOL_DIR/cpp"
|
||||
# strip = "$TOOL_DIR/strip"
|
||||
# ranlib = "$TOOL_DIR/ranlib"
|
||||
# nm = "$TOOL_DIR/nm"
|
||||
# objcopy = "$TOOL_DIR/objcopy"
|
||||
# objdump = "$TOOL_DIR/objdump"
|
||||
# readelf = "$TOOL_DIR/readelf"
|
||||
|
||||
[build.flags]
|
||||
# Baseline C compiler flags for packages that do not supply their own.
|
||||
@@ -39,6 +44,8 @@ cflags += ["-g"]
|
||||
# Optional C++ and linker defaults:
|
||||
# cxxflags = ["-O2"]
|
||||
ldflags = ["-Wl,-O1"]
|
||||
# Select a linker through compiler drivers such as clang/gcc.
|
||||
# fuse_ld = "lld"
|
||||
|
||||
# Link-time optimization defaults. When use_lto is true, Depot will inject
|
||||
# ltoflags into the appropriate compiler and linker flag sets automatically.
|
||||
|
||||
@@ -10,8 +10,11 @@
|
||||
prefix = "/usr/local"
|
||||
|
||||
# Personal toolchain preference.
|
||||
# tool_dir = "/usr/bin"
|
||||
cc = "clang"
|
||||
# cxx = "clang++"
|
||||
# cxx = "$TOOL_DIR/clang++"
|
||||
# ranlib = "$TOOL_DIR/ranlib"
|
||||
# strip = "$TOOL_DIR/strip"
|
||||
|
||||
[build.flags]
|
||||
# User-local compiler preferences.
|
||||
@@ -22,6 +25,7 @@ carch = "x86_64"
|
||||
# Examples:
|
||||
# cxxflags = ["-O2", "-g"]
|
||||
# ldflags = ["-Wl,-O1"]
|
||||
# fuse_ld = "lld"
|
||||
# makeflags = "-j4"
|
||||
|
||||
# Optional install directory overrides for supported builders.
|
||||
|
||||
Reference in New Issue
Block a user