From 883908ac330378414b49df654636fcb5bcda457c Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Fri, 13 Sep 2024 15:41:06 +0100 Subject: [PATCH] Move Windows stubs to opam-core As opam now routinely has stubs, eliminate the complicated dances for only linking stub libraries on Windows. --- .gitignore | 5 +- Makefile | 4 +- configure | 36 ++++++--------- configure.ac | 31 +++++-------- dune-project | 2 +- master_changes.md | 2 + opam-client.opam | 2 +- opam-core.opam | 2 +- opam-devel.opam | 2 +- opam-format.opam | 2 +- opam-installer.opam | 2 +- opam-repository.opam | 2 +- opam-solver.opam | 2 +- opam-state.opam | 2 +- {src/stubs/win32 => shell}/build-putenv.ml | 0 src/{stubs => core}/c-flags.sexp.in | 0 src/core/dune | 42 +++++++++++++---- src/{stubs/win32 => core}/opam-putenv.c | 0 src/core/opamCommonStubs.c | 6 +++ src/{stubs/win32 => core}/opamInject.c | 0 src/core/opamStubs.ocaml4.ml | 39 +++++++++++++++- .../{opamStubs.dummy.ml => opamStubs.unix.ml} | 0 src/core/opamStubsTypes.ml | 2 +- src/{stubs/win32 => core}/opamWindows.c | 0 src/stubs/dune | 4 -- src/stubs/win32/dune-win32 | 40 ---------------- src/stubs/win32/opamWin32Stubs.ml | 46 ------------------- 27 files changed, 116 insertions(+), 159 deletions(-) rename {src/stubs/win32 => shell}/build-putenv.ml (100%) rename src/{stubs => core}/c-flags.sexp.in (100%) rename src/{stubs/win32 => core}/opam-putenv.c (100%) rename src/{stubs/win32 => core}/opamInject.c (100%) rename src/core/{opamStubs.dummy.ml => opamStubs.unix.ml} (100%) rename src/{stubs/win32 => core}/opamWindows.c (100%) delete mode 100644 src/stubs/dune delete mode 100644 src/stubs/win32/dune-win32 delete mode 100644 src/stubs/win32/opamWin32Stubs.ml diff --git a/.gitignore b/.gitignore index 511177abdc4..d3db3d09ff0 100644 --- a/.gitignore +++ b/.gitignore @@ -80,12 +80,11 @@ src/ocaml-flags-configure.sexp src/**/.merlin src/client/linking.sexp src/client/no-git-version +src/core/cc64 +src/core/c-flags.sexp src/core/developer src/manifest/dune src/manifest/install.inc -src/stubs/win32/cc64 -src/stubs/win32/dune -src/stubs/c-flags.sexp # doc doc/dev-manual/*aux doc/dev-manual/*.html diff --git a/Makefile b/Makefile index f1f3ac712a8..1f07139c43f 100644 --- a/Makefile +++ b/Makefile @@ -96,8 +96,8 @@ clean: distclean: clean clean-ext rm -rf autom4te.cache bootstrap rm -f Makefile.config config.log config.status aclocal.m4 - rm -f src/*.META src/*/.merlin src/manifest/dune src/manifest/install.inc src/stubs/win32/dune src/stubs/win32/cc64 src/ocaml-flags-configure.sexp - rm -f src/client/linking.sexp src/stubs/c-flags.sexp src/core/developer src/core/version + rm -f src/*.META src/*/.merlin src/manifest/dune src/manifest/install.inc src/stubs/win32/dune src/core/cc64 src/ocaml-flags-configure.sexp + rm -f src/client/linking.sexp src/core/c-flags.sexp src/core/developer src/core/version OPAMINSTALLER_FLAGS = --prefix "$(call CYGPATH,$(DESTDIR)$(prefix))" OPAMINSTALLER_FLAGS += --mandir "$(call CYGPATH,$(DESTDIR)$(mandir))" diff --git a/configure b/configure index ba110a0625f..be601110dd6 100755 --- a/configure +++ b/configure @@ -5001,8 +5001,8 @@ fi if test "x${CC64}" != "xno" then : - echo "${CC64} -o " > src/stubs/win32/cc64 - echo " -Wdeclaration-after-statement -municode " >> src/stubs/win32/cc64 + echo "${CC64} -o " > src/core/cc64 + echo " -Wdeclaration-after-statement -municode " >> src/core/cc64 fi @@ -5048,14 +5048,14 @@ else $as_nop printf "%s\n" "from $MSVS_NAME" >&6; } CL_FULL="`PATH="${MSVS_PATH}:${PATH}" which cl | cygpath -f - -w`" MSVS_PATH="`echo "${MSVS_PATH}" | cygpath -f - -wp`" - echo "cl /nologo /Fe" > src/stubs/win32/cc64 - echo " " >> src/stubs/win32/cc64 - echo "PATH" >> src/stubs/win32/cc64 - echo "${MSVS_PATH}" >> src/stubs/win32/cc64 - echo "LIB" >> src/stubs/win32/cc64 - echo "${MSVS_LIB}" >> src/stubs/win32/cc64 - echo "INCLUDE" >> src/stubs/win32/cc64 - echo "${MSVS_INC}" >> src/stubs/win32/cc64 + echo "cl /nologo /Fe" > src/core/cc64 + echo " " >> src/core/cc64 + echo "PATH" >> src/core/cc64 + echo "${MSVS_PATH}" >> src/core/cc64 + echo "LIB" >> src/core/cc64 + echo "${MSVS_LIB}" >> src/core/cc64 + echo "INCLUDE" >> src/core/cc64 + echo "${MSVS_INC}" >> src/core/cc64 fi @@ -5820,7 +5820,7 @@ fi # NOTE: On Windows, the Windows specific dlls should stay dynamic for security reasons # NOTE: -l:libstdc++.a is necessary (vs. -lstdc++) as flexlink will use libstdc++.dll.a # which still depends on the DLL at runtime instead of libstdc++.a (that looks like a bug in flexlink) - platform_dependent_stuff="-cclib -lopam_stubs_win32_stubs -cclib -l:libstdc++.a -cclib -l:libpthread.a -cclib -Wl,-static -cclib -ladvapi32 -cclib -lgdi32 -cclib -luser32 -cclib -lshell32 -cclib -lole32 -cclib -luuid -cclib -luserenv" + platform_dependent_stuff="-cclib -l:libstdc++.a -cclib -l:libpthread.a -cclib -Wl,-static -cclib -ladvapi32 -cclib -lgdi32 -cclib -luser32 -cclib -lshell32 -cclib -lole32 -cclib -luuid -cclib -luserenv" if test "x${SYSTEM}" = "xmingw" then : platform_dependent_stuff="${platform_dependent_stuff} -cclib -lwindowsapp" @@ -7076,7 +7076,7 @@ if test "x$prefix" = "xNONE"; then prefix=$ac_default_prefix fi -ac_config_files="$ac_config_files Makefile.config src/ocaml-flags-configure.sexp src/stubs/c-flags.sexp" +ac_config_files="$ac_config_files Makefile.config src/ocaml-flags-configure.sexp src/core/c-flags.sexp" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -7781,7 +7781,7 @@ do case $ac_config_target in "Makefile.config") CONFIG_FILES="$CONFIG_FILES Makefile.config" ;; "src/ocaml-flags-configure.sexp") CONFIG_FILES="$CONFIG_FILES src/ocaml-flags-configure.sexp" ;; - "src/stubs/c-flags.sexp") CONFIG_FILES="$CONFIG_FILES src/stubs/c-flags.sexp" ;; + "src/core/c-flags.sexp") CONFIG_FILES="$CONFIG_FILES src/core/c-flags.sexp" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac @@ -8253,16 +8253,6 @@ fi fi -rm -f src/stubs/win32/dune -if test ${WIN32} -eq 1 -then : - - cd src/stubs/win32 - ${LN_S} -f dune-win32 dune - cd ../../.. - -fi - echo bindir="`eval echo ${bindir}`" diff --git a/configure.ac b/configure.ac index 465bcab992c..670ad0254fb 100644 --- a/configure.ac +++ b/configure.ac @@ -198,8 +198,8 @@ AS_IF([ test ${WIN32} -eq 1 ],[ ac_tool_prefix='x86_64-w64-mingw32-'])]) AC_CHECK_TOOL(CC64,[${T_CC64}],[no]) AS_IF([ test "x${CC64}" != "xno" ],[ - echo "${CC64} -o " > src/stubs/win32/cc64 - echo " -Wdeclaration-after-statement -municode " >> src/stubs/win32/cc64 + echo "${CC64} -o " > src/core/cc64 + echo " -Wdeclaration-after-statement -municode " >> src/core/cc64 ]) ],[ AC_MSG_CHECKING([whether Microsoft Linker needs a PATH shim]) @@ -223,14 +223,14 @@ AS_IF([ test ${WIN32} -eq 1 ],[ AC_MSG_RESULT([from $MSVS_NAME]) CL_FULL="`PATH="${MSVS_PATH}:${PATH}" which cl | cygpath -f - -w`" MSVS_PATH="`echo "${MSVS_PATH}" | cygpath -f - -wp`" - echo "cl /nologo /Fe" > src/stubs/win32/cc64 - echo " " >> src/stubs/win32/cc64 - echo "PATH" >> src/stubs/win32/cc64 - echo "${MSVS_PATH}" >> src/stubs/win32/cc64 - echo "LIB" >> src/stubs/win32/cc64 - echo "${MSVS_LIB}" >> src/stubs/win32/cc64 - echo "INCLUDE" >> src/stubs/win32/cc64 - echo "${MSVS_INC}" >> src/stubs/win32/cc64 + echo "cl /nologo /Fe" > src/core/cc64 + echo " " >> src/core/cc64 + echo "PATH" >> src/core/cc64 + echo "${MSVS_PATH}" >> src/core/cc64 + echo "LIB" >> src/core/cc64 + echo "${MSVS_LIB}" >> src/core/cc64 + echo "INCLUDE" >> src/core/cc64 + echo "${MSVS_INC}" >> src/core/cc64 ]) ]) AS_IF([ test "x${CC64}" = "xno" ],[ @@ -330,7 +330,7 @@ AS_CASE([$TARGET], # NOTE: On Windows, the Windows specific dlls should stay dynamic for security reasons # NOTE: -l:libstdc++.a is necessary (vs. -lstdc++) as flexlink will use libstdc++.dll.a # which still depends on the DLL at runtime instead of libstdc++.a (that looks like a bug in flexlink) - platform_dependent_stuff="-cclib -lopam_stubs_win32_stubs -cclib -l:libstdc++.a -cclib -l:libpthread.a -cclib -Wl,-static -cclib -ladvapi32 -cclib -lgdi32 -cclib -luser32 -cclib -lshell32 -cclib -lole32 -cclib -luuid -cclib -luserenv" + platform_dependent_stuff="-cclib -l:libstdc++.a -cclib -l:libpthread.a -cclib -Wl,-static -cclib -ladvapi32 -cclib -lgdi32 -cclib -luser32 -cclib -lshell32 -cclib -lole32 -cclib -luuid -cclib -luserenv" AS_IF([test "x${SYSTEM}" = "xmingw"], [platform_dependent_stuff="${platform_dependent_stuff} -cclib -lwindowsapp"]) ]) AS_CASE([${support_static},${enable_static}], @@ -433,7 +433,7 @@ fi AC_CONFIG_FILES( Makefile.config src/ocaml-flags-configure.sexp - src/stubs/c-flags.sexp + src/core/c-flags.sexp ) AC_OUTPUT @@ -449,13 +449,6 @@ AS_IF([test "x${with_private_runtime}" != "xno"],[ ]) ]) -rm -f src/stubs/win32/dune -AS_IF([ test ${WIN32} -eq 1],[ - cd src/stubs/win32 - ${LN_S} -f dune-win32 dune - cd ../../.. -]) - echo bindir="`eval echo ${bindir}`" diff --git a/dune-project b/dune-project index dc537179296..15b75c2e8d0 100644 --- a/dune-project +++ b/dune-project @@ -1,4 +1,4 @@ -(lang dune 2.0) +(lang dune 2.6) (name opam) (implicit_transitive_deps true) diff --git a/master_changes.md b/master_changes.md index 2c01fccc46a..0ba755dab14 100644 --- a/master_changes.md +++ b/master_changes.md @@ -112,6 +112,7 @@ users) * Require opam-0install-cudf >= 0.5.0 [#6130 @kit-ty-kate] * Bump the vendored mccs to 1.1+18 [#6170 @kit-ty-kate] * Fix Windows builds with OCaml >= 5.0 [#6189 @kit-ty-kate - fix #6148] + * Upgrade the minimum required version for dune from 2.0.0 to 2.6.0 [#5381 @dra27] ## Infrastructure @@ -158,6 +159,7 @@ users) * Speedup OpamVersionCompare by 25% by removing the unused handling of epoch [#5518 @kit-ty-kate] * Fix error in `OpamSystem.transform_patch` - patches were only applied when debugging [#6182 @dra27 regression since #3449] * Remove `--with-acl` option from the configure script and its related C stubs (reverts a Cygwin fix in #4265) [#5381 @kit-ty-kate - fix #5373] + * Move Windows stubs to opam-core [#5381 @dra27] ## Internal: Windows diff --git a/opam-client.opam b/opam-client.opam index 1972746ebc7..b2c9407c00e 100644 --- a/opam-client.opam +++ b/opam-client.opam @@ -35,7 +35,7 @@ depends: [ "opam-repository" {= version} "re" {>= "1.10.0"} "cmdliner" {>= "1.1.0"} - "dune" {>= "2.0.0"} + "dune" {>= "2.6.0"} ] conflicts: [ "extlib" {< "1.7.8"} diff --git a/opam-core.opam b/opam-core.opam index 4778b85c518..d901e7ba809 100644 --- a/opam-core.opam +++ b/opam-core.opam @@ -26,7 +26,7 @@ depends: [ "base-unix" "ocamlgraph" "re" {>= "1.9.0"} - "dune" {>= "2.0.0"} + "dune" {>= "2.6.0"} "sha" {>= "1.13"} "jsonm" "swhid_core" diff --git a/opam-devel.opam b/opam-devel.opam index ed2015b8cb8..afcbcaf9c42 100644 --- a/opam-devel.opam +++ b/opam-devel.opam @@ -31,7 +31,7 @@ depends: [ "ocaml" {>= "4.08.0"} "opam-client" {= version} "cmdliner" {>= "1.1.0"} - "dune" {>= "2.0.0"} + "dune" {>= "2.6.0"} "conf-openssl" {with-test} "conf-diffutils" {with-test} ] diff --git a/opam-format.opam b/opam-format.opam index 4a3915e5d4d..cd4cb6a03c1 100644 --- a/opam-format.opam +++ b/opam-format.opam @@ -32,5 +32,5 @@ depends: [ "opam-core" {= version} "opam-file-format" {>= "2.1.4"} "re" {>= "1.9.0"} - "dune" {>= "2.0.0"} + "dune" {>= "2.6.0"} ] diff --git a/opam-installer.opam b/opam-installer.opam index 2de65fca63e..7c93f15c623 100644 --- a/opam-installer.opam +++ b/opam-installer.opam @@ -33,5 +33,5 @@ depends: [ "ocaml" {>= "4.08.0"} "opam-format" {= version} "cmdliner" {>= "0.9.8"} - "dune" {>= "2.0.0"} + "dune" {>= "2.6.0"} ] diff --git a/opam-repository.opam b/opam-repository.opam index a697de4f2f0..470cb759fdd 100644 --- a/opam-repository.opam +++ b/opam-repository.opam @@ -30,5 +30,5 @@ build: [ depends: [ "ocaml" {>= "4.08.0"} "opam-format" {= version} - "dune" {>= "2.0.0"} + "dune" {>= "2.6.0"} ] diff --git a/opam-solver.opam b/opam-solver.opam index 40ead91ed5c..09e0f3ae589 100644 --- a/opam-solver.opam +++ b/opam-solver.opam @@ -34,7 +34,7 @@ depends: [ "dose3" {>= "6.1"} "cudf" {>= "0.7"} "re" {>= "1.9.0"} - "dune" {>= "2.0.0"} + "dune" {>= "2.6.0"} "opam-0install-cudf" {>= "0.5.0"} ] depopts: [ diff --git a/opam-state.opam b/opam-state.opam index 7db07f42f89..8306aac95bc 100644 --- a/opam-state.opam +++ b/opam-state.opam @@ -32,5 +32,5 @@ depends: [ "opam-repository" {= version} "re" {>= "1.9.0"} "spdx_licenses" {>= "1.0.0"} - "dune" {>= "2.0.0"} + "dune" {>= "2.6.0"} ] diff --git a/src/stubs/win32/build-putenv.ml b/shell/build-putenv.ml similarity index 100% rename from src/stubs/win32/build-putenv.ml rename to shell/build-putenv.ml diff --git a/src/stubs/c-flags.sexp.in b/src/core/c-flags.sexp.in similarity index 100% rename from src/stubs/c-flags.sexp.in rename to src/core/c-flags.sexp.in diff --git a/src/core/dune b/src/core/dune index 4fbd46f2e15..723aa44aaab 100644 --- a/src/core/dune +++ b/src/core/dune @@ -3,34 +3,39 @@ (public_name opam-core) (synopsis "OCaml Package Manager core internal stdlib") ; TODO: Remove (re_export ...) when CI uses the OCaml version that includes https://github.com/ocaml/ocaml/pull/11989 - (libraries re (re_export ocamlgraph) unix sha jsonm swhid_core uutf - (select opamStubs.ml from - (opam-core.stubs -> opamStubs.win32.ml) - ( -> opamStubs.dummy.ml))) + (libraries re (re_export ocamlgraph) unix sha jsonm swhid_core uutf) (flags (:standard (:include ../ocaml-flags-standard.sexp) (:include ../ocaml-flags-configure.sexp) (:include ../ocaml-context-flags.sexp))) (foreign_stubs (language c) - (names opamCommonStubs) + (names opam_stubs) (flags :standard -DUNICODE -D_UNICODE -DCAML_NAME_SPACE - (:include ../stubs/c-flags.sexp))) + (:include c-flags.sexp))) (c_library_flags (:standard (:include c-libraries.sexp))) (wrapped false)) +(rule + (deps opamWindows.c opamInject.c) + (action (copy# opamCommonStubs.c opam_stubs.c))) + (rule (copy# opamStubsTypes.ml opamStubsTypes.mli)) (rule - (enabled_if (< %{ocaml_version} "5.0")) - (action (copy# opamStubs.ocaml4.ml opamStubs.win32.ml))) + (enabled_if (<> %{os_type} "Win32")) + (action (copy# opamStubs.unix.ml opamStubs.ml))) (rule - (enabled_if (>= %{ocaml_version} "5.0")) - (action (copy# opamStubs.ocaml5.ml opamStubs.win32.ml))) + (enabled_if (and (= %{os_type} "Win32") (< %{ocaml_version} "5.0"))) + (action (copy# opamStubs.ocaml4.ml opamStubs.ml))) + +(rule + (enabled_if (and (= %{os_type} "Win32") (>= %{ocaml_version} "5.0"))) + (action (copy# opamStubs.ocaml5.ml opamStubs.ml))) (rule (write-file opamCoreConfigDeveloper.ml @@ -50,5 +55,22 @@ (mode fallback) (action (with-stdout-to %{targets} (echo "")))) +(rule + (enabled_if (= %{os_type} "Win32")) + (targets opam-putenv.exe) + (deps opamInject.c) + (action (run ocaml %{dep:../../shell/build-putenv.ml} %{targets} %{dep:opam-putenv.c} %{dep:cc64}))) + +(install + (enabled_if (= %{os_type} "Win32")) + (section bin) + (package opam) + (files opam-putenv.exe)) + (rule (with-stdout-to c-libraries.sexp (run ocaml %{dep:../../shell/context_flags.ml} clibs))) + +(rule + (targets c-flags.sexp) + (mode fallback) + (action (with-stdout-to %{targets} (echo "()")))) diff --git a/src/stubs/win32/opam-putenv.c b/src/core/opam-putenv.c similarity index 100% rename from src/stubs/win32/opam-putenv.c rename to src/core/opam-putenv.c diff --git a/src/core/opamCommonStubs.c b/src/core/opamCommonStubs.c index a4cae1f813e..4687e5a69e6 100644 --- a/src/core/opamCommonStubs.c +++ b/src/core/opamCommonStubs.c @@ -58,3 +58,9 @@ CAMLprim value opam_is_executable(value path) caml_stat_free(p); CAMLreturn(Val_bool(ret == 0)); } + +/* This is done here as it simplifies the dune file */ +#ifdef _WIN32 +#include "opamInject.c" +#include "opamWindows.c" +#endif diff --git a/src/stubs/win32/opamInject.c b/src/core/opamInject.c similarity index 100% rename from src/stubs/win32/opamInject.c rename to src/core/opamInject.c diff --git a/src/core/opamStubs.ocaml4.ml b/src/core/opamStubs.ocaml4.ml index 22792c62461..7763f92837c 100644 --- a/src/core/opamStubs.ocaml4.ml +++ b/src/core/opamStubs.ocaml4.ml @@ -9,9 +9,44 @@ (**************************************************************************) include OpamStubsTypes -include OpamWin32Stubs -let getpid () = Int32.to_int (getCurrentProcessID ()) +external getCurrentProcessID : unit -> int32 = "OPAMW_GetCurrentProcessID" +let getpid () = Int32.to_int (getCurrentProcessID ()) +(* Polymorphic parameters below are used as placeholders for types in + * OpamStubsTypes - it's not worth the effort of propagating the types here, + * even if it does result in some ugly-looking primitives! + *) +external getStdHandle : 'a -> 'b = "OPAMW_GetStdHandle" +external getConsoleScreenBufferInfo : 'a -> 'b = "OPAMW_GetConsoleScreenBufferInfo" +external setConsoleTextAttribute : 'a -> int -> unit = "OPAMW_SetConsoleTextAttribute" +external fillConsoleOutputCharacter : 'a -> char -> int -> int * int -> bool = "OPAMW_FillConsoleOutputCharacter" +external getConsoleMode : 'a -> int = "OPAMW_GetConsoleMode" +external setConsoleMode : 'a -> int -> bool = "OPAMW_SetConsoleMode" +external getWindowsVersion : unit -> int * int * int * int = "OPAMW_GetWindowsVersion" +external getArchitecture : unit -> 'a = "OPAMW_GetArchitecture" +external waitpids : int list -> int -> int * Unix.process_status = "OPAMW_waitpids" +external readRegistry : 'a -> string -> string -> 'b -> 'c option = "OPAMW_ReadRegistry" +external enumRegistry : 'a -> string -> 'b -> (string * 'c) list = "OPAMW_RegEnumValue" +external writeRegistry : 'a -> string -> string -> 'b -> 'c -> unit = "OPAMW_WriteRegistry" +external getConsoleOutputCP : unit -> int = "OPAMW_GetConsoleOutputCP" +external getCurrentConsoleFontEx : 'a -> bool -> 'b = "OPAMW_GetCurrentConsoleFontEx" +external create_glyph_checker : string -> 'a * 'a = "OPAMW_CreateGlyphChecker" +external delete_glyph_checker : 'a * 'a -> unit = "OPAMW_DeleteGlyphChecker" +external has_glyph : 'a * 'a -> Uchar.t -> bool = "OPAMW_HasGlyph" +external getProcessArchitecture : int32 option -> 'a = "OPAMW_GetProcessArchitecture" +external process_putenv : int32 -> string -> string -> bool = "OPAMW_process_putenv" +external getPathToHome : unit -> string = "OPAMW_GetPathToHome" +external getPathToSystem : unit -> string = "OPAMW_GetPathToSystem" +external getPathToLocalAppData : unit -> string = "OPAMW_GetPathToLocalAppData" +external sendMessageTimeout : nativeint -> int -> int -> 'a -> 'b -> 'c -> int * 'd = "OPAMW_SendMessageTimeout_byte" "OPAMW_SendMessageTimeout" +external getProcessAncestry : unit -> (int32 * string) list = "OPAMW_GetProcessAncestry" +external getConsoleAlias : string -> string -> string = "OPAMW_GetConsoleAlias" +external getConsoleWindowClass : unit -> string option = "OPAMW_GetConsoleWindowClass" +external setErrorMode : int -> int = "OPAMW_SetErrorMode" +external getErrorMode : unit -> int = "OPAMW_GetErrorMode" +external setConsoleToUTF8 : unit -> unit = "OPAMW_SetConsoleToUTF8" +external getVersionInfo : string -> 'a option = "OPAMW_GetVersionInfo" +external get_initial_environment : unit -> string list = "OPAMW_CreateEnvironmentBlock" external win_create_process : string -> string -> string option -> Unix.file_descr -> Unix.file_descr -> Unix.file_descr -> int = "win_create_process" "win_create_process_native" diff --git a/src/core/opamStubs.dummy.ml b/src/core/opamStubs.unix.ml similarity index 100% rename from src/core/opamStubs.dummy.ml rename to src/core/opamStubs.unix.ml diff --git a/src/core/opamStubsTypes.ml b/src/core/opamStubsTypes.ml index b8a7a5b03f9..40667c0836e 100644 --- a/src/core/opamStubsTypes.ml +++ b/src/core/opamStubsTypes.ml @@ -8,7 +8,7 @@ (* *) (**************************************************************************) -(** Types for C stubs modules. *) +(** Types for C stubs modules and common C stubs. *) (** CONSOLE_SCREEN_BUFFER_INFO struct (see https://docs.microsoft.com/en-us/windows/console/console-screen-buffer-info-str) diff --git a/src/stubs/win32/opamWindows.c b/src/core/opamWindows.c similarity index 100% rename from src/stubs/win32/opamWindows.c rename to src/core/opamWindows.c diff --git a/src/stubs/dune b/src/stubs/dune deleted file mode 100644 index 81c80a658bd..00000000000 --- a/src/stubs/dune +++ /dev/null @@ -1,4 +0,0 @@ -(rule - (targets c-flags.sexp) - (mode fallback) - (action (with-stdout-to %{targets} (echo "()")))) diff --git a/src/stubs/win32/dune-win32 b/src/stubs/win32/dune-win32 deleted file mode 100644 index 9066e956253..00000000000 --- a/src/stubs/win32/dune-win32 +++ /dev/null @@ -1,40 +0,0 @@ -(library - (name opam_stubs_win32) - (public_name opam-core.stubs) - (synopsis "OCaml Package Manager C stubs") - (libraries unix) - (flags (:standard - (:include ../../ocaml-flags-standard.sexp) - (:include ../../ocaml-flags-configure.sexp) - (:include ../../ocaml-context-flags.sexp))) - (modules opamWin32Stubs) - (foreign_stubs - (language c) - (names opamInject opamWindows) - (flags :standard - -DUNICODE -D_UNICODE -DCAML_NAME_SPACE - (:include ../c-flags.sexp))) - (c_library_flags (:standard - (:include c-libraries.sexp))) - (wrapped false)) - -(rule - (copy# opamWin32Stubs.ml opamWin32Stubs.mli)) - -(rule - (targets opam-putenv.exe) - (deps opamInject.c) - (action (run ocaml %{dep:build-putenv.ml} %{targets} %{dep:opam-putenv.c} %{dep:cc64}))) - -(rule - (targets cc64) - (mode fallback) - (action (with-stdout-to %{targets} (echo "")))) - -(install - (section bin) - (package opam) - (files opam-putenv.exe)) - -(rule - (with-stdout-to c-libraries.sexp (run ocaml %{dep:../../../shell/context_flags.ml} clibs))) diff --git a/src/stubs/win32/opamWin32Stubs.ml b/src/stubs/win32/opamWin32Stubs.ml deleted file mode 100644 index dc4c2f7ef34..00000000000 --- a/src/stubs/win32/opamWin32Stubs.ml +++ /dev/null @@ -1,46 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright 2018 MetaStack Solutions Ltd. *) -(* *) -(* All rights reserved. This file is distributed under the terms of the *) -(* GNU Lesser General Public License version 2.1, with the special *) -(* exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -external getCurrentProcessID : unit -> int32 = "OPAMW_GetCurrentProcessID" -(* Polymorphic parameters below are used as placeholders for types in - * OpamStubsTypes - it's not worth the effort of propagating the types here, - * even if it does result in some ugly-looking primitives! - *) -external getStdHandle : 'a -> 'b = "OPAMW_GetStdHandle" -external getConsoleScreenBufferInfo : 'a -> 'b = "OPAMW_GetConsoleScreenBufferInfo" -external setConsoleTextAttribute : 'a -> int -> unit = "OPAMW_SetConsoleTextAttribute" -external fillConsoleOutputCharacter : 'a -> char -> int -> int * int -> bool = "OPAMW_FillConsoleOutputCharacter" -external getConsoleMode : 'a -> int = "OPAMW_GetConsoleMode" -external setConsoleMode : 'a -> int -> bool = "OPAMW_SetConsoleMode" -external getWindowsVersion : unit -> int * int * int * int = "OPAMW_GetWindowsVersion" -external getArchitecture : unit -> 'a = "OPAMW_GetArchitecture" -external waitpids : int list -> int -> int * Unix.process_status = "OPAMW_waitpids" -external readRegistry : 'a -> string -> string -> 'b -> 'c option = "OPAMW_ReadRegistry" -external enumRegistry : 'a -> string -> 'b -> (string * 'c) list = "OPAMW_RegEnumValue" -external writeRegistry : 'a -> string -> string -> 'b -> 'c -> unit = "OPAMW_WriteRegistry" -external getConsoleOutputCP : unit -> int = "OPAMW_GetConsoleOutputCP" -external getCurrentConsoleFontEx : 'a -> bool -> 'b = "OPAMW_GetCurrentConsoleFontEx" -external create_glyph_checker : string -> 'a * 'a = "OPAMW_CreateGlyphChecker" -external delete_glyph_checker : 'a * 'a -> unit = "OPAMW_DeleteGlyphChecker" -external has_glyph : 'a * 'a -> Uchar.t -> bool = "OPAMW_HasGlyph" -external getProcessArchitecture : int32 option -> 'a = "OPAMW_GetProcessArchitecture" -external process_putenv : int32 -> string -> string -> bool = "OPAMW_process_putenv" -external getPathToHome : unit -> string = "OPAMW_GetPathToHome" -external getPathToSystem : unit -> string = "OPAMW_GetPathToSystem" -external getPathToLocalAppData : unit -> string = "OPAMW_GetPathToLocalAppData" -external sendMessageTimeout : nativeint -> int -> int -> 'a -> 'b -> 'c -> int * 'd = "OPAMW_SendMessageTimeout_byte" "OPAMW_SendMessageTimeout" -external getProcessAncestry : unit -> (int32 * string) list = "OPAMW_GetProcessAncestry" -external getConsoleAlias : string -> string -> string = "OPAMW_GetConsoleAlias" -external getConsoleWindowClass : unit -> string option = "OPAMW_GetConsoleWindowClass" -external setErrorMode : int -> int = "OPAMW_SetErrorMode" -external getErrorMode : unit -> int = "OPAMW_GetErrorMode" -external setConsoleToUTF8 : unit -> unit = "OPAMW_SetConsoleToUTF8" -external getVersionInfo : string -> 'a option = "OPAMW_GetVersionInfo" -external get_initial_environment : unit -> string list = "OPAMW_CreateEnvironmentBlock"