Skip to content
Snippets Groups Projects
Commit e8c9d194 authored by Rodrigo Mesquita's avatar Rodrigo Mesquita :seedling: Committed by Mikolaj
Browse files

Don't build unnecessary targets of legacy-fallback deps.

The refactor in f70fc980 solved an
inconsistency in `buildAndInstallUnpackedPackage`. Namely, before the
refactor, we didn't pass `hsSetupBuildArgs` to the build invocations,
and afterwards we did.

The result is that build targets of (legacy) package `B`, that a package
`A` depends on, are now passed to the ./Setup build invocation of
package `B` (e.g. `./Setup build lib:openapi3` rather than just `./Setup
build`).

This means we no longer /build always all targets of a legacy-package/
(for example, the lib, the testsuites and the executables).
Instead only the required target (just the lib) will be built.

However, despite now passing the build args to `./Setup build`, we
weren't passing the same arguments to the `./Setup copy` invocation.
Therefore, `./Setup copy` would also try to copy targets of the package
that weren't built, resulting in a failure.

This fixes that failure by correctly passing the build targets to the
`./Setup copy` invocation, just like we do for the `./Setup build` one.

Fixes #9640
parent 3f4c81fd
No related branches found
No related tags found
No related merge requests found
Showing
with 127 additions and 3 deletions
......@@ -109,12 +109,12 @@ import Distribution.Client.ProjectBuilding.PackageFileMonitor
--
-- * Configure phase
-- * Build phase
-- * Haddock phase
-- * Install phase (copy + register)
-- * Register phase
-- * Test phase
-- * Bench phase
-- * Repl phase
-- * Haddock phase
--
-- Depending on whether we are installing the package or building it inplace,
-- the phases will be carried out differently. For example, when installing,
......@@ -183,7 +183,7 @@ buildAndRegisterUnpackedPackage
-- Build phase
delegate $
PBBuildPhase $
annotateFailure mlogFile BuildFailed $
annotateFailure mlogFile BuildFailed $ do
setup buildCommand buildFlags buildArgs
-- Haddock phase
......@@ -198,7 +198,7 @@ buildAndRegisterUnpackedPackage
PBInstallPhase
{ runCopy = \destdir ->
annotateFailure mlogFile InstallFailed $
setup Cabal.copyCommand (copyFlags destdir) (const [])
setup Cabal.copyCommand (copyFlags destdir) copyArgs
, runRegister = \pkgDBStack registerOpts ->
annotateFailure mlogFile InstallFailed $ do
-- We register ourselves rather than via Setup.hs. We need to
......@@ -284,6 +284,9 @@ buildAndRegisterUnpackedPackage
verbosity
builddir
destdir
-- In theory, we could want to copy less things than those that were
-- built, but instead, we simply copy the targets that were built.
copyArgs = buildArgs
testCommand = Cabal.testCommand -- defaultProgramDb
testFlags v =
......
# Revision history for depend-on-custom-with-exe
## 0.1.0.0 -- YYYY-mm-dd
* First version. Released on an unsuspecting world.
Copyright (c) 2024, Rodrigo Mesquita
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Rodrigo Mesquita nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# cabal v2-update
Downloading the latest package list from test-local-repo
# cabal build
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- one-custom-0.1.0.0 (lib:one-custom) (requires build)
- depend-on-custom-with-exe-0.1.0.0 (lib) (first run)
Configuring one-custom-0.1.0.0...
Preprocessing library for one-custom-0.1.0.0..
Building library for one-custom-0.1.0.0..
Installing library in <PATH>
Warning: depend-on-custom-with-exe.cabal:16:1: Ignoring trailing fields after sections: "ghc-options"
Configuring library for depend-on-custom-with-exe-0.1.0.0...
Preprocessing library for depend-on-custom-with-exe-0.1.0.0...
Building library for depend-on-custom-with-exe-0.1.0.0...
packages: .
extra-packages: one-custom
import Test.Cabal.Prelude
main = cabalTest $ withRepo "repo" $ do
skipUnlessGhcVersion ">= 8.8"
cabal "build" ["depend-on-custom-with-exe"]
cabal-version: 2.4
name: depend-on-custom-with-exe
version: 0.1.0.0
-- synopsis:
-- description:
license: BSD-3-Clause
license-file: LICENSE
author: Rodrigo Mesquita
maintainer: rodrigo.m.mesquita@gmail.com
-- copyright:
build-type: Simple
extra-doc-files: CHANGELOG.md
-- extra-source-files:
common warnings
ghc-options: -Wall
library
import: warnings
exposed-modules: MyLib
build-depends: base, one-custom
hs-source-dirs: src
default-language: Haskell2010
# Revision history for one-custom
## 0.1.0.0 -- YYYY-mm-dd
* First version. Released on an unsuspecting world.
main = putStrLn "Hello"
import Distribution.Simple
main = defaultMain
packages: .
cabal-version: 2.4
name: one-custom
version: 0.1.0.0
license: NONE
build-type: Custom
extra-doc-files: CHANGELOG.md
custom-setup
setup-depends: base, Cabal
common warnings
ghc-options: -Wall
library
import: warnings
exposed-modules: MyLib
build-depends: base
hs-source-dirs: src
default-language: Haskell2010
executable example
main-is: Main.hs
default-language: Haskell2010
build-depends: base
module MyLib (someFunc) where
someFunc :: IO ()
someFunc = putStrLn "someFunc"
module MyLib (someFunc) where
someFunc :: IO ()
someFunc = putStrLn "someFunc"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment