Skip to content

Commit

Permalink
Merge pull request #1 from radxa-repo/ubuild
Browse files Browse the repository at this point in the history
Rework lbuild & ubuild into a single tool
  • Loading branch information
RadxaYuntian authored Jul 22, 2022
2 parents db5d17c + 04e6629 commit 9c64b42
Show file tree
Hide file tree
Showing 174 changed files with 2,903 additions and 410 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@ jobs:
query:
runs-on: ubuntu-latest
outputs:
forks: ${{ steps.query.outputs.forks }}
linux: ${{ steps.query.outputs.linux }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Query available board configs
id: query
run: |
echo "::set-output name=forks::$(./lbuild --json forks)"
echo "::set-output name=linux::$(./bsp --json 'edition linux')"
build:
needs: query
runs-on: ubuntu-latest
strategy:
matrix:
forks: ${{fromJSON(needs.query.outputs.forks)}}
linux: ${{fromJSON(needs.query.outputs.linux)}}
steps:
- name: Build
uses: radxa-repo/lbuild@main
uses: radxa-repo/bsp@main
with:
fork: ${{ matrix.forks }}
target: linux
edition: ${{ matrix.linux }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
.src/
.root/
.vscode/
forks/**/0500-private/
**/0500-private/
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
# lbuild - Radxa Linux Kernel Build Tool
# bsp - Radxa BSP Build Tool

[![Build](https://github.com/radxa-repo/lbuild/actions/workflows/build.yml/badge.svg)](https://github.com/radxa-repo/lbuild/actions/workflows/build.yml)
[![Build](https://github.com/radxa-repo/bsp/actions/workflows/build.yml/badge.svg)](https://github.com/radxa-repo/bsp/actions/workflows/build.yml)

`lbuild` aims to provide a standardized way to build Linux kernel for Radxa boards, so the resulting file can be easliy included in our image generation pipeline.
`bsp` aims to provide a standardized way to build Linux kernel and U-Boot for Radxa boards, so the build output can be easliy included in our image generation pipeline.

## Usage

### Local
### Local

Please run the following command to check all available options:

```
git clone --depth 1 https://github.com/radxa-repo/lbuild.git
lbuild/lbuild
git clone --depth 1 https://github.com/radxa-repo/bsp.git
cd ./bsp
./bsp
```

You can then build the bootloader with supported options. The resulting deb package will be stored in your current directory.
You can then build the BSP components with supported options. The resulting deb package will be stored in your current directory.

### Running in GitHub Action

Please check out our [GitHub workflows](https://github.com/radxa-repo/lbuild/tree/main/.github/workflows).
Please check out our [GitHub workflows](https://github.com/radxa-repo/bsp/tree/main/.github/workflows).

## Documentation
Please visit [Radxa Documentation](https://radxa-doc.github.io/).

Please visit [Radxa Documentation](https://radxa-doc.github.io/).

12 changes: 7 additions & 5 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: lbuild
description: Radxa Linux Kernel Build Tool
name: bsp
description: Radxa BSP Build Tool
inputs:
fork:
target:
required: true
edition:
required: true
revision:
retuired: false
Expand All @@ -16,7 +18,7 @@ runs:
- name: Checkout
uses: actions/checkout@v3
with:
repository: radxa-repo/lbuild
repository: radxa-repo/bsp
- name: Install dependency
shell: bash
run: |
Expand All @@ -27,7 +29,7 @@ runs:
run: |
mkdir .output
pushd .output
../lbuild -r ${{ inputs.revision }} ${{ inputs.fork }}
../bsp -r ${{ inputs.revision }} ${{ inputs.target }} ${{ inputs.edition }}
popd
- name: Upload
if: inputs.release-id != '' && inputs.github-token != ''
Expand Down
157 changes: 157 additions & 0 deletions bsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#!/bin/bash

SCRIPT_DIR="$(dirname "$(realpath "$0")")"
source "$SCRIPT_DIR/lib/utils.sh"

usage() {
cat >&2 << EOF
Radxa BSP Build Tool
usage: $(basename "$0") [options] <linux|u-boot> <edition> [product]
When building u-boot, you can also provide 'product' argument,
which will only build for that specific image.
Supported package generation options:
-r, --revision [num]
Specify custom revision number, default=1
--no-prepare-source Allow building against locally modified repos
Alternative functionalities
--json [catagory] Print supported options in json format
Available catagories: $(get_supported_infos)
-h, --help Show this help message
Supported Linux edition:
$(printf_array " %s\n" "$(get_supported_edition linux)")
Supported U-Boot edition:
$(printf_array " %s\n" "$(get_supported_edition u-boot)")
EOF
}

get_supported_edition() {
if [[ ! -d "$SCRIPT_DIR/$1" ]] || [[ -z "$1" ]]
then
error $EXIT_UNSUPPORTED_OPTION "$1"
fi

local editions=()
for f in $(ls $SCRIPT_DIR/$1)
do
editions+="$f "
done
echo "${editions[@]}"
}

get_supported_infos() {
local infos=("edition linux" "edition u-boot")
echo "${infos[@]}"
}

json() {
local array=( "$(get_supported_infos)" )
if ! in_array "$@" "${array[@]}"
then
error $EXIT_UNKNOWN_OPTION "$1"
fi

local output
output=( $(get_supported_$@) )
if (( $? != 0 ))
then
return 1
fi
printf_array "json" "${output[@]}"
}

build() {
prepare_source "$TARGET"

bsp_prepare

bsp_make $BSP_DEFCONFIG 2>&1 | tee -a "$SCRIPT_DIR/.src/build.log"

for d in $(find -L "$SCRIPT_DIR/$TARGET/$FORK" -mindepth 1 -type d | sort)
do
apply_kconfig "$d/kconfig.conf"
done
apply_kconfig "$SCRIPT_DIR/$TARGET/$FORK/kconfig.conf"

bsp_make olddefconfig $BSP_MAKE_TARGETS 2>&1 | tee -a "$SCRIPT_DIR/.src/build.log"
}

main() {
local PKG_REVISION="1"
local NO_PREPARE_SOURCE=

if [[ -e "$SCRIPT_DIR/.src/build.log" ]]
then
rm "$SCRIPT_DIR/.src/build.log"
fi

while (( $# > 0 ))
do
case "$1" in
-r | --revision)
PKG_REVISION="$2"
shift 2
;;
--no-prepare-source)
NO_PREPARE_SOURCE="yes"
shift
;;
--json)
shift
json "$@"
return
;;
-h | --help)
usage
return
;;
-*)
error $EXIT_UNKNOWN_OPTION "$1"
;;
linux)
load_edition "$1" "$2"
build
bsp_makedeb
return
;;
u-boot)
load_edition "$1" "$2"

if [[ -n "$3" ]]
then
if ! in_array "$3" "${SUPPORTED_BOARDS[@]}"
then
error $EXIT_UNKNOWN_OPTION "$1"
fi
local products=("$3")
else
local products=("${SUPPORTED_BOARDS[@]}")
fi

rm -rf "$SCRIPT_DIR/.root"

for BOARD in "${products[@]}"
do
load_edition "$1" "$2"
bsp_$BOARD
build
bsp_preparedeb
NO_PREPARE_SOURCE="yes"
done

SUPPORTED_BOARDS=("${products[@]}")
bsp_makedeb
return
;;
*) break ;;
esac
done
usage
return 1
}

main "$@"
Loading

0 comments on commit 9c64b42

Please sign in to comment.