-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (166 loc) · 6.15 KB
/
platform-tools-solana.yml
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Solana Platform tools
on:
push:
tags:
- "platform-tools-solana*"
# todo remove
pull_request:
branches:
- main
permissions:
contents: write
env:
LLVM_VERSION: 16
jobs:
release:
name: release
strategy:
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-20.04
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-20.04
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
runs-on: ${{ matrix.os }}
outputs:
version: ${{ steps.extract_version.outputs.version }}
steps:
- name: Extract version from tag
id: extract_version
run: |
echo "version=$(echo ${GITHUB_REF#refs/tags/platform-tools-solana-})" >> $GITHUB_OUTPUT
- name: Install dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
set -euxo pipefail
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
echo -e deb http://apt.llvm.org/focal/ llvm-toolchain-focal-${{ env.LLVM_VERSION }} main | sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt update
sudo apt -y install \
clang-${{ env.LLVM_VERSION }} \
cmake \
lld-${{ env.LLVM_VERSION }} \
ninja-build
echo /usr/lib/llvm-${{ env.LLVM_VERSION }}/bin >> $GITHUB_PATH
- name: Install dependencies
if: startsWith(matrix.os, 'macos')
run: |
brew install cmake ninja
- name: Install musl
if: matrix.target == 'aarch64-unknown-linux-musl'
run: |
sudo sed -i 's/^deb /deb [arch=amd64] /g' /etc/apt/sources.list
sudo tee -a /etc/apt/sources.list << EOF
deb [arch=arm64] http://ports.ubuntu.com/ jammy main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ jammy-security main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ jammy-updates main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ jammy-backports main restricted universe multiverse
EOF
sudo dpkg --add-architecture arm64
sudo apt update
sudo apt -y musl-dev:arm64
- name: Install musl
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: |
sudo apt -y musl-dev
- name: Checkout code
uses: actions/checkout@v2
with:
path: binaries
- name: Checkout Rust code
uses: actions/checkout@v2
with:
path: rust
repository: solana-labs/rust
ref: solana-tools-${{ steps.extract_version.outputs.version }}
- name: Build Rust
run: |
cd rust
cp ../binaries/platform-tools-solana/config.toml .
./x.py build --stage 1 --target ${{ matrix.target }},sbf-solana-solana
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
- name: Checkout Cargo code
uses: actions/checkout@v2
with:
path: cargo
repository: solana-labs/caego
ref: solana-tools-${{ steps.extract_version.outputs.version }}
- name: Build Cargo
env:
OPENSSL_STATIC: 1
run: |
cd cargo
cargo build --release
- name: Copy Rust build products
run: |
set -euxo pipefail
mkdir -p deploy/rust
cp version.md deploy/
cp -R "rust/build/${HOST_TRIPLE}/stage1/bin" deploy/rust/
cp -R "cargo/target/release/cargo${EXE_SUFFIX}" deploy/rust/bin/
mkdir -p deploy/rust/lib/rustlib/
cp -R "rust/build/${HOST_TRIPLE}/stage1/lib/rustlib/${HOST_TRIPLE}" deploy/rust/lib/rustlib/
cp -R "rust/build/${HOST_TRIPLE}/stage1/lib/rustlib/sbf-solana-solana" deploy/rust/lib/rustlib/
find . -maxdepth 6 -type f -path "./rust/build/${HOST_TRIPLE}/stage1/lib/*" -exec cp {} deploy/rust/lib \;
mkdir -p deploy/rust/lib/rustlib/src/rust
cp "rust/build/${HOST_TRIPLE}/stage1/lib/rustlib/src/rust/Cargo.lock" deploy/rust/lib/rustlib/src/rust
cp -R "rust/build/${HOST_TRIPLE}/stage1/lib/rustlib/src/rust/library" deploy/rust/lib/rustlib/src/rust
- name: Copy LLVM build products
run: |
set -euxo pipefail
mkdir -p deploy/llvm/{bin,lib}
while IFS= read -r f
do
bin_file="rust/build/${HOST_TRIPLE}/llvm/build/bin/${f}${EXE_SUFFIX}"
if [[ -f "$bin_file" ]] ; then
cp -R "$bin_file" deploy/llvm/bin/
fi
done < <(cat <<EOF
clang
clang++
clang-cl
clang-cpp
clang-16
ld.lld
ld64.lld
llc
lld
lld-link
lldb
lldb-vscode
llvm-ar
llvm-objcopy
llvm-objdump
llvm-readelf
llvm-readobj
EOF
)
cp -R "rust/build/${HOST_TRIPLE}/llvm/build/lib/clang" deploy/llvm/lib/
if [[ "${HOST_TRIPLE}" != "x86_64-pc-windows-msvc" ]] ; then
cp -R newlib_install/sbf-solana/lib/lib{c,m}.a deploy/llvm/lib/
cp -R newlib_install/sbf-solana/include deploy/llvm/
cp -R rust/src/llvm-project/lldb/scripts/solana/* deploy/llvm/bin/
cp -R rust/build/${HOST_TRIPLE}/llvm/lib/liblldb.* deploy/llvm/lib/
cp -R rust/build/${HOST_TRIPLE}/llvm/lib/python* deploy/llvm/lib/
fi
- name: Archive artifacts
run: |
tar -C deploy -jcf solana-platform-tools-${{ matrix.target }}.tar.bz2 .
rm -rf deploy
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
solana-platform-tools-${{ matrix.target }}.tar.bz2