Skip to content

Commit

Permalink
Close #16 which requires caching of build artifacts so that rebuilds …
Browse files Browse the repository at this point in the history
…of the Bitcoin SV node repo can be skipped.
  • Loading branch information
rt121212121 committed Aug 12, 2020
1 parent 5c9402d commit 7aeb47a
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 39 deletions.
26 changes: 26 additions & 0 deletions .azure-pipelines/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,29 @@ trigger:
paths:
exclude: [ 'README.md' ]

variables:
- name: BSV_GIT_URI
value: https://github.com/electrumsv/bitcoin-sv
- name: BSV_GIT_BRANCH
value: bugfix/cmake-windows-build
- name: BSV_GIT_REVISION
value: 94827a14b2ca3001a71837d302ff56c9d04b32d5

jobs:
- job: Linux
pool: {vmImage: 'ubuntu-latest'}
variables:
BSV_BUILD_PATH: '$(Build.BinariesDirectory)/bitcoin-sv-centos7'
BSV_RESULTS_PATH: '$(Build.BinariesDirectory)/bitcoin-sv-centos7-results'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: 3.7
- task: Cache@2
displayName: Cache build results
inputs:
key: $(BSV_GIT_REVISION) | "$(Agent.OSArchitecture)" | "$(Agent.OS)"
path: '$(BSV_RESULTS_PATH)'
- bash: |
export "CIBW_BUILD=cp37-manylinux_x86_64 cp38-manylinux_x86_64"
export CIBW_BUILD_VERBOSITY=1
Expand All @@ -40,7 +54,13 @@ jobs:
pool: {vmImage: 'macos-10.15'}
variables:
BSV_BUILD_PATH: '$(Build.BinariesDirectory)/bitcoin-sv-macos'
BSV_RESULTS_PATH: '$(Build.BinariesDirectory)/bitcoin-sv-macos-results'
steps:
- task: Cache@2
displayName: Cache build results
inputs:
key: $(BSV_GIT_REVISION) | "$(Agent.OSArchitecture)" | "$(Agent.OS)"
path: '$(BSV_RESULTS_PATH)'
- script: |
export "CIBW_BUILD=cp37-macosx_x86_64 cp38-macosx_x86_64"
export CIBW_BUILD_VERBOSITY=1
Expand All @@ -56,6 +76,7 @@ jobs:
pool: {vmImage: 'windows-latest'}
variables:
BSV_BUILD_PATH: '$(Build.BinariesDirectory)\bitcoin-sv-windows'
BSV_RESULTS_PATH: '$(Build.BinariesDirectory)\bitcoin-sv-windows-results'
vcpkgVersion: 2020.06.15
vcpkgInstallParamFile: '$(Build.SourcesDirectory)/.azure-pipelines/vcpkg/x64-windows-static.txt'
vcpkgBinariesPath: 'C:\Users\VssAdministrator\AppData\Local\vcpkg\archives'
Expand All @@ -68,6 +89,11 @@ jobs:
inputs:
key: $(vcpkgInstallParamFile) | "$(vcpkgVersion)" | "$(Agent.OS)"
path: '$(vcpkgBinariesPath)'
- task: Cache@2
displayName: Cache build results
inputs:
key: $(BSV_GIT_REVISION) | "$(Agent.OSArchitecture)" | "$(Agent.OS)"
path: '$(BSV_RESULTS_PATH)'
- script: |
set "CIBW_BUILD=cp37-win_amd64 cp38-win_amd64"
set CIBW_BUILD_VERBOSITY=1
Expand Down
4 changes: 3 additions & 1 deletion contrib/build/linux-build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash

# $1 - path to checkout and build Bitcoin SV in.
# $2 - git clone URI.
# $3 - git clone branch name.

# ---

Expand Down Expand Up @@ -59,7 +61,7 @@ echo "/opt/boost_1_70/lib" > /etc/ld.so.conf.d/boost_1_70.conf
ldconfig
cd ../../

git clone --branch v1.0.4 --depth=1 https://github.com/bitcoin-sv/bitcoin-sv.git $1
git clone --branch $3 --depth=1 $2 $1
pushd $1
ACLOCAL_PATH=/usr/share/aclocal ./autogen.sh
./configure --disable-wallet --disable-tests --disable-bench --with-boost=/opt/boost_1_70
Expand Down
4 changes: 3 additions & 1 deletion contrib/build/macos-build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash

