Nam Nguyen writes:

> here is an update to devel/rgbds.
>
> This diff:
> - updates to 0.6.1 released on Dec 3, 2022.
> - adds devel/bison and shells/bash to BUILD_DEPENDS
>   (bash appears in many of the shell scripts and bison appears in
>   src/check_bison_ver.sh.).
> - pledge is reapplied to the new C and C++ files. Use err instead of
>   errx. Notably, gfx/main.cpp now uses fputs to print to stderr then
>   calls exit(1) instead of errx, which is for C only.
> - workaround in Makefile patch from [1] for vasprintf bug in openbsd
>   headers when POSIX_C_SOURCE=200809L is defined. This was discussed by
>   bentley@ in [1] and rsadowski@ in [2]. I propose having this as a
>   temporary workaround until openbsd's llvm headers can be fixed with a
>   more optimal solution[3].
> [1] https://github.com/gbdev/rgbds/issues/1111
> [2] https://marc.info/?l=openbsd-tech&m=161833545600505&w=2
> [3] https://marc.info/?l=openbsd-bugs&m=157758838031146&w=2

Please find a fresh diff inline that additionally regens WANTLIB.

>
>
> Testing:
> https://gbdev.io/gb-asm-tutorial/part1/hello_world.html
>
> I followed this hello world tutorial and loaded the rom in
> emulators/sameboy. It successfully printed.
>
> Feedback and tests are welcome. OK?

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/rgbds/Makefile,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 Makefile
--- Makefile    11 Mar 2022 18:53:10 -0000      1.10
+++ Makefile    18 Apr 2023 04:45:09 -0000
@@ -2,7 +2,7 @@ FIX_EXTRACT_PERMISSIONS =       Yes
 
 COMMENT =      Game Boy development system
 
-V =            0.4.2
+V =            0.6.1
 DISTNAME =     rgbds-$V
 
 CATEGORIES =   devel
@@ -15,12 +15,15 @@ MAINTAINER =        Anthony J. Bentley <anthony
 PERMIT_PACKAGE =       Yes
 
 # uses pledge()
-WANTLIB += c m png z
+WANTLIB += ${COMPILER_LIBCXX} c m png
 
 MASTER_SITES = https://github.com/gbdev/rgbds/releases/download/v$V/
 
 COMPILER =     base-clang ports-gcc
 COMPILER_LANGS =       c
+
+BUILD_DEPENDS =        devel/bison \
+               shells/bash
 
 LIB_DEPENDS =  graphics/png
 
Index: distinfo
===================================================================
RCS file: /cvs/ports/devel/rgbds/distinfo,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 distinfo
--- distinfo    13 Dec 2020 14:24:29 -0000      1.8
+++ distinfo    18 Apr 2023 04:45:09 -0000
@@ -1,2 +1,2 @@
-SHA256 (rgbds-0.4.2.tar.gz) = C6xG8NPPq/hoPGIUW58BpgfHAyle8peKPlSPEG9Q+sE=
-SIZE (rgbds-0.4.2.tar.gz) = 208023
+SHA256 (rgbds-0.6.1.tar.gz) = hyAYUJxsvC2elHoabVCf2dxWoBCCf2CMX0+kbeL6GGo=
+SIZE (rgbds-0.6.1.tar.gz) = 8040703
Index: patches/patch-Makefile
===================================================================
RCS file: patches/patch-Makefile
diff -N patches/patch-Makefile
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Makefile      18 Apr 2023 04:45:09 -0000
@@ -0,0 +1,20 @@
+workaround for vasprintf bug in openbsd headers when
+POSIX_C_SOURCE=200809L is defined
+
+see:
+https://github.com/gbdev/rgbds/issues/1111
+https://marc.info/?l=openbsd-tech&m=161833545600505&w=2
+https://marc.info/?l=openbsd-bugs&m=157758838031146&w=2
+
+Index: Makefile
+--- Makefile.orig
++++ Makefile
+@@ -42,7 +42,7 @@ CXXFLAGS     ?= -O3 -flto -DNDEBUG
+ REALCFLAGS    := ${CFLAGS} ${WARNFLAGS} -std=gnu11 -I include \
+                  -D_POSIX_C_SOURCE=200809L -D_ISOC11_SOURCE
+ REALCXXFLAGS  := ${CXXFLAGS} ${WARNFLAGS} -std=c++17 -I include \
+-                 -D_POSIX_C_SOURCE=200809L -fno-exceptions -fno-rtti
++                 -fno-exceptions -fno-rtti
+ # Overridable LDFLAGS
+ LDFLAGS               ?=
+ # Non-overridable LDFLAGS
Index: patches/patch-src_asm_main_c
===================================================================
RCS file: /cvs/ports/devel/rgbds/patches/patch-src_asm_main_c,v
retrieving revision 1.6
diff -u -p -u -p -r1.6 patch-src_asm_main_c
--- patches/patch-src_asm_main_c        11 Mar 2022 18:53:10 -0000      1.6
+++ patches/patch-src_asm_main_c        18 Apr 2023 04:45:09 -0000
@@ -1,22 +1,21 @@
 Index: src/asm/main.c
 --- src/asm/main.c.orig
 +++ src/asm/main.c
