diff --git a/internal/rosa/cmake.go b/internal/rosa/cmake.go index 5a97dff..13ad917 100644 --- a/internal/rosa/cmake.go +++ b/internal/rosa/cmake.go @@ -51,12 +51,16 @@ type CMakeAttr struct { Env []string // Runs before cmake. ScriptEarly string - // Runs after cmake. + // Runs after cmake, replaces default. + ScriptConfigured string + // Runs after install. Script string // Override the default installation prefix [AbsSystem]. Prefix *check.Absolute + // Passed through to [Toolchain.New]. + Paths []pkg.ExecPath // Passed through to [Toolchain.New]. Flag int } @@ -82,11 +86,9 @@ func (t Toolchain) NewViaCMake( panic("CACHE must be non-empty") } - scriptEarly := attr.ScriptEarly - if attr.Writable { - scriptEarly = ` -chmod -R +w "${ROSA_SOURCE}" -` + scriptEarly + scriptConfigured := "cmake --build .\ncmake --install .\n" + if attr.ScriptConfigured != "" { + scriptConfigured = attr.ScriptConfigured } prefix := attr.Prefix @@ -102,7 +104,7 @@ chmod -R +w "${ROSA_SOURCE}" "ROSA_SOURCE=" + sourcePath.String(), "ROSA_CMAKE_SOURCE=" + sourcePath.Append(attr.Append...).String(), "ROSA_INSTALL_PREFIX=/work" + prefix.String(), - }, attr.Env), scriptEarly+` + }, attr.Env), attr.ScriptEarly+` mkdir /cure && cd /cure cmake -G Ninja \ -DCMAKE_C_COMPILER_TARGET="${ROSA_TRIPLE}" \ @@ -117,7 +119,7 @@ cmake -G Ninja \ }), " \\\n\t")+` \ -DCMAKE_INSTALL_PREFIX="${ROSA_INSTALL_PREFIX}" \ "${ROSA_CMAKE_SOURCE}" -cmake --build . -cmake --install . -`+attr.Script, pkg.Path(sourcePath, attr.Writable, source)) +`+scriptConfigured+attr.Script, slices.Concat([]pkg.ExecPath{ + pkg.Path(sourcePath, attr.Writable, source), + }, attr.Paths)...) } diff --git a/internal/rosa/llvm.go b/internal/rosa/llvm.go index 684672b..a5e375f 100644 --- a/internal/rosa/llvm.go +++ b/internal/rosa/llvm.go @@ -22,12 +22,18 @@ type llvmAttr struct { cmake [][2]string // Override CMakeAttr.Append. append []string - // Concatenated with default dependencies for CMakeAttr.Extra. + // Concatenated with default dependencies for Toolchain.NewViaCMake. extra []pkg.Artifact + // Passed through to CMakeAttr.Paths. + paths []pkg.ExecPath + // Passed through to CMakeAttr.ScriptConfigured. + scriptConfigured string // Concatenated with default fixup for CMakeAttr.Script. script string // Passed through to CMakeAttr.Prefix. prefix *check.Absolute + // Passed through to CMakeAttr.Writable. + writable bool // Patch name and body pairs. patches [][2]string @@ -186,9 +192,13 @@ cp -r /system/include /usr/include && rm -rf /system/include "ROSA_LLVM_PROJECTS=" + strings.Join(projects, ";"), "ROSA_LLVM_RUNTIMES=" + strings.Join(runtimes, ";"), }, attr.env), - ScriptEarly: scriptEarly, Script: script + attr.script, + ScriptEarly: scriptEarly, + ScriptConfigured: attr.scriptConfigured, + Script: script + attr.script, + Writable: attr.writable, - Flag: TExclusive, + Paths: attr.paths, + Flag: TExclusive, }, stage3Concat(t, attr.extra, t.Load(Libffi), t.Load(Python),