expandVariables expands placeholder variables in the given string and returns the result. Placeholders like ${CC}, ${CXX}, ${SYSROOT}, etc. are replaced with actual values.
(content string)
| 883 | // expandVariables expands placeholder variables in the given string and returns the result. |
| 884 | // Placeholders like ${CC}, ${CXX}, ${SYSROOT}, etc. are replaced with actual values. |
| 885 | func (b BuildConfig) expandVariables(content string) string { |
| 886 | toolchain := b.Ctx.Platform().GetToolchain() |
| 887 | rootfs := b.Ctx.Platform().GetRootFS() |
| 888 | |
| 889 | // Replace ${CC}, ${CXX}, ${HOST_CC} for compiler paths. |
| 890 | // For Clang with sysroot, add --gcc-toolchain to find GCC runtime files. |
| 891 | ccValue := toolchain.GetCC() |
| 892 | cxxValue := toolchain.GetCXX() |
| 893 | if !b.DevDep && rootfs != nil && toolchain.GetName() == "clang" { |
| 894 | ccValue += " --gcc-toolchain=/usr" |
| 895 | cxxValue += " --gcc-toolchain=/usr" |
| 896 | } |
| 897 | content = strings.ReplaceAll(content, "${CC}", ccValue) |
| 898 | content = strings.ReplaceAll(content, "${CXX}", cxxValue) |
| 899 | |
| 900 | content = b.ExprVars.Expand(content) |
| 901 | return content |
| 902 | } |
| 903 | |
| 904 | // IsPythonPackage returns true if the build config references Python placeholders |
| 905 | // in its custom commands, indicating it's a Python package that should be installed |
no test coverage detected