Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] cbang: cross-compile, scons: change to python3
@ 2020-05-17 16:25 sgn
  2020-05-17 16:30 ` Johnnynator
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: sgn @ 2020-05-17 16:25 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 414 bytes --]

There is a new pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages cross-compile-cbang
https://github.com/void-linux/void-packages/pull/22047

cbang: cross-compile, scons: change to python3
@pullmoll 

See also: https://github.com/CauldronDevelopmentLLC/cbang/pull/51

A patch file from https://github.com/void-linux/void-packages/pull/22047.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-cross-compile-cbang-22047.patch --]
[-- Type: text/x-diff, Size: 18539 bytes --]

From df23489f4517f360c08729f9cd3b5aed6fc54262 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Sun, 17 May 2020 19:39:37 +0700
Subject: [PATCH 1/3] build-style: scons: add lowercase compiler variable

---
 common/build-style/scons.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/common/build-style/scons.sh b/common/build-style/scons.sh
index 01f309ed0a6..17527d7ac65 100644
--- a/common/build-style/scons.sh
+++ b/common/build-style/scons.sh
@@ -5,7 +5,10 @@ do_build() {
 	: ${make_cmd:=scons}
 
 	${make_cmd} ${makejobs} CC=$CC CXX=$CXX CCFLAGS="$CFLAGS" \
+		cc=$CC cxx=$CXX ccflags="$CFLAGS" \
 		CXXFLAGS="$CXXFLAGS" LINKFLAGS="$LDFLAGS" \
+		cxxflags="$CXXFLAGS" linkflags="$LDFLAGS" \
+		RANLIB="$RANLIB" ranlib="$RANLIB" \
 		prefix=/usr destdir=${DESTDIR} DESTDIR=${DESTDIR} \
 		${make_build_args} ${make_build_target}
 }
@@ -14,7 +17,10 @@ do_install() {
 	: ${make_install_target:=install}
 
 	${make_cmd} ${makejobs} CC=$CC CXX=$CXX CCFLAGS="$CFLAGS" \
+		cc=$CC cxx=$CXX ccflags="$CFLAGS" \
 		CXXFLAGS="$CXXFLAGS" LINKFLAGS="$LDFLAGS" \
+		cxxflags="$CXXFLAGS" linkflags="$LDFLAGS" \
+		RANLIB="$RANLIB" ranlib="$RANLIB" \
 		prefix=/usr destdir=${DESTDIR} DESTDIR=${DESTDIR} \
 		${make_install_args} ${make_install_target}
 }

From c7c6c59f41eff074c98d847075f97bccfdde4abd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Sun, 17 May 2020 20:38:31 +0700
Subject: [PATCH 2/3] scons: switch to python3

---
 srcpkgs/scons/template | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/scons/template b/srcpkgs/scons/template
index 52c8013f7d6..1503094a73d 100644
--- a/srcpkgs/scons/template
+++ b/srcpkgs/scons/template
@@ -1,11 +1,12 @@
 # Template file for 'scons'
 pkgname=scons
 version=3.1.2
-revision=3
-build_style=python2-module
+revision=4
+archs=noarch
+build_style=python3-module
 make_install_args="--standard-lib --install-data=/usr/share"
-hostmakedepends="python python-setuptools"
-depends="python"
+hostmakedepends="python3 python3-setuptools"
+depends="python3"
 short_desc="Software construction tool"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
@@ -15,5 +16,7 @@ checksum="7801f3f62f654528e272df780be10c0e9337e897650b62ddcee9f39fde13f8fb"
 
 
 post_install() {
+	rm -f "$DESTDIR"/usr/bin/scons.bat
+	rm -f "$DESTDIR"/usr/bin/scons-${version}.bat
 	vlicense LICENSE.txt
 }

From c960900617a065e6c4cc73ee9b7eb9feaa2f6553 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Sun, 17 May 2020 23:23:22 +0700
Subject: [PATCH 3/3] cbang: cross compiling

---
 ...config-openssl-correct-version-check.patch |  52 ++++++++
 ...heck-OPENSSL_VERSION-in-compile-time.patch |  47 +++++++
 ...bevent-use-compile-time-sizeof-check.patch | 119 ++++++++++++++++++
 ...ibevent-use-TryCompile-if-applicable.patch |  73 +++++++++++
 ...o-check-for-signature-of-gethostbyna.patch |  90 +++++++++++++
 srcpkgs/cbang/template                        |   4 +-
 6 files changed, 382 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch
 create mode 100644 srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
 create mode 100644 srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch
 create mode 100644 srcpkgs/cbang/patches/0004-libevent-use-TryCompile-if-applicable.patch
 create mode 100644 srcpkgs/cbang/patches/0005-libevent-use-C-to-check-for-signature-of-gethostbyna.patch

diff --git a/srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch b/srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch
new file mode 100644
index 00000000000..a89fccb494e
--- /dev/null
+++ b/srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch
@@ -0,0 +1,52 @@
+From 9e22c0114d010a35128aa67b0dc38cc23f4d873f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 21:53:46 +0700
+Subject: [PATCH 1/5] config/openssl: correct version check
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Current code requires all conditions meet to pass the check, thus,
+return false negative for:
+- 1.0.2 vs 1.1.0
+- 1.1.0 vs 2.0.0
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ config/openssl/__init__.py | 17 ++++++++++-------
+ 1 file changed, 10 insertions(+), 7 deletions(-)
+
+diff --git config/openssl/__init__.py config/openssl/__init__.py
+index 421271cd..e0d3884a 100644
+--- config/openssl/__init__.py
++++ config/openssl/__init__.py
+@@ -6,15 +6,18 @@ def check_version(context, version):
+     context.Message("Checking for openssl version >= %s..." % version)
+ 
+     version = version.split('.')
+-    src = '#include <openssl/opensslv.h>\nint main() {\nreturn ('
+-    src += version[0] + '<= (OPENSSL_VERSION_NUMBER >> 28)'
++    src = '''
++    #include <openssl/opensslv.h>
++    int main() {
++        return (OPENSSL_VERSION_NUMBER >= '''
++    src += '(' + version[0] + ' >> 28)'
+     if 1 < len(version):
+-        src += ' && ' + version[1] + \
+-               '<= ((OPENSSL_VERSION_NUMBER >> 20) & 0xf)'
++        src += ' + (' + version[1] + ' >> 20)'
+     if 2 < len(version):
+-        src += ' && ' + version[2] + \
+-               '<= ((OPENSSL_VERSION_NUMBER >> 12) & 0xf)'
+-    src += ') ? 0 : 1;}\n'
++        src += ' + (' + version[2] + ' >> 12)'
++    src += ''') ? 0 : 1;
++    }
++    '''
+ 
+     ret = context.TryRun(src, '.cpp')[0]
+ 
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch b/srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
new file mode 100644
index 00000000000..df857d8ab2f
--- /dev/null
+++ b/srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
@@ -0,0 +1,47 @@
+From a2d81dfceb153d6388dcff63d8be1140cad7a33e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 22:26:09 +0700
+Subject: [PATCH 2/5] config/openssl: check OPENSSL_VERSION in compile time
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+All of required information are available at compile time, use compile
+time check to support cross compiling.
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ config/openssl/__init__.py | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git config/openssl/__init__.py config/openssl/__init__.py
+index e0d3884a..580d72e7 100644
+--- config/openssl/__init__.py
++++ config/openssl/__init__.py
+@@ -9,17 +9,19 @@ def check_version(context, version):
+     src = '''
+     #include <openssl/opensslv.h>
+     int main() {
+-        return (OPENSSL_VERSION_NUMBER >= '''
++        int  a[(OPENSSL_VERSION_NUMBER >= '''
+     src += '(' + version[0] + ' >> 28)'
+     if 1 < len(version):
+         src += ' + (' + version[1] + ' >> 20)'
+     if 2 < len(version):
+         src += ' + (' + version[2] + ' >> 12)'
+-    src += ''') ? 0 : 1;
++    src += ''')];
++        a[0] = 0;
++        return 0;
+     }
+     '''
+ 
+-    ret = context.TryRun(src, '.cpp')[0]
++    ret = context.TryCompile(src, '.cpp')
+ 
+     context.Result(ret)
+     return ret
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch b/srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch
new file mode 100644
index 00000000000..32254f0bbf5
--- /dev/null
+++ b/srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch
@@ -0,0 +1,119 @@
+From df79b8912f92083e7ef51353e762fa1c67b2593b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 22:44:25 +0700
+Subject: [PATCH 3/5] libevent: use compile time sizeof check
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Taken from https://github.com/scons/scons/wiki/AutoconfRecipes#ac_check_sizeof
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ src/libevent/SConscript | 81 +++++++++++++++++++++++++++++++++++++----
+ 1 file changed, 73 insertions(+), 8 deletions(-)
+
+diff --git src/libevent/SConscript src/libevent/SConscript
+index 89e770c1..2e8373f9 100644
+--- src/libevent/SConscript
++++ src/libevent/SConscript
+@@ -18,22 +18,87 @@ conf.AddTest('CheckSYS_TIMERFD_H', CheckSYS_TIMERFD_H)
+ 
+ 
+ # sizeof
++# https://github.com/scons/scons/wiki/AutoconfRecipes#ac_check_sizeof
++# Sensible default for common types on common platforms.
++_DEFAULTS_SIZEOF = {
++    'short' : [2],
++    'int' : [4, 2],
++    'long' : [4, 8],
++    'long long' : [8, 4],
++    'unsigned short' : [2],
++    'unsigned int' : [4, 2],
++    'unsigned long' : [4, 8],
++    'unsigned long long' : [8, 4],
++    'float' : [4],
++    'double' : [8],
++    'long double' : [12],
++    'size_t' : [4, 8],
++}
++
+ def CheckSizeOf(ctx, type, includes = None):
++    """This check can be used to get the size of a given type,
++    or to check whether the type is of expected size.
++
++    Arguments:
++        - type : str
++            the type to check
++        - includes : sequence
++            list of headers to include in the test code before testing the type
++        Returns:
++                status : int
++                        0 if the check failed, or the found size of the type
++                        if the check succeeded."""
++    minsz = 0
++    maxsz = 16
++
+     src = '''
+       #include <sys/types.h>
+       #include <stdlib.h>
+       #include <stdio.h>
+-      int main() {printf("%d", (int)sizeof(''' + type + ''')); return 0;}
++      #include <stdint.h>
+     '''
++    if includes:
++        src += "\n".join("#include <%s>\n" % i for i in includes)
+ 
+-    if includes is not None:
+-        for inc in includes:
+-            src = '#include <%s>\n%s' % (inc, src)
++    ext = '.c'
++    # test code taken from autoconf: this is a pretty clever hack to find that
++    # a type is of a given size using only compilation. This speeds things up
++    # quite a bit compared to straightforward code using TryRun
++    src += r"""
++typedef %s scons_check_type;
+ 
+-    ctx.Message('Checking size of ' + type + '... ')
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[1]
++int main()
++{
++    static int test_array[1 - 2 * ((long int) sizeof(scons_check_type) > %d)];
++    test_array[0] = 0;
++
++    return 0;
++}
++"""
++
++    # Only check if the given size is the right one
++    ctx.Message('Checking size of %s ... ' % type)
++
++    # Try sensible defaults first
++    try:
++        szrange = _DEFAULTS_SIZEOF[type]
++    except KeyError:
++        szrange = []
++    szrange.extend(range(minsz, maxsz))
++    st = 0
++
++    # Actual test
++    for sz in szrange:
++        st = ctx.TryCompile(src % (type, sz), ext)
++        if st:
++            break
++
++    if st:
++        ctx.Result('%d' % sz)
++        return sz
++    else:
++        ctx.Result('Failed !')
++        return 0
+ 
+ conf.AddTest('CheckSizeOf', CheckSizeOf)
+ 
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/patches/0004-libevent-use-TryCompile-if-applicable.patch b/srcpkgs/cbang/patches/0004-libevent-use-TryCompile-if-applicable.patch
new file mode 100644
index 00000000000..06b73e8b7e6
--- /dev/null
+++ b/srcpkgs/cbang/patches/0004-libevent-use-TryCompile-if-applicable.patch
@@ -0,0 +1,73 @@
+From b31932609b9019f7f72efdc3d67ea16971a34c76 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 22:47:26 +0700
+Subject: [PATCH 4/5] libevent: use TryCompile if applicable
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ src/libevent/SConscript | 24 ++++++++++++------------
+ 1 file changed, 12 insertions(+), 12 deletions(-)
+
+diff --git src/libevent/SConscript src/libevent/SConscript
+index 2e8373f9..f9dceaa5 100644
+--- src/libevent/SConscript
++++ src/libevent/SConscript
+@@ -117,9 +117,9 @@ def CheckDecl(ctx, decl, includes = None):
+             src = '#include <%s>\n%s' % (inc, src)
+ 
+     ctx.Message('Checking for decl ' + decl + '... ')
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[0]
++    ret = ctx.TryCompile(src + '\n', '.c')
++    ctx.Result(ret)
++    return ret
+ 
+ conf.AddTest('CheckDecl', CheckDecl)
+ 
+@@ -133,9 +133,9 @@ def CheckStruct(ctx, struct, includes = None):
+             src = '#include <%s>\n%s' % (inc, src)
+ 
+     ctx.Message('Checking for struct ' + struct + '... ')
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[0]
++    ret = ctx.TryCompile(src + '\n', '.c')
++    ctx.Result(ret)
++    return ret
+ 
+ conf.AddTest('CheckStruct', CheckStruct)
+ 
+@@ -153,9 +153,9 @@ def CheckType(ctx, type, includes = None, defs = None):
+             src = '#define %s\n%s' % (d, src)
+ 
+     ctx.Message('Checking for type ' + type + '... ')
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[0]
++    ret = ctx.TryCompile(src + '\n', '.c')
++    ctx.Result(ret)
++    return ret
+ 
+ conf.AddTest('CheckType', CheckType)
+ 
+@@ -177,9 +177,9 @@ def CheckStructMember(ctx, struct, member, includes = None):
+             src = '#include <%s>\n%s' % (inc, src)
+ 
+     ctx.Message('Checking for %s in struct %s... ' % (member, struct))
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[0]
++    ret = ctx.TryCompile(src + '\n', '.c')
++    ctx.Result(ret)
++    return ret
+ 
+ conf.AddTest('CheckStructMember', CheckStructMember)
+ 
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/patches/0005-libevent-use-C-to-check-for-signature-of-gethostbyna.patch b/srcpkgs/cbang/patches/0005-libevent-use-C-to-check-for-signature-of-gethostbyna.patch
new file mode 100644
index 00000000000..f0181b641d7
--- /dev/null
+++ b/srcpkgs/cbang/patches/0005-libevent-use-C-to-check-for-signature-of-gethostbyna.patch
@@ -0,0 +1,90 @@
+From 9239db8606320967e9e8526f68acd3e641c60ebb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 22:56:41 +0700
+Subject: [PATCH 5/5] libevent: use C++ to check for signature of
+ gethostbyname_r
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+C++ by definition requires matching prototype (both number of arguments,
+order of arguments, and type of arguments) to be compilable.
+
+Use this property to check for signature of gethostbyname_r(3) at
+compile time in order to support cross compiling.
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ src/libevent/SConscript | 23 ++++++++++++++++++++---
+ 1 file changed, 20 insertions(+), 3 deletions(-)
+
+diff --git src/libevent/SConscript src/libevent/SConscript
+index f9dceaa5..be56e29a 100644
+--- src/libevent/SConscript
++++ src/libevent/SConscript
+@@ -184,6 +184,14 @@ def CheckStructMember(ctx, struct, member, includes = None):
+ conf.AddTest('CheckStructMember', CheckStructMember)
+ 
+ 
++def CheckCompileCxx(ctx, msg, src):
++    ctx.Message('Checking for %s... ' % msg)
++    ret = ctx.TryCompile(src + '\n', '.cpp')
++    ctx.Result(ret)
++    return ret
++
++conf.AddTest('CheckCompileCxx', CheckCompileCxx)
++
+ # General compile and run check
+ def CheckRun(ctx, msg, src):
+     ctx.Message('Checking for %s... ' % msg)
+@@ -213,6 +221,9 @@ structs = 'addrinfo in6_addr sockaddr_in6 sockaddr_storage'
+ sizeof = ['int', 'long', 'long long', 'off_t', 'short', 'size_t', 'void *']
+ 
+ gethostbyname_r_3_arg_src = '''
++  #ifndef __cplusplus
++  #error must be compiled as cxx
++  #endif
+   #define _BSD_SOURCE
+   #include <netdb.h>
+   int main(int argc, char **argv) {
+@@ -224,6 +235,9 @@ gethostbyname_r_3_arg_src = '''
+ '''
+ 
+ gethostbyname_r_5_arg_src = '''
++  #ifndef __cplusplus
++  #error must be compiled as cxx
++  #endif
+   #define _BSD_SOURCE
+   #include <netdb.h>
+   int main(int argc, char **argv) {
+@@ -237,6 +251,9 @@ gethostbyname_r_5_arg_src = '''
+ '''
+ 
+ gethostbyname_r_6_arg_src = '''
++  #ifndef __cplusplus
++  #error must be compiled as cxx
++  #endif
+   #define _BSD_SOURCE
+   #include <netdb.h>
+   int main(int argc, char **argv) {
+@@ -336,13 +353,13 @@ def get_event_config_defs():
+     if 'HAVE_EPOLL_CREATE' in defs: defs['HAVE_EPOLL'] = '1'
+ 
+     # gethostbyname_r
+-    if conf.CheckRun('3 arg gethostbyname_r()', gethostbyname_r_3_arg_src):
++    if conf.CheckCompileCxx('3 arg gethostbyname_r()', gethostbyname_r_3_arg_src):
+         defs['HAVE_GETHOSTBYNAME_R_3_ARG'] = '1'
+ 
+-    if conf.CheckRun('5 arg gethostbyname_r()', gethostbyname_r_5_arg_src):
++    if conf.CheckCompileCxx('5 arg gethostbyname_r()', gethostbyname_r_5_arg_src):
+         defs['HAVE_GETHOSTBYNAME_R_5_ARG'] = '1'
+ 
+-    if conf.CheckRun('6 arg gethostbyname_r()', gethostbyname_r_6_arg_src):
++    if conf.CheckCompileCxx('6 arg gethostbyname_r()', gethostbyname_r_6_arg_src):
+         defs['HAVE_GETHOSTBYNAME_R_6_ARG'] = '1'
+ 
+ 
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/template b/srcpkgs/cbang/template
index 3e1d8e2c215..1cd18791844 100644
--- a/srcpkgs/cbang/template
+++ b/srcpkgs/cbang/template
@@ -14,10 +14,8 @@ license="LGPL-2.1-only"
 homepage="https://github.com/CauldronDevelopmentLLC/cbang"
 distfiles="https://github.com/CauldronDevelopmentLLC/cbang/archive/${version}.tar.gz>${pkgname}-${version}.tar.gz"
 checksum=332a776ab026c30aa1666ad2482e1bf77fa5c41e3e2f7cde9ff2d98cfd3b4026
-nocross="Cannot cross build with scons"
 
-do_install() {
-	scons ${make_install_args} prefix=${DESTDIR}/usr install
+post_install() {
 	# Create missing symbolic links for the shared library
 	ln -sf libcbang0.so.0.0.1 ${DESTDIR}/usr/lib/libcbang.so.0.0
 	ln -sf libcbang0.so.0.0.1 ${DESTDIR}/usr/lib/libcbang.so.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cbang: cross-compile, scons: change to python3
  2020-05-17 16:25 [PR PATCH] cbang: cross-compile, scons: change to python3 sgn
@ 2020-05-17 16:30 ` Johnnynator
  2020-05-17 16:38 ` pullmoll
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Johnnynator @ 2020-05-17 16:30 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 307 bytes --]

New comment by Johnnynator on void-packages repository

https://github.com/void-linux/void-packages/pull/22047#issuecomment-629824802

Comment:
If you change scons to py3 you also need to test every package that uses scons. Scons build scripts are just python scripts that import scons. (or smth like that)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cbang: cross-compile, scons: change to python3
  2020-05-17 16:25 [PR PATCH] cbang: cross-compile, scons: change to python3 sgn
  2020-05-17 16:30 ` Johnnynator
