forked from ni/grpc-labview
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (135 loc) · 5.04 KB
/
build_on_rt.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
name: RT Build
on:
workflow_call:
workflow_dispatch:
env:
CMAKE_VERSION: 3.18.3
BUILD_TYPE: Release
jobs:
build-nilrt:
name: NILRT Cross Compile with GCC 6.3.0
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup python3
uses: actions/setup-python@v5
with:
python-version: '3.x'
# The URL used to download this toolchain may change in the future as
# improvements to hosting and exports of the NILRT toolchain are made.
- name: Install NI Linux RT CC Toolchain
run: |
wget -nv https://download.ni.com/support/softlib/labview/labview_rt/2018/Linux%20Toolchains/linux/oecore-x86_64-core2-64-toolchain-6.0.sh
sudo chmod a+x ./oecore-x86_64-core2-64-toolchain-6.0.sh
sudo ./oecore-x86_64-core2-64-toolchain-6.0.sh -y -d ${GITHUB_WORKSPACE}/nilrt-toolchain/
echo "${GITHUB_WORKSPACE}/nilrt-toolchain/sysroots/x86_64-nilrtsdk-linux/usr/bin/x86_64-nilrt-linux" >> ${GITHUB_PATH}
- name: Update Submodules
id: submodules
run: |
git submodule update --init --recursive
echo "::set-output name=grpc-commit::$(git rev-parse --short @:./third_party/grpc)"
- name: Cache Host OS gRPC Support
uses: actions/cache@v4
id: hostgrpccache
env:
cache-name: hostgrpccache
with:
path: third_party/grpc/build/
key: ${{ github.repository }}-${{ runner.os }}-${{ env.cache-name }}-${{ steps.submodules.outputs.grpc-commit }}
- name: Configure Host OS gRPC Support
if: steps.hostgrpccache.outputs.cache-hit != 'true'
shell: cmake -P {0}
run: |
set(path_separator ":")
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}")
execute_process(
COMMAND cmake
-S $ENV{GITHUB_WORKSPACE}/third_party/grpc/
-B $ENV{GITHUB_WORKSPACE}/third_party/grpc/build
-D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
-D gRPC_INSTALL=ON
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: Build Host OS gRPC Support
if: steps.hostgrpccache.outputs.cache-hit != 'true'
shell: cmake -P {0}
run: |
execute_process(
COMMAND cmake --build $ENV{GITHUB_WORKSPACE}/third_party/grpc/build
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE output
ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE
)
if (NOT result EQUAL 0)
string(REGEX MATCH "FAILED:.*$" error_message "${output}")
string(REPLACE "\n" "%0A" error_message "${error_message}")
message("::error::${error_message}")
message(FATAL_ERROR "Build failed")
endif()
- name: Install Host OS gRPC Support
run: sudo cmake --install ${GITHUB_WORKSPACE}/third_party/grpc/build
- name: Configure Cross Compile
shell: cmake -P {0}
run: |
set(path_separator ":")
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}")
execute_process(
COMMAND cmake
-S .
-B build
-D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
-D CMAKE_TOOLCHAIN_FILE=$ENV{GITHUB_WORKSPACE}/nilrt-x86_64.cmake
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: Cross Compile
shell: cmake -P {0}
run: |
execute_process(
COMMAND cmake --build build --config $ENV{BUILD_TYPE} -j 16
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE output
ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE
)
if (NOT result EQUAL 0)
string(REGEX MATCH "FAILED:.*$" error_message "${output}")
string(REPLACE "\n" "%0A" error_message "${error_message}")
message("::error::${error_message}")
message(FATAL_ERROR "Build failed")
endif()
- if: ${{always() }}
name: Print CMakeTests logs
run: |
folder="${{runner.workspace}}/grpc-labview/tests/CMakeTests/logs/"
# Check if the folder exists
if [ ! -d "$folder" ]; then
echo "CMakeTests log folder (grpc-labview/tests/CmakeTests/logs) does not exist."
echo "Exiting the script."
exit
fi
# Change to the folder
cd "$folder" || exit
# Iterate through files and print their contents
for file in *; do
if [ -f "$file" ]; then
cat "$file"
echo
fi
done
- name: Tar Build Artifacts
run: >-
tar -czvf liblabview-grpc-server-rt.tar.gz -C ${GITHUB_WORKSPACE}/build liblabview_grpc_server.so
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: liblabview-grpc-server-rt
path: liblabview-grpc-server-rt.tar.gz
retention-days: 5