# $1 - path to checkout and build Bitcoin SV in.
# $2 - git clone URI.
# $3 - git clone branch name.

brew install automake berkeley-db libtool boost openssl pkg-config libevent
git clone --branch bugfix/cmake-windows-build --depth=1 https://github.com/electrumsv/bitcoin-sv $1
git clone --branch $3 --depth=1 $2 $1
export MACOSX_DEPLOYMENT_TARGET=10.15
pushd $1
./autogen.sh
Expand Down
6 changes: 3 additions & 3 deletions contrib/build/windows-build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ REM Unless echo is disabled for the vswhere loop, it prints every command.
echo off

REM %1 - path to checkout and build Bitcoin SV in.
REM %2 - git clone URI.
REM %3 - git clone branch name.

set VSINSTALL_PATH=
set VSWHERE_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe
Expand All @@ -18,10 +20,8 @@ call "%VSINSTALL_PATH%\VC\Auxiliary\Build\vcvars64.bat"

echo on
set VCPKG_ROOT=%VCPKG_INSTALLATION_ROOT%
set BITCOIN_SV_REVISION=bugfix/cmake-windows-build
set BITCOIN_SV_REPO=https://github.com/electrumsv/bitcoin-sv

git clone --depth=1 --branch %BITCOIN_SV_REVISION% %BITCOIN_SV_REPO% %1
git clone --depth=1 --branch %3 %2 %1

pushd %1
mkdir build
Expand Down
115 changes: 81 additions & 34 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,53 +29,98 @@
version = line.strip().split('= ')[1].strip("'")
break

bitcoin_version = '1.0.4'
target_names = ("bitcoind", "bitcoin-seeder", "bitcoin-cli", "bitcoin-tx", "bitcoin-miner")

BSV_BUILD_PATH = os.environ.get("BSV_BUILD_PATH", "bitcoin-sv")
BSV_BUILD_ARTIFACTS_PATH = os.environ.get("BSV_BUILD_ARTIFACTS_PATH", "bitcoin-sv-results")
BSV_GIT_URI = os.environ.get("BSV_GIT_URI", "https://github.com/electrumsv/bitcoin-sv")
BSV_GIT_BRANCH = os.environ.get("BSV_GIT_BRANCH", "bugfix/cmake-windows-build")

def _resolve_bsv_build_path() -> str:
build_path = os.environ.get("BSV_BUILD_PATH")
if build_path is None:
build_path = "bitcoin-sv"
return build_path
PACKAGE_BIN_PATH = os.path.join("electrumsv_node", "bin")

BSV_BUILD_PATH = _resolve_bsv_build_path()

def _copy_build_artifacts_to_package() -> None:
shutil.rmtree(PACKAGE_BIN_PATH)
os.mkdir(PACKAGE_BIN_PATH)

if sys.platform == 'darwin':
if not os.path.exists(BSV_BUILD_PATH):
subprocess.run(f"contrib/build/macos-build.sh {BSV_BUILD_PATH}", shell=True)
for target_name in os.listdir(BSV_BUILD_ARTIFACTS_PATH):
target_path = os.path.join(BSV_BUILD_ARTIFACTS_PATH, target_name)
if os.path.islink(target_path):
continue
if os.path.isfile(target_path):
shutil.copy(target_path, PACKAGE_BIN_PATH)
elif os.path.isdir(target_path):
shutil.copytree(target_path, os.path.join(PACKAGE_BIN_PATH, target_name))

# Bundle the executables that were just built with the node.
package_bin_path = os.path.join("electrumsv_node", "bin")
for target_name in target_names:
artifact_path = os.path.join(BSV_BUILD_PATH, "src", target_name)
shutil.copy(artifact_path, package_bin_path)

elif sys.platform == 'win32':
if not os.path.exists(BSV_BUILD_PATH):
subprocess.run(f"contrib\\build\\windows-build.bat {BSV_BUILD_PATH}", shell=True)
if sys.platform == 'darwin':
if not os.path.exists(BSV_BUILD_ARTIFACTS_PATH):
subprocess.run(
f"contrib/build/macos-build.sh {BSV_BUILD_PATH} {BSV_GIT_URI} {BSV_GIT_BRANCH}",
shell=True)
if not os.path.exists(BSV_BUILD_PATH):
sys.exit("Failed to locate the Bitcoin SV build directory")

