@@ -57,6 +57,9 @@ usage: $0 [options] [ platform(s) ] [ -- cmake arguments ]
5757 Incompatible with -p. To stop after downloading Zephyr, do not
5858 pass any platform or cmake argument.
5959
60+ -u Initial Zephyr remote for the -c option. Default value:
61+ https://github.com/zephyrproject-rtos/zephyr
62+
6063 -z Initial Zephyr git ref for the -c option. Can be a branch, tag,
6164 full SHA1 in a fork, magic pull/12345/merge,... anything as long as
6265 it is fetchable from https://github.com/zephyrproject-rtos/zephyr/
@@ -111,18 +114,26 @@ zephyr_fetch_and_switch()
111114# link back to sof/
112115west_init_update ()
113116{
114- local init_ref=" $1 "
115-
116- # Or, we could have a default value:
117- # init_ref=${1:-811a09bd8305}
118-
119- git clone --depth=5 https://github.com/zephyrproject-rtos/zephyr \
120- " $WEST_TOP " /zephyr
117+ # Default Zephyr remote and branch if nothing passed on the
118+ # command line.
119+ local init_remote=" ${1:- https:// github.com/ zephyrproject-rtos/ zephyr} "
120+
121+ # This can be a branch, a 40-digit SHA or empty to fetch the
122+ # default branch. Example:
123+ # local init_ref=${2:-sof/stable-v2.1}
124+ local init_ref=" $2 "
125+
126+ # git fetch accepts anything, even 40-digits SHA but git clone is
127+ # less flexible. So we git clone the default branch first to get
128+ # started and then we switch to any 'z_ref' thanks to git fetch.
129+ ( set -x
130+ git clone --depth=5 " $init_remote " " $WEST_TOP " /zephyr
131+ )
121132
122133 # To keep things simple, this moves to a detached HEAD even when
123134 # init_ref is a (remote) branch.
124135 test -z " $init_ref " ||
125- zephyr_fetch_and_switch origin " ${init_ref} "
136+ zephyr_fetch_and_switch " ${init_remote} " " ${init_ref} "
126137
127138 # This shows how to point CI at any Zephyr commit from anywhere
128139 # and to run all tests on it. Simply edit remote and reference,
@@ -302,14 +313,15 @@ build_platforms()
302313parse_args ()
303314{
304315 local zeproj
305- unset zephyr_ref
316+ unset zephyr_remote zephyr_ref
306317 local OPTIND=1
307318
308319 # Parse -options
309- while getopts " acz :j:k:p:v" OPTION; do
320+ while getopts " acu:z :j:k:p:v" OPTION; do
310321 case " $OPTION " in
311322 a) PLATFORMS=(" ${DEFAULT_PLATFORMS[@]} " ) ;;
312323 c) DO_CLONE=yes ;;
324+ u) zephyr_remote=" $OPTARG " ;;
313325 z) zephyr_ref=" $OPTARG " ;;
314326 j) BUILD_JOBS=" $OPTARG " ;;
315327 k) RIMAGE_KEY_OPT=" $OPTARG " ;;
@@ -328,8 +340,8 @@ parse_args()
328340 die ' Cannot use -p with -c, -c supports %s only' " ${SOF_TOP} /zephyrproject"
329341 fi
330342
331- if [ -n " $zephyr_ref " ] && [ -z " $DO_CLONE " ]; then
332- die ' %s' ' -z without -c makes no sense'
343+ if [ -n " $zephyr_remote " -o -n " $ zephyr_ref" ] && [ -z " $DO_CLONE " ]; then
344+ die ' %s' ' -u or - z without -c makes no sense'
333345 fi
334346
335347 if [ -n " $zeproj " ]; then
@@ -407,7 +419,7 @@ see https://docs.zephyrproject.org/latest/getting_started/index.html"
407419 # Resolve symlinks
408420 mkdir " $zep " ; WEST_TOP=$( cd " $zep " && /bin/pwd )
409421
410- west_init_update " ${zephyr_ref} "
422+ west_init_update " ${zephyr_remote} " " ${ zephyr_ref}"
411423
412424 else
413425 # Look for Zephyr and define WEST_TOP
0 commit comments