This repository was archived by the owner on Oct 12, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathpackage.sh
More file actions
executable file
·133 lines (111 loc) · 3.69 KB
/
Copy pathpackage.sh
File metadata and controls
executable file
·133 lines (111 loc) · 3.69 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash -e
MY_NAME="$(basename $0)"
MY_DIR="$(cd $(dirname $0);pwd)"
source common.sh
PACKAGE_TREE_DIR="${ARTIFACTS_DIR}/package"
PACKAGE_ARTIFACTS_DIR="${PACKAGE_TREE_DIR}/artifacts"
LLVM_VERSION=""
function make_windows_wrapper_scripts()
{
local input="${1}"
local output_dir="${2}"
local output_base_name="${3}"
local output_path
local output_name
for TRIPLE in ${ANDROID_TRIPLES}; do
output_name="${TRIPLE}-${output_base_name}"
output_path="${output_dir}/${output_name}.cmd"
sed -e "s/@TARGET_NAME@/${output_name}/g" < "${input}" > "${output_path}"
done
}
function make_unix_wrapper_scripts()
{
local input="${1}"
local output_dir="${2}"
local output_base_name="${3}"
local output_path
local output_name
for TRIPLE in ${ANDROID_TRIPLES}; do
output_name="${TRIPLE}-${output_base_name}"
output_path="${output_dir}/${output_name}"
cp -a -P "${input}" "${output_path}"
done
}
function prepare()
{
local os="${1}"
local artifacts_source="${ARTIFACTS_DIR}/${os}/"
local artifacts_source_bin="${artifacts_source}/bin"
local artifacts_source_lib="${artifacts_source}lib"
local artifacts_dest_bin="${PACKAGE_ARTIFACTS_DIR}/${os}/bin"
local artifacts_dest_lib="${PACKAGE_ARTIFACTS_DIR}/${os}/lib"
local version_file
echo
echo Preparing binaries for ${os}
echo
create_empty_dir "${artifacts_dest_bin}"
create_empty_dir "${artifacts_dest_lib}"
local exe
local cmd
if [ "${os}" == "windows" ]; then
exe=".exe"
cmd=".cmd"
cp -P -a "${artifacts_source_bin}/llvm-objcopy.pdb" "${artifacts_dest_bin}/llvm-objcopy.pdb"
cp -P -a "${artifacts_source_bin}/lld.pdb" "${artifacts_dest_bin}/lld.pdb"
make_windows_wrapper_scripts "scripts/llvm-objcopy.cmd.in" "${artifacts_source_bin}" "objcopy"
make_windows_wrapper_scripts "scripts/llvm-strip.cmd.in" "${artifacts_source_bin}" "strip"
make_windows_wrapper_scripts "scripts/gas.cmd.in" "${artifacts_source_bin}" "as"
make_windows_wrapper_scripts "scripts/ld.cmd.in" "${artifacts_source_bin}" "ld"
else
make_unix_wrapper_scripts "scripts/llvm-objcopy.sh" "${artifacts_source_bin}" "objcopy"
make_unix_wrapper_scripts "scripts/llvm-strip.sh" "${artifacts_source_bin}" "strip"
make_unix_wrapper_scripts "scripts/gas.sh" "${artifacts_source_bin}" "as"
make_unix_wrapper_scripts "scripts/ld.sh" "${artifacts_source_bin}" "ld"
fi
if [ -z "${LLVM_VERSION}" ]; then
version_file="${artifacts_source}/llvm-version.txt"
LLVM_VERSION=$(head -1 "${version_file}" | tr -d ' \n\t')
cp "${version_file}" "${PACKAGE_ARTIFACTS_DIR}"
fi
local dest_b=
local src_pdb=
local dest_pdb=
for b in ${BINARIES}; do
src_pdb=""
dest_pdb=""
if [ "${b}" == "lld" ]; then
dest_b="ld"
else
dest_b="${b}"
fi
if [ -f "${artifacts_source_bin}/${b}${exe}" ]; then
src_pdb="${b}.pdb"
dest_pdb="${dest_b}.pdb"
b="${b}${exe}"
dest_b="${dest_b}${exe}"
elif [ -f "${artifacts_source_bin}/${b}${cmd}" ]; then
b="${b}${cmd}"
dest_b="${dest_b}${cmd}"
fi
if [ -f "${artifacts_source_bin}/${b}.upx" ]; then
cp -P -a "${artifacts_source_bin}/${b}.upx" "${artifacts_dest_bin}/${dest_b}"
else
cp -P -a "${artifacts_source_bin}/${b}" "${artifacts_dest_bin}/${dest_b}"
fi
chmod 755 "${artifacts_dest_bin}/${dest_b}"
if [ -n "${src_pdb}" -a -f "${artifacts_source_bin}/${src_pdb}" ]; then
cp -P -a "${artifacts_source_bin}/${src_pdb}" "${artifacts_dest_bin}/${dest_pdb}"
fi
done
if [ -d "${artifacts_source_lib}" ]; then
cp -P -a "${artifacts_source_lib}"/* "${artifacts_dest_lib}"
chmod 644 "${artifacts_dest_lib}"/*.*
fi
}
for os in ${OPERATING_SYSTEMS}; do
prepare ${os}
done
if [ -z "${LLVM_VERSION}" ]; then
die Unable to detect LLVM version from the artifacts
fi
echo Creating package for LLVM version ${LLVM_VERSION}