Skip to content

Allow stack build to target sub-libraries #6042

Open
@philderbeast

Description

@philderbeast

Could we add lib as a comptype in docs section for target syntax?

  • component. Instead of referring to an entire package and letting Stack decide which components to build, you select individual components from inside a package. This can be done for more fine-grained control over which test suites to run, or to have a faster compilation cycle. There are multiple ways to refer to a specific component (provided for convenience):

packagename:comptype:compname is the most explicit. The available comptypes are exe, test, and bench.
SOURCE: Target syntax

There's no mention of lib as comptype but I can use it.

$ stack repl stack:lib
stack> initial-build-steps (lib)
Configuring GHCi with the following packages: stack
GHCi, version 9.2.5: https://www.haskell.org/ghc/  :? for help
[  1 of 117] Compiling Network.HTTP.StackClient
...
[117 of 117] Compiling Stack.Ls
Ok, 117 modules loaded.
ghci>

I see it listed as a packagename:comptype target:

$ stack ide targets
stack:lib
stack:exe:stack
stack:exe:stack-integration-test
stack:test:stack-test

The library name is the same as the package name but we can't use that as a packagename:comptype:compname target.

$ stack repl stack:lib:stack
Error: [S-6948]
TargetParseException ["Directory not found: stack:lib:stack"]
Note that to specify options to be passed to GHCi, use the '--ghci-options' flag.

When we support multiple library packages we'll need to be able to specify the compname of libraries. Before that feature lands we could allow compname for libraries.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions