summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config_host.mk.in4
-rw-r--r--configure.ac87
-rw-r--r--solenv/gbuild/DotnetLibrary.mk2
3 files changed, 72 insertions, 21 deletions
diff --git a/config_host.mk.in b/config_host.mk.in
index 70e8552fdced..b9c357aaf19b 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -137,6 +137,8 @@ export DISABLE_CVE_TESTS=@DISABLE_CVE_TESTS@
export DISABLE_DYNLOADING=@DISABLE_DYNLOADING@
export DISABLE_PYTHON=@DISABLE_PYTHON@
export DOCDIR=@DOCDIR@
+DOTNET=@DOTNET@
+DOTNET_ROOT=@DOTNET_ROOT@
export DOXYGEN=@DOXYGEN@
export DO_FETCH_TARBALLS=@DO_FETCH_TARBALLS@
export DRAGONBOX_CFLAGS=@DRAGONBOX_CFLAGS@
@@ -170,7 +172,7 @@ export ENABLE_DBGUTIL=@ENABLE_DBGUTIL@
export ENABLE_DBUS=@ENABLE_DBUS@
export ENABLE_DCONF=@ENABLE_DCONF@
export ENABLE_DEBUG=@ENABLE_DEBUG@
-export ENABLE_DOTNET=@ENABLE_DOTNET@
+ENABLE_DOTNET=@ENABLE_DOTNET@
SYSTEM_DRAGONBOX=@SYSTEM_DRAGONBOX@
SYSTEM_FROZEN=@SYSTEM_FROZEN@
export ENABLE_EPOXY=@ENABLE_EPOXY@
diff --git a/configure.ac b/configure.ac
index 81dfe1a3b924..9bed7d626149 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2177,10 +2177,6 @@ AC_ARG_ENABLE(cli,
[Disable the generation of old CLI bindings.]),
,enable_cli=yes)
-AC_ARG_ENABLE(dotnet,
- AS_HELP_STRING([--enable-dotnet],
- [Enables or disables .NET 8.0 support and bindings generation.]))
-
dnl ===================================================================
dnl Optional Packages (--with/without-)
dnl ===================================================================
@@ -2840,6 +2836,12 @@ AC_ARG_WITH(keep-awake,
If no command is specified, defaults to using Awake (from Microsoft PowerToys) on Windows
and caffeinate on macOS]))
+AC_ARG_WITH(dotnet,
+ AS_HELP_STRING([--with-dotnet=<absolute path to dotnet executable>],
+ [Specify the dotnet executable used to build .NET bindings and components.
+ Requires .NET SDK 8 or higher. To disable building .NET components, use
+ --without-dotnet or --with-dotnet=no.]))
+
dnl ===================================================================
dnl Branding
dnl ===================================================================
@@ -3587,15 +3589,16 @@ COMPATH=`echo $COMPATH | $SED "s@/[[Bb]][[Ii]][[Nn]]\\\$@@"`
dnl ===================================================================
dnl .NET support
dnl ===================================================================
+
AC_MSG_CHECKING([whether to build with .NET support])
-if test "$enable_dotnet" != "no"; then
+if test "$with_dotnet" != no; then
if test "$DISABLE_SCRIPTING" = TRUE; then
AC_MSG_RESULT([no, overridden by --disable-scripting])
+ with_dotnet=no
ENABLE_DOTNET=""
- enable_dotnet=no
else
AC_MSG_RESULT([yes])
- ENABLE_DOTNET="TRUE"
+ ENABLE_DOTNET=TRUE
fi
else
AC_MSG_RESULT([no])
@@ -3603,26 +3606,72 @@ else
fi
if test "$ENABLE_DOTNET" = TRUE; then
- AC_PATH_PROG(DOTNET, dotnet)
- if test "$DOTNET" != ""; then
- AC_MSG_CHECKING([whether .NET SDK is installed])
- DOTNET_SDK_VERSION=`dotnet --list-sdks`
- if test "$DOTNET_SDK_VERSION" != ""; then
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_FEATURE_DOTNET)
+ if test -n "$with_dotnet" && test "$with_dotnet" != yes; then
+ dnl the user explicitly asks for a particular dotnet executable here
+
+ AC_MSG_CHECKING([for dotnet])
+ PathFormat "$with_dotnet"
+ DOTNET="$formatted_path_unix"
+
+ if test -f "$DOTNET"; then
+ dnl the user provided dotnet is valid
+ AC_MSG_RESULT([$formatted_path])
else
- AC_MSG_RESULT([no])
+ dnl since the user wants to use a particular dotnet executable,
+ dnl error out and let them correct the path instead of silently disabling.
+
+ AC_MSG_ERROR([$DOTNET is not a valid dotnet executable])
ENABLE_DOTNET=""
fi
else
- ENABLE_DOTNET=""
+ dnl no specific path to dotnet provided, try looking in $PATH
+
+ AC_PATH_PROGS(DOTNET, [dotnet dotnet.exe])
+ PathFormat "$DOTNET"
+ DOTNET="$formatted_path_unix"
+
+ if test -z "$DOTNET"; then
+ dnl since the user does not specify any particular dotnet
+ dnl silently disable here instead of erroring out, to prevent
+ dnl breaking their build, as --with-dotnet is enabled by default.
+
+ AC_MSG_WARN([dotnet not found, disabling .NET support])
+ ENABLE_DOTNET=""
+ fi
+ fi
+
+ if test -n "$DOTNET"; then
+ dnl the dotnet executable was found, but no guarantees on whether
+ dnl it contains SDK version 8 or higher unless we check.
+
+ AC_MSG_CHECKING([for .NET SDK 8 or higher])
+ dotnet_sdk_ver_major=`"$DOTNET" --version | "$AWK" -F. '{ print $1 }'`
+ if test "$dotnet_sdk_ver_major" -ge 8; then
+ dnl the SDK seems valid, get the root directory
+
+ dotnet_sdk_ver=`"$DOTNET" --version | "$SED" 's/\r//g'`
+ dotnet_sdk_dir=`"$DOTNET" --list-sdks | "$AWK" -F [[]][[]] "/^$dotnet_sdk_ver/"'{ print $2 }' | "$SED" 's/\r//g'`
+ PathFormat "$dotnet_sdk_dir"
+ DOTNET_ROOT=`dirname "$formatted_path_unix"`
+
+ AC_MSG_RESULT([yes])
+ else
+ dnl silently disable for same reason as before
+
+ AC_MSG_RESULT([no, disabling .NET support])
+ ENABLE_DOTNET=""
+ fi
fi
fi
-AC_SUBST(ENABLE_DOTNET)
+if test "$ENABLE_DOTNET" != TRUE; then
+ DOTNET=""
+ DOTNET_ROOT=""
+fi
-dnl set ENABLE_DOTNET="TRUE" for build-time and run-time .NET support
-dnl set ENABLE_DOTNET="" for no .NET support at all
+AC_SUBST(ENABLE_DOTNET)
+AC_SUBST(DOTNET)
+AC_SUBST(DOTNET_ROOT)
dnl ===================================================================
dnl Java support
diff --git a/solenv/gbuild/DotnetLibrary.mk b/solenv/gbuild/DotnetLibrary.mk
index 9d20638f0738..61a52545e03c 100644
--- a/solenv/gbuild/DotnetLibrary.mk
+++ b/solenv/gbuild/DotnetLibrary.mk
@@ -55,7 +55,7 @@ $(call gb_DotnetLibrary_get_target,%) :
echo "$(DOTNET_ITEM_ELEMENTS)" >> $$P && \
echo "</ItemGroup>" >> $$P && \
echo "</Project>" >> $$P && \
- dotnet build $$P $(DOTNET_BUILD_FLAGS) \
+ "$(DOTNET)" build $$P $(DOTNET_BUILD_FLAGS) \
-o $(call gb_DotnetLibrary_get_workdir,$*) \
> $@.log 2>&1 || \
(echo \