Skip to content

Commit

Permalink
EasyWinBuilder v0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
phelixnmc committed Sep 2, 2013
1 parent 0810f84 commit e29c848
Show file tree
Hide file tree
Showing 26 changed files with 500 additions and 0 deletions.
9 changes: 9 additions & 0 deletions contrib/easywinbuilder/1a_environment_mingw.bat
@@ -0,0 +1,9 @@
@call set_vars.bat
@echo About to download MinGW installer - you need to install it manually like this:
@echo Use prepackaged catalogue
@echo Install to default directory: C:\MinGW
@echo Configure options: C, C++, MSYS basic system
@echo.
@pause
@start http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/%MINGWINSTALLER%/%MINGWINSTALLER%.exe/download
@set WAITMINGW=1
7 changes: 7 additions & 0 deletions contrib/easywinbuilder/1b_environment_qt.bat
@@ -0,0 +1,7 @@
@call set_vars.bat
@echo About to download Qt installer - you need to install it manually.
@echo Use default directory "C:\Qt\4.8.5". If it complains about the GCC version just ignore it.
@echo.
@pause
@start %QTDOWNLOADPATH%
@set WAITQT=1
7 changes: 7 additions & 0 deletions contrib/easywinbuilder/2a_run_download.bat
@@ -0,0 +1,7 @@
@call set_vars.bat
@if not "%WAITMINGW%" == "1" goto continue
@echo Ensure MinGW installer has finished.
@pause
:continue
@bash download.sh
@if not "%RUNALL%"=="1" pause
3 changes: 3 additions & 0 deletions contrib/easywinbuilder/2b_run_unpack.bat
@@ -0,0 +1,3 @@
@call set_vars.bat
@bash unpack.sh
@if not "%RUNALL%"=="1" pause
22 changes: 22 additions & 0 deletions contrib/easywinbuilder/3a_build_boost.bat
@@ -0,0 +1,22 @@
@call set_vars.bat
@echo Building boost...
@cd %ROOTPATH%\%EWBLIBS%\%BOOST%

@echo bootstrap...
call bootstrap.bat mingw
@echo.
@echo.
@echo building...
b2.exe --build-type=minimal --with-chrono --with-filesystem --with-program_options --with-system --with-thread^
--layout=versioned -sNO_BZIP2=1 -sNO_ZLIB=1^
variant=release^
toolset=gcc^
link=static^
threading=multi^
target-os=windows^
threadapi=win32^
cxxflags="%ADDITIONALCCFLAGS%"^
cflags="%ADDITIONALCCFLAGS%"^
stage
@cd ..\..\%EWBPATH%
@if not "%RUNALL%"=="1" pause
3 changes: 3 additions & 0 deletions contrib/easywinbuilder/3b_run_build_dep.bat
@@ -0,0 +1,3 @@
@call set_vars.bat
@rxvt -e ./build_dep.sh
@if not "%RUNALL%"=="1" pause
9 changes: 9 additions & 0 deletions contrib/easywinbuilder/3c_build_miniupnpc.bat
@@ -0,0 +1,9 @@
@call set_vars.bat
@bash patch_files.sh
@cd %ROOTPATH%\%EWBLIBS%\
@echo miniupnp...
@cd %MINIUPNPC%
@rem mingw32-make is different from normal msys make
mingw32-make -f Makefile.mingw ADDITIONALCCFLAGS="%ADDITIONALCCFLAGS%"
@cd ..\..\%EWBPATH%
@if not "%RUNALL%"=="1" pause
47 changes: 47 additions & 0 deletions contrib/easywinbuilder/4a_build_daemon.bat
@@ -0,0 +1,47 @@
@call set_vars.bat
@bash patch_files.sh
@echo Building Bitcoin daemon...
@rem todo: rewrite this with ^ line wrapping
@set PARAMS=BOOST_SUFFIX=%BOOSTSUFFIX%
@set PARAMS=%PARAMS% INCLUDEPATHS="
@rem set PARAMS=%PARAMS%-I'../src'
@set PARAMS=%PARAMS% -I'../%EWBLIBS%/%BOOST%'
@set PARAMS=%PARAMS% -I'../%EWBLIBS%/%OPENSSL%/include'
@set PARAMS=%PARAMS% -I'../%EWBLIBS%/%BERKELEYDB%/build_unix'
@set PARAMS=%PARAMS% -I'../%EWBLIBS%/%MINIUPNPC%'
@set PARAMS=%PARAMS%"
@set PARAMS=%PARAMS% LIBPATHS="
@set PARAMS=%PARAMS%-L'../src/leveldb'
@set PARAMS=%PARAMS% -L'../%EWBLIBS%/%BOOST%/stage/lib'
@set PARAMS=%PARAMS% -L'../%EWBLIBS%/%OPENSSL%'
@set PARAMS=%PARAMS% -L'../%EWBLIBS%/%BERKELEYDB%/build_unix'
@set PARAMS=%PARAMS% -L'../%EWBLIBS%/%MINIUPNPC%'
@set PARAMS=%PARAMS%"
@set PARAMS=%PARAMS% ADDITIONALCCFLAGS="%ADDITIONALCCFLAGS%"
@set PARAMS=%PARAMS:\=/%
@echo PARAMS: %PARAMS%

