Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows build #710

Open
wants to merge 5 commits into
base: capnp
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 101 additions & 111 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,143 +1,133 @@
cmake_minimum_required(VERSION 3.5) # ubuntu 16 version
CMAKE_MINIMUM_REQUIRED(VERSION 3.5) # ubuntu 16 version
SET(CMAKE_CXX_STANDARD 17)

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

option(ENABLE_TESTS "enable building of tests" OFF)
set(WITH_LIBBTC "../libbtc" CACHE STRING "path to libbtc built sources")
OPTION(ENABLE_TESTS "enable building of tests" OFF)
SET(THIRD_PARTY_PATH ".." CACHE STRING "path 3rd party libs")

if(WIN32)
set(VCPKG_DEPS protobuf libwebsockets lmdb mpir)
else()
set(VCPKG_DEPS protobuf)
endif()

if (ENABLE_TESTS)
list(APPEND VCPKG_DEPS gtest)
endif ()

include(Set-Toolchain-vcpkg)
#### detect build env ####
PROJECT(BitcoinArmory C CXX)
IF (CMAKE_SYSTEM_NAME STREQUAL "MSYS")
SET(MINGW 1)
ENDIF ()

IF (WIN32 OR MSVC)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib)
ELSEIF (UNIX)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a .so)
set(CMAKE_FIND_LIBRARY_PREFIXES lib)
set(CMAKE_LIBRARY_HINTS /lib/x86_64-linux-gnu /usr/lib)
#### absolute 3rd party path ####
IF (NOT IS_ABSOLUTE ${THIRD_PARTY_PATH})
GET_FILENAME_COMPONENT (THIRD_PARTY_PATH ${THIRD_PARTY_PATH} REALPATH)
ENDIF ()
MESSAGE (" * third party libs path: ${THIRD_PARTY_PATH} * ")

#### find libraries ####
IF (MINGW)
SET(CMAKE_FIND_LIBRARY_PREFIXES "")
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so .dll)
SET(CMAKE_LIBRARY_HINTS /usr/lib /usr/include)
ELSE ()
SET(CMAKE_FIND_LIBRARY_PREFIXES "lib")
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so)
SET(CMAKE_LIBRARY_HINTS "")
ENDIF ()

find_library(LMDB_LIB lmdb HINTS ${CMAKE_LIBRARY_HINTS})
## lmdb ##
FIND_LIBRARY (LMDB_LIB liblmdb HINTS ${THIRD_PARTY_PATH}/lmdb/libraries/liblmdb)
IF (NOT LMDB_LIB)
MESSAGE(FATAL_ERROR "Could not find LMDB lib")
ENDIF ()
SET(LMDB_INCLUDE_DIRS ${THIRD_PARTY_PATH}/lmdb/libraries/liblmdb)

if(IS_ABSOLUTE ${WITH_LIBBTC})
# do nothing
else()
set(WITH_LIBBTC ${CMAKE_SOURCE_DIR}/${WITH_LIBBTC})
endif()
## libbtc ##
IF (IS_ABSOLUTE ${THIRD_PARTY_PATH})
SET(LIBBTC_PATH ${THIRD_PARTY_PATH}/libbtc)
ELSE ()
SET(LIBBTC_PATH ${CMAKE_SOURCE_DIR}/${THIRD_PARTY_PATH}/libbtc)
ENDIF ()