@ 2020-05-17 16:38 ` pullmoll
  2020-05-17 16:39 ` [PR PATCH] [Updated] " sgn
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pullmoll @ 2020-05-17 16:38 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 302 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/22047#issuecomment-629825860

Comment:
@sgn A really clever trick to avoid tryRun to determine the sizeof(type). However as @Johnnynator said the scons to python3 change needs thorough testing first.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PR PATCH] [Updated] cbang: cross-compile, scons: change to python3
  2020-05-17 16:25 [PR PATCH] cbang: cross-compile, scons: change to python3 sgn
  2020-05-17 16:30 ` Johnnynator
  2020-05-17 16:38 ` pullmoll
@ 2020-05-17 16:39 ` sgn
  2020-05-17 16:40 ` sgn
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: sgn @ 2020-05-17 16:39 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages cross-compile-cbang
https://github.com/void-linux/void-packages/pull/22047

cbang: cross-compile, scons: change to python3
@pullmoll 

See also: https://github.com/CauldronDevelopmentLLC/cbang/pull/51

A patch file from https://github.com/void-linux/void-packages/pull/22047.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-cross-compile-cbang-22047.patch --]
[-- Type: text/x-diff, Size: 18992 bytes --]

From df23489f4517f360c08729f9cd3b5aed6fc54262 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Sun, 17 May 2020 19:39:37 +0700
Subject: [PATCH 1/3] build-style: scons: add lowercase compiler variable