ARTIFACT_PATHS = (
os.path.join("src", "bitcoind"),
os.path.join("src", "bitcoin-seeder"),
os.path.join("src", "bitcoin-cli"),
os.path.join("src", "bitcoin-tx"),
os.path.join("src", "bitcoin-miner"),
)

os.mkdir(BSV_BUILD_ARTIFACTS_PATH)
for artifact_path in ARTIFACT_PATHS:
shutil.copy(os.path.join(BSV_BUILD_PATH, artifact_path), BSV_BUILD_ARTIFACTS_PATH)

_copy_build_artifacts_to_package()

# Bundle the executables that were just built with the node.
package_bin_path = os.path.join("electrumsv_node", "bin")
binaries_path = os.path.join(BSV_BUILD_PATH, "build", "src", "Release", "*.exe")
for binary_path in glob.glob(binaries_path):
shutil.copy(binary_path, package_bin_path)
elif sys.platform == 'win32':
if not os.path.exists(BSV_BUILD_ARTIFACTS_PATH):
subprocess.run(
f"contrib\\build\\windows-build.bat {BSV_BUILD_PATH} {BSV_GIT_URI} {BSV_GIT_BRANCH}",
shell=True)
if not os.path.exists(BSV_BUILD_PATH):
sys.exit("Failed to locate the Bitcoin SV build directory")

BUILD_SUBPATH = os.path.join(BSV_BUILD_PATH, "build", "src", "Release")
ARTIFACT_PATHS = (
os.path.join(BUILD_SUBPATH, "bitcoind.exe"),
os.path.join(BUILD_SUBPATH, "bitcoin-cli.exe"),
os.path.join(BUILD_SUBPATH, "bitcoin-tx.exe"),
os.path.join(BUILD_SUBPATH, "bitcoin-miner.exe"),
)

os.mkdir(BSV_BUILD_ARTIFACTS_PATH)
for artifact_path in ARTIFACT_PATHS:
shutil.copy(os.path.join(BSV_BUILD_PATH, artifact_path), BSV_BUILD_ARTIFACTS_PATH)

_copy_build_artifacts_to_package()

elif sys.platform == 'linux':
# Manylinux compilation is on Centos 6, and requires manual building of boost.
# We would really want to have a pre-configured docker image with it present to make it
# rather than faking it as we do locally.

if not os.path.exists(BSV_BUILD_PATH):
subprocess.run(f"contrib/build/linux-build.sh {BSV_BUILD_PATH}", shell=True)
if not os.path.exists(BSV_BUILD_PATH):
sys.exit("Failed to locate the Bitcoin SV build directory")
if not os.path.exists(BSV_BUILD_ARTIFACTS_PATH):
subprocess.run(
f"contrib/build/linux-build.sh {BSV_BUILD_PATH} {BSV_GIT_URI} {BSV_GIT_BRANCH}",
shell=True)
if not os.path.exists(BSV_BUILD_PATH):
sys.exit("Failed to locate the Bitcoin SV build directory")

ARTIFACT_PATHS = (
os.path.join("src", "bitcoind"),
os.path.join("src", "bitcoin-seeder"),
os.path.join("src", "bitcoin-cli"),
os.path.join("src", "bitcoin-tx"),
os.path.join("src", "bitcoin-miner"),
)

os.mkdir(BSV_BUILD_ARTIFACTS_PATH)
for artifact_path in ARTIFACT_PATHS:
shutil.copy(os.path.join(BSV_BUILD_PATH, artifact_path), BSV_BUILD_ARTIFACTS_PATH)

for target_name in target_names:
artifact_path = os.path.join(BSV_BUILD_PATH, "src", target_name)
subprocess.run(f"strip {artifact_path}", shell=True)
shutil.copy(artifact_path, "electrumsv_node/bin/")
_copy_build_artifacts_to_package()


class BinaryDistribution(Distribution):
Expand Down Expand Up @@ -117,9 +162,11 @@ def finalize_options(self):
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: MIT License',
'License :: Open BSV',
'Natural Language :: English',
'Operating System :: OS Independent',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows :: Windows 10',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: Implementation :: CPython',
Expand Down

0 comments on commit 7aeb47a

Please sign in to comment.