#!/bin/bash -eu # # Copyright 2017 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # To track how long we took to startup. case $(uname -s) in Darwin) export TRACE_BEGIN_SOONG=`$T/prebuilts/build-tools/path/darwin-x86/date +%s%3N` ;; *) export TRACE_BEGIN_SOONG=$(date +%s%N) ;; esac
source $(cd $(dirname $BASH_SOURCE) &> /dev/null && pwd)/../make/shell_utils.sh require_top # Save the current PWD for use in soong_ui export ORIGINAL_PWD=${PWD} export TOP=$(gettop) source ${TOP}/build/soong/scripts/microfactory.bash
if echo "$@" | grep -q -- "--build-mode"; then echo "参数 --build-mode 存在" if [[ -v SOONG_DEBUG ]]; then echo "进入调试模式" exec dlv --listen=:2345 --headless=true --api-version=2 exec -- "$(getoutdir)/soong_ui" "$@" else exec "$(getoutdir)/soong_ui" "$@" fi else #echo "参数 --build-mode 不存在" exec "$(getoutdir)/soong_ui" "$@" fi
启动soong
SOONG_DEBUG参数是我们为调试手动添加的!!
1 2 3
source build/envsetup.sh lunch XXX SOONG_DEBUG=1 m
当我们执行m脚本以后,soong将进入等待状态
1 2 3 4 5
➜ android-14.0.0_r73 SOONG_DEBUG=1 m 参数 --build-mode 存在 进入调试模式 API server listening at: [::]:2345 2025-09-16T09:17:02+08:00 warn layer=rpc Listening for remote connections (connections are not authenticated nor encrypted)