@@ -410,24 +410,62 @@ let pacman_opam2 ?(labels = []) ?arch ~opam_hashes distro () =
410410 @@ Linux.Pacman. add_user ~uid: 1000 ~sudo: true " opam"
411411 @@ install_bubblewrap_wrappers @@ Linux.Git. init ()
412412
413- (* TODO: Compile opam-2.0 and 2.1 instead of downloading binaries,
414- add an option to enable 0install-solver,
415- and pass ~hash_opam_2_0 ~hash_opam_2_1 like the cygwin one *)
416- (* Native Windows, WinGet, Cygwin based Dockerfiles *)
417- let windows_opam2 ?win10_revision ?winget ?(labels = [] ) ?arch ~opam_hashes
413+ let install_winget ?win10_revision ?winget version =
414+ match winget with
415+ | None when Windows.Winget. is_supported version ->
416+ ( Windows. header ~alias: " winget-builder" ?win10_revision ~version ()
417+ @@ Windows.Winget. install_from_release () ,
418+ Windows.Winget. setup ~from: " winget-builder" ()
419+ @@ Windows.Winget. dev_packages ~version () )
420+ | _ -> (empty, empty)
421+
422+ (* Native Windows with mingw-w64 and WinGet. *)
423+ let windows_mingw_opam2 ?win10_revision ?winget ?(labels = [] ) ?arch
424+ ~opam_hashes distro () =
425+ let opam_master_hash, opam_branches =
426+ create_opam_branches_windows opam_hashes
427+ in
428+ let version = match distro with `Windows (_ , v ) -> v | _ -> assert false in
429+ let winget_image, winget_setup =
430+ install_winget ?win10_revision ?winget version
431+ in
432+ let opams_image =
433+ Windows. header ~alias: " opam-builder" ?win10_revision ~version ()
434+ @@ Windows. sanitize_reg_path ()
435+ @@ Windows.Cygwin. (
436+ install_cygwin
437+ ~extra:
438+ (" git" :: " patch" :: " mingw64-x86_64-gcc-g++"
439+ :: " mingw64-i686-gcc-g++" :: mingw_packages)
440+ () )
441+ @@ install_opams_windows opam_master_hash opam_branches
442+ in
443+ (* 2022-10-12: Docker Engine 20.10.18 on Windows fails copying
444+ C:\cygwin64, so we cannot build Cygwin in a separate image. *)
445+ let ocaml_for_windows =
446+ let extra = Windows.Cygwin. mingw_packages in
447+ let extra, pkgs = Windows.Cygwin. ocaml_for_windows_packages ~extra () in
448+ Windows.Cygwin. install_cygwin ~msvs_tools: true ~extra () @@ pkgs
449+ in
450+ winget_image @@ opams_image
451+ @@ header ?win10_revision ?arch distro
452+ @@ label ((" distro_style" , " windows" ) :: labels)
453+ @@ user " ContainerAdministrator"
454+ @@ Windows. install_vc_redist ()
455+ @@ Windows. sanitize_reg_path ()
456+ @@ winget_setup @@ ocaml_for_windows
457+ @@ copy_opams_windows opam_branches
458+ @@ Windows.Cygwin. setup () @@ Windows.Cygwin.Git. init ()
459+
460+ (* Native Windows with MSVC and WinGet. *)
461+ let windows_msvc_opam2 ?win10_revision ?winget ?(labels = [] ) ~opam_hashes
418462 distro () =
419463 let opam_master_hash, opam_branches =
420464 create_opam_branches_windows opam_hashes
421465 in
422466 let version = match distro with `Windows (_ , v ) -> v | _ -> assert false in
423467 let winget_image, winget_setup =
424- match winget with
425- | None when Windows.Winget. is_supported version ->
426- ( Windows. header ~alias: " winget-builder" ?win10_revision ~version ()
427- @@ Windows.Winget. install_from_release () ,
428- Windows.Winget. setup ~from: " winget-builder" ()
429- @@ Windows.Winget. dev_packages ~version () )
430- | _ -> (empty, empty)
468+ install_winget ?win10_revision ?winget version
431469 in
432470 let opams_image =
433471 Windows. header ~alias: " opam-builder" ?win10_revision ~version ()
@@ -444,16 +482,12 @@ let windows_opam2 ?win10_revision ?winget ?(labels = []) ?arch ~opam_hashes
444482 C:\cygwin64, so we cannot build Cygwin in a separate image. *)
445483 let ocaml_for_windows =
446484 let extra, vs_build_tools =
447- match distro with
448- | `Windows (`Mingw, _ ) -> (Windows.Cygwin. mingw_packages, empty)
449- | `Windows (`Msvc, _ ) ->
450- ( Windows.Cygwin. msvc_packages,
451- Windows. install_visual_studio_build_tools
452- [
453- " Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ;
454- " Microsoft.VisualStudio.Component.Windows10SDK.18362" ;
455- ] )
456- | _ -> invalid_arg " Invalid distribution"
485+ ( Windows.Cygwin. msvc_packages,
486+ Windows. install_visual_studio_build_tools
487+ [
488+ " Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ;
489+ " Microsoft.VisualStudio.Component.Windows10SDK.18362" ;
490+ ] )
457491 in
458492 let extra, pkgs = Windows.Cygwin. ocaml_for_windows_packages ~extra () in
459493 Windows.Cygwin. install_cygwin ~msvs_tools: true ~extra ()
@@ -488,8 +522,14 @@ let gen_opam2_distro ?win10_revision ?winget ?(clone_opam_repo = true) ?arch
488522 ~c_devtools_libs ~opam_hashes d ()
489523 | `Zypper -> zypper_opam2 ?labels ?arch ~opam_hashes d ()
490524 | `Pacman -> pacman_opam2 ?labels ?arch ~opam_hashes d ()
491- | `Windows ->
492- windows_opam2 ?win10_revision ?winget ?labels ?arch ~opam_hashes d ()
525+ | `Windows -> (
526+ match d with
527+ | `Windows (`Mingw, _ ) ->
528+ windows_mingw_opam2 ?win10_revision ?winget ?labels ?arch
529+ ~opam_hashes d ()
530+ | `Windows (`Msvc, _ ) ->
531+ windows_msvc_opam2 ?win10_revision ?winget ?labels ~opam_hashes d ()
532+ | _ -> assert false )
493533 | `Cygwin ->
494534 failwith
495535 " OCaml/opam Docker images with the Cygwin port are not supported."
0 commit comments