-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathupload-deps.cmake
64 lines (54 loc) · 2.35 KB
/
upload-deps.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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}.tar.xz
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 .tar.xz archive
execute_process(COMMAND vcpkg export --raw --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 ()
execute_process(
COMMAND cmake -E tar cJf ${TEMP_DIR}/${VCPKG_TARGET_TRIPLET}-${DEP_HASH}.tar.xz .
WORKING_DIRECTORY ${TEMP_DIR}/${VCPKG_TARGET_TRIPLET}-${DEP_HASH} COMMAND_ECHO STDOUT
RESULT_VARIABLE RESULT)
if (NOT RESULT EQUAL 0)
message(FATAL_ERROR "tar 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}.tar.xz
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 ()