forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-alsa-tools.sh
More file actions
executable file
·127 lines (103 loc) · 3.8 KB
/
build-alsa-tools.sh
File metadata and controls
executable file
·127 lines (103 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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."