---
 common/build-style/scons.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/common/build-style/scons.sh b/common/build-style/scons.sh
index 01f309ed0a6..17527d7ac65 100644
--- a/common/build-style/scons.sh
+++ b/common/build-style/scons.sh
@@ -5,7 +5,10 @@ do_build() {
 	: ${make_cmd:=scons}
 
 	${make_cmd} ${makejobs} CC=$CC CXX=$CXX CCFLAGS="$CFLAGS" \
+		cc=$CC cxx=$CXX ccflags="$CFLAGS" \
 		CXXFLAGS="$CXXFLAGS" LINKFLAGS="$LDFLAGS" \
+		cxxflags="$CXXFLAGS" linkflags="$LDFLAGS" \
+		RANLIB="$RANLIB" ranlib="$RANLIB" \
 		prefix=/usr destdir=${DESTDIR} DESTDIR=${DESTDIR} \
 		${make_build_args} ${make_build_target}
 }
@@ -14,7 +17,10 @@ do_install() {
 	: ${make_install_target:=install}
 
 	${make_cmd} ${makejobs} CC=$CC CXX=$CXX CCFLAGS="$CFLAGS" \
+		cc=$CC cxx=$CXX ccflags="$CFLAGS" \
 		CXXFLAGS="$CXXFLAGS" LINKFLAGS="$LDFLAGS" \
+		cxxflags="$CXXFLAGS" linkflags="$LDFLAGS" \
+		RANLIB="$RANLIB" ranlib="$RANLIB" \
 		prefix=/usr destdir=${DESTDIR} DESTDIR=${DESTDIR} \
 		${make_install_args} ${make_install_target}
 }