@set PARAMS=%PARAMS% USE_UPNP=1
@rem remove "rem " from the next line to deactivate upnp
@rem set PARAMS=%PARAMS% USE_UPNP=-

@cd %ROOTPATH%\src
@mingw32-make -f makefile.mingw %PARAMS%
@if errorlevel 1 goto error
@echo.
@echo.
@strip %COINNAME%d.exe
@if errorlevel 1 goto error
@echo !!!!!!! %COINNAME% daemon DONE: Find %COINNAME%d.exe in ./src :)
@echo.
@echo.
@if not "%RUNALL%"=="1" pause
@goto end

:error
@echo.
@echo.
@echo !!!!!! Error! Build daemon failed.
@pause
:end
@cd ..\%EWBPATH%
37 changes: 37 additions & 0 deletions contrib/easywinbuilder/4b_build_qt.bat
@@ -0,0 +1,37 @@
@call set_vars.bat
@if not "%WAITQT%" == "1" goto continue
@echo Ensure Qt installer has finished.
@pause
:continue

@bash patch_files.sh

@cd %ROOTPATH%
@echo building qt - qmake...

@set QMPS=BOOST_INCLUDE_PATH=%EWBLIBS%/%BOOST%^
BOOST_LIB_PATH=%EWBLIBS%/%BOOST%/stage/lib^
BOOST_LIB_SUFFIX=%BOOSTSUFFIX%^
OPENSSL_INCLUDE_PATH=%EWBLIBS%/%OPENSSL%/include^
OPENSSL_LIB_PATH=%EWBLIBS%/%OPENSSL%^
BDB_INCLUDE_PATH=%EWBLIBS%/%BERKELEYDB%/build_unix^
BDB_LIB_PATH=%EWBLIBS%/%BERKELEYDB%/build_unix^
MINIUPNPC_INCLUDE_PATH=%EWBLIBS%/%MINIUPNPC%^
MINIUPNPC_LIB_PATH=%EWBLIBS%/%MINIUPNPC%^
QMAKE_CXXFLAGS="%ADDITIONALCCFLAGS%"^
QMAKE_CFLAGS="%ADDITIONALCCFLAGS%"

@%QTPATH%\qmake.exe %QMPS%
@echo.
@echo.
@echo building qt - make...
mingw32-make -f Makefile.Release
@if errorlevel 1 goto continue
@echo !!!!!!! %COINNAME%-qt DONE: Find %COINNAME%-qt.exe in ./release :)
:continue
@echo.
@echo.
@echo.
@echo.
@cd %EWBPATH%
@if not "%RUNALL%"=="1" pause
3 changes: 3 additions & 0 deletions contrib/easywinbuilder/5a_run_hash_daemon.bat
@@ -0,0 +1,3 @@
@call set_vars.bat
@bash hash_daemon.sh
@if not "%RUNALL%"=="1" pause
3 changes: 3 additions & 0 deletions contrib/easywinbuilder/5b_run_hash_qt.bat
@@ -0,0 +1,3 @@
@call set_vars.bat
@bash hash_qt.sh
@if not "%RUNALL%"=="1" pause
11 changes: 11 additions & 0 deletions contrib/easywinbuilder/6_gather_dlls.bat
@@ -0,0 +1,11 @@
@call set_vars.bat
copy %QTPATH%\QtCore4.dll %ROOTPATH%\release\
copy %QTPATH%\QtGui4.dll %ROOTPATH%\release\
copy %QTPATH%\QtNetwork4.dll %ROOTPATH%\release\
copy C:\MinGW\bin\libgcc_s_dw2-1.dll %ROOTPATH%\release\
copy "C:\MinGW\bin\libstdc++-6.dll" %ROOTPATH%\release\
copy C:\MinGW\bin\mingwm10.dll %ROOTPATH%\release\

copy C:\MinGW\bin\libgcc_s_dw2-1.dll %ROOTPATH%\src\
copy "C:\MinGW\bin\libstdc++-6.dll" %ROOTPATH%\src\
@if not "%RUNALL%"=="1" pause
27 changes: 27 additions & 0 deletions contrib/easywinbuilder/README.md
@@ -0,0 +1,27 @@
EasyWinBuilder v0.3
===============
(c) 2013 phelix / blockchained.com - MIT license

