Command Reference¶
with-dkml.exe¶
- Summary
Runs a specified command with an appropriate environment for a Microsoft/Apple/GNU compiler that includes headers and libraries of optionally vcpkg and optionally third-party C packages.
The environment variable
DKML_3P_PREFIX_PATH
can be set to a semicolon separated list of third-party directories, and anybin
,include
,lib
andlib/pkgconfig
subdirectories will be added to various compiler environment variables (more details below).The environment variable
DKML_3P_PROGRAM_PATH
can be set to a semicolon separated list of third-party directories, and any directory in it will be added to the PATH.An SDK Project automatically sets
DKML_3P_PREFIX_PATH
andDKML_3P_PROGRAM_PATH
to the CMAKE_PREFIX_PATH and CMAKE_PROGRAM_PATH variables, respectively.- Usage
# Execute: CMD ARGS with-dkml CMD ARGS
- Examples
# Enter a Bash session with-dkml CMD ARGS # Run Opam with-dkml opam
- Configuration File
dkmlvars-v2.sexp
This file must exist in one of the following directories:
$LOCALAPPDATA/Programs/DiskuvOCaml/
$XDG_DATA_HOME/diskuv-ocaml/
$HOME/.local/share/diskuv-ocaml/
The directories are checked in order, and the first directory that contains
dkmlvars-v2.sexp
is used.The value will have been set automatically by the Windows Diskuv OCaml installer or by
makeit init-dev
of SDK Projects for non-Windows OSes.- Configuration File
vsstudio.dir.txt
This file is located using the same directory search as
dkmlvars-v2.sexp
. It only needs to be present when Visual Studio has been detected, and is set automatically by the Windows Diskuv OCaml installer.The value is the location of the Visual Studio installation. Example:
C:\DiskuvOCaml\BuildTools
- Configuration File
vsstudio.msvs_preference.txt
This file is located using the same directory search as
dkmlvars-v2.sexp
. It only needs to be present when Visual Studio has been detected, and is set automatically by the Windows Diskuv OCaml installer.The value is the
MSVS_PREFERENCE
environment variable that must be set to locate the Visual Studio installation when https://github.com/metastack/msvs-tools’s or Opam’smsvs-detect
is invoked. Example:VS16.6
- Configuration File
vsstudio.cmake_generator.txt
This file is located using the same directory search as
dkmlvars-v2.sexp
. It only needs to be present when Visual Studio has been detected, and is set automatically by the Windows Diskuv OCaml installer.The value is a recommendation for which CMake Generator to use when setting up a CMake project initially.
- Arguments CMD ARGS
The name of the command to run, and any optional arguments. The command does not need to an absolute path if it already part of the existing PATH or part of the modified PATH.
Note
On Windows the command may come from MSYS2. For example,
bash
is a valid command.- Sequence of operations
The environment variable
DKML_TARGET_ABI
will be detected through compiler probing and set to one of:android_arm64v8a
android_arm32v7a
android_x86
android_x86_64
darwin_arm64
darwin_x86_64
linux_arm64
linux_arm32v6
linux_arm32v7
linux_x86_64
windows_x86_64
windows_x86
windows_arm64
windows_arm32
The compiler probing is done when with-dkml is compiled. During Diskuv OCaml installation on Windows a
with-dkml
will be placed on the PATH; that will use the Visual Studio compiler detected at installation time.Note
An SDK Project supports cross-compilation and can have many
with-dkml
binaries. Any./makeit *-<platform>-<buildtype>
target like./makeit build-windows_x86-Debug
or./makeit build-dev
will first call a./makeit init-<platform>
target; that will compile awith-dkml
binary using a compiler specific to the given<platform>
. That means thatDKML_TARGET_ABI
will be<platform>
, exceptDKML_TARGET_ABI
will be the results of probing the system compiler if<platform> = "dev"
.Warning
Only
windows_x86_64
,darwin_arm64
anddarwin_x86_64
are supported today.If and only if the configuration file
vsstudio.msvs_preference.txt
exists then theMSVS_PREFERENCE
environment variable will be set to its valueIf and only if the configuration file
vsstudio.cmake_generator.txt
exists then theCMAKE_GENERATOR_RECOMMENDED
environment variable will be set to its valueIf and only if the configuration file
vsstudio.dir.txt
exists then theCMAKE_GENERATOR_INSTANCE_RECOMMENDED
environment variable will be set to its valueThe existing environment variable PATH is:
(MSYS2) Stripped of all path entries that end with
\MSYS2\usr\bin
. For example, if the existing PATH isC:\Program Files\Miniconda3\Scripts;C:\MSYS2\usr\bin;C:\WINDOWS\system32;C:\WINDOWS
the stripped PATH will be
C:\Program Files\Miniconda3\Scripts;C:\WINDOWS\system32;C:\WINDOWS
(MSVC) Stripped of all path entries that end with
\Common7\IDE
or\Common7\Tools
or\MSBuild\Current\Bin
(MSVC) Stripped of all path entries that contain
\VC\Tools\MSVC\
,\Windows Kits\10\bin\
,\Microsoft.NET\Framework64\
or\MSBuild\Current\bin\
If and only if there is a
DiskuvOCamlMSYS2Dir
configuration value indkmlvars-v2.sexp
, theVsDevCmd.bat
Microsoft batch script is run. The following environment variables are captured and passed to theCMD ARGS
:PATH
DevEnvDir
ExtensionSdkDir
Framework40Version
FrameworkDir
Framework64
FrameworkVersion
FrameworkVersion64
INCLUDE
LIB
LIBPATH
UCRTVersion
UniversalCRTSdkDir
VCIDEInstallDir
VCINSTALLDIR
VCToolsInstallDir
VCToolsRedistDir
VCToolsVersion
VisualStudioVersion
VS140COMNTOOLS
VS150COMNTOOLS
VS160COMNTOOLS
VSINSTALLDIR
WindowsLibPath
WindowsSdkBinPath
WindowsSdkDir
WindowsSDKLibVersion
WindowsSdkVerBinPath
WindowsSDKVersion
The PATH is stripped of all directories in the semicolon separated environment variable
DKML_3P_PROGRAM_PATH
. For example, on Windows if the existingPATH
isC:\Project\tools\local\bin;C:\Temp\share;C:\WINDOWS\system32;C:\WINDOWS
and the environment variable
DKML_3P_PROGRAM_PATH
isC:\Project\tools\local;C:\Temp\share
, the strippedPATH
will beC:\Project\tools\local\bin;C:\WINDOWS\system32;C:\WINDOWS
Each directory in
DKML_3P_PROGRAM_PATH
is added to thePATH
environment variableThe following environment variables:
INCLUDE
CPATH
COMPILER_PATH
LIB
LIBRARY_PATH
PKG_CONFIG_PATH
PATH
are:
Stripped of all directories in the semicolon separated environment variable
DKML_3P_PREFIX_PATH
or any of its subdirectories. For example, on Windows if the existingINCLUDE
isC:\Project\tools\local\include;C:\Temp\share;C:\WINDOWS\system32;C:\WINDOWS
and the environment variable
DKML_3P_PREFIX_PATH
isC:\Project\tools\local;C:\Temp\share
, the strippedINCLUDE
will beC:\WINDOWS\system32;C:\WINDOWS
For each directory
$DIR
inDKML_3P_PREFIX_PATH
:$DIR/include
is added to theINCLUDE
environment variable which is used as system header paths by Microsoft’s ‘cl.exe’ compiler$DIR/include
is added to theCPATH
environment variable which is used as system header paths by Apple’s ‘clang’ compiler$DIR/include
is added to theCOMPILER_PATH
environment variable which is used as system header paths by GNU’s ‘gcc’ compiler$DIR/lib
is added to theLIB
environment variable which is used as system library paths by Microsoft’s ‘link.exe’ linker$DIR/lib
is added to theLIBRARY_PATH
environment variable which is used as system library paths by GNU’s ‘gcc’ compiler and Apple’s ‘clang’ compiler$DIR/lib/pkgconfig
is added to thePKG_CONFIG_PATH
environment variable which is used to locate package header and library information by pkg-config and pkgconf$DIR/bin
is added to thePATH
environment variable