Skip to content

Commit

Permalink
msvc build support.
Browse files Browse the repository at this point in the history
- ssize_t support. (base64.h, windows_config/config.h)
- update windows build bat file. (newer source code, UTF-8, ECMULT_WINDOW_SIZE, elements)
  • Loading branch information
k-matsuzawa authored and greenaddress committed Nov 20, 2019
1 parent 8248cc9 commit 88d30c6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/ccan/ccan/base64/base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#ifndef CCAN_BASE64_H
#define CCAN_BASE64_H

#include "config.h"
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <sys/types.h>
Expand Down
1 change: 1 addition & 0 deletions src/wrap_js/windows_config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define HAVE_UNISTD_H 1
#define STDC_HEADERS 1
#define VERSION "0.6"
#define ssize_t long long

#define alignment_ok(p, n) ((size_t)(p) % (n) == 0)

Expand Down
8 changes: 7 additions & 1 deletion tools/msvc/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ REM everything is being munged together for Windows as a hack it causes
REM problems. Make a copy called hex_.c as a workaround.
copy src\ccan\ccan\str\hex\hex.c src\ccan\ccan\str\hex\hex_.c

if %ELEMENTS_BUILD% == "elements" (
set ELEMENTS_OPT=/DBUILD_ELEMENTS
) else (
set ELEMENTS_OPT=
)

REM Compile everything (wally, ccan, libsecp256k) in one lump.
REM Define USE_ECMULT_STATIC_PRECOMPUTATION to pick up the
REM ecmult_static_context.h file generated previously
cl /DUSE_ECMULT_STATIC_PRECOMPUTATION /DWALLY_CORE_BUILD /DHAVE_CONFIG_H /DSECP256K1_BUILD /I%LIBWALLY_DIR%\src\wrap_js\windows_config /I%LIBWALLY_DIR% /I%LIBWALLY_DIR%\src /I%LIBWALLY_DIR%\include /I%LIBWALLY_DIR%\src\ccan /I%LIBWALLY_DIR%\src\secp256k1 /Zi /LD src/aes.c src/base58.c src/bip32.c src/bip38.c src/bip39.c src/ecdh.c src/elements.c src/hex.c src/hmac.c src/internal.c src/mnemonic.c src/pbkdf2.c src/script.c src/scrypt.c src/sign.c src/transaction.c src/wif.c src/wordlist.c src/ccan/ccan/crypto/ripemd160/ripemd160.c src/ccan/ccan/crypto/sha256/sha256.c src/ccan/ccan/crypto/sha512/sha512.c src\ccan\ccan\str\hex\hex_.c src/secp256k1/src/secp256k1.c /Fewally.dll
cl /utf-8 /DUSE_ECMULT_STATIC_PRECOMPUTATION /DECMULT_WINDOW_SIZE=16 /DWALLY_CORE_BUILD %ELEMENTS_OPT% /DHAVE_CONFIG_H /DSECP256K1_BUILD /I%LIBWALLY_DIR%\src\wrap_js\windows_config /I%LIBWALLY_DIR% /I%LIBWALLY_DIR%\src /I%LIBWALLY_DIR%\include /I%LIBWALLY_DIR%\src\ccan /I%LIBWALLY_DIR%\src\ccan\base64 /I%LIBWALLY_DIR%\src\secp256k1 /Zi /LD src/aes.c src/base58.c src/bech32.c src/bip32.c src/bip38.c src/bip39.c src/blech32.c src/ecdh.c src/elements.c src/hex.c src/hmac.c src/internal.c src/mnemonic.c src/pbkdf2.c src/psbt.c src/script.c src/scrypt.c src/sign.c src/symmetric.c src/transaction.c src/wif.c src/wordlist.c src/ccan/ccan/crypto/ripemd160/ripemd160.c src/ccan/ccan/crypto/sha256/sha256.c src/ccan/ccan/crypto/sha512/sha512.c src/ccan/ccan/base64/base64.c src\ccan\ccan\str\hex\hex_.c src/secp256k1/src/secp256k1.c /Fewally.dll
2 changes: 1 addition & 1 deletion tools/msvc/gen_ecmult_static_context.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cl /DWALLY_CORE_BUILD /DHAVE_CONFIG_H /DSECP256K1_BUILD /I%LIBWALLY_DIR%\src\wrap_js\windows_config /I%LIBWALLY_DIR%\ /I%LIBWALLY_DIR%\src /I%LIBWALLY_DIR%\include /I%LIBWALLY_DIR%\src\ccan /I%LIBWALLY_DIR%\src\secp256k1 /Zi %LIBWALLY_DIR%\src/secp256k1/src/gen_context.c /Fegen_context.exe
cl /utf-8 /DWALLY_CORE_BUILD /DHAVE_CONFIG_H /DSECP256K1_BUILD /I%LIBWALLY_DIR%\src\wrap_js\windows_config /I%LIBWALLY_DIR%\ /I%LIBWALLY_DIR%\src /I%LIBWALLY_DIR%\include /I%LIBWALLY_DIR%\src\ccan /I%LIBWALLY_DIR%\src\secp256k1 /Zi %LIBWALLY_DIR%\src/secp256k1/src/gen_context.c /Fegen_context.exe
gen_context.exe
10 changes: 8 additions & 2 deletions tools/msvc/wallyjs.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ set LIBWALLY_DIR=%cd%
call "%~dp0\gen_ecmult_static_context.bat" || echo ERRORGENCONTEXT && exit /b 1

REM Create wrappers for wallyjs node module
REM Elements build is 'set ELEMENTS_BUILD="elements"'.
cd src
python wrap_js/makewrappers/wrap.py wally Release
python wrap_js/makewrappers/wrap.py nodejs Release
python wrap_js/makewrappers/wrap.py wally Release %ELEMENTS_BUILD%
python wrap_js/makewrappers/wrap.py nodejs Release %ELEMENTS_BUILD%
if %ELEMENTS_BUILD% == "elements" (
copy /Y /B wrap_js\windows_config\binding.gyp.elements_tmpl wrap_js\binding.gyp /B
) else (
copy /Y /B wrap_js\windows_config\binding.gyp.tmpl wrap_js\binding.gyp /B
)

REM Install wallyjs
cd wrap_js
Expand Down

0 comments on commit 88d30c6

Please sign in to comment.