MESSAGE("WITH_LIBBTC: ${WITH_LIBBTC}")
find_library(LIBBTC_LIB libbtc btc HINTS ${WITH_LIBBTC}/.libs ${WITH_LIBBTC}/lib ${WITH_LIBBTC}/build
${WITH_LIBBTC}/build/Debug ${WITH_LIBBTC}/build/Release
FIND_LIBRARY (LIBBTC_LIB libbtc HINTS
${LIBBTC_PATH}/.libs
${LIBBTC_PATH}/lib
${LIBBTC_PATH}/build
)
IF (NOT LIBBTC_LIB)
MESSAGE(FATAL_ERROR "Could not find libbtc")
ENDIF ()
set(LIBBTC_INCLUDE_DIR ${WITH_LIBBTC}/include)
set(SECP256k1_INCLUDE_DIR ${WITH_LIBBTC}/src/secp256k1/include)
SET(LIBBTC_INCLUDE_DIR ${LIBBTC_PATH})

## lws ##
IF (IS_ABSOLUTE ${WITH_LWS})
# do nothing
ELSE ()
SET(WITH_LWS ${CMAKE_SOURCE_DIR}/${WITH_LWS})
ENDIF ()

if (ENABLE_TESTS)
find_library(GTEST_LIB gtest HINTS ${CMAKE_LIBRARY_HINTS})
IF (NOT GTEST_LIB)
MESSAGE(FATAL_ERROR "Could not find gtest lib")
ENDIF ()
endif (ENABLE_TESTS)
## libwebsockets ##
IF (IS_ABSOLUTE ${THIRD_PARTY_PATH})
SET(LWS_PATH ${THIRD_PARTY_PATH}/libwebsockets)
ELSE ()
SET(LWS_PATH ${CMAKE_SOURCE_DIR}/${THIRD_PARTY_PATH}/libwebsockets)
ENDIF ()

FIND_LIBRARY (LIBWEBSOCKETS_LIB libwebsockets_static HINTS
${LWS_PATH}/build/lib)
IF (NOT LIBWEBSOCKETS_LIB)
MESSAGE(FATAL_ERROR "Could not find WS lib")
ENDIF ()
SET(LIBWEBSOCKETS_INCLUDE_DIRS ${LWS_PATH}/build/include)

project(BitcoinArmory C CXX)
## capnproto ##
IF (IS_ABSOLUTE ${THIRD_PARTY_PATH})
SET(CAPNP_PATH ${THIRD_PARTY_PATH}/capnproto)
ELSE ()
SET(CAPNP_PATH ${CMAKE_SOURCE_DIR}/${THIRD_PARTY_PATH}/capnproto)
ENDIF ()

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Release with debug info version" FORCE)
endif()
SET(CAPNP_SUFFIX c++/src)
SET(CAPNP_INCLUDE_DIRS ${CAPNP_PATH}/${CAPNP_SUFFIX})

if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
FIND_LIBRARY (CAPNPROTO_LIB libcapnp HINTS ${CAPNP_PATH}/build/${CAPNP_SUFFIX}/capnp)
IF (NOT CAPNPROTO_LIB)
MESSAGE (FATAL_ERROR "Failed to find capnp lib")
ENDIF ()

include(ArmorySupport)
include(GCCToolchain)
include(LLVMToolchain)
include(LTO)
include(CompilerColorDiagnostics)
include(CompilerWarnings)
## capnp compiler ##
SET(CAPNP_EXECUTABLE ${CAPNP_PATH}/build/${CAPNP_SUFFIX}/capnp/capnp.exe)
IF (NOT EXISTS ${CAPNP_EXECUTABLE})
MESSAGE (FATAL_ERROR "Could not find capnp binary at: ${CAPNP_EXECUTABLE}")
ENDIF ()

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
## kj (capnproto dependency) ##
FIND_LIBRARY (KJ_LIB libkj HINTS ${CAPNP_PATH}/build/${CAPNP_SUFFIX}/kj)
IF (NOT KJ_LIB)
MESSAGE (FATAL_ERROR "Failed ot find kj lib")
ENDIF ()

# use ccache if available, and not already enabled on the command line
# but not with ninja and msys ccache on msys2
if(NOT (WIN32 AND (NOT $ENV{MSYSTEM} STREQUAL "") AND CMAKE_GENERATOR STREQUAL Ninja))
if(NOT CMAKE_CXX_COMPILER_LAUNCHER AND NOT CMAKE_C_COMPILER_LAUNCHER)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)
endif()
endif()
## gtest ##
IF (ENABLE_TESTS)
FIND_LIBRARY(GTEST_LIB libgtest_main.dll HINTS ${CMAKE_LIBRARY_HINTS})
IF (NOT GTEST_LIB)
MESSAGE(FATAL_ERROR "Could not find gtest lib")
ENDIF ()
MESSAGE ("gtest lib: ${GTEST_LIB}")
ENDIF (ENABLE_TESTS)

# build for host CPU if desired (default yes)
option(WITH_HOST_CPU_FEATURES "support the CPU features of the build host, gcc only" ON)
## winsock ##
FIND_LIBRARY (WINSOCK_LIB ws2_32)
IF (NOT WINSOCK_LIB)
MESSAGE (FATAL_ERROR "Could not find system lib: ws2_32.dll")
ENDIF ()

if(WITH_HOST_CPU_FEATURES AND CMAKE_CXX_COMPILER_ID STREQUAL GNU)
check_x86_cpu_features()
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Release with debug info version" FORCE)
ENDIF ()

add_compile_options(-march=native ${X86_CPU_FEATURES_COMPILER_FLAGS})
endif()
include(GCCToolchain)
include(CompilerColorDiagnostics)
include(CompilerWarnings)

if(MSVC)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
IF (MSVC OR MINGW)
add_definitions(-DNOMINMAX -D_WINSOCKAPI_)
endif()

# support brew and macports
if(APPLE)
if(EXISTS /usr/local/include AND EXISTS /usr/local/lib)
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
elseif(EXISTS /opt/local/include AND EXISTS /opt/local/lib)
include_directories(/opt/local/include)
link_directories(/opt/local/lib)
endif()
endif()

# we are bundling libwebsockets for the time being, at least until ubuntu
# updates their version

# this is the right way to set options for sub-projects
# we allow these to be overridden by the user
if(NOT DEFINED LWS_SSL_CLIENT_USE_OS_CA_CERTS)
set(LWS_SSL_CLIENT_USE_OS_CA_CERTS OFF CACHE BOOL "disable using OS CA certs for libwebsockets" FORCE)
endif()

if(NOT DEFINED LWS_WITH_SHARED)
set(LWS_WITH_SHARED OFF CACHE BOOL "disable building libwebsockets as shared library" FORCE)
endif()