From c7c6c59f41eff074c98d847075f97bccfdde4abd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Sun, 17 May 2020 20:38:31 +0700
Subject: [PATCH 2/3] scons: switch to python3

---
 srcpkgs/scons/template | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/scons/template b/srcpkgs/scons/template
index 52c8013f7d6..1503094a73d 100644
--- a/srcpkgs/scons/template
+++ b/srcpkgs/scons/template
@@ -1,11 +1,12 @@
 # Template file for 'scons'
 pkgname=scons
 version=3.1.2
-revision=3
-build_style=python2-module
+revision=4
+archs=noarch
+build_style=python3-module
 make_install_args="--standard-lib --install-data=/usr/share"
-hostmakedepends="python python-setuptools"
-depends="python"
+hostmakedepends="python3 python3-setuptools"
+depends="python3"
 short_desc="Software construction tool"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
@@ -15,5 +16,7 @@ checksum="7801f3f62f654528e272df780be10c0e9337e897650b62ddcee9f39fde13f8fb"
 
 
 post_install() {
+	rm -f "$DESTDIR"/usr/bin/scons.bat
+	rm -f "$DESTDIR"/usr/bin/scons-${version}.bat
 	vlicense LICENSE.txt
 }

From 6565a80ae1fecfeabcbed44a96b273f86622b34e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Sun, 17 May 2020 23:23:22 +0700
Subject: [PATCH 3/3] cbang: cross compiling

---
 ...config-openssl-correct-version-check.patch |  52 ++++++++
 ...heck-OPENSSL_VERSION-in-compile-time.patch |  47 +++++++
 ...bevent-use-compile-time-sizeof-check.patch | 119 ++++++++++++++++++
 ...ibevent-use-TryCompile-if-applicable.patch |  73 +++++++++++
 ...o-check-for-signature-of-gethostbyna.patch |  90 +++++++++++++
 srcpkgs/cbang/template                        |  14 ++-
 6 files changed, 391 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch
 create mode 100644 srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
 create mode 100644 srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch
 create mode 100644 srcpkgs/cbang/patches/0004-libevent-use-TryCompile-if-applicable.patch
 create mode 100644 srcpkgs/cbang/patches/0005-libevent-use-C-to-check-for-signature-of-gethostbyna.patch