-@@ -34,6 +34,8 @@
- #include "helpers.h"
- #include "version.h"
+@@ -49,6 +49,8 @@
+ char const *__asan_default_options(void) { return "detect_leaks=0"; }
+ #endif
  
 +int pledge(const char *, const char *);
 +
  // Old Bison versions (confirmed for 2.3) do not forward-declare `yyparse` in 
the generated header
  // Unfortunately, macOS still ships 2.3, which is from 2008...
  int yyparse(void);
-@@ -307,6 +309,9 @@ int main(int argc, char *argv[])
-       cldefines = malloc(cldefines_bufsize);
-       if (!cldefines)
-               fatalerror("No memory for command line defines\n");
-+
+@@ -148,6 +150,8 @@ static void print_usage(void)
+ 
+ int main(int argc, char *argv[])
+ {
 +      if (pledge("stdio rpath wpath cpath", NULL) == -1)
 +              fatalerror("pledge");
+       time_t now = time(NULL);
+       char const *sourceDateEpoch = getenv("SOURCE_DATE_EPOCH");
  
- #if defined(YYDEBUG) && YYDEBUG
-       yydebug = 1;
Index: patches/patch-src_fix_main_c
===================================================================
RCS file: /cvs/ports/devel/rgbds/patches/patch-src_fix_main_c,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 patch-src_fix_main_c
--- patches/patch-src_fix_main_c        11 Mar 2022 18:53:10 -0000      1.3
+++ patches/patch-src_fix_main_c        18 Apr 2023 04:45:09 -0000
@@ -1,22 +1,30 @@
 Index: src/fix/main.c
 --- src/fix/main.c.orig
 +++ src/fix/main.c
-@@ -49,6 +49,8 @@ static struct option const longopts[] = {
+@@ -21,6 +21,7 @@
+ 
+ #include "extern/getopt.h"
+ 
++#include "error.h"
+ #include "helpers.h"
+ #include "platform.h"
+ #include "version.h"
+@@ -62,6 +63,8 @@ static struct option const longopts[] = {
        { NULL,               no_argument,       NULL, 0   }
  };
  
 +int pledge(const char *, const char *);
 +
- static void print_usage(void)
+ static void printUsage(void)
  {
        fputs(
-@@ -107,6 +109,9 @@ int main(int argc, char *argv[])
-       int ramsize = 0;   /* RAM size ID */
-       int version = 0;   /* mask ROM version number */
-       int padvalue = 0;  /* to pad the rom with if it changes size */
+@@ -1221,6 +1224,9 @@ int main(int argc, char *argv[])
+ {
+       nbErrors = 0;
+       int ch;
 +
 +      if (pledge("stdio rpath wpath cpath", NULL) == -1)
-+              errx(1, "pledge");
++              err("pledge");
  
-       while ((ch = musl_getopt_long_only(argc, argv, optstring, longopts,
-                                          NULL)) != -1) {
+       while ((ch = musl_getopt_long_only(argc, argv, optstring, longopts, 
NULL)) != -1) {
+               switch (ch) {
Index: patches/patch-src_gfx_main_c
===================================================================
RCS file: patches/patch-src_gfx_main_c
diff -N patches/patch-src_gfx_main_c
--- patches/patch-src_gfx_main_c        11 Mar 2022 18:53:10 -0000      1.5
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,22 +0,0 @@
-Index: src/gfx/main.c
---- src/gfx/main.c.orig
-+++ src/gfx/main.c
-@@ -52,6 +52,8 @@ static struct option const longopts[] = {
-       { NULL,              no_argument,       NULL, 0   }
- };
- 
-+int pledge(const char *, const char *);
-+
- static void print_usage(void)
- {
-       fputs(
-@@ -81,6 +83,9 @@ int main(int argc, char *argv[])
-       struct Mapfile tilemap = {0};
-       struct Mapfile attrmap = {0};
-       char *ext;
-+
-+      if (pledge("stdio rpath wpath cpath", NULL) == -1)
-+              errx(1, "pledge");
- 
-       opts.tilemapfile = "";
-       opts.attrmapfile = "";
Index: patches/patch-src_gfx_main_cpp
===================================================================
RCS file: patches/patch-src_gfx_main_cpp
diff -N patches/patch-src_gfx_main_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_gfx_main_cpp      18 Apr 2023 04:45:09 -0000
@@ -0,0 +1,24 @@
+Index: src/gfx/main.cpp
+--- src/gfx/main.cpp.orig
++++ src/gfx/main.cpp
+@@ -138,6 +138,8 @@ static struct option const longopts[] = {
+     {NULL,                 no_argument,       NULL, 0  }
+ };
+ 
++int pledge(const char *, const char *);
++
+ static void printUsage(void) {
+       fputs("Usage: rgbgfx [-r stride] [-CmuVZ] [-v [-v ...]] [-a <attr_map> 
| -A]\n"
+             "       [-b <base_ids>] [-c <colors>] [-d <depth>] [-L <slice>] 
[-N <nb_tiles>]\n"
+@@ -581,6 +583,11 @@ static char *parseArgv(int argc, char **argv, bool &au
+ 
+ int main(int argc, char *argv[]) {
+       bool autoAttrmap = false, autoTilemap = false, autoPalettes = false, 
autoPalmap = false;
++
++      if (pledge("stdio rpath wpath cpath", NULL) == -1) {
++              fputs("pledge", stderr);
++              exit(1);
++      }
+ 
+       struct AtFileStackEntry {
+               int parentInd; // Saved offset into parent argv
Index: patches/patch-src_link_main_c
===================================================================
RCS file: /cvs/ports/devel/rgbds/patches/patch-src_link_main_c,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 patch-src_link_main_c
--- patches/patch-src_link_main_c       11 Mar 2022 18:53:10 -0000      1.4
+++ patches/patch-src_link_main_c       18 Apr 2023 04:45:09 -0000
@@ -1,22 +1,22 @@
 Index: src/link/main.c
 --- src/link/main.c.orig
 +++ src/link/main.c
-@@ -144,6 +144,8 @@ FILE *openFile(char const *fileName, char const *mode)
- /* Short options */
- static char const *optstring = "dl:m:n:O:o:p:s:tVvwx";
+@@ -167,6 +167,8 @@ FILE *openFile(char const *fileName, char const *mode)
+ // Short options
+ static const char *optstring = "dl:m:Mn:O:o:p:S:s:tVvWwx";
  
 +int pledge(const char *, const char *);
 +
  /*
   * Equivalent long options
   * Please keep in the same order as short opts
-@@ -207,6 +209,9 @@ int main(int argc, char *argv[])
+@@ -359,6 +361,9 @@ int main(int argc, char *argv[])
        int optionChar;
-       char *endptr; /* For error checking with `strtol` */
-       unsigned long value; /* For storing `strtoul`'s return value */
+       char *endptr; // For error checking with `strtoul`
+       unsigned long value; // For storing `strtoul`'s return value
 +
 +      if (pledge("stdio rpath wpath cpath", NULL) == -1)
-+              errx(1, "pledge");
++              err("pledge");
  
-       /* Parse options */
+       // Parse options
        while ((optionChar = musl_getopt_long_only(argc, argv, optstring,

Reply via email to