Skip to content

Commit

Permalink
state,arg: load MSYS2 Cygwin binary path in 'OpamCoreConfig.cygbin'
Browse files Browse the repository at this point in the history
If MSYS2 is detected via 'os-distribution' in the config file, resolve
'cygcheck' from the environment and store resulting value as Cygwin
binary path in 'OpamCoreConfig.cygbin'
  • Loading branch information
rjbou committed Feb 29, 2024
1 parent 61bc20f commit 44c74ba
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
2 changes: 2 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,15 @@ users)
## opam-client
* `OpamClient.windows_checks`: On existing cygwin install, permit to detect msys2 and store `os-distribution=msys2` in `global-variables` config file field [#5843 @rjbou]
* `OpamClient.windows_checks`: When updating config file for msys2, resolve `pacman` path and store it in `sys-pkg-manager-cmd` for msys2 [#5843 @rjbou]
* `OpamArg.apply_global_options`: load MSYS2 Cygwin binary path too [#5843 @rjbou]

## opam-repository

## opam-state
* `OpamEnv.env_expansion`: Fix detection of out-of-date environment variables, a filter predicate was inverted [#5837 @dra27]
* `OpamSysInteract.Cygwin.check_install`: add `variant` argument to permit checking that it is an Cygwin-like install if it is set to true, keep checking that it is a strictly Cygwin install if false [#5843 @rjbou]
* `OpamSysInteract.Cygwin.check_install`: look for `cygcheck.exe` in `usr/bin` also as MSYS2 doesn't have "bin" [#5843 @rjbou]
* `OpamGlobalState.load_config`: load MSYS2 Cygwin binary path too at config file loading [#5843 @rjbou]

## opam-solver

Expand Down
15 changes: 15 additions & 0 deletions src/client/opamArg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,21 @@ let apply_global_options cli o =
| _, element::elements -> aux (Some element) elements
in
aux None elements
| { pelem = Variable ({ pelem = "global-variables"; _},
{pelem = List { pelem = elements; _}; _}); _} ->
let rec aux last elements =
match last, elements with
| _, [] -> ()
| Some { pelem = Ident "os-distribution"; _},
{ pelem = String "msys2"; _}::_ ->
let cygbin =
OpamStd.Option.map Filename.dirname
(OpamSystem.resolve_command "cygcheck")
in
OpamCoreConfig.update ?cygbin ()
| _, element::elements -> aux (Some element) elements
in
aux None elements
| { pelem = Variable ({ pelem = "git-location"; _},
{pelem = String git_location; _}); _} ->
OpamCoreConfig.update ~git_location ()
Expand Down
20 changes: 16 additions & 4 deletions src/state/opamGlobalState.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,22 @@ let load_config lock_kind global_lock root =
let config =
OpamFormatUpgrade.as_necessary lock_kind global_lock root config
in
OpamStd.Option.iter
(fun cygbin ->
OpamCoreConfig.update ~cygbin:(OpamFilename.Dir.to_string cygbin) ())
(OpamSysInteract.Cygwin.cygbin_opt (fst config));
(* Update Cygwin variants cygbin *)
let cygbin =
let config = fst config in
match OpamSysInteract.Cygwin.cygbin_opt config with
| Some cygbin -> Some (OpamFilename.Dir.to_string cygbin)
| None ->
if List.exists (function
| (v, S "msys2", _) ->
String.equal (OpamVariable.to_string v) "os-distribution"
| _ -> false) (OpamFile.Config.global_variables config)
then
OpamStd.Option.map Filename.dirname
(OpamSystem.resolve_command "cygcheck")
else None
in
OpamCoreConfig.update ?cygbin ();
config

let inferred_from_system = "Inferred from system"
Expand Down

0 comments on commit 44c74ba

Please sign in to comment.