diff --git a/srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch b/srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch
new file mode 100644
index 00000000000..a89fccb494e
--- /dev/null
+++ b/srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch
@@ -0,0 +1,52 @@
+From 9e22c0114d010a35128aa67b0dc38cc23f4d873f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 21:53:46 +0700
+Subject: [PATCH 1/5] config/openssl: correct version check
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Current code requires all conditions meet to pass the check, thus,
+return false negative for:
+- 1.0.2 vs 1.1.0
+- 1.1.0 vs 2.0.0
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ config/openssl/__init__.py | 17 ++++++++++-------
+ 1 file changed, 10 insertions(+), 7 deletions(-)
+
+diff --git config/openssl/__init__.py config/openssl/__init__.py
+index 421271cd..e0d3884a 100644
+--- config/openssl/__init__.py
++++ config/openssl/__init__.py
+@@ -6,15 +6,18 @@ def check_version(context, version):
+     context.Message("Checking for openssl version >= %s..." % version)
+ 
+     version = version.split('.')
+-    src = '#include <openssl/opensslv.h>\nint main() {\nreturn ('
+-    src += version[0] + '<= (OPENSSL_VERSION_NUMBER >> 28)'
++    src = '''
++    #include <openssl/opensslv.h>
++    int main() {
++        return (OPENSSL_VERSION_NUMBER >= '''
++    src += '(' + version[0] + ' >> 28)'
+     if 1 < len(version):
+-        src += ' && ' + version[1] + \
+-               '<= ((OPENSSL_VERSION_NUMBER >> 20) & 0xf)'
++        src += ' + (' + version[1] + ' >> 20)'
+     if 2 < len(version):
+-        src += ' && ' + version[2] + \
+-               '<= ((OPENSSL_VERSION_NUMBER >> 12) & 0xf)'
+-    src += ') ? 0 : 1;}\n'
++        src += ' + (' + version[2] + ' >> 12)'
++    src += ''') ? 0 : 1;
++    }
++    '''
+ 
+     ret = context.TryRun(src, '.cpp')[0]
+ 
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch b/srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
new file mode 100644
index 00000000000..df857d8ab2f
--- /dev/null
+++ b/srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
@@ -0,0 +1,47 @@
+From a2d81dfceb153d6388dcff63d8be1140cad7a33e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 22:26:09 +0700
+Subject: [PATCH 2/5] config/openssl: check OPENSSL_VERSION in compile time
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+All of required information are available at compile time, use compile
+time check to support cross compiling.
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ config/openssl/__init__.py | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git config/openssl/__init__.py config/openssl/__init__.py
+index e0d3884a..580d72e7 100644
+--- config/openssl/__init__.py
++++ config/openssl/__init__.py
+@@ -9,17 +9,19 @@ def check_version(context, version):
+     src = '''
+     #include <openssl/opensslv.h>
+     int main() {
+-        return (OPENSSL_VERSION_NUMBER >= '''
++        int  a[(OPENSSL_VERSION_NUMBER >= '''
+     src += '(' + version[0] + ' >> 28)'
+     if 1 < len(version):
+         src += ' + (' + version[1] + ' >> 20)'
+     if 2 < len(version):
+         src += ' + (' + version[2] + ' >> 12)'
+-    src += ''') ? 0 : 1;
++    src += ''')];
++        a[0] = 0;
++        return 0;
+     }
+     '''
+ 
+-    ret = context.TryRun(src, '.cpp')[0]
++    ret = context.TryCompile(src, '.cpp')
+ 
+     context.Result(ret)
+     return ret
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch b/srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch
new file mode 100644
index 00000000000..32254f0bbf5
--- /dev/null
+++ b/srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch
@@ -0,0 +1,119 @@
+From df79b8912f92083e7ef51353e762fa1c67b2593b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 22:44:25 +0700
+Subject: [PATCH 3/5] libevent: use compile time sizeof check
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Taken from https://github.com/scons/scons/wiki/AutoconfRecipes#ac_check_sizeof
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ src/libevent/SConscript | 81 +++++++++++++++++++++++++++++++++++++----
+ 1 file changed, 73 insertions(+), 8 deletions(-)
+
+diff --git src/libevent/SConscript src/libevent/SConscript
+index 89e770c1..2e8373f9 100644
+--- src/libevent/SConscript
++++ src/libevent/SConscript
+@@ -18,22 +18,87 @@ conf.AddTest('CheckSYS_TIMERFD_H', CheckSYS_TIMERFD_H)
+ 
+ 
+ # sizeof
++# https://github.com/scons/scons/wiki/AutoconfRecipes#ac_check_sizeof
++# Sensible default for common types on common platforms.
++_DEFAULTS_SIZEOF = {
++    'short' : [2],
++    'int' : [4, 2],
++    'long' : [4, 8],
++    'long long' : [8, 4],
++    'unsigned short' : [2],
++    'unsigned int' : [4, 2],
++    'unsigned long' : [4, 8],
++    'unsigned long long' : [8, 4],
++    'float' : [4],
++    'double' : [8],
++    'long double' : [12],
++    'size_t' : [4, 8],
++}
++
+ def CheckSizeOf(ctx, type, includes = None):
++    """This check can be used to get the size of a given type,
++    or to check whether the type is of expected size.
++
++    Arguments:
++        - type : str
++            the type to check
++        - includes : sequence
++            list of headers to include in the test code before testing the type
++        Returns:
++                status : int
++                        0 if the check failed, or the found size of the type
++                        if the check succeeded."""
++    minsz = 0
++    maxsz = 16
++
+     src = '''
+       #include <sys/types.h>
+       #include <stdlib.h>
+       #include <stdio.h>
+-      int main() {printf("%d", (int)sizeof(''' + type + ''')); return 0;}
++      #include <stdint.h>
+     '''
++    if includes:
++        src += "\n".join("#include <%s>\n" % i for i in includes)
+ 
+-    if includes is not None:
+-        for inc in includes:
+-            src = '#include <%s>\n%s' % (inc, src)
++    ext = '.c'
++    # test code taken from autoconf: this is a pretty clever hack to find that
++    # a type is of a given size using only compilation. This speeds things up
++    # quite a bit compared to straightforward code using TryRun
++    src += r"""
++typedef %s scons_check_type;
+ 
+-    ctx.Message('Checking size of ' + type + '... ')
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[1]
++int main()
++{
++    static int test_array[1 - 2 * ((long int) sizeof(scons_check_type) > %d)];
++    test_array[0] = 0;
++
++    return 0;
++}
++"""
++
++    # Only check if the given size is the right one
++    ctx.Message('Checking size of %s ... ' % type)
++
++    # Try sensible defaults first
++    try:
++        szrange = _DEFAULTS_SIZEOF[type]
++    except KeyError:
++        szrange = []
++    szrange.extend(range(minsz, maxsz))
++    st = 0
++
++    # Actual test
++    for sz in szrange:
++        st = ctx.TryCompile(src % (type, sz), ext)
++        if st:
++            break
++
++    if st:
++        ctx.Result('%d' % sz)
++        return sz
++    else:
++        ctx.Result('Failed !')
++        return 0
+ 
+ conf.AddTest('CheckSizeOf', CheckSizeOf)
+ 
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/patches/0004-libevent-use-TryCompile-if-applicable.patch b/srcpkgs/cbang/patches/0004-libevent-use-TryCompile-if-applicable.patch
new file mode 100644
index 00000000000..06b73e8b7e6
--- /dev/null
+++ b/srcpkgs/cbang/patches/0004-libevent-use-TryCompile-if-applicable.patch
@@ -0,0 +1,73 @@
+From b31932609b9019f7f72efdc3d67ea16971a34c76 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 22:47:26 +0700
+Subject: [PATCH 4/5] libevent: use TryCompile if applicable
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ src/libevent/SConscript | 24 ++++++++++++------------
+ 1 file changed, 12 insertions(+), 12 deletions(-)
+
+diff --git src/libevent/SConscript src/libevent/SConscript
+index 2e8373f9..f9dceaa5 100644
+--- src/libevent/SConscript
++++ src/libevent/SConscript
+@@ -117,9 +117,9 @@ def CheckDecl(ctx, decl, includes = None):
+             src = '#include <%s>\n%s' % (inc, src)
+ 
+     ctx.Message('Checking for decl ' + decl + '... ')
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[0]
++    ret = ctx.TryCompile(src + '\n', '.c')
++    ctx.Result(ret)
++    return ret
+ 
+ conf.AddTest('CheckDecl', CheckDecl)
+ 
+@@ -133,9 +133,9 @@ def CheckStruct(ctx, struct, includes = None):
+             src = '#include <%s>\n%s' % (inc, src)
+ 
+     ctx.Message('Checking for struct ' + struct + '... ')
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[0]
++    ret = ctx.TryCompile(src + '\n', '.c')
++    ctx.Result(ret)
++    return ret
+ 
+ conf.AddTest('CheckStruct', CheckStruct)
+ 
+@@ -153,9 +153,9 @@ def CheckType(ctx, type, includes = None, defs = None):
+             src = '#define %s\n%s' % (d, src)
+ 
+     ctx.Message('Checking for type ' + type + '... ')
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[0]
++    ret = ctx.TryCompile(src + '\n', '.c')
++    ctx.Result(ret)
++    return ret
+ 
+ conf.AddTest('CheckType', CheckType)
+ 
+@@ -177,9 +177,9 @@ def CheckStructMember(ctx, struct, member, includes = None):
+             src = '#include <%s>\n%s' % (inc, src)
+ 
+     ctx.Message('Checking for %s in struct %s... ' % (member, struct))
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[0]
++    ret = ctx.TryCompile(src + '\n', '.c')
++    ctx.Result(ret)
++    return ret
+ 
+ conf.AddTest('CheckStructMember', CheckStructMember)
+ 
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/patches/0005-libevent-use-C-to-check-for-signature-of-gethostbyna.patch b/srcpkgs/cbang/patches/0005-libevent-use-C-to-check-for-signature-of-gethostbyna.patch
new file mode 100644
index 00000000000..f0181b641d7
--- /dev/null
+++ b/srcpkgs/cbang/patches/0005-libevent-use-C-to-check-for-signature-of-gethostbyna.patch
@@ -0,0 +1,90 @@
+From 9239db8606320967e9e8526f68acd3e641c60ebb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 22:56:41 +0700
+Subject: [PATCH 5/5] libevent: use C++ to check for signature of
+ gethostbyname_r
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+C++ by definition requires matching prototype (both number of arguments,
+order of arguments, and type of arguments) to be compilable.
+
+Use this property to check for signature of gethostbyname_r(3) at
+compile time in order to support cross compiling.
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ src/libevent/SConscript | 23 ++++++++++++++++++++---
+ 1 file changed, 20 insertions(+), 3 deletions(-)
+
+diff --git src/libevent/SConscript src/libevent/SConscript
+index f9dceaa5..be56e29a 100644
+--- src/libevent/SConscript
++++ src/libevent/SConscript
+@@ -184,6 +184,14 @@ def CheckStructMember(ctx, struct, member, includes = None):
+ conf.AddTest('CheckStructMember', CheckStructMember)
+ 
+ 
++def CheckCompileCxx(ctx, msg, src):
++    ctx.Message('Checking for %s... ' % msg)
++    ret = ctx.TryCompile(src + '\n', '.cpp')
++    ctx.Result(ret)
++    return ret
++
++conf.AddTest('CheckCompileCxx', CheckCompileCxx)
++
+ # General compile and run check
+ def CheckRun(ctx, msg, src):
+     ctx.Message('Checking for %s... ' % msg)
+@@ -213,6 +221,9 @@ structs = 'addrinfo in6_addr sockaddr_in6 sockaddr_storage'
+ sizeof = ['int', 'long', 'long long', 'off_t', 'short', 'size_t', 'void *']
+ 
+ gethostbyname_r_3_arg_src = '''
++  #ifndef __cplusplus
++  #error must be compiled as cxx
++  #endif
+   #define _BSD_SOURCE
+   #include <netdb.h>
+   int main(int argc, char **argv) {
+@@ -224,6 +235,9 @@ gethostbyname_r_3_arg_src = '''
+ '''
+ 
+ gethostbyname_r_5_arg_src = '''
++  #ifndef __cplusplus
++  #error must be compiled as cxx
++  #endif
+   #define _BSD_SOURCE
+   #include <netdb.h>
+   int main(int argc, char **argv) {
+@@ -237,6 +251,9 @@ gethostbyname_r_5_arg_src = '''
+ '''
+ 
+ gethostbyname_r_6_arg_src = '''
++  #ifndef __cplusplus
++  #error must be compiled as cxx
++  #endif
+   #define _BSD_SOURCE
+   #include <netdb.h>
+   int main(int argc, char **argv) {
+@@ -336,13 +353,13 @@ def get_event_config_defs():
+     if 'HAVE_EPOLL_CREATE' in defs: defs['HAVE_EPOLL'] = '1'
+ 
+     # gethostbyname_r
+-    if conf.CheckRun('3 arg gethostbyname_r()', gethostbyname_r_3_arg_src):
++    if conf.CheckCompileCxx('3 arg gethostbyname_r()', gethostbyname_r_3_arg_src):
+         defs['HAVE_GETHOSTBYNAME_R_3_ARG'] = '1'
+ 
+-    if conf.CheckRun('5 arg gethostbyname_r()', gethostbyname_r_5_arg_src):
++    if conf.CheckCompileCxx('5 arg gethostbyname_r()', gethostbyname_r_5_arg_src):
+         defs['HAVE_GETHOSTBYNAME_R_5_ARG'] = '1'
+ 
+-    if conf.CheckRun('6 arg gethostbyname_r()', gethostbyname_r_6_arg_src):
++    if conf.CheckCompileCxx('6 arg gethostbyname_r()', gethostbyname_r_6_arg_src):
+         defs['HAVE_GETHOSTBYNAME_R_6_ARG'] = '1'
+ 
+ 
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/template b/srcpkgs/cbang/template
index 3e1d8e2c215..75af292e8e9 100644
--- a/srcpkgs/cbang/template
+++ b/srcpkgs/cbang/template
@@ -3,7 +3,7 @@ pkgname=cbang
 version=1.4.0
 revision=1
 build_style=scons
-make_build_args="prefix=/usr sharedlib=1 staticlib=1"
+make_build_args="sharedlib=1 staticlib=1"
 make_install_args="${make_build_args}"
 hostmakedepends="pkg-config"
 makedepends="boost-devel bzip2-devel expat-devel leveldb-devel libevent-devel
@@ -14,10 +14,16 @@ license="LGPL-2.1-only"
 homepage="https://github.com/CauldronDevelopmentLLC/cbang"
 distfiles="https://github.com/CauldronDevelopmentLLC/cbang/archive/${version}.tar.gz>${pkgname}-${version}.tar.gz"
 checksum=332a776ab026c30aa1666ad2482e1bf77fa5c41e3e2f7cde9ff2d98cfd3b4026
-nocross="Cannot cross build with scons"
 
-do_install() {
-	scons ${make_install_args} prefix=${DESTDIR}/usr install
+pre_build() {
+	make_build_args+=" prefix=$DESTDIR/usr"
+}
+
+pre_install() {
+	make_install_args+=" prefix=$DESTDIR/usr"
+}
+
+post_install() {
 	# Create missing symbolic links for the shared library
 	ln -sf libcbang0.so.0.0.1 ${DESTDIR}/usr/lib/libcbang.so.0.0
 	ln -sf libcbang0.so.0.0.1 ${DESTDIR}/usr/lib/libcbang.so.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PR PATCH] [Updated] cbang: cross-compile, scons: change to python3
  2020-05-17 16:25 [PR PATCH] cbang: cross-compile, scons: change to python3 sgn
                   ` (2 preceding siblings ...)
  2020-05-17 16:39 ` [PR PATCH] [Updated] " sgn
@ 2020-05-17 16:40 ` sgn
  2020-05-17 16:40 ` sgn
  2020-05-17 22:32 ` [PR PATCH] [Merged]: cbang: cross-compile pullmoll
  5 siblings, 0 replies; 7+ messages in thread
From: sgn @ 2020-05-17 16:40 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages cross-compile-cbang
https://github.com/void-linux/void-packages/pull/22047

cbang: cross-compile, scons: change to python3
@pullmoll 

See also: https://github.com/CauldronDevelopmentLLC/cbang/pull/51

A patch file from https://github.com/void-linux/void-packages/pull/22047.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-cross-compile-cbang-22047.patch --]
[-- Type: text/x-diff, Size: 17799 bytes --]

From df23489f4517f360c08729f9cd3b5aed6fc54262 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Sun, 17 May 2020 19:39:37 +0700
Subject: [PATCH 1/2] build-style: scons: add lowercase compiler variable

---
 common/build-style/scons.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/common/build-style/scons.sh b/common/build-style/scons.sh
index 01f309ed0a6..17527d7ac65 100644
--- a/common/build-style/scons.sh
+++ b/common/build-style/scons.sh
@@ -5,7 +5,10 @@ do_build() {
 	: ${make_cmd:=scons}
 
 	${make_cmd} ${makejobs} CC=$CC CXX=$CXX CCFLAGS="$CFLAGS" \
+		cc=$CC cxx=$CXX ccflags="$CFLAGS" \
 		CXXFLAGS="$CXXFLAGS" LINKFLAGS="$LDFLAGS" \
+		cxxflags="$CXXFLAGS" linkflags="$LDFLAGS" \
+		RANLIB="$RANLIB" ranlib="$RANLIB" \
 		prefix=/usr destdir=${DESTDIR} DESTDIR=${DESTDIR} \
 		${make_build_args} ${make_build_target}
 }
@@ -14,7 +17,10 @@ do_install() {
 	: ${make_install_target:=install}
 
 	${make_cmd} ${makejobs} CC=$CC CXX=$CXX CCFLAGS="$CFLAGS" \
+		cc=$CC cxx=$CXX ccflags="$CFLAGS" \
 		CXXFLAGS="$CXXFLAGS" LINKFLAGS="$LDFLAGS" \
+		cxxflags="$CXXFLAGS" linkflags="$LDFLAGS" \
+		RANLIB="$RANLIB" ranlib="$RANLIB" \
 		prefix=/usr destdir=${DESTDIR} DESTDIR=${DESTDIR} \
 		${make_install_args} ${make_install_target}
 }

From ceef0ecfab3a26100b90e07191b98196f84a05f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Sun, 17 May 2020 23:23:22 +0700
Subject: [PATCH 2/2] cbang: cross compiling

---
 ...config-openssl-correct-version-check.patch |  52 ++++++++
 ...heck-OPENSSL_VERSION-in-compile-time.patch |  47 +++++++
 ...bevent-use-compile-time-sizeof-check.patch | 119 ++++++++++++++++++
 ...ibevent-use-TryCompile-if-applicable.patch |  73 +++++++++++
 ...o-check-for-signature-of-gethostbyna.patch |  90 +++++++++++++
 srcpkgs/cbang/template                        |  14 ++-
 6 files changed, 391 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch
 create mode 100644 srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
 create mode 100644 srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch
 create mode 100644 srcpkgs/cbang/patches/0004-libevent-use-TryCompile-if-applicable.patch
 create mode 100644 srcpkgs/cbang/patches/0005-libevent-use-C-to-check-for-signature-of-gethostbyna.patch

diff --git a/srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch b/srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch
new file mode 100644
index 00000000000..a89fccb494e
--- /dev/null
+++ b/srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch
@@ -0,0 +1,52 @@
+From 9e22c0114d010a35128aa67b0dc38cc23f4d873f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 21:53:46 +0700
+Subject: [PATCH 1/5] config/openssl: correct version check
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Current code requires all conditions meet to pass the check, thus,
+return false negative for:
+- 1.0.2 vs 1.1.0
+- 1.1.0 vs 2.0.0
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ config/openssl/__init__.py | 17 ++++++++++-------
+ 1 file changed, 10 insertions(+), 7 deletions(-)
+
+diff --git config/openssl/__init__.py config/openssl/__init__.py
+index 421271cd..e0d3884a 100644
+--- config/openssl/__init__.py
++++ config/openssl/__init__.py
+@@ -6,15 +6,18 @@ def check_version(context, version):
+     context.Message("Checking for openssl version >= %s..." % version)
+ 
+     version = version.split('.')
+-    src = '#include <openssl/opensslv.h>\nint main() {\nreturn ('
+-    src += version[0] + '<= (OPENSSL_VERSION_NUMBER >> 28)'
++    src = '''
++    #include <openssl/opensslv.h>
++    int main() {
++        return (OPENSSL_VERSION_NUMBER >= '''
++    src += '(' + version[0] + ' >> 28)'
+     if 1 < len(version):
+-        src += ' && ' + version[1] + \
+-               '<= ((OPENSSL_VERSION_NUMBER >> 20) & 0xf)'
++        src += ' + (' + version[1] + ' >> 20)'
+     if 2 < len(version):
+-        src += ' && ' + version[2] + \
+-               '<= ((OPENSSL_VERSION_NUMBER >> 12) & 0xf)'
+-    src += ') ? 0 : 1;}\n'
++        src += ' + (' + version[2] + ' >> 12)'
++    src += ''') ? 0 : 1;
++    }
++    '''
+ 
+     ret = context.TryRun(src, '.cpp')[0]
+ 
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch b/srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
new file mode 100644
index 00000000000..df857d8ab2f
--- /dev/null
+++ b/srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
@@ -0,0 +1,47 @@
+From a2d81dfceb153d6388dcff63d8be1140cad7a33e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 22:26:09 +0700
+Subject: [PATCH 2/5] config/openssl: check OPENSSL_VERSION in compile time
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+All of required information are available at compile time, use compile
+time check to support cross compiling.
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ config/openssl/__init__.py | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git config/openssl/__init__.py config/openssl/__init__.py
+index e0d3884a..580d72e7 100644
+--- config/openssl/__init__.py
++++ config/openssl/__init__.py
+@@ -9,17 +9,19 @@ def check_version(context, version):
+     src = '''
+     #include <openssl/opensslv.h>
+     int main() {
+-        return (OPENSSL_VERSION_NUMBER >= '''
++        int  a[(OPENSSL_VERSION_NUMBER >= '''
+     src += '(' + version[0] + ' >> 28)'
+     if 1 < len(version):
+         src += ' + (' + version[1] + ' >> 20)'
+     if 2 < len(version):
+         src += ' + (' + version[2] + ' >> 12)'
+-    src += ''') ? 0 : 1;
++    src += ''')];
++        a[0] = 0;
++        return 0;
+     }
+     '''
+ 
+-    ret = context.TryRun(src, '.cpp')[0]
++    ret = context.TryCompile(src, '.cpp')
+ 
+     context.Result(ret)
+     return ret
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch b/srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch
new file mode 100644
index 00000000000..32254f0bbf5
--- /dev/null
+++ b/srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch
@@ -0,0 +1,119 @@
+From df79b8912f92083e7ef51353e762fa1c67b2593b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 22:44:25 +0700
+Subject: [PATCH 3/5] libevent: use compile time sizeof check
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Taken from https://github.com/scons/scons/wiki/AutoconfRecipes#ac_check_sizeof
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ src/libevent/SConscript | 81 +++++++++++++++++++++++++++++++++++++----
+ 1 file changed, 73 insertions(+), 8 deletions(-)
+
+diff --git src/libevent/SConscript src/libevent/SConscript
+index 89e770c1..2e8373f9 100644
+--- src/libevent/SConscript
++++ src/libevent/SConscript
+@@ -18,22 +18,87 @@ conf.AddTest('CheckSYS_TIMERFD_H', CheckSYS_TIMERFD_H)
+ 
+ 
+ # sizeof
++# https://github.com/scons/scons/wiki/AutoconfRecipes#ac_check_sizeof
++# Sensible default for common types on common platforms.
++_DEFAULTS_SIZEOF = {
++    'short' : [2],
++    'int' : [4, 2],
++    'long' : [4, 8],
++    'long long' : [8, 4],
++    'unsigned short' : [2],
++    'unsigned int' : [4, 2],
++    'unsigned long' : [4, 8],
++    'unsigned long long' : [8, 4],
++    'float' : [4],
++    'double' : [8],
++    'long double' : [12],
++    'size_t' : [4, 8],
++}
++
+ def CheckSizeOf(ctx, type, includes = None):
++    """This check can be used to get the size of a given type,
++    or to check whether the type is of expected size.
++
++    Arguments:
++        - type : str
++            the type to check
++        - includes : sequence
++            list of headers to include in the test code before testing the type
++        Returns:
++                status : int
++                        0 if the check failed, or the found size of the type
++                        if the check succeeded."""
++    minsz = 0
++    maxsz = 16
++
+     src = '''
+       #include <sys/types.h>
+       #include <stdlib.h>
+       #include <stdio.h>
+-      int main() {printf("%d", (int)sizeof(''' + type + ''')); return 0;}
++      #include <stdint.h>
+     '''
++    if includes:
++        src += "\n".join("#include <%s>\n" % i for i in includes)
+ 
+-    if includes is not None:
+-        for inc in includes:
+-            src = '#include <%s>\n%s' % (inc, src)
++    ext = '.c'
++    # test code taken from autoconf: this is a pretty clever hack to find that
++    # a type is of a given size using only compilation. This speeds things up
++    # quite a bit compared to straightforward code using TryRun
++    src += r"""
++typedef %s scons_check_type;
+ 
+-    ctx.Message('Checking size of ' + type + '... ')
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[1]
++int main()
++{
++    static int test_array[1 - 2 * ((long int) sizeof(scons_check_type) > %d)];
++    test_array[0] = 0;
++
++    return 0;
++}
++"""
++
++    # Only check if the given size is the right one
++    ctx.Message('Checking size of %s ... ' % type)
++
++    # Try sensible defaults first
++    try:
++        szrange = _DEFAULTS_SIZEOF[type]
++    except KeyError:
++        szrange = []
++    szrange.extend(range(minsz, maxsz))
++    st = 0
++
++    # Actual test
++    for sz in szrange:
++        st = ctx.TryCompile(src % (type, sz), ext)
++        if st:
++            break
++
++    if st:
++        ctx.Result('%d' % sz)
++        return sz
++    else:
++        ctx.Result('Failed !')
++        return 0
+ 
+ conf.AddTest('CheckSizeOf', CheckSizeOf)
+ 
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/patches/0004-libevent-use-TryCompile-if-applicable.patch b/srcpkgs/cbang/patches/0004-libevent-use-TryCompile-if-applicable.patch
new file mode 100644
index 00000000000..06b73e8b7e6
--- /dev/null
+++ b/srcpkgs/cbang/patches/0004-libevent-use-TryCompile-if-applicable.patch
@@ -0,0 +1,73 @@
+From b31932609b9019f7f72efdc3d67ea16971a34c76 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 22:47:26 +0700
+Subject: [PATCH 4/5] libevent: use TryCompile if applicable
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ src/libevent/SConscript | 24 ++++++++++++------------
+ 1 file changed, 12 insertions(+), 12 deletions(-)
+
+diff --git src/libevent/SConscript src/libevent/SConscript
+index 2e8373f9..f9dceaa5 100644
+--- src/libevent/SConscript
++++ src/libevent/SConscript
+@@ -117,9 +117,9 @@ def CheckDecl(ctx, decl, includes = None):
+             src = '#include <%s>\n%s' % (inc, src)
+ 
+     ctx.Message('Checking for decl ' + decl + '... ')
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[0]
++    ret = ctx.TryCompile(src + '\n', '.c')
++    ctx.Result(ret)
++    return ret
+ 
+ conf.AddTest('CheckDecl', CheckDecl)
+ 
+@@ -133,9 +133,9 @@ def CheckStruct(ctx, struct, includes = None):
+             src = '#include <%s>\n%s' % (inc, src)
+ 
+     ctx.Message('Checking for struct ' + struct + '... ')
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[0]
++    ret = ctx.TryCompile(src + '\n', '.c')
++    ctx.Result(ret)
++    return ret
+ 
+ conf.AddTest('CheckStruct', CheckStruct)
+ 
+@@ -153,9 +153,9 @@ def CheckType(ctx, type, includes = None, defs = None):
+             src = '#define %s\n%s' % (d, src)
+ 
+     ctx.Message('Checking for type ' + type + '... ')
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[0]
++    ret = ctx.TryCompile(src + '\n', '.c')
++    ctx.Result(ret)
++    return ret
+ 
+ conf.AddTest('CheckType', CheckType)
+ 
+@@ -177,9 +177,9 @@ def CheckStructMember(ctx, struct, member, includes = None):
+             src = '#include <%s>\n%s' % (inc, src)
+ 
+     ctx.Message('Checking for %s in struct %s... ' % (member, struct))
+-    ret = ctx.TryRun(src + '\n', '.c')
+-    ctx.Result(ret[0])
+-    return ret[0]
++    ret = ctx.TryCompile(src + '\n', '.c')
++    ctx.Result(ret)
++    return ret
+ 
+ conf.AddTest('CheckStructMember', CheckStructMember)
+ 
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/patches/0005-libevent-use-C-to-check-for-signature-of-gethostbyna.patch b/srcpkgs/cbang/patches/0005-libevent-use-C-to-check-for-signature-of-gethostbyna.patch
new file mode 100644
index 00000000000..f0181b641d7
--- /dev/null
+++ b/srcpkgs/cbang/patches/0005-libevent-use-C-to-check-for-signature-of-gethostbyna.patch
@@ -0,0 +1,90 @@
+From 9239db8606320967e9e8526f68acd3e641c60ebb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
+ <congdanhqx@gmail.com>
+Date: Sun, 17 May 2020 22:56:41 +0700
+Subject: [PATCH 5/5] libevent: use C++ to check for signature of
+ gethostbyname_r
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+C++ by definition requires matching prototype (both number of arguments,
+order of arguments, and type of arguments) to be compilable.
+
+Use this property to check for signature of gethostbyname_r(3) at
+compile time in order to support cross compiling.
+
+Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
+---
+ src/libevent/SConscript | 23 ++++++++++++++++++++---
+ 1 file changed, 20 insertions(+), 3 deletions(-)
+
+diff --git src/libevent/SConscript src/libevent/SConscript
+index f9dceaa5..be56e29a 100644
+--- src/libevent/SConscript
++++ src/libevent/SConscript
+@@ -184,6 +184,14 @@ def CheckStructMember(ctx, struct, member, includes = None):
+ conf.AddTest('CheckStructMember', CheckStructMember)
+ 
+ 
++def CheckCompileCxx(ctx, msg, src):
++    ctx.Message('Checking for %s... ' % msg)
++    ret = ctx.TryCompile(src + '\n', '.cpp')
++    ctx.Result(ret)
++    return ret
++
++conf.AddTest('CheckCompileCxx', CheckCompileCxx)
++
+ # General compile and run check
+ def CheckRun(ctx, msg, src):
+     ctx.Message('Checking for %s... ' % msg)
+@@ -213,6 +221,9 @@ structs = 'addrinfo in6_addr sockaddr_in6 sockaddr_storage'
+ sizeof = ['int', 'long', 'long long', 'off_t', 'short', 'size_t', 'void *']
+ 
+ gethostbyname_r_3_arg_src = '''
++  #ifndef __cplusplus
++  #error must be compiled as cxx
++  #endif
+   #define _BSD_SOURCE
+   #include <netdb.h>
+   int main(int argc, char **argv) {
+@@ -224,6 +235,9 @@ gethostbyname_r_3_arg_src = '''
+ '''
+ 
+ gethostbyname_r_5_arg_src = '''
++  #ifndef __cplusplus
++  #error must be compiled as cxx
++  #endif
+   #define _BSD_SOURCE
+   #include <netdb.h>
+   int main(int argc, char **argv) {
+@@ -237,6 +251,9 @@ gethostbyname_r_5_arg_src = '''
+ '''
+ 
+ gethostbyname_r_6_arg_src = '''
++  #ifndef __cplusplus
++  #error must be compiled as cxx
++  #endif
+   #define _BSD_SOURCE
+   #include <netdb.h>
+   int main(int argc, char **argv) {
+@@ -336,13 +353,13 @@ def get_event_config_defs():
+     if 'HAVE_EPOLL_CREATE' in defs: defs['HAVE_EPOLL'] = '1'
+ 
+     # gethostbyname_r
+-    if conf.CheckRun('3 arg gethostbyname_r()', gethostbyname_r_3_arg_src):
++    if conf.CheckCompileCxx('3 arg gethostbyname_r()', gethostbyname_r_3_arg_src):
+         defs['HAVE_GETHOSTBYNAME_R_3_ARG'] = '1'
+ 
+-    if conf.CheckRun('5 arg gethostbyname_r()', gethostbyname_r_5_arg_src):
++    if conf.CheckCompileCxx('5 arg gethostbyname_r()', gethostbyname_r_5_arg_src):
+         defs['HAVE_GETHOSTBYNAME_R_5_ARG'] = '1'
+ 
+-    if conf.CheckRun('6 arg gethostbyname_r()', gethostbyname_r_6_arg_src):
++    if conf.CheckCompileCxx('6 arg gethostbyname_r()', gethostbyname_r_6_arg_src):
+         defs['HAVE_GETHOSTBYNAME_R_6_ARG'] = '1'
+ 
+ 
+-- 
+2.26.2.672.g232c24e857
+
diff --git a/srcpkgs/cbang/template b/srcpkgs/cbang/template
index 3e1d8e2c215..75af292e8e9 100644
--- a/srcpkgs/cbang/template
+++ b/srcpkgs/cbang/template
@@ -3,7 +3,7 @@ pkgname=cbang
 version=1.4.0
 revision=1
 build_style=scons
-make_build_args="prefix=/usr sharedlib=1 staticlib=1"
+make_build_args="sharedlib=1 staticlib=1"
 make_install_args="${make_build_args}"
 hostmakedepends="pkg-config"
 makedepends="boost-devel bzip2-devel expat-devel leveldb-devel libevent-devel
@@ -14,10 +14,16 @@ license="LGPL-2.1-only"
 homepage="https://github.com/CauldronDevelopmentLLC/cbang"
 distfiles="https://github.com/CauldronDevelopmentLLC/cbang/archive/${version}.tar.gz>${pkgname}-${version}.tar.gz"
 checksum=332a776ab026c30aa1666ad2482e1bf77fa5c41e3e2f7cde9ff2d98cfd3b4026
-nocross="Cannot cross build with scons"
 
-do_install() {
-	scons ${make_install_args} prefix=${DESTDIR}/usr install
+pre_build() {
+	make_build_args+=" prefix=$DESTDIR/usr"
+}
+
+pre_install() {
+	make_install_args+=" prefix=$DESTDIR/usr"
+}
+
+post_install() {
 	# Create missing symbolic links for the shared library
 	ln -sf libcbang0.so.0.0.1 ${DESTDIR}/usr/lib/libcbang.so.0.0
 	ln -sf libcbang0.so.0.0.1 ${DESTDIR}/usr/lib/libcbang.so.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cbang: cross-compile, scons: change to python3
  2020-05-17 16:25 [PR PATCH] cbang: cross-compile, scons: change to python3 sgn
                   ` (3 preceding siblings ...)
  2020-05-17 16:40 ` sgn
@ 2020-05-17 16:40 ` sgn
  2020-05-17 22:32 ` [PR PATCH] [Merged]: cbang: cross-compile pullmoll
  5 siblings, 0 replies; 7+ messages in thread
From: sgn @ 2020-05-17 16:40 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 171 bytes --]

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/22047#issuecomment-629826075

Comment:
Ok, I'll drop the change to scons.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PR PATCH] [Merged]: cbang: cross-compile
  2020-05-17 16:25 [PR PATCH] cbang: cross-compile, scons: change to python3 sgn
                   ` (4 preceding siblings ...)
  2020-05-17 16:40 ` sgn
@ 2020-05-17 22:32 ` pullmoll
  5 siblings, 0 replies; 7+ messages in thread
From: pullmoll @ 2020-05-17 22:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 233 bytes --]

There's a merged pull request on the void-packages repository

cbang: cross-compile
https://github.com/void-linux/void-packages/pull/22047

Description:
@pullmoll 

See also: https://github.com/CauldronDevelopmentLLC/cbang/pull/51

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-17 22:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-17 16:25 [PR PATCH] cbang: cross-compile, scons: change to python3 sgn
2020-05-17 16:30 ` Johnnynator
2020-05-17 16:38 ` pullmoll
2020-05-17 16:39 ` [PR PATCH] [Updated] " sgn
2020-05-17 16:40 ` sgn
2020-05-17 16:40 ` sgn
2020-05-17 22:32 ` [PR PATCH] [Merged]: cbang: cross-compile pullmoll

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).