Can we change componentBuildDir to distinguish different types of components?
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
Currently, we have:
```haskell
componentBuildDir :: LocalBuildInfo -> ComponentLocalBuildInfo -> FilePath
componentBuildDir lbi clbi =
buildDir lbi
case componentLocalName clbi of
CLibName LMainLibName ->
if prettyShow (componentUnitId clbi) == prettyShow (componentComponentId clbi)
then ""
else prettyShow (componentUnitId clbi)
CLibName (LSubLibName s) ->
if prettyShow (componentUnitId clbi) == prettyShow (componentComponentId clbi)
then unUnqualComponentName s
else prettyShow (componentUnitId clbi)
CFLibName s -> unUnqualComponentName s
CExeName s -> unUnqualComponentName s
CTestName s -> unUnqualComponentName s
CBenchName s -> unUnqualComponentName s
```
Ignoring the Backpack-related stuff about libraries, one issue here is that one can end up with the same build directory for a library and an executable of the same name. Instead, I would expect library build dirs to be given by `buildDir lbi "lib" nm` and the executable build dirs to be `buildDir lbi "exe" nm`.
This potential for clashes was the source of workarounds, e.g. using `buildDir lbi nm nl ++ "-tmp"` to avoid the build path for a non-library clashing with the main library build path. I believe this workaround was introduced by commit 56bb1badce6ba49aaa14b3b62e43d2a09bd66711.
How feasible would such a change be? I imagine changing the structure of these `buildDir`s could break assumptions people make about where build products are put, but I think it would be nicer if build products were always simply put in `componentBuildDir` and that there are no additional workarounds piled on top involving `-tmp`.
Contributor guide
Assessment
This issue has not been assessed yet.