diff --git a/README.md b/README.md index 599237ce..3a7e427d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/scripts/devtool-clang.sh b/scripts/devtool-clang.sh new file mode 100755 index 00000000..08f9214f --- /dev/null +++ b/scripts/devtool-clang.sh @@ -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