Skip to content

Commit

Permalink
devtool-clang.sh: Add script for setting devtool workflow
Browse files Browse the repository at this point in the history
Document the process in README

Signed-off-by: Khem Raj <[email protected]>
  • Loading branch information
kraj committed May 26, 2024
1 parent 4e63e15 commit 253e056
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,29 @@ URI: ghttps://github.com/openembedded/bitbake.git
branch: master
revision: HEAD
```
# Using Devtool and Upstream Development

All LLVM based recipes use single llvm source directory, As a LLVM
developer, you might want to work on your own repository to build
related recipes, devtool can we useful in establishing such a workflow
there is a script provided `scripts/devtool-clang.sh` which can assist
in setting up all the recipes to use custom LLVM repository, in order
to setup repository make sure that it has all the needed patches applied
or else it will fail to build. Such a tree is already prepared and kept
in sync at

https://github.com/kraj/llvm-project

There are branches under `oe` namespace which carry the needed OE patches

```
cd $TOPDIR/workspace/sources
git clone https://github.com/kraj/llvm-project -b oe/main llvm-project
```

Once project is setup and meta-clang is added, run `devtool-clang.sh`
script which will do the needed for setting up external sources for the
yocto recipes, now yocto will use custom LLVM tree for its needs.

# Contributing

Expand Down
41 changes: 41 additions & 0 deletions scripts/devtool-clang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env sh
# Clone the repository first if not already done locally
# git clone https://github.com/kraj/llvm-project -b oe/main /mnt/b/yoe/master/workspace/sources/llvm-project
#
# if local repository exists then make a clone/copy
# git clone /home/kraj/work/llvm-project /mnt/b/yoe/master/workspace/sources/llvm-project
#
layerloc="$(dirname "$0")/../conf/layer.conf"
workspace="$(dirname "$0")/../../../workspace"

origver=$(grep "LLVMVERSION =" < "$layerloc" | awk '{print $3}' | tr -d '"')

major=$(grep -e "set(LLVM_VERSION_MAJOR [0-9]" < "$workspace"/sources/llvm-project/cmake/Modules/LLVMVersion.cmake| cut -d ' ' -f 4 | sed "s/)//")
minor=$(grep -e "set(LLVM_VERSION_MINOR [0-9]" < "$workspace"/sources/llvm-project/cmake/Modules/LLVMVersion.cmake| cut -d ' ' -f 4 | sed "s/)//")
patch=$(grep -e "set(LLVM_VERSION_PATCH [0-9]" < "$workspace"/sources/llvm-project/cmake/Modules/LLVMVersion.cmake| cut -d ' ' -f 4 | sed "s/)//")

recipes="\
llvm-project-source-$origver \
clang \
clang-cross-riscv64 \
clang-crosssdk-x86_64 \
clang-cross-canadian-riscv64 \
nativesdk-clang-glue \
compiler-rt \
compiler-rt-sanitizers \
libclc \
libcxx \
openmp \
"

for recipe in $recipes; do
devtool modify -n "$recipe" "$workspace/sources/llvm-project"
sed -i "/pn-$recipe /p;s/pn-$recipe /pn-nativesdk-$recipe /g" "$workspace"/appends/"$recipe"*.bbappend
sed -i "/pn-$recipe /p;s/pn-$recipe /pn-$recipe-native /g" "$workspace"/appends/"$recipe"*.bbappend
done

for f in "$workspace"/appends/*.bbappend; do
{ echo "MAJOR_VER = \"$major\"" ; echo "MINOR_VER = \"$minor\"" ; echo "PATCH_VER = \"$patch\"" ; } >> "$f"
done

sed -i -e "s/$origver/$major.$minor.$patch/g" "$workspace"/appends/llvm-project-source.bbappend

0 comments on commit 253e056

Please sign in to comment.