Skip to content

Commit

Permalink
Add sys-ocaml-system variable
Browse files Browse the repository at this point in the history
Forward planning for the rest of the base-system- packages
  • Loading branch information
dra27 authored and rjbou committed Mar 28, 2024
1 parent 763a306 commit 350b896
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ users)
* Properly test if "we're in interactive mode" instead of "in a tty" in fish script [#5866 @ElectreAAS]
* Make the computation of the init default `sys-ocaml-*` eval variables on Windows faster, no more depending on Cygwin [#5829 @dra27 @rjbou]
* Simplify computation of OCaml init default `sys-ocaml-*` eval variables on Unix [#5829 @dra27]
* Add a init OCaml `sys-ocaml-system` eval variable [#5829 @dra27]

## Config report

Expand Down
5 changes: 5 additions & 0 deletions src/state/opamEnv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,11 @@ let sys_ocaml_eval_variables =
if Sys.win32 then var, win32, comment
else var, unix, comment)
[
"sys-ocaml-system",
"Target system of the OCaml compiler present on your system",
["sh"; "-c";
"ocamlc -config 2>/dev/null | tr -d '\\r' | sed -n -e 's/system: //p'"],
["cmd"; "/d"; "/c"; "ocamlc -config-var system 2>nul"];
"sys-ocaml-arch",
"Target architecture of the OCaml compiler present on your system",
["sh"; "-c";
Expand Down
6 changes: 3 additions & 3 deletions tests/reftests/init-ocaml-eval-variables.unix.test
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ No configuration file found, using built-in defaults.
<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[default] Initialised
### opam-cat $OPAMROOT/config | grep eval-variables
eval-variables: [[sys-ocaml-version ["ocamlc" "-vnum"] "OCaml version present on your system independently of opam, if any"] [sys-ocaml-arch ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/i386/i686/;s/amd64/x86_64/;s/^architecture: //p'"] "Target architecture of the OCaml compiler present on your system"] [sys-ocaml-cc ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/^ccomp_type: //p'"] "Host C Compiler type of the OCaml compiler present on your system"] [sys-ocaml-libc ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/^os_type: Win32/msvc/p;s/^os_type: .*/libc/p'"] "Host C Runtime Library type of the OCaml compiler present on your system"]]
eval-variables: [[sys-ocaml-version ["ocamlc" "-vnum"] "OCaml version present on your system independently of opam, if any"] [sys-ocaml-system ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/system: //p'"] "Target system of the OCaml compiler present on your system"] [sys-ocaml-arch ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/i386/i686/;s/amd64/x86_64/;s/^architecture: //p'"] "Target architecture of the OCaml compiler present on your system"] [sys-ocaml-cc ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/^ccomp_type: //p'"] "Host C Compiler type of the OCaml compiler present on your system"] [sys-ocaml-libc ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/^os_type: Win32/msvc/p;s/^os_type: .*/libc/p'"] "Host C Runtime Library type of the OCaml compiler present on your system"]]
### rm "$OPAMROOT/config"
### ::::::::::::::::::::
### :II: From 2.0 root :
Expand All @@ -65,7 +65,7 @@ Continue? [y/n] y
Format upgrade done.
Set to '4' the field jobs in global configuration
### opam-cat $OPAMROOT/config | grep eval-variables
eval-variables: [[sys-ocaml-libc ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/^os_type: Win32/msvc/p;s/^os_type: .*/libc/p'"] "Host C Runtime Library type of the OCaml compiler present on your system"] [sys-ocaml-cc ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/^ccomp_type: //p'"] "Host C Compiler type of the OCaml compiler present on your system"] [sys-ocaml-arch ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/i386/i686/;s/amd64/x86_64/;s/^architecture: //p'"] "Target architecture of the OCaml compiler present on your system"] [sys-ocaml-version ["ocamlc" "-vnum"] "OCaml version present on your system independently of opam, if any"]]
eval-variables: [[sys-ocaml-system ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/system: //p'"] "Target system of the OCaml compiler present on your system"] [sys-ocaml-libc ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/^os_type: Win32/msvc/p;s/^os_type: .*/libc/p'"] "Host C Runtime Library type of the OCaml compiler present on your system"] [sys-ocaml-cc ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/^ccomp_type: //p'"] "Host C Compiler type of the OCaml compiler present on your system"] [sys-ocaml-arch ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/i386/i686/;s/amd64/x86_64/;s/^architecture: //p'"] "Target architecture of the OCaml compiler present on your system"] [sys-ocaml-version ["ocamlc" "-vnum"] "OCaml version present on your system independently of opam, if any"]]
### rm "$OPAMROOT/config"
### :::::::::::::::::::::
### :III: From 2.1 root :
Expand All @@ -84,4 +84,4 @@ Continue? [y/n] y
Format upgrade done.
Set to '4' the field jobs in global configuration
### opam-cat $OPAMROOT/config | grep eval-variables
eval-variables: [[sys-ocaml-version ["ocamlc" "-vnum"] "OCaml version present on your system independently of opam, if any"] [sys-ocaml-arch ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/i386/i686/;s/amd64/x86_64/;s/^architecture: //p'"] "Target architecture of the OCaml compiler present on your system"] [sys-ocaml-cc ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/^ccomp_type: //p'"] "Host C Compiler type of the OCaml compiler present on your system"] [sys-ocaml-libc ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/^os_type: Win32/msvc/p;s/^os_type: .*/libc/p'"] "Host C Runtime Library type of the OCaml compiler present on your system"]]
eval-variables: [[sys-ocaml-system ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/system: //p'"] "Target system of the OCaml compiler present on your system"] [sys-ocaml-version ["ocamlc" "-vnum"] "OCaml version present on your system independently of opam, if any"] [sys-ocaml-arch ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/i386/i686/;s/amd64/x86_64/;s/^architecture: //p'"] "Target architecture of the OCaml compiler present on your system"] [sys-ocaml-cc ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/^ccomp_type: //p'"] "Host C Compiler type of the OCaml compiler present on your system"] [sys-ocaml-libc ["sh" "-c" "ocamlc -config 2>/dev/null | tr -d '/r' | sed -n -e 's/^os_type: Win32/msvc/p;s/^os_type: .*/libc/p'"] "Host C Runtime Library type of the OCaml compiler present on your system"]]
6 changes: 3 additions & 3 deletions tests/reftests/init-ocaml-eval-variables.win32.test
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ No configuration file found, using built-in defaults.
<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[default] Initialised
### opam-cat $OPAMROOT/config | grep eval-variables
eval-variables: [[sys-ocaml-version ["ocamlc" "-vnum"] "OCaml version present on your system independently of opam, if any"] [sys-ocaml-arch ["cmd" "/d" "/c" "for /f %f in ('ocamlc -config-var architecture 2^>nul') do @if '%f' equ 'i386' (echo i686) else if '%f' equ 'amd64' (echo x86_64) else (echo %f)"] "Target architecture of the OCaml compiler present on your system"] [sys-ocaml-cc ["cmd" "/d" "/c" "ocamlc -config-var ccomp_type 2>nul"] "Host C Compiler type of the OCaml compiler present on your system"] [sys-ocaml-libc ["cmd" "/d" "/c" "for /f %f in ('ocamlc -config-var os_type 2^>nul') do @if '%f' equ 'Win32' (echo msvc) else (echo libc)"] "Host C Runtime Library type of the OCaml compiler present on your system"]]
eval-variables: [[sys-ocaml-version ["ocamlc" "-vnum"] "OCaml version present on your system independently of opam, if any"] [sys-ocaml-system ["cmd" "/d" "/c" "ocamlc -config-var system 2>nul"] "Target system of the OCaml compiler present on your system"] [sys-ocaml-arch ["cmd" "/d" "/c" "for /f %f in ('ocamlc -config-var architecture 2^>nul') do @if '%f' equ 'i386' (echo i686) else if '%f' equ 'amd64' (echo x86_64) else (echo %f)"] "Target architecture of the OCaml compiler present on your system"] [sys-ocaml-cc ["cmd" "/d" "/c" "ocamlc -config-var ccomp_type 2>nul"] "Host C Compiler type of the OCaml compiler present on your system"] [sys-ocaml-libc ["cmd" "/d" "/c" "for /f %f in ('ocamlc -config-var os_type 2^>nul') do @if '%f' equ 'Win32' (echo msvc) else (echo libc)"] "Host C Runtime Library type of the OCaml compiler present on your system"]]
### rm "$OPAMROOT/config"
### ::::::::::::::::::::
### :II: From 2.0 root :
Expand All @@ -65,7 +65,7 @@ Continue? [y/n] y
Format upgrade done.
Set to '4' the field jobs in global configuration
### opam-cat $OPAMROOT/config | grep eval-variables
eval-variables: [[sys-ocaml-libc ["cmd" "/d" "/c" "for /f %f in ('ocamlc -config-var os_type 2^>nul') do @if '%f' equ 'Win32' (echo msvc) else (echo libc)"] "Host C Runtime Library type of the OCaml compiler present on your system"] [sys-ocaml-cc ["cmd" "/d" "/c" "ocamlc -config-var ccomp_type 2>nul"] "Host C Compiler type of the OCaml compiler present on your system"] [sys-ocaml-arch ["cmd" "/d" "/c" "for /f %f in ('ocamlc -config-var architecture 2^>nul') do @if '%f' equ 'i386' (echo i686) else if '%f' equ 'amd64' (echo x86_64) else (echo %f)"] "Target architecture of the OCaml compiler present on your system"] [sys-ocaml-version ["ocamlc" "-vnum"] "OCaml version present on your system independently of opam, if any"]]
eval-variables: [[sys-ocaml-system ["cmd" "/d" "/c" "ocamlc -config-var system 2>nul"] "Target system of the OCaml compiler present on your system"] [sys-ocaml-libc ["cmd" "/d" "/c" "for /f %f in ('ocamlc -config-var os_type 2^>nul') do @if '%f' equ 'Win32' (echo msvc) else (echo libc)"] "Host C Runtime Library type of the OCaml compiler present on your system"] [sys-ocaml-cc ["cmd" "/d" "/c" "ocamlc -config-var ccomp_type 2>nul"] "Host C Compiler type of the OCaml compiler present on your system"] [sys-ocaml-arch ["cmd" "/d" "/c" "for /f %f in ('ocamlc -config-var architecture 2^>nul') do @if '%f' equ 'i386' (echo i686) else if '%f' equ 'amd64' (echo x86_64) else (echo %f)"] "Target architecture of the OCaml compiler present on your system"] [sys-ocaml-version ["ocamlc" "-vnum"] "OCaml version present on your system independently of opam, if any"]]
### rm "$OPAMROOT/config"
### :::::::::::::::::::::
### :III: From 2.1 root :
Expand All @@ -84,4 +84,4 @@ Continue? [y/n] y
Format upgrade done.
Set to '4' the field jobs in global configuration
### opam-cat $OPAMROOT/config | grep eval-variables
eval-variables: [[sys-ocaml-version ["ocamlc" "-vnum"] "OCaml version present on your system independently of opam, if any"] [sys-ocaml-arch ["cmd" "/d" "/c" "for /f %f in ('ocamlc -config-var architecture 2^>nul') do @if '%f' equ 'i386' (echo i686) else if '%f' equ 'amd64' (echo x86_64) else (echo %f)"] "Target architecture of the OCaml compiler present on your system"] [sys-ocaml-cc ["cmd" "/d" "/c" "ocamlc -config-var ccomp_type 2>nul"] "Host C Compiler type of the OCaml compiler present on your system"] [sys-ocaml-libc ["cmd" "/d" "/c" "for /f %f in ('ocamlc -config-var os_type 2^>nul') do @if '%f' equ 'Win32' (echo msvc) else (echo libc)"] "Host C Runtime Library type of the OCaml compiler present on your system"]]
eval-variables: [[sys-ocaml-system ["cmd" "/d" "/c" "ocamlc -config-var system 2>nul"] "Target system of the OCaml compiler present on your system"] [sys-ocaml-version ["ocamlc" "-vnum"] "OCaml version present on your system independently of opam, if any"] [sys-ocaml-arch ["cmd" "/d" "/c" "for /f %f in ('ocamlc -config-var architecture 2^>nul') do @if '%f' equ 'i386' (echo i686) else if '%f' equ 'amd64' (echo x86_64) else (echo %f)"] "Target architecture of the OCaml compiler present on your system"] [sys-ocaml-cc ["cmd" "/d" "/c" "ocamlc -config-var ccomp_type 2>nul"] "Host C Compiler type of the OCaml compiler present on your system"] [sys-ocaml-libc ["cmd" "/d" "/c" "for /f %f in ('ocamlc -config-var os_type 2^>nul') do @if '%f' equ 'Win32' (echo msvc) else (echo libc)"] "Host C Runtime Library type of the OCaml compiler present on your system"]]
2 changes: 2 additions & 0 deletions tests/reftests/var-option.test
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Removed variable sys-ocaml-arch in global configuration
Removed variable sys-ocaml-cc in global configuration
### opam var sys-ocaml-libc= --global
Removed variable sys-ocaml-libc in global configuration
### opam var sys-ocaml-system= --global
Removed variable sys-ocaml-system in global configuration
### opam option wrap-build-commands=[] --global
Set to '[]' the field wrap-build-commands in global configuration
### opam option wrap-install-commands=[] --global
Expand Down

0 comments on commit 350b896

Please sign in to comment.