Skip to content

Commit

Permalink
Merge pull request #5541 from rjbou/more-windows-shell
Browse files Browse the repository at this point in the history
Some windows shell updates
  • Loading branch information
rjbou authored Jun 15, 2023
2 parents 5acf0e7 + 4a31da2 commit 469cc40
Show file tree
Hide file tree
Showing 19 changed files with 530 additions and 348 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ _obuild/
_opam/
_olint/
.vscode/
bootstrap/
/bootstrap*/
tests/tmp/
tests/.merlin
tests/reftests/.merlin
Expand Down
2 changes: 1 addition & 1 deletion dune
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(dirs :standard \ bootstrap release)
(dirs :standard \ bootstrap* release)
17 changes: 16 additions & 1 deletion master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ users)
* Use `.opam` from `%HOME%` or `%USERPROFILE%` on Windows, only if found; otherwise use `%LOCALAPPDATA%\opam` as root. [#5212 @dra27]
* Display actual location of OPAMROOT in `opam init` if `--root` or `OPAMROOT` have been set [#5212 @dra27 - fix #4992]
* Surround and add a comment describing the role of the lines added to the ~/.profile or equivalent [#5456 @kit-ty-kate]
* Don't require cc on Windows [#5541 @dra27]
* Generate init and variables for Windows [#5541 @dra27]

## Config report
* [BUG] Don't fail is no switch is set [#5198 @rjbou]
Expand Down Expand Up @@ -405,6 +407,10 @@ users)
* Correct invocation of Cygwin binaries when Cygwin bin directory is first in PATH [#5293 @dra27]
* [BUG] Fix case insensitive variable handling [#5356 @dra27]
* Use OCaml code to copy/move/remove directories instead of unix commands [#4823 @kit-ty-kate - fix #1073]
* Update Windows-on-Windows detection for ARM [#5541 @dra27]
* Overhaul parent process detection [#5541 @dra27]
* Tweak UTF-8 support for Windows Terminal [#5541 @dra27]
* Handle Windows specific environment variables [#5541 @dra27]

## Test
* Update crowbar with compare functions [#4918 @rjbou]
Expand Down Expand Up @@ -528,7 +534,10 @@ users)
* fish: fix deprecated redirection syntax `^` [#4736 @vzaliva]
* dash: recognize dash as a POSIX shell for opam env [#4816 @jonahbeckford]
* pwsh,powershell: use $env: for opam env [#4816 @jonahbeckford]
* command prompt: use SET for opam env [#4816 @jonahbeckford]
* use `::` instead of REM [#5541 @dra27]
* Don't generate .profile for cmd & powershell [#5541 @dra27]
* command prompt: use `SET` for opam env [#4816 @jonahbeckford]
* use `set` instead [#5541 @dra27]

## Doc
* Standardise `macOS` use [#4782 @kit-ty-kate]
Expand Down Expand Up @@ -601,6 +610,7 @@ users)
* `OpamVCS.pull_url`: clean repository before fetching [#4879 @rjbou]
* `OpamDownload`: Add `SWHID` submodule that implements SWH fallback (retrieve url, download, check hash, and copy in target) [#4859 @rjbou]
* `OpamCLIVersion.of_string`: print version when failing to parse it [#5566 @MisterDA]
* `OpamInitdefaults.recommended_tools`: don't require `cc` on Windows [#5541 @dra27]

## opam-state
* `OpamSwitchState.universe`: `requested` argument moved from `name_package_set` to `package_set`, to precise installed packages with `--best-effort` [#4796 @LasseBlaauwbroek]
Expand Down Expand Up @@ -634,6 +644,8 @@ users)
* `OpamSysInteract`: add global config argument to function, in order to be able to retrieve system package manager path for MSYS2, and in the future Cygwin, etc. [#5433 @rjbou]
* `OpamSwitchState.load`: fill empty switch synopsis with invariant formula instead of compiler package name [#5208 @rjbou]
* `OpamSwitchState`: add `compiler_packages` that returns set of installed compilers, with their dependencies including only build & depopt [#5480 @rjbou]
* `OpamEnv`: generalise splitting of environment variables [#5541 @dra27]
* `OpamEnv`: add handling of `SH_pwsh` and `SH_cmd` in shell lists [#5541 @dra27]

## opam-solver
* `OpamCudf`: Change type of `conflict_case.Conflict_cycle` (`string list list` to `Cudf.package action list list`) and `cycle_conflict`, `string_of_explanations`, `conflict_explanations_raw` types accordingly [#4039 @gasche]
Expand Down Expand Up @@ -726,3 +738,6 @@ users)
* `OpamSWHID`: add module to handle swhid [#4859 @rjbou]
* `OpamProcess`: expose the `command` type as a private type [#5452 @Leonidas-from-XIV]
* `OpamFilename`: add `with_open_out_bin` and `with_open_out_bin_atomic` [#5476 @dra27]
* `OpamStd.Sys`: add `SH_pwsh`, `SH_win_cmd` and `SH_win_powershell` to `shell` type [#4816 @jonahbeckford]
* unify powershell variant: `SH_win_powershell` and `SH_pwsh` to `SH_pwsh of powershell_host` [#5203 @dra27]
* change `SH_win_cmd` into `SH_cmd` [#5541 @dra27]
2 changes: 1 addition & 1 deletion src/client/opamArg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ let shell_opt ?section cli validity =
None,"zsh",SH_zsh;
None,"fish",SH_fish;
Some cli2_2,"pwsh",SH_pwsh Powershell_pwsh;
Some cli2_2,"cmd",SH_win_cmd;
Some cli2_2,"cmd",SH_cmd;
Some cli2_2,"powershell",SH_pwsh Powershell
] |> List.map (fun (c,s,v) -> OpamStd.Option.map_default cli_from cli_original c, s, v)
in
Expand Down
21 changes: 10 additions & 11 deletions src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,9 @@ let init cli =
| Some s -> s
| None -> OpamStd.Sys.guess_shell_compat ()
in
let dot_profile = match dot_profile_o with
| Some n -> n
| None ->
OpamFilename.of_string (OpamStd.Sys.guess_dot_profile shell)
let dot_profile =
OpamStd.Option.Op.(dot_profile_o >>+ fun () ->
OpamStd.Sys.guess_dot_profile shell >>| OpamFilename.of_string)
in
if already_init then
if reinit then
Expand All @@ -371,7 +370,7 @@ let init cli =
~no_default_config_file:no_config_file ~add_config_file:config_file
in
let reinit conf =
OpamClient.reinit ~init_config ~interactive ~dot_profile
OpamClient.reinit ~init_config ~interactive ?dot_profile
?update_config ?env_hook ?completion ~inplace ~bypass_checks
~check_sandbox:(not no_sandboxing)
conf shell
Expand All @@ -394,7 +393,7 @@ let init cli =
"Opam was already initialised. If you want to set it up again, \
use `--interactive', `--reinit', or choose a different \
`--root'.\n";
OpamEnv.setup root ~interactive ~dot_profile ?update_config ?env_hook
OpamEnv.setup root ~interactive ?dot_profile ?update_config ?env_hook
?completion ~inplace shell)
else
let init_config =
Expand All @@ -410,7 +409,7 @@ let init cli =
let gt, rt, default_compiler =
OpamClient.init
~init_config ~interactive
?repo ~bypass_checks ~dot_profile
?repo ~bypass_checks ?dot_profile
?update_config ?env_hook ?completion
~check_sandbox:(not no_sandboxing)
shell
Expand Down Expand Up @@ -1320,7 +1319,7 @@ let config cli =
`Ok (OpamConfigCommand.env gt sw
~set_opamroot ~set_opamswitch
~csh:(shell=SH_csh) ~sexp ~fish:(shell=SH_fish)
~pwsh ~cmd:(shell=SH_win_cmd)
~pwsh ~cmd:(shell=SH_cmd)
~inplace_path))
| Some `revert_env, [] ->
OpamGlobalState.with_ `Lock_none @@ fun gt ->
Expand All @@ -1330,7 +1329,7 @@ let config cli =
`Ok (OpamConfigCommand.ensure_env gt sw;
OpamConfigCommand.print_eval_env
~csh:(shell=SH_csh) ~sexp ~fish:(shell=SH_fish)
~pwsh ~cmd:(shell=SH_win_cmd)
~pwsh ~cmd:(shell=SH_cmd)
(OpamEnv.add [] [])))
| Some `list, [] ->
OpamGlobalState.with_ `Lock_none @@ fun gt ->
Expand Down Expand Up @@ -1634,12 +1633,12 @@ let env cli =
OpamConfigCommand.env gt sw
~set_opamroot ~set_opamswitch
~csh:(shell=SH_csh) ~sexp ~fish:(shell=SH_fish)
~pwsh ~cmd:(shell=SH_win_cmd)
~pwsh ~cmd:(shell=SH_cmd)
~inplace_path);
| true ->
OpamConfigCommand.print_eval_env
~csh:(shell=SH_csh) ~sexp ~fish:(shell=SH_fish)
~pwsh ~cmd:(shell=SH_win_cmd)
~pwsh ~cmd:(shell=SH_cmd)
(OpamEnv.add [] [])
in
let open Common_config_flags in
Expand Down
4 changes: 2 additions & 2 deletions src/client/opamConfigCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ let print_cmd_env env =
| _ -> false
in
if OpamCompat.String.(exists is_special v || exists is_special k) then
OpamConsole.msg "SET \"%s=%s\"\n" k v
OpamConsole.msg "set \"%s=%s\"\n" k v
else
OpamConsole.msg "SET %s=%s\n" k v
OpamConsole.msg "set %s=%s\n" k v
end;
aux r
in
Expand Down
4 changes: 3 additions & 1 deletion src/client/opamInitDefaults.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ let freebsd_filter = os_filter "freebsd"
let not_open_free_bsd_filter =
FNot (FOr (openbsd_filter, freebsd_filter))
let win32_filter = os_filter "win32"
let not_win32_filter =
FOp (FIdent ([], OpamVariable.of_string "os", None), `Neq, FString "win32")
let sandbox_filter = FOr (linux_filter, macos_filter)

let gpatch_filter = FOr (openbsd_filter, freebsd_filter)
Expand Down Expand Up @@ -125,7 +127,7 @@ let recommended_tools () =
let make = OpamStateConfig.(Lazy.force !r.makecmd) in
[
[make], None, None;
["cc"], None, None;
["cc"], None, Some not_win32_filter;
]

let required_tools ~sandboxing () =
Expand Down
12 changes: 9 additions & 3 deletions src/core/opamConsole.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ let disp_status_line () =
| `Auto -> OpamStd.Sys.tty_out && (color () || not (Lazy.force dumb_term))

let utf8, utf8_extended =
let use_auto_utf8_extended = lazy (
match OpamStd.Sys.os () with
| Darwin -> true
| Win32 -> OpamStubs.getConsoleWindowClass () <> Some "ConsoleWindowClass"
| _ -> false
) in
let auto = lazy (
if Sys.win32 then
let attempt handle =
Expand Down Expand Up @@ -73,9 +79,9 @@ let utf8, utf8_extended =
| `Never -> false
| `Auto -> Lazy.force auto),
(fun () -> match OpamCoreConfig.(!r.utf8) with
| `Extended -> not Sys.win32
| `Extended -> true
| `Always | `Never -> false
| `Auto -> Lazy.force auto && OpamStd.Sys.(os () = Darwin))
| `Auto -> Lazy.force auto && Lazy.force use_auto_utf8_extended)

module Symbols = struct
let rightwards_arrow = Uchar.of_int 0x2192
Expand Down Expand Up @@ -122,7 +128,7 @@ let utf8_symbol main ?(alternates=[]) s =
if utf8 () then
try
let scalar =
if Sys.win32 then
if Sys.win32 && not (utf8_extended ()) then
let current_font =
let open OpamStubs in
try
Expand Down
Loading

0 comments on commit 469cc40

Please sign in to comment.