if(NOT DEFINED LWS_WITH_SSL)
set(LWS_WITH_SSL OFF CACHE BOOL "disable SSL support in libwebsockets" FORCE)
endif()

if(NOT WIN32)
find_library(LIBWEBSOCKETS_LIB websockets HINTS ${CMAKE_LIBRARY_HINTS})
IF (NOT LIBWEBSOCKETS_LIB)
MESSAGE(FATAL_ERROR "Could not find WS lib")
ENDIF ()

# add_subdirectory(libwebsockets EXCLUDE_FROM_ALL)
# set(LIBWEBSOCKETS_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libwebsockets/include ${CMAKE_BINARY_DIR}/libwebsockets/include CACHE PATH "libwebsockets include dirs" FORCE)
endif()

FIND_PATH(GMP_INCLUDE_DIR gmp.h)
ENDIF ()

# this is the main project
add_subdirectory(cppForSwig)
21 changes: 9 additions & 12 deletions armoryengine/ArmoryUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Distributed under the GNU Affero General Public License (AGPL v3) #
# See LICENSE or http://www.gnu.org/licenses/agpl.html #
# #
# Copyright (C) 2016-2023, goatpig #
# Copyright (C) 2016-2024, goatpig #
# Distributed under the MIT license #
# See LICENSE-MIT or https://opensource.org/licenses/MIT #
# #
Expand Down Expand Up @@ -42,6 +42,8 @@
import subprocess
import binascii

from pathlib import Path

try:
if os.path.exists('update_version.py') and os.path.exists('.git'):
subprocess.check_output(["python", "update_version.py"])
Expand Down Expand Up @@ -125,8 +127,10 @@
parser.add_option("--ram-usage", dest="ram_usage", default=-1, type="int", help="Set maximum ram during scans, as 128MB increments. Defaults to 4")
parser.add_option("--thread-count", dest="thread_count", default=-1, type="int", help="Set max thread count during builds and scans. Defaults to CPU total thread count")
parser.add_option("--db-type", dest="db_type", default="DB_FULL", type="str", help="Set db mode, defaults to DB_FULL")
parser.add_option("--language", dest="language", default="en", type="str", help="""Set the language for the client to display in. Use the ISO 639-1 language code to choose a language.
Options are da, de, en, es, el, fr, he, hr, id, ru, sv. Default is en. """)
parser.add_option("--language", dest="language", default="en", type="str", help=
"""Set the language for the client to display in. Use the ISO 639-1 language code to choose a language.
Options are da, de, en, es, el, fr, he, hr, id, ru, sv. Default is en.
""")

parser.set_defaults(enableDetSign=True)

Expand Down Expand Up @@ -161,7 +165,7 @@
MIN_RELAY_TX_FEE = 20000
MIN_FEE_BYTE = 200
MT_WAIT_TIMEOUT_SEC = 20
DEFAULT_FEE_TYPE = "Auto"
DEFAULT_FEE_TYPE = "Auto"
DEFAULT_CHANGE_TYPE = 'P2PKH'
DEFAULT_RECEIVE_TYPE = 'P2PKH'

Expand Down Expand Up @@ -302,7 +306,7 @@ class SignerException(Exception): pass
# Figure out the default directories for Satoshi client, and BicoinArmory
OS_NAME = ''
OS_VARIANT = ''
USER_HOME_DIR = ''
USER_HOME_DIR = str(Path.home())
BTC_HOME_DIR = ''
ARMORY_HOME_DIR = ''
ARMORY_DB_DIR = ''
Expand All @@ -318,11 +322,6 @@ class SignerException(Exception): pass
OS_NAME = 'Windows'
OS_VARIANT = platform.win32_ver()

import ctypes
buffer = ctypes.create_unicode_buffer(u'\0' * 260)
rt = ctypes.windll.shell32.SHGetFolderPathW(0, 26, 0, 0, ctypes.byref(buffer))
USER_HOME_DIR = unicode(buffer.value)

if BTC_HOME_DIR == '':
BTC_HOME_DIR = os.path.join(USER_HOME_DIR, 'Bitcoin')
if SUBDIR != '':
Expand All @@ -335,7 +334,6 @@ class SignerException(Exception): pass
import distro
OS_NAME = 'Linux'
OS_VARIANT = distro.linux_distribution()
USER_HOME_DIR = os.getenv('HOME')

if BTC_HOME_DIR == '':
BTC_HOME_DIR = os.path.join(USER_HOME_DIR, '.bitcoin')
Expand All @@ -349,7 +347,6 @@ class SignerException(Exception): pass
platform.mac_ver()
OS_NAME = 'MacOSX'
OS_VARIANT = platform.mac_ver()
USER_HOME_DIR = os.path.expanduser('~/Library/Application Support')

if BTC_HOME_DIR == '':
BTC_HOME_DIR = os.path.join(USER_HOME_DIR, 'Bitcoin')
Expand Down
Empty file added c20p1305_cffi/__init__.py
Empty file.
Loading