-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripts to download, build and upload dependencies
- Loading branch information
1 parent
14fc09d
commit eb87e26
Showing
5 changed files
with
180 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ vcpkg | |
vcpkg_cache | ||
vcpkg_exported | ||
dist | ||
deps-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
set(ROOT ${CMAKE_CURRENT_LIST_DIR}) | ||
|
||
set(URL https://gh-bin.fra1.digitaloceanspaces.com/brisk-deps/{TRIPLET}-{DEP_HASH}.7z) | ||
|
||
if (DEFINED ENV{VCPKG_TARGET_TRIPLET}) | ||
set(VCPKG_TARGET_TRIPLET $ENV{VCPKG_TARGET_TRIPLET}) | ||
else () | ||
if (DEFINED ENV{VCPKG_DEFAULT_TRIPLET}) | ||
set(VCPKG_TARGET_TRIPLET $ENV{VCPKG_DEFAULT_TRIPLET}) | ||
else () | ||
message(FATAL_ERROR "Set VCPKG_TARGET_TRIPLET or VCPKG_DEFAULT_TRIPLET environment variable") | ||
endif () | ||
endif () | ||
|
||
include(${ROOT}/dep-hash.cmake) | ||
|
||
# Define the URL and destination file for download | ||
string(REPLACE "{DEP_HASH}" "${DEP_HASH}" URL "${URL}") | ||
string(REPLACE "{TRIPLET}" "${VCPKG_TARGET_TRIPLET}" URL "${URL}") | ||
set(DEST_FILE ${ROOT}/deps-${VCPKG_TARGET_TRIPLET}-${DEP_HASH}.7z) | ||
|
||
if (NOT EXISTS ${DEST_FILE}) | ||
|
||
message(STATUS "Downloading ${URL}") | ||
# Download the file | ||
file( | ||
DOWNLOAD ${URL} ${DEST_FILE} | ||
SHOW_PROGRESS | ||
STATUS DOWNLOAD_STATUS) | ||
list(GET DOWNLOAD_STATUS 0 DOWNLOAD_STATUS_CODE) | ||
if (NOT DOWNLOAD_STATUS_CODE EQUAL 0) | ||
if (DEFINED DEP_BUILD AND NOT DEP_BUILD) | ||
message(FATAL_ERROR "Download failed (Status ${DOWNLOAD_STATUS_CODE}), exit") | ||
endif () | ||
message(WARNING "Download failed, dependencies will be built using vcpkg (Status ${DOWNLOAD_STATUS_CODE})") | ||
|
||
execute_process( | ||
COMMAND vcpkg install --x-install-root ${ROOT}/vcpkg_installed --x-feature=icu ${EXTRA_VCPKG_ARGS} | ||
WORKING_DIRECTORY ${ROOT} | ||
RESULT_VARIABLE RESULT) | ||
if (NOT RESULT EQUAL 0) | ||
message(FATAL_ERROR "vcpkg install failed with exit code ${RESULT}") | ||
endif () | ||
endif () | ||
|
||
file(REMOVE_RECURSE ${ROOT}/vcpkg_exported) | ||
|
||
else () | ||
|
||
message(STATUS "File ${DEST_FILE} already exists. Remove it to force re-download") | ||
|
||
endif () | ||
|
||
if (NOT EXISTS ${ROOT}/vcpkg_exported) | ||
|
||
message(STATUS "Extracting archive") | ||
|
||
# Create the vcpkg_exported directory | ||
file(MAKE_DIRECTORY ${ROOT}/vcpkg_exported) | ||
|
||
# Extract the archive | ||
execute_process( | ||
COMMAND ${CMAKE_COMMAND} -E tar xf ${DEST_FILE} | ||
WORKING_DIRECTORY ${ROOT}/vcpkg_exported | ||
RESULT_VARIABLE RESULT) | ||
if (NOT RESULT EQUAL 0) | ||
message(FATAL_ERROR "cmake -E tar failed with exit code ${RESULT}") | ||
endif () | ||
|
||
# Move all contents of extracted folder to the root of vcpkg_exported | ||
file(GLOB EXTRACTED_CONTENTS "${ROOT}/vcpkg_exported/*/*") | ||
foreach (FILE IN LISTS EXTRACTED_CONTENTS) | ||
get_filename_component(ONLY_NAME ${FILE} NAME) | ||
file(RENAME ${FILE} ${ROOT}/vcpkg_exported/${ONLY_NAME}) | ||
endforeach () | ||
|
||
file(GLOB VCPKG_INSTALLED_CONTENTS ${ROOT}/vcpkg_installed/*) | ||
if (NOT VCPKG_INSTALLED_CONTENTS STREQUAL "") | ||
message( | ||
FATAL_ERROR | ||
"${ROOT}/vcpkg_installed is not empty. Remove it and run the script again to install dependencies") | ||
endif () | ||
|
||
file(REMOVE_RECURSE ${ROOT}/vcpkg_installed) | ||
|
||
file(RENAME ${ROOT}/vcpkg_exported/installed ${ROOT}/vcpkg_installed) | ||
|
||
else () | ||
|
||
message(STATUS "Directory ${ROOT}/vcpkg_exported already exists. Remove it to force extraction from the archive") | ||
|
||
endif () | ||
|
||
message(STATUS "All operations finished") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
set(ROOT ${CMAKE_CURRENT_LIST_DIR}) | ||
|
||
if (WIN32) | ||
set(TEMP_DIR $ENV{TEMP}) | ||
else () | ||
set(TEMP_DIR $ENV{TMPDIR}) | ||
endif () | ||
|
||
if (NOT DEFINED ENV{AWS_SECRET_ACCESS_KEY}) | ||
message(FATAL_ERROR "AWS_SECRET_ACCESS_KEY is not set. This script is for internal use only") | ||
endif () | ||
|
||
if (DEFINED ENV{VCPKG_TARGET_TRIPLET}) | ||
set(VCPKG_TARGET_TRIPLET $ENV{VCPKG_TARGET_TRIPLET}) | ||
else () | ||
if (DEFINED ENV{VCPKG_DEFAULT_TRIPLET}) | ||
set(VCPKG_TARGET_TRIPLET $ENV{VCPKG_DEFAULT_TRIPLET}) | ||
else () | ||
message(FATAL_ERROR "Set VCPKG_TARGET_TRIPLET or VCPKG_DEFAULT_TRIPLET environment variable") | ||
endif () | ||
endif () | ||
|
||
include(${ROOT}/dep-hash.cmake) | ||
|
||
# Check if the archive exists on S3 | ||
execute_process(COMMAND aws s3 ls s3://gh-bin/brisk-deps/${VCPKG_TARGET_TRIPLET}-${DEP_HASH}.7z RESULT_VARIABLE RESULT) | ||
|
||
if (RESULT EQUAL 0) # aws s3 ls was successfull, file exists | ||
message("Archive does exist on S3, skipping build") | ||
else () | ||
message("Archive does not exist on S3, trying to build") | ||
|
||
# Install vcpkg dependencies with icu feature | ||
execute_process( | ||
COMMAND vcpkg install --x-feature=icu | ||
WORKING_DIRECTORY ${ROOT} COMMAND_ECHO STDOUT | ||
RESULT_VARIABLE RESULT) | ||
if (NOT RESULT EQUAL 0) | ||
message(FATAL_ERROR "vcpkg install failed with exit code ${RESULT}") | ||
endif () | ||
|
||
# Export the package to a .7z archive | ||
execute_process(COMMAND vcpkg export --7zip --output-dir=${TEMP_DIR} --output=${VCPKG_TARGET_TRIPLET}-${DEP_HASH} | ||
COMMAND_ECHO STDOUT RESULT_VARIABLE RESULT) | ||
if (NOT RESULT EQUAL 0) | ||
message(FATAL_ERROR "vcpkg export failed with exit code ${RESULT}") | ||
endif () | ||
|
||
# Upload the archive to S3 | ||
execute_process(COMMAND aws s3 cp --acl public-read ${TEMP_DIR}/${VCPKG_TARGET_TRIPLET}-${DEP_HASH}.7z | ||
s3://gh-bin/brisk-deps/ COMMAND_ECHO STDOUT RESULT_VARIABLE RESULT) | ||
if (NOT RESULT EQUAL 0) | ||
message(FATAL_ERROR "aws s3 cp failed with exit code ${RESULT}") | ||
endif () | ||
endif () |