Skip to content

Commit 182b9c8

Browse files
committed
Bring back install_deps script on Windows
1 parent 9c0b870 commit 182b9c8

File tree

4 files changed

+106
-7
lines changed

4 files changed

+106
-7
lines changed

cmake/EthDependencies.cmake

+1-6
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,7 @@ if (MSVC)
3939
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.0)
4040
message(FATAL_ERROR "ERROR - As of the 1.3.0 release, cpp-ethereum only supports Visual Studio 2015 or newer.\nPlease download from https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx.")
4141
else()
42-
get_filename_component(DEPS_DIR "${CMAKE_CURRENT_LIST_DIR}/../deps/install" ABSOLUTE)
43-
set(ETH_DEPENDENCY_INSTALL_DIR
44-
"${DEPS_DIR}/x64" # Old location for deps.
45-
"${DEPS_DIR}/win64" # New location for deps.
46-
"${DEPS_DIR}/win64/Release/share" # LLVM shared cmake files.
47-
)
42+
get_filename_component(ETH_DEPENDENCY_INSTALL_DIR "${CMAKE_CURRENT_LIST_DIR}/../deps/x64" ABSOLUTE)
4843
endif()
4944
set (CMAKE_PREFIX_PATH ${ETH_DEPENDENCY_INSTALL_DIR} ${CMAKE_PREFIX_PATH})
5045
endif()

cmake/scripts/helpers.cmake

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
get_filename_component(ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE)
2+
3+
set(CACHE_DIR "${ROOT_DIR}/deps/src")
4+
set(PACKAGES_DIR "${ROOT_DIR}/packages")
5+
6+
function(download URL DST_FILE STATUS)
7+
set(TMP_FILE "${DST_FILE}.part")
8+
9+
get_filename_component(FILE_NAME ${DST_FILE} NAME)
10+
if (NOT EXISTS ${DST_FILE})
11+
message("Downloading ${FILE_NAME}")
12+
file(DOWNLOAD ${URL} ${TMP_FILE} SHOW_PROGRESS STATUS DOWNLOAD_STATUS)
13+
list(GET DOWNLOAD_STATUS 0 STATUS_CODE)
14+
if (STATUS_CODE EQUAL 0)
15+
file(RENAME ${TMP_FILE} ${DST_FILE})
16+
else()
17+
file(REMOVE ${TMP_FILE})
18+
list(GET DOWNLOAD_STATUS 1 ERROR_MSG)
19+
20+
message("ERROR! Downloading '${FILE_NAME}' failed.")
21+
message(STATUS "URL: ${URL}")
22+
message(STATUS "Error: ${STATUS_CODE} ${ERROR_MSG}")
23+
set(STATUS FALSE PARENT_SCOPE)
24+
return()
25+
endif()
26+
else()
27+
message("Using cached ${FILE_NAME}")
28+
endif()
29+
set(STATUS TRUE PARENT_SCOPE)
30+
endfunction(download)
31+
32+
function(download_and_unpack PACKAGE_URL DST_DIR)
33+
get_filename_component(FILE_NAME ${PACKAGE_URL} NAME)
34+
35+
set(DST_FILE "${CACHE_DIR}/${FILE_NAME}")
36+
set(TMP_FILE "${DST_FILE}.part")
37+
38+
file(MAKE_DIRECTORY ${CACHE_DIR})
39+
file(MAKE_DIRECTORY ${DST_DIR})
40+
41+
download(${PACKAGE_URL} ${DST_FILE} STATUS)
42+
43+
if (STATUS)
44+
message("Unpacking ${FILE_NAME} to ${DST_DIR}")
45+
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xf ${DST_FILE}
46+
WORKING_DIRECTORY ${DST_DIR})
47+
endif()
48+
endfunction(download_and_unpack)
49+
50+
# Packs installed package binaries and headers into an archive.
51+
function(create_package NAME DIR)
52+
message("Creating package ${NAME}")
53+
file(MAKE_DIRECTORY ${PACKAGES_DIR})
54+
55+
# To create an archive without addicional top level directory
56+
# (like package-X.Y.Z) we need to know all top level files/dirs.
57+
# Usually it is just "win64" dir.
58+
file(GLOB TOP_FILES RELATIVE ${DIR} "${DIR}/*")
59+
60+
set(PACKAGE_FILE "${PACKAGES_DIR}/${NAME}.tar.gz")
61+
execute_process(COMMAND ${CMAKE_COMMAND} -E
62+
tar -czf ${PACKAGE_FILE} ${TOP_FILES}
63+
WORKING_DIRECTORY ${DIR})
64+
endfunction(create_package)
65+
66+
# Downloads the source code of the package and unpacks it to dedicated 'src'
67+
# dir. Also creates 'build' and 'install' dir to be used by a build script.
68+
function(prepare_package_source NAME VERSION URL)
69+
set(PACKAGE_NAME "${NAME}-${VERSION}")
70+
71+
set(PACKAGE_DIR "${CACHE_DIR}/${PACKAGE_NAME}")
72+
set(SOURCE_DIR "${PACKAGE_DIR}/src")
73+
set(BUILD_DIR "${PACKAGE_DIR}/build")
74+
set(INSTALL_DIR "${PACKAGE_DIR}/install")
75+
76+
if (NOT EXISTS ${SOURCE_DIR})
77+
download_and_unpack(${URL} ${PACKAGE_DIR} STATUS)
78+
file(GLOB ORIG_SOURCE_DIR_NAME "${PACKAGE_DIR}/*")
79+
file(RENAME ${ORIG_SOURCE_DIR_NAME} ${SOURCE_DIR})
80+
endif()
81+
82+
file(MAKE_DIRECTORY ${BUILD_DIR})
83+
file(MAKE_DIRECTORY ${INSTALL_DIR})
84+
85+
# Export names and dirs to be used by a package-specific build script.
86+
set(PACKAGE_NAME ${PACKAGE_NAME} PARENT_SCOPE)
87+
set(SOURCE_DIR ${SOURCE_DIR} PARENT_SCOPE)
88+
set(BUILD_DIR ${BUILD_DIR} PARENT_SCOPE)
89+
set(INSTALL_DIR ${INSTALL_DIR} PARENT_SCOPE)
90+
endfunction()

cmake/scripts/install_deps.cmake

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
include("${CMAKE_CURRENT_LIST_DIR}/helpers.cmake")
2+
3+
set(INSTALL_DIR "${ROOT_DIR}/deps")
4+
set(SERVER "https://github.com/ethereum/cpp-dependencies/releases/download/vc140/")
5+
6+
function(download_and_install PACKAGE_NAME)
7+
download_and_unpack("${SERVER}${PACKAGE_NAME}.tar.gz" ${INSTALL_DIR})
8+
endfunction(download_and_install)
9+
10+
11+
download_and_install("curl-7.4.2")
12+
download_and_install("leveldb-1.2")
13+
download_and_install("microhttpd-0.9.2")
14+
download_and_install("miniupnpc-1.9")

scripts/install_deps.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ REM
5656
REM Copyright (c) 2016 cpp-ethereum contributors.
5757
REM ---------------------------------------------------------------------------
5858

59-
cmake -P deps\install_deps.cmake
59+
cmake -P cmake\scripts\install_deps.cmake

0 commit comments

Comments
 (0)