-
Notifications
You must be signed in to change notification settings - Fork 349
[SKIP SOFCI-TEST] topology: build using a local ALSA install #9870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bdfad4e
cfc661d
c0f6e16
6c2f49a
60ba53a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| #!/bin/bash | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
| # Copyright(c) 2025 Intel Corporation. All rights reserved. | ||
|
|
||
| # fail immediately on any errors | ||
| set -e | ||
|
|
||
| # Array of ALSA Git repository URLs. Add or remove repositories as needed. | ||
| declare -a REPOS=( | ||
| "https://github.com/thesofproject/alsa-lib.git" | ||
| "https://github.com/thesofproject/alsa-utils.git" | ||
| # Add more repositories here... | ||
| ) | ||
|
|
||
| # Commit ID to check for (optional). If specified, the script will update | ||
| # the repository if this commit ID is not found. Leave empty to skip. | ||
| # This array order must align with REPO array above. | ||
| declare -a COMMIT_ID=( | ||
| "df8f1cc1ec9d9ee15be5e2c23ad25b9389fd8766" | ||
| "09550cd393b1a7d307ee6f26637b1ed7bd275e38" | ||
| # Add more IDs here... | ||
| ) | ||
|
|
||
| # Directory where repositories will be cloned/updated. | ||
| if [[ -z "$SOF_WORKSPACE" ]]; then | ||
| # Environment variable is empty or unset so use default | ||
| BASE_DIR="$HOME/work/sof" | ||
| else | ||
| # Environment variable exists and has a value | ||
| BASE_DIR="$SOF_WORKSPACE" | ||
| fi | ||
|
|
||
| # Arguments to pass to ./configure for each repository. Add or remove | ||
| declare -a CONFIGURE_ARGS=( | ||
| "--prefix=${BASE_DIR}/tools" | ||
| "--prefix=${BASE_DIR}/tools \ | ||
| --with-alsa-prefix=${BASE_DIR}/tools \ | ||
| --with-alsa-inc-prefix=${BASE_DIR}/tools/include \ | ||
| --with-sysroot=${BASE_DIR}/tools \ | ||
| --with-udev-rules-dir=${BASE_DIR}/tools \ | ||
| PKG_CONFIG_PATH=${BASE_DIR}/tools \ | ||
| LDFLAGS=-L${BASE_DIR}/tools/lib \ | ||
| --with-asound-state-dir=${BASE_DIR}/tools/var/lib/alsa \ | ||
| --with-systemdsystemunitdir=${BASE_DIR}/tools/lib/systemd/system" | ||
| ) | ||
|
|
||
| # Arguments to pass to make for each repository. Add or remove arguments as needed. | ||
| declare -a TARGET_ARGS=( | ||
| "--disable-old-symbols" | ||
| "--enable-alsatopology" | ||
| ) | ||
|
|
||
| # Function to check if a commit ID exists in a repository | ||
| check_commit() { | ||
| local repo_dir="$1" | ||
| local commit_id="$2" | ||
|
|
||
| if [ -z "$commit_id" ]; then | ||
| return 0 # Skip check if no commit ID is provided | ||
| fi | ||
|
|
||
| if ! git -C "$repo_dir" rev-parse --quiet --verify "$commit_id" >/dev/null 2>&1; then | ||
| return 1 # Commit ID not found | ||
| else | ||
| return 0 # Commit ID found | ||
| fi | ||
| } | ||
|
|
||
|
|
||
| # Function to update the repository | ||
| update_repo() { | ||
| local repo_dir="$1" | ||
| echo "Updating repository: $repo_dir" | ||
| git -C "$repo_dir" fetch --all | ||
| git -C "$repo_dir" pull | ||
| } | ||
|
|
||
| # Function to build and install the repository | ||
| build_and_install() { | ||
| local repo_dir="$1" | ||
| local configure_args="$2" | ||
| local target_args="$3" | ||
|
|
||
| echo "Building and installing: $repo_dir $configure_args $target_args" | ||
|
|
||
| if [ ! -f "$repo_dir/gitcompile" ]; then | ||
| echo "Error: gitcompile not found in $repo_dir" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # if Makefile exists then we can just run make | ||
| if [ ! -f "$repo_dir/Makefile" ]; then | ||
| (cd "$repo_dir" && ./gitcompile $configure_args $target_args) || \ | ||
| { echo "configure failed in $repo_dir"; exit 1; } | ||
| else | ||
| (cd "$repo_dir" && make -j) || { echo "make failed in $repo_dir"; exit 1; } | ||
| fi | ||
|
|
||
| (cd "$repo_dir" && make install) || { echo "make install failed in $repo_dir"; exit 1; } | ||
|
|
||
| echo "Build and installation complete for $repo_dir" | ||
| } | ||
|
|
||
| # Main script logic | ||
| mkdir -p "$BASE_DIR" | ||
|
|
||
| for ((i = 0; i < ${#REPOS[@]}; i++)); do | ||
| echo "Counter: $i, Value: ${REPOS[i]}" | ||
| repo_url=${REPOS[i]} | ||
|
|
||
| repo_name=$(basename "$repo_url" .git) # Extract repo name | ||
| repo_dir="$BASE_DIR/$repo_name" | ||
|
|
||
| if [ ! -d "$repo_dir" ]; then | ||
| echo "Cloning repository: $repo_url" | ||
| git clone "$repo_url" "$repo_dir" || { echo "git clone failed for $repo_url"; exit 1; } | ||
| elif ! check_commit "$repo_dir" "${COMMIT_ID[i]}"; then | ||
| update_repo "$repo_dir" | ||
| else | ||
| echo "Repository $repo_name is up to date." | ||
| fi | ||
|
|
||
| build_and_install "$repo_dir" "${CONFIGURE_ARGS[i]}" | ||
|
|
||
| done | ||
|
|
||
| echo "All repositories processed." | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,9 @@ add_executable(sof-ctl | |
| ctl.c | ||
| ) | ||
|
|
||
| target_link_directories(sof-ctl BEFORE | ||
| PRIVATE "${SOF_ROOT_SOURCE_DIRECTORY}/../tools/lib") | ||
|
|
||
| target_link_libraries(sof-ctl PRIVATE | ||
| "-lasound" | ||
| ) | ||
|
|
@@ -13,6 +16,7 @@ target_compile_options(sof-ctl PRIVATE | |
| ) | ||
|
|
||
| target_include_directories(sof-ctl PRIVATE | ||
| "${SOF_ROOT_SOURCE_DIRECTORY}/../tools/include" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested this and works in my local environment, but with @cgturner1 's test docker image (thesofproject/sof:20250410_no-alsa) with no system ALSA installed, the build fails as linkage still uses system libasound:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kv2019i now fixed |
||
| "${SOF_ROOT_SOURCE_DIRECTORY}/src/include" | ||
| "${SOF_ROOT_SOURCE_DIRECTORY}" | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be
For the default case, the BASE_DIR should point to parent directory of sof as this is the directory assumed in tools/topology/CMakeLists.txt rules:
So BASE_DIR should match "${SOF_ROOT_SOURCE_DIRECTORY}".
This is causing failuress e.g. when we try to use "build-tools.sh -A" in docker in github (and might be a reason why @lgirdwood you "open-coded" the build recipe for github testbench workflow in this PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct. We are cloning into the
~/work/sofworkspace directory with contains the~/work/sof/sofFW directory. e.g. my SOF workspace directory looks likeThe workspace should include all ingredients used to build FW, topologies, tooling i.e. everything a developer needs to create a new module and deploy it. I'll fix the other makefiles.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgirdwood Right so "$ZEPHYR_WORKSPACE=work/sof" is terms of
https://thesofproject.github.io/latest/getting_started/build-guide/build-with-zephyr.html
Ok I didn't realize that, I never use "sof" as the workspace directory name, but indeed then the problem is elsewhere setting the workspace path.
UPDATE2: ahaa, the build-from SOF source instructions do have "work/sof/sof". https://thesofproject.github.io/latest/getting_started/build-guide/build-from-scratch.html#step-1-set-up-the-workspace-directory . so then this is indeed aligned!
UPDATE: our docker images have used workspace path "/home/sof/work" with sof git checked out in "/home/sof/work/sof". This just means the workspace has to be manually be set with "--env SOF_WORKSPACE=/home/sof/work/".