diff --git a/proto-x86/Dockerfile b/proto-x86/Dockerfile deleted file mode 100644 index 729effd..0000000 --- a/proto-x86/Dockerfile +++ /dev/null @@ -1,144 +0,0 @@ -FROM ubuntu -MAINTAINER earlz - -WORKDIR /root -RUN set -emx \ - && apt-get update \ - && apt-get install -y -qq --no-install-recommends ca-certificates curl wget apt-utils build-essential git libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils git cmake libboost-all-dev software-properties-common texinfo bison flex libmpc-dev libmpfr-dev libgmp3-dev yasm \ - && add-apt-repository ppa:bitcoin/bitcoin -y \ - && apt-get update \ - && apt-get install libdb4.8-dev libdb4.8++-dev -y -qq --no-install-recommends - - -ENV REPO_PREFIX=https://github.com/qtumproject -ENV BRANCH=proto-x86 -ENV MAKE_SUFFIX=-j2 - - -# get x86-toolchain source -RUN set -ex \ - && git clone $REPO_PREFIX/x86-toolchain \ - && cd x86-toolchain \ - && git checkout $BRANCH - - - - -ENV PREFIX=/opt/cross -ENV TARGET=i686-elf -ENV SYSROOT=/opt/x86-compiler/sysroot -ENV PATH=${PATH}:${SYSROOT}/bin:$PREFIX/bin:/root/qtum:/root/qtum:/root/qtum-docker/proto-x86/utils - -# build the freestanding compiler -RUN set -ex \ - && cd x86-toolchain \ - && mkdir build-binutils \ - && cd build-binutils \ - && ../binutils-2.29/configure --target="$TARGET" --prefix="$PREFIX" --disable-werror \ - && make \ - && make install \ - && cd .. \ - && mkdir build-gcc \ - && cd build-gcc \ - && ../gcc-7.2.0/configure --target="$TARGET" --prefix="$PREFIX" --enable-languages=c,c++ \ - && make all-gcc \ - && make all-target-libgcc \ - && make install-gcc \ - && make install-target-libgcc - -#get libc -RUN set -ex \ - && git clone $REPO_PREFIX/FsLibc \ - && cd FsLibc \ - && git checkout $BRANCH - -ENV TARGET=i686-qtum - -#compile QtumOS compiler and supports -RUN set -ex \ - && ls $PREFIX/bin \ - && i686-elf-gcc -v \ - && cd FsLibc \ - && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=cross-toolchain.cmake -DCMAKE_INSTALL_PREFIX=$SYSROOT/usr . \ - && make -C libc \ - && make -C libc install \ - && cd ~/x86-toolchain/crtfiles \ - && make \ - && cd .. \ - && mkdir -p $SYSROOT/usr/lib \ - && mkdir -p $SYSROOT/usr/include \ - && cp crtfiles/*.o $SYSROOT/usr/lib/ \ - && cp -r includes/* $SYSROOT/usr/include/ \ - && rm -rf build-binutils \ - && mkdir build-binutils \ - && cd build-binutils \ - && ../binutils-2.29/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot="$SYSROOT" --disable-werror \ - && make \ - && make install \ - && cd .. \ - && rm -rf build-gcc \ - && mkdir build-gcc \ - && cd build-gcc \ - && ../gcc-7.2.0/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot="$SYSROOT" --enable-languages=c \ - && make all-gcc \ - && make all-target-libgcc \ - && make install-gcc \ - && make install-target-libgcc - - - -# get qtum source -RUN set -ex \ - && git clone $REPO_PREFIX/qtum qtum-compile --recursive \ - && cd qtum-compile \ - && git checkout $BRANCH - -# build qtum -RUN set -ex \ - && cd qtum-compile \ - && ./autogen.sh \ - && ./configure --disable-tests --without-gui \ - && make $MAKE_SUFFIX - -# build x86lib utility -RUN set -ex \ - && cd qtum-compile/src/x86lib \ - && make $MAKE_SUFFIX - -#install qtum tools -RUN set -ex \ - && cd qtum-compile \ - && mkdir /root/qtum \ - && cp src/qtumd src/qtum-cli src/qtum-tx src/x86lib/x86testbench /root/qtum - -# get libqtum -RUN set -ex \ - && git clone $REPO_PREFIX/libqtum \ - && cd libqtum \ - && git checkout $BRANCH - -# build libqtum -RUN set -ex \ - && cd libqtum \ - && make \ - && make deploy - -# get docker helpers -RUN set -ex \ - && git clone $REPO_PREFIX/qtum-docker \ - && cd qtum-docker \ - && git checkout $BRANCH - -#clean up -RUN set -ex \ - && rm -rf qtum-compile \ - && rm -rf x86-toolchain - -# create data directory -ENV QTUM_DATA /data -RUN mkdir $QTUM_DATA \ - && ln -sfn $QTUM_DATA /root/.qtum \ -VOLUME /data - -EXPOSE 3888 3889 13888 13889 -CMD ["qtumd", "-regtest", "-logevents"] diff --git a/proto-x86/build_qtumx86 b/proto-x86/build_qtumx86 deleted file mode 100755 index 3202e74..0000000 --- a/proto-x86/build_qtumx86 +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -docker build -t qtumx86 -f Dockerfile . \ No newline at end of file diff --git a/proto-x86/client/Dockerfile b/proto-x86/client/Dockerfile new file mode 100644 index 0000000..92dad8e --- /dev/null +++ b/proto-x86/client/Dockerfile @@ -0,0 +1,35 @@ +FROM qtum-alpine-bin as build +LABEL maintainers "earlz, VoR0220" + +FROM alpine + +# +# Copy the binaries from the build to our new container +# +COPY --from=build /usr/local/bin/qtumd /usr/local/bin +COPY --from=build /usr/local/bin/qtum-cli /usr/local/bin +# +# Install all dependencies +# +RUN apk update && apk add boost boost-filesystem \ + boost-program_options \ + boost-system boost-thread \ + boost-random busybox db-c++ \ + libevent libgcc libressl2.7-libcrypto \ + libstdc++ musl + +# +# Copy the qtum.conf file from +# the build context into the container +# +COPY qtum.conf /qtum.conf + +# create data directory +ENV QTUM_DATA /data +RUN mkdir $QTUM_DATA \ + && ln -sfn $QTUM_DATA /.qtum +VOLUME /data + +EXPOSE 3888 3889 13888 13889 +ENV PATH=${PATH}:/usr/local/bin: +CMD ["qtumd", "-regtest", "-logevents", "-printtoconsole"] \ No newline at end of file diff --git a/proto-x86/client/Dockerfile.build b/proto-x86/client/Dockerfile.build new file mode 100644 index 0000000..f3e45ad --- /dev/null +++ b/proto-x86/client/Dockerfile.build @@ -0,0 +1,2 @@ +FROM alpine-dev +RUN set -ex && git clone https://github.com/qtumproject/qtum-x86.git --recursive && cd qtum-x86 && git checkout qtum-x86 \ No newline at end of file diff --git a/proto-x86/client/Dockerfile.dev b/proto-x86/client/Dockerfile.dev new file mode 100644 index 0000000..afccc21 --- /dev/null +++ b/proto-x86/client/Dockerfile.dev @@ -0,0 +1,19 @@ +FROM alpine:3.9.4 +LABEL maintainers "earlz, VoR0220" + +RUN apk update && apk add git \ + make \ + cmake \ + file \ + autoconf \ + automake \ + build-base \ + libtool \ + db-c++ \ + db-dev \ + boost-system \ + boost-program_options \ + boost-filesystem \ + boost-dev \ + libressl-dev \ + libevent-dev \ No newline at end of file diff --git a/proto-x86/client/Dockerfile.install b/proto-x86/client/Dockerfile.install new file mode 100644 index 0000000..7fd66e6 --- /dev/null +++ b/proto-x86/client/Dockerfile.install @@ -0,0 +1,12 @@ +FROM qtum-alpine-build +RUN (cd qtum-x86 && ./autogen.sh && \ + ./configure \ + --disable-bench --disable-static \ + --without-gui --disable-zmq \ + --with-incompatible-bdb \ + CFLAGS='-w' CXXFLAGS='-w' && \ + make -j 4 && \ + strip src/qtumd && \ + strip src/qtum-cli && \ + strip src/qtum-tx && \ + make install && make check && make clean && make distclean) diff --git a/proto-x86/client/build.sh b/proto-x86/client/build.sh new file mode 100755 index 0000000..f71b566 --- /dev/null +++ b/proto-x86/client/build.sh @@ -0,0 +1,4 @@ +docker build -f Dockerfile.dev -t alpine-dev . +docker build -f Dockerfile.build -t qtum-alpine-build . +docker build --no-cache -f Dockerfile.install -t qtum-alpine-bin . +docker build -f Dockerfile -t qtum-alpine . \ No newline at end of file diff --git a/proto-x86/client/qtum.conf b/proto-x86/client/qtum.conf new file mode 100644 index 0000000..fb13419 --- /dev/null +++ b/proto-x86/client/qtum.conf @@ -0,0 +1,7 @@ +regtest=1 +server=1 +rpcbind=127.0.0.1:3888 +rpcuser=user +rpcpassword=password +rpcallowip=0.0.0.0/0 +rpcport=3888 \ No newline at end of file diff --git a/proto-x86/helpers.sh b/proto-x86/helpers.sh index aa5aaa4..a658b86 100755 --- a/proto-x86/helpers.sh +++ b/proto-x86/helpers.sh @@ -1,6 +1,6 @@ #!/bin/bash function qx86start() { - docker run --rm -v "${PWD}:/root/bind" --name qx86 -d qtumx86 qtum/src/qtumd -regtest -logevents + docker run --rm -v "${PWD}:/root/bind" --name qx86 -d qtum-alpine qtumd -regtest -logevents -printtoconsole } export -f qx86start @@ -9,20 +9,20 @@ function qx86stop() { } export -f qx86stop -alias qx86cli='docker exec qx86 qcli' +alias qx86cli='docker exec qx86 qtum-cli -regtest' function qx86deploy() { - docker exec -t qx86 deploy_contract `cat $1` + docker exec -t qx86 qtum-cli -regtest createcontract `cat $1` } export -f qx86deploy -function qx86tb() { - docker run --rm -v "${PWD}:/root/bind" qtumx86 x86tb -} -export -f qx86tb - function qx86make() { - docker run --rm -v "${PWD}:/root/bind" qtumx86 qmake "$@" + docker run --rm -v "${PWD}:/root/bind" -w "/root/bind" qtumtoolchain-alpine make } export -f qx86make +function qx86simpleabi() { + docker run --rm -it -v "${PWD}:/root/bind" -w /root/bind qtum-simpleabi -a "$1" -d -e +} + +export -f qx86simpleabi diff --git a/proto-x86/install.sh b/proto-x86/install.sh new file mode 100755 index 0000000..7d4369c --- /dev/null +++ b/proto-x86/install.sh @@ -0,0 +1,7 @@ +#!/bin/bash +cd client +./build.sh +cd ../toolchain +./build.sh +cd ../simpleabi +docker build -t qtum-simpleabi . \ No newline at end of file diff --git a/proto-x86/simpleabi/Dockerfile b/proto-x86/simpleabi/Dockerfile new file mode 100644 index 0000000..ea369ba --- /dev/null +++ b/proto-x86/simpleabi/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:1.7.3 + +RUN go get -u -v -d github.com/qtumproject/simple-abi && \ + cd /go/src/github.com/qtumproject/simple-abi && \ + CGO_ENABLED=0 GOOS=linux go build -o simple-abi . + +FROM alpine:3.9.4 +LABEL maintainers "earlz, VoR0220" + +COPY --from=0 /go/src/github.com/qtumproject/simple-abi/simple-abi /usr/local/bin +ENTRYPOINT [ "simple-abi" ] \ No newline at end of file diff --git a/proto-x86/test/Makefile b/proto-x86/test/Makefile new file mode 100644 index 0000000..21b5ae7 --- /dev/null +++ b/proto-x86/test/Makefile @@ -0,0 +1,28 @@ +# files to be built +# fill this in as a template +HDRS = +C_SRC = helloworld.c +OUTPUT = helloworld.elf +LIBS = +BYTECODE = helloworld.qbit + +C_OBJS = $(subst .c,.o,$(C_SRC)) + +#these default flags will just remove dead code and give warnings +CFLAGS += -Wall -ffunction-sections -fdata-sections +LDFLAGS += -Wl,--gc-section + + +default: $(BYTECODE) + +$(BYTECODE): $(OUTPUT) + qx86-codeify -elf $(OUTPUT) -hex -o $(BYTECODE) + +$(OUTPUT): $(C_OBJS) + $(CC) $(LDFLAGS) -o $(OUTPUT) $(C_OBJS) $(LIBS) + +$(C_OBJS): $(HDRS) $(C_SRC) + $(CC) $(CFLAGS) -c $*.c -o $@ + +clean: + rm -f $(C_OBJS) $(OUTPUT) $(BYTECODE) \ No newline at end of file diff --git a/proto-x86/test/helloworld.c b/proto-x86/test/helloworld.c new file mode 100644 index 0000000..9d689c9 --- /dev/null +++ b/proto-x86/test/helloworld.c @@ -0,0 +1,13 @@ +#include + +int onCreate() +{ + qtumEventStringString("Hello World", "Contract creation"); + return 0; +} + +int main() +{ + qtumEventStringString("Hello World", "Execution Success!"); + return 0; +} \ No newline at end of file diff --git a/proto-x86/toolchain/Dockerfile b/proto-x86/toolchain/Dockerfile new file mode 100644 index 0000000..f0d543f --- /dev/null +++ b/proto-x86/toolchain/Dockerfile @@ -0,0 +1,90 @@ +FROM qtumtoolchain-alpine-build + +ENV PREFIX=/opt/cross +ENV TARGET=i686-elf +ENV SYSROOT=/opt/x86-compiler/sysroot +ENV PATH=${PATH}:${SYSROOT}/bin:$PREFIX/bin:/root/qtum:/root/qtum:/root/qtum-docker/proto-x86/utils + +RUN set -ex \ + && cd qx86-codeify \ + && make -j4 + +# build the freestanding compiler +RUN set -ex \ + && cd x86-toolchain \ + && mkdir build-binutils \ + && cd build-binutils \ + && ../binutils-2.29/configure --target="$TARGET" --prefix="$PREFIX" --disable-werror \ + && make \ + && make install \ + && cd .. \ + && mkdir build-gcc \ + && cd gcc-7.2.0 \ + && ./contrib/download_prerequisites \ + && cd ../build-gcc \ + && ../gcc-7.2.0/configure --target="$TARGET" --prefix="$PREFIX" --enable-languages=c,c++ \ + && make all-gcc -j4 \ + && make all-target-libgcc \ + && make install-gcc \ + && make install-target-libgcc + +ENV TARGET=i686-qtum + +#compile QtumOS compiler and supports +RUN set -ex \ + && ls $PREFIX/bin \ + && i686-elf-gcc -v \ + && cd FsLibc \ + && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=cross-toolchain.cmake -DCMAKE_INSTALL_PREFIX=$SYSROOT/usr . \ + && make -C libc \ + && make -C libc install \ + && cd /x86-toolchain/crtfiles \ + && make \ + && cd .. \ + && mkdir -p $SYSROOT/usr/lib \ + && mkdir -p $SYSROOT/usr/include \ + && cp crtfiles/*.o $SYSROOT/usr/lib/ \ + && cp -r includes/* $SYSROOT/usr/include/ \ + && rm -rf build-binutils \ + && mkdir build-binutils \ + && cd build-binutils \ + && ../binutils-2.29/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot="$SYSROOT" --disable-werror \ + && make \ + && make install \ + && cd .. \ + && rm -rf build-gcc \ + && mkdir build-gcc \ + && cd build-gcc \ + && ../gcc-7.2.0/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot="$SYSROOT" --enable-languages=c \ + && make all-gcc -j4 \ + && make all-target-libgcc \ + && make install-gcc \ + && make install-target-libgcc + +# build libqtum +RUN set -ex \ + && cd libqtum \ + && make -j2 \ + && make deploy \ + && make deploy + +FROM alpine:3.9.4 + +RUN apk --no-cache add make \ + musl \ + db-dev + +COPY --from=0 /lib /lib +COPY --from=0 /qx86-codeify/qx86-codeify /usr/local/bin +COPY --from=0 /opt/cross /opt/cross +COPY --from=0 /opt/x86-compiler/sysroot /opt/x86-compiler/sysroot +COPY --from=0 /usr/include /usr/include + +ENV PATH=${PATH}:/opt/x86-compiler/sysroot/bin:/opt/cross/bin:/root/qtum:/usr/local/bin +ENV CC=i686-qtum-gcc +ENV LD=i686-qtum-ld +ENV CXX=i686-qtum-g++ +ENV CPP=i686-qtum-cpp +ENV AR=i686-qtum-ar +ENV STRIP=i686-qtum-strip +ENV OBJCOPY=i686-qtum-objcopy \ No newline at end of file diff --git a/proto-x86/toolchain/Dockerfile.build b/proto-x86/toolchain/Dockerfile.build new file mode 100644 index 0000000..8a5f1f7 --- /dev/null +++ b/proto-x86/toolchain/Dockerfile.build @@ -0,0 +1,14 @@ +FROM alpine-dev +LABEL maintainers "earlz, VoR0220" + +ENV REPO_PREFIX=https://github.com/qtumproject +ENV BRANCH=proto-x86 + +RUN git clone $REPO_PREFIX/x86-toolchain +RUN git clone $REPO_PREFIX/FsLibc && cd FsLibc && git checkout $BRANCH +RUN git clone $REPO_PREFIX/qx86-codeify +# get libqtum +RUN set -ex \ + && git clone $REPO_PREFIX/libqtum \ + && cd libqtum \ + && git checkout $BRANCH \ No newline at end of file diff --git a/proto-x86/toolchain/Dockerfile.dev b/proto-x86/toolchain/Dockerfile.dev new file mode 100644 index 0000000..ceea859 --- /dev/null +++ b/proto-x86/toolchain/Dockerfile.dev @@ -0,0 +1,24 @@ +FROM alpine:3.9.4 +LABEL maintainers "earlz, VoR0220" + +RUN apk update && apk add git \ + make \ + cmake \ + musl \ + alpine-sdk \ + texinfo \ + bison \ + flex \ + yasm \ + perl-utils \ + autoconf \ + automake \ + libtool \ + db-dev \ + boost \ + boost-system \ + boost-program_options \ + boost-filesystem \ + boost-dev \ + openssl-dev \ + libevent-dev \ No newline at end of file diff --git a/proto-x86/toolchain/build.sh b/proto-x86/toolchain/build.sh new file mode 100755 index 0000000..3868719 --- /dev/null +++ b/proto-x86/toolchain/build.sh @@ -0,0 +1,3 @@ +docker build -f Dockerfile.dev -t alpine-dev . +docker build -f Dockerfile.build -t qtumtoolchain-alpine-build . +docker build -f Dockerfile -t qtumtoolchain-alpine . \ No newline at end of file diff --git a/proto-x86/utils/deploy_contract b/proto-x86/utils/deploy_contract deleted file mode 100755 index 35ea59b..0000000 --- a/proto-x86/utils/deploy_contract +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - - -# bytecode, gaslimit, gasprice, senderaddress, broadcast -qcli createcontract "$@" \ No newline at end of file diff --git a/proto-x86/utils/qcli b/proto-x86/utils/qcli deleted file mode 100755 index 067039c..0000000 --- a/proto-x86/utils/qcli +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -cd ~/bind -~/qtum/qtum-cli -regtest "$@" \ No newline at end of file diff --git a/proto-x86/utils/qmake b/proto-x86/utils/qmake deleted file mode 100755 index 75e6151..0000000 --- a/proto-x86/utils/qmake +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -export CC=i686-qtum-gcc -export LD=i686-qtum-ld -export CXX=i686-qtum-g++ -export CPP=i686-qtum-cpp -export AR=i686-qtum-ar -export STRIP=i686-qtum-strip -export OBJCOPY=i686-qtum-objcopy - -cd ${HOME}/bind - -make "$@" \ No newline at end of file diff --git a/proto-x86/utils/start_qtum b/proto-x86/utils/start_qtum deleted file mode 100755 index e69de29..0000000 diff --git a/proto-x86/utils/stop_qtum b/proto-x86/utils/stop_qtum deleted file mode 100755 index e69de29..0000000 diff --git a/proto-x86/utils/x86tb b/proto-x86/utils/x86tb deleted file mode 100755 index e782b2a..0000000 --- a/proto-x86/utils/x86tb +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -~/qtum/src/x86testbench "$@"" \ No newline at end of file