aboutsummaryrefslogtreecommitdiffstats
path: root/Mk/Uses/mono.mk
blob: 9d15cc3c05639add00a32d02c3c0cd37f07802df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# $FreeBSD$
#
# mono (c#) support
#
# Feature:  mono
# Usage:    USES=mono:ARGS
# Valid ARGS:   nuget
#
# MAINTAINER=   mono@FreeBSD.org
#
# Arguments:
#
# nuget     Specifies that the port uses nuget packages.  The
#       variables NUGET_DEPENDS needs to be set with the names,
#       versions and optionally the port origin of the nuget
#       packages in the format:
#           ${name}=${version}(:${PKGORIGIN})
#
# Targets:
#
# makenuget This target will output the NUGET_DEPENDS based on the
#       port's packages.config file.
#
# Variables overrideable by the port:
#
# NUGET_PACKAGEDIR  The directory in which the port expects the
#           nuget packages to be available
#           default: ${WRKSRC}/packages

.if !defined(_INCLUDE_USES_MONO_MK)
_INCLUDE_USES_MONO_MK=  yes

.if !empty(mono_ARGS:Nnuget)
IGNORE= USES=mono only supports an optional nuget argument
.endif

# Set the location of the .wapi directory so we write to a location we
# can always assume to be writable.
MONO_SHARED_DIR=    ${WRKDIR}
CONFIGURE_ENV+=     MONO_SHARED_DIR="${MONO_SHARED_DIR}"
MAKE_ENV+=      MONO_SHARED_DIR="${MONO_SHARED_DIR}" TZ=UTC
BUILD_DEPENDS+=     mono:lang/mono
RUN_DEPENDS+=       mono:lang/mono

# Set the location that webaps served by XSP should use.
XSP_DOCROOT=        ${PREFIX}/www/xsp

# gac utilities
GACUTIL=${LOCALBASE}/bin/gacutil /root ${PREFIX}/lib/ /gacdir ${PREFIX}/lib
GACUTIL_INSTALL=${GACUTIL} /i
GACUTIL_INSTALL_PACKAGE=${GACUTIL} /i /package 1.0 /package 2.0

.if ${mono_ARGS:Mnuget}
NUGET_PACKAGEDIR=   ${WRKSRC}/packages

.  for depend in ${NUGET_DEPENDS}
id=     ${depend:C/=.*$//}
version=    ${depend:C/^.*=//}
group=      nuget_${id:S/.//g:S/-//g}
nupkg=      ${id:tl}.${version}.nupkg
NUPKG_${group}:=    ${nupkg}
DISTFILES_${group}:=    ${nupkg}:${group}
MASTER_SITES_${group}:= https://www.nuget.org/api/v2/package/${id}/${version}?dummy=/:${group}
NUGET_NUPKGS_${group}:= ${nupkg}:${depend}

NUGET_DISTFILES+=${NUPKG_nuget_${depend:C/=.*$//:S/.//g:S/-//g}}
DISTFILES+= ${DISTFILES_nuget_${depend:C/=.*$//:S/.//g:S/-//g}}
MASTER_SITES+=  ${MASTER_SITES_nuget_${depend:C/=.*$//:S/.//g:S/-//g}}
NUGET_NUPKGS+=  ${NUGET_NUPKGS_nuget_${depend:C/=.*$//:S/.//g:S/-//g}}
.  endfor

# Prevent the nuget packages from being extracted (and poluting ${WRKDIR}, however
# only bmake supports this.
.  if !defined(EXTRACT_ONLY) && defined(.PARSEDIR)
EXTRACT_ONLY=   ${_DISTFILES:[0]:C/${NUGET_DISTFILES}//g}
.  endif

_USES_extract+= 900:nuget-extract
nuget-extract:
.  for nupkg in ${NUGET_NUPKGS}
    @${MKDIR} ${NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S/=/./}
    @${LN} -s ${NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S/=/./} ${NUGET_PACKAGEDIR}/${nupkg:C/^.*://:C/=.*//}
    @tar -xf ${DISTDIR}/${nupkg:C/:.*$//} -C ${NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S/=/./} \
        -s/%2B/\+/g -s/%2B/\+/g -s/%2B/\+/g \
        --exclude '\[Content_Types\].xml' \
        --exclude package/ \
        --exclude _rels/
.  endfor
.endif

makenuget: patch
    @${FIND} ${WRKSRC} -name packages.config | \
        ${XARGS} ${SED} -nE 's|.*<package id="([^"]+)" version="([^"]+)"[^/]*/>.*|\1-\2|gp' | \
        ${SORT} -u | \
        ${SED} \
            -e '1s|^|NUGET_DEPENDS= |' \
            -e '2,$$s|^|        |g' \
            -e '$$!s|$$| \\|g'

.endif