Download environment software, all dependencies and build Bitcoin/Namecoin/Altcoin automatically. To run simply double click __all_easywinbuilder.bat or manually start the batch files in order. Building Bitcoin on Windows really is a pain. Hopefully this saves people some trouble.

EasyWinBuilder can run on a mint windows system (e.g. a virtual machine) or a normal system. It might overwrite your MinGW or Qt installation, though. Please note the process takes about half an hour or more and will need about 3GB of hard drive space.

In this repository there are no changes to the Bitcoin code itself though the process makes a handful of small changes. This means it should be possible to plug'n'play the easywinbuilder directory into similar Bitcoin versions.

To change dependency versions edit set_vars.bat

File Hashes
-----------
The process will calculate a hash of the disassemblies of the final executables. The idea is to validate binaries by several people.
I am not quite sure if this will reliably result in the same hash for the same build. Please let me know if you get different values or know how to improve this feature.

ToDo
-----
* Check daemon disassembly hashes (deterministic build)
* Automatic environment install (how to bootstrap?)
* Try to speed up building of OpenSSL and Berkeley DB by only building what is necessary


Credits
-------
Based on build instructions by nitrogenetics (https://bitcointalk.org/index.php?topic=149479.0), Matt Corallo and others
17 changes: 17 additions & 0 deletions contrib/easywinbuilder/__all_easywinbuilder.bat
@@ -0,0 +1,17 @@
@echo EasyWinBuilder v0.3
@echo.
@set RUNALL=1
@echo.
@call 1a_environment_mingw.bat
@rem if errorlevel 1 goto error
@call 1b_environment_qt.bat
@rem if errorlevel 1 goto error
@echo.
@call __everything_but_environment_easywinbuilder.bat
@goto end

:error
@echo Fatal error! Errorlevel: %errorlevel%
@pause

:end
@@ -0,0 +1,13 @@
@set RUNALL=1
@call 2a_run_download.bat
@if errorlevel 1 goto error
@call 2b_run_unpack.bat
@if errorlevel 1 goto error
@call __everything_from_after_unpack_easywinbuilder.bat
@goto end

:error
@echo Fatal error! Errorlevel: %ERRORLEVEL%
@pause

:end
@@ -0,0 +1,28 @@
@set RUNALL=1
@call 3a_build_boost.bat
@if errorlevel 1 goto error
@call 3b_run_build_dep.bat
@if errorlevel 1 goto error
@call 3c_build_miniupnpc.bat
@if errorlevel 1 goto error
@call 4a_build_daemon.bat
@if errorlevel 1 goto error
@call 4b_build_qt.bat
@if errorlevel 1 goto error
@rem call 5a_run_hash_daemon.bat
@if errorlevel 1 goto error
@call 5b_run_hash_qt.bat
@if errorlevel 1 goto error
@call 6_gather_dlls.bat
@if errorlevel 1 goto error
@echo.
@echo.
@goto end

:error
@echo Fatal error! Errorlevel: %errorlevel%

:end
@pause


34 changes: 34 additions & 0 deletions contrib/easywinbuilder/build_dep.sh
@@ -0,0 +1,34 @@
set -o errexit

if [ -d "${ROOTPATHSH}/src/leveldb" ]; then
echo leveldb...
cd $ROOTPATHSH/src/leveldb
make memenv_test TARGET_OS=OS_WINDOWS_CROSSCOMPILE \
OPT="${ADDITIONALCCFLAGS}"
echo
cd ../../$EWBPATH
fi

cd $ROOTPATHSH/$EWBLIBS

echo db...
cd $BERKELEYDB
cd build_unix
../dist/configure --disable-replication --enable-mingw --enable-cxx \
CXXFLAGS="${ADDITIONALCCFLAGS}" \
CFLAGS="${ADDITIONALCCFLAGS}"
sed -i 's/typedef pthread_t db_threadid_t;/typedef u_int32_t db_threadid_t;/g' db.h # workaround, see https://bitcointalk.org/index.php?topic=45507.0
make
cd ..
cd ..
echo

echo openssl...
cd $OPENSSL
export CC="gcc ${ADDITIONALCCFLAGS}"
./config
make
cd ..
echo

cd ../$EWBPATH
4 changes: 4 additions & 0 deletions contrib/easywinbuilder/dahash.bat
@@ -0,0 +1,4 @@
@call %~dp0\set_vars.bat
@set FN=%1
@set FN=%FN:\=/%
@bash %~dp0\dahash.sh %FN%
11 changes: 11 additions & 0 deletions contrib/easywinbuilder/dahash.sh
@@ -0,0 +1,11 @@
if [ ! -f $1 ]; then
echo ERROR: File $1 not found.
exit
fi

echo File hash sha256:
shasum -a 256 -b $1
echo
echo Hash sha256 of disassembly [may take a while]:
objdump -d $1 | shasum -a 256
echo
27 changes: 27 additions & 0 deletions contrib/easywinbuilder/download.sh
@@ -0,0 +1,27 @@
echo Creating lib directory...
echo Downloading tools...
mingw-get install msys-wget-bin # > /dev/null 2>&1
mingw-get install msys-unzip-bin #> /dev/null 2>&1
mingw-get install msys-perl # > /dev/null 2>&1
# There is a problem with MSYS bash and sh that stalls OpenSSL config on some systems. Using rxvt shell as a workaround.
mingw-get install msys-rxvt # > /dev/null 2>&1
echo

set -o errexit

cd $ROOTPATHSH
if [ ! -d $EWBLIBS ]; then
mkdir $EWBLIBS
fi

# echo Downloading source...
# wget --no-check-certificate -N "https://github.com/phelixbtc/namecoin-qt/archive/easywinbuilder.tar.gz" -O "source.tar.gz"
# echo

echo Downloading dependencies...
cd libs
wget -N "http://www.openssl.org/source/$OPENSSL.tar.gz"
wget -N "http://download.oracle.com/berkeley-db/$BERKELEYDB.tar.gz"
wget -N "http://downloads.sourceforge.net/project/boost/boost/$BOOSTVERSION/$BOOST.tar.gz"
wget -N "http://miniupnp.tuxfamily.org/files/download.php?file=$MINIUPNPC.tar.gz"
echo
3 changes: 3 additions & 0 deletions contrib/easywinbuilder/hash_daemon.sh
@@ -0,0 +1,3 @@
echo Hash of daemon binary [experimental]...
bash dahash.sh $ROOTPATHSH/src/${COINNAME}d.exe
echo phelix got:
6 changes: 6 additions & 0 deletions contrib/easywinbuilder/hash_qt.sh
@@ -0,0 +1,6 @@
echo Hash of Qt binary [experimental]...
bash dahash.sh $ROOTPATHSH/release/${COINNAME}-qt.exe
echo phelix got: 6ebd7bb9ff0bb85a2328527e99357ada89cd2ed57726395188ea7b5ea453284b
echo
echo

16 changes: 16 additions & 0 deletions contrib/easywinbuilder/patch_files.sh
@@ -0,0 +1,16 @@
sed -i.bak 's/INCLUDEPATHS= \\/INCLUDEPATHS?= \\/g' $ROOTPATHSH/src/makefile.mingw
sed -i.bak 's/LIBPATHS= \\/LIBPATHS?= \\/g' $ROOTPATHSH/src/makefile.mingw
sed -i.bak 's/USE_UPNP:=-/USE_UPNP?=-/g' $ROOTPATHSH/src/makefile.mingw

sed -i.bak 's,#include <miniupnpc/miniwget.h>,#include <miniwget.h>,g' $ROOTPATHSH/src/net.cpp
sed -i.bak 's,#include <miniupnpc/miniupnpc.h>,#include <miniupnpc.h>,g' $ROOTPATHSH/src/net.cpp
sed -i.bak 's,#include <miniupnpc/upnpcommands.h>,#include <upnpcommands.h>,g' $ROOTPATHSH/src/net.cpp
sed -i.bak 's,#include <miniupnpc/upnperrors.h>,#include <upnperrors.h>,g' $ROOTPATHSH/src/net.cpp

sed -i.bak 's/\$(CC) -enable-stdcall-fixup/\$(CC) -Wl,-enable-stdcall-fixup/g' $ROOTPATHSH/${EWBLIBS}/${MINIUPNPC}/Makefile.mingw # workaround, see http://stackoverflow.com/questions/13227354/warning-cannot-find-entry-symbol-nable-stdcall-fixup-defaulting
sed -i.bak 's/all: init upnpc-static upnpc-shared testminixml libminiupnpc.a miniupnpc.dll/all: init upnpc-static/g' $ROOTPATHSH/${EWBLIBS}/${MINIUPNPC}/Makefile.mingw # only need static, rest is not compiling

# += does not work on windows defined variables
sed -i.bak 's/CFLAGS=-mthreads/CFLAGS=${ADDITIONALCCFLAGS} -mthreads/g' $ROOTPATHSH/src/makefile.mingw
sed -i.bak 's/CC = gcc/CC=gcc ${ADDITIONALCCFLAGS} -Wall/g' $ROOTPATHSH/${EWBLIBS}/${MINIUPNPC}/Makefile.mingw

0 comments on commit e29c848

Please sign in to comment.