···11-# setup-dkml
22-# Short form: sd4
33-44-<#
55-.SYNOPSIS
66-77-Setup Diskuv OCaml (DKML) compiler on a desktop PC.
88-99-.DESCRIPTION
1010-1111-Setup Diskuv OCaml (DKML) compiler on a desktop PC.
1212-1313-.PARAMETER PC_PROJECT_DIR
1414-Context variable for the project directory. Defaults to the current directory.
1515-1616-.PARAMETER FDOPEN_OPAMEXE_BOOTSTRAP
1717-Input variable.
1818-1919-.PARAMETER CACHE_PREFIX
2020-Input variable.
2121-2222-.PARAMETER OCAML_COMPILER
2323-Input variable. -DKML_COMPILER takes priority. If -DKML_COMPILER is not set and -OCAML_COMPILER is set, then the specified OCaml version tag of dkml-compiler (ex. 4.12.1) is used.
2424-2525-.PARAMETER DKML_COMPILER
2626-Input variable. Unspecified or blank is the latest from the default branch (main) of dkml-compiler. @repository@ is the latest from Opam.
2727-2828-.PARAMETER SKIP_OPAM_MODIFICATIONS
2929-Input variable. If true (the default is false) then the opam root and switches will not be created or modified.
3030-3131-.PARAMETER SECONDARY_SWITCH
3232-Input variable. If true then the secondary switch named 'two' is created.
3333-3434-.PARAMETER PRIMARY_SWITCH_SKIP_INSTALL
3535-Input variable. If true no dkml-base-compiler will be installed in the 'dkml' switch.
3636-3737-.PARAMETER CONF_DKML_CROSS_TOOLCHAIN
3838-Input variable. Unspecified or blank is the latest from the default branch (main) of conf-dkml-cross-toolchain. @repository@ is the latest from Opam.
3939-4040-.PARAMETER DISKUV_OPAM_REPOSITORY
4141-Input variable. Defaults to the value of -DEFAULT_DISKUV_OPAM_REPOSITORY_TAG (see below)
4242-4343-.PARAMETER DKML_HOME
4444-Input variables. If specified then DiskuvOCamlHome, DiskuvOCamlBinaryPaths and DiskuvOCamlDeploymentId will be set, in addition to the always-present DiskuvOCamlVarsVersion, DiskuvOCamlVersion
4545-and DiskuvOCamlMSYS2Dir.
4646-4747-# autogen from global_env_vars.
4848-.PARAMETER DKML_VERSION
4949-Environment variable.
5050-5151-.PARAMETER DEFAULT_DISKUV_OPAM_REPOSITORY_TAG
5252-Environment variable.
5353-5454-.PARAMETER DEFAULT_DKML_COMPILER
5555-Environment variable.
5656-5757-.PARAMETER PIN_ASTRING
5858-Environment variable.
5959-6060-.PARAMETER PIN_BASE
6161-Environment variable.
6262-6363-.PARAMETER PIN_BASE64
6464-Environment variable.
6565-6666-.PARAMETER PIN_BIGARRAY_COMPAT
6767-Environment variable.
6868-6969-.PARAMETER PIN_BOS
7070-Environment variable.
7171-7272-.PARAMETER PIN_CAMLP_STREAMS
7373-Environment variable.
7474-7575-.PARAMETER PIN_CHROME_TRACE
7676-Environment variable.
7777-7878-.PARAMETER PIN_CMDLINER
7979-Environment variable.
8080-8181-.PARAMETER PIN_CONF_DKML_SYS_OPAM
8282-Environment variable.
8383-8484-.PARAMETER PIN_CONF_PKG_CONFIG
8585-Environment variable.
8686-8787-.PARAMETER PIN_CONF_SQLITE3
8888-Environment variable.
8989-9090-.PARAMETER PIN_CPPO
9191-Environment variable.
9292-9393-.PARAMETER PIN_CRUNCH
9494-Environment variable.
9595-9696-.PARAMETER PIN_CSEXP
9797-Environment variable.
9898-9999-.PARAMETER PIN_CSTRUCT
100100-Environment variable.
101101-102102-.PARAMETER PIN_CTYPES_FOREIGN
103103-Environment variable.
104104-105105-.PARAMETER PIN_CTYPES
106106-Environment variable.
107107-108108-.PARAMETER PIN_CUDF
109109-Environment variable.
110110-111111-.PARAMETER PIN_DIGESTIF
112112-Environment variable.
113113-114114-.PARAMETER PIN_DISKUVBOX
115115-Environment variable.
116116-117117-.PARAMETER PIN_DKML_APPS
118118-Environment variable.
119119-120120-.PARAMETER PIN_DKML_BASE_COMPILER
121121-Environment variable.
122122-123123-.PARAMETER PIN_DKML_BUILD_DESKTOP
124124-Environment variable.
125125-126126-.PARAMETER PIN_DKML_C_PROBE
127127-Environment variable.
128128-129129-.PARAMETER PIN_DKML_COMPILER_ENV
130130-Environment variable.
131131-132132-.PARAMETER PIN_DKML_COMPILER_SRC
133133-Environment variable.
134134-135135-.PARAMETER PIN_DKML_COMPONENT_COMMON_DESKTOP
136136-Environment variable.
137137-138138-.PARAMETER PIN_DKML_COMPONENT_COMMON_OPAM
139139-Environment variable.
140140-141141-.PARAMETER PIN_DKML_COMPONENT_COMMON_UNIXUTILS
142142-Environment variable.
143143-144144-.PARAMETER PIN_DKML_COMPONENT_OCAMLCOMPILER_COMMON
145145-Environment variable.
146146-147147-.PARAMETER PIN_DKML_COMPONENT_OCAMLCOMPILER_NETWORK
148148-Environment variable.
149149-150150-.PARAMETER PIN_DKML_COMPONENT_OCAMLCOMPILER_OFFLINE
151151-Environment variable.
152152-153153-.PARAMETER PIN_DKML_COMPONENT_OFFLINE_DESKTOP_FULL
154154-Environment variable.
155155-156156-.PARAMETER PIN_DKML_COMPONENT_OFFLINE_OPAMSHIM
157157-Environment variable.
158158-159159-.PARAMETER PIN_DKML_COMPONENT_OFFLINE_UNIXUTILS
160160-Environment variable.
161161-162162-.PARAMETER PIN_DKML_COMPONENT_STAGING_DESKTOP_FULL
163163-Environment variable.
164164-165165-.PARAMETER PIN_DKML_COMPONENT_STAGING_DKMLCONFDIR
166166-Environment variable.
167167-168168-.PARAMETER PIN_DKML_COMPONENT_STAGING_OCAMLRUN
169169-Environment variable.
170170-171171-.PARAMETER PIN_DKML_COMPONENT_STAGING_OPAM32
172172-Environment variable.
173173-174174-.PARAMETER PIN_DKML_COMPONENT_STAGING_OPAM64
175175-Environment variable.
176176-177177-.PARAMETER PIN_DKML_COMPONENT_STAGING_UNIXUTILS
178178-Environment variable.
179179-180180-.PARAMETER PIN_DKML_COMPONENT_STAGING_WITHDKML
181181-Environment variable.
182182-183183-.PARAMETER PIN_DKML_COMPONENT_XX_CONSOLE
184184-Environment variable.
185185-186186-.PARAMETER PIN_DKML_EXE_LIB
187187-Environment variable.
188188-189189-.PARAMETER PIN_DKML_EXE
190190-Environment variable.
191191-192192-.PARAMETER PIN_DKML_INSTALL_INSTALLER
193193-Environment variable.
194194-195195-.PARAMETER PIN_DKML_INSTALL_RUNNER
196196-Environment variable.
197197-198198-.PARAMETER PIN_DKML_INSTALL
199199-Environment variable.
200200-201201-.PARAMETER PIN_DKML_INSTALLER_OCAML_COMMON
202202-Environment variable.
203203-204204-.PARAMETER PIN_DKML_INSTALLER_OCAML_OFFLINE
205205-Environment variable.
206206-207207-.PARAMETER PIN_DKML_PACKAGE_CONSOLE
208208-Environment variable.
209209-210210-.PARAMETER PIN_DKML_RUNTIME_COMMON_NATIVE
211211-Environment variable.
212212-213213-.PARAMETER PIN_DKML_RUNTIME_COMMON
214214-Environment variable.
215215-216216-.PARAMETER PIN_DKML_RUNTIME_DISTRIBUTION
217217-Environment variable.
218218-219219-.PARAMETER PIN_DKML_RUNTIMELIB
220220-Environment variable.
221221-222222-.PARAMETER PIN_DKML_RUNTIMESCRIPTS
223223-Environment variable.
224224-225225-.PARAMETER PIN_DKML_WORKFLOWS
226226-Environment variable.
227227-228228-.PARAMETER PIN_DUNE_ACTION_PLUGIN
229229-Environment variable.
230230-231231-.PARAMETER PIN_DUNE_BUILD_INFO
232232-Environment variable.
233233-234234-.PARAMETER PIN_DUNE_CONFIGURATOR
235235-Environment variable.
236236-237237-.PARAMETER PIN_DUNE_GLOB
238238-Environment variable.
239239-240240-.PARAMETER PIN_DUNE_PRIVATE_LIBS
241241-Environment variable.
242242-243243-.PARAMETER PIN_DUNE_RPC_LWT
244244-Environment variable.
245245-246246-.PARAMETER PIN_DUNE_RPC
247247-Environment variable.
248248-249249-.PARAMETER PIN_DUNE_SITE
250250-Environment variable.
251251-252252-.PARAMETER PIN_DUNE
253253-Environment variable.
254254-255255-.PARAMETER PIN_DYN
256256-Environment variable.
257257-258258-.PARAMETER PIN_EITHER
259259-Environment variable.
260260-261261-.PARAMETER PIN_EQAF
262262-Environment variable.
263263-264264-.PARAMETER PIN_EXTLIB
265265-Environment variable.
266266-267267-.PARAMETER PIN_EZJSONM
268268-Environment variable.
269269-270270-.PARAMETER PIN_FEATHER
271271-Environment variable.
272272-273273-.PARAMETER PIN_FIBER
274274-Environment variable.
275275-276276-.PARAMETER PIN_FIX
277277-Environment variable.
278278-279279-.PARAMETER PIN_FMT
280280-Environment variable.
281281-282282-.PARAMETER PIN_FPATH
283283-Environment variable.
284284-285285-.PARAMETER PIN_GRAPHICS
286286-Environment variable.
287287-288288-.PARAMETER PIN_HEX
289289-Environment variable.
290290-291291-.PARAMETER PIN_INTEGERS
292292-Environment variable.
293293-294294-.PARAMETER PIN_JANE_STREET_HEADERS
295295-Environment variable.
296296-297297-.PARAMETER PIN_JINGOO
298298-Environment variable.
299299-300300-.PARAMETER PIN_JSONM
301301-Environment variable.
302302-303303-.PARAMETER PIN_JSONRPC
304304-Environment variable.
305305-306306-.PARAMETER PIN_JST_CONFIG
307307-Environment variable.
308308-309309-.PARAMETER PIN_LAMBDA_TERM
310310-Environment variable.
311311-312312-.PARAMETER PIN_LOGS
313313-Environment variable.
314314-315315-.PARAMETER PIN_LSP
316316-Environment variable.
317317-318318-.PARAMETER PIN_LWT
319319-Environment variable.
320320-321321-.PARAMETER PIN_LWT_REACT
322322-Environment variable.
323323-324324-.PARAMETER PIN_MCCS
325325-Environment variable.
326326-327327-.PARAMETER PIN_MDX
328328-Environment variable.
329329-330330-.PARAMETER PIN_MENHIR
331331-Environment variable.
332332-333333-.PARAMETER PIN_MENHIRLIB
334334-Environment variable.
335335-336336-.PARAMETER PIN_MENHIRSDK
337337-Environment variable.
338338-339339-.PARAMETER PIN_MERLIN_LIB
340340-Environment variable.
341341-342342-.PARAMETER PIN_METAPP
343343-Environment variable.
344344-345345-.PARAMETER PIN_METAQUOT
346346-Environment variable.
347347-348348-.PARAMETER PIN_MEW
349349-Environment variable.
350350-351351-.PARAMETER PIN_MEW_VI
352352-Environment variable.
353353-354354-.PARAMETER PIN_NUM
355355-Environment variable.
356356-357357-.PARAMETER PIN_OCAML_COMPILER_LIBS
358358-Environment variable.
359359-360360-.PARAMETER PIN_OCAML_LSP_SERVER
361361-Environment variable.
362362-363363-.PARAMETER PIN_OCAML_VERSION
364364-Environment variable.
365365-366366-.PARAMETER PIN_OCAML
367367-Environment variable.
368368-369369-.PARAMETER PIN_OCAMLBUILD
370370-Environment variable.
371371-372372-.PARAMETER PIN_OCAMLC_LOC
373373-Environment variable.
374374-375375-.PARAMETER PIN_OCAMLFIND
376376-Environment variable.
377377-378378-.PARAMETER PIN_OCAMLFORMAT_LIB
379379-Environment variable.
380380-381381-.PARAMETER PIN_OCAMLFORMAT_RPC_LIB
382382-Environment variable.
383383-384384-.PARAMETER PIN_OCAMLFORMAT
385385-Environment variable.
386386-387387-.PARAMETER PIN_OCP_INDENT
388388-Environment variable.
389389-390390-.PARAMETER PIN_OCPLIB_ENDIAN
391391-Environment variable.
392392-393393-.PARAMETER PIN_ODOC_PARSER
394394-Environment variable.
395395-396396-.PARAMETER PIN_ODOC
397397-Environment variable.
398398-399399-.PARAMETER PIN_ORDERING
400400-Environment variable.
401401-402402-.PARAMETER PIN_PARSEXP
403403-Environment variable.
404404-405405-.PARAMETER PIN_PP
406406-Environment variable.
407407-408408-.PARAMETER PIN_PPX_ASSERT
409409-Environment variable.
410410-411411-.PARAMETER PIN_PPX_BASE
412412-Environment variable.
413413-414414-.PARAMETER PIN_PPX_COLD
415415-Environment variable.
416416-417417-.PARAMETER PIN_PPX_COMPARE
418418-Environment variable.
419419-420420-.PARAMETER PIN_PPX_DERIVERS
421421-Environment variable.
422422-423423-.PARAMETER PIN_PPX_DERIVING
424424-Environment variable.
425425-426426-.PARAMETER PIN_PPX_ENUMERATE
427427-Environment variable.
428428-429429-.PARAMETER PIN_PPX_EXPECT
430430-Environment variable.
431431-432432-.PARAMETER PIN_PPX_GLOBALIZE
433433-Environment variable.
434434-435435-.PARAMETER PIN_PPX_HASH
436436-Environment variable.
437437-438438-.PARAMETER PIN_PPX_HERE
439439-Environment variable.
440440-441441-.PARAMETER PIN_PPX_IGNORE_INSTRUMENTATION
442442-Environment variable.
443443-444444-.PARAMETER PIN_PPX_INLINE_TEST
445445-Environment variable.
446446-447447-.PARAMETER PIN_PPX_OPTCOMP
448448-Environment variable.
449449-450450-.PARAMETER PIN_PPX_PIPEBANG
451451-Environment variable.
452452-453453-.PARAMETER PIN_PPX_SEXP_CONV
454454-Environment variable.
455455-456456-.PARAMETER PIN_PPX_YOJSON_CONV_LIB
457457-Environment variable.
458458-459459-.PARAMETER PIN_PPXLIB
460460-Environment variable.
461461-462462-.PARAMETER PIN_PTIME
463463-Environment variable.
464464-465465-.PARAMETER PIN_QRC
466466-Environment variable.
467467-468468-.PARAMETER PIN_RE
469469-Environment variable.
470470-471471-.PARAMETER PIN_REACT
472472-Environment variable.
473473-474474-.PARAMETER PIN_REFL
475475-Environment variable.
476476-477477-.PARAMETER PIN_RESULT
478478-Environment variable.
479479-480480-.PARAMETER PIN_RRESULT
481481-Environment variable.
482482-483483-.PARAMETER PIN_SEQ
484484-Environment variable.
485485-486486-.PARAMETER PIN_SEXPLIB
487487-Environment variable.
488488-489489-.PARAMETER PIN_SEXPLIB0
490490-Environment variable.
491491-492492-.PARAMETER PIN_SHA
493493-Environment variable.
494494-495495-.PARAMETER PIN_SPAWN
496496-Environment variable.
497497-498498-.PARAMETER PIN_SQLITE3
499499-Environment variable.
500500-501501-.PARAMETER PIN_STDCOMPAT
502502-Environment variable.
503503-504504-.PARAMETER PIN_STDIO
505505-Environment variable.
506506-507507-.PARAMETER PIN_STDLIB_SHIMS
508508-Environment variable.
509509-510510-.PARAMETER PIN_STDUNE
511511-Environment variable.
512512-513513-.PARAMETER PIN_TIME_NOW
514514-Environment variable.
515515-516516-.PARAMETER PIN_TOPKG
517517-Environment variable.
518518-519519-.PARAMETER PIN_TRAVERSE
520520-Environment variable.
521521-522522-.PARAMETER PIN_TRIE
523523-Environment variable.
524524-525525-.PARAMETER PIN_TSORT
526526-Environment variable.
527527-528528-.PARAMETER PIN_TYXML
529529-Environment variable.
530530-531531-.PARAMETER PIN_UCHAR
532532-Environment variable.
533533-534534-.PARAMETER PIN_UTOP
535535-Environment variable.
536536-537537-.PARAMETER PIN_UUCP
538538-Environment variable.
539539-540540-.PARAMETER PIN_UUIDM
541541-Environment variable.
542542-543543-.PARAMETER PIN_UUSEG
544544-Environment variable.
545545-546546-.PARAMETER PIN_UUTF
547547-Environment variable.
548548-549549-.PARAMETER PIN_WITH_DKML
550550-Environment variable.
551551-552552-.PARAMETER PIN_XDG
553553-Environment variable.
554554-555555-.PARAMETER PIN_YOJSON
556556-Environment variable.
557557-558558-.PARAMETER PIN_ZED
559559-Environment variable.
560560-561561-#>
562562-[CmdletBinding()]
563563-param (
564564- # Context variables
565565- [Parameter(HelpMessage='Defaults to the current directory')]
566566- [string]
567567- $PC_PROJECT_DIR = $PWD,
568568-569569- # Input variables
570570- [string]
571571- $FDOPEN_OPAMEXE_BOOTSTRAP = "false",
572572- [string]
573573- $CACHE_PREFIX = "v1",
574574- [string]
575575- $OCAML_COMPILER = "",
576576- [string]
577577- $DKML_COMPILER = "",
578578- [string]
579579- $SKIP_OPAM_MODIFICATIONS = "false",
580580- [string]
581581- $SECONDARY_SWITCH = "false",
582582- [string]
583583- $PRIMARY_SWITCH_SKIP_INSTALL = "false",
584584- [string]
585585- $CONF_DKML_CROSS_TOOLCHAIN = "@repository@",
586586- [string]
587587- $DISKUV_OPAM_REPOSITORY = "",
588588- [string]
589589- $DKML_HOME = ""
590590-591591- # Conflicts with automatic variable $Verbose
592592- # [Parameter()]
593593- # [string]
594594- # $VERBOSE = "false"
595595-596596- # Environment variables (can be overridden on command line)
597597- # autogen from global_env_vars.
598598- ,[Parameter()] [string] $DKML_VERSION = "2.0.3"
599599- ,[Parameter()] [string] $DEFAULT_DISKUV_OPAM_REPOSITORY_TAG = "2.0.3"
600600- ,[Parameter()] [string] $DEFAULT_DKML_COMPILER = "2.0.3"
601601- ,[Parameter()] [string] $PIN_ASTRING = "0.8.5"
602602- ,[Parameter()] [string] $PIN_BASE = "v0.16.1"
603603- ,[Parameter()] [string] $PIN_BASE64 = "3.5.1"
604604- ,[Parameter()] [string] $PIN_BIGARRAY_COMPAT = "1.1.0"
605605- ,[Parameter()] [string] $PIN_BOS = "0.2.1"
606606- ,[Parameter()] [string] $PIN_CAMLP_STREAMS = "5.0.1"
607607- ,[Parameter()] [string] $PIN_CHROME_TRACE = "3.10.0"
608608- ,[Parameter()] [string] $PIN_CMDLINER = "1.2.0"
609609- ,[Parameter()] [string] $PIN_CONF_DKML_SYS_OPAM = "1"
610610- ,[Parameter()] [string] $PIN_CONF_PKG_CONFIG = "2+cpkgs"
611611- ,[Parameter()] [string] $PIN_CONF_SQLITE3 = "3.1+cpkgs"
612612- ,[Parameter()] [string] $PIN_CPPO = "1.6.9"
613613- ,[Parameter()] [string] $PIN_CRUNCH = "3.3.1"
614614- ,[Parameter()] [string] $PIN_CSEXP = "1.5.2"
615615- ,[Parameter()] [string] $PIN_CSTRUCT = "6.2.0"
616616- ,[Parameter()] [string] $PIN_CTYPES_FOREIGN = "0.19.2-windowssupport-r7"
617617- ,[Parameter()] [string] $PIN_CTYPES = "0.19.2-windowssupport-r7"
618618- ,[Parameter()] [string] $PIN_CUDF = "0.10"
619619- ,[Parameter()] [string] $PIN_DIGESTIF = "1.1.4"
620620- ,[Parameter()] [string] $PIN_DISKUVBOX = "0.2.0"
621621- ,[Parameter()] [string] $PIN_DKML_APPS = "2.0.3"
622622- ,[Parameter()] [string] $PIN_DKML_BASE_COMPILER = "4.14.0~v2.0.3"
623623- ,[Parameter()] [string] $PIN_DKML_BUILD_DESKTOP = "2.0.3"
624624- ,[Parameter()] [string] $PIN_DKML_C_PROBE = "3.0.0"
625625- ,[Parameter()] [string] $PIN_DKML_COMPILER_ENV = "2.0.3"
626626- ,[Parameter()] [string] $PIN_DKML_COMPILER_SRC = "2.0.3"
627627- ,[Parameter()] [string] $PIN_DKML_COMPONENT_COMMON_DESKTOP = "2.0.3"
628628- ,[Parameter()] [string] $PIN_DKML_COMPONENT_COMMON_OPAM = "2.2.0~alpha0~20221228"
629629- ,[Parameter()] [string] $PIN_DKML_COMPONENT_COMMON_UNIXUTILS = "0.2.0"
630630- ,[Parameter()] [string] $PIN_DKML_COMPONENT_OCAMLCOMPILER_COMMON = "4.14.0~v2.0.3"
631631- ,[Parameter()] [string] $PIN_DKML_COMPONENT_OCAMLCOMPILER_NETWORK = "4.14.0~v2.0.3"
632632- ,[Parameter()] [string] $PIN_DKML_COMPONENT_OCAMLCOMPILER_OFFLINE = "4.14.0~v2.0.3"
633633- ,[Parameter()] [string] $PIN_DKML_COMPONENT_OFFLINE_DESKTOP_FULL = "2.0.3"
634634- ,[Parameter()] [string] $PIN_DKML_COMPONENT_OFFLINE_OPAMSHIM = "2.2.0~alpha0~20221228"
635635- ,[Parameter()] [string] $PIN_DKML_COMPONENT_OFFLINE_UNIXUTILS = "0.2.0"
636636- ,[Parameter()] [string] $PIN_DKML_COMPONENT_STAGING_DESKTOP_FULL = "2.0.3"
637637- ,[Parameter()] [string] $PIN_DKML_COMPONENT_STAGING_DKMLCONFDIR = "2.0.3"
638638- ,[Parameter()] [string] $PIN_DKML_COMPONENT_STAGING_OCAMLRUN = "4.14.0~v2.0.3"
639639- ,[Parameter()] [string] $PIN_DKML_COMPONENT_STAGING_OPAM32 = "2.2.0~alpha0~20221228"
640640- ,[Parameter()] [string] $PIN_DKML_COMPONENT_STAGING_OPAM64 = "2.2.0~alpha0~20221228"
641641- ,[Parameter()] [string] $PIN_DKML_COMPONENT_STAGING_UNIXUTILS = "0.2.0"
642642- ,[Parameter()] [string] $PIN_DKML_COMPONENT_STAGING_WITHDKML = "2.0.3"
643643- ,[Parameter()] [string] $PIN_DKML_COMPONENT_XX_CONSOLE = "0.1.1"
644644- ,[Parameter()] [string] $PIN_DKML_EXE_LIB = "2.0.3"
645645- ,[Parameter()] [string] $PIN_DKML_EXE = "2.0.3"
646646- ,[Parameter()] [string] $PIN_DKML_INSTALL_INSTALLER = "0.5.1"
647647- ,[Parameter()] [string] $PIN_DKML_INSTALL_RUNNER = "0.5.1"
648648- ,[Parameter()] [string] $PIN_DKML_INSTALL = "0.5.1"
649649- ,[Parameter()] [string] $PIN_DKML_INSTALLER_OCAML_COMMON = "2.0.3"
650650- ,[Parameter()] [string] $PIN_DKML_INSTALLER_OCAML_OFFLINE = "2.0.3"
651651- ,[Parameter()] [string] $PIN_DKML_PACKAGE_CONSOLE = "0.5.1"
652652- ,[Parameter()] [string] $PIN_DKML_RUNTIME_COMMON_NATIVE = "2.0.3"
653653- ,[Parameter()] [string] $PIN_DKML_RUNTIME_COMMON = "2.0.3"
654654- ,[Parameter()] [string] $PIN_DKML_RUNTIME_DISTRIBUTION = "2.0.3"
655655- ,[Parameter()] [string] $PIN_DKML_RUNTIMELIB = "2.0.3"
656656- ,[Parameter()] [string] $PIN_DKML_RUNTIMESCRIPTS = "2.0.3"
657657- ,[Parameter()] [string] $PIN_DKML_WORKFLOWS = "2.0.3"
658658- ,[Parameter()] [string] $PIN_DUNE_ACTION_PLUGIN = "3.8.3"
659659- ,[Parameter()] [string] $PIN_DUNE_BUILD_INFO = "3.8.3"
660660- ,[Parameter()] [string] $PIN_DUNE_CONFIGURATOR = "3.8.3"
661661- ,[Parameter()] [string] $PIN_DUNE_GLOB = "3.8.3"
662662- ,[Parameter()] [string] $PIN_DUNE_PRIVATE_LIBS = "3.8.3"
663663- ,[Parameter()] [string] $PIN_DUNE_RPC_LWT = "3.8.3"
664664- ,[Parameter()] [string] $PIN_DUNE_RPC = "3.8.3"
665665- ,[Parameter()] [string] $PIN_DUNE_SITE = "3.8.3"
666666- ,[Parameter()] [string] $PIN_DUNE = "3.8.3"
667667- ,[Parameter()] [string] $PIN_DYN = "3.8.3"
668668- ,[Parameter()] [string] $PIN_EITHER = "1.0.0"
669669- ,[Parameter()] [string] $PIN_EQAF = "0.9"
670670- ,[Parameter()] [string] $PIN_EXTLIB = "1.7.9"
671671- ,[Parameter()] [string] $PIN_EZJSONM = "1.3.0"
672672- ,[Parameter()] [string] $PIN_FEATHER = "0.3.0"
673673- ,[Parameter()] [string] $PIN_FIBER = "3.7.0"
674674- ,[Parameter()] [string] $PIN_FIX = "20230505"
675675- ,[Parameter()] [string] $PIN_FMT = "0.9.0"
676676- ,[Parameter()] [string] $PIN_FPATH = "0.7.3"
677677- ,[Parameter()] [string] $PIN_GRAPHICS = "5.1.2"
678678- ,[Parameter()] [string] $PIN_HEX = "1.5.0"
679679- ,[Parameter()] [string] $PIN_INTEGERS = "0.7.0"
680680- ,[Parameter()] [string] $PIN_JANE_STREET_HEADERS = "v0.16.0"
681681- ,[Parameter()] [string] $PIN_JINGOO = "1.4.4"
682682- ,[Parameter()] [string] $PIN_JSONM = "1.0.2"
683683- ,[Parameter()] [string] $PIN_JSONRPC = "1.16.2"
684684- ,[Parameter()] [string] $PIN_JST_CONFIG = "v0.16.0"
685685- ,[Parameter()] [string] $PIN_LAMBDA_TERM = "3.3.1"
686686- ,[Parameter()] [string] $PIN_LOGS = "0.7.0"
687687- ,[Parameter()] [string] $PIN_LSP = "1.16.2"
688688- ,[Parameter()] [string] $PIN_LWT = "5.6.1"
689689- ,[Parameter()] [string] $PIN_LWT_REACT = "1.2.0"
690690- ,[Parameter()] [string] $PIN_MCCS = "1.1+13"
691691- ,[Parameter()] [string] $PIN_MDX = "2.3.0"
692692- ,[Parameter()] [string] $PIN_MENHIR = "20230608"
693693- ,[Parameter()] [string] $PIN_MENHIRLIB = "20230608"
694694- ,[Parameter()] [string] $PIN_MENHIRSDK = "20230608"
695695- ,[Parameter()] [string] $PIN_MERLIN_LIB = "4.9-414"
696696- ,[Parameter()] [string] $PIN_METAPP = "0.4.4+win"
697697- ,[Parameter()] [string] $PIN_METAQUOT = "0.5.2"
698698- ,[Parameter()] [string] $PIN_MEW = "0.1.0"
699699- ,[Parameter()] [string] $PIN_MEW_VI = "0.5.0"
700700- ,[Parameter()] [string] $PIN_NUM = "1.4"
701701- ,[Parameter()] [string] $PIN_OCAML_COMPILER_LIBS = "v0.12.4"
702702- ,[Parameter()] [string] $PIN_OCAML_LSP_SERVER = "1.16.2"
703703- ,[Parameter()] [string] $PIN_OCAML_VERSION = "3.6.1"
704704- ,[Parameter()] [string] $PIN_OCAML = "4.14.0"
705705- ,[Parameter()] [string] $PIN_OCAMLBUILD = "0.14.2+win+unix"
706706- ,[Parameter()] [string] $PIN_OCAMLC_LOC = "3.8.3"
707707- ,[Parameter()] [string] $PIN_OCAMLFIND = "1.9.5"
708708- ,[Parameter()] [string] $PIN_OCAMLFORMAT_LIB = "0.25.1"
709709- ,[Parameter()] [string] $PIN_OCAMLFORMAT_RPC_LIB = "0.25.1"
710710- ,[Parameter()] [string] $PIN_OCAMLFORMAT = "0.25.1"
711711- ,[Parameter()] [string] $PIN_OCP_INDENT = "1.8.2-windowssupport"
712712- ,[Parameter()] [string] $PIN_OCPLIB_ENDIAN = "1.2"
713713- ,[Parameter()] [string] $PIN_ODOC_PARSER = "2.0.0"
714714- ,[Parameter()] [string] $PIN_ODOC = "2.2.0"
715715- ,[Parameter()] [string] $PIN_ORDERING = "3.8.3"
716716- ,[Parameter()] [string] $PIN_PARSEXP = "v0.16.0"
717717- ,[Parameter()] [string] $PIN_PP = "1.1.2"
718718- ,[Parameter()] [string] $PIN_PPX_ASSERT = "v0.16.0"
719719- ,[Parameter()] [string] $PIN_PPX_BASE = "v0.16.0"
720720- ,[Parameter()] [string] $PIN_PPX_COLD = "v0.16.0"
721721- ,[Parameter()] [string] $PIN_PPX_COMPARE = "v0.16.0"
722722- ,[Parameter()] [string] $PIN_PPX_DERIVERS = "1.2.1"
723723- ,[Parameter()] [string] $PIN_PPX_DERIVING = "5.2.1"
724724- ,[Parameter()] [string] $PIN_PPX_ENUMERATE = "v0.16.0"
725725- ,[Parameter()] [string] $PIN_PPX_EXPECT = "v0.16.0"
726726- ,[Parameter()] [string] $PIN_PPX_GLOBALIZE = "v0.16.0"
727727- ,[Parameter()] [string] $PIN_PPX_HASH = "v0.16.0"
728728- ,[Parameter()] [string] $PIN_PPX_HERE = "v0.16.0"
729729- ,[Parameter()] [string] $PIN_PPX_IGNORE_INSTRUMENTATION = "v0.16.0"
730730- ,[Parameter()] [string] $PIN_PPX_INLINE_TEST = "v0.16.0"
731731- ,[Parameter()] [string] $PIN_PPX_OPTCOMP = "v0.16.0"
732732- ,[Parameter()] [string] $PIN_PPX_PIPEBANG = "v0.16.0"
733733- ,[Parameter()] [string] $PIN_PPX_SEXP_CONV = "v0.16.0"
734734- ,[Parameter()] [string] $PIN_PPX_YOJSON_CONV_LIB = "v0.16.0"
735735- ,[Parameter()] [string] $PIN_PPXLIB = "0.30.0"
736736- ,[Parameter()] [string] $PIN_PTIME = "1.1.0"
737737- ,[Parameter()] [string] $PIN_QRC = "0.1.1~dune"
738738- ,[Parameter()] [string] $PIN_RE = "1.11.0"
739739- ,[Parameter()] [string] $PIN_REACT = "1.2.2"
740740- ,[Parameter()] [string] $PIN_REFL = "0.4.1"
741741- ,[Parameter()] [string] $PIN_RESULT = "1.5"
742742- ,[Parameter()] [string] $PIN_RRESULT = "0.7.0"
743743- ,[Parameter()] [string] $PIN_SEQ = "base"
744744- ,[Parameter()] [string] $PIN_SEXPLIB = "v0.16.0"
745745- ,[Parameter()] [string] $PIN_SEXPLIB0 = "v0.16.0"
746746- ,[Parameter()] [string] $PIN_SHA = "1.15.4"
747747- ,[Parameter()] [string] $PIN_SPAWN = "v0.15.1"
748748- ,[Parameter()] [string] $PIN_SQLITE3 = "5.1.0+msvc"
749749- ,[Parameter()] [string] $PIN_STDCOMPAT = "19+optautoconf"
750750- ,[Parameter()] [string] $PIN_STDIO = "v0.16.0"
751751- ,[Parameter()] [string] $PIN_STDLIB_SHIMS = "0.3.0"
752752- ,[Parameter()] [string] $PIN_STDUNE = "3.8.3"
753753- ,[Parameter()] [string] $PIN_TIME_NOW = "v0.16.0"
754754- ,[Parameter()] [string] $PIN_TOPKG = "1.0.7"
755755- ,[Parameter()] [string] $PIN_TRAVERSE = "0.3.0"
756756- ,[Parameter()] [string] $PIN_TRIE = "1.0.0"
757757- ,[Parameter()] [string] $PIN_TSORT = "2.1.0"
758758- ,[Parameter()] [string] $PIN_TYXML = "4.5.0"
759759- ,[Parameter()] [string] $PIN_UCHAR = "0.0.2"
760760- ,[Parameter()] [string] $PIN_UTOP = "2.13.1"
761761- ,[Parameter()] [string] $PIN_UUCP = "15.0.0"
762762- ,[Parameter()] [string] $PIN_UUIDM = "0.9.8"
763763- ,[Parameter()] [string] $PIN_UUSEG = "15.0.0"
764764- ,[Parameter()] [string] $PIN_UUTF = "1.0.3"
765765- ,[Parameter()] [string] $PIN_WITH_DKML = "2.0.3"
766766- ,[Parameter()] [string] $PIN_XDG = "3.9.0"
767767- ,[Parameter()] [string] $PIN_YOJSON = "2.1.0"
768768- ,[Parameter()] [string] $PIN_ZED = "3.2.2"
769769-)
770770-771771-$ErrorActionPreference = "Stop"
772772-773773-# Reset environment so no conflicts with a parent Opam or OCaml system
774774-if (Test-Path Env:OPAMROOT) { Remove-Item Env:OPAMROOT }
775775-if (Test-Path Env:OPAMSWITCH) { Remove-Item Env:OPAMSWITCH }
776776-if (Test-Path Env:OPAM_SWITCH_PREFIX) { Remove-Item Env:OPAM_SWITCH_PREFIX }
777777-if (Test-Path Env:CAML_LD_LIBRARY_PATH) { Remove-Item Env:CAML_LD_LIBRARY_PATH }
778778-if (Test-Path Env:OCAMLLIB) { Remove-Item Env:OCAMLLIB }
779779-if (Test-Path Env:OCAML_TOPLEVEL_PATH) { Remove-Item Env:OCAML_TOPLEVEL_PATH }
780780-781781-# Pushdown context variables
782782-$env:PC_CI = 'true'
783783-$env:PC_PROJECT_DIR = $PC_PROJECT_DIR
784784-785785-# Pushdown input variables
786786-$env:FDOPEN_OPAMEXE_BOOTSTRAP = $FDOPEN_OPAMEXE_BOOTSTRAP
787787-$env:CACHE_PREFIX = $CACHE_PREFIX
788788-$env:OCAML_COMPILER = $OCAML_COMPILER
789789-$env:DKML_COMPILER = $DKML_COMPILER
790790-$env:SKIP_OPAM_MODIFICATIONS = $SKIP_OPAM_MODIFICATIONS
791791-$env:SECONDARY_SWITCH = $SECONDARY_SWITCH
792792-$env:PRIMARY_SWITCH_SKIP_INSTALL = $PRIMARY_SWITCH_SKIP_INSTALL
793793-$env:CONF_DKML_CROSS_TOOLCHAIN = $CONF_DKML_CROSS_TOOLCHAIN
794794-$env:DISKUV_OPAM_REPOSITORY = $DISKUV_OPAM_REPOSITORY
795795-$env:DKML_HOME = $DKML_HOME
796796-797797-# Set matrix variables
798798-# autogen from pc_vars. only windows_x86_64
799799-$env:dkml_host_os = "windows"
800800-$env:opam_root_cacheable = "${env:PC_PROJECT_DIR}/.ci/o"
801801-$env:abi_pattern = "win32-windows_x86_64"
802802-$env:msys2_system = "CLANG64"
803803-$env:msys2_packages = "mingw-w64-clang-x86_64-pkg-config"
804804-$env:exe_ext = ".exe"
805805-$env:bootstrap_opam_version = "2.2.0-alpha-20221228"
806806-$env:opam_abi = "windows_x86_64"
807807-$env:dkml_host_abi = "windows_x86_64"
808808-$env:opam_root = "${env:PC_PROJECT_DIR}/.ci/o"
809809-$env:vsstudio_hostarch = "x64"
810810-$env:vsstudio_arch = "x64"
811811-812812-813813-# Set environment variables
814814-# autogen from global_env_vars.
815815-$env:DKML_VERSION = $DKML_VERSION
816816-$env:DEFAULT_DISKUV_OPAM_REPOSITORY_TAG = $DEFAULT_DISKUV_OPAM_REPOSITORY_TAG
817817-$env:DEFAULT_DKML_COMPILER = $DEFAULT_DKML_COMPILER
818818-$env:PIN_ASTRING = $PIN_ASTRING
819819-$env:PIN_BASE = $PIN_BASE
820820-$env:PIN_BASE64 = $PIN_BASE64
821821-$env:PIN_BIGARRAY_COMPAT = $PIN_BIGARRAY_COMPAT
822822-$env:PIN_BOS = $PIN_BOS
823823-$env:PIN_CAMLP_STREAMS = $PIN_CAMLP_STREAMS
824824-$env:PIN_CHROME_TRACE = $PIN_CHROME_TRACE
825825-$env:PIN_CMDLINER = $PIN_CMDLINER
826826-$env:PIN_CONF_DKML_SYS_OPAM = $PIN_CONF_DKML_SYS_OPAM
827827-$env:PIN_CONF_PKG_CONFIG = $PIN_CONF_PKG_CONFIG
828828-$env:PIN_CONF_SQLITE3 = $PIN_CONF_SQLITE3
829829-$env:PIN_CPPO = $PIN_CPPO
830830-$env:PIN_CRUNCH = $PIN_CRUNCH
831831-$env:PIN_CSEXP = $PIN_CSEXP
832832-$env:PIN_CSTRUCT = $PIN_CSTRUCT
833833-$env:PIN_CTYPES_FOREIGN = $PIN_CTYPES_FOREIGN
834834-$env:PIN_CTYPES = $PIN_CTYPES
835835-$env:PIN_CUDF = $PIN_CUDF
836836-$env:PIN_DIGESTIF = $PIN_DIGESTIF
837837-$env:PIN_DISKUVBOX = $PIN_DISKUVBOX
838838-$env:PIN_DKML_APPS = $PIN_DKML_APPS
839839-$env:PIN_DKML_BASE_COMPILER = $PIN_DKML_BASE_COMPILER
840840-$env:PIN_DKML_BUILD_DESKTOP = $PIN_DKML_BUILD_DESKTOP
841841-$env:PIN_DKML_C_PROBE = $PIN_DKML_C_PROBE
842842-$env:PIN_DKML_COMPILER_ENV = $PIN_DKML_COMPILER_ENV
843843-$env:PIN_DKML_COMPILER_SRC = $PIN_DKML_COMPILER_SRC
844844-$env:PIN_DKML_COMPONENT_COMMON_DESKTOP = $PIN_DKML_COMPONENT_COMMON_DESKTOP
845845-$env:PIN_DKML_COMPONENT_COMMON_OPAM = $PIN_DKML_COMPONENT_COMMON_OPAM
846846-$env:PIN_DKML_COMPONENT_COMMON_UNIXUTILS = $PIN_DKML_COMPONENT_COMMON_UNIXUTILS
847847-$env:PIN_DKML_COMPONENT_OCAMLCOMPILER_COMMON = $PIN_DKML_COMPONENT_OCAMLCOMPILER_COMMON
848848-$env:PIN_DKML_COMPONENT_OCAMLCOMPILER_NETWORK = $PIN_DKML_COMPONENT_OCAMLCOMPILER_NETWORK
849849-$env:PIN_DKML_COMPONENT_OCAMLCOMPILER_OFFLINE = $PIN_DKML_COMPONENT_OCAMLCOMPILER_OFFLINE
850850-$env:PIN_DKML_COMPONENT_OFFLINE_DESKTOP_FULL = $PIN_DKML_COMPONENT_OFFLINE_DESKTOP_FULL
851851-$env:PIN_DKML_COMPONENT_OFFLINE_OPAMSHIM = $PIN_DKML_COMPONENT_OFFLINE_OPAMSHIM
852852-$env:PIN_DKML_COMPONENT_OFFLINE_UNIXUTILS = $PIN_DKML_COMPONENT_OFFLINE_UNIXUTILS
853853-$env:PIN_DKML_COMPONENT_STAGING_DESKTOP_FULL = $PIN_DKML_COMPONENT_STAGING_DESKTOP_FULL
854854-$env:PIN_DKML_COMPONENT_STAGING_DKMLCONFDIR = $PIN_DKML_COMPONENT_STAGING_DKMLCONFDIR
855855-$env:PIN_DKML_COMPONENT_STAGING_OCAMLRUN = $PIN_DKML_COMPONENT_STAGING_OCAMLRUN
856856-$env:PIN_DKML_COMPONENT_STAGING_OPAM32 = $PIN_DKML_COMPONENT_STAGING_OPAM32
857857-$env:PIN_DKML_COMPONENT_STAGING_OPAM64 = $PIN_DKML_COMPONENT_STAGING_OPAM64
858858-$env:PIN_DKML_COMPONENT_STAGING_UNIXUTILS = $PIN_DKML_COMPONENT_STAGING_UNIXUTILS
859859-$env:PIN_DKML_COMPONENT_STAGING_WITHDKML = $PIN_DKML_COMPONENT_STAGING_WITHDKML
860860-$env:PIN_DKML_COMPONENT_XX_CONSOLE = $PIN_DKML_COMPONENT_XX_CONSOLE
861861-$env:PIN_DKML_EXE_LIB = $PIN_DKML_EXE_LIB
862862-$env:PIN_DKML_EXE = $PIN_DKML_EXE
863863-$env:PIN_DKML_INSTALL_INSTALLER = $PIN_DKML_INSTALL_INSTALLER
864864-$env:PIN_DKML_INSTALL_RUNNER = $PIN_DKML_INSTALL_RUNNER
865865-$env:PIN_DKML_INSTALL = $PIN_DKML_INSTALL
866866-$env:PIN_DKML_INSTALLER_OCAML_COMMON = $PIN_DKML_INSTALLER_OCAML_COMMON
867867-$env:PIN_DKML_INSTALLER_OCAML_OFFLINE = $PIN_DKML_INSTALLER_OCAML_OFFLINE
868868-$env:PIN_DKML_PACKAGE_CONSOLE = $PIN_DKML_PACKAGE_CONSOLE
869869-$env:PIN_DKML_RUNTIME_COMMON_NATIVE = $PIN_DKML_RUNTIME_COMMON_NATIVE
870870-$env:PIN_DKML_RUNTIME_COMMON = $PIN_DKML_RUNTIME_COMMON
871871-$env:PIN_DKML_RUNTIME_DISTRIBUTION = $PIN_DKML_RUNTIME_DISTRIBUTION
872872-$env:PIN_DKML_RUNTIMELIB = $PIN_DKML_RUNTIMELIB
873873-$env:PIN_DKML_RUNTIMESCRIPTS = $PIN_DKML_RUNTIMESCRIPTS
874874-$env:PIN_DKML_WORKFLOWS = $PIN_DKML_WORKFLOWS
875875-$env:PIN_DUNE_ACTION_PLUGIN = $PIN_DUNE_ACTION_PLUGIN
876876-$env:PIN_DUNE_BUILD_INFO = $PIN_DUNE_BUILD_INFO
877877-$env:PIN_DUNE_CONFIGURATOR = $PIN_DUNE_CONFIGURATOR
878878-$env:PIN_DUNE_GLOB = $PIN_DUNE_GLOB
879879-$env:PIN_DUNE_PRIVATE_LIBS = $PIN_DUNE_PRIVATE_LIBS
880880-$env:PIN_DUNE_RPC_LWT = $PIN_DUNE_RPC_LWT
881881-$env:PIN_DUNE_RPC = $PIN_DUNE_RPC
882882-$env:PIN_DUNE_SITE = $PIN_DUNE_SITE
883883-$env:PIN_DUNE = $PIN_DUNE
884884-$env:PIN_DYN = $PIN_DYN
885885-$env:PIN_EITHER = $PIN_EITHER
886886-$env:PIN_EQAF = $PIN_EQAF
887887-$env:PIN_EXTLIB = $PIN_EXTLIB
888888-$env:PIN_EZJSONM = $PIN_EZJSONM
889889-$env:PIN_FEATHER = $PIN_FEATHER
890890-$env:PIN_FIBER = $PIN_FIBER
891891-$env:PIN_FIX = $PIN_FIX
892892-$env:PIN_FMT = $PIN_FMT
893893-$env:PIN_FPATH = $PIN_FPATH
894894-$env:PIN_GRAPHICS = $PIN_GRAPHICS
895895-$env:PIN_HEX = $PIN_HEX
896896-$env:PIN_INTEGERS = $PIN_INTEGERS
897897-$env:PIN_JANE_STREET_HEADERS = $PIN_JANE_STREET_HEADERS
898898-$env:PIN_JINGOO = $PIN_JINGOO
899899-$env:PIN_JSONM = $PIN_JSONM
900900-$env:PIN_JSONRPC = $PIN_JSONRPC
901901-$env:PIN_JST_CONFIG = $PIN_JST_CONFIG
902902-$env:PIN_LAMBDA_TERM = $PIN_LAMBDA_TERM
903903-$env:PIN_LOGS = $PIN_LOGS
904904-$env:PIN_LSP = $PIN_LSP
905905-$env:PIN_LWT = $PIN_LWT
906906-$env:PIN_LWT_REACT = $PIN_LWT_REACT
907907-$env:PIN_MCCS = $PIN_MCCS
908908-$env:PIN_MDX = $PIN_MDX
909909-$env:PIN_MENHIR = $PIN_MENHIR
910910-$env:PIN_MENHIRLIB = $PIN_MENHIRLIB
911911-$env:PIN_MENHIRSDK = $PIN_MENHIRSDK
912912-$env:PIN_MERLIN_LIB = $PIN_MERLIN_LIB
913913-$env:PIN_METAPP = $PIN_METAPP
914914-$env:PIN_METAQUOT = $PIN_METAQUOT
915915-$env:PIN_MEW = $PIN_MEW
916916-$env:PIN_MEW_VI = $PIN_MEW_VI
917917-$env:PIN_NUM = $PIN_NUM
918918-$env:PIN_OCAML_COMPILER_LIBS = $PIN_OCAML_COMPILER_LIBS
919919-$env:PIN_OCAML_LSP_SERVER = $PIN_OCAML_LSP_SERVER
920920-$env:PIN_OCAML_VERSION = $PIN_OCAML_VERSION
921921-$env:PIN_OCAML = $PIN_OCAML
922922-$env:PIN_OCAMLBUILD = $PIN_OCAMLBUILD
923923-$env:PIN_OCAMLC_LOC = $PIN_OCAMLC_LOC
924924-$env:PIN_OCAMLFIND = $PIN_OCAMLFIND
925925-$env:PIN_OCAMLFORMAT_LIB = $PIN_OCAMLFORMAT_LIB
926926-$env:PIN_OCAMLFORMAT_RPC_LIB = $PIN_OCAMLFORMAT_RPC_LIB
927927-$env:PIN_OCAMLFORMAT = $PIN_OCAMLFORMAT
928928-$env:PIN_OCP_INDENT = $PIN_OCP_INDENT
929929-$env:PIN_OCPLIB_ENDIAN = $PIN_OCPLIB_ENDIAN
930930-$env:PIN_ODOC_PARSER = $PIN_ODOC_PARSER
931931-$env:PIN_ODOC = $PIN_ODOC
932932-$env:PIN_ORDERING = $PIN_ORDERING
933933-$env:PIN_PARSEXP = $PIN_PARSEXP
934934-$env:PIN_PP = $PIN_PP
935935-$env:PIN_PPX_ASSERT = $PIN_PPX_ASSERT
936936-$env:PIN_PPX_BASE = $PIN_PPX_BASE
937937-$env:PIN_PPX_COLD = $PIN_PPX_COLD
938938-$env:PIN_PPX_COMPARE = $PIN_PPX_COMPARE
939939-$env:PIN_PPX_DERIVERS = $PIN_PPX_DERIVERS
940940-$env:PIN_PPX_DERIVING = $PIN_PPX_DERIVING
941941-$env:PIN_PPX_ENUMERATE = $PIN_PPX_ENUMERATE
942942-$env:PIN_PPX_EXPECT = $PIN_PPX_EXPECT
943943-$env:PIN_PPX_GLOBALIZE = $PIN_PPX_GLOBALIZE
944944-$env:PIN_PPX_HASH = $PIN_PPX_HASH
945945-$env:PIN_PPX_HERE = $PIN_PPX_HERE
946946-$env:PIN_PPX_IGNORE_INSTRUMENTATION = $PIN_PPX_IGNORE_INSTRUMENTATION
947947-$env:PIN_PPX_INLINE_TEST = $PIN_PPX_INLINE_TEST
948948-$env:PIN_PPX_OPTCOMP = $PIN_PPX_OPTCOMP
949949-$env:PIN_PPX_PIPEBANG = $PIN_PPX_PIPEBANG
950950-$env:PIN_PPX_SEXP_CONV = $PIN_PPX_SEXP_CONV
951951-$env:PIN_PPX_YOJSON_CONV_LIB = $PIN_PPX_YOJSON_CONV_LIB
952952-$env:PIN_PPXLIB = $PIN_PPXLIB
953953-$env:PIN_PTIME = $PIN_PTIME
954954-$env:PIN_QRC = $PIN_QRC
955955-$env:PIN_RE = $PIN_RE
956956-$env:PIN_REACT = $PIN_REACT
957957-$env:PIN_REFL = $PIN_REFL
958958-$env:PIN_RESULT = $PIN_RESULT
959959-$env:PIN_RRESULT = $PIN_RRESULT
960960-$env:PIN_SEQ = $PIN_SEQ
961961-$env:PIN_SEXPLIB = $PIN_SEXPLIB
962962-$env:PIN_SEXPLIB0 = $PIN_SEXPLIB0
963963-$env:PIN_SHA = $PIN_SHA
964964-$env:PIN_SPAWN = $PIN_SPAWN
965965-$env:PIN_SQLITE3 = $PIN_SQLITE3
966966-$env:PIN_STDCOMPAT = $PIN_STDCOMPAT
967967-$env:PIN_STDIO = $PIN_STDIO
968968-$env:PIN_STDLIB_SHIMS = $PIN_STDLIB_SHIMS
969969-$env:PIN_STDUNE = $PIN_STDUNE
970970-$env:PIN_TIME_NOW = $PIN_TIME_NOW
971971-$env:PIN_TOPKG = $PIN_TOPKG
972972-$env:PIN_TRAVERSE = $PIN_TRAVERSE
973973-$env:PIN_TRIE = $PIN_TRIE
974974-$env:PIN_TSORT = $PIN_TSORT
975975-$env:PIN_TYXML = $PIN_TYXML
976976-$env:PIN_UCHAR = $PIN_UCHAR
977977-$env:PIN_UTOP = $PIN_UTOP
978978-$env:PIN_UUCP = $PIN_UUCP
979979-$env:PIN_UUIDM = $PIN_UUIDM
980980-$env:PIN_UUSEG = $PIN_UUSEG
981981-$env:PIN_UUTF = $PIN_UUTF
982982-$env:PIN_WITH_DKML = $PIN_WITH_DKML
983983-$env:PIN_XDG = $PIN_XDG
984984-$env:PIN_YOJSON = $PIN_YOJSON
985985-$env:PIN_ZED = $PIN_ZED
986986-987987-# https://patchwork.kernel.org/project/qemu-devel/patch/20211215073402.144286-17-thuth@redhat.com/
988988-$env:CHERE_INVOKING = "yes" # Preserve the current working directory
989989-$env:MSYSTEM = $env:msys2_system # Start a 64 bit environment if CLANG64, etc.
990990-991991-########################### before_script ###############################
992992-993993-# Troubleshooting
994994-If ( "${env:VERBOSE}" -eq "true" ) { Get-ChildItem 'env:' }
995995-996996-# -----
997997-# MSYS2
998998-# -----
999999-#
10001000-# https://www.msys2.org/docs/ci/
10011001-# https://patchwork.kernel.org/project/qemu-devel/patch/20211215073402.144286-17-thuth@redhat.com/
10021002-10031003-if ( Test-Path -Path msys64\usr\bin\pacman.exe ) {
10041004- Write-Host "Re-using MSYS2 from cache."
10051005-}
10061006-else {
10071007- Write-Host "Download the archive ..."
10081008- If ( !(Test-Path -Path msys64\var\cache ) ) { New-Item msys64\var\cache -ItemType Directory | Out-Null }
10091009- If ( !(Test-Path -Path msys64\var\cache\msys2.exe ) ) { Invoke-WebRequest "https://github.com/msys2/msys2-installer/releases/download/2022-09-04/msys2-base-x86_64-20220904.sfx.exe" -outfile "msys64\var\cache\msys2.exe" }
10101010-10111011- Write-Host "Extract the archive ..."
10121012- msys64\var\cache\msys2.exe -y # Extract to .\msys64
10131013- Remove-Item msys64\var\cache\msys2.exe # Delete the archive again
10141014- ((Get-Content -path msys64\etc\post-install\07-pacman-key.post -Raw) -replace '--refresh-keys', '--version') | Set-Content -Path msys64\etc\post-install\07-pacman-key.post
10151015- msys64\usr\bin\bash -lc "sed -i 's/^CheckSpace/#CheckSpace/g' /etc/pacman.conf"
10161016-10171017- Write-Host "Run for the first time ..."
10181018- msys64\usr\bin\bash -lc ' '
10191019-}
10201020-Write-Host "Update MSYS2 ..."
10211021-msys64\usr\bin\bash -lc 'pacman --noconfirm -Syuu' # Core update (in case any core packages are outdated)
10221022-msys64\usr\bin\bash -lc 'pacman --noconfirm -Syuu' # Normal update
10231023-if ("${env:CI}" -eq "true") { taskkill /F /FI "MODULES eq msys-2.0.dll" } # Only safe to kill MSYS2 in CI
10241024-10251025-Write-Host "Install matrix, required and CI packages ..."
10261026-# Packages for GitLab CI:
10271027-# dos2unix (used to translate PowerShell written files below in this CI .yml into MSYS2 scripts)
10281028-msys64\usr\bin\bash -lc 'set -x; pacman -Sy --noconfirm --needed ${msys2_packages} wget make rsync diffutils patch unzip git tar xz dos2unix'
10291029-10301030-Write-Host "Uninstall MSYS2 conflicting executables ..."
10311031-msys64\usr\bin\bash -lc 'rm -vf /usr/bin/link.exe' # link.exe interferes with MSVC's link.exe
10321032-10331033-Write-Host "Installing VSSetup for the Get-VSSetupInstance function ..."
10341034-Install-Module VSSetup -Scope CurrentUser -Force
10351035-10361036-Write-Host "Writing scripts ..."
10371037-10381038-# POSIX and AWK scripts
10391039-10401040-If ( !(Test-Path -Path.ci\sd4 ) ) { New-Item .ci\sd4 -ItemType Directory | Out-Null }
10411041-10421042-$Content = @'
10431043-#!/bin/sh
10441044-10451045-# ------------------------ Log Formatting ------------------------
10461046-10471047-TXT_SECTION="\e[94m" # bright blue
10481048-TXT_CLEAR="\e[0m"
10491049-10501050-if [ "${GITLAB_CI:-}" = "true" ]; then
10511051- # https://docs.gitlab.com/ee/ci/jobs/#expand-and-collapse-job-log-sections
10521052- print_section_start() {
10531053- print_section_start_NAME=$1
10541054- shift
10551055- printf "\e[0Ksection_start:%s:%s[collapsed=true]\r\e[0K" \
10561056- "$(date +%s)" \
10571057- "$print_section_start_NAME"
10581058- }
10591059- print_section_end() {
10601060- print_section_end_NAME=$1
10611061- shift
10621062- printf "\e[0Ksection_end:%s:%s\r\e[0K\n" \
10631063- "$(date +%s)" \
10641064- "$print_section_end_NAME"
10651065- }
10661066-elif [ -n "${GITHUB_ENV:-}" ]; then
10671067- # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines
10681068- print_section_start() {
10691069- print_section_start_NAME=$1
10701070- shift
10711071- printf "::group::"
10721072- }
10731073- print_section_end() {
10741074- print_section_end_NAME=$1
10751075- shift
10761076- printf "::endgroup::\n"
10771077- }
10781078-else
10791079- print_section_start() {
10801080- print_section_start_NAME=$1
10811081- shift
10821082- }
10831083- print_section_end() {
10841084- print_section_end_NAME=$1
10851085- shift
10861086- }
10871087-fi
10881088-10891089-section_begin() {
10901090- # https://docs.gitlab.com/ee/ci/yaml/script.html#add-color-codes-to-script-output
10911091- section_NAME=$1
10921092- shift
10931093- section_HEADER=$1
10941094- shift
10951095- print_section_start "$section_NAME"
10961096- printf "${TXT_SECTION}%s${TXT_CLEAR}\n" "$section_HEADER"
10971097-}
10981098-10991099-section_end() {
11001100- section_NAME=$1
11011101- shift
11021102- print_section_end "$section_NAME"
11031103-}
11041104-11051105-# ------------------- Other Functions -----------------
11061106-11071107-transfer_dir() {
11081108- transfer_dir_SRC=$1
11091109- shift
11101110- transfer_dir_DST=$1
11111111- shift
11121112- # Remove the destination directory completely, but make sure the parent of the
11131113- # destination directory exists so `mv` will work
11141114- install -d "$transfer_dir_DST"
11151115- rm -rf "$transfer_dir_DST"
11161116- # Move
11171117- mv "$transfer_dir_SRC" "$transfer_dir_DST"
11181118-}
11191119-11201120-# Set TEMP variable which is used, among other things, for OCaml's
11211121-# [Filename.temp_dir_name] on Win32, and by with-dkml.exe on Windows
11221122-export_temp_for_windows() {
11231123- if [ -x /usr/bin/cygpath ]; then
11241124- if [ -n "${RUNNER_TEMP:-}" ]; then
11251125- # GitHub Actions
11261126- TEMP=$(cygpath -am "$RUNNER_TEMP")
11271127- else
11281128- # GitLab CI/CD or desktop
11291129- install -d .ci/tmp
11301130- TEMP=$(cygpath -am ".ci/tmp")
11311131- fi
11321132- export TEMP
11331133- fi
11341134-}
11351135-11361136-# Fixup opam_root on Windows to be mixed case.
11371137-# On input the following variables must be present:
11381138-# - opam_root
11391139-# - opam_root_cacheable
11401140-# On output the input variables will be modified _and_ the
11411141-# following variables will be available:
11421142-# - original_opam_root
11431143-# - original_opam_root_cacheable
11441144-# - unix_opam_root
11451145-# - unix_opam_root_cacheable
11461146-fixup_opam_root() {
11471147- # shellcheck disable=SC2034
11481148- original_opam_root=$opam_root
11491149- # shellcheck disable=SC2034
11501150- original_opam_root_cacheable=$opam_root_cacheable
11511151- if [ -x /usr/bin/cygpath ]; then
11521152- opam_root=$(/usr/bin/cygpath -m "$opam_root")
11531153- opam_root_cacheable=$(/usr/bin/cygpath -m "$opam_root_cacheable")
11541154- unix_opam_root=$(/usr/bin/cygpath -u "$opam_root")
11551155- unix_opam_root_cacheable=$(/usr/bin/cygpath -u "$opam_root_cacheable")
11561156- else
11571157- # shellcheck disable=SC2034
11581158- unix_opam_root=$opam_root
11591159- # shellcheck disable=SC2034
11601160- unix_opam_root_cacheable=$opam_root_cacheable
11611161- fi
11621162-}
11631163-'@
11641164-Set-Content -Path ".ci\sd4\common-values.sh" -Encoding Unicode -Value $Content
11651165-msys64\usr\bin\bash -lc 'dos2unix .ci/sd4/common-values.sh'
11661166-11671167-11681168-$Content = @'
11691169-#!/bin/sh
11701170-11711171-# ================
11721172-# checkout-code.sh
11731173-# ================
11741174-#
11751175-# Checkouts all of the git source code.
11761176-#
11771177-# This should be done outside of
11781178-# dockcross (used by Linux) since a Docker-in-Docker container can have
11791179-# difficulties doing a git checkout (the Git credentials for any private
11801180-# repositories are likely not present). We don't care about any private
11811181-# repositories for DKML but any code that extends this (ex. DKSDK) may
11821182-# need to use private repositories.
11831183-11841184-set -euf
11851185-11861186-setup_WORKSPACE_VARNAME=$1
11871187-shift
11881188-setup_WORKSPACE=$1
11891189-shift
11901190-11911191-if [ -x /usr/bin/cygpath ]; then
11921192- setup_WORKSPACE=$(/usr/bin/cygpath -au "$setup_WORKSPACE")
11931193-fi
11941194-11951195-# ------------------------ Functions ------------------------
11961196-11971197-# shellcheck source=./common-values.sh
11981198-. .ci/sd4/common-values.sh
11991199-12001200-# Disable automatic garbage collection
12011201-git_disable_gc() {
12021202- git_disable_gc_NAME=$1
12031203- shift
12041204- git -C ".ci/sd4/g/$git_disable_gc_NAME" config --local gc.auto 0
12051205-}
12061206-12071207-# Mimic the behavior of GitHub's actions/checkout@v3
12081208-# - the plus symbol in 'git fetch ... origin +REF:refs/tags/v0.0' overrides any existing REF
12091209-git_checkout() {
12101210- git_checkout_NAME=$1
12111211- shift
12121212- git_checkout_URL=$1
12131213- shift
12141214- git_checkout_REF=$1
12151215- shift
12161216-12171217- if [ -e ".ci/sd4/g/$git_checkout_NAME" ]; then
12181218- git_disable_gc "$git_checkout_NAME"
12191219- git -C ".ci/sd4/g/$git_checkout_NAME" remote set-url origin "$git_checkout_URL"
12201220- git -C ".ci/sd4/g/$git_checkout_NAME" fetch --no-tags --progress --no-recurse-submodules --depth=1 origin "+${git_checkout_REF}:refs/tags/v0.0"
12211221- else
12221222- install -d ".ci/sd4/g/$git_checkout_NAME"
12231223- git -C ".ci/sd4/g/$git_checkout_NAME" -c init.defaultBranch=main init
12241224- git_disable_gc "$git_checkout_NAME"
12251225- git -C ".ci/sd4/g/$git_checkout_NAME" remote add origin "$git_checkout_URL"
12261226- git -C ".ci/sd4/g/$git_checkout_NAME" fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin "+${git_checkout_REF}:refs/tags/v0.0"
12271227- fi
12281228- git -C ".ci/sd4/g/$git_checkout_NAME" -c advice.detachedHead=false checkout --progress --force refs/tags/v0.0
12291229- git -C ".ci/sd4/g/$git_checkout_NAME" log -1 --format='%H'
12301230-}
12311231-12321232-# ---------------------------------------------------------------------
12331233-12341234-section_begin checkout-info "Summary: code checkout"
12351235-12361236-# shellcheck disable=SC2154
12371237-echo "
12381238-================
12391239-checkout-code.sh
12401240-================
12411241-.
12421242----------
12431243-Arguments
12441244----------
12451245-WORKSPACE_VARNAME=$setup_WORKSPACE_VARNAME
12461246-WORKSPACE=$setup_WORKSPACE
12471247-.
12481248-------
12491249-Inputs
12501250-------
12511251-VERBOSE=${VERBOSE:-}
12521252-.
12531253-------
12541254-Matrix
12551255-------
12561256-dkml_host_abi=$dkml_host_abi
12571257-.
12581258-"
12591259-12601260-section_end checkout-info
12611261-12621262-install -d .ci/sd4/g
12631263-12641264-# dkml-runtime-distribution
12651265-12661266-# For 'Diagnose Visual Studio environment variables (Windows)' we need dkml-runtime-distribution
12671267-# so that 'Import-Module Machine' and 'Get-VSSetupInstance' can be run.
12681268-# The version doesn't matter too much, as long as it has a functioning Get-VSSetupInstance
12691269-# that supports the Visual Studio versions of the latest GitLab CI and GitHub Actions machines.
12701270-# commit 4d6f1bfc3510c55ba4273cb240e43727854b5718 = WinSDK 19041 and VS 14.29
12711271-case "$dkml_host_abi" in
12721272-windows_*)
12731273- section_begin checkout-dkml-runtime-distribution 'Checkout dkml-runtime-distribution'
12741274- git_checkout dkml-runtime-distribution https://github.com/diskuv/dkml-runtime-distribution.git "4d6f1bfc3510c55ba4273cb240e43727854b5718"
12751275- section_end checkout-dkml-runtime-distribution
12761276- ;;
12771277-esac
12781278-12791279-'@
12801280-Set-Content -Path ".ci\sd4\run-checkout-code.sh" -Encoding Unicode -Value $Content
12811281-msys64\usr\bin\bash -lc 'dos2unix .ci/sd4/run-checkout-code.sh'
12821282-12831283-12841284-$Content = @'
12851285-#!/bin/sh
12861286-set -euf
12871287-12881288-# Constants
12891289-SHA512_DEVNULL='cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e'
12901290-12911291-setup_WORKSPACE_VARNAME=$1
12921292-shift
12931293-setup_WORKSPACE=$1
12941294-shift
12951295-12961296-if [ -x /usr/bin/cygpath ]; then
12971297- setup_WORKSPACE=$(/usr/bin/cygpath -au "$setup_WORKSPACE")
12981298-fi
12991299-13001300-# ------------------ Variables and functions ------------------------
13011301-13021302-# shellcheck source=./common-values.sh
13031303-. .ci/sd4/common-values.sh
13041304-13051305-if [ "${VERBOSE:-}" = "true" ]; then
13061306- do_tar_rf() {
13071307- tar rvf "$@"
13081308- }
13091309-else
13101310- do_tar_rf() {
13111311- tar rf "$@"
13121312- }
13131313-fi
13141314-13151315-# Make the standard input work as an OCaml string.
13161316-# This currently only escapes backslashes and double quotes.
13171317-escape_arg_as_ocaml_string() {
13181318- escape_arg_as_ocaml_string_ARG=$1
13191319- shift
13201320- printf "%s" "$escape_arg_as_ocaml_string_ARG" | sed 's#\\#\\\\#g; s#"#\\"#g;'
13211321-}
13221322-13231323-# Fixup opam_root on Windows to be mixed case. Set original_* and unix_* as well.
13241324-fixup_opam_root
13251325-13261326-# Set TEMP variable for Windows
13271327-export_temp_for_windows
13281328-13291329-# Load VS studio environment
13301330-if [ -e .ci/sd4/vsenv.sh ]; then
13311331- # shellcheck disable=SC1091
13321332- . .ci/sd4/vsenv.sh
13331333-fi
13341334-13351335-# -------------------------------------------------------------------
13361336-13371337-section_begin setup-info "Summary: setup-dkml"
13381338-13391339-SKIP_OPAM_MODIFICATIONS=${SKIP_OPAM_MODIFICATIONS:-false} # default is false
13401340-13411341-# shellcheck disable=SC2154
13421342-echo "
13431343-=============
13441344-setup-dkml.sh
13451345-=============
13461346-.
13471347----------
13481348-Arguments
13491349----------
13501350-WORKSPACE_VARNAME=$setup_WORKSPACE_VARNAME
13511351-WORKSPACE=$setup_WORKSPACE
13521352-.
13531353-------
13541354-Inputs
13551355-------
13561356-FDOPEN_OPAMEXE_BOOTSTRAP=${FDOPEN_OPAMEXE_BOOTSTRAP:-}
13571357-DISKUV_OPAM_REPOSITORY=${DISKUV_OPAM_REPOSITORY:-}
13581358-DKML_COMPILER=${DKML_COMPILER:-}
13591359-OCAML_COMPILER=${OCAML_COMPILER:-}
13601360-CONF_DKML_CROSS_TOOLCHAIN=${CONF_DKML_CROSS_TOOLCHAIN:-}
13611361-SKIP_OPAM_MODIFICATIONS=${SKIP_OPAM_MODIFICATIONS:-}
13621362-SECONDARY_SWITCH=${SECONDARY_SWITCH:-}
13631363-PRIMARY_SWITCH_SKIP_INSTALL=${PRIMARY_SWITCH_SKIP_INSTALL:-}
13641364-MANYLINUX=${MANYLINUX:-}
13651365-DKML_HOME=${DKML_HOME:-}
13661366-VERBOSE=${VERBOSE:-}
13671367-.
13681368--------------------
13691369-Generated Constants
13701370--------------------
13711371-DKML_VERSION=$DKML_VERSION
13721372-DEFAULT_DISKUV_OPAM_REPOSITORY_TAG=$DEFAULT_DISKUV_OPAM_REPOSITORY_TAG
13731373-DEFAULT_DKML_COMPILER=$DEFAULT_DKML_COMPILER
13741374-.
13751375-------
13761376-Matrix
13771377-------
13781378-dkml_host_abi=$dkml_host_abi
13791379-bootstrap_opam_version=$bootstrap_opam_version
13801380-abi_pattern=$abi_pattern
13811381-opam_root=${opam_root}
13821382-opam_root_cacheable=${opam_root_cacheable}
13831383-original_opam_root=${original_opam_root}
13841384-original_opam_root_cacheable=${original_opam_root_cacheable}
13851385-unix_opam_root=${unix_opam_root}
13861386-unix_opam_root_cacheable=${unix_opam_root_cacheable}
13871387-dockcross_image=${dockcross_image:-}
13881388-dockcross_image_custom_prefix=${dockcross_image_custom_prefix:-}
13891389-dockcross_run_extra_args=${dockcross_run_extra_args:-}
13901390-docker_runner=${docker_runner:-}
13911391-in_docker=${in_docker:-}
13921392-ocaml_options=${ocaml_options:-}
13931393-.
13941394-----
13951395-Pins
13961396-----
13971397-"
13981398-set | grep ^PIN_
13991399-echo ".
14001400-"
14011401-case "$dkml_host_abi" in
14021402-windows_*)
14031403- # shellcheck disable=SC2153
14041404- echo "
14051405--------------
14061406-Visual Studio
14071407--------------
14081408-VS_DIR=$VS_DIR
14091409-VS_VCVARSVER=$VS_VCVARSVER
14101410-VS_WINSDKVER=$VS_WINSDKVER
14111411-VS_MSVSPREFERENCE=$VS_MSVSPREFERENCE
14121412-VS_CMAKEGENERATOR=$VS_CMAKEGENERATOR
14131413-.
14141414-"
14151415- ;;
14161416-esac
14171417-section_end setup-info
14181418-14191419-do_bootstrap() {
14201420- # Bootstrap from historical release
14211421- runit_BOOTSTRAPPED=0
14221422-14231423- # Bootstrap opam from fdopen (Windows)
14241424- if [ "$runit_BOOTSTRAPPED" = 0 ] && [ "${FDOPEN_OPAMEXE_BOOTSTRAP:-}" = "true" ]; then
14251425- if [ -e .ci/sd4/opam64/bin/opam.exe ] && [ -e .ci/sd4/opam64/bin/opam-installer.exe ]; then
14261426- runit_BOOTSTRAPPED=1
14271427- else
14281428- case "$dkml_host_abi" in
14291429- windows_*)
14301430- echo 'Bootstrap opam from fdopen (Windows) ...'
14311431- install -d .ci/sd4/bs/bin
14321432- wget -O "$setup_WORKSPACE"/.ci/sd4/opam64.tar.xz https://github.com/fdopen/opam-repository-mingw/releases/download/0.0.0.2/opam64.tar.xz
14331433-14341434- # this stalls: tar xvCfJ "$setup_WORKSPACE"/.ci/sd4 "$setup_WORKSPACE"/.ci/sd4/opam64.tar.xz
14351435- xz -v -d "$setup_WORKSPACE"/.ci/sd4/opam64.tar.xz
14361436- tar xvCf .ci/sd4 .ci/sd4/opam64.tar
14371437-14381438- rm -rf "$setup_WORKSPACE"/.ci/sd4/bs/bin/Opam.Runtime.amd64
14391439- mv -v "$setup_WORKSPACE"/.ci/sd4/opam64/bin/Opam.Runtime.amd64/ "$setup_WORKSPACE"/.ci/sd4/bs/bin/
14401440- mv -v "$setup_WORKSPACE"/.ci/sd4/opam64/bin/opam.exe "$setup_WORKSPACE"/.ci/sd4/bs/bin/
14411441- mv -v "$setup_WORKSPACE"/.ci/sd4/opam64/bin/opam-installer.exe "$setup_WORKSPACE"/.ci/sd4/bs/bin/
14421442-14431443- # diagnostics
14441444- ldd "$setup_WORKSPACE"/.ci/sd4/bs/bin/opam.exe
14451445- ldd "$setup_WORKSPACE"/.ci/sd4/bs/bin/opam-installer.exe
14461446-14471447- runit_BOOTSTRAPPED=1
14481448- ;;
14491449- esac
14501450- fi
14511451- fi
14521452-14531453- # Bootstrap from historical release
14541454- if [ "$runit_BOOTSTRAPPED" = 0 ] && [ "$bootstrap_opam_version" != "os" ]; then
14551455- install -d .ci/sd4/bs
14561456- cd .ci/sd4/bs
14571457-14581458- if [ ! -e version ] || [ "$(cat version)" != "$bootstrap_opam_version" ]; then
14591459- echo 'Bootstrap opam from historical release (non-Windows; Windows non-fdopen) ...'
14601460- if command -v curl > /dev/null 2> /dev/null; then
14611461- curl -L -o opam.tar.gz "https://github.com/diskuv/dkml-component-opam/releases/download/v${bootstrap_opam_version}/dkml-component-staging-opam.tar.gz"
14621462- else
14631463- wget -O opam.tar.gz "https://github.com/diskuv/dkml-component-opam/releases/download/v${bootstrap_opam_version}/dkml-component-staging-opam.tar.gz"
14641464- fi
14651465- tar tvfz opam.tar.gz
14661466- tar xfz opam.tar.gz "./staging-files/${dkml_host_abi}/"
14671467- rm -rf bin/
14681468- mv "staging-files/${dkml_host_abi}/bin" .
14691469- rm -rf "${abi_pattern}"
14701470- printf "%s" "${bootstrap_opam_version}" >version
14711471- fi
14721472-14731473- rm -f opam.tar.gz
14741474- cd ../../..
14751475-14761476- runit_BOOTSTRAPPED=1
14771477- fi
14781478-14791479- # Bootstrap from package manager or GitHub ocaml/opam release
14801480- case "$runit_BOOTSTRAPPED,$bootstrap_opam_version,$dkml_host_abi" in
14811481- 0,os,darwin_*)
14821482- if ! command -v opam; then
14831483- echo 'Bootstrap opam from package manager (macOS) ...'
14841484- brew install gpatch
14851485- brew install opam
14861486- fi
14871487- runit_BOOTSTRAPPED=1
14881488- ;;
14891489- 0,os,linux_x86)
14901490- if [ ! -x .ci/sd4/bs/bin/opam ]; then
14911491- echo 'Bootstrap opam from GitHub ocaml/opam release (Linux x86) ...'
14921492- install -d .ci/sd4/bs/bin
14931493- if command -v curl > /dev/null 2> /dev/null; then
14941494- curl -L -o .ci/sd4/bs/bin/opam.tmp https://github.com/ocaml/opam/releases/download/2.1.2/opam-2.1.2-i686-linux
14951495- else
14961496- wget -O .ci/sd4/bs/bin/opam.tmp https://github.com/ocaml/opam/releases/download/2.1.2/opam-2.1.2-i686-linux
14971497- fi
14981498- sha512_check=$(openssl sha512 2>&1 </dev/null | cut -f 2 -d ' ')
14991499- if [ "$SHA512_DEVNULL" = "$sha512_check" ]; then
15001500- sha512=$(openssl sha512 ".ci/sd4/bs/bin/opam.tmp" 2>/dev/null | cut -f 2 -d ' ')
15011501- check="85a480d60e09a7d37fa0d0434ed97a3187434772ceb4e7e8faa5b06bc18423d004af3ad5849c7d35e72dca155103257fd6b1178872df8291583929eb8f884b6a"
15021502- test "$sha512" = "$check"
15031503- chmod +x .ci/sd4/bs/bin/opam.tmp
15041504- mv .ci/sd4/bs/bin/opam.tmp .ci/sd4/bs/bin/opam
15051505- else
15061506- echo "openssl 512 option unsupported."
15071507- exit 61
15081508- fi
15091509- fi
15101510- runit_BOOTSTRAPPED=1
15111511- ;;
15121512- 0,os,linux_x86_64)
15131513- if [ ! -x .ci/sd4/bs/bin/opam ]; then
15141514- echo 'Bootstrap opam from GitHub ocaml/opam release (Linux x86_64) ...'
15151515- install -d .ci/sd4/bs/bin
15161516- if command -v curl > /dev/null 2> /dev/null; then
15171517- curl -L -o .ci/sd4/bs/bin/opam.tmp https://github.com/ocaml/opam/releases/download/2.1.2/opam-2.1.2-x86_64-linux
15181518- else
15191519- wget -O .ci/sd4/bs/bin/opam.tmp https://github.com/ocaml/opam/releases/download/2.1.2/opam-2.1.2-x86_64-linux
15201520- fi
15211521- sha512_check=$(openssl sha512 2>&1 </dev/null | cut -f 2 -d ' ')
15221522- if [ "$SHA512_DEVNULL" = "$sha512_check" ]; then
15231523- sha512=$(openssl sha512 ".ci/sd4/bs/bin/opam.tmp" 2>/dev/null | cut -f 2 -d ' ')
15241524- check="c0657ecbd4dc212587a4da70c5ff0402df95d148867be0e1eb1be8863a2851015f191437c3c99b7c2b153fcaa56cac99169c76ec94c5787750d7a59cd1fbb68b"
15251525- test "$sha512" = "$check"
15261526- chmod +x .ci/sd4/bs/bin/opam.tmp
15271527- mv .ci/sd4/bs/bin/opam.tmp .ci/sd4/bs/bin/opam
15281528- else
15291529- echo "openssl 512 option unsupported."
15301530- exit 61
15311531- fi
15321532- fi
15331533- runit_BOOTSTRAPPED=1
15341534- ;;
15351535- esac
15361536-}
15371537-section_begin bootstrap-opam 'Bootstrap opam'
15381538-do_bootstrap
15391539-section_end bootstrap-opam
15401540-15411541-# Start environment distribution tarball
15421542-# We use .tar rather than .tar.gz/.tar.bz2 because we can repeatedly add to an uncompressed .tar. But we need to
15431543-# start with an empty tarball since some tar programs will only add ('tar rf xyz.tar') to an existing .tar.
15441544-install -d .ci/sd4/dist
15451545-tar cf .ci/sd4/dist/run-with-env.tar -T /dev/null
15461546-15471547-do_get_dockcross() {
15481548- if [ -n "${dockcross_image:-}" ]; then
15491549- # The dockcross script is super-slow
15501550- section_begin get-dockcross 'Get dockcross binary (ManyLinux)'
15511551- install -d .ci/sd4
15521552- # shellcheck disable=SC2086
15531553- docker run ${dockcross_run_extra_args:-} --rm "${dockcross_image_custom_prefix:-}${dockcross_image:-}" >.ci/sd4/dockcross.gen
15541554-15551555- # PROBLEM 1
15561556- # ---------
15571557- # Super-annoying stderr output from dockcross at line:
15581558- # tty -s && [ -z "$MSYS" ] && TTY_ARGS=-ti
15591559- # When there is no tty, get:
15601560- # tty: ignoring all arguments
15611561- # not a tty
15621562- # So replace 'tty -s &&' with 'false &&'
15631563- sed 's/tty -s &&/false \&\&/' .ci/sd4/dockcross.gen >.ci/sd4/dockcross-real
15641564- rm -f .ci/sd4/dockcross.gen
15651565- chmod +x .ci/sd4/dockcross-real
15661566-15671567- # PROBLEM 2
15681568- # ---------
15691569- # By default dockcross for ManyLinux will chown -R all python packages; super-slow (~10 seconds)!
15701570- # Confer: https://github.com/dockcross/dockcross/blob/master/manylinux-common/pre_exec.sh
15711571- # That kills speed for any repetitive dockcross invocation.
15721572- #
15731573- # BUT it is unnecessary to chown -R when the current user is root, because inside the Docker container
15741574- # the files are already root!
15751575- #
15761576- # The chown -R (within pre_exec.sh) is not run when the user ids are not passed in.
15771577- # Confer: https://github.com/dockcross/dockcross/blob/96d87416f639af0204bdd42553e4b99315ca8476/imagefiles/entrypoint.sh#L21-L53
15781578- #
15791579- # So explicitly call the entrypoint if root!
15801580- if echo "${dockcross_run_extra_args:-}" | grep -q linux/386; then
15811581- # https://github.com/dockcross/dockcross/blob/master/linux-x86/linux32-entrypoint.sh
15821582- # But only when `--platform linux/386` because the container image may be overridden.
15831583- dockcross_entrypoint=/dockcross/linux32-entrypoint.sh
15841584- else
15851585- dockcross_entrypoint=/dockcross/entrypoint.sh
15861586- fi
15871587- cat > .ci/sd4/dockcross <<EOF
15881588-#!/bin/bash
15891589-set -euf
15901590-BUILDER_UID="\$( id -u )"
15911591-BUILDER_GID="\$( id -g )"
15921592-if [ "\$BUILDER_UID" = 0 ] && [ "\$BUILDER_GID" = 0 ]; then
15931593- # ---------- Start of dockcross script snippet -------
15941594- # Verbatim from
15951595- # https://github.com/dockcross/dockcross/blob/96d87416f639af0204bdd42553e4b99315ca8476/imagefiles/dockcross#L175-L204
15961596- # except 1) disabling of USER_IDS
15971597-15981598- # Bash on Ubuntu on Windows
15991599- UBUNTU_ON_WINDOWS=\$([ -e /proc/version ] && grep -l Microsoft /proc/version || echo "")
16001600- # MSYS, Git Bash, etc.
16011601- MSYS=\$([ -e /proc/version ] && grep -l MINGW /proc/version || echo "")
16021602- # CYGWIN
16031603- CYGWIN=\$([ -e /proc/version ] && grep -l CYGWIN /proc/version || echo "")
16041604-16051605- #if [ -z "\$UBUNTU_ON_WINDOWS" -a -z "\$MSYS" -a "\$OCI_EXE" != "podman" ]; then
16061606- # USER_IDS=(-e BUILDER_UID="\$( id -u )" -e BUILDER_GID="\$( id -g )" -e BUILDER_USER="\$( id -un )" -e BUILDER_GROUP="\$( id -gn )")
16071607- #fi
16081608-16091609- # Change the PWD when working in Docker on Windows
16101610- if [ -n "\$UBUNTU_ON_WINDOWS" ]; then
16111611- WSL_ROOT="/mnt/"
16121612- CFG_FILE=/etc/wsl.conf
16131613- if [ -f "\$CFG_FILE" ]; then
16141614- CFG_CONTENT=\$(cat \$CFG_FILE | sed -r '/[^=]+=[^=]+/!d' | sed -r 's/\s+=\s/=/g')
16151615- eval "\$CFG_CONTENT"
16161616- if [ -n "\$root" ]; then
16171617- WSL_ROOT=\$root
16181618- fi
16191619- fi
16201620- HOST_PWD=\`pwd -P\`
16211621- HOST_PWD=\${HOST_PWD/\$WSL_ROOT//}
16221622- elif [ -n "\$MSYS" ]; then
16231623- HOST_PWD=\$PWD
16241624- HOST_PWD=\${HOST_PWD/\//}
16251625- HOST_PWD=\${HOST_PWD/\//:\/}
16261626- elif [ -n "\$CYGWIN" ]; then
16271627- for f in pwd readlink cygpath ; do
16281628- test -n "\$(type "\${f}" )" || { echo >&2 "Missing functionality (\${f}) (in cygwin)." ; exit 1 ; } ;
16291629- done ;
16301630- HOST_PWD="\$( cygpath -w "\$( readlink -f "\$( pwd ;)" ; )" ; )" ;
16311631- else
16321632- HOST_PWD=\$PWD
16331633- [ -L \$HOST_PWD ] && HOST_PWD=\$(readlink \$HOST_PWD)
16341634- fi
16351635-16361636- # ---------- End of dockcross script snippet -------
16371637-16381638- # Handle: dockcross --args "-v X:Y --platform P"
16391639- ARGS=
16401640- if [ "\$#" -ge 1 ] && [ "\$1" = "--args" ]; then
16411641- shift
16421642- ARGS=\$1
16431643- shift
16441644- fi
16451645-16461646- # Directly invoke entrypoint
16471647- exec docker run --entrypoint /bin/bash \
16481648- --rm \
16491649- \${ARGS:-} \
16501650- -v "\$HOST_PWD":/work \
16511651- ${dockcross_image_custom_prefix:-}${dockcross_image:-} ${dockcross_entrypoint} "\$@"
16521652-else
16531653- HERE=\$(dirname "\$0")
16541654- HERE=\$(cd "\$HERE" && pwd)
16551655- exec "\$HERE/dockcross-real" "\$@"
16561656-fi
16571657-EOF
16581658- chmod +x .ci/sd4/dockcross
16591659-16601660- # Bundle for consumers of setup-dkml.yml
16611661- do_tar_rf .ci/sd4/dist/run-with-env.tar .ci/sd4/dockcross .ci/sd4/dockcross-real
16621662-16631663- section_end get-dockcross
16641664- fi
16651665-}
16661666-do_get_dockcross
16671667-16681668-if [ -n "${dockcross_image:-}" ]; then
16691669- # rsync needs to be available, even after Docker container disappears
16701670- if [ ! -e .ci/sd4/bs/bin/rsync ]; then
16711671- section_begin get-opam-prereqs-in-dockcross 'Get Opam prerequisites (ManyLinux)'
16721672- install -d .ci/sd4/bs/bin
16731673- # Install rsync with 'yum' (ManyLinux) or 'apt' (dockcross/linux-x64, etc.)
16741674- # if not present.
16751675- # shellcheck disable=SC2016
16761676- .ci/sd4/dockcross --args "${dockcross_run_extra_args:-}" sh -c 'if ! command -v rsync; then if command -v yum; then sudo yum install -y rsync; else sudo apt-get install -qq -o=Dpkg::Use-Pty=0 -y rsync; fi; fi && install $(command -v rsync) .ci/sd4/bs/bin'
16771677- section_end get-opam-prereqs-in-dockcross
16781678- fi
16791679-fi
16801680-16811681-# Opam prerequisites for using opam (not for installing opam)
16821682-16831683-{
16841684- if [ -n "${docker_runner:-}" ]; then
16851685- # rsync needs to be available, even after Docker container disappears
16861686- if [ ! -e .ci/sd4/bs/bin/rsync.deps ]; then
16871687- section_begin get-opam-prereqs-in-docker 'Get Opam prerequisites (Linux Docker)'
16881688- install -d .ci/sd4/bs/bin
16891689- ${docker_runner} sh -c '
16901690- apt-get update -qq -o=Dpkg::Use-Pty=0 &&
16911691- apt-get install -qq -o=Dpkg::Use-Pty=0 -y rsync &&
16921692- ldd /usr/bin/rsync &&
16931693- ls -l /lib/i386-linux-gnu/libpopt.so.0 /lib/i386-linux-gnu/libacl.so.1 /lib/i386-linux-gnu/libattr.so.1 &&
16941694- tar cCfhz / /work/.ci/sd4/bs/bin/deps.tar.gz /usr/bin/rsync /lib/i386-linux-gnu/libpopt.so.0
16951695- '
16961696- touch .ci/sd4/bs/bin/rsync.deps
16971697- section_end get-opam-prereqs-in-docker
16981698- fi
16991699- fi
17001700-17011701- # Bundle Opam prerequisites (ManyLinux or Linux Docker)
17021702- if [ -n "${docker_runner:-}" ] || [ -n "${dockcross_image:-}" ]; then
17031703- # Bundle for consumers of setup-dkml.yml
17041704- do_tar_rf .ci/sd4/dist/run-with-env.tar .ci/sd4/bs/bin/rsync
17051705- fi
17061706-}
17071707-17081708-# Get Opam Cache
17091709-do_get_opam_cache() {
17101710- if [ "$unix_opam_root_cacheable" = "$unix_opam_root" ]; then return; fi
17111711- if [ ! -e "$unix_opam_root_cacheable" ]; then return; fi
17121712- section_begin get-opam-cache "Transferring Opam cache to $original_opam_root_cacheable"
17131713- echo Starting transfer # need some output or GitLab CI will not display the section duration
17141714- transfer_dir "$unix_opam_root_cacheable" "$unix_opam_root"
17151715- echo Finished transfer
17161716- section_end get-opam-cache
17171717-}
17181718-do_get_opam_cache
17191719-17201720-# Setup Opam
17211721-17221722-do_write_opam_scripts() {
17231723- case "${FDOPEN_OPAMEXE_BOOTSTRAP:-},$dkml_host_abi" in
17241724- true,windows_*)
17251725- # With fdopen's opam.exe, 'os-distribution = "cygwinports"'. But native Windows opam.exe has 'os-distribution = "win32"'.
17261726- # But on Windows we always want MSYS2 or native Windows libraries, not Cygwin. If cygwinports then
17271727- # code like https://github.com/ocaml/opam-repository/blob/08cbb8258bd4bf30cd6f307c958911a29d537b54/packages/conf-pkg-config/conf-pkg-config.2/opam#L36
17281728- # will fail. So always set 'os-distribution = "win32"' on Windows.
17291729- PATCH_OS_DISTRIBUTION_WIN32=true
17301730- # With fdopen's opam.exe, no 'exe = ".exe"' is set because Cygwin does not need file extensions.
17311731- # Native Windows requires a .exe extension.
17321732- PATCH_EXE_WIN32=true
17331733- ;;
17341734- *)
17351735- PATCH_OS_DISTRIBUTION_WIN32=false
17361736- PATCH_EXE_WIN32=false
17371737- ;;
17381738- esac
17391739-17401740- # ---------------------
17411741- # Empty opam repository
17421742- # ---------------------
17431743-17441744- install -d .ci/sd4/eor
17451745- cat >.ci/sd4/eor/repo <<EOF
17461746-opam-version: "2.0"
17471747-browse: "https://opam.ocaml.org/pkg/"
17481748-upstream: "https://github.com/ocaml/opam-repository/tree/master/"
17491749-EOF
17501750-17511751- # ---------------
17521752- # Create Opam troubleshooting script
17531753- # Dump logs modified within the last 4 hours
17541754- # ---------------
17551755-17561756- cat >.ci/sd4/troubleshoot-opam.sh <<EOF
17571757-#!/bin/sh
17581758-set -euf
17591759-OPAMROOT=\$1
17601760-shift
17611761-if find . -maxdepth 0 -mmin -240 2>/dev/null >/dev/null; then
17621762- FINDARGS="-mmin -240" # is -mmin supported? BSD (incl. macOS), MSYS2, GNU
17631763-else
17641764- FINDARGS="-mtime -1" # use 1 day instead. Solaris
17651765-fi
17661766-printf "\n\n========= [START OF TROUBLESHOOTING] ===========\n\n" >&2
17671767-find "\$OPAMROOT"/log -mindepth 1 -maxdepth 1 \$FINDARGS -name "*.out" ! -name "log-*.out" ! -name "ocaml-variants-*.out" | while read -r dump_on_error_LOG; do
17681768- dump_on_error_BLOG=\$(basename "\$dump_on_error_LOG")
17691769- printf "\n\n========= [TROUBLESHOOTING] %s ===========\n\n" "\$dump_on_error_BLOG" >&2
17701770- awk -v BLOG="\$dump_on_error_BLOG" '{print "[" BLOG "]", \$0}' "\$dump_on_error_LOG" >&2
17711771-done
17721772-printf "\nScroll up to see the [TROUBLESHOOTING] logs that begin at the [START OF TROUBLESHOOTING] line\n" >&2
17731773-EOF
17741774-17751775- chmod +x .ci/sd4/troubleshoot-opam.sh
17761776- do_tar_rf .ci/sd4/dist/run-with-env.tar .ci/sd4/troubleshoot-opam.sh
17771777-17781778- # ---------------
17791779- # Create Opam support scripts (not needed for all platforms)
17801780- # The PATH to find opam must work internally in setup-dkml.yml (sd4/bs/bin) and
17811781- # by consumers of setup-dkml.yml (sd4/opamexe)
17821782- # ---------------
17831783-17841784- USER_ID=$(id -u)
17851785- GROUP_ID=$(id -g)
17861786- USER_NAME=$(id -un)
17871787- GROUP_NAME=$(id -gn)
17881788-17891789- case "${opam_root}" in
17901790- /* | ?:*) # /a/b/c or C:\Windows
17911791- validate_supports_docker() {
17921792- echo "Docker only supported with relative paths for the opam root, not: ${opam_root}" >&2
17931793- exit 3
17941794- }
17951795- ;;
17961796- *) # relative path
17971797- validate_supports_docker() {
17981798- true
17991799- }
18001800- cat >.ci/sd4/run-in-docker <<EOF
18011801-#!/bin/sh
18021802-set -euf
18031803-export PATH="/work/.ci/local/bin:/work/.ci/sd4/bs/bin:/work/.ci/sd4/opamexe:\$PATH"
18041804-export OPAMROOT=/work/${opam_root}
18051805-export OPAMROOTISOK=1
18061806-if [ "${PATCH_OS_DISTRIBUTION_WIN32}" = true ]; then export OPAMVAR_os_distribution=win32; fi
18071807-if [ "${PATCH_EXE_WIN32}" = true ]; then export OPAMVAR_exe=.exe; fi
18081808-18091809-# Reset environment so no conflicts with a parent Opam or OCaml system
18101810-unset OPAM_SWITCH_PREFIX
18111811-unset OPAMSWITCH
18121812-unset CAML_LD_LIBRARY_PATH
18131813-unset OCAMLLIB
18141814-unset OCAML_TOPLEVEL_PATH
18151815-18161816-prog=\$1
18171817-shift
18181818-18191819-# Optionally skip troubleshooting
18201820-troubleshooting=1
18211821-if [ "\$#" -ge 1 ] && [ "\$prog" = opam ] && [ "\$1" = "--no-troubleshooting" ]; then
18221822- shift
18231823- troubleshooting=0
18241824-fi
18251825-18261826-echo "Running inside Docker container: \$prog \$*" >&2
18271827-set +e
18281828-"\$prog" "\$@"
18291829-exitcode=\$?
18301830-if [ \$troubleshooting = 1 ] && [ \$prog = opam ]; then
18311831- [ \$exitcode = 0 ] || "/work/.ci/sd4/troubleshoot-opam.sh" \$OPAMROOT
18321832-fi
18331833-exit \$exitcode
18341834-EOF
18351835- chmod +x .ci/sd4/run-in-docker
18361836- ;;
18371837- esac
18381838-18391839- cat >.ci/sd4/deescalate <<EOF
18401840-#!/bin/sh
18411841-set -euf
18421842-18431843-if [ -e /work/.ci/sd4/bs/bin/deps.tar.gz ]; then
18441844- tar xCfz / /work/.ci/sd4/bs/bin/deps.tar.gz
18451845-fi
18461846-18471847-groupadd -g ${GROUP_ID} ${GROUP_NAME}
18481848-useradd -l -m -u ${USER_ID} -g ${GROUP_ID} ${USER_NAME}
18491849-exec runuser -u ${USER_NAME} -g ${GROUP_NAME} -- "\$@"
18501850-EOF
18511851-18521852- chmod +x .ci/sd4/deescalate
18531853-18541854- # -----------------------------------
18551855- # Create run-with-env
18561856- # -----------------------------------
18571857-18581858- install -d .ci/sd4/dist
18591859-18601860- if [ -x .ci/sd4/dockcross ]; then
18611861- # Adding empty dockcross root volume avoids:
18621862- # cp: target ‘/home/root/’ is not a directory
18631863- # chown: cannot access ‘/home/root’: No such file or directory
18641864- # from https://github.com/dockcross/dockcross/blob/96d87416f639af0204bdd42553e4b99315ca8476/imagefiles/entrypoint.sh#L31-L32
18651865- install -d .ci/sd4/edr
18661866-18671867- cat >.ci/sd4/run-with-env <<EOF
18681868-#!/bin/sh
18691869-set -euf
18701870-18711871-HERE=\$(dirname "\$0")
18721872-HERE=\$(cd "\$HERE" && pwd)
18731873-PROJECT_DIR=\$(cd "\$HERE"/../.. && pwd)
18741874-18751875-# Optionally enable terminal if and only if '-it' option given
18761876-termargs=
18771877-if [ "\$#" -ge 1 ] && [ "\$1" = "-it" ]; then
18781878- shift
18791879- termargs=-it
18801880-fi
18811881-18821882-exec bash "\${PROJECT_DIR}"/.ci/sd4/dockcross --args "\${termargs} -v \${PROJECT_DIR}/.ci/sd4/edr:/home/root ${dockcross_run_extra_args:-}" /work/.ci/sd4/run-in-docker "\$@"
18831883-EOF
18841884- chmod +x .ci/sd4/run-with-env
18851885-18861886- validate_supports_docker
18871887-18881888- # Bundle for consumers of setup-dkml.yml
18891889- echo '__ run-in-docker __' >&2
18901890- cat .ci/sd4/run-in-docker >&2
18911891- echo '___________________' >&2
18921892- do_tar_rf .ci/sd4/dist/run-with-env.tar .ci/sd4/run-with-env .ci/sd4/run-in-docker .ci/sd4/edr
18931893-18941894- elif [ -n "${docker_runner:-}" ]; then
18951895-18961896- cat >.ci/sd4/run-with-env <<EOF
18971897-#!/bin/sh
18981898-set -euf
18991899-exec ${docker_runner:-} /work/.ci/sd4/deescalate /work/.ci/sd4/run-in-docker "\$@"
19001900-EOF
19011901- chmod +x .ci/sd4/run-with-env
19021902-19031903- validate_supports_docker
19041904-19051905- # Bundle for consumers of setup-dkml.yml
19061906- echo '__ run-in-docker __' >&2
19071907- cat .ci/sd4/run-in-docker >&2
19081908- echo '________________________' >&2
19091909- echo '__ deescalate __' >&2
19101910- cat .ci/sd4/deescalate >&2
19111911- echo '________________' >&2
19121912- do_tar_rf .ci/sd4/dist/run-with-env.tar .ci/sd4/run-with-env .ci/sd4/run-in-docker .ci/sd4/deescalate
19131913-19141914- else
19151915-19161916- cat >.ci/sd4/run-with-env <<EOF
19171917-#!/bin/sh
19181918-set -euf
19191919-19201920-HERE=\$(dirname "\$0")
19211921-HERE=\$(cd "\$HERE" && pwd)
19221922-PROJECT_DIR=\$(cd "\$HERE"/../.. && pwd)
19231923-19241924-export PATH="\${PROJECT_DIR}/.ci/local/bin:\${PROJECT_DIR}/.ci/sd4/bs/bin:\${PROJECT_DIR}/.ci/sd4/opamexe:\$PATH"
19251925-export OPAMROOT='${opam_root}'
19261926-export OPAMROOTISOK=1
19271927-if [ "${PATCH_OS_DISTRIBUTION_WIN32}" = true ]; then export OPAMVAR_os_distribution=win32; fi
19281928-if [ "${PATCH_EXE_WIN32}" = true ]; then export OPAMVAR_exe=.exe; fi
19291929-19301930-# Reset environment so no conflicts with a parent Opam or OCaml system
19311931-unset OPAM_SWITCH_PREFIX
19321932-unset OPAMSWITCH
19331933-unset CAML_LD_LIBRARY_PATH
19341934-unset OCAMLLIB
19351935-unset OCAML_TOPLEVEL_PATH
19361936-19371937-prog=\$1
19381938-shift
19391939-19401940-# Optionally skip troubleshooting
19411941-troubleshooting=1
19421942-if [ "\$#" -ge 1 ] && [ "\$prog" = opam ] && [ "\$1" = "--no-troubleshooting" ]; then
19431943- shift
19441944- troubleshooting=0
19451945-fi
19461946-19471947-echo "Running: \$prog \$*" >&2
19481948-set +e
19491949-"\$prog" "\$@"
19501950-exitcode=\$?
19511951-if [ \$troubleshooting = 1 ] && [ \$prog = opam ]; then
19521952- [ \$exitcode = 0 ] || "\${PROJECT_DIR}/.ci/sd4/troubleshoot-opam.sh" \$OPAMROOT
19531953-fi
19541954-exit \$exitcode
19551955-EOF
19561956- chmod +x .ci/sd4/run-with-env
19571957-19581958- # Bundle for consumers of setup-dkml.yml
19591959- do_tar_rf .ci/sd4/dist/run-with-env.tar .ci/sd4/run-with-env
19601960-19611961- fi
19621962- echo '__ run-with-env __' >&2
19631963- cat .ci/sd4/run-with-env >&2
19641964- echo '__________________' >&2
19651965-19661966- # ------
19671967- # cmdrun
19681968- # ------
19691969-19701970- install -d .ci/sd4/opamrun
19711971- cat >.ci/sd4/opamrun/cmdrun <<EOF
19721972-#!/bin/sh
19731973-set -euf
19741974-19751975-HERE=\$(dirname "\$0")
19761976-HERE=\$(cd "\$HERE" && pwd)
19771977-PROJECT_DIR=\$(cd "\$HERE"/../../.. && pwd)
19781978-19791979-# Add MSVC compiler environment if available
19801980-if [ -e "\${PROJECT_DIR}/.ci/sd4/msvcenv" ]; then
19811981- _oldpath="\$PATH"
19821982- # shellcheck disable=SC1091
19831983- . "\${PROJECT_DIR}/.ci/sd4/msvcenv"
19841984- PATH="\$PATH:\$_oldpath"
19851985-19861986- # MSVC (link.exe) needs a TMP as well.
19871987- # Confer: https://docs.microsoft.com/en-us/cpp/build/reference/linking?view=msvc-170#link-environment-variables
19881988- if [ -z "\${TMP:-}" ]; then
19891989- # GitHub Actions as of 2022-10 does not set TMP. GitLab CI/CD does.
19901990- TMP="\$RUNNER_TEMP"
19911991- fi
19921992- export TMP
19931993- if [ -x /usr/bin/cygpath ]; then
19941994- TMP=\$(/usr/bin/cygpath -aw "\$TMP")
19951995- fi
19961996-fi
19971997-19981998-# Windows
19991999-if [ -n "\${COMSPEC:-}" ]; then
20002000- # We must place MSYS2 in front of path so that MSYS2
20012001- # tar.exe is used instead of Windows tar.exe.
20022002- PATH="/usr/bin:\$PATH"
20032003-fi
20042004-20052005-exec "\${PROJECT_DIR}/.ci/sd4/run-with-env" "\$@"
20062006-EOF
20072007- chmod +x .ci/sd4/opamrun/cmdrun
20082008-20092009- # -------
20102010- # opamrun
20112011- # -------
20122012-20132013- install -d .ci/sd4/opamrun
20142014- cat >.ci/sd4/opamrun/opamrun <<EOF
20152015-#!/bin/sh
20162016-set -euf
20172017-20182018-HERE=\$(dirname "\$0")
20192019-HERE=\$(cd "\$HERE" && pwd)
20202020-PROJECT_DIR=\$(cd "\$HERE"/../../.. && pwd)
20212021-20222022-exec "\${PROJECT_DIR}/.ci/sd4/opamrun/cmdrun" opam "\$@"
20232023-EOF
20242024- chmod +x .ci/sd4/opamrun/opamrun
20252025-20262026- # Bundle for consumers of setup-dkml.yml
20272027- do_tar_rf .ci/sd4/dist/run-with-env.tar .ci/sd4/opamrun
20282028-}
20292029-section_begin 'write-opam-scripts' 'Write opam scripts'
20302030-do_write_opam_scripts
20312031-section_end 'write-opam-scripts'
20322032-20332033-# Expose opamrun (also used for consumers of setup-dkml.yml) to GitHub
20342034-if [ -n "${GITHUB_PATH:-}" ]; then
20352035- opamrunabs="$setup_WORKSPACE/.ci/sd4/opamrun"
20362036- if [ -x /usr/bin/cygpath ]; then opamrunabs=$(/usr/bin/cygpath -aw "$opamrunabs"); fi
20372037- echo "$opamrunabs" >>"$GITHUB_PATH"
20382038- # Special case: GITHUB_PATH does not influence msys2.CMD of msys2/setup-msys2@v2, so place in real MSYS2 PATH
20392039- if [ -n "${MSYSTEM:-}" ]; then
20402040- install -d /usr/local/bin
20412041- install .ci/sd4/opamrun/opamrun /usr/local/bin/opamrun
20422042- fi
20432043-fi
20442044-20452045-# Place opamrun in the immediate PATH
20462046-PATH="$setup_WORKSPACE/.ci/sd4/opamrun:$PATH"
20472047-20482048-# Complicated Opam sequence is because:
20492049-# 1. Opam's default curl does not work on Windows,
20502050-# and `opam init` does not provide a way to change it (TODO: need
20512051-# a PR!).
20522052-# 2. We have to separate the Opam download cache from the other Opam
20532053-# caches
20542054-if [ "${SKIP_OPAM_MODIFICATIONS:-}" = "false" ] && [ ! -s "$opam_root/.ci.root-init" ]; then # non-empty init file so can be cached irrespective of existence
20552055- section_begin opam-init 'Initialize opam root'
20562056-20572057- # Clear any partial previous attempt
20582058- rm -rf "$opam_root"
20592059-20602060- case "$dkml_host_abi,${in_docker:-}" in
20612061- windows_*,*)
20622062- eor=$(cygpath -am "$setup_WORKSPACE"/.ci/sd4/eor)
20632063- opamrun init --disable-sandboxing --no-setup --kind local --bare "$eor"
20642064- case "$(opamrun --version)" in
20652065- 2.0.*) echo 'download-command: wget' >>"$opam_root/config" ;;
20662066- *) opamrun option --yes --global download-command=wget ;;
20672067- esac
20682068- ;;
20692069- *,true)
20702070- opamrun init --disable-sandboxing --no-setup --kind local --bare "/work/.ci/sd4/eor"
20712071- ;;
20722072- *)
20732073- opamrun init --disable-sandboxing --no-setup --kind local --bare "$setup_WORKSPACE/.ci/sd4/eor"
20742074- ;;
20752075- esac
20762076- echo yes > "$opam_root/.ci.root-init"
20772077-20782078- section_end opam-init
20792079-fi
20802080-20812081-if [ "${SKIP_OPAM_MODIFICATIONS:-}" = "false" ]; then
20822082- section_begin opam-vars "Summary: opam global variables"
20832083- opamrun --no-troubleshooting var --global || true
20842084- section_end opam-vars
20852085-fi
20862086-20872087-# Build OCaml
20882088-20892089-do_switch_create() {
20902090- do_switch_create_NAME=$1
20912091- shift
20922092-20932093- section_begin "switch-create-$do_switch_create_NAME" "Create opam switch '$do_switch_create_NAME'"
20942094- # Create, or recreate, the Opam switch. The Opam switch should not be
20952095- # cached except for the compiler (confer docs for setup-ocaml GitHub
20962096- # Action) which is the 'dkml' switch (or the 'two' switch).
20972097- # Check if the switch name is present in the Opam root (which may come from cache)
20982098- NOMINALLY_PRESENT=false
20992099- if opamrun switch list --short | grep "^${do_switch_create_NAME}\$"; then NOMINALLY_PRESENT=true; fi
21002100-21012101- # Check if the switch is actually present in case of cache incoherence
21022102- # or corrupt Opam state that could result in:
21032103- # Error: No config file found for switch dkml. Switch broken?
21042104- if [ $NOMINALLY_PRESENT = true ] && [ ! -e "$opam_root/$do_switch_create_NAME/.opam-switch/switch-config" ]; then
21052105- # Remove the switch name from Opam root, and any partial switch state.
21062106- # Ignore inevitable warnings/failure about missing switch.
21072107- opamrun --no-troubleshooting switch remove "$do_switch_create_NAME" --yes || true
21082108- rm -rf "${opam_root:?}/$do_switch_create_NAME"
21092109- NOMINALLY_PRESENT=false
21102110- fi
21112111-21122112- if [ $NOMINALLY_PRESENT = false ]; then
21132113- opamrun switch create "$do_switch_create_NAME" --empty --yes
21142114- fi
21152115- section_end "switch-create-$do_switch_create_NAME"
21162116-}
21172117-if [ "${SKIP_OPAM_MODIFICATIONS:-}" = "false" ]; then
21182118- do_switch_create dkml
21192119- if [ "${SECONDARY_SWITCH:-}" = "true" ]; then
21202120- do_switch_create two
21212121- else
21222122- section_begin "switch-create-two" "Create empty opam switch 'two'"
21232123- # Always create a secondary switch ... just empty. Avoid problems with cache content missing
21242124- # and idempotency.
21252125- opamrun --no-troubleshooting switch remove two --yes || true
21262126- rm -rf "$opam_root/two"
21272127- opamrun switch create two --empty --yes
21282128- section_end "switch-create-two"
21292129- fi
21302130-fi
21312131-21322132-do_switch_active() {
21332133- section_begin "switch-active" "Set dkml as active switch"
21342134- opamrun switch set dkml --yes
21352135- section_end "switch-active"
21362136-}
21372137-if [ "${SKIP_OPAM_MODIFICATIONS:-}" = "false" ]; then
21382138- do_switch_active
21392139-fi
21402140-21412141-do_opam_repositories_add() {
21422142- section_begin "opam-repo-add" "Add 'diskuv' opam repository"
21432143- if ! opamrun --no-troubleshooting repository list -s | grep '^diskuv'; then
21442144- opamrun repository add diskuv "git+https://github.com/diskuv/diskuv-opam-repository.git#${DISKUV_OPAM_REPOSITORY:-$DEFAULT_DISKUV_OPAM_REPOSITORY_TAG}" --yes --dont-select
21452145- fi
21462146- section_end "opam-repo-add"
21472147-}
21482148-if [ "${SKIP_OPAM_MODIFICATIONS:-}" = "false" ]; then
21492149- do_opam_repositories_add
21502150-fi
21512151-21522152-do_opam_repositories_config() {
21532153- do_opam_repositories_config_NAME=$1
21542154- shift
21552155-21562156- section_begin "opam-repo-$do_opam_repositories_config_NAME" "Attach repositories to $do_opam_repositories_config_NAME"
21572157-21582158- if [ ! -s "$opam_root/.ci.$do_opam_repositories_config_NAME.repo-init" ]; then # non-empty init file so can be cached irrespective of existence
21592159- opamrun --no-troubleshooting repository remove default --switch "$do_opam_repositories_config_NAME" --yes || true
21602160- opamrun --no-troubleshooting repository remove diskuv --switch "$do_opam_repositories_config_NAME" --yes || true
21612161- opamrun repository add default --switch "$do_opam_repositories_config_NAME" --yes
21622162- opamrun repository add diskuv --switch "$do_opam_repositories_config_NAME" --yes
21632163- echo yes > "$opam_root/.ci.$do_opam_repositories_config_NAME.repo-init"
21642164- fi
21652165-21662166- section_end "opam-repo-$do_opam_repositories_config_NAME"
21672167-}
21682168-if [ "${SKIP_OPAM_MODIFICATIONS:-}" = "false" ]; then
21692169- do_opam_repositories_config dkml
21702170- if [ "${SECONDARY_SWITCH:-}" = "true" ]; then
21712171- do_opam_repositories_config two
21722172- fi
21732173-fi
21742174-21752175-do_opam_repositories_update() {
21762176- section_begin "opam-repo-update" "Update opam repositories"
21772177- # The default repository may be the initial 'eor' (empty) repository
21782178- opamrun repository set-url default https://opam.ocaml.org --yes
21792179- # Always set the `diskuv` repository url since it can change
21802180- opamrun repository set-url diskuv "git+https://github.com/diskuv/diskuv-opam-repository.git#${DISKUV_OPAM_REPOSITORY:-$DEFAULT_DISKUV_OPAM_REPOSITORY_TAG}" --yes --dont-select
21812181- # Update both `default` and `diskuv` Opam repositories
21822182- opamrun update default diskuv
21832183- section_end "opam-repo-update"
21842184-}
21852185-if [ "${SKIP_OPAM_MODIFICATIONS:-}" = "false" ]; then
21862186- do_opam_repositories_update
21872187-fi
21882188-21892189-do_pins() {
21902190- do_pins_NAME=$1
21912191- shift
21922192-21932193- section_begin "opam-pins-$do_pins_NAME" "Opam pins for $do_pins_NAME switch"
21942194- ### BEGIN pin-adds. DO NOT EDIT THE LINES IN THIS SECTION
21952195- # Managed by bump-packages.cmake
21962196- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version astring "${PIN_ASTRING}"
21972197- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version base "${PIN_BASE}"
21982198- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version base64 "${PIN_BASE64}"
21992199- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version bigarray-compat "${PIN_BIGARRAY_COMPAT}"
22002200- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version bos "${PIN_BOS}"
22012201- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version camlp-streams "${PIN_CAMLP_STREAMS}"
22022202- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version chrome-trace "${PIN_CHROME_TRACE}"
22032203- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version cmdliner "${PIN_CMDLINER}"
22042204- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version conf-dkml-sys-opam "${PIN_CONF_DKML_SYS_OPAM}"
22052205- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version conf-pkg-config "${PIN_CONF_PKG_CONFIG}"
22062206- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version conf-sqlite3 "${PIN_CONF_SQLITE3}"
22072207- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version cppo "${PIN_CPPO}"
22082208- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version crunch "${PIN_CRUNCH}"
22092209- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version csexp "${PIN_CSEXP}"
22102210- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version cstruct "${PIN_CSTRUCT}"
22112211- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ctypes "${PIN_CTYPES}"
22122212- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ctypes-foreign "${PIN_CTYPES_FOREIGN}"
22132213- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version cudf "${PIN_CUDF}"
22142214- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version digestif "${PIN_DIGESTIF}"
22152215- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version diskuvbox "${PIN_DISKUVBOX}"
22162216- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-apps "${PIN_DKML_APPS}"
22172217- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-base-compiler "${PIN_DKML_BASE_COMPILER}"
22182218- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-build-desktop "${PIN_DKML_BUILD_DESKTOP}"
22192219- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-c-probe "${PIN_DKML_C_PROBE}"
22202220- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-compiler-env "${PIN_DKML_COMPILER_ENV}"
22212221- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-compiler-src "${PIN_DKML_COMPILER_SRC}"
22222222- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-common-desktop "${PIN_DKML_COMPONENT_COMMON_DESKTOP}"
22232223- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-common-opam "${PIN_DKML_COMPONENT_COMMON_OPAM}"
22242224- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-common-unixutils "${PIN_DKML_COMPONENT_COMMON_UNIXUTILS}"
22252225- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-ocamlcompiler-common "${PIN_DKML_COMPONENT_OCAMLCOMPILER_COMMON}"
22262226- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-ocamlcompiler-network "${PIN_DKML_COMPONENT_OCAMLCOMPILER_NETWORK}"
22272227- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-ocamlcompiler-offline "${PIN_DKML_COMPONENT_OCAMLCOMPILER_OFFLINE}"
22282228- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-offline-desktop-full "${PIN_DKML_COMPONENT_OFFLINE_DESKTOP_FULL}"
22292229- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-offline-opamshim "${PIN_DKML_COMPONENT_OFFLINE_OPAMSHIM}"
22302230- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-offline-unixutils "${PIN_DKML_COMPONENT_OFFLINE_UNIXUTILS}"
22312231- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-staging-desktop-full "${PIN_DKML_COMPONENT_STAGING_DESKTOP_FULL}"
22322232- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-staging-dkmlconfdir "${PIN_DKML_COMPONENT_STAGING_DKMLCONFDIR}"
22332233- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-staging-ocamlrun "${PIN_DKML_COMPONENT_STAGING_OCAMLRUN}"
22342234- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-staging-opam32 "${PIN_DKML_COMPONENT_STAGING_OPAM32}"
22352235- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-staging-opam64 "${PIN_DKML_COMPONENT_STAGING_OPAM64}"
22362236- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-staging-unixutils "${PIN_DKML_COMPONENT_STAGING_UNIXUTILS}"
22372237- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-staging-withdkml "${PIN_DKML_COMPONENT_STAGING_WITHDKML}"
22382238- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-component-xx-console "${PIN_DKML_COMPONENT_XX_CONSOLE}"
22392239- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-exe "${PIN_DKML_EXE}"
22402240- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-exe-lib "${PIN_DKML_EXE_LIB}"
22412241- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-install "${PIN_DKML_INSTALL}"
22422242- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-install-installer "${PIN_DKML_INSTALL_INSTALLER}"
22432243- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-install-runner "${PIN_DKML_INSTALL_RUNNER}"
22442244- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-installer-ocaml-common "${PIN_DKML_INSTALLER_OCAML_COMMON}"
22452245- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-installer-ocaml-offline "${PIN_DKML_INSTALLER_OCAML_OFFLINE}"
22462246- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-package-console "${PIN_DKML_PACKAGE_CONSOLE}"
22472247- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-runtime-common "${PIN_DKML_RUNTIME_COMMON}"
22482248- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-runtime-common-native "${PIN_DKML_RUNTIME_COMMON_NATIVE}"
22492249- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-runtime-distribution "${PIN_DKML_RUNTIME_DISTRIBUTION}"
22502250- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-runtimelib "${PIN_DKML_RUNTIMELIB}"
22512251- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-runtimescripts "${PIN_DKML_RUNTIMESCRIPTS}"
22522252- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dkml-workflows "${PIN_DKML_WORKFLOWS}"
22532253- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dune "${PIN_DUNE}"
22542254- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dune-action-plugin "${PIN_DUNE_ACTION_PLUGIN}"
22552255- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dune-build-info "${PIN_DUNE_BUILD_INFO}"
22562256- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dune-configurator "${PIN_DUNE_CONFIGURATOR}"
22572257- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dune-glob "${PIN_DUNE_GLOB}"
22582258- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dune-private-libs "${PIN_DUNE_PRIVATE_LIBS}"
22592259- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dune-rpc "${PIN_DUNE_RPC}"
22602260- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dune-rpc-lwt "${PIN_DUNE_RPC_LWT}"
22612261- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dune-site "${PIN_DUNE_SITE}"
22622262- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version dyn "${PIN_DYN}"
22632263- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version either "${PIN_EITHER}"
22642264- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version eqaf "${PIN_EQAF}"
22652265- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version extlib "${PIN_EXTLIB}"
22662266- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ezjsonm "${PIN_EZJSONM}"
22672267- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version feather "${PIN_FEATHER}"
22682268- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version fiber "${PIN_FIBER}"
22692269- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version fix "${PIN_FIX}"
22702270- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version fmt "${PIN_FMT}"
22712271- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version fpath "${PIN_FPATH}"
22722272- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version graphics "${PIN_GRAPHICS}"
22732273- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version hex "${PIN_HEX}"
22742274- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version integers "${PIN_INTEGERS}"
22752275- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version jane-street-headers "${PIN_JANE_STREET_HEADERS}"
22762276- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version jingoo "${PIN_JINGOO}"
22772277- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version jsonm "${PIN_JSONM}"
22782278- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version jsonrpc "${PIN_JSONRPC}"
22792279- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version jst-config "${PIN_JST_CONFIG}"
22802280- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version lambda-term "${PIN_LAMBDA_TERM}"
22812281- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version logs "${PIN_LOGS}"
22822282- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version lsp "${PIN_LSP}"
22832283- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version lwt "${PIN_LWT}"
22842284- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version lwt_react "${PIN_LWT_REACT}"
22852285- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version mccs "${PIN_MCCS}"
22862286- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version mdx "${PIN_MDX}"
22872287- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version menhir "${PIN_MENHIR}"
22882288- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version menhirLib "${PIN_MENHIRLIB}"
22892289- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version menhirSdk "${PIN_MENHIRSDK}"
22902290- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version merlin-lib "${PIN_MERLIN_LIB}"
22912291- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version metapp "${PIN_METAPP}"
22922292- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version metaquot "${PIN_METAQUOT}"
22932293- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version mew "${PIN_MEW}"
22942294- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version mew_vi "${PIN_MEW_VI}"
22952295- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version num "${PIN_NUM}"
22962296- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ocaml "${PIN_OCAML}"
22972297- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ocaml-compiler-libs "${PIN_OCAML_COMPILER_LIBS}"
22982298- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ocaml-lsp-server "${PIN_OCAML_LSP_SERVER}"
22992299- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ocaml-version "${PIN_OCAML_VERSION}"
23002300- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ocamlbuild "${PIN_OCAMLBUILD}"
23012301- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ocamlc-loc "${PIN_OCAMLC_LOC}"
23022302- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ocamlfind "${PIN_OCAMLFIND}"
23032303- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ocamlformat "${PIN_OCAMLFORMAT}"
23042304- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ocamlformat-lib "${PIN_OCAMLFORMAT_LIB}"
23052305- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ocamlformat-rpc-lib "${PIN_OCAMLFORMAT_RPC_LIB}"
23062306- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ocp-indent "${PIN_OCP_INDENT}"
23072307- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ocplib-endian "${PIN_OCPLIB_ENDIAN}"
23082308- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version odoc "${PIN_ODOC}"
23092309- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version odoc-parser "${PIN_ODOC_PARSER}"
23102310- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ordering "${PIN_ORDERING}"
23112311- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version parsexp "${PIN_PARSEXP}"
23122312- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version pp "${PIN_PP}"
23132313- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_assert "${PIN_PPX_ASSERT}"
23142314- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_base "${PIN_PPX_BASE}"
23152315- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_cold "${PIN_PPX_COLD}"
23162316- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_compare "${PIN_PPX_COMPARE}"
23172317- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_derivers "${PIN_PPX_DERIVERS}"
23182318- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_deriving "${PIN_PPX_DERIVING}"
23192319- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_enumerate "${PIN_PPX_ENUMERATE}"
23202320- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_expect "${PIN_PPX_EXPECT}"
23212321- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_globalize "${PIN_PPX_GLOBALIZE}"
23222322- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_hash "${PIN_PPX_HASH}"
23232323- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_here "${PIN_PPX_HERE}"
23242324- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_ignore_instrumentation "${PIN_PPX_IGNORE_INSTRUMENTATION}"
23252325- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_inline_test "${PIN_PPX_INLINE_TEST}"
23262326- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_optcomp "${PIN_PPX_OPTCOMP}"
23272327- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_pipebang "${PIN_PPX_PIPEBANG}"
23282328- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_sexp_conv "${PIN_PPX_SEXP_CONV}"
23292329- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppx_yojson_conv_lib "${PIN_PPX_YOJSON_CONV_LIB}"
23302330- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ppxlib "${PIN_PPXLIB}"
23312331- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version ptime "${PIN_PTIME}"
23322332- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version qrc "${PIN_QRC}"
23332333- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version re "${PIN_RE}"
23342334- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version react "${PIN_REACT}"
23352335- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version refl "${PIN_REFL}"
23362336- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version result "${PIN_RESULT}"
23372337- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version rresult "${PIN_RRESULT}"
23382338- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version seq "${PIN_SEQ}"
23392339- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version sexplib "${PIN_SEXPLIB}"
23402340- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version sexplib0 "${PIN_SEXPLIB0}"
23412341- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version sha "${PIN_SHA}"
23422342- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version spawn "${PIN_SPAWN}"
23432343- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version sqlite3 "${PIN_SQLITE3}"
23442344- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version stdcompat "${PIN_STDCOMPAT}"
23452345- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version stdio "${PIN_STDIO}"
23462346- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version stdlib-shims "${PIN_STDLIB_SHIMS}"
23472347- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version stdune "${PIN_STDUNE}"
23482348- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version time_now "${PIN_TIME_NOW}"
23492349- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version topkg "${PIN_TOPKG}"
23502350- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version traverse "${PIN_TRAVERSE}"
23512351- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version trie "${PIN_TRIE}"
23522352- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version tsort "${PIN_TSORT}"
23532353- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version tyxml "${PIN_TYXML}"
23542354- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version uchar "${PIN_UCHAR}"
23552355- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version utop "${PIN_UTOP}"
23562356- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version uucp "${PIN_UUCP}"
23572357- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version uuidm "${PIN_UUIDM}"
23582358- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version uuseg "${PIN_UUSEG}"
23592359- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version uutf "${PIN_UUTF}"
23602360- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version with-dkml "${PIN_WITH_DKML}"
23612361- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version xdg "${PIN_XDG}"
23622362- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version yojson "${PIN_YOJSON}"
23632363- opamrun pin add --switch "$do_pins_NAME" --yes --no-action -k version zed "${PIN_ZED}"
23642364- ### END pin-adds. DO NOT EDIT THE LINES ABOVE
23652365- section_end "opam-pins-$do_pins_NAME"
23662366-23672367- # --------------
23682368- # REMAINING PINS
23692369- # --------------
23702370-23712371- # These come after [pin-adds] section since [pin-adds] may need to be overridden by
23722372- # users' choice.
23732373-23742374- # dkml-base-compiler
23752375-23762376- if [ "${DKML_COMPILER:-}" != '@repository@' ] && [ -z "${DKML_COMPILER:-}" ] && [ -z "${OCAML_COMPILER:-}" ]; then
23772377- section_begin checkout-dkml-base-compiler "Pin dkml-base-compiler to default ${DEFAULT_DKML_COMPILER} (neither dkml-base-compiler nor OCAML_COMPILER specified) for $do_pins_NAME switch"
23782378- opamrun pin add --switch "$do_pins_NAME" --yes --no-action dkml-base-compiler "https://github.com/diskuv/dkml-compiler.git#${DEFAULT_DKML_COMPILER}"
23792379- section_end checkout-dkml-base-compiler
23802380- elif [ "${DKML_COMPILER:-}" != '@repository@' ] && [ -n "${DKML_COMPILER:-}" ] && [ -z "${OCAML_COMPILER:-}" ]; then
23812381- section_begin checkout-dkml-base-compiler "Pin dkml-base-compiler to $DKML_COMPILER (dkml-base-compiler specified; no OCAML_COMPILER specified) for $do_pins_NAME switch"
23822382- opamrun pin add --switch "$do_pins_NAME" --yes --no-action dkml-base-compiler "https://github.com/diskuv/dkml-compiler.git#${DKML_COMPILER}"
23832383- section_end checkout-dkml-base-compiler
23842384- elif [ -n "${OCAML_COMPILER:-}" ]; then
23852385- # Validate OCAML_COMPILER (OCAML_COMPILER specified)
23862386- case "${OCAML_COMPILER:-}" in
23872387- 4.12.1) true ;;
23882388- 4.14.0) true ;;
23892389- *)
23902390- echo "OCAML_COMPILER version ${OCAML_COMPILER:-} is not supported" >&2
23912391- exit 109
23922392- ;;
23932393- esac
23942394-23952395- section_begin checkout-dkml-base-compiler "Pin dkml-base-compiler (OCAML_COMPILER specified) for $do_pins_NAME switch"
23962396- opamrun pin add --switch "$do_pins_NAME" --yes --no-action dkml-base-compiler "https://github.com/diskuv/dkml-compiler.git#${OCAML_COMPILER}-v${DKML_VERSION}"
23972397- section_end checkout-dkml-base-compiler
23982398- fi
23992399-24002400- # conf-dkml-cross-toolchain
24012401-24022402- if [ "${CONF_DKML_CROSS_TOOLCHAIN:-}" != '@repository@' ]; then
24032403- section_begin checkout-conf-dkml-cross-toolchain "Pin conf-dkml-cross-toolchain for $do_pins_NAME switch"
24042404- opamrun pin add --switch "$do_pins_NAME" --yes --no-action conf-dkml-cross-toolchain "https://github.com/diskuv/conf-dkml-cross-toolchain.git#$CONF_DKML_CROSS_TOOLCHAIN"
24052405- section_end checkout-conf-dkml-cross-toolchain
24062406- fi
24072407-}
24082408-24092409-if [ "${SKIP_OPAM_MODIFICATIONS:-}" = "false" ]; then
24102410- do_pins dkml
24112411- if [ "${SECONDARY_SWITCH:-}" = "true" ]; then
24122412- do_pins two
24132413- fi
24142414-fi
24152415-24162416-do_use_vsstudio() {
24172417- do_use_vsstudio_NAME=$1
24182418- shift
24192419- case "$dkml_host_abi" in
24202420- windows_*)
24212421- section_begin "use-vsstudio-$do_use_vsstudio_NAME" "Use Visual Studio in dkml-* Opam packages (Windows) for $do_use_vsstudio_NAME switch"
24222422-24232423- # shellcheck disable=SC2153
24242424- E_VS_DIR=$(escape_arg_as_ocaml_string "$VS_DIR")
24252425- # shellcheck disable=SC2153
24262426- E_VS_VCVARSVER=$(escape_arg_as_ocaml_string "$VS_VCVARSVER")
24272427- # shellcheck disable=SC2153
24282428- E_VS_WINSDKVER=$(escape_arg_as_ocaml_string "$VS_WINSDKVER")
24292429- # shellcheck disable=SC2153
24302430- E_VS_MSVSPREFERENCE=$(escape_arg_as_ocaml_string "$VS_MSVSPREFERENCE")
24312431- # shellcheck disable=SC2153
24322432- E_VS_CMAKEGENERATOR=$(escape_arg_as_ocaml_string "$VS_CMAKEGENERATOR")
24332433-24342434- case "$(opamrun --version)" in
24352435- 2.0.*)
24362436- if [ "${in_docker}" = "true" ]; then
24372437- echo Opam 2.0 support in dockcross to use a portable opam var prefix not yet implemented
24382438- exit 67
24392439- fi
24402440- OP=$(opamrun var prefix --switch "$do_use_vsstudio_NAME")
24412441- OPSC=$OP/.opam-switch/switch-config
24422442- if grep setenv: "$OPSC"; then
24432443- echo "INFO: Updating switch-config. Old was:"
24442444- awk '{print ">> " $0}' "$OPSC"
24452445-24462446- awk '$1=="setenv:"{x=1} x==0{print} x==1 && $0=="]"{x=0}' "$OPSC" >"$OPSC".trimmed
24472447- mv "$OPSC".trimmed "$OPSC"
24482448- fi
24492449- echo 'setenv: [' >>"$OPSC"
24502450- echo ' [DKML_COMPILE_SPEC = "1"]' >>"$OPSC"
24512451- echo ' [DKML_COMPILE_TYPE = "VS"]' >>"$OPSC"
24522452- echo " [DKML_COMPILE_VS_DIR = \"$E_VS_DIR\"]" >>"$OPSC"
24532453- echo " [DKML_COMPILE_VS_VCVARSVER = \"$E_VS_VCVARSVER\"]" >>"$OPSC"
24542454- echo " [DKML_COMPILE_VS_WINSDKVER = \"$E_VS_WINSDKVER\"]" >>"$OPSC"
24552455- echo " [DKML_COMPILE_VS_MSVSPREFERENCE = \"$E_VS_MSVSPREFERENCE\"]" >>"$OPSC"
24562456- echo " [DKML_COMPILE_VS_CMAKEGENERATOR = \"$E_VS_CMAKEGENERATOR\"]" >>"$OPSC"
24572457- echo " [DKML_HOST_ABI = \"${dkml_host_abi}\"]" >>"$OPSC"
24582458- echo ']' >>"$OPSC"
24592459- cat "$OPSC" >&2 # print
24602460- ;;
24612461- *)
24622462- opamrun option --switch "$do_use_vsstudio_NAME" setenv= # reset
24632463- opamrun option --switch "$do_use_vsstudio_NAME" setenv+='DKML_COMPILE_SPEC = "1"'
24642464- opamrun option --switch "$do_use_vsstudio_NAME" setenv+='DKML_COMPILE_TYPE = "VS"'
24652465- opamrun option --switch "$do_use_vsstudio_NAME" setenv+="DKML_COMPILE_VS_DIR = \"$E_VS_DIR\""
24662466- opamrun option --switch "$do_use_vsstudio_NAME" setenv+="DKML_COMPILE_VS_VCVARSVER = \"$E_VS_VCVARSVER\""
24672467- opamrun option --switch "$do_use_vsstudio_NAME" setenv+="DKML_COMPILE_VS_WINSDKVER = \"$E_VS_WINSDKVER\""
24682468- opamrun option --switch "$do_use_vsstudio_NAME" setenv+="DKML_COMPILE_VS_MSVSPREFERENCE = \"$E_VS_MSVSPREFERENCE\""
24692469- opamrun option --switch "$do_use_vsstudio_NAME" setenv+="DKML_COMPILE_VS_CMAKEGENERATOR = \"$E_VS_CMAKEGENERATOR\""
24702470- opamrun option --switch "$do_use_vsstudio_NAME" setenv+="DKML_HOST_ABI = \"${dkml_host_abi}\""
24712471- opamrun option --switch "$do_use_vsstudio_NAME" setenv # print
24722472- ;;
24732473- esac
24742474-24752475- # shellcheck disable=SC2016
24762476- opamrun exec --switch "$do_use_vsstudio_NAME" -- sh -c 'echo $VCToolsRedistDir'
24772477-24782478- section_end "use-vsstudio-$do_use_vsstudio_NAME"
24792479- ;;
24802480- esac
24812481-}
24822482-if [ "${SKIP_OPAM_MODIFICATIONS:-}" = "false" ]; then
24832483- do_use_vsstudio dkml
24842484- if [ "${SECONDARY_SWITCH:-}" = "true" ]; then
24852485- do_use_vsstudio two
24862486- fi
24872487-fi
24882488-24892489-# Because dune.X.Y.Z+shim (and any user DKML packages) requires DKML installed (after all, it is just
24902490-# a with-dkml.exe shim), we need either dkmlvars-v2.sexp or DKML environment
24912491-# variables. Confer: Dkml_runtimelib.Dkml_context.get_dkmlversion
24922492-#
24932493-# grep matches either:
24942494-# [... [DiskuvOCamlVersion = "1.0.1"] ...]
24952495-# DiskuvOCamlVersion = "1.0.1"
24962496-do_setenv() {
24972497- do_setenv_SWITCH=$1
24982498- shift
24992499- section_begin "setenv-$do_setenv_SWITCH" "Set opam option for $do_setenv_SWITCH switch"
25002500- opamrun option --switch "$do_setenv_SWITCH" setenv > ".ci/sd4/setenv.$do_setenv_SWITCH.txt"
25012501- if ! grep -q '\(^|\[\)DiskuvOCamlVarsVersion ' ".ci/sd4/setenv.$do_setenv_SWITCH.txt"; then
25022502- opamrun option --switch "$do_setenv_SWITCH" setenv+='DiskuvOCamlVarsVersion = "2"'
25032503- fi
25042504- if ! grep -q '\(^|\[\)DiskuvOCamlVersion ' ".ci/sd4/setenv.$do_setenv_SWITCH.txt"; then
25052505- opamrun option --switch "$do_setenv_SWITCH" setenv+="DiskuvOCamlVersion = \"$DKML_VERSION\""
25062506- fi
25072507- if [ "$do_setenv_SWITCH" = dkml ] && [ -n "${DKML_HOME:-}" ]; then
25082508- do_setenv_DKMLHOME_ESCAPED="$DKML_HOME"
25092509- do_setenv_USRBIN_ESCAPED="$DKML_HOME/usr/bin"
25102510- do_setenv_BIN_ESCAPED="$DKML_HOME/bin"
25112511- if [ -x /usr/bin/cygpath ]; then
25122512- do_setenv_DKMLHOME_ESCAPED=$(/usr/bin/cygpath -aw "$do_setenv_DKMLHOME_ESCAPED" | sed 's/\\/\\\\/g')
25132513- do_setenv_USRBIN_ESCAPED=$(/usr/bin/cygpath -aw "$do_setenv_USRBIN_ESCAPED" | sed 's/\\/\\\\/g')
25142514- do_setenv_BIN_ESCAPED=$(/usr/bin/cygpath -aw "$do_setenv_BIN_ESCAPED" | sed 's/\\/\\\\/g')
25152515- fi
25162516- if ! grep -q '\(^|\[\)DiskuvOCamlHome ' ".ci/sd4/setenv.$do_setenv_SWITCH.txt"; then
25172517- opamrun option --switch "$do_setenv_SWITCH" setenv+="DiskuvOCamlHome = \"$do_setenv_DKMLHOME_ESCAPED\""
25182518- fi
25192519- if ! grep -q '\(^|\[\)DiskuvOCamlBinaryPaths ' ".ci/sd4/setenv.$do_setenv_SWITCH.txt"; then
25202520- opamrun option --switch "$do_setenv_SWITCH" setenv+="DiskuvOCamlBinaryPaths = \"$do_setenv_USRBIN_ESCAPED;$do_setenv_BIN_ESCAPED\""
25212521- fi
25222522- if ! grep -q '\(^|\[\)DiskuvOCamlDeploymentId ' ".ci/sd4/setenv.$do_setenv_SWITCH.txt"; then
25232523- opamrun option --switch "$do_setenv_SWITCH" setenv+="DiskuvOCamlDeploymentId = \"setup-dkml-switch-$do_setenv_SWITCH\""
25242524- fi
25252525- fi
25262526- case "${dkml_host_abi}" in
25272527- windows_*)
25282528- if ! grep -q '\(^|\[\)DiskuvOCamlMSYS2Dir ' ".ci/sd4/setenv.$do_setenv_SWITCH.txt"; then
25292529- if [ -x /usr/bin/cygpath ]; then
25302530- MSYS2_DIR_NATIVE=$(/usr/bin/cygpath -aw /)
25312531- else
25322532- # If we are already inside MSYS2 then MSYSTEM_PREFIX should be set. But cygpath should be there as well!!
25332533- echo "FATAL: Could not locate MSYS2: there was no cygpath" >&2
25342534- exit 3
25352535- fi
25362536- MSYS2_DIR_NATIVE_ESCAPED=$(printf "%s" "$MSYS2_DIR_NATIVE" | sed 's/\\/\\\\/g')
25372537- opamrun option --switch "$do_setenv_SWITCH" setenv+="DiskuvOCamlMSYS2Dir = \"$MSYS2_DIR_NATIVE_ESCAPED\""
25382538- fi
25392539- esac
25402540- section_end "setenv-$do_setenv_SWITCH"
25412541-}
25422542-if [ "${SKIP_OPAM_MODIFICATIONS:-}" = "false" ]; then
25432543- do_setenv dkml
25442544- if [ "${SECONDARY_SWITCH:-}" = "true" ]; then
25452545- do_setenv two
25462546- fi
25472547-fi
25482548-25492549-do_install_compiler() {
25502550- do_install_compiler_NAME=$1
25512551- shift
25522552- section_begin "install-compiler-$do_install_compiler_NAME" "Install OCaml compiler for $do_install_compiler_NAME switch"
25532553- opamrun pin list --switch "$do_install_compiler_NAME"
25542554- # shellcheck disable=SC2086
25552555- opamrun upgrade --switch "$do_install_compiler_NAME" --yes dkml-base-compiler conf-dkml-cross-toolchain ${ocaml_options:-}
25562556- section_end "install-compiler-$do_install_compiler_NAME"
25572557-}
25582558-if [ "${SKIP_OPAM_MODIFICATIONS:-}" = "false" ]; then
25592559- if ! [ "${PRIMARY_SWITCH_SKIP_INSTALL:-}" = "true" ]; then
25602560- do_install_compiler dkml
25612561- fi
25622562- if [ "${SECONDARY_SWITCH:-}" = "true" ]; then
25632563- do_install_compiler two
25642564- fi
25652565-fi
25662566-25672567-do_summary() {
25682568- do_summary_NAME=$1
25692569- shift
25702570- section_begin "summary-$do_summary_NAME" "Summary: $do_summary_NAME switch"
25712571- opamrun var --switch "$do_summary_NAME"
25722572- opamrun exec --switch "$do_summary_NAME" -- ocamlc -config
25732573- section_end "summary-$do_summary_NAME"
25742574-}
25752575-if [ "${SKIP_OPAM_MODIFICATIONS:-}" = "false" ]; then
25762576- do_summary dkml
25772577- if [ "${SECONDARY_SWITCH:-}" = "true" ]; then
25782578- do_summary two
25792579- fi
25802580-fi
25812581-25822582-'@
25832583-Set-Content -Path ".ci\sd4\run-setup-dkml.sh" -Encoding Unicode -Value $Content
25842584-msys64\usr\bin\bash -lc 'dos2unix .ci/sd4/run-setup-dkml.sh'
25852585-25862586-$Content = @'
25872587-# MSVC environment variables:
25882588-# 1. https://docs.microsoft.com/en-us/cpp/build/reference/cl-environment-variables?view=msvc-170
25892589-# 2. https://docs.microsoft.com/en-us/cpp/build/reference/linking?view=msvc-170#link-environment-variables (except TMP)
25902590-# 3. VCToolsRedistDir: https://docs.microsoft.com/en-us/cpp/windows/redistributing-visual-cpp-files?view=msvc-170#locate-the-redistributable-files
25912591-BEGIN{FS="="}
25922592-$1=="CL"||$1=="_CL_"||$1=="INCLUDE"||$1=="LIBPATH" {print "export " $0}
25932593-$1=="LINK"||$1=="_LINK_"||$1=="LIB"||$1=="PATH" {print "export " $0}
25942594-$1=="VCToolsRedistDir" {print "export " $0}
25952595-25962596-'@
25972597-Set-Content -Path ".ci\sd4\msvcenv.awk" -Encoding Unicode -Value $Content
25982598-msys64\usr\bin\bash -lc 'dos2unix .ci/sd4/msvcenv.awk'
25992599-26002600-26012601-$Content = @'
26022602-{
26032603- # trim leading and trailing space
26042604- sub(/^ */, "");
26052605- sub(/ *$/, "");
26062606-26072607- print "export PATH='" $0 "'";
26082608-}
26092609-'@
26102610-Set-Content -Path ".ci\sd4\msvcpath.awk" -Encoding Unicode -Value $Content
26112611-msys64\usr\bin\bash -lc 'dos2unix .ci/sd4/msvcpath.awk'
26122612-26132613-# PowerShell (UTF-16) and Batch (ANSI) scripts
26142614-26152615-26162616-$Content = @'
26172617-# Diagnose Visual Studio environment variables (Windows)
26182618-# This wastes time and has lots of rows! Only run if "VERBOSE" GitHub input key.
26192619-if ( "${env:VERBOSE}" -eq "true" ) {
26202620- if (Test-Path -Path "C:\Program Files (x86)\Windows Kits\10\include") {
26212621- Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\include"
26222622- }
26232623- if (Test-Path -Path "C:\Program Files (x86)\Windows Kits\10\Extension SDKs\WindowsDesktop") {
26242624- Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\Extension SDKs\WindowsDesktop"
26252625- }
26262626-26272627- $env:PSModulePath += "$([System.IO.Path]::PathSeparator).ci\sd4\g\dkml-runtime-distribution\src\windows"
26282628- Import-Module Machine
26292629-26302630- $allinstances = Get-VSSetupInstance
26312631- $allinstances | ConvertTo-Json -Depth 5
26322632-}
26332633-26342634-# Make export expression [SN]NAME=[SV]VALUE[EV]
26352635-# where [SN] is start name and [SV] and [EV] are start and end value
26362636-if (("${env:GITLAB_CI}" -eq "true") -or ("${env:PC_CI}" -eq "true")) {
26372637- # Executed immediately in POSIX shell, so must be a real POSIX shell variable declaration
26382638- $ExportSN = "export "
26392639- $ExportSV = "'"
26402640- $ExportEV = "'"
26412641- $ExportExt = ".sh"
26422642-} else {
26432643- # Goes into $env:GITHUB_ENV, so must be plain NAME=VALUE
26442644- $ExportSN = ""
26452645- $ExportSV = ""
26462646- $ExportEV = ""
26472647- $ExportExt = ".github"
26482648-}
26492649-26502650-# Locate Visual Studio (Windows)
26512651-if ("${env:vsstudio_dir}" -eq "" -and (!(Test-Path -Path .ci/sd4/vsenv${ExportExt}) -or !(Test-Path -Path .ci/sd4/vsenv.ps1))) {
26522652- $env:PSModulePath += "$([System.IO.Path]::PathSeparator).ci\sd4\g\dkml-runtime-distribution\src\windows"
26532653- Import-Module Machine
26542654-26552655- $CompatibleVisualStudios = Get-CompatibleVisualStudios -ErrorIfNotFound
26562656- $CompatibleVisualStudios
26572657- $ChosenVisualStudio = ($CompatibleVisualStudios | Select-Object -First 1)
26582658- $VisualStudioProps = Get-VisualStudioProperties -VisualStudioInstallation $ChosenVisualStudio
26592659- $VisualStudioProps
26602660-26612661- Write-Output "${ExportSN}VS_DIR=${ExportSV}$($VisualStudioProps.InstallPath)${ExportEV}" > .ci/sd4/vsenv${ExportExt}
26622662- Write-Output "${ExportSN}VS_VCVARSVER=${ExportSV}$($VisualStudioProps.VcVarsVer)${ExportEV}" >> .ci/sd4/vsenv${ExportExt}
26632663- Write-Output "${ExportSN}VS_WINSDKVER=${ExportSV}$($VisualStudioProps.WinSdkVer)${ExportEV}" >> .ci/sd4/vsenv${ExportExt}
26642664- Write-Output "${ExportSN}VS_MSVSPREFERENCE=${ExportSV}$($VisualStudioProps.MsvsPreference)${ExportEV}" >> .ci/sd4/vsenv${ExportExt}
26652665- Write-Output "${ExportSN}VS_CMAKEGENERATOR=${ExportSV}$($VisualStudioProps.CMakeGenerator)${ExportEV}" >> .ci/sd4/vsenv${ExportExt}
26662666-26672667- Write-Output "`$env:VS_DIR='$($VisualStudioProps.InstallPath)'" > .ci/sd4/vsenv.ps1
26682668- Write-Output "`$env:VS_VCVARSVER='$($VisualStudioProps.VcVarsVer)'" >> .ci/sd4/vsenv.ps1
26692669- Write-Output "`$env:VS_WINSDKVER='$($VisualStudioProps.WinSdkVer)'" >> .ci/sd4/vsenv.ps1
26702670- Write-Output "`$env:VS_MSVSPREFERENCE='$($VisualStudioProps.MsvsPreference)'" >> .ci/sd4/vsenv.ps1
26712671- Write-Output "`$env:VS_CMAKEGENERATOR='$($VisualStudioProps.CMakeGenerator)'" >> .ci/sd4/vsenv.ps1
26722672-}
26732673-26742674-# Link to hardcoded Visual Studio (Windows)
26752675-if ("${env:vsstudio_dir}" -ne "") {
26762676- Write-Output "${ExportSN}VS_DIR=${ExportSV}${env:vsstudio_dir}${ExportEV}" > .ci/sd4/vsenv${ExportExt}
26772677- Write-Output "${ExportSN}VS_VCVARSVER=${ExportSV}${env:vsstudio_vcvarsver}${ExportEV}" >> .ci/sd4/vsenv${ExportExt}
26782678- Write-Output "${ExportSN}VS_WINSDKVER=${ExportSV}${env:vsstudio_winsdkver}${ExportEV}" >> .ci/sd4/vsenv${ExportExt}
26792679- Write-Output "${ExportSN}VS_MSVSPREFERENCE=${ExportSV}${env:vsstudio_msvspreference}${ExportEV}" >> .ci/sd4/vsenv${ExportExt}
26802680- Write-Output "${ExportSN}VS_CMAKEGENERATOR=${ExportSV}${env:vsstudio_cmakegenerator}${ExportEV}" >> .ci/sd4/vsenv${ExportExt}
26812681-26822682- Write-Output "`$env:VS_DIR='${env:vsstudio_dir}'" > .ci/sd4/vsenv.ps1
26832683- Write-Output "`$env:VS_VCVARSVER='${env:vsstudio_vcvarsver}'" >> .ci/sd4/vsenv.ps1
26842684- Write-Output "`$env:VS_WINSDKVER='${env:vsstudio_winsdkver}'" >> .ci/sd4/vsenv.ps1
26852685- Write-Output "`$env:VS_MSVSPREFERENCE='${env:vsstudio_msvspreference}'" >> .ci/sd4/vsenv.ps1
26862686- Write-Output "`$env:VS_CMAKEGENERATOR='${env:vsstudio_cmakegenerator}'" >> .ci/sd4/vsenv.ps1
26872687-}
26882688-26892689-'@
26902690-Set-Content -Path ".ci\sd4\config-vsstudio.ps1" -Encoding Unicode -Value $Content
26912691-26922692-26932693-$Content = @'
26942694-@ECHO OFF
26952695-26962696-REM The OCaml dkml-base-compiler will compile fine but any other
26972697-REM packages (ocamlbuild, etc.) which
26982698-REM need a native compiler will fail without the MSVC compiler in the
26992699-REM PATH. There isn't a `with-dkml.exe` alternative available at
27002700-REM this stage of the GitHub workflow.
27012701-SET VSCMD_DEBUG=2
27022702-SET VSCMD_SKIP_SENDTELEMETRY=1
27032703-call "%VS_DIR%\Common7\Tools\VsDevCmd.bat" -no_logo -host_arch=%vsstudio_hostarch% -arch=%vsstudio_arch% -vcvars_ver=%VS_VCVARSVER% -winsdk=%VS_WINSDKVER%
27042704-if %ERRORLEVEL% neq 0 (
27052705- echo.
27062706- echo.The "%VS_DIR%\Common7\Tools\VsDevCmd.bat" command failed
27072707- echo.with exit code %ERRORLEVEL%.
27082708- echo.
27092709- exit /b %ERRORLEVEL%
27102710-)
27112711-27122712-REM VsDevCmd.bat turns off echo; be explicit if we want it on or off
27132713-@echo OFF
27142714-27152715-REM MSVC environment variables in Unix format.
27162716-echo %PATH% > .ci\sd4\msvcpath
27172717-27182718-27192719-REM * We can't use `bash -lc` directly to query for all MSVC environment variables
27202720-REM because it stomps over the PATH. So we are inside a Batch script to do the query.
27212721-msys64\usr\bin\bash -lc "set | grep -v '^PATH=' | awk -f .ci/sd4/msvcenv.awk > .ci/sd4/msvcenv"
27222722-'@
27232723-Set-Content -Path ".ci\sd4\get-msvcpath-into-msys2.bat" -Encoding Default -Value $Content
27242724-27252725-msys64\usr\bin\bash -lc "sh .ci/sd4/run-checkout-code.sh PC_PROJECT_DIR '${env:PC_PROJECT_DIR}'"
27262726-if ($LASTEXITCODE -ne 0) {
27272727- throw "run-checkout-code.sh failed"
27282728-}
27292729-27302730-# Diagnose Visual Studio environment variables (Windows)
27312731-# This wastes time and has lots of rows! Only run if "VERBOSE" GitHub input key.
27322732-27332733-If ( "${env:VERBOSE}" -eq "true" ) {
27342734- if (Test-Path -Path "C:\Program Files (x86)\Windows Kits\10\include") {
27352735- Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\include"
27362736- }
27372737- if (Test-Path -Path "C:\Program Files (x86)\Windows Kits\10\Extension SDKs\WindowsDesktop") {
27382738- Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\Extension SDKs\WindowsDesktop"
27392739- }
27402740-27412741- $env:PSModulePath += "$([System.IO.Path]::PathSeparator).ci\sd4\g\dkml-runtime-distribution\src\windows"
27422742- Import-Module Machine
27432743-27442744- $allinstances = Get-VSSetupInstance
27452745- $allinstances | ConvertTo-Json -Depth 5
27462746-}
27472747-.ci\sd4\config-vsstudio.ps1
27482748-msys64\usr\bin\bash -lc "dos2unix .ci/sd4/vsenv.sh"
27492749-Get-Content .ci/sd4/vsenv.sh
27502750-Get-Content .ci/sd4/vsenv.ps1
27512751-27522752-# Capture Visual Studio compiler environment
27532753-& .ci\sd4\vsenv.ps1
27542754-& .ci\sd4\get-msvcpath-into-msys2.bat
27552755-msys64\usr\bin\bash -lc "cat .ci/sd4/msvcpath | tr -d '\r' | cygpath --path -f - | awk -f .ci/sd4/msvcpath.awk >> .ci/sd4/msvcenv"
27562756-msys64\usr\bin\bash -lc "tail -n100 .ci/sd4/msvcpath .ci/sd4/msvcenv"
27572757-27582758-msys64\usr\bin\bash -lc "sh .ci/sd4/run-setup-dkml.sh PC_PROJECT_DIR '${env:PC_PROJECT_DIR}'"
27592759-if ($LASTEXITCODE -ne 0) {
27602760- throw "run-setup-dkml.sh failed"
27612761-}
27622762-27632763-########################### script ###############################
27642764-27652765-Write-Host @"
27662766-Finished setup.
27672767-27682768-To continue your testing, run in PowerShell:
27692769- `$env:CHERE_INVOKING = "yes"
27702770- `$env:MSYSTEM = "$env:msys2_system"
27712771- `$env:dkml_host_abi = "$env:dkml_host_abi"
27722772- `$env:abi_pattern = "$env:abi_pattern"
27732773- `$env:opam_root = "$env:opam_root"
27742774- `$env:exe_ext = "$env:exe_ext"
27752775-27762776-Now you can use 'opamrun' to do opam commands like:
27772777-27782778- msys64\usr\bin\bash -lc 'PATH="`$PWD/.ci/sd4/opamrun:`$PATH"; opamrun install XYZ.opam'
27792779- msys64\usr\bin\bash -lc 'PATH="`$PWD/.ci/sd4/opamrun:`$PATH"; opamrun exec -- bash'
27802780- msys64\usr\bin\bash -lc 'sh ci/build-test.sh'
27812781-"@
-6
.gitattributes
···2233# Shell scripts are required to be LF
44*.sh text eol=lf
55-66-# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-7.1
77-*.ps1 text working-tree-encoding=UTF-16 eol=crlf
88-*.psm1 text working-tree-encoding=UTF-16 eol=crlf
99-# Other file types that must be CRLF
1010-*.sln text eol=crlf
-103
.github/workflows/dkml.yml
···11-##########################################################################
22-# File: dktool/cmake/scripts/dkml/workflow/compilers-github-workflows-dkml.in.yml#
33-# #
44-# Copyright 2022 Diskuv, Inc. #
55-# #
66-# Licensed under the Apache License, Version 2.0 (the "License"); #
77-# you may not use this file except in compliance with the License. #
88-# You may obtain a copy of the License at #
99-# #
1010-# http://www.apache.org/licenses/LICENSE-2.0 #
1111-# #
1212-# Unless required by applicable law or agreed to in writing, software #
1313-# distributed under the License is distributed on an "AS IS" BASIS, #
1414-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or #
1515-# implied. See the License for the specific language governing #
1616-# permissions and limitations under the License. #
1717-# #
1818-##########################################################################
1919-2020-# Updating
2121-# --------
2222-#
2323-# 1. Delete this file.
2424-# 2. Run dk with your original arguments:
2525-# ./dk dkml.workflow.compilers CI GitHub Desktop OS Windows
2626-# or get help to come up with new arguments:
2727-# ./dk dkml.workflow.compilers HELP
2828-2929-name: Build with DkML compiler
3030-3131-on:
3232- # trigger on any push or pull request
3333- push:
3434- pull_request:
3535- # ... or trigger manually from GitHub web interface
3636- workflow_dispatch:
3737-3838-jobs:
3939- build:
4040- strategy:
4141- matrix:
4242- include: #
4343- - gh_os: windows-2019
4444- abi_pattern: win32-windows_x86
4545- dkml_host_abi: windows_x86
4646- - gh_os: windows-2019
4747- abi_pattern: win32-windows_x86_64
4848- dkml_host_abi: windows_x86_64
4949-5050- runs-on: ${{ matrix.gh_os }}
5151- name: build / ${{ matrix.abi_pattern }}
5252-5353- steps:
5454- - name: Checkout code
5555- uses: actions/checkout@v3
5656-5757- - name: Cache DkML compilers code
5858- uses: actions/cache@v3
5959- id: cache-dkml-compilers
6060- with:
6161- path: .ci/dkml-compilers
6262- key: ${{ runner.os }}
6363-6464- - name: Checkout DkML compilers code
6565- if: steps.cache-dkml-compilers.outputs.cache-hit != 'true'
6666- # For help: ./dk dkml.workflow.compilers HELP
6767- run: ./dk dkml.workflow.compilers CI GitHub
6868-6969- # The .ci/dkml-compilers "pre" actions will create the environment variables:
7070- # opam_root, exe_ext, dkml_host_abi, abi_pattern (and many more)
7171- #
7272- - name: Setup DkML compilers on a Windows host
7373- if: startsWith(matrix.dkml_host_abi, 'windows_')
7474- uses: ./.ci/dkml-compilers/gh-windows/pre
7575- with:
7676- DKML_COMPILER: ${{ env.DKML_COMPILER }}
7777- CACHE_PREFIX: ${{ env.CACHE_PREFIX }}
7878-7979- # This section is for your own build logic which you should place in
8080- # ci/build-test.sh or a similar file
8181-8282- - name: Build and test on Windows host
8383- if: startsWith(matrix.dkml_host_abi, 'windows_')
8484- shell: msys2 {0}
8585- run: ci/build-test.sh
8686-8787- - name: Build and test on non-Windows host
8888- if: "!startsWith(matrix.dkml_host_abi, 'windows_')"
8989- run: ci/build-test.sh
9090-9191- # The .ci/dkml-compilers "post" actions will finalize caching, etc.
9292-9393- - name: Teardown DkML compilers on a Windows host
9494- if: startsWith(matrix.dkml_host_abi, 'windows_')
9595- uses: ./.ci/dkml-compilers/gh-windows/post
9696-9797- - name: Teardown DkML compilers on a Darwin host
9898- if: startsWith(matrix.dkml_host_abi, 'darwin_')
9999- uses: ./.ci/dkml-compilers/gh-darwin/post
100100-101101- - name: Teardown DkML compilers on a Linux host
102102- if: startsWith(matrix.dkml_host_abi, 'linux_')
103103- uses: ./.ci/dkml-compilers/gh-linux/post
+1-10
.gitignore
···1515mirage/.mirage.config
1616_opam
1717*.install
1818-1919-# CI using dkml-workflows' DkML compilers.
2020-# DkML compilers populate the .opam folder.
2121-/.opam/
2222-# GitHub, unlike GitLab, does not need its CI files to exist
2323-# before referencing them. That means the GitHub scripts do not need
2424-# to be checked in.
2525-/.ci/dkml-compilers/gh-*
2626-# Desktop testing on Windows uses MSYS2.
2727-/msys64/
1818+.opam/
-96
ci/build-test.sh
···11-#!/bin/sh
22-##########################################################################
33-# File: dktool/cmake/scripts/dkml/workflow/compilers-build-test.in.sh #
44-# #
55-# Copyright 2022 Diskuv, Inc. #
66-# #
77-# Licensed under the Apache License, Version 2.0 (the "License"); #
88-# you may not use this file except in compliance with the License. #
99-# You may obtain a copy of the License at #
1010-# #
1111-# http://www.apache.org/licenses/LICENSE-2.0 #
1212-# #
1313-# Unless required by applicable law or agreed to in writing, software #
1414-# distributed under the License is distributed on an "AS IS" BASIS, #
1515-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or #
1616-# implied. See the License for the specific language governing #
1717-# permissions and limitations under the License. #
1818-# #
1919-##########################################################################
2020-2121-# Updating
2222-# --------
2323-#
2424-# 1. Delete this file.
2525-# 2. Run dk with your original arguments:
2626-# ./dk dkml.workflow.compilers CI GitHub Desktop OS Windows
2727-# or get help to come up with new arguments:
2828-# ./dk dkml.workflow.compilers HELP
2929-3030-set -euf
3131-3232-# Set project directory
3333-if [ -n "${CI_PROJECT_DIR:-}" ]; then
3434- PROJECT_DIR="$CI_PROJECT_DIR"
3535-elif [ -n "${PC_PROJECT_DIR:-}" ]; then
3636- PROJECT_DIR="$PC_PROJECT_DIR"
3737-elif [ -n "${GITHUB_WORKSPACE:-}" ]; then
3838- PROJECT_DIR="$GITHUB_WORKSPACE"
3939-else
4040- PROJECT_DIR="$PWD"
4141-fi
4242-if [ -x /usr/bin/cygpath ]; then
4343- PROJECT_DIR=$(/usr/bin/cygpath -au "$PROJECT_DIR")
4444-fi
4545-4646-# shellcheck disable=SC2154
4747-echo "
4848-=============
4949-build-test.sh
5050-=============
5151-.
5252----------
5353-Arguments
5454----------
5555-$*
5656-.
5757-------
5858-Matrix
5959-------
6060-dkml_host_abi=$dkml_host_abi
6161-abi_pattern=$abi_pattern
6262-opam_root=$opam_root
6363-exe_ext=${exe_ext:-}
6464-.
6565-"
6666-6767-# PATH. Add opamrun
6868-export PATH="$PROJECT_DIR/.ci/sd4/opamrun:$PATH"
6969-7070-# Initial Diagnostics (optional but useful)
7171-opamrun switch
7272-opamrun list
7373-opamrun var
7474-opamrun config report
7575-opamrun option
7676-opamrun exec -- ocamlc -config
7777-7878-# Update
7979-opamrun update
8080-8181-# Build logic
8282-# 2024-02-09: Remove mirage-crypto-pk on Windows since no portable GMP library (used by Zarith).
8383-# 2024-02-24: Remove mirage-crypto-ec on Windows since it results in test failures.
8484-packages_TOPOLOGICALSORT="mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-mirage"
8585-case "$dkml_host_abi" in
8686- windows_*)
8787- packages_TOPOLOGICALSORT="$packages_TOPOLOGICALSORT"
8888- ;;
8989- *)
9090- packages_TOPOLOGICALSORT="$packages_TOPOLOGICALSORT,mirage-crypto-pk,mirage-crypto-ec"
9191-esac
9292-# shellcheck disable=SC2086
9393-opamrun pin add -y -n .
9494-opamrun install --yes --deps-only --with-test $(echo $packages_TOPOLOGICALSORT | tr ',' ' ')
9595-opamrun exec -- dune build -p "$packages_TOPOLOGICALSORT"
9696-opamrun exec -- dune runtest -p "$packages_TOPOLOGICALSORT"
-235
cmake/FindDkToolScripts.cmake
···11-##########################################################################
22-# File: dktool/cmake/FindDkToolScripts.cmake #
33-# #
44-# Copyright 2023 Diskuv, Inc. #
55-# #
66-# Licensed under the Apache License, Version 2.0 (the "License"); #
77-# you may not use this file except in compliance with the License. #
88-# You may obtain a copy of the License at #
99-# #
1010-# http://www.apache.org/licenses/LICENSE-2.0 #
1111-# #
1212-# Unless required by applicable law or agreed to in writing, software #
1313-# distributed under the License is distributed on an "AS IS" BASIS, #
1414-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or #
1515-# implied. See the License for the specific language governing #
1616-# permissions and limitations under the License. #
1717-# #
1818-##########################################################################
1919-2020-# Recommendation: Place this file in source control.
2121-# Auto-generated by `./dk dksdk.project.new` of dktool.
2222-2323-include(FetchContent)
2424-2525-function(parse_dktool_command_line)
2626- # The first argument is <command>. All dots will be replaced with a
2727- # triple underscore as a convenience and to be pretty for the user.
2828- # However, we do not error if no <command> is given ... we'll do
2929- # that later.
3030- set(command)
3131- set(expected_function_name)
3232- set(quotedArgs "")
3333- if(ARGC EQUAL 0 OR (ARGC EQUAL 1 AND ARGV0 STREQUAL HELP))
3434- message(NOTICE [[Usage:
3535- ./dk <command> HELP
3636- ./dk <command> [args]
3737-]])
3838- else()
3939- set(command ${ARGV0})
4040- string(REPLACE "." "___" expected_function_name ${command})
4141- message(VERBOSE "Searching for ${expected_function_name}")
4242-4343- # Parse the remainder of the arguments [args]
4444- # * Use technique from [Professional CMake: A Practical Guide - Forwarding Command Arguments]
4545- # to be able to forward arguments correctly to an inner function (the <command> function).
4646- cmake_parse_arguments(PARSE_ARGV 1 FWD "" "" "")
4747- foreach(arg IN LISTS FWD_UNPARSED_ARGUMENTS)
4848- string(APPEND quotedArgs " [===[${arg}]===]")
4949- endforeach()
5050- endif()
5151-5252- # Set policies (we are in a new EVAL CODE context)
5353- # Included scripts do automatic cmake_policy PUSH and POP
5454- if(POLICY CMP0011)
5555- cmake_policy(SET CMP0011 NEW)
5656- endif()
5757- # Allow GIT_SUBMODULES empty to mean no submodules
5858- if(POLICY CMP0097)
5959- cmake_policy(SET CMP0097 NEW)
6060- endif()
6161-6262- # Setup the binary directory
6363- if(NOT DKTOOL_WORKDIR)
6464- message(FATAL_ERROR "Illegal state. Expecting DKTOOL_WORKDIR")
6565- endif()
6666- set(CMAKE_BINARY_DIR ${DKTOOL_WORKDIR})
6767- set(CMAKE_CURRENT_BINARY_DIR ${CMAKE_BINARY_DIR})
6868-6969- # Search in all the user scripts
7070- set(dot_function_names)
7171- file(GLOB_RECURSE command_files
7272- LIST_DIRECTORIES FALSE
7373- RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/scripts
7474- cmake/scripts/*.cmake)
7575- foreach(command_file IN LISTS command_files)
7676- # Normalize and lowercase
7777- cmake_path(NORMAL_PATH command_file)
7878- string(TOLOWER "${command_file}" command_file)
7979- cmake_path(REMOVE_EXTENSION command_file OUTPUT_VARIABLE command_file_no_ext)
8080-8181- # Convert to list
8282- string(REPLACE "/" ";" command_stems_no_namespace ${command_file_no_ext})
8383-8484- # Make a pretty description only for validation
8585- set(pretty_stems ${command_stems_no_namespace})
8686- list(TRANSFORM pretty_stems PREPEND "'")
8787- list(TRANSFORM pretty_stems APPEND "'")
8888- string(JOIN ", " pretty_stems_str ${pretty_stems})
8989- string(REGEX REPLACE ",([^,]*)" " and \\1" pretty_stems_str "${pretty_stems_str}")
9090-9191- # Validate that only alphanumeric with underscores (but not the reserved three underscores)
9292- string(REGEX MATCH "[/a-z0-9_]*" only_alphanum_and_underscores "${command_file_no_ext}")
9393- if(NOT only_alphanum_and_underscores STREQUAL "${command_file_no_ext}")
9494- message(WARNING "Ignoring user script ${CMAKE_CURRENT_SOURCE_DIR}/${command_file}.
9595-The stems of the user script (${pretty_stems_str}) must only contain letters, numbers and underscores.")
9696- continue()
9797- endif()
9898- string(FIND "${command_file_no_ext}" "___" reserved_underscores)
9999- if(reserved_underscores GREATER_EQUAL 0)
100100- message(WARNING "Ignoring user script ${CMAKE_CURRENT_SOURCE_DIR}/${command_file}.
101101-No stem of the user script (${pretty_stems_str}) can contain a triple underscore ('___').")
102102- continue()
103103- endif()
104104-105105- # Translate dev/xxx.cmake to the "user" namespaced function name
106106- # `user__dev__xxx` and `user.dev.xxx`.
107107- set(command_stems ${command_stems_no_namespace})
108108- list(PREPEND command_stems "user")
109109- string(JOIN "___" command_function_name ${command_stems})
110110- string(JOIN "." dot_function_name ${command_stems})
111111- list(APPEND dot_function_names ${dot_function_name})
112112-113113- # In a new scope (to avoid a global, leaky namespace) register the function.
114114- message(VERBOSE "Shimming ${command_function_name}")
115115- cmake_language(EVAL CODE "
116116-function(${command_function_name})
117117- include(\"${CMAKE_CURRENT_SOURCE_DIR}/cmake/scripts/${command_file}\")
118118- if(COMMAND run)
119119- run(${quotedArgs})
120120- else()
121121- message(FATAL_ERROR [[The user script ${CMAKE_CURRENT_SOURCE_DIR}/cmake/scripts/${command_file} was missing:
122122- function(run)
123123- # Your user code
124124- endfunction()
125125-]])
126126- endif()
127127-endfunction()
128128-")
129129- endforeach()
130130-131131- # Include all the system scripts.
132132- # - Since the system scripts come after the user scripts, the user scripts
133133- # don't override the system scripts unless the user scripts use deferred
134134- # hooks or redefine CMake built-in functions. Regardless, the user
135135- # scripts are namespaced with `user__` prefix
136136- if(NOT IS_DIRECTORY cmake/scripts/dksdk)
137137- # If this project (ex. dktool) has the system scripts, it must
138138- # have all of them. Otherwise we download the system scripts.
139139- FetchContent_Populate(dktool
140140- QUIET
141141- GIT_REPOSITORY https://gitlab.com/diskuv/dktool.git
142142- GIT_TAG 1.0
143143- # As of 3.25.3 the bug https://gitlab.kitware.com/cmake/cmake/-/issues/24578
144144- # has still not been fixed. That means empty strings get removed.
145145- # ExternalProject_Add(GIT_SUBMODULES) in dktool-subbuild/CMakeLists.txt
146146- # means fetch all submodules.
147147- # https://gitlab.kitware.com/cmake/cmake/-/issues/20579#note_734045
148148- # has a workaround.
149149- GIT_SUBMODULES cmake # Non-git-submodule dir that already exists
150150- GIT_SUBMODULES_RECURSE OFF
151151- )
152152- file(GLOB_RECURSE system_command_files
153153- LIST_DIRECTORIES FALSE
154154- RELATIVE ${dktool_SOURCE_DIR}/cmake/scripts
155155- ${dktool_SOURCE_DIR}/cmake/scripts/dkml/*.cmake
156156- ${dktool_SOURCE_DIR}/cmake/scripts/dksdk/*.cmake)
157157- foreach(command_file IN LISTS system_command_files)
158158- # Normalize and lowercase
159159- cmake_path(NORMAL_PATH command_file)
160160- string(TOLOWER "${command_file}" command_file)
161161- cmake_path(REMOVE_EXTENSION command_file OUTPUT_VARIABLE command_file_no_ext)
162162-163163- # Convert to list
164164- string(REPLACE "/" ";" command_stems_no_namespace ${command_file_no_ext})
165165-166166- # Translate dksdk/xxx.cmake to the function name `dksdk__xxx` and `dksdk.xxx`
167167- set(command_stems ${command_stems_no_namespace})
168168- string(JOIN "___" command_function_name ${command_stems})
169169- string(JOIN "." dot_function_name ${command_stems})
170170- list(APPEND dot_function_names ${dot_function_name})
171171-172172- # In a new scope (to avoid a global, leaky namespace) register the function.
173173- message(VERBOSE "Shimming ${command_function_name}")
174174- cmake_language(EVAL CODE "
175175-function(${command_function_name})
176176- include(\"${dktool_SOURCE_DIR}/cmake/scripts/${command_file}\")
177177- if(COMMAND run)
178178- run(${quotedArgs})
179179- else()
180180- message(FATAL_ERROR [[The system script ${dktool_SOURCE_DIR}/cmake/scripts/${command_file} was missing:
181181- function(run)
182182- # The system code
183183- endfunction()
184184-]])
185185- endif()
186186-endfunction()
187187-")
188188-189189- endforeach()
190190- endif()
191191-192192- # Pretty function names that are available
193193- set(pretty_function_names ${dot_function_names})
194194- list(TRANSFORM pretty_function_names PREPEND " ")
195195- list(TRANSFORM pretty_function_names APPEND "\n")
196196- string(JOIN "" str_pretty_function_names ${pretty_function_names})
197197-198198- # Exit if no <command>
199199- if(NOT command)
200200- message(NOTICE "The following commands are available:
201201-${str_pretty_function_names}")
202202- return()
203203- endif()
204204-205205- # Validate the <command> exists
206206- if(NOT COMMAND ${expected_function_name})
207207- message(FATAL_ERROR "No command '${command}' exists. The following commands are available:
208208-${str_pretty_function_names}")
209209- message(FATAL_ERROR "No command '${command}' exists")
210210- endif()
211211-212212- # Call the <command> function
213213- cmake_language(EVAL CODE "${expected_function_name}()")
214214-endfunction()
215215-216216-# DkML data home
217217-if(WIN32)
218218- set(DKML_DATA_HOME "$ENV{LOCALAPPDATA}/Programs/DiskuvOCaml")
219219-elseif(DEFINED ENV{XDG_DATA_HOME})
220220- set(DKML_DATA_HOME "$ENV{XDG_DATA_HOME}/diskuv-ocaml")
221221-else()
222222- set(DKML_DATA_HOME "$ENV{HOME}/.local/share/diskuv-ocaml")
223223-endif()
224224-225225-# DkSDK data home
226226-if(WIN32)
227227- set(DKSDK_DATA_HOME "$ENV{LOCALAPPDATA}/Programs/DkSDK")
228228-elseif(DEFINED ENV{XDG_DATA_HOME})
229229- set(DKSDK_DATA_HOME "$ENV{XDG_DATA_HOME}/dksdk")
230230-else()
231231- set(DKSDK_DATA_HOME "$ENV{HOME}/.local/share/dksdk")
232232-endif()
233233-234234-# Splat DKTOOL_CMDLINE
235235-cmake_language(EVAL CODE "parse_dktool_command_line(${DKTOOL_CMDLINE})")
-723
dk
···11-#!/bin/sh
22-##########################################################################
33-# File: dktool/dk #
44-# #
55-# Copyright 2023 Diskuv, Inc. #
66-# #
77-# Licensed under the Apache License, Version 2.0 (the "License"); #
88-# you may not use this file except in compliance with the License. #
99-# You may obtain a copy of the License at #
1010-# #
1111-# http://www.apache.org/licenses/LICENSE-2.0 #
1212-# #
1313-# Unless required by applicable law or agreed to in writing, software #
1414-# distributed under the License is distributed on an "AS IS" BASIS, #
1515-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or #
1616-# implied. See the License for the specific language governing #
1717-# permissions and limitations under the License. #
1818-# #
1919-##########################################################################
2020-2121-# Recommendation: Place this file in source control.
2222-# Auto-generated by `./dk dksdk.project.new` of dktool.
2323-#
2424-# Invoking: ./dk
2525-# That works in Powershell on Windows, and in Unix. Copy-and-paste works!
2626-#
2727-# Purpose: Install CMake if not already. Then invoke CMake.
2828-2929-set -euf
3030-3131-dk_pwd=$PWD
3232-3333-# --- Imports of dkml-runtime-common's crossplatform-functions.sh ---
3434-3535-# Get standard locations of Unix system binaries like `/usr/bin/mv` (or `/bin/mv`).
3636-#
3737-# Will not return anything in `/usr/local/bin` or `/usr/sbin`. Use when you do not
3838-# know whether the PATH has been set correctly, or when you do not know if the
3939-# system binary exists.
4040-#
4141-# At some point in the future, this function will error out if the required system binaries
4242-# do not exist. Most system binaries are common to all Unix/Linux/macOS installations but
4343-# some (like `comm`) may need to be installed for proper functioning of DKML.
4444-#
4545-# Outputs:
4646-# - env:DKMLSYS_MV - Location of `mv`
4747-# - env:DKMLSYS_CHMOD - Location of `chmod`
4848-# - env:DKMLSYS_UNAME - Location of `uname`
4949-# - env:DKMLSYS_ENV - Location of `env`
5050-# - env:DKMLSYS_AWK - Location of `awk`
5151-# - env:DKMLSYS_SED - Location of `sed`
5252-# - env:DKMLSYS_COMM - Location of `comm`
5353-# - env:DKMLSYS_INSTALL - Location of `install`
5454-# - env:DKMLSYS_RM - Location of `rm`
5555-# - env:DKMLSYS_SORT - Location of `sort`
5656-# - env:DKMLSYS_CAT - Location of `cat`
5757-# - env:DKMLSYS_STAT - Location of `stat`
5858-# - env:DKMLSYS_GREP - Location of `grep`
5959-# - env:DKMLSYS_CURL - Location of `curl` (empty if not found)
6060-# - env:DKMLSYS_WGET - Location of `wget` (empty if not found)
6161-# - env:DKMLSYS_TR - Location of `tr`
6262-autodetect_system_binaries() {
6363- if [ -z "${DKMLSYS_MV:-}" ]; then
6464- if [ -x /usr/bin/mv ]; then
6565- DKMLSYS_MV=/usr/bin/mv
6666- else
6767- DKMLSYS_MV=/bin/mv
6868- fi
6969- fi
7070- if [ -z "${DKMLSYS_CHMOD:-}" ]; then
7171- if [ -x /usr/bin/chmod ]; then
7272- DKMLSYS_CHMOD=/usr/bin/chmod
7373- else
7474- DKMLSYS_CHMOD=/bin/chmod
7575- fi
7676- fi
7777- if [ -z "${DKMLSYS_UNAME:-}" ]; then
7878- if [ -x /usr/bin/uname ]; then
7979- DKMLSYS_UNAME=/usr/bin/uname
8080- else
8181- DKMLSYS_UNAME=/bin/uname
8282- fi
8383- fi
8484- if [ -z "${DKMLSYS_ENV:-}" ]; then
8585- if [ -x /usr/bin/env ]; then
8686- DKMLSYS_ENV=/usr/bin/env
8787- else
8888- DKMLSYS_ENV=/bin/env
8989- fi
9090- fi
9191- if [ -z "${DKMLSYS_AWK:-}" ]; then
9292- if [ -x /usr/bin/awk ]; then
9393- DKMLSYS_AWK=/usr/bin/awk
9494- else
9595- DKMLSYS_AWK=/bin/awk
9696- fi
9797- fi
9898- if [ -z "${DKMLSYS_SED:-}" ]; then
9999- if [ -x /usr/bin/sed ]; then
100100- DKMLSYS_SED=/usr/bin/sed
101101- else
102102- DKMLSYS_SED=/bin/sed
103103- fi
104104- fi
105105- if [ -z "${DKMLSYS_COMM:-}" ]; then
106106- if [ -x /usr/bin/comm ]; then
107107- DKMLSYS_COMM=/usr/bin/comm
108108- else
109109- DKMLSYS_COMM=/bin/comm
110110- fi
111111- fi
112112- if [ -z "${DKMLSYS_INSTALL:-}" ]; then
113113- if [ -x /usr/bin/install ]; then
114114- DKMLSYS_INSTALL=/usr/bin/install
115115- else
116116- DKMLSYS_INSTALL=/bin/install
117117- fi
118118- fi
119119- if [ -z "${DKMLSYS_RM:-}" ]; then
120120- if [ -x /usr/bin/rm ]; then
121121- DKMLSYS_RM=/usr/bin/rm
122122- else
123123- DKMLSYS_RM=/bin/rm
124124- fi
125125- fi
126126- if [ -z "${DKMLSYS_SORT:-}" ]; then
127127- if [ -x /usr/bin/sort ]; then
128128- DKMLSYS_SORT=/usr/bin/sort
129129- else
130130- DKMLSYS_SORT=/bin/sort
131131- fi
132132- fi
133133- if [ -z "${DKMLSYS_CAT:-}" ]; then
134134- if [ -x /usr/bin/cat ]; then
135135- DKMLSYS_CAT=/usr/bin/cat
136136- else
137137- DKMLSYS_CAT=/bin/cat
138138- fi
139139- fi
140140- if [ -z "${DKMLSYS_STAT:-}" ]; then
141141- if [ -x /usr/bin/stat ]; then
142142- DKMLSYS_STAT=/usr/bin/stat
143143- else
144144- DKMLSYS_STAT=/bin/stat
145145- fi
146146- fi
147147- if [ -z "${DKMLSYS_GREP:-}" ]; then
148148- if [ -x /usr/bin/grep ]; then
149149- DKMLSYS_GREP=/usr/bin/grep
150150- else
151151- DKMLSYS_GREP=/bin/grep
152152- fi
153153- fi
154154- if [ -z "${DKMLSYS_CURL:-}" ]; then
155155- if [ -x /usr/bin/curl ]; then
156156- DKMLSYS_CURL=/usr/bin/curl
157157- elif [ -x /bin/curl ]; then
158158- DKMLSYS_CURL=/bin/curl
159159- else
160160- DKMLSYS_CURL=
161161- fi
162162- fi
163163- if [ -z "${DKMLSYS_WGET:-}" ]; then
164164- if [ -x /usr/bin/wget ]; then
165165- DKMLSYS_WGET=/usr/bin/wget
166166- elif [ -x /bin/wget ]; then
167167- DKMLSYS_WGET=/bin/wget
168168- else
169169- DKMLSYS_WGET=
170170- fi
171171- fi
172172- if [ -z "${DKMLSYS_TR:-}" ]; then
173173- if [ -x /usr/bin/tr ]; then
174174- DKMLSYS_TR=/usr/bin/tr
175175- else
176176- DKMLSYS_TR=/bin/tr
177177- fi
178178- fi
179179- export DKMLSYS_MV DKMLSYS_CHMOD DKMLSYS_UNAME DKMLSYS_ENV DKMLSYS_AWK DKMLSYS_SED DKMLSYS_COMM DKMLSYS_INSTALL
180180- export DKMLSYS_RM DKMLSYS_SORT DKMLSYS_CAT DKMLSYS_STAT DKMLSYS_GREP DKMLSYS_CURL DKMLSYS_WGET DKMLSYS_TR
181181-}
182182-183183-# Is a Windows build machine if we are in a MSYS2 or Cygwin environment.
184184-#
185185-# Better alternatives
186186-# -------------------
187187-#
188188-# 1. If you are checking to see if you should do a cygpath, then just guard it
189189-# like so:
190190-# if [ -x /usr/bin/cygpath ]; then
191191-# do_something $(/usr/bin/cygpath ...) ...
192192-# fi
193193-# This clearly guards what you are about to do (cygpath) with what you will
194194-# need (cygpath).
195195-# 2. is_arg_windows_platform
196196-is_unixy_windows_build_machine() {
197197- if is_msys2_msys_build_machine || is_cygwin_build_machine; then
198198- return 0
199199- fi
200200- return 1
201201-}
202202-203203-# Is a MSYS2 environment with the MSYS or MINGW64 subsystem?
204204-# * MSYS2 can also do MinGW 32-bit and 64-bit subsystems. Used by Diskuv OCaml
205205-# * MINGW64 used by Git Bash (aka. GitHub Actions `shell: bash`)
206206-# https://www.msys2.org/docs/environments/
207207-is_msys2_msys_build_machine() {
208208- if [ -e /usr/bin/msys-2.0.dll ] && {
209209- [ "${MSYSTEM:-}" = "MSYS" ] || [ "${MSYSTEM:-}" = "MINGW64" ] || [ "${MSYSTEM:-}" = "UCRT64" ] || [ "${MSYSTEM:-}" = "CLANG64" ] || [ "${MSYSTEM:-}" = "MINGW32" ] || [ "${MSYSTEM:-}" = "CLANG32" ] || [ "${MSYSTEM:-}" = "CLANGARM64" ]
210210- }; then
211211- return 0
212212- fi
213213- return 1
214214-}
215215-216216-is_cygwin_build_machine() {
217217- if [ -e /usr/bin/cygwin1.dll ]; then
218218- return 0
219219- fi
220220- return 1
221221-}
222222-223223-# Tries to find the host ABI.
224224-#
225225-# Beware: This function uses `uname` probing which is inaccurate during
226226-# cross-compilation.
227227-#
228228-# Outputs:
229229-# - env:BUILDHOST_ARCH will contain the host ABI.
230230-autodetect_buildhost_arch() {
231231- # Set DKMLSYS_*
232232- autodetect_system_binaries
233233-234234- autodetect_buildhost_arch_SYSTEM=$("$DKMLSYS_UNAME" -s)
235235- autodetect_buildhost_arch_MACHINE=$("$DKMLSYS_UNAME" -m)
236236- # list from https://en.wikipedia.org/wiki/Uname and https://stackoverflow.com/questions/45125516/possible-values-for-uname-m
237237- case "${autodetect_buildhost_arch_SYSTEM}-${autodetect_buildhost_arch_MACHINE}" in
238238- Linux-armv7*)
239239- BUILDHOST_ARCH=linux_arm32v7;;
240240- Linux-armv6* | Linux-arm)
241241- BUILDHOST_ARCH=linux_arm32v6;;
242242- Linux-aarch64 | Linux-arm64 | Linux-armv8*)
243243- BUILDHOST_ARCH=linux_arm64;;
244244- Linux-i386 | Linux-i686)
245245- BUILDHOST_ARCH=linux_x86;;
246246- Linux-x86_64)
247247- BUILDHOST_ARCH=linux_x86_64;;
248248- Darwin-arm64)
249249- BUILDHOST_ARCH=darwin_arm64;;
250250- Darwin-x86_64)
251251- BUILDHOST_ARCH=darwin_x86_64;;
252252- *-i386 | *-i686)
253253- if is_unixy_windows_build_machine; then
254254- BUILDHOST_ARCH=windows_x86
255255- else
256256- printf "%s\n" "FATAL: Unsupported build machine type obtained from 'uname -s' and 'uname -m': $autodetect_buildhost_arch_SYSTEM and $autodetect_buildhost_arch_MACHINE" >&2
257257- exit 1
258258- fi
259259- ;;
260260- *-x86_64)
261261- if is_unixy_windows_build_machine; then
262262- BUILDHOST_ARCH=windows_x86_64
263263- else
264264- printf "%s\n" "FATAL: Unsupported build machine type obtained from 'uname -s' and 'uname -m': $autodetect_buildhost_arch_SYSTEM and $autodetect_buildhost_arch_MACHINE" >&2
265265- exit 1
266266- fi
267267- ;;
268268- *)
269269- # Since:
270270- # 1) MSYS2 does not run on ARM/ARM64 (https://www.msys2.org/docs/environments/)
271271- # 2) MSVC does not use ARM/ARM64 as host machine (https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-160)
272272- # we do not support Windows ARM/ARM64 as a build machine
273273- printf "%s\n" "FATAL: Unsupported build machine type obtained from 'uname -s' and 'uname -m': $autodetect_buildhost_arch_SYSTEM and $autodetect_buildhost_arch_MACHINE" >&2
274274- exit 1
275275- ;;
276276- esac
277277-}
278278-279279-# A function that will try to print an ISO8601 timestamp, but will fallback to
280280-# the system default. Always uses UTC timezone.
281281-try_iso8601_timestamp() {
282282- date -u -Iseconds 2>/dev/null || TZ=UTC date
283283-}
284284-285285-# A function that will print the command and possibly time it (if and only if it uses a full path to
286286-# an executable, so that 'time' does not fail on internal shell functions).
287287-# If --return-error-code is the first argument or LOG_TRACE_RETURN_ERROR_CODE=ON, then instead of exiting the
288288-# function will return the error code.
289289-log_trace() {
290290- log_trace_RETURN=${LOG_TRACE_RETURN_ERROR_CODE:-OFF}
291291-292292- log_trace_1="$1"
293293- if [ "$log_trace_1" = "--return-error-code" ]; then
294294- shift
295295- log_trace_RETURN=ON
296296- fi
297297-298298- if [ "${DKML_BUILD_TRACE:-OFF}" = ON ]; then
299299- printf "[%s] %s\n" "$(try_iso8601_timestamp)" "+ $*" >&2
300300- if [ -x "$1" ]; then
301301- time "$@"
302302- else
303303- "$@"
304304- fi
305305- else
306306- # use judgement so we essentially have log at an INFO level
307307- case "$1" in
308308- rm|cp)
309309- # debug level. only show when DKML_BUILD_TRACE=ON
310310- ;;
311311- git|make|ocaml_configure|ocaml_make|make_host|make_target)
312312- # info level. and can show entire command without polluting the screen
313313- printf "[%s] %s\n" "$(try_iso8601_timestamp)" "$*" >&2
314314- ;;
315315- *) printf "[%s] %s\n" "$(try_iso8601_timestamp)" "$1" >&2
316316- esac
317317- "$@"
318318- fi
319319- log_trace_ec="$?"
320320- if [ "$log_trace_ec" -ne 0 ]; then
321321- if [ "$log_trace_RETURN" = ON ]; then
322322- return "$log_trace_ec"
323323- else
324324- printf "FATAL: Command failed with exit code %s: %s\n" "$log_trace_ec" "$*" >&2
325325- exit "$log_trace_ec"
326326- fi
327327- fi
328328-}
329329-330330-# [sha256compute FILE] writes the SHA256 checksum (hex encoded) of file FILE to the standard output.
331331-sha256compute() {
332332- sha256compute_FILE="$1"
333333- shift
334334- # For reasons unclear doing the following in MSYS2:
335335- # sha256sum 'Z:\source\README.md'
336336- # will produce a backslash like:
337337- # \5518c76ed7234a153941fb7bc94b6e91d9cb8f1c4e22daf169a59b5878c3fc8a *Z:\\source\\README.md
338338- # So always cygpath the filename if available
339339- if [ -x /usr/bin/cygpath ]; then
340340- sha256compute_FILE=$(/usr/bin/cygpath -a "$sha256compute_FILE")
341341- fi
342342-343343- if [ -x /usr/bin/shasum ]; then
344344- /usr/bin/shasum -a 256 "$sha256compute_FILE" | awk '{print $1}'
345345- elif [ -x /usr/bin/sha256sum ]; then
346346- /usr/bin/sha256sum "$sha256compute_FILE" | awk '{print $1}'
347347- else
348348- printf "FATAL: %s\n" "No sha256 checksum utility found" >&2
349349- exit 107
350350- fi
351351-}
352352-353353-# [sha256check FILE SUM] checks that the file FILE has a SHA256 checksum (hex encoded) of SUM.
354354-# The function will return nonzero (and exit with failure if `set -e` is enabled) if the checksum does not match.
355355-sha256check() {
356356- sha256check_FILE="$1"
357357- shift
358358- sha256check_SUM="$1"
359359- shift
360360- if [ -x /usr/bin/shasum ]; then
361361- printf "%s %s" "$sha256check_SUM" "$sha256check_FILE" | /usr/bin/shasum -a 256 -c >&2
362362- elif [ -x /usr/bin/sha256sum ]; then
363363- printf "%s %s" "$sha256check_SUM" "$sha256check_FILE" | /usr/bin/sha256sum -c >&2
364364- else
365365- printf "FATAL: %s\n" "No sha256 checksum utility found" >&2
366366- exit 107
367367- fi
368368-}
369369-370370-# [downloadfile URL FILE SUM] downloads from URL into FILE and verifies the SHA256 checksum of SUM.
371371-# If the FILE already exists with the correct checksum it is not redownloaded.
372372-# The function will exit with failure if the checksum does not match.
373373-downloadfile() {
374374- downloadfile_URL="$1"
375375- shift
376376- downloadfile_FILE="$1"
377377- shift
378378- downloadfile_SUM="$1"
379379- shift
380380-381381- # Set DKMLSYS_*
382382- autodetect_system_binaries
383383-384384- if [ -e "$downloadfile_FILE" ]; then
385385- if sha256check "$downloadfile_FILE" "$downloadfile_SUM"; then
386386- return 0
387387- else
388388- $DKMLSYS_RM -f "$downloadfile_FILE"
389389- fi
390390- fi
391391- if [ "${CI:-}" = true ]; then
392392- if [ -n "$DKMLSYS_CURL" ]; then
393393- log_trace "$DKMLSYS_CURL" -L -s "$downloadfile_URL" -o "$downloadfile_FILE".tmp
394394- elif [ -n "$DKMLSYS_WGET" ]; then
395395- log_trace "$DKMLSYS_WGET" -q -O "$downloadfile_FILE".tmp "$downloadfile_URL"
396396- else
397397- echo "No curl or wget available on the system paths" >&2
398398- exit 107
399399- fi
400400- else
401401- if [ -n "$DKMLSYS_CURL" ]; then
402402- log_trace "$DKMLSYS_CURL" -L "$downloadfile_URL" -o "$downloadfile_FILE".tmp
403403- elif [ -n "$DKMLSYS_WGET" ]; then
404404- log_trace "$DKMLSYS_WGET" -O "$downloadfile_FILE".tmp "$downloadfile_URL"
405405- else
406406- echo "No curl or wget available on the system paths" >&2
407407- exit 107
408408- fi
409409- fi
410410- if ! sha256check "$downloadfile_FILE".tmp "$downloadfile_SUM"; then
411411- printf "%s\n" "FATAL: Encountered a corrupted or compromised download from $downloadfile_URL" >&2
412412- exit 1
413413- fi
414414- $DKMLSYS_MV "$downloadfile_FILE".tmp "$downloadfile_FILE"
415415-}
416416-417417-# --- Environment detection ---
418418-419419-# Set DKMLSYS_*
420420-autodetect_system_binaries
421421-422422-# Find host ABI. Set in BUILDHOST_ARCH
423423-autodetect_buildhost_arch
424424-425425-# Use the project tree as the current directory
426426-PROJ_DIR=$(dirname "$0")
427427-PROJ_DIR=$(cd "$PROJ_DIR" && pwd)
428428-cd "$PROJ_DIR"
429429-430430-# --- Tool directory selection ---
431431-432432-tools_dir=
433433-tools_name=dktool
434434-# 1. Check if CI since many CI providers can only cache content in a subdirectory
435435-# of the project.
436436-if [ -z "$tools_dir" ] && [ "${CI:-}" = true ]; then
437437- install -d "$PROJ_DIR/.tools"
438438- tools_dir="$PROJ_DIR/.tools"
439439-fi
440440-# 2. Check in locations rooted under /opt/diskuv
441441-# We look under a /opt/diskuv early because
442442-# - Especially important for WSL2 to use a pure Linux filesystem (ext4) for
443443-# best performance.
444444-# - Using a canonical location (especially /opt/diskuv/usr/share) makes
445445-# it easy to use CMake presets for non-Windows hosts.
446446-if [ -z "$tools_dir" ] && [ -n "${XDG_DATA_HOME:-}" ] && [ -w "/opt/diskuv/$XDG_DATA_HOME" ]; then
447447- install -d "/opt/diskuv/$XDG_DATA_HOME/$tools_name"
448448- tools_dir="/opt/diskuv/$XDG_DATA_HOME/$tools_name"
449449-fi
450450-if [ -z "$tools_dir" ] && [ -n "${HOME:-}" ] && [ -w "/opt/diskuv/$HOME" ]; then
451451- install -d "/opt/diskuv/$HOME/.local/share/$tools_name"
452452- tools_dir="/opt/diskuv/$HOME/.local/share/$tools_name"
453453-fi
454454-if [ -z "$tools_dir" ] && [ -w "/opt/diskuv/usr/share" ]; then
455455- install -d "/opt/diskuv/usr/share/$tools_name"
456456- tools_dir="/opt/diskuv/usr/share/$tools_name"
457457-fi
458458-# 3. Check in the conventional locations rooted under /
459459-if [ -z "$tools_dir" ] && [ -n "${XDG_DATA_HOME:-}" ] && [ -w "$XDG_DATA_HOME" ]; then
460460- install -d "$XDG_DATA_HOME/$tools_name"
461461- tools_dir="$XDG_DATA_HOME/$tools_name"
462462-fi
463463-if [ -z "$tools_dir" ] && [ -n "${HOME:-}" ] && [ -w "$HOME" ]; then
464464- install -d "$HOME/.local/share/$tools_name"
465465- tools_dir="$HOME/.local/share/$tools_name"
466466-fi
467467-# 4. Validate
468468-if [ -z "$tools_dir" ]; then
469469- echo "FATAL: Could not find a location to install the tools necessary for this project." >&2
470470- echo " ...: Make sure you have a home directory and that it is write-able, or define" >&2
471471- echo " ...: the environment variable XDG_DATA_HOME in a shell profile script after" >&2
472472- echo " ...: creating the \$XDG_DATA_HOME directory." >&2
473473- exit 2
474474-fi
475475-476476-# --- Tool downloads and installs ---
477477-478478-# PREREQS
479479-# -------
480480-481481-install_linux_prog() {
482482- install_linux_prog_NAME=$1
483483- shift
484484- install_linux_prog_PKG=$1
485485- shift
486486- if [ -x "/usr/bin/$install_linux_prog_NAME" ]; then
487487- export DK_PROG_INSTALLED_LOCATION="/usr/bin/$install_linux_prog_NAME"
488488- else
489489- if command -v yum > /dev/null 2> /dev/null; then
490490- if [ "$(id -u)" -eq 0 ]; then
491491- yum install -y "$install_linux_prog_PKG"
492492- else
493493- echo "Running: sudo yum install -y $install_linux_prog_PKG"
494494- sudo yum install -y "$install_linux_prog_PKG"
495495- fi
496496- else
497497- if [ "$(id -u)" -eq 0 ]; then
498498- apt-get -q install -y "$install_linux_prog_PKG"
499499- else
500500- echo "Running: sudo -q apt-get -qq install -y --no-install-suggests $install_linux_prog_PKG"
501501- sudo apt-get -qq install -y --no-install-suggests "$install_linux_prog_PKG"
502502- fi
503503- fi
504504- DK_PROG_INSTALLED_LOCATION=$(command -v "$install_linux_prog_NAME")
505505- export DK_PROG_INSTALLED_LOCATION
506506- fi
507507-}
508508-509509-get_homebrew_binary() {
510510- get_homebrew_binary_NAME=$1
511511- shift
512512- if command -v brew > /dev/null 2> /dev/null; then
513513- get_homebrew_binary_PREFIX=$(brew --prefix)
514514- if [ -x "$get_homebrew_binary_PREFIX/bin/$get_homebrew_binary_NAME" ]; then
515515- export DK_PROG_INSTALLED_LOCATION="$get_homebrew_binary_PREFIX/bin/$get_homebrew_binary_NAME"
516516- return 0
517517- fi
518518- fi
519519- return 1
520520-}
521521-522522-install_macos_prog() {
523523- install_macos_prog_NAME=$1
524524- shift
525525- install_macos_prog_PKG=$1
526526- shift
527527- if [ -x "/usr/bin/$install_macos_prog_NAME" ]; then
528528- export DK_PROG_INSTALLED_LOCATION="/usr/bin/$install_macos_prog_NAME"
529529- elif [ -x "/usr/local/bin/$install_macos_prog_NAME" ]; then
530530- export DK_PROG_INSTALLED_LOCATION="/usr/local/bin/$install_macos_prog_NAME"
531531- elif get_homebrew_binary "$install_macos_prog_NAME"; then
532532- # DK_PROG_INSTALLED_LOCATION already set by [get_homebrew_binary]
533533- true
534534- else
535535- if command -v brew > /dev/null 2> /dev/null; then
536536- brew install --quiet --formula "$install_macos_prog_PKG" >&2
537537- get_homebrew_binary "$install_macos_prog_NAME"
538538- # DK_PROG_INSTALLED_LOCATION already set by [get_homebrew_binary]
539539- elif command -v port > /dev/null 2> /dev/null; then
540540- if [ "$(id -u)" -eq 0 ]; then
541541- port install "$install_macos_prog_PKG"
542542- else
543543- echo "Running: sudo port install $install_macos_prog_PKG"
544544- sudo port install "$install_macos_prog_PKG"
545545- fi
546546- DK_PROG_INSTALLED_LOCATION=$(command -v "$install_macos_prog_NAME")
547547- export DK_PROG_INSTALLED_LOCATION
548548- else
549549- echo "FATAL: Neither Homebrew nor MacPorts are available on your macOS. You can follow https://docs.brew.sh/Installation to install Homebrew." >&2
550550- exit 2
551551- fi
552552- fi
553553-}
554554-555555-case $BUILDHOST_ARCH in
556556- linux_*)
557557- install_linux_prog wget wget # For [downloadfile]
558558- install_linux_prog tar tar # For handling tar balls later in this script
559559- ;;
560560-esac
561561-562562-# NINJA
563563-# -----
564564-# We need a valid CMAKE_GENERATOR to do FetchContent_Populate() in script mode
565565-566566-NINJA_EXE=
567567-case $BUILDHOST_ARCH in
568568- darwin_*)
569569- install_macos_prog ninja ninja
570570- NINJA_EXE=$DK_PROG_INSTALLED_LOCATION;;
571571- linux_*)
572572- install_linux_prog ninja ninja-build
573573- NINJA_EXE=$DK_PROG_INSTALLED_LOCATION;;
574574-esac
575575-576576-# CMAKE
577577-# -----
578578-579579-case $BUILDHOST_ARCH in
580580- linux_*)
581581- # This is for CMake to do FetchContent()
582582- install_linux_prog git git ;;
583583-esac
584584-case $BUILDHOST_ARCH in
585585- linux_x86)
586586- # This is for Python wheel extraction
587587- install_linux_prog unzip unzip ;;
588588-esac
589589-590590-cmake_base=
591591-cmake_majmin_ver=3.25
592592-cmake_majminpat_ver=3.25.2
593593-cmake_bindir=
594594-cmake_destdir=$tools_dir/cmake-$cmake_majminpat_ver
595595-install -d "$tools_dir/dl"
596596-download_cmake() {
597597- case $BUILDHOST_ARCH in
598598- darwin_*)
599599- install_macos_prog cmake cmake
600600- cmake_bindir=$(dirname "$DK_PROG_INSTALLED_LOCATION")
601601- ;;
602602- linux_x86_64)
603603- cmake_base="cmake-$cmake_majminpat_ver-linux-x86_64"
604604- printf "%s\n\n" "-- Downloading cmake-$cmake_majminpat_ver for Linux x86_64" >&2
605605- downloadfile \
606606- "https://github.com/Kitware/CMake/releases/download/v$cmake_majminpat_ver/$cmake_base.tar.gz" \
607607- "$tools_dir/dl/cmake.tar.gz" \
608608- 783da74f132fd1fea91b8236d267efa4df5b91c5eec1dea0a87f0cf233748d99
609609- cmake_bindir="$cmake_destdir/bin" ;;
610610- linux_x86)
611611- # CMake does not provide 32-bit binaries. But pypi does at https://pypi.org/project/cmake/
612612- printf "%s\n\n" "-- Downloading cmake-$cmake_majminpat_ver for Linux x86" >&2
613613- downloadfile \
614614- https://files.pythonhosted.org/packages/11/6e/aeeddf2f5b16542b6a30ceab4896421e8705d8e9a9296dba79395db11b00/cmake-3.25.2-py2.py3-none-manylinux_2_17_i686.manylinux2014_i686.whl \
615615- "$tools_dir/dl/cmake.whl" \
616616- 715ef82e81b48db3e4c7744614c15ff361d53f6987fd70b1b66b0880595f2e2c
617617- cmake_bindir="$cmake_destdir/bin" ;;
618618- linux_arm64)
619619- cmake_base="cmake-$cmake_majminpat_ver-linux-aarch64"
620620- printf "%s\n\n" "-- Downloading cmake-$cmake_majminpat_ver for Linux ARM64" >&2
621621- downloadfile \
622622- "https://github.com/Kitware/CMake/releases/download/v$cmake_majminpat_ver/$cmake_base.tar.gz" \
623623- "$tools_dir/dl/cmake.tar.gz" \
624624- 9216ecf0449ade700e66e0def11eeaebf9fa7d4428c02f49cb59f11418d3f8a5
625625- cmake_bindir="$cmake_destdir/bin" ;;
626626- esac
627627-}
628628-export_cmake_vars() {
629629- case $BUILDHOST_ARCH in
630630- darwin_*)
631631- if command -v brew > /dev/null 2> /dev/null; then
632632- cmake_bindir=$(brew --prefix cmake)/bin
633633- else
634634- cmake_bindir=$(command -v cmake)
635635- cmake_bindir=$(dirname "$cmake_bindir")
636636- fi
637637- ;;
638638- linux_x86_64)
639639- cmake_bindir="$cmake_destdir/bin" ;;
640640- linux_x86)
641641- cmake_bindir="$cmake_destdir/bin" ;;
642642- esac
643643-}
644644-have_correct_cmake=0
645645-if [ -x "$tools_dir/cmake-$cmake_majminpat_ver/bin/cmake" ]; then
646646- # shellcheck disable=SC2016
647647- have_correct_cmake_VER=$("$tools_dir/cmake-$cmake_majminpat_ver/bin/cmake" --version | $DKMLSYS_AWK 'NR==1{print $NF}')
648648- if [ "$have_correct_cmake_VER" = "$cmake_majminpat_ver" ]; then
649649- have_correct_cmake=1
650650- fi
651651-fi
652652-if [ $have_correct_cmake -eq 0 ]; then
653653- download_cmake
654654-fi
655655-# Handle tarball
656656-if [ -e "$tools_dir/dl/cmake.tar.gz" ] && [ -n "$cmake_base" ]; then
657657- rm -rf "$tools_dir/cmake-$cmake_majminpat_ver"
658658- install -d "$cmake_destdir"
659659- tar xCfz "$cmake_destdir" "$tools_dir/dl/cmake.tar.gz"
660660- rm -f "$tools_dir/dl/cmake.tar.gz"
661661- set +f
662662- if [ -e "$cmake_destdir/$cmake_base/CMake.app" ]; then
663663- mv "$cmake_destdir/$cmake_base/CMake.app/Contents"/* "$cmake_destdir/"
664664- else
665665- mv "$cmake_destdir/$cmake_base"/* "$cmake_destdir/"
666666- fi
667667- set -f
668668-fi
669669-# Handle Python wheel
670670-if [ -e "$tools_dir/dl/cmake.whl" ]; then
671671- rm -rf "$tools_dir/cmake-$cmake_majminpat_ver"
672672- cd "$tools_dir/dl"
673673- rm -rf cmake/data
674674- # Don't want cmake/data/{aclocal,bash-completion,emacs,vim}
675675- unzip -q cmake.whl 'cmake/data/bin/**'
676676- unzip -q cmake.whl 'cmake/data/doc/**'
677677- # Don't want cmake/data/share/cmake-$cmake_majmin_ver/Help
678678- unzip -q cmake.whl "cmake/data/share/cmake-$cmake_majmin_ver/"'include/**'
679679- unzip -q cmake.whl "cmake/data/share/cmake-$cmake_majmin_ver/"'Modules/**'
680680- unzip -q cmake.whl "cmake/data/share/cmake-$cmake_majmin_ver/"'Templates/**'
681681- rm -f cmake.whl
682682- cd -
683683- set +f
684684- install -d "$cmake_destdir/share" "$cmake_destdir/doc" "$cmake_destdir/bin"
685685- mv "$tools_dir/dl/cmake/data/bin"/* "$cmake_destdir/bin/"
686686- rm -rf "$cmake_destdir/share/cmake-$cmake_majmin_ver" "$cmake_destdir/doc/cmake-$cmake_majmin_ver" "$cmake_destdir/doc/cmake"
687687- mv "$tools_dir/dl/cmake/data/share/cmake-$cmake_majmin_ver" "$cmake_destdir/share/"
688688- if [ -e "$tools_dir/dl/cmake/data/doc/cmake" ]; then # Windows wheel
689689- mv "$tools_dir/dl/cmake/data/doc/cmake" "$cmake_destdir/doc/"
690690- fi
691691- if [ -e "$tools_dir/dl/cmake/data/doc/cmake-$cmake_majmin_ver" ]; then # Linux wheel
692692- mv "$tools_dir/dl/cmake/data/doc/cmake-$cmake_majmin_ver" "$cmake_destdir/doc/"
693693- fi
694694- set -f
695695- # other dirs: aclocal bash-completion emacs vim
696696- rm -rf "$tools_dir/dl/cmake/data/share"
697697- # be pedantic. if we don't know about a directory, it may be important. so error
698698- # if some directory is non-empty
699699- rmdir "$tools_dir/dl/cmake/data/bin" "$tools_dir/dl/cmake/data/doc"
700700- rmdir "$tools_dir/dl/cmake/data"
701701-fi
702702-703703-# Put tools in PATH
704704-export_cmake_vars
705705-if [ -n "$cmake_bindir" ] && [ -d "$cmake_bindir" ]; then
706706- tools_bin_dir=$(cd "$cmake_bindir" && pwd)
707707- export PATH="$tools_bin_dir:$PATH"
708708-else
709709- echo "This platform is not supported. No cmake 3.25+ download logic has been added" >&2
710710- exit 1
711711-fi
712712-713713-# Validate
714714-"$cmake_bindir/cmake" --version > /dev/null
715715-716716-# --- Run finder script ---
717717-718718-cd "$PROJ_DIR"
719719-"$cmake_bindir/cmake" \
720720- -D CMAKE_GENERATOR=Ninja -D CMAKE_MAKE_PROGRAM="$NINJA_EXE" \
721721- -D "DKTOOL_PWD:FILEPATH=$dk_pwd" \
722722- -D "DKTOOL_WORKDIR:FILEPATH=$tools_dir/work" -D "DKTOOL_CMDLINE:STRING=$*" \
723723- -P cmake/FindDkToolScripts.cmake
-183
dk.cmd
···11-@ECHO OFF
22-33-REM ##########################################################################
44-REM # File: dktool/dk.cmd #
55-REM # #
66-REM # Copyright 2023 Diskuv, Inc. #
77-REM # #
88-REM # Licensed under the Apache License, Version 2.0 (the "License"); #
99-REM # you may not use this file except in compliance with the License. #
1010-REM # You may obtain a copy of the License at #
1111-REM # #
1212-REM # http://www.apache.org/licenses/LICENSE-2.0 #
1313-REM # #
1414-REM # Unless required by applicable law or agreed to in writing, software #
1515-REM # distributed under the License is distributed on an "AS IS" BASIS, #
1616-REM # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or #
1717-REM # implied. See the License for the specific language governing #
1818-REM # permissions and limitations under the License. #
1919-REM # #
2020-REM ##########################################################################
2121-2222-REM Recommendation: Place this file in source control.
2323-REM Auto-generated by `./dk dksdk.project.new` of dktool.
2424-2525-REM The canonical way to run this script is: ./dk
2626-REM That works in Powershell on Windows, and in Unix. Copy-and-paste works!
2727-2828-SETLOCAL
2929-3030-REM Coding guidelines
3131-REM 1. Microsoft way of getting around PowerShell permissions:
3232-REM https://github.com/microsoft/vcpkg/blob/71422c627264daedcbcd46f01f1ed0dcd8460f1b/bootstrap-vcpkg.bat
3333-REM 2. Write goto downward please so code flow is top to bottom.
3434-3535-SET DK_CMAKE_VER=3.25.3
3636-SET DK_NINJA_VER=1.11.1
3737-SET DK_BUILD_TYPE=Release
3838-SET DK_SHARE=%LOCALAPPDATA%\Programs\DkSDK\dktool
3939-SET DK_PROJ_DIR=%~dp0
4040-SET DK_PWD=%CD%
4141-4242-REM -------------- CMAKE --------------
4343-4444-REM Find CMAKE.EXE
4545-where.exe /q cmake.exe >NUL 2>NUL
4646-IF %ERRORLEVEL% neq 0 (
4747- goto FindDownloadedCMake
4848-)
4949-FOR /F "tokens=* usebackq" %%F IN (`where.exe cmake.exe`) DO (
5050- SET "DK_CMAKE_EXE=%%F"
5151-)
5252-5353-REM Check if present at <data>/cmake-VER/bin/cmake.exe
5454-:FindDownloadedCMake
5555-IF EXIST %DK_SHARE%\cmake-%DK_CMAKE_VER%-windows-x86_64\bin\cmake.exe (
5656- SET "DK_CMAKE_EXE=%DK_SHARE%\cmake-%DK_CMAKE_VER%-windows-x86_64\bin\cmake.exe"
5757- GOTO ValidateCMake
5858-)
5959-6060-REM Download CMAKE.EXE
6161-bitsadmin /transfer dktool-cmake /download /priority FOREGROUND ^
6262- "https://github.com/Kitware/CMake/releases/download/v%DK_CMAKE_VER%/cmake-%DK_CMAKE_VER%-windows-x86_64.zip" ^
6363- "%TEMP%\cmake-%DK_CMAKE_VER%-windows-x86_64.zip"
6464-IF %ERRORLEVEL% equ 0 (
6565- GOTO UnzipCMakeZip
6666-)
6767-REM Try PowerShell 3+ instead
6868-powershell -NoProfile -ExecutionPolicy Bypass -Command ^
6969- "Invoke-WebRequest https://github.com/Kitware/CMake/releases/download/v%DK_CMAKE_VER%/cmake-%DK_CMAKE_VER%-windows-x86_64.zip -OutFile '%TEMP%\cmake-%DK_CMAKE_VER%-windows-x86_64.zip'"
7070-IF %ERRORLEVEL% neq 0 (
7171- echo.
7272- echo.Could not download CMake %DK_CMAKE_VER%. Make sure that PowerShell is installed
7373- echo.and has not been disabled by a corporate policy.
7474- echo.
7575- EXIT /b 1
7676-)
7777-7878-REM Unzip CMAKE.EXE (use PowerShell; could download unzip.exe and sha256sum.exe as well in case corporate policy)
7979-:UnzipCMakeZip
8080-powershell -NoProfile -ExecutionPolicy Bypass -Command ^
8181- "Expand-Archive '%TEMP%\cmake-%DK_CMAKE_VER%-windows-x86_64.zip' -DestinationPath '%DK_SHARE%'"
8282-IF %ERRORLEVEL% neq 0 (
8383- echo.
8484- echo.Could not unzip CMake %DK_CMAKE_VER%. Make sure that PowerShell is installed
8585- echo.and has not been disabled by a corporate policy.
8686- echo.
8787- EXIT /b 1
8888-)
8989-SET "DK_CMAKE_EXE=%DK_SHARE%\cmake-%DK_CMAKE_VER%-windows-x86_64\bin\cmake.exe"
9090-9191-REM Validate cmake.exe
9292-:ValidateCMake
9393-"%DK_CMAKE_EXE%" -version >NUL 2>NUL
9494-if %ERRORLEVEL% neq 0 (
9595- echo.
9696- echo.%DK_CMAKE_EXE%
9797- echo.is not responding to the -version option. Make sure that
9898- echo.CMake is installed correctly.
9999- echo.
100100- exit /b 1
101101-)
102102-103103-REM -------------- NINJA --------------
104104-105105-REM Find NINJA.EXE
106106-where.exe /q ninja.exe >NUL 2>NUL
107107-IF %ERRORLEVEL% neq 0 (
108108- goto FindDownloadedNinja
109109-)
110110-FOR /F "tokens=* usebackq" %%F IN (`where.exe ninja.exe`) DO (
111111- SET "DK_NINJA_EXE=%%F"
112112-)
113113-114114-REM Check if present at <data>/ninja-VER/bin/ninja.exe
115115-:FindDownloadedNinja
116116-IF EXIST %DK_SHARE%\ninja-%DK_NINJA_VER%-windows-x86_64\bin\ninja.exe (
117117- SET "DK_NINJA_EXE=%DK_SHARE%\ninja-%DK_NINJA_VER%-windows-x86_64\bin\ninja.exe"
118118- GOTO ValidateNinja
119119-)
120120-121121-REM Download NINJA.EXE
122122-bitsadmin /transfer dktool-ninja /download /priority FOREGROUND ^
123123- "https://github.com/ninja-build/ninja/releases/download/v%DK_NINJA_VER%/ninja-win.zip" ^
124124- "%TEMP%\ninja-%DK_NINJA_VER%-windows-x86_64.zip"
125125-IF %ERRORLEVEL% equ 0 (
126126- GOTO UnzipNinjaZip
127127-)
128128-REM Try PowerShell 3+ instead
129129-powershell -NoProfile -ExecutionPolicy Bypass -Command ^
130130- "Invoke-WebRequest https://github.com/ninja-build/ninja/releases/download/v%DK_NINJA_VER%/ninja-win.zip -OutFile '%TEMP%\ninja-%DK_NINJA_VER%-windows-x86_64.zip'"
131131-IF %ERRORLEVEL% neq 0 (
132132- echo.
133133- echo.Could not download Ninja %DK_NINJA_VER%. Make sure that PowerShell is installed
134134- echo.and has not been disabled by a corporate policy.
135135- echo.
136136- EXIT /b 1
137137-)
138138-139139-REM Unzip NINJA.EXE (use PowerShell; could download unzip.exe and sha256sum.exe as well in case corporate policy)
140140-:UnzipNinjaZip
141141-powershell -NoProfile -ExecutionPolicy Bypass -Command ^
142142- "Expand-Archive '%TEMP%\ninja-%DK_NINJA_VER%-windows-x86_64.zip' -DestinationPath '%DK_SHARE%\ninja-%DK_NINJA_VER%-windows-x86_64\bin'"
143143-IF %ERRORLEVEL% neq 0 (
144144- echo.
145145- echo.Could not unzip Ninja %DK_NINJA_VER%. Make sure that PowerShell is installed
146146- echo.and has not been disabled by a corporate policy.
147147- echo.
148148- EXIT /b 1
149149-)
150150-SET "DK_NINJA_EXE=%DK_SHARE%\ninja-%DK_NINJA_VER%-windows-x86_64\bin\ninja.exe"
151151-152152-REM Validate ninja.exe
153153-:ValidateNinja
154154-"%DK_NINJA_EXE%" --version >NUL 2>NUL
155155-if %ERRORLEVEL% neq 0 (
156156- echo.
157157- echo.%DK_NINJA_EXE%
158158- echo.is not responding to the --version option. Make sure that
159159- echo.Ninja is installed correctly.
160160- echo.
161161- exit /b 1
162162-)
163163-164164-REM -------------- DkML PATH ---------
165165-REM We get "git-sh-setup: file not found" in Git for Windows because
166166-REM Command Prompt has the "Path" environment variable, while PowerShell
167167-REM and `with-dkml` use the PATH environment variable. Sadly both
168168-REM can be present in Command Prompt at the same time. Git for Windows
169169-REM (called by FetchContent in CMake) does not comport with what Command
170170-REM Prompt is using. So we let Command Prompt be the source of truth by
171171-REM removing any duplicated PATH twice and resetting to what Command Prompt
172172-REM thinks the PATH is.
173173-174174-SET _DK_PATH=%PATH%
175175-SET PATH=
176176-SET PATH=
177177-SET PATH=%_DK_PATH%
178178-SET _DK_PATH=
179179-180180-REM -------------- Run finder --------------
181181-182182-cd /d %DK_PROJ_DIR%
183183-"%DK_CMAKE_EXE%" -D CMAKE_GENERATOR=Ninja -D "CMAKE_MAKE_PROGRAM=%DK_NINJA_EXE%" -D "DKTOOL_PWD:FILEPATH=%DK_PWD%" -D "DKTOOL_WORKDIR:FILEPATH=%DK_SHARE%\work" -D "DKTOOL_CMDLINE:STRING=%*" -P cmake/FindDkToolScripts.cmake