Skip to content

Commit

Permalink
Defaults for DkML vars in shell scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonah Beckford committed Nov 27, 2023
1 parent e4b3fac commit 23aecfc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
1 change: 1 addition & 0 deletions bump-version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include(${DKML_BUMP_VERSION_PARTICIPANT_MODULE})

DkMLBumpVersionParticipant_PlainReplace(template.dkmlroot)
DkMLBumpVersionParticipant_PlainReplace(README.md)
DkMLBumpVersionParticipant_PlainReplace(unix/crossplatform-functions.sh)
DkMLBumpVersionParticipant_MetaReplace(META)
DkMLBumpVersionParticipant_OpamReplace(dkml-runtime-common.opam)
DkMLBumpVersionParticipant_OpamReplace(dkml-runtime-common-native.opam)
Expand Down
4 changes: 2 additions & 2 deletions unix/_common_tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# _common_tool.sh
#
# Inputs:
# DKMLDIR: The 'diskuv-ocaml' vendored directory containing '.dkmlroot'.
# DKMLDIR: The DkML vendored directory containing '.dkmlroot'.
#
#################################################

Expand Down Expand Up @@ -52,7 +52,7 @@ is_reproducible_platform() {
is_arg_linux_based_platform "$PLATFORM"
}

if [ ! -e "$DKMLDIR/.dkmlroot" ]; then echo "FATAL: Not embedded within or launched from a 'diskuv-ocaml' Local Project" >&2 ; exit 1; fi
if [ ! -e "$DKMLDIR/.dkmlroot" ]; then echo "FATAL: Not launched within a directory tree containing a .dkmlroot file" >&2 ; exit 1; fi

# set $dkml_root_version
# shellcheck disable=SC1091
Expand Down
37 changes: 36 additions & 1 deletion unix/crossplatform-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ set_dkmlparenthomedir() {
fi
}

set_default_dkmlnativedir() {
if [ -n "${LOCALAPPDATA:-}" ]; then
DKMLNATIVEDIR_BUILDHOST="$LOCALAPPDATA\\Programs\\DkMLNative"
elif is_macos_build_machine; then
DKMLNATIVEDIR_BUILDHOST="$HOME/Applications/DkMLNative"
else
# shellcheck disable=SC2034
DKMLNATIVEDIR_BUILDHOST="${XDG_DATA_HOME:-$HOME/.local/share}/dkml-native"
fi
}

# Detects DkML and sets its variables.
#
# If the environment variables already exist they are not overwritten.
Expand All @@ -110,7 +121,20 @@ set_dkmlparenthomedir() {
# - env:DKMLBINPATHS_UNIX - set if DkML installed. Paths will be in Unix (colon separated) format
# - env:DKMLMSYS2DIR_BUILDHOST - set if DkML installed MSYS2. Directory will be in Windows format
# Return Code:
# - 1 if DiskuvOCaml is not installed
# - 1 if DkML is not installed
default_dkmlvars() {
set_default_dkmlnativedir # Native is the default mode, not Bytecode
autodetect_dkmlvars_DiskuvOCamlVarsVersion_Override=2
if [ -x /usr/bin/cygpath ]; then
autodetect_dkmlvars_DiskuvOCamlHome_Override=$(/usr/bin/cygpath -a "$DKMLNATIVEDIR_BUILDHOST")
else
autodetect_dkmlvars_DiskuvOCamlHome_Override=$DKMLNATIVEDIR_BUILDHOST
fi
autodetect_dkmlvars_DiskuvOCamlBinaryPaths_Override="$autodetect_dkmlvars_DiskuvOCamlHome_Override/usr/bin;$autodetect_dkmlvars_DiskuvOCamlHome_Override/bin"
autodetect_dkmlvars_DiskuvOCamlDeploymentId_Override="default-592592597"
autodetect_dkmlvars_DiskuvOCamlVersion_Override=2.1.0
autodetect_dkmlvars_DiskuvOCamlMSYS2Dir_Override=
}
autodetect_dkmlvars() {
autodetect_dkmlvars_DiskuvOCamlVarsVersion_Override=${DiskuvOCamlVarsVersion:-}
autodetect_dkmlvars_DiskuvOCamlHome_Override=${DiskuvOCamlHome:-}
Expand Down Expand Up @@ -139,11 +163,15 @@ autodetect_dkmlvars() {
# shellcheck disable=SC1090
. "$DKMLPARENTHOME_BUILDHOST\\dkmlvars.sh"
fi
else
default_dkmlvars
fi
else
if [ -e "$DKMLPARENTHOME_BUILDHOST/dkmlvars.sh" ]; then
# shellcheck disable=SC1091
. "$DKMLPARENTHOME_BUILDHOST/dkmlvars.sh"
else
default_dkmlvars
fi
fi
# Overrides
Expand Down Expand Up @@ -559,6 +587,13 @@ is_cygwin_build_machine() {
return 1
}

is_macos_build_machine() {
if [ -x /usr/bin/uname ] && [ "$(/usr/bin/uname -s)" = Darwin ]; then
return 0
fi
return 1
}

# Inputs:
# - $1 - The PLATFORM
is_arg_windows_platform() {
Expand Down

0 comments on commit 23aecfc

Please sign in to comment.