Skip to content

Commit d3dc844

Browse files
authored
[Feature:System] Build x86_64 and aarch64 exes on release (#10)
1 parent 67fd8c9 commit d3dc844

3 files changed

Lines changed: 108 additions & 10 deletions

File tree

.github/workflows/build_binary.yml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,47 @@ name: Build binaries on release
33
on:
44
push:
55
tags:
6-
- "*"
6+
- '*'
7+
78
jobs:
89
build:
910
name: build
1011
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
arch: [x86_64, aarch64]
1115
defaults:
1216
run:
1317
shell: bash
1418
steps:
1519
- uses: actions/checkout@v2
16-
- name: Change permission
17-
run: chmod +x install_analysistoolsts.sh
20+
- name: Install dependencies (aarch64)
21+
if: matrix.arch == 'aarch64'
22+
run: sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
23+
- name: Set CC / CXX (aarch64)
24+
if: matrix.arch == 'aarch64'
25+
run: |
26+
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
27+
echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
1828
- name: Build executable
19-
run: sudo ./install_analysistoolsts.sh local
29+
run: bash build.sh
30+
- name: Duplicate executables (x86_64)
31+
if: matrix.arch == 'x86_64'
32+
run: |
33+
cp build/submitty_count_ts build/submitty_count_ts-x86_64
34+
cp build/submitty_diagnostics_ts build/submitty_diagnostics_ts-x86_64
35+
- name: Move executables (aarch64)
36+
if: matrix.arch == 'aarch64'
37+
run: |
38+
mv build/submitty_count_ts build/submitty_count_ts-aarch64
39+
mv build/submitty_diagnostics_ts build/submitty_diagnostics_ts-aarch64
40+
- name: Upload artifacts
41+
uses: actions/upload-artifact@v3
42+
with:
43+
name: executables
44+
path: build/submitty_*
2045
- name: Release
2146
uses: softprops/action-gh-release@v1
2247
if: startsWith(github.ref, 'refs/tags/')
2348
with:
24-
files: |
25-
build/submitty_count_ts
26-
build/submitty_diagnostics_ts
49+
files: build/submitty_*

.github/workflows/test.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ jobs:
1010
os: [ubuntu-latest, macos-latest]
1111
steps:
1212
- uses: actions/checkout@v2
13-
- name: Change permission
14-
run: chmod +x install_analysistoolsts.sh
1513
- name: Build executable
16-
run: sudo ./install_analysistoolsts.sh local
14+
run: bash ./build.sh
1715
- name: run tests
1816
run: python3 testRunner.py

build.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
echo "Building AnalysisToolsTS... "
6+
7+
CUR_DIR=$(dirname "${0}")
8+
BUILD_DIR=${CUR_DIR}/build
9+
INCLUDE_DIR=${CUR_DIR}/include
10+
11+
mkdir -p "${BUILD_DIR}"
12+
mkdir -p "${INCLUDE_DIR}"
13+
14+
########################################################################
15+
16+
# Clone the tree-sitter repos
17+
repos=( tree-sitter tree-sitter-python tree-sitter-c tree-sitter-cpp tree-sitter-java)
18+
19+
for repo in "${repos[@]}"
20+
do
21+
dir="${INCLUDE_DIR}/${repo}"
22+
23+
echo "clone or update ${repo}... "
24+
25+
if [ -d "${dir}" ]; then
26+
echo "pulling changes ..."
27+
# IF THE REPO ALREADY EXISTS...
28+
pushd "${dir}"
29+
30+
CURRENT_BRANCH=$(git branch --show-current)
31+
32+
# PULL CHANGES
33+
git fetch
34+
git reset --hard HEAD
35+
git merge "origin/${CURRENT_BRANCH}"
36+
37+
popd
38+
else
39+
# THE REPO DID NOT EXIST
40+
echo "the repository did not previously exist cloning... "
41+
git clone --depth 1 "https://github.com/tree-sitter/${repo}" "${INCLUDE_DIR}/${repo}"
42+
fi
43+
done
44+
45+
# CHECKOUT & INSTALL THE NLOHMANN C++ JSON LIBRARY
46+
echo "clone or update nlohmann"
47+
if [ -d "${INCLUDE_DIR}/json" ]; then
48+
echo "pulling changes ..."
49+
pushd "${INCLUDE_DIR}/json"
50+
51+
CURRENT_BRANCH=$(git branch --show-current)
52+
git fetch
53+
git reset --hard HEAD
54+
git merge "origin/${CURRENT_BRANCH}"
55+
popd
56+
else
57+
git clone --depth 1 "https://github.com/nlohmann/json.git" "${INCLUDE_DIR}/json"
58+
fi
59+
60+
61+
########################################################################
62+
63+
# build tree sitter library
64+
pushd "${INCLUDE_DIR}/tree-sitter"
65+
make
66+
popd
67+
68+
echo "building submitty_count_ts ..."
69+
70+
# Compile the project
71+
cmake -S "${CUR_DIR}" -B "${BUILD_DIR}" -DJSONDIR="${INCLUDE_DIR}/json/include"
72+
73+
pushd "${BUILD_DIR}"
74+
make
75+
popd
76+
77+
echo "Done building AnalysisToolsTS"

0 commit comments

Comments
 (0)