compat: move build-mingw script into configure

This commit is contained in:
~locpyl-tidnyd 2021-03-29 13:27:27 +00:00
parent d03e48702a
commit 2b5f00075d
3 changed files with 58 additions and 68 deletions

View File

@ -21,7 +21,8 @@
"mingw": {
"include": "include",
"lib": ".libs",
"prepare": "./autogen.sh && ./configure --enable-module-recovery"
"prepare": "./autogen.sh && ./configure --enable-module-recovery && make",
"make": "libsecp256k1.la"
},
"owner": "bitcoin-core",
"repo": "secp256k1",

View File

@ -1,61 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
function xxd()
{
cch=0
echo "unsigned char $2[] = {"
while IFS='' read line
do
for i in $line
do
echo -n " 0x$i,"
cch=$((cch+1))
done
echo
done < <(od -An -v -tx1 $1)
echo "};"
echo "unsigned int $2_len = $cch;"
}
case $(uname -s|tr A-Z a-z) in
*mingw64*)
;;
*)
echo This script works only on MingW64.
exit 1
;;
esac
if [ ! -e config.mk ]
then
# ensure required mingw packages are installed
mpkgs=(cmake curl gcc jq libsigsegv libuv make wslay)
pacman -S --needed autoconf automake-wrapper libtool patch ${mpkgs[@]/#/mingw-w64-x86_64-}
unset cdirs
unset ldirs
declare -a cdirs
declare -a ldirs
. <(jq -sr '
add|to_entries|.[]|select(.value.mingw)|.key as $key|(if .value.url then "
mkdir -p ../\($key)
pushd ../\($key)
curl -L \(.value.url)|(tar --strip \(.value.mingw.strip+1) -xzf - || true)" +
("../urbit/compat/mingw/\($key).patch"|"
[ -e \(.) ] && patch -p 1 <\(.)") else "
pushd ../\($key)" end) + "
\(.value.mingw.prepare//"")
make \(.value.mingw.make//"")
popd
\(.value.mingw.include//"."|if type == "array" then .[] else . end|"cdirs+=(-I../\($key)/\(.))
")\(.value.mingw.lib//"."|if type == "array" then .[] else . end|"ldirs+=(-L../\($key)/\(.))
")"' ../../nix/sources.json ../../nix/sources-mingw.json)
xxd /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt include_ca_bundle_crt >include/ca-bundle.h
xxd ../../bin/ivory.pill u3_Ivory_pill >include/ivory.h
CFLAGS="${CFLAGS-} ${cdirs[@]}" LDFLAGS="${LDFLAGS-} ${ldirs[@]}" PKG_CONFIG=echo ./configure
fi
make build/urbit build/urbit-worker

62
pkg/urbit/configure vendored
View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -e
set -euo pipefail
URBIT_VERSION="$(cat ./version)"
@ -19,12 +19,28 @@ defmacro () {
echo "#define $1 $2" >>include/config.h
}
xxd () {
cch=0
echo "unsigned char $2[] = {"
while IFS='' read line
do
for i in $line
do
echo -n " 0x$i,"
cch=$((cch+1))
done
echo
done < <(od -An -v -tx1 $1)
echo "};"
echo "unsigned int $2_len = $cch;"
}
defmacro URBIT_VERSION "\"$URBIT_VERSION\""
[ -n "$MEMORY_DEBUG" ] && defmacro U3_MEMORY_DEBUG 1
[ -n "$MEMORY_LOG" ] && defmacro U3_MEMORY_LOG 1
[ -n "$CPU_DEBUG" ] && defmacro U3_CPU_DEBUG 1
[ -n "$EVENT_TIME_DEBUG" ] && defmacro U3_EVENT_TIME_DEBUG 1
[ -n "${MEMORY_DEBUG-}" ] && defmacro U3_MEMORY_DEBUG 1
[ -n "${MEMORY_LOG-}" ] && defmacro U3_MEMORY_LOG 1
[ -n "${CPU_DEBUG-}" ] && defmacro U3_CPU_DEBUG 1
[ -n "${EVENT_TIME_DEBUG-}" ] && defmacro U3_EVENT_TIME_DEBUG 1
if [ -n "${HOST-}" ]
then os=$(sed 's$^[^-]*-\([^-]*\)-.*$\1$' <<< "$HOST")
@ -59,13 +75,47 @@ esac
# TODO Determine if the target cpu is little or big endian.
case $(tr A-Z a-z <<< $os) in
*mingw*)
# ensure required mingw packages are installed
mpkgs=(cmake curl gcc jq libsigsegv libuv make wslay)
pacman -S --needed autoconf automake-wrapper libtool patch ${mpkgs[@]/#/mingw-w64-x86_64-}
# poor man's nix-shell
declare -a cdirs
declare -a ldirs
. <(jq -sr '
add|to_entries|.[]|select(.value.mingw)|.key as $key|"../\(.key)" as $dir|(if .value.url then "
if [ ! -d \($dir) ]
then
mkdir -p \($dir)
pushd \($dir)
curl -L \(.value.url)|(tar --strip \(.value.mingw.strip+1) -xzf - || true)
popd
fi" else "" end) + "
pushd \($dir)
if [ ! -e .mingw~ ]
then" + ("../urbit/compat/mingw/\($key).patch"|"
[ -e \(.) ] && patch -p 1 <\(.)") + "
\(.value.mingw.prepare//"")
touch .mingw~
fi
make \(.value.mingw.make//"")
popd
\(.value.mingw.include//"."|if type == "array" then .[] else . end|"cdirs+=(-I../\($key)/\(.))
")\(.value.mingw.lib//"."|if type == "array" then .[] else . end|"ldirs+=(-L../\($key)/\(.))
")"' ../../nix/sources.json ../../nix/sources-mingw.json)
[ -e include/ca-bundle.h ] || xxd /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt include_ca_bundle_crt >include/ca-bundle.h
[ -e include/ivory.h ] || xxd ../../bin/ivory.pill u3_Ivory_pill >include/ivory.h
defmacro U3_OS_mingw 1
defmacro U3_OS_TERM_dumb 1
# increase default thread stack size and link Windows implibs
ldextra="-Wl,--stack,67108864 -lbcrypt -lws2_32"
vcompat="compat = mingw"
CFLAGS="${CFLAGS-} -DH2O_NO_UNIX_SOCKETS -Icompat/mingw"
CFLAGS="${CFLAGS-} ${cdirs[@]} -DH2O_NO_UNIX_SOCKETS -Icompat/mingw"
LDFLAGS="${LDFLAGS-} ${ldirs[@]}"
PKG_CONFIG="echo"
;;
*linux*)
defmacro U3_OS_linux 1