Skip to content

Commit 4c9e315

Browse files
authored
Merge pull request #10890 from haskell/mergify/bp/3.14/pr-10826
Backport #10826: Append paths in global config to progdb in configureCompiler v2
2 parents a8cf469 + a89dd4e commit 4c9e315

File tree

13 files changed

+174
-7
lines changed

13 files changed

+174
-7
lines changed

cabal-install/src/Distribution/Client/ProjectPlanning.hs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ configureCompiler
470470
{ projectConfigHcFlavor
471471
, projectConfigHcPath
472472
, projectConfigHcPkg
473+
, projectConfigProgPathExtra
473474
}
474475
, projectConfigLocalPackages =
475476
PackageConfig
@@ -493,25 +494,28 @@ configureCompiler
493494
)
494495
$ do
495496
liftIO $ info verbosity "Compiler settings changed, reconfiguring..."
496-
let extraPath = fromNubList packageConfigProgramPathExtra
497-
progdb <- liftIO $ prependProgramSearchPath verbosity extraPath [] defaultProgramDb
498-
let progdb' = userSpecifyPaths (Map.toList (getMapLast packageConfigProgramPaths)) progdb
499-
result@(_, _, progdb'') <-
497+
progdb <-
498+
liftIO $
499+
-- Add paths in the global config
500+
prependProgramSearchPath verbosity (fromNubList projectConfigProgPathExtra) [] defaultProgramDb
501+
-- Add paths in the local config
502+
>>= prependProgramSearchPath verbosity (fromNubList packageConfigProgramPathExtra) []
503+
>>= pure . userSpecifyPaths (Map.toList (getMapLast packageConfigProgramPaths))
504+
result@(_, _, progdb') <-
500505
liftIO $
501506
Cabal.configCompilerEx
502507
hcFlavor
503508
hcPath
504509
hcPkg
505-
progdb'
510+
progdb
506511
verbosity
507-
508512
-- Note that we added the user-supplied program locations and args
509513
-- for /all/ programs, not just those for the compiler prog and
510514
-- compiler-related utils. In principle we don't know which programs
511515
-- the compiler will configure (and it does vary between compilers).
512516
-- We do know however that the compiler will only configure the
513517
-- programs it cares about, and those are the ones we monitor here.
514-
monitorFiles (programsMonitorFiles progdb'')
518+
monitorFiles (programsMonitorFiles progdb')
515519

516520
-- Note: There is currently a bug here: we are dropping unconfigured
517521
-- programs from the 'ProgramDb' when we re-use the cache created by
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module MyLibrary () where
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: *.cabal
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: CheckExtraProgPathGlobal
2+
version: 0.1
3+
license: BSD3
4+
license-file: LICENSE
5+
author: Yuto Takano
6+
maintainer: Yuto Takano
7+
synopsis: Check Extra Prog Path Global
8+
category: PackageTests
9+
build-type: Simple
10+
cabal-version: 2.0
11+
12+
description:
13+
Check that Cabal recognizes an override of the prog path.
14+
15+
Library
16+
pkgconfig-depends: zlib
17+
default-language: Haskell2010
18+
build-depends: base <5.0
19+
exposed-modules:
20+
MyLibrary
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
# ugly, but "good enough" for this test
6+
# This will need to be updated whenever cabal invokes pkg-config
7+
# in new ways
8+
case "$*" in
9+
'--version')
10+
echo 2.1.0 # whatever
11+
;;
12+
13+
'--variable pc_path pkg-config')
14+
echo '.'
15+
;;
16+
17+
'--list-all')
18+
printf 'zlib zlib - zlib compression library\n'
19+
# \256 = \xAE is the iso-8859-1 (latin-1) encoded version of U+00AE,
20+
# i.e. the "registered sign": ®
21+
# This resulted in problems, see #9608
22+
printf 'vpl Intel\256 Video Processing Library - Accelerated video decode, encode, and frame processing capabilities on Intel\256 GPUs\n'
23+
# \360 = \xF0 is latin-1 for ð; this is orð, Icelandic for "word"/"words".
24+
printf 'or\360 Icelandic characters\n'
25+
;;
26+
27+
'--modversion '*)
28+
shift # drop the --modversion
29+
for arg; do
30+
case "$arg" in
31+
zlib) echo 1.3; ;; # whatever
32+
vpl) echo 2.10; ;; # whatever
33+
# No entry for orð here; let's not even try to match on that
34+
*)
35+
echo >&2 "Package $arg was not found in the pkg-config search path."
36+
exit 1
37+
esac
38+
done
39+
;;
40+
41+
# Ignore some stuff we're not implementing
42+
'--cflags '*) ;;
43+
'--libs '*) ;;
44+
45+
*)
46+
echo >&2 "pkg-config: unrecognised arguments $* (this is an incomplete shim)"
47+
exit 1
48+
;;
49+
esac
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH/sh.exe"
2+
args = "SCRIPTSWINPATHDIR/pkg-config"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
exit 1;
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH/sh.exe"
2+
args = "SCRIPTSDIR/pkg-config"

0 commit comments

Comments
 (0)