summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorRMZeroFour <ritobroto04@gmail.com>2024-06-27 22:30:44 +0530
committerHossein <hossein@libreoffice.org>2024-08-03 10:31:11 +0200
commit5f4083ffa9e4ecd073063c904412f83986b8e813 (patch)
tree82ec5148b9fe53b2f45f37d44f384c6bfced2585 /configure.ac
parent67afda89557cd0d3bd181e7c3c8d1406075ea364 (diff)
.NET Bindings: Upgrade --enable-dotnet to --with-dotnet
This commit changes the existing --enable-dotnet switch into --with-dotnet, allowing users to pass in a different dotnet executable than the one on their PATH, similar to --with-java. This is used to determine the variables DOTNET and DOTNET_ROOT. Change-Id: Ia4f02dfdbd33d7629a800a076f758b26bb186d9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169656 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac87
1 files changed, 68 insertions, 19 deletions
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