mirror of
https://github.com/urbit/shrub.git
synced 2024-09-11 12:25:43 +03:00
build: implements static builds in urbit ./configure, prunes deps
This commit is contained in:
parent
d1a9ae4b2c
commit
e3cd08b96a
@ -1,8 +1,12 @@
|
||||
{ lib, stdenv, coreutils, pkgconfig, argon2u, cacert, ca-bundle, curlMinimal
|
||||
, ed25519, ent, urcrypt, gmp, h2o, herb, ivory, libaes_siv, libscrypt
|
||||
, libsigsegv, libuv, lmdb, murmur3, openssl, secp256k1, softfloat3, zlib
|
||||
, enableStatic ? stdenv.hostPlatform.isStatic, enableDebug ? false
|
||||
, doCheck ? true, enableParallelBuilding ? true, dontStrip ? true }:
|
||||
{ lib, stdenv, coreutils, pkgconfig # build/env
|
||||
, cacert, ca-bundle, ivory # codegen
|
||||
, curlMinimal, ent, gmp, h2o, libsigsegv, libuv, lmdb # libs
|
||||
, murmur3, openssl, softfloat3, urcrypt, zlib #
|
||||
, enableStatic ? stdenv.hostPlatform.isStatic # opts
|
||||
, enableDebug ? false
|
||||
, doCheck ? true
|
||||
, enableParallelBuilding ? true
|
||||
, dontStrip ? true }:
|
||||
|
||||
let
|
||||
|
||||
@ -19,30 +23,23 @@ in stdenv.mkDerivation {
|
||||
nativeBuildInputs = [ pkgconfig ];
|
||||
|
||||
buildInputs = [
|
||||
argon2u
|
||||
cacert
|
||||
ca-bundle
|
||||
curlMinimal
|
||||
ed25519
|
||||
ent
|
||||
urcrypt
|
||||
gmp
|
||||
h2o
|
||||
ivory.header
|
||||
libaes_siv
|
||||
libscrypt
|
||||
libsigsegv
|
||||
libuv
|
||||
lmdb
|
||||
murmur3
|
||||
openssl
|
||||
secp256k1
|
||||
softfloat3
|
||||
urcrypt
|
||||
zlib
|
||||
];
|
||||
|
||||
checkInputs = [ herb ];
|
||||
|
||||
# Ensure any `/usr/bin/env bash` shebang is patched.
|
||||
postPatch = ''
|
||||
patchShebangs ./configure
|
||||
@ -56,9 +53,14 @@ in stdenv.mkDerivation {
|
||||
cp ./build/urbit-worker $out/bin/urbit-worker
|
||||
'';
|
||||
|
||||
dontDisableStatic = enableStatic;
|
||||
|
||||
configureFlags = if enableStatic
|
||||
then [ "--disable-shared" "--enable-static" ]
|
||||
else [];
|
||||
|
||||
CFLAGS = [ (if enableDebug then "-O0" else "-O3") "-g" ]
|
||||
++ lib.optionals (!enableDebug) [ "-Werror" ]
|
||||
++ lib.optionals enableStatic [ "-static" ];
|
||||
++ lib.optionals (!enableDebug) [ "-Werror" ];
|
||||
|
||||
MEMORY_DEBUG = enableDebug;
|
||||
CPU_DEBUG = enableDebug;
|
||||
|
@ -1,4 +1,5 @@
|
||||
{ stdenv, autoreconfHook, pkgconfig, openssl, gmp, secp256k1, scrypt, libaes_siv
|
||||
{ stdenv, autoreconfHook, pkgconfig
|
||||
, libaes_siv, openssl, secp256k1
|
||||
, enableStatic ? stdenv.hostPlatform.isStatic }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
@ -16,5 +17,5 @@ stdenv.mkDerivation rec {
|
||||
[ autoreconfHook pkgconfig ];
|
||||
|
||||
buildInputs =
|
||||
[ openssl gmp secp256k1 scrypt libaes_siv ];
|
||||
[ openssl secp256k1 libaes_siv ];
|
||||
}
|
||||
|
42
pkg/urbit/configure
vendored
42
pkg/urbit/configure
vendored
@ -4,9 +4,9 @@ set -euo pipefail
|
||||
|
||||
URBIT_VERSION="$(cat ./version)"
|
||||
|
||||
deps=" \
|
||||
curl gmp sigsegv argon2 ed25519 ent h2o scrypt uv murmur3 \
|
||||
softfloat3 ssl liburcrypt-0 crypto aes_siv z lmdb pthread libsecp256k1 \
|
||||
deps=" \
|
||||
curl gmp sigsegv ent h2o uv murmur3 softfloat3 \
|
||||
liburcrypt-0 ssl crypto z lmdb pthread \
|
||||
"
|
||||
|
||||
headers=" \
|
||||
@ -22,6 +22,7 @@ defmacro () {
|
||||
defmacro URBIT_VERSION "\"$URBIT_VERSION\""
|
||||
|
||||
opt_debug=
|
||||
opt_static=
|
||||
|
||||
while test $# != 0
|
||||
do
|
||||
@ -32,6 +33,18 @@ do
|
||||
--disable-debug)
|
||||
opt_debug=
|
||||
;;
|
||||
--enable-static)
|
||||
opt_static=1
|
||||
;;
|
||||
--enable-shared)
|
||||
opt_static=
|
||||
;;
|
||||
--disable-static)
|
||||
opt_static=
|
||||
;;
|
||||
--disable-shared)
|
||||
opt_static=1
|
||||
;;
|
||||
*)
|
||||
echo "unrecognized option: $1"
|
||||
;;
|
||||
@ -39,6 +52,12 @@ do
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
if [ -n "${opt_static-}" ]
|
||||
then
|
||||
CFLAGS="${CFLAGS-} -static"
|
||||
fi
|
||||
|
||||
[ -n "${MEMORY_DEBUG-}" ] && defmacro U3_MEMORY_DEBUG 1
|
||||
[ -n "${MEMORY_LOG-}" ] && defmacro U3_MEMORY_LOG 1
|
||||
[ -n "${CPU_DEBUG-}" ] && defmacro U3_CPU_DEBUG 1
|
||||
@ -77,6 +96,12 @@ esac
|
||||
# TODO Determine if the target cpu is little or big endian.
|
||||
case $(tr A-Z a-z <<< $os) in
|
||||
*mingw*)
|
||||
if [ -z "${opt_static-}" ]
|
||||
then
|
||||
echo mingw builds are static-only
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ensure required mingw packages are installed
|
||||
mpkgs=(cmake curl gcc jq make)
|
||||
pacman -S --needed autoconf automake-wrapper libtool patch ${mpkgs[@]/#/mingw-w64-x86_64-}
|
||||
@ -137,10 +162,17 @@ case $(tr A-Z a-z <<< $os) in
|
||||
;;
|
||||
esac
|
||||
|
||||
PKG_CONFIG="${PKG_CONFIG-pkg-config}"
|
||||
|
||||
if [ -n "${opt_static-}" ]
|
||||
then
|
||||
PKG_CONFIG="$PKG_CONFIG --static"
|
||||
fi
|
||||
|
||||
for dep in ${osdeps-} $deps
|
||||
do
|
||||
LDFLAGS="${LDFLAGS-} $(${PKG_CONFIG-pkg-config} --libs $dep 2>/dev/null || echo -l$dep)"
|
||||
CFLAGS="${CFLAGS-} $(${PKG_CONFIG-pkg-config} --cflags $dep 2>/dev/null || true)"
|
||||
LDFLAGS="${LDFLAGS-} $($PKG_CONFIG --libs $dep 2>/dev/null || echo -l$dep)"
|
||||
CFLAGS="${CFLAGS-} $($PKG_CONFIG --cflags $dep 2>/dev/null || true)"
|
||||
done
|
||||
|
||||
for header in $headers; do
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <openssl/ssl.h>
|
||||
#include <h2o.h>
|
||||
#include <curl/curl.h>
|
||||
#include <argon2.h>
|
||||
#include <vere/db/lmdb.h>
|
||||
|
||||
#include "ca-bundle.h"
|
||||
@ -533,7 +532,6 @@ report(void)
|
||||
LIBCURL_VERSION_MAJOR,
|
||||
LIBCURL_VERSION_MINOR,
|
||||
LIBCURL_VERSION_PATCH);
|
||||
printf("argon2: 0x%x\n", ARGON2_VERSION_NUMBER);
|
||||
}
|
||||
|
||||
/* _stop_exit(): exit immediately.
|
||||
|
Loading…
Reference in New Issue
Block a user