Files
slimbootloader/BaseTools/BuildEnv
Guo Dong 416f2d95da Sync edk2 basetool mdepkg (#2121)
* Sync BaseTools to align with edk2-stable202311

Keep the SBL specific change (e.g. Lz4).

Signed-off-by: Guo Dong <guo.dong@intel.com>

* feat: Sync MdePkg from EDK2 edk2-stable202311 branch

Only sync required file without any changes to EDK2 files.

Signed-off-by: Guo Dong <guo.dong@intel.com>

* feat: Update MdePkg for SBL after sync from EDK2

Signed-off-by: Guo Dong <guo.dong@intel.com>

* Update SBL after updating Basetool and MdePkg

After Sync BaseTool and MdePkg to edk2-stable202311,
Need update SBL code to align with this change.

Signed-off-by: Guo Dong <guo.dong@intel.com>

* feat: rollback some changes after mdepkg sync

New change from MdePkg requires new NASM version.
To make sure NASM 2.14.02 still works, just rollback
few changes.

Signed-off-by: Guo Dong <guo.dong@intel.com>

* feat: Update component size to fix build failure

After syncing BaseTool and MdePkg, some components would
have a little bigger size. So update the config to fix the
build failure.

Signed-off-by: Guo Dong <guo.dong@intel.com>

* feat: Remove unused asl code

Some ASL files don't exist but they are included in other asl files.
It would cause build failure with new build BaseTool. So just remove
them to fix the build failure.

Signed-off-by: Guo Dong <guo.dong@intel.com>

---------

Signed-off-by: Guo Dong <guo.dong@intel.com>
2024-03-08 13:43:46 -05:00

280 lines
6.3 KiB
Plaintext

## @file
# Setup the environment for unix-like systems running a bash-like shell.
# This file must be "sourced" not merely executed. For example: ". edksetup.sh"
#
# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
SetWorkspace() {
#
# If WORKSPACE is already set, then we can return right now
#
if [ -n "$WORKSPACE" ]
then
return 0
fi
#
# Set $WORKSPACE
#
WORKSPACE=$(pwd)
export WORKSPACE
return 0
}
RestorePreviousConfiguration() {
#
# Restore previous configuration
#
if [ -z "$CONF_PATH" ]
then
export CONF_PATH=$WORKSPACE/Conf
if [ ! -d $WORKSPACE/Conf ] && [ -n "$PACKAGES_PATH" ]
then
for DIR in $(echo $PACKAGES_PATH | tr ':' ' ')
do
if [ -d $DIR/Conf ]
then
export CONF_PATH=$DIR/Conf
break
fi
done
fi
fi
PREVIOUS_CONF_FILE=$CONF_PATH/BuildEnv.sh
if [ -e $PREVIOUS_CONF_FILE ]
then
echo Loading previous configuration from $PREVIOUS_CONF_FILE
. $PREVIOUS_CONF_FILE
fi
}
GenerateShellCodeToSetVariable() {
VARIABLE=$1
OUTPUT_FILE=$2
VAR_VALUE="echo \${${VARIABLE}}"
VAR_VALUE=`eval $VAR_VALUE`
echo "if [ -z \"\$${VARIABLE}\" ]" >> $OUTPUT_FILE
echo "then" >> $OUTPUT_FILE
echo " export ${VARIABLE}=${VAR_VALUE}" >> $OUTPUT_FILE
echo "fi" >> $OUTPUT_FILE
}
GenerateShellCodeToUpdatePath() {
OUTPUT_FILE=$1
echo "if [ -e $EDK_TOOLS_PATH_BIN ]" >> $OUTPUT_FILE
echo "then" >> $OUTPUT_FILE
echo " FOUND_TOOLS_PATH_BIN=0" >> $OUTPUT_FILE
echo " for DIR in \$(echo \$PATH | tr ':' ' '); do" >> $OUTPUT_FILE
echo " if [ \"\$DIR\" = \"$EDK_TOOLS_PATH_BIN\" ]; then" >> $OUTPUT_FILE
echo " FOUND_TOOLS_PATH_BIN=1" >> $OUTPUT_FILE
echo " fi" >> $OUTPUT_FILE
echo " done" >> $OUTPUT_FILE
echo " if [ \$FOUND_TOOLS_PATH_BIN = 0 ]" >> $OUTPUT_FILE
echo " then" >> $OUTPUT_FILE
echo " export PATH=$EDK_TOOLS_PATH_BIN:\$PATH" >> $OUTPUT_FILE
echo " fi" >> $OUTPUT_FILE
echo "fi" >> $OUTPUT_FILE
}
StoreCurrentConfiguration() {
#
# Write configuration to a shell script to allow for configuration to be
# easily reloaded.
#
OUTPUT_FILE=$CONF_PATH/BuildEnv.sh
#echo Storing current configuration into $OUTPUT_FILE
echo "# Auto-generated by BaseTools/BuildEnv" >| $OUTPUT_FILE
GenerateShellCodeToSetVariable WORKSPACE $OUTPUT_FILE
GenerateShellCodeToSetVariable EDK_TOOLS_PATH $OUTPUT_FILE
GenerateShellCodeToUpdatePath $OUTPUT_FILE
}
SetEdkToolsPath() {
#
# If EDK_TOOLS_PATH is already set, then we can return right now
#
if [ -n "$EDK_TOOLS_PATH" ]
then
return 0
fi
#
# Try $CONF_PATH/EdkTools
#
if [ -e $CONF_PATH/EdkTools ]
then
export EDK_TOOLS_PATH=$CONF_PATH/EdkTools
return 0
fi
#
# Try $CONF_PATH/BaseToolsSource
#
if [ -e $CONF_PATH/BaseToolsSource ]
then
export EDK_TOOLS_PATH=$CONF_PATH/BaseToolsSource
return 0
fi
#
# Try $WORKSPACE/BaseTools
#
if [ -e $WORKSPACE/BaseTools ]
then
export EDK_TOOLS_PATH=$WORKSPACE/BaseTools
return 0
fi
#
# Try $PACKAGES_PATH
#
if [ -n "$PACKAGES_PATH" ]
then
for DIR in $(echo $PACKAGES_PATH | tr ':' ' ')
do
if [ -d $DIR/BaseTools ]
then
export EDK_TOOLS_PATH=$DIR/BaseTools
return 0
fi
done
fi
echo "Unable to determine EDK_TOOLS_PATH"
echo
echo "You may need to download the 'BaseTools' from buildtools.tianocore.org."
echo "After downloading, either create a symbolic link to the source at"
echo "\$WORKSPACE/Conf/BaseToolsSource, or set the EDK_TOOLS_PATH environment"
echo "variable."
}
GetBaseToolsBinSubDir() {
#
# Figure out a uniq directory name from the uname command
#
echo $(uname -sm | tr ' ' '-')
}
GetEdkToolsPathBinDirectory() {
#
# Figure out a uniq directory name from the uname command
#
BIN_SUB_DIR=`GetBaseToolsBinSubDir`
if [ -e $EDK_TOOLS_PATH/BinWrappers/$BIN_SUB_DIR ]
then
EDK_TOOLS_PATH_BIN=$EDK_TOOLS_PATH/BinWrappers/$BIN_SUB_DIR
else
EDK_TOOLS_PATH_BIN=$EDK_TOOLS_PATH/Bin/$BIN_SUB_DIR
fi
echo $EDK_TOOLS_PATH_BIN
}
AddDirToStartOfPath() {
DIRNAME=$1
PATH=$DIRNAME:$PATH
export PATH
}
AddEdkToolsToPath() {
#
# If EDK_TOOLS_PATH is not set, then we cannot update PATH
#
if [ -z "$EDK_TOOLS_PATH" ]
then
return 1
fi
EDK_TOOLS_PATH_BIN=`GetEdkToolsPathBinDirectory`
# check if the edk2basetools pip package is available
if $PYTHON_COMMAND -c "import edk2basetools" > /dev/null 2>&1; then
# if it is, use the pip version of the wrappers
echo "Using Pip Basetools"
AddDirToStartOfPath $EDK_TOOLS_PATH/BinPipWrappers/PosixLike
else
echo "Using EDK2 in-source Basetools"
AddDirToStartOfPath $EDK_TOOLS_PATH/BinWrappers/PosixLike
fi
AddDirToStartOfPath $EDK_TOOLS_PATH_BIN
}
CopySingleTemplateFile() {
SRC_FILENAME=Conf/$1.template
DST_FILENAME=$CONF_PATH/$1.txt
if [ -e $DST_FILENAME ]
then
[ $RECONFIG != TRUE ] && return
fi
echo "Copying \$EDK_TOOLS_PATH/$SRC_FILENAME"
echo " to $DST_FILENAME"
SRC_FILENAME=$EDK_TOOLS_PATH/$SRC_FILENAME
cp $SRC_FILENAME $DST_FILENAME
}
CopyTemplateFiles() {
CopySingleTemplateFile build_rule
CopySingleTemplateFile tools_def
CopySingleTemplateFile target
}
ScriptMain() {
SetWorkspace
if [ -z $WORKSPACE ]
then
echo "Failure setting WORKSPACE"
return 1
fi
RestorePreviousConfiguration
SetEdkToolsPath
if [ -z $EDK_TOOLS_PATH ]
then
return 1
fi
AddEdkToolsToPath
if [ $? -ne 0 ]
then
echo "Failure adding EDK Tools into PATH!"
return 1
fi
StoreCurrentConfiguration
echo WORKSPACE: $WORKSPACE
echo EDK_TOOLS_PATH: $EDK_TOOLS_PATH
echo CONF_PATH: $CONF_PATH
CopyTemplateFiles
}
#
# Run the main function
#
ScriptMain