Fork me on GitHub

USE_DOTNET and USE_MSBUILD

Gentoo Mono Handbook
 

USE_DOTNET

Actually, USE_DOTNET name is confusing.
The better name should be "THIS_EBUILD_SUPPORT_AND_IS_INSTALLED_FOR_USE_WITH_THE_FOLLOWING_DOTNET_RUNTIMES"
or "IUSE_DOTNET", to indicate that it should be placed inside ebuild.

Ebuild can declare which version it understands: USE_DOTNET="net40 net20"
https://github.com/gentoo/dotnet/blob/master/dev-dotnet/fake/fake-3.23.0.ebuild#L6
here are the sample values: https://github.com/gentoo/dotnet/blob/master/eclass/dotnet.eclass#L40

USE_DOTNET is concatenated to IUSE variable with "inherit dotnet" line
that's why it is not necessary to mention net45 in IUSE for the second time.

The implementation is here:
https://github.com/gentoo/dotnet/blob/master/eclass/dotnet.eclass#L28-L36

DOTNET_TARGETS variable (specified in /etc/portage/make.conf) just adds a "+" sign before some IUSE-flags.

DOTNET_TARGETS

https://github.com/gentoo/dotnet/blob/master/readme.md
instructs the user to specify necessary platforms in /etc/portage/make.conf
«add the following USE flags if relevant.
add DOTNET_TARGETS="net45 net40" to make.conf»
The great mystery is why it was not possible to
just use conventional USE-flags in /etc/portage/make.conf and IUSE in the text of ebuilds.

USE_EXPAND variables

Gentoo have a mechanism for creating additional kinds of USE-flags.
see USE_EXPAND and ARCH USE Flags
USE_EXPAND
Defines a list of variables which are to be treated incrementally and whose contents are to be expanded into the USE variable as passed to ebuilds.
USE_EXPAND_UNPREFIXED
Similar to USE_EXPAND, but no prefix is used. If the repository contains any package using an EAPI supporting
«USE_EXPAND values may be forced or masked by using expand_name_value.»
https://projects.gentoo.org/pms/7/pms.html

The USE_EXPAND list is set in profiles/base/make.defaults
(or USE_EXPAND can be modified in /etc/portage/make.conf)

«all USE_EXPAND variables are always exported with filtered USE flags inside, even if none of those flags are declared in IUSE. This is the behavior required for EAPI 5+ by the PMS.» «why should USE_EXPAND have any effect on a package which doesn't declare the corresponding flags in IUSE?»
https://archives.gentoo.org/gentoo-portage-dev/message/1c5724058e4f484f3a76ba787d15cdc3

We see that the necessary steps are:
1) add USE-flags into IUSE (probably in expanded form)
2) add name of variable into USE_EXPAND

USE_EXPAND_VALUES_${v} - the (undocumented) profile variable
USE_EXPAND_UNPREFIXED (this list must contain at least ARCH)

Each variable, mentioned in USE_EXPAND is displayed separately during USE-flags processing.
(example is needed here)

An idea to convert USE_DOTNET into expand variable

Table:  Example Variable Settings

VariableValue
IUSE_IMPLICITprefix selinux
USE_EXPANDELIBC KERNEL USERLAND
USE_EXPAND_UNPREFIXEDARCH
USE_EXPAND_IMPLICITARCH ELIBC KERNEL USERLAND
USE_EXPAND_VALUES_ARCHamd64 ppc ppc64 x86 x86-fbsd x86-solaris
USE_EXPAND_VALUES_ELIBCFreeBSD glibc
USE_EXPAND_VALUES_KERNELFreeBSD linux SunOS
USE_EXPAND_VALUES_USERLANDBSD GNU


USE_DOTNET looks like UNPREFIXED and IMPLICIT
I propose to make it conventional USE-expand variable (or remove at all !!!, because .Net 2.0-3.5 is deprecated and there is only one slot for .Net 4.x in Gentoo)

Profile IUSE injection (profile-iuse-inject)

profile defined IUSE injection, since EAPI-5
https://projects.gentoo.org/pms/7/pms.html#x1-56001r4

USE_MSBUILD

There are at least 2 build systems - msbuild and xbuild.
They have their own USE-flags "msbuild" and "xbuild".
But msbuild have a slotted install, that's why one more variable (USE_MSBUILD) was added and used.
Some msbuild tasks can be used with each of build systems.



FRAMEWORK variable is set in pkg_setup, so it should be available in src_prepare https://devmanual.gentoo.org/ebuild-writing/functions/ this allow to apply patches based on FRAMEWORK variable value

DOTNET_TARGETS variable?
 * ERROR: app-editors/mypad-1.0.3_p201606130::shnurise failed (setup phase):
 *   USE Flag 'net45' not in IUSE for app-editors/mypad-1.0.3_p201606130
 
MSBUILD: error MSBUILD0004: Too many project files specified