25 use_openwrt_container:
34 name: Setup build ${{ inputs.target }}
35 runs-on: ubuntu-latest
37 owner_lc: ${{ steps.lower_owner.outputs.owner_lc }}
38 ccache_hash: ${{ steps.ccache_hash.outputs.ccache_hash }}
39 container_tag: ${{ steps.determine_tools_container.outputs.container_tag }}
43 uses: actions/checkout@v3
45 - name: Set lower case owner name
48 OWNER_LC=$(echo "${{ github.repository_owner }}" \
49 | tr '[:upper:]' '[:lower:]')
51 if [ ${{ inputs.use_openwrt_container }} == "true" ]; then
55 echo "owner_lc=$OWNER_LC" >> $GITHUB_OUTPUT
57 - name: Generate ccache hash
60 CCACHE_HASH=$(md5sum include/kernel-* | awk '{ print $1 }' \
61 | md5sum | awk '{ print $1 }')
62 echo "ccache_hash=$CCACHE_HASH" >> $GITHUB_OUTPUT
64 # Per branch tools container tag
65 # By default stick to latest
66 # For official test targetting openwrt stable branch
67 # Get the branch or parse the tag and push dedicated tools containers
68 # For local test to use the correct container for stable release testing
69 # you need to use for the branch name a prefix of openwrt-[0-9][0-9].[0-9][0-9]-
70 - name: Determine tools container tag
71 id: determine_tools_container
74 if [ -n "${{ github.base_ref }}" ]; then
75 if echo "${{ github.base_ref }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
76 CONTAINER_TAG="${{ github.base_ref }}"
78 elif [ ${{ github.ref_type }} == "branch" ]; then
79 if echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
80 CONTAINER_TAG=${{ github.ref_name }}
81 elif echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
82 CONTAINER_TAG="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\)-.*/\1/')"
84 elif [ ${{ github.ref_type }} == "tag" ]; then
85 if echo "${{ github.ref_name }}" | grep -q -E '^v[0-9][0-9]\.[0-9][0-9]\..+'; then
86 CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/^v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
89 echo "Tools container to use tools:$CONTAINER_TAG"
90 echo "container_tag=$CONTAINER_TAG" >> $GITHUB_OUTPUT
93 name: Build ${{ inputs.target }}
95 runs-on: ubuntu-latest
97 container: ghcr.io/${{ needs.setup_build.outputs.owner_lc }}/tools:${{ needs.setup_build.outputs.container_tag }}
104 - name: Checkout master directory
105 uses: actions/checkout@v3
109 - name: Checkout packages feed
110 if: inputs.include_feeds == true
111 uses: actions/checkout@v3
113 repository: openwrt/packages
114 path: openwrt/feeds/packages
116 - name: Checkout luci feed
117 if: inputs.include_feeds == true
118 uses: actions/checkout@v3
120 repository: openwrt/luci
121 path: openwrt/feeds/luci
123 - name: Checkout routing feed
124 if: inputs.include_feeds == true
125 uses: actions/checkout@v3
127 repository: openwrt/routing
128 path: openwrt/feeds/routing
130 - name: Checkout telephony feed
131 if: inputs.include_feeds == true
132 uses: actions/checkout@v3
134 repository: openwrt/telephony
135 path: openwrt/feeds/telephony
137 - name: Fix permission
139 chown -R buildbot:buildbot openwrt
141 - name: Initialization environment
143 TARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 1)
144 SUBTARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 2)
145 echo "TARGET=$TARGET" >> "$GITHUB_ENV"
146 echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV"
148 - name: Prepare prebuilt tools
149 shell: su buildbot -c "sh -e {0}"
150 working-directory: openwrt
152 mkdir -p staging_dir build_dir
153 ln -s /prebuilt_tools/staging_dir/host staging_dir/host
154 ln -s /prebuilt_tools/build_dir/host build_dir/host
156 ./scripts/ext-tools.sh --refresh
158 - name: Update & Install feeds
159 if: inputs.include_feeds == true
160 shell: su buildbot -c "sh -e {0}"
161 working-directory: openwrt
163 ./scripts/feeds update -a
164 ./scripts/feeds install -a
166 - name: Parse toolchain file
167 if: inputs.build_toolchain == false
169 working-directory: openwrt
171 TOOLCHAIN_PATH=snapshots
173 if [ -n "${{ github.base_ref }}" ]; then
174 if echo "${{ github.base_ref }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
175 major_ver="$(echo ${{ github.base_ref }} | sed 's/^openwrt-/v/')"
177 elif [ "${{ github.ref_type }}" = "branch" ]; then
178 if echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
179 major_ver="$(echo ${{ github.ref_name }} | sed 's/^openwrt-/v/')"
180 elif echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
181 major_ver="$(echo ${{ github.ref_name }} | sed 's/^openwrt-\([0-9][0-9]\.[0-9][0-9]\)-.*/v\1/')"
183 elif [ "${{ github.ref_type }}" = "tag" ]; then
184 if echo "${{ github.ref_name }}" | grep -q -E '^v[0-9][0-9]\.[0-9][0-9]\..+'; then
185 major_ver="$(echo ${{ github.ref_name }} | sed 's/^\(v[0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
189 if [ -n "$major_ver" ]; then
191 latest_tag="$(git tag --sort=-creatordate -l $major_ver* | head -n1)"
192 if [ -n "$latest_tag" ]; then
193 TOOLCHAIN_PATH=releases/$(echo $latest_tag | sed 's/^v//')
197 SUMS_FILE="https://downloads.cdn.openwrt.org/$TOOLCHAIN_PATH/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/sha256sums"
198 if curl $SUMS_FILE | grep -q ".*openwrt-toolchain.*tar.xz"; then
199 TOOLCHAIN_STRING="$( curl $SUMS_FILE | grep ".*openwrt-toolchain.*tar.xz")"
200 TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p')
202 echo "toolchain-type=external_toolchain" >> $GITHUB_OUTPUT
203 elif curl $SUMS_FILE | grep -q ".*openwrt-sdk.*tar.xz"; then
204 TOOLCHAIN_STRING="$( curl $SUMS_FILE | grep ".*openwrt-sdk.*tar.xz")"
205 TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-sdk.*\).tar.xz/\1/p')
207 echo "toolchain-type=external_sdk" >> $GITHUB_OUTPUT
209 echo "toolchain-type=internal" >> $GITHUB_OUTPUT
212 echo "TOOLCHAIN_FILE=$TOOLCHAIN_FILE" >> "$GITHUB_ENV"
213 echo "TOOLCHAIN_PATH=$TOOLCHAIN_PATH" >> "$GITHUB_ENV"
216 uses: actions/cache@v3
218 path: openwrt/.ccache
219 key: ccache-kernel-${{ env.TARGET }}/${{ env.SUBTARGET }}-${{ needs.setup_build.outputs.ccache_hash }}
221 ccache-kernel-${{ env.TARGET }}/${{ env.SUBTARGET }}-
223 - name: Download external toolchain/sdk
224 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type != 'internal'
225 shell: su buildbot -c "sh -e {0}"
226 working-directory: openwrt
228 wget -O - https://downloads.cdn.openwrt.org/${{ env.TOOLCHAIN_PATH }}/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/${{ env.TOOLCHAIN_FILE }}.tar.xz \
231 - name: Configure testing kernel
232 if: inputs.testing == true
233 shell: su buildbot -c "sh -e {0}"
234 working-directory: openwrt
236 echo CONFIG_TESTING_KERNEL=y >> .config
238 - name: Configure all kernel modules
239 if: inputs.build_all_kmods == true
240 shell: su buildbot -c "sh -e {0}"
241 working-directory: openwrt
243 echo CONFIG_ALL_KMODS=y >> .config
245 - name: Configure all modules
246 if: inputs.build_all_modules == true
247 shell: su buildbot -c "sh -e {0}"
248 working-directory: openwrt
250 echo CONFIG_ALL=y >> .config
252 - name: Configure all boards
253 if: inputs.build_all_boards == true
254 shell: su buildbot -c "sh -e {0}"
255 working-directory: openwrt
257 echo CONFIG_TARGET_MULTI_PROFILE=y >> .config
258 echo CONFIG_TARGET_PER_DEVICE_ROOTFS=y >> .config
259 echo CONFIG_TARGET_ALL_PROFILES=y >> .config
261 - name: Configure external toolchain
262 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_toolchain'
263 shell: su buildbot -c "sh -e {0}"
264 working-directory: openwrt
266 echo CONFIG_DEVEL=y >> .config
267 echo CONFIG_AUTOREMOVE=y >> .config
268 echo CONFIG_CCACHE=y >> .config
270 ./scripts/ext-toolchain.sh \
271 --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \
273 --config ${{ env.TARGET }}/${{ env.SUBTARGET }}
275 - name: Adapt external sdk to external toolchain format
276 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_sdk'
277 shell: su buildbot -c "sh -e {0}"
278 working-directory: openwrt
280 TOOLCHAIN_DIR=${{ env.TOOLCHAIN_FILE }}/staging_dir/$(ls ${{ env.TOOLCHAIN_FILE }}/staging_dir | grep toolchain)
281 TOOLCHAIN_BIN=$TOOLCHAIN_DIR/bin
284 # Find target name from toolchain info.mk
285 GNU_TARGET_NAME=$(cat $TOOLCHAIN_DIR/info.mk | grep TARGET_CROSS | sed 's/^TARGET_CROSS=\(.*\)-$/\1/')
289 # Revert sdk wrapper scripts applied to all the bins
290 for app in $(find . -name "*.bin"); do
291 TARGET_APP=$(echo $app | sed 's/\.\/\.\(.*\)\.bin/\1/')
293 mv .$TARGET_APP.bin $TARGET_APP
296 # Setup the wrapper script in the sdk toolchain dir simulating an external toolchain build
297 cp $OPENWRT_DIR/target/toolchain/files/wrapper.sh $GNU_TARGET_NAME-wrapper.sh
298 for app in cc gcc g++ c++ cpp ld as ; do
299 [ -f $GNU_TARGET_NAME-$app ] && mv $GNU_TARGET_NAME-$app $GNU_TARGET_NAME-$app.bin
300 ln -sf $GNU_TARGET_NAME-wrapper.sh $GNU_TARGET_NAME-$app
303 - name: Configure external toolchain with sdk
304 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_sdk'
305 shell: su buildbot -c "sh -e {0}"
306 working-directory: openwrt
308 echo CONFIG_DEVEL=y >> .config
309 echo CONFIG_AUTOREMOVE=y >> .config
310 echo CONFIG_CCACHE=y >> .config
312 ./scripts/ext-toolchain.sh \
313 --toolchain ${{ env.TOOLCHAIN_FILE }}/staging_dir/toolchain-* \
315 --config ${{ env.TARGET }}/${{ env.SUBTARGET }}
317 - name: Configure internal toolchain
318 if: inputs.build_toolchain == true || steps.parse-toolchain.outputs.toolchain-type == 'internal'
319 shell: su buildbot -c "sh -e {0}"
320 working-directory: openwrt
322 echo CONFIG_DEVEL=y >> .config
323 echo CONFIG_AUTOREMOVE=y >> .config
324 echo CONFIG_CCACHE=y >> .config
326 echo "CONFIG_TARGET_${{ env.TARGET }}=y" >> .config
327 echo "CONFIG_TARGET_${{ env.TARGET }}_${{ env.SUBTARGET }}=y" >> .config
331 - name: Show configuration
332 shell: su buildbot -c "sh -e {0}"
333 working-directory: openwrt
334 run: ./scripts/diffconfig.sh
337 shell: su buildbot -c "sh -e {0}"
338 working-directory: openwrt
339 run: make tools/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
341 - name: Build toolchain
342 shell: su buildbot -c "sh -e {0}"
343 working-directory: openwrt
344 run: make toolchain/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
347 if: inputs.build_kernel == true
348 shell: su buildbot -c "sh -e {0}"
349 working-directory: openwrt
350 run: make target/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
352 - name: Build Kernel Kmods
353 if: inputs.build_kernel == true
354 shell: su buildbot -c "sh -e {0}"
355 working-directory: openwrt
356 run: make package/linux/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
358 - name: Build everything
359 if: inputs.build_full == true
360 shell: su buildbot -c "sh -e {0}"
361 working-directory: openwrt
362 run: make -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
366 uses: actions/upload-artifact@v3
368 name: ${{ env.TARGET }}-${{ env.SUBTARGET }}-logs