Skip to content

Commit

Permalink
Better idea - split the variable according to the default
Browse files Browse the repository at this point in the history
i.e. the variables are assumed to be specified according to the system's
defaults, and then get converted afterwards.
  • Loading branch information
dra27 committed Nov 7, 2023
1 parent 58371bd commit 5c7d0b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
8 changes: 2 additions & 6 deletions src/state/opamEnv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,11 @@ let expand_update expand_string update =
match update with
| {envu_value = `Value envu_value; _} as update ->
[{update with envu_value}]
| {envu_value = `Ident ident; envu_rewrite; envu_var; _} ->
| {envu_value = `Ident ident; (*envu_rewrite;*) envu_var; _} ->
(* XXX Do this directly from expand_string! *)
let envu_value = expand_string (Printf.sprintf "%%{%s}%%" ident) in
(* XXX Nicked from expand - factor out *)
let sepfmt =
match envu_rewrite with
| None -> `norewrite
| Some (SPF_Resolved None) -> `rewrite_default envu_var
| Some (SPF_Resolved (Some spf)) -> `rewrite spf
let sepfmt = `rewrite (default_separator, default_format)
in
List.map (fun envu_value -> {update with envu_value}) (split_var ~sepfmt (OpamStd.Env.Name.of_string envu_var) envu_value)

Expand Down
9 changes: 4 additions & 5 deletions tests/reftests/env-dra27.win32.test
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,14 @@ PATH += C:\Program\ Files\Microsoft\ Visual\ Studio\2022\Preview\Common7\Tools\
PATH += C:\Program\ Files\Microsoft\ Visual\ Studio\2022\Preview\VC\Tools\MSVC\14.38.33030\bin\HostX64\x64;C:\Program\ Files\Microsoft\ Visual\ Studio\2022\Preview\Common7\IDE\VC\VCPackages;C:\Program\ Files\Microsoft\ Visual\ Studio\2022\Preview\Common7\Tools\ ; target-quoted Updated\ by\ package\ setenv-dra27
MANPATH += /home/dra/manual/man : host Updated\ by\ package\ setenv-dra27
PKG_CONFIG_PATH += ${BASEDIR}/OPAM/rewriting/lib/pkgconfig : host Updated\ by\ package\ setenv-dra27
PKG_CONFIG_PATH += C : host Updated\ by\ package\ setenv-dra27
PKG_CONFIG_PATH += \Program\ Files\Microsoft\ Visual\ Studio\2022\Preview\VC\Tools\MSVC\14.38.33030\bin\HostX64\x64;C : host Updated\ by\ package\ setenv-dra27
PKG_CONFIG_PATH += \Program\ Files\Microsoft\ Visual\ Studio\2022\Preview\Common7\IDE\VC\VCPackages;C : host Updated\ by\ package\ setenv-dra27
PKG_CONFIG_PATH += \Program\ Files\Microsoft\ Visual\ Studio\2022\Preview\Common7\Tools\ : host Updated\ by\ package\ setenv-dra27
PKG_CONFIG_PATH += C:\Program\ Files\Microsoft\ Visual\ Studio\2022\Preview\VC\Tools\MSVC\14.38.33030\bin\HostX64\x64 : host Updated\ by\ package\ setenv-dra27
PKG_CONFIG_PATH += C:\Program\ Files\Microsoft\ Visual\ Studio\2022\Preview\Common7\IDE\VC\VCPackages : host Updated\ by\ package\ setenv-dra27
PKG_CONFIG_PATH += C:\Program\ Files\Microsoft\ Visual\ Studio\2022\Preview\Common7\Tools\ : host Updated\ by\ package\ setenv-dra27
PKG_CONFIG_PATH += C:\Program\ Files\Microsoft\ Visual\ Studio\2022\Preview\VC\Tools\MSVC\14.38.33030\bin\HostX64\x64;C:\Program\ Files\Microsoft\ Visual\ Studio\2022\Preview\Common7\IDE\VC\VCPackages;C:\Program\ Files\Microsoft\ Visual\ Studio\2022\Preview\Common7\Tools\ : host Updated\ by\ package\ setenv-dra27
OCAMLPATH += ${BASEDIR}/OPAM/rewriting/lib ; target Updated\ by\ package\ setenv-dra27
CI = /home/ci/config norewrite Updated\ by\ package\ setenv-dra27
FOO = this\ does\ not\ require/allow\ a\ rewrite\ entry ; target Updated\ by\ package\ setenv-dra27
MANPATH =: ${BASEDIR}/OPAM/rewriting/man Current\ opam\ switch\ man\ dir
PATH =+= ${BASEDIR}/OPAM/rewriting/bin Binary\ dir\ for\ opam\ switch\ rewriting
### opam env | grep PKG_CONFIG | '/tmp/build_[^/]*/opam-reftest-[^/]*/' -> '${BASEDIR}/'
PKG_CONFIG_PATH='/cygdrive/c/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.38.33030/bin/HostX64/x64;C:/Program Files/Microsoft Visual Studio/2022/Preview/Common7/IDE/VC/VCPackages;C:/Program Files/Microsoft Visual Studio/2022/Preview/Common7/Tools/:/cygdrive/c/Program Files/Microsoft Visual Studio/2022/Preview/Common7/Tools":/cygdrive/c/Program Files/Microsoft Visual Studio/2022/Preview/Common7/IDE/VC/VCPackages;C:/cygdrive/c/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.38.33030/bin/HostX64/x64;C:C:${BASEDIR}/OPAM/rewriting/lib/pkgconfig'; export PKG_CONFIG_PATH;
PKG_CONFIG_PATH='/cygdrive/c/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.38.33030/bin/HostX64/x64;C:/Program Files/Microsoft Visual Studio/2022/Preview/Common7/IDE/VC/VCPackages;C:/Program Files/Microsoft Visual Studio/2022/Preview/Common7/Tools/:/cygdrive/c/Program Files/Microsoft Visual Studio/2022/Preview/Common7/Tools/:/cygdrive/c/Program Files/Microsoft Visual Studio/2022/Preview/Common7/IDE/VC/VCPackages:/cygdrive/c/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.38.33030/bin/HostX64/x64:${BASEDIR}/OPAM/rewriting/lib/pkgconfig'; export PKG_CONFIG_PATH;

0 comments on commit 5c7d0b1

Please sign in to comment.