thfr commited his (long) diff to enable mono support in Godot games.
It's great!  With this we can play several more titles on OpenBSD and
that's awesome.

Since mono is not available on all arch, instead of setting
ONLY_FOR_ARCHS (which could still be done if we want to), we decided
to build the mono support only on MONO_ARCHS.

One peculiarity to keep in mind about godot is that we're shipping the
-main package with the game engine alone, and the -tools package with
the engine plus the editor.  This allows folks that only want to play
games to install -main, and who wants to also develop on OpenBSD to
install the -tools package.

Now, with mono both subpackages needs some shared mono stuff, which
thfr moved in the -sharp subpackage to avoid collisions between -main
and -tools.

Here, I'm attempting to simplify his work.  thfr diff was already big
enough that we decided to commit it first and polish it once landed,
to avoid a tiresome ping-pong of nitpicking.

so, my idea is to drop the IS_MONO_ARCH loop and use PROPERTIES:Mmono
(thanks espie for the tip!) and a PSEUDO_FLAVOR to:

 1. disable the -sharp subpackage
 2. don't build mono support in -main and -tools

which to me resambles how x11/wxWidgets uses no_webview (my first and
only experience so far with PSEUDO_FLAVORS.)

If it's preferred to use an actual flavor, fine with me.

thfr and I decided against adding a -mono/-no-mono flavor to avoid
building 4 packages (two -main and two -tools) which can be annoying.
First for discovery (what -main should I install??) and further
confusions (imagine if one installs -main without mono and then
-tools,mono.)

Thruth to be told, I often considered to just use flavors for
everything, including -tools.  It gets a bit awkward with FULLPKGNAME
(I want -main and -tools to be installable together), but can be done.
Building twice in do-build and subpackages were an attempt to reduce
the build time, but in hindsight I could have done better.

This packages for me and runs.  If it's not a blasfemy, I'd like to go
ahead with this and then test the 3.5.3 update that was released just
today :-)


Thanks,

Omar Polo

Index: Makefile
===================================================================
RCS file: /home/cvs/ports/games/godot/Makefile,v
retrieving revision 1.51
diff -u -p -r1.51 Makefile
--- Makefile    25 Sep 2023 10:03:03 -0000      1.51
+++ Makefile    25 Sep 2023 10:30:13 -0000
@@ -7,7 +7,7 @@ COMMENT-sharp =         glue for mono/C# module
 V =            3.5.2
 DISTNAME =     godot-${V}-stable
 PKGNAME =      godot-${V}
-REVISION =     6
+REVISION =     7
 
 CATEGORIES =   games
 
@@ -20,6 +20,9 @@ PERMIT_PACKAGE =      Yes
 
 MULTI_PACKAGES =       -main -tools -sharp
 
+PSEUDO_FLAVORS =       no_sharp
+FLAVOR ?=
+
 WANTLIB += ${COMPILER_LIBCXX} BulletCollision BulletDynamics BulletSoftBody
 WANTLIB += GL LinearMath X11 X11-xcb Xau Xcursor Xdmcp Xext Xfixes
 WANTLIB += Xi Xinerama Xrandr Xrender Xxf86vm c drm enet execinfo
@@ -100,14 +103,7 @@ DPB_PROPERTIES =   parallel
 
 .include <bsd.port.arch.mk>
 
-IS_MONO_ARCH=
-.for _arch in ${MONO_ARCHS}
-.  if ${MACHINE_ARCH} == ${_arch}
-IS_MONO_ARCH = 1
-.  endif
-.endfor
-
-.if !empty(IS_MONO_ARCH)
+.if ${PROPERTIES:Mmono}
 USE_WXNEEDED =         Yes
 USE_NOBTCFI =          Yes
 PORTHOME =             ${WRKDIR}/nugethome
@@ -128,17 +124,8 @@ RUN_DEPENDS-tools +=       devel/msbuild \
                        games/godot,-sharp
 GLUEDIR =      ${WRKDIR}/godot-${V}-mono-glue
 MONOSUFFIX =   .mono
-SHARP_POST_EXTRACT =   mkdir -p        ${PORTHOME}/.nuget; \
-       mv      ${WRKDIR}/godot-${V}-nuget-packages 
${PORTHOME}/.nuget/packages; \
-       mv      ${GLUEDIR}/mono_glue.gen.cpp ${WRKSRC}/modules/mono/glue/; \
-       mv      ${GLUEDIR}/GodotSharp/GodotSharp/Generated \
-               ${WRKSRC}/modules/mono/glue/GodotSharp/GodotSharp/; \
-       mv      ${GLUEDIR}/GodotSharp/GodotSharpEditor/Generated \
-               ${WRKSRC}/modules/mono/glue/GodotSharp/GodotSharpEditor/
-SHARP_DO_INSTALL =     ${INSTALL_DATA_DIR} ${PREFIX}/share/godot; \
-       cp -R   ${WRKBUILD}/bin/GodotSharp ${PREFIX}/share/godot/
 .else
-BUILD_PACKAGES :=      ${BUILD_PACKAGES:N-sharp}
+FLAVOR +=              no_sharp
 MONOSUFFIX =
 .endif
 
@@ -165,7 +152,15 @@ post-extract:
        cp -R   ${FILESDIR}/sndio ${WRKDIST}/drivers
        cp      ${FILESDIR}/ujoy/joypad_openbsd.{cpp,h} \
                ${WRKDIST}/platform/x11/
-       ${SHARP_POST_EXTRACT}
+.if !${FLAVOR:Mno_sharp}
+       mkdir -p ${PORTHOME}/.nuget
+       mv      ${WRKDIR}/godot-${V}-nuget-packages ${PORTHOME}/.nuget/packages
+       mv      ${GLUEDIR}/mono_glue.gen.cpp ${WRKSRC}/modules/mono/glue/
+       mv      ${GLUEDIR}/GodotSharp/GodotSharp/Generated \
+               ${WRKSRC}/modules/mono/glue/GodotSharp/GodotSharp/
+       mv      ${GLUEDIR}/GodotSharp/GodotSharpEditor/Generated \
+               ${WRKSRC}/modules/mono/glue/GodotSharp/GodotSharpEditor
+.endif
 
 pre-configure:
        ${SUBST_CMD} ${WRKSRC}/misc/dist/linux/*.desktop
@@ -190,7 +185,10 @@ do-install:
        ${INSTALL_PROGRAM} 
${WRKBUILD}/bin/godot.x11.opt.tools.${BINSUFFIX}${MONOSUFFIX} \
                ${PREFIX}/bin/godot-tools
        # GodotSharp files if built
-       ${SHARP_DO_INSTALL}
+.if !${FLAVOR:Mno_sharp}
+       ${INSTALL_DATA_DIR} ${PREFIX}/share/godot
+       cp -R   ${WRKBUILD}/bin/GodotSharp ${PREFIX}/share/godot/
+.endif
        # Rest: man pages, icons, desktop integration
        ${INSTALL_MAN_DIR} ${PREFIX}/man/man6
        ${INSTALL_MAN} ${WRKSRC}/misc/dist/linux/godot.6 \

Reply via email to