From 350b896fa9e2d70c4a7a2ac9f4ab397d5aaf5afb Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Wed, 31 Jan 2024 22:26:09 +0000 Subject: [PATCH] Add sys-ocaml-system variable Forward planning for the rest of the base-system- packages --- master_changes.md | 1 + src/state/opamEnv.ml | 5 +++++ tests/reftests/init-ocaml-eval-variables.unix.test | 6 +++--- tests/reftests/init-ocaml-eval-variables.win32.test | 6 +++--- tests/reftests/var-option.test | 2 ++ 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/master_changes.md b/master_changes.md index dd6280d7037..b383888a849 100644 --- a/master_changes.md +++ b/master_changes.md @@ -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 diff --git a/src/state/opamEnv.ml b/src/state/opamEnv.ml index 33d4cf235b9..797c5159afc 100644 --- a/src/state/opamEnv.ml +++ b/src/state/opamEnv.ml @@ -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"; diff --git a/tests/reftests/init-ocaml-eval-variables.unix.test b/tests/reftests/init-ocaml-eval-variables.unix.test index adcc0d67459..1a3e8a89709 100644 --- a/tests/reftests/init-ocaml-eval-variables.unix.test +++ b/tests/reftests/init-ocaml-eval-variables.unix.test @@ -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 : @@ -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 : @@ -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"]] diff --git a/tests/reftests/init-ocaml-eval-variables.win32.test b/tests/reftests/init-ocaml-eval-variables.win32.test index bb99025435b..fbbca848513 100644 --- a/tests/reftests/init-ocaml-eval-variables.win32.test +++ b/tests/reftests/init-ocaml-eval-variables.win32.test @@ -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 : @@ -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 : @@ -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"]] diff --git a/tests/reftests/var-option.test b/tests/reftests/var-option.test index 477749e0f60..ad68aae76eb 100644 --- a/tests/reftests/var-option.test +++ b/tests/reftests/var-option.test @@ -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