xtheme support is mostly working

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-03-24 18:17:12 +03:00
parent 446b3cc6f6
commit 91ab997f5f
9 changed files with 260 additions and 937 deletions

906
gbuild.sh
View File

@ -1,906 +0,0 @@
#!/bin/bash
# ebuild.sh ->ebuild.sh //renamed to be unique file begining from E
# Script for building CloverEFI source under OS X or Linux
# Supported chainloads(compilers) are XCODE*, GCC*, UNIXGCC and CLANG
#
#
# Created by Jadran Puharic on 1/6/12.
# Modified by JrCs on 3/9/13.
# Zenith432, STLVNUB, cecekpawon 2016
# Micky1979 2016
# Go to the Clover root directory
cd "$(dirname $0)"
# Global variables
declare -r SELF="${0##*/}"
declare -r CLOVERROOT="$PWD"
declare -r SYSNAME="$(uname)"
declare -r DRIVERS_LEGACY="BIOS" # same in buildpkg.sh/makeiso
declare -r DRIVERS_UEFI="UEFI" # same in buildpkg.sh/makeiso
declare -r DRIVERS_OFF="off" # same in buildpkg.sh/makeiso
if [[ "$SYSNAME" == Linux ]]; then
declare -r NUMBER_OF_CPUS=$(nproc)
else
declare -r NUMBER_OF_CPUS=$(sysctl -n hw.logicalcpu)
fi
declare -a EDK2_BUILD_OPTIONS=
print_option_help_wc=
have_fmt=
PLATFORMFILE=
MODULEFILE=
TARGETRULE=
SCRIPT_VERS="2019-09-06"
# Macro
M_NOGRUB=0
M_APPLEHFS=0
# Default values
export TOOLCHAIN=GCC53
export TARGETARCH=X64
export BUILDTARGET=RELEASE
export BUILDTHREADS=$(( NUMBER_OF_CPUS + 1 ))
export WORKSPACE=${WORKSPACE:-}
export CONF_PATH=${CONF_PATH:-}
#export NASM_PREFIX=
export EDK_TOOLS_PATH="${PWD}"/BaseTools
# if building through Xcode, then TOOLCHAIN_DIR is not defined
# checking if it is where CloverGrowerPro put it
if [[ "$SYSNAME" == Linux ]]; then
export TOOLCHAIN=GCC53
TOOLCHAIN_DIR=${TOOLCHAIN_DIR:-/usr}
else
TOOLCHAIN_DIR=${TOOLCHAIN_DIR:-"$CLOVERROOT"/../../toolchain}
fi
if [[ ! -d $TOOLCHAIN_DIR ]]; then
TOOLCHAIN_DIR="${PWD}"/../opt/local
fi
export TOOLCHAIN_DIR
echo "TOOLCHAIN_DIR: $TOOLCHAIN_DIR"
VBIOSPATCHCLOVEREFI=0
ONLYSATA0PATCH=0
USE_BIOS_BLOCKIO=0
USE_LOW_EBDA=1
CLANG=0
GENPAGE=0
FORCEREBUILD=0
NOBOOTFILES=0
declare -r GIT=`which git`
#declare -r GITDIR=`git status 2> /dev/null` # unsafe as git repository may exist in parent directory
#declare -r VERSTXT="vers.txt"
if [[ -x "/usr/bin/sw_vers" ]]; then
declare -r OSVER="$(sw_vers -productVersion | sed -e 's/\.0$//g')"
elif [[ -x "/usr/bin/lsb_release" ]]; then
# Linux print the name+version in in two lines, sed serves to made it in one line!
# ..otherwise Clover fail because Version.h will have a line with no null terminated char.
declare -r OSVER="$(lsb_release -sir | sed -e ':a;N;$!ba;s/\n/ /g')"
fi
# Bash options
set -e # errexit
set -u # Blow on unbound variable
## FUNCTIONS ##
print_option_help () {
if [[ x$print_option_help_wc = x ]]; then
if wc -L </dev/null > /dev/null 2>&1; then
print_option_help_wc=-L
elif wc -m </dev/null > /dev/null 2>&1; then
print_option_help_wc=-m
else
print_option_help_wc=-b
fi
fi
if [[ x$have_fmt = x ]]; then
if fmt -w 40 </dev/null > /dev/null 2>&1; then
have_fmt=y;
else
have_fmt=n;
fi
fi
local print_option_help_lead=" $1"
local print_option_help_lspace="$(echo "$print_option_help_lead" | wc $print_option_help_wc)"
local print_option_help_fill="$((26 - print_option_help_lspace))"
printf "%s" "$print_option_help_lead"
local print_option_help_nl=
if [[ $print_option_help_fill -le 0 ]]; then
print_option_help_nl=y
echo
else
print_option_help_i=0;
while [[ $print_option_help_i -lt $print_option_help_fill ]]; do
printf " "
print_option_help_i=$((print_option_help_i+1))
done
print_option_help_nl=n
fi
local print_option_help_split=
if [[ x$have_fmt = xy ]]; then
print_option_help_split="$(echo "$2" | fmt -w 50)"
else
print_option_help_split="$2"
fi
if [[ x$print_option_help_nl = xy ]]; then
echo "$print_option_help_split" | awk '{ print " " $0; }'
else
echo "$print_option_help_split" | awk 'BEGIN { n = 0 }
{ if (n == 1) print " " $0; else print $0; n = 1 ; }'
fi
}
# Function to manage PATH
pathmunge () {
if [[ ! $PATH =~ (^|:)$1(:|$) ]]; then
if [[ "${2:-}" = "after" ]]; then
export PATH=$PATH:$1
else
export PATH=$1:$PATH
fi
fi
}
packagesPathmunge () {
if [[ -z "${PACKAGES_PATH:-}" ]]; then
export PACKAGES_PATH="$WORKSPACE" # must be always the first
fi
if [[ ! $PACKAGES_PATH =~ (^|:)$1(:|$) ]]; then
if [[ "${2:-}" = "after" ]]; then
export PACKAGES_PATH=$PACKAGES_PATH:$1
else
export PACKAGES_PATH=$1:$PACKAGES_PATH
fi
fi
}
# Add edk2 build option
addEdk2BuildOption() {
EDK2_BUILD_OPTIONS=("${EDK2_BUILD_OPTIONS[@]}" $@)
}
# Add edk2 build macro
addEdk2BuildMacro() {
local macro="$1"
[[ "$macro" == "NO_GRUB_DRIVERS" ]] && M_NOGRUB=1
addEdk2BuildOption "-D" "$macro"
}
# Check NASM
IsNumericOnly() {
if [[ "${1}" =~ ^-?[0-9]+$ ]]; then
return 0 # no, contains other or is empty
else
return 1 # yes is an integer (no matter for bash if there are zeroes at the beginning comparing it as integer)
fi
}
isNASMGood() {
# nasm should be greater or equal to 2.12.02 to be good building Clover.
# There was a bad macho relocation in outmacho.c, fixed by Zenith432
# and accepted by nasm devel during 2.12.rcxx (release candidate)
result=1
local nasmver=$( "${1}" -v | grep 'NASM version' | awk '{print $3}' )
case "$nasmver" in
2.12.0[2-9]* | 2.12.[1-9]* | 2.1[3-9]* | 2.[2-9]* | [3-9]* | [1-9][1-9]*)
result=0;;
*)
printf "\n\e[1;33mUnknown or unsupported NASM version found at:\n${1}\n\n\e[0m";;
esac
return $result
}
# Check Xcode toolchain
checkXcode () {
XCODE_BUILD="/usr/bin/xcodebuild"
local LOCALBIN="/usr/local/bin"
if [[ ! -x "${XCODE_BUILD}" ]]; then
echo "ERROR: Install Xcode Tools from Apple before using this script." >&2; exit 1
fi
if [[ -x "/opt/local/bin/mtoc.NEW" ]]; then
export MTOC_PREFIX="/opt/local/bin/"
elif [[ -x "${LOCALBIN}/mtoc.NEW" ]]; then
export MTOC_PREFIX="${LOCALBIN}/"
elif [[ -x "${TOOLCHAIN_DIR}/bin/mtoc.NEW" ]]; then
export MTOC_PREFIX="${TOOLCHAIN_DIR}/bin/"
else
export MTOC_PREFIX="${TOOLCHAIN_DIR}/bin/"
./buildmtoc.sh
fi
echo "MTOC_PREFIX: $MTOC_PREFIX"
}
# Print the usage.
usage() {
echo "Script for building CloverEFI sources on Darwin OS X"
echo "Version from ${SCRIPT_VERS}"
printf "Usage: %s [OPTIONS] [all|fds|genc|genmake|clean|cleanpkg|cleanall|cleanlib|modules|libraries]\n" "$SELF"
echo
echo "Configuration:"
print_option_help "-n THREADNUMBER" "Build the platform using multi-threaded compiler [default is number of CPUs + 1]"
print_option_help "-h, --help" "print this message and exit"
print_option_help "-v, --version" "print the version information and exit"
echo
echo "Toolchain:"
print_option_help "-clang" "use XCode Clang toolchain"
print_option_help "-llvm" "use LLVM toolchain"
print_option_help "-gcc49" "use GCC 4.9 toolchain"
print_option_help "-gcc53" "use GCC 5.3 toolchain"
print_option_help "-unixgcc" "use UNIXGCC toolchain"
print_option_help "-xcode" "use XCode 3.2 toolchain"
print_option_help "-xcode5" "use XCode 5-7 toolchain "
print_option_help "-xcode8" "use XCode 8 toolchain [Default]"
print_option_help "-t TOOLCHAIN, --tagname=TOOLCHAIN" "force to use a specific toolchain"
echo
echo "Target:"
print_option_help "-x64" "build Clover in 64-bit [boot6] [Default]"
print_option_help "-mc, --x64-mcp" "build Clover in 64-bit [boot7] using BiosBlockIO (compatible with MCP chipset)"
print_option_help "-p PLATFORMFILE, --platform=PLATFORMFILE" "Build the platform specified by the DSC filename argument"
print_option_help "-m MODULEFILE, --module=MODULEFILE" "Build only the module specified by the INF filename argument"
print_option_help "-b BUILDTARGET, --buildtarget=BUILDTARGET" "using the BUILDTARGET to build the platform"
print_option_help "-clean" "same as clean"
print_option_help "-cleanall" "same as cleanall"
echo
echo "Options:"
print_option_help "-D MACRO, --define=MACRO" "Macro: \"Name[=Value]\"."
print_option_help "--vbios-patch-cloverefi" "activate vbios patch in CloverEFI"
print_option_help "--only-sata0" "activate only SATA0 patch"
print_option_help "--std-ebda" "ebda offset dont shift to 0x88000"
print_option_help "--genpage" "dynamically generate page table under ebda"
print_option_help "--no-usb" "disable USB support"
print_option_help "--no-lto" "disable Link Time Optimisation"
print_option_help "--ext-pre" "deprecated option"
print_option_help "--ext-co" "deprecated option"
print_option_help "--ext-build" "deprecated option"
print_option_help "--edk2shell <MinimumShell|FullShell>" "copy edk2 Shell to EFI tools dir"
echo
echo "build options:"
print_option_help "-fr, --force-rebuild" "force rebuild all targets"
print_option_help "-nb, --no-bootfiles" "don't generate boot files"
echo
echo "Report bugs to https://sourceforge.net/p/cloverefiboot/discussion/1726372/"
}
# Manage option argument
argument () {
local opt=$1
shift
if [[ $# -eq 0 ]]; then
printf "%s: option \`%s' requires an argument\n" "$0" "$opt"
exit 1
fi
echo $1
}
# Check the command line arguments
checkCmdlineArguments() {
while [[ $# -gt 0 ]]; do
local option=$1
shift
case "$option" in
-clang | --clang) TOOLCHAIN=XCLANG ; CLANG=1 ;;
-llvm | --llvm) TOOLCHAIN=LLVM ; CLANG=1 ;;
-xcode5 | --xcode5 ) TOOLCHAIN=XCODE5 ; CLANG=1 ;;
-xcode8 | --xcode8 ) TOOLCHAIN=XCODE8 ; CLANG=1 ;;
-GCC49 | --GCC49) TOOLCHAIN=GCC49 ;;
-gcc49 | --gcc49) TOOLCHAIN=GCC49 ;;
-GCC53 | --GCC53) TOOLCHAIN=GCC53 ;;
-gcc53 | --gcc53) TOOLCHAIN=GCC53 ;;
-unixgcc | --gcc) TOOLCHAIN=UNIXGCC ;;
-xcode | --xcode ) TOOLCHAIN=XCODE32 ;;
-x64 | --x64)
printf "\`%s' is deprecated because Clover is 64 bit only. This message will be removed soon\n" "$option" 1>&2
sleep 4
;;
-mc | --x64-mcp) USE_BIOS_BLOCKIO=1 ;;
-clean) TARGETRULE=clean ;;
-cleanall) TARGETRULE=cleanall ;;
-fr | --force-rebuild) FORCEREBUILD=1 ;;
-nb | --no-bootfiles) NOBOOTFILES=1 ;;
# -d | -debug | --debug) BUILDTARGET=DEBUG ;;
# -r | -release | --release) BUILDTARGET=RELEASE ;;
-a) TARGETARCH=$(argument $option "$@")
printf "\`%s' is deprecated because Clover is 64 bit only. This message will be removed soon\n" "$option" 1>&2
sleep 4
;;
--arch=*)
printf "\`%s' is deprecated because Clover is 64 bit only. This message will be removed soon\n" "$option" 1>&2
sleep 4
;;
-p) PLATFORMFILE=$(argument $option "$@"); shift
;;
--platform=*)
PLATFORMFILE=$(echo "$option" | sed 's/--platform=//')
;;
-m) MODULEFILE=$(argument $option "$@"); shift
;;
--module=*)
MODULEFILE=$(echo "$option" | sed 's/--module=//')
;;
-b) BUILDTARGET=$(argument $option "$@"); shift
;;
--buildtarget=*)
BUILDTARGET=$(echo "$option" | sed 's/--buildtarget=//')
;;
-t) TOOLCHAIN=$(argument $option "$@"); shift
;;
--tagname=*)
TOOLCHAIN=$(echo "$option" | sed 's/--tagname=//')
;;
-D)
addEdk2BuildMacro $(argument $option "$@"); shift
;;
--define=*)
addEdk2BuildMacro $(echo "$option" | sed 's/--define=//')
;;
-n)
BUILDTHREADS=$(argument $option "$@"); shift
;;
--vbios-patch-cloverefi)
VBIOSPATCHCLOVEREFI=1
;;
--only-sata0)
ONLYSATA0PATCH=1
;;
--std-ebda)
USE_LOW_EBDA=0
;;
--genpage)
GENPAGE=1
;;
--no-usb)
addEdk2BuildMacro DISABLE_USB_SUPPORT
;;
--no-lto)
addEdk2BuildMacro DISABLE_LTO
;;
--ext-pre | --ext-co | --ext-build)
printf "\`%s' is deprecated. This message will be removed soon\n" "$option" 1>&2
sleep 4
;;
--edk2shell) EDK2SHELL=$(argument $option "$@"); shift
;;
-h | -\? | -help | --help)
usage && exit 0
;;
-v | --version)
echo "$SELF vers from $SCRIPT_VERS" && exit 0
;;
-*)
printf "Unrecognized option \`%s'\n" "$option" 1>&2
exit 1
;;
*)
TARGETRULE="$option"
;;
esac
done
# Update variables
PLATFORMFILE="${PLATFORMFILE:-Clover.dsc}"
if [ ! -z "${MODULEFILE}" ]; then
MODULEFILE=" -m $MODULEFILE"
fi
# Allow custom config path
if [[ -f "${CONF_PATH}/target.txt" ]]; then
addEdk2BuildOption "--conf=${CONF_PATH%/}"
elif [[ -f "${CLOVERROOT}/Conf/target.txt" ]]; then
addEdk2BuildOption "--conf=${CLOVERROOT}/Conf"
fi
}
## Check tools for the toolchain
checkToolchain() {
case "$TOOLCHAIN" in
XCLANG|XCODE*) checkXcode ;;
esac
if [[ "$SYSNAME" == Linux ]]; then
export GCC53_BIN="$TOOLCHAIN_DIR/bin/"
if [[ ! -x "${GCC53_BIN}gcc" ]]; then
echo "No clover toolchain found !" >&2
echo "Install on your system or define the TOOLCHAIN_DIR variable." >&2
exit 1
fi
else
export GCC53_BIN="$TOOLCHAIN_DIR/cross/bin/x86_64-clover-linux-gnu-"
if [[ $TOOLCHAIN == GCC* ]] && [[ ! -x "${GCC53_BIN}gcc" ]]; then
echo "No clover toolchain found !" >&2
echo "Build it with the build_gcc8.sh script or define the TOOLCHAIN_DIR variable." >&2
exit 1
fi
fi
if [[ -x "/opt/local/bin/nasm" ]]; then
export NASM_PREFIX="/opt/local/bin/"
elif [[ -x "${TOOLCHAIN_DIR}/bin/nasm" ]]; then
# using $TOOLCHAIN_DIR here should allow Clover source to be
# inside any sub folder instead of only in ~/
export NASM_PREFIX="${TOOLCHAIN_DIR}/bin/"
else
export NASM_PREFIX="${TOOLCHAIN_DIR}/bin/"
./buildnasm.sh
fi
echo "NASM_PREFIX: $NASM_PREFIX"
#NASM_VER=`nasm -v | awk '/version/ {print $3}'`
NASM_VER=`${NASM_PREFIX}nasm -v | sed -nE 's/^.*version.([0-9\.]+).*$/\1/p'`
echo "NASM_VER: $NASM_VER"
if [[ "$SYSNAME" == Darwin ]]; then
if ! isNASMGood "${NASM_PREFIX}nasm"; then echo "your nasm is not good to build Clover!" && exit 1; fi
fi
}
# Main build script
MainBuildScript() {
checkCmdlineArguments $@
checkToolchain
local repoRev=$(git describe --tags $(git rev-list --tags --max-count=1))
#
# we are building the same rev as before?
local SkipAutoGen=0
#
if [[ -f "$CLOVERROOT"/rEFIt_UEFI/Version.h ]]; then
local builtedRev=$(cat "$CLOVERROOT"/rEFIt_UEFI/Version.h \
| grep '#define FIRMWARE_REVISION L' | awk -v FS="(\"|\")" '{print $2}')
# echo "old revision ${builtedRev}" >echo.txt
# echo "new revision ${repoRev}" >>echo.txt
if [ "${repoRev}" = "${builtedRev}" ]; then SkipAutoGen=1; fi
fi
#
# Setup workspace if it is not set
#
local EDK2DIR=$(cd "$CLOVERROOT" && echo "$PWD")
if [[ -z "$WORKSPACE" ]]; then
echo "Initializing workspace"
if [[ ! -x "${EDK2DIR}"/edksetup.sh ]]; then
echo "Error: Can't find edksetup.sh script !" >&2
exit 1
fi
# This version is for the tools in the BaseTools project.
# this assumes svn pulls have the same root dir
# export EDK_TOOLS_PATH=`pwd`/../BaseTools
# This version is for the tools source in edk2
# cd "$EDK2DIR"
export EDK_TOOLS_PATH="${PWD}"/BaseTools
set +u
source ./edksetup.sh BaseTools
set -u
cd "$CLOVERROOT"
WORKSPACE="${PWD}"
else
echo "Building from: $WORKSPACE"
fi
export CLOVER_PKG_DIR="$CLOVERROOT"/CloverPackage/CloverV2
# Cleaning part of the script if we have told to do it
if [[ "$TARGETRULE" == cleanpkg ]]; then
if [[ "$SYSNAME" != Linux ]]; then
# Make some house cleaning
echo "Cleaning CloverUpdater files..."
make -C "$CLOVERROOT"/CloverPackage/CloverUpdater clean
echo "Cleaning CloverPrefpane files..."
make -C "$CLOVERROOT"/CloverPackage/CloverPrefpane clean
fi
echo "Cleaning bootsector files..."
local BOOTHFS="$CLOVERROOT"/BootHFS
DESTDIR="$CLOVER_PKG_DIR"/BootSectors make -C $BOOTHFS clean
echo
# Use subshell to use shopt
(
echo "Cleaning packaging files..."
shopt -s nullglob
find "$CLOVER_PKG_DIR"/Bootloaders/x64/ -mindepth 1 -not -path "**/.svn*" -delete
if [[ -d "$CLOVER_PKG_DIR"/EFI/BOOT ]]; then
find "$CLOVER_PKG_DIR"/EFI/BOOT/ -name '*.efi' -mindepth 1 -not -path "**/.svn*" -delete
rmdir "$CLOVER_PKG_DIR"/EFI/BOOT &>/dev/null
fi
local dir
for dir in "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers*; do
find "$dir" -mindepth 1 -not -path "**/.svn*" -delete
rmdir "$dir" &>/dev/null
done
find "$CLOVER_PKG_DIR"/EFI/CLOVER/ -name '*.efi' -maxdepth 1 -not -path "**/.svn*" -delete
for dir in "$CLOVER_PKG_DIR"/drivers/$DRIVERS_OFF/*; do
find "$dir" -mindepth 1 -not -path "**/.svn*" -delete
done
)
echo "Done!"
exit $?
elif [[ "$TARGETRULE" == clean || "$TARGETRULE" == cleanall ]]; then
build --quiet -p $PLATFORMFILE -b $BUILDTARGET \
-t $TOOLCHAIN -n $BUILDTHREADS $TARGETRULE
[[ "$TARGETRULE" == cleanall ]] && make -C $WORKSPACE/BaseTools clean
exit $?
fi
# Create edk tools if necessary
if [[ ! -x "$EDK_TOOLS_PATH/Source/C/bin/GenFv" ]]; then
echo "Building tools as they are not found"
make -C "$WORKSPACE"/BaseTools CC="gcc -Wno-deprecated-declarations"
fi
# Apply options
[[ "$USE_BIOS_BLOCKIO" -ne 0 ]] && addEdk2BuildMacro 'USE_BIOS_BLOCKIO'
[[ "$VBIOSPATCHCLOVEREFI" -ne 0 ]] && addEdk2BuildMacro 'ENABLE_VBIOS_PATCH_CLOVEREFI'
[[ "$ONLYSATA0PATCH" -ne 0 ]] && addEdk2BuildMacro 'ONLY_SATA_0'
[[ "$USE_LOW_EBDA" -ne 0 ]] && addEdk2BuildMacro 'USE_LOW_EBDA'
[[ -d "$WORKSPACE/MdeModulePkg/Universal/Variable/EmuRuntimeDxe" ]] && addEdk2BuildMacro 'HAVE_LEGACY_EMURUNTIMEDXE'
[[ "$CLANG" -ne 0 ]] && addEdk2BuildMacro 'CLANG'
local cmd="${EDK2_BUILD_OPTIONS[@]}"
if (( $SkipAutoGen == 1 )) && (( $FORCEREBUILD == 0 )); then
cmd="build --skip-autogen $cmd"
else
cmd="build $cmd"
fi
cmd="$cmd -p $PLATFORMFILE $MODULEFILE -a $TARGETARCH -b $BUILDTARGET"
cmd="$cmd -t $TOOLCHAIN -n $BUILDTHREADS $TARGETRULE"
echo
echo "Running edk2 build for Clover$TARGETARCH using the command:"
echo "$cmd"
echo
# Build Clover version
if (( $SkipAutoGen == 0 )) || (( $FORCEREBUILD == 1 )); then
# local clover_revision=$(cat "${CLOVERROOT}/${VERSTXT}")
local clover_revision=$(git describe --tags $(git rev-list --tags --max-count=1))
local clover_build_date=$(date '+%Y-%m-%d %H:%M:%S')
#echo "#define FIRMWARE_VERSION \"2.31\"" > "$CLOVERROOT"/Version.h
echo "#define FIRMWARE_BUILDDATE \"${clover_build_date}\"" > "$CLOVERROOT"/Version.h
echo "#define FIRMWARE_REVISION L\"${clover_revision}\"" >> "$CLOVERROOT"/Version.h
local sha1="(github unknown)"
if [[ -d "${CLOVERROOT}"/.git ]]; then
sha1="($(git rev-parse --abbrev-ref HEAD), commit $(git rev-parse --short HEAD))"
fi
echo "#define REVISION_STR \"Clover revision: ${clover_revision} $sha1\"" >> "$CLOVERROOT"/Version.h
# echo "#define REVISION_STR \"Clover revision: ${clover_revision}\"" >> "$CLOVERROOT"/Version.h
local clover_build_info="Args: "
if [[ -n "$@" ]]; then
clover_build_info="${clover_build_info} $@"
fi
clover_build_info="${clover_build_info} | $(echo $cmd | xargs | sed -e "s, -p ${PLATFORMFILE} , ,")"
if [[ -n "${OSVER:-}" ]]; then
clover_build_info="${clover_build_info} | OS: ${OSVER}"
fi
if [[ -n "${XCODE_VERSION:-}" ]]; then
clover_build_info="${clover_build_info} | XCODE: ${XCODE_VERSION}"
fi
# removing force rebuild related flags, and ensure only one blank space is used as separator
clover_build_info=$(echo ${clover_build_info} | sed -e 's/ -fr / /' \
| sed -e 's/ --force-rebuild / /' | sed -e 's/ --skip-autogen / /' \
| sed -e 's/build//' | sed -e 's/Args: | /Args: /' | sed -e 's/ / /')
echo "#define BUILDINFOS_STR \"${clover_build_info}\"" >> "$CLOVERROOT"/Version.h
cp "$CLOVERROOT"/Version.h "$CLOVERROOT"/rEFIt_UEFI/
fi
eval "$cmd"
}
copyBin() {
local cpSrc="$1"
local cpDest="$2"
local cpFile=$(basename "$2")
local cpDestDIR=$(dirname "$cpDest")
[[ ! -f "$cpSrc" || ! -d "$cpDestDIR" ]] && return
[[ -d "$cpDest" ]] && cpFile=$(basename "$cpSrc")
echo " -> $cpFile"
cp -f "$cpSrc" "$cpDest" 2>/dev/null
}
setInitBootMsg(){
local byte="35"
case "${1}" in
*boot2)
byte="32"
;;
*boot3)
byte="33"
;;
*boot4)
byte="34"
;;
*boot5)
byte="35"
;;
*boot6)
byte="36"
;;
*boot7)
byte="37"
;;
*boot7-MCP79)
byte="4d"
;;
*boot8)
byte="38"
;;
*boot9)
byte="39"
;;
*)
return;
;;
esac
if [[ -f "${1}" ]]; then
echo -e "Changing byte at 0xa9 of $(basename ${1}) to show \x${byte} as init message:"
printf "\x${byte}" | dd conv=notrunc of="${1}" bs=1 seek=$((0xa9))
fi
}
# Deploy Clover files for packaging
MainPostBuildScript() {
# if [[ -z "$EDK_TOOLS_PATH" ]]; then
export BASETOOLS_DIR="$WORKSPACE"/BaseTools/Source/C/bin
# else
# export BASETOOLS_DIR="$EDK_TOOLS_PATH"/Source/C/bin
# fi
export BOOTSECTOR_BIN_DIR="$CLOVERROOT"/CloverEFI/BootSector/bin
if (( $NOBOOTFILES == 0 )); then
echo Compressing DUETEFIMainFv.FV ...
"$BASETOOLS_DIR"/LzmaCompress -e -o "${BUILD_DIR}/FV/DUETEFIMAINFV${TARGETARCH}.z" "${BUILD_DIR}/FV/DUETEFIMAINFV${TARGETARCH}.Fv"
echo Compressing DxeCore.efi ...
"$BASETOOLS_DIR"/LzmaCompress -e -o "${BUILD_DIR}/FV/DxeMain${TARGETARCH}.z" "$BUILD_DIR_ARCH/DxeCore.efi"
echo Compressing DxeIpl.efi ...
"$BASETOOLS_DIR"/LzmaCompress -e -o "${BUILD_DIR}/FV/DxeIpl${TARGETARCH}.z" "$BUILD_DIR_ARCH/DxeIpl.efi"
echo "Generate Loader Image ..."
fi
cloverEFIFile=boot$((6 + USE_BIOS_BLOCKIO))
if (( $NOBOOTFILES == 0 )); then
"$BASETOOLS_DIR"/GenFw --rebase 0x10000 -o "$BUILD_DIR_ARCH/EfiLoader.efi" "$BUILD_DIR_ARCH/EfiLoader.efi"
"$BASETOOLS_DIR"/EfiLdrImage -o "${BUILD_DIR}"/FV/Efildr64 \
"$BUILD_DIR_ARCH"/EfiLoader.efi \
"${BUILD_DIR}"/FV/DxeIpl${TARGETARCH}.z \
"${BUILD_DIR}"/FV/DxeMain${TARGETARCH}.z \
"${BUILD_DIR}"/FV/DUETEFIMAINFV${TARGETARCH}.z
if [[ "$GENPAGE" -eq 0 && "$USE_LOW_EBDA" -ne 0 ]]; then
if [[ "$SYSNAME" == Linux ]]; then
local -r EL_SIZE=$(stat -c "%s" "${BUILD_DIR}"/FV/Efildr64)
else
local -r EL_SIZE=$(stat -f "%z" "${BUILD_DIR}"/FV/Efildr64)
fi
if (( $((EL_SIZE)) > 417792 )); then
echo 'warning: boot file bigger than low-ebda permits, switching to --std-ebda'
USE_LOW_EBDA=0
fi
fi
local -ar COM_NAMES=(H H2 H3 H4 H5 H6 H5 H6) # Note: (H{,2,3,4,5,6,5,6}) works in Linux bash, but not Darwin bash
startBlock=Start64${COM_NAMES[$((GENPAGE << 2 | USE_LOW_EBDA << 1 | USE_BIOS_BLOCKIO))]}.com
if [[ "$GENPAGE" -ne 0 ]]; then
cat $BOOTSECTOR_BIN_DIR/$startBlock $BOOTSECTOR_BIN_DIR/efi64.com3 "${BUILD_DIR}"/FV/Efildr64 > "${BUILD_DIR}"/FV/boot
else
cat $BOOTSECTOR_BIN_DIR/$startBlock $BOOTSECTOR_BIN_DIR/efi64.com3 "${BUILD_DIR}"/FV/Efildr64 > "${BUILD_DIR}"/FV/Efildr20Pure
if [[ "$USE_LOW_EBDA" -ne 0 ]]; then
"$BASETOOLS_DIR"/GenPage "${BUILD_DIR}"/FV/Efildr20Pure -b 0x88000 -f 0x68000 -o "${BUILD_DIR}"/FV/Efildr20
else
"$BASETOOLS_DIR"/GenPage "${BUILD_DIR}"/FV/Efildr20Pure -o "${BUILD_DIR}"/FV/Efildr20
fi
# Create CloverEFI file
dd if="${BUILD_DIR}"/FV/Efildr20 of="${BUILD_DIR}"/FV/boot bs=512 skip=1
fi
rm -rf "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers 2> /dev/null
# clean old drivers directories
if [[ "$DRIVERS_LEGACY" != drivers64 ]]; then
rm -rf "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers64
fi
if [[ "$DRIVERS_UEFI" != drivers64UEFI ]]; then
rm -rf "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers64UEFI
fi
rm -rf "$CLOVER_PKG_DIR"/CloverV2/drivers-Off
# Be sure that all needed directories exists
mkdir -p "$CLOVER_PKG_DIR"/Bootloaders/x64
mkdir -p "$CLOVER_PKG_DIR"/EFI/BOOT
mkdir -p "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_LEGACY
mkdir -p "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_UEFI
# off drivers
mkdir -p "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_LEGACY/FileVault2
mkdir -p "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_UEFI/FileVault2
mkdir -p "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_UEFI/MemoryFix
mkdir -p "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_LEGACY/FileSystem
mkdir -p "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_UEFI/FileSystem
mkdir -p "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_UEFI/HID
mkdir -p "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_UEFI/Other
# Install CloverEFI file
echo "Copy CloverEFI:"
copyBin "${BUILD_DIR}"/FV/boot "$CLOVER_PKG_DIR"/Bootloaders/x64/$cloverEFIFile
# For GENPAGE, the character "[TX]" is at offset 0x74 of Start64H[56].com, not offset 0xa9 - zenith432
if [[ "$GENPAGE" -eq 0 ]]; then
setInitBootMsg "$CLOVER_PKG_DIR"/Bootloaders/x64/$cloverEFIFile
fi
copyBin "$BUILD_DIR_ARCH"/CLOVER.efi "$CLOVER_PKG_DIR"/EFI/BOOT/BOOTX64.efi
copyBin "$BUILD_DIR_ARCH"/CLOVER.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/CLOVERX64.efi
# Mandatory drivers
echo "Copy Mandatory drivers:"
binArray=( FSInject XhciDxe SMCHelper AudioDxe )
for efi in "${binArray[@]}"
do
copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_LEGACY/$efi.efi
done
binArray=( AppleImageCodec AppleKeyAggregator AppleUITheme FirmwareVolume )
for efi in "${binArray[@]}"
do
copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_LEGACY/FileVault2/$efi.efi
done
binArray=( ApfsDriverLoader )
for efi in "${binArray[@]}"
do
copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_LEGACY/FileSystem/$efi.efi
done
if [[ $M_APPLEHFS -eq 1 ]]; then
copyBin "${CLOVERROOT}"/FileSystems/HFSPlus/X64/HFSPlus.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_LEGACY/FileSystem/HFSPlus.efi
fi
binArray=( FSInject DataHubDxe SMCHelper AudioDxe )
for efi in "${binArray[@]}"
do
copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_UEFI/$efi.efi
done
binArray=( AppleImageCodec AppleUITheme AppleKeyAggregator FirmwareVolume )
for efi in "${binArray[@]}"
do
copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_UEFI/FileVault2/$efi.efi
done
if [[ $M_NOGRUB -eq 0 ]]; then
binArray=( GrubEXFAT GrubISO9660 GrubNTFS GrubUDF )
for efi in "${binArray[@]}"
do
copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_LEGACY/FileSystem/$efi.efi
done
fi
# drivers64UEFI
binArray=( CsmVideoDxe EnglishDxe EmuVariableUefi NvmExpressDxe OsxFatBinaryDrv PartitionDxe )
for efi in "${binArray[@]}"
do
copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_UEFI/Other/$efi.efi
done
binArray=( Ps2MouseDxe UsbKbDxe UsbMouseDxe AptioInputFix )
for efi in "${binArray[@]}"
do
copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_UEFI/HID/$efi.efi
done
binArray=( ApfsDriverLoader Fat VBoxExt2 VBoxExt4 VBoxIso9600 VBoxHfs )
for efi in "${binArray[@]}"
do
copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_UEFI/FileSystem/$efi.efi
done
if [[ $M_APPLEHFS -eq 1 ]]; then
copyBin "${CLOVERROOT}"/FileSystems/HFSPlus/X64/HFSPlus.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_UEFI/FileSystem/HFSPlus.efi
fi
# drivers64UEFI/FileVault2
binArray=( AppleKeyFeeder HashServiceFix )
for efi in "${binArray[@]}"
do
copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_UEFI/FileVault2/$efi.efi
done
# drivers64UEFI/MemoryFix
binArray=( OsxAptioFixDrv OsxLowMemFixDrv OsxAptioFix3Drv AptioMemoryFix )
for efi in "${binArray[@]}"
do
copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_OFF/$DRIVERS_UEFI/MemoryFix/$efi.efi
done
# Applications
echo "Copy Applications:"
copyBin "$BUILD_DIR_ARCH"/bdmesg.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/tools/
if [[ "${EDK2SHELL:-}" == "MinimumShell" ]]; then
copyBin "${WORKSPACE}"/ShellBinPkg/MinUefiShell/X64/Shell.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/tools/Shell64U.efi
elif [[ "${EDK2SHELL:-}" == "FullShell" ]]; then
copyBin "${WORKSPACE}"/ShellBinPkg/UefiShell/X64/Shell.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/tools/Shell64U.efi
else
copyBin "$BUILD_DIR_ARCH"/Shell.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/tools/Shell64U.efi
fi
fi
echo "Done!"
# Build and install Bootsectors
echo
echo "Generating BootSectors"
local BOOTHFS="$CLOVERROOT"/BootHFS
DESTDIR="$CLOVER_PKG_DIR"/BootSectors make -C $BOOTHFS
echo "Done!"
}
# BUILD START #
# Default locale
export LC_ALL=POSIX
# Add toolchain bin directory to the PATH
if [[ "$SYSNAME" != Linux ]]; then
pathmunge "$TOOLCHAIN_DIR/bin"
fi
MainBuildScript $@
export BUILD_DIR="${WORKSPACE}/Build/Clover/${BUILDTARGET}_${TOOLCHAIN}"
export BUILD_DIR_ARCH="${BUILD_DIR}/$TARGETARCH"
if [[ -z $MODULEFILE ]] && (( $NOBOOTFILES == 0 )); then
MainPostBuildScript
else
copyBin "$BUILD_DIR_ARCH"/CLOVER.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/CLOVERX64.efi
copyBin "$BUILD_DIR_ARCH"/CLOVER.efi "$CLOVER_PKG_DIR"/EFI/BOOT/BOOTX64.efi
fi
# Local Variables: #
# mode: ksh #
# tab-width: 4 #
# indent-tabs-mode: nil #
# End: #
#
# vi: set expandtab ts=4 sw=4 sts=4: #

View File

@ -146,14 +146,23 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
Entry->AtClick = ActionSelect;
Entry->AtDoubleClick = ActionEnter;
Entry->AtRightClick = ActionDetails;
#if USE_XTHEME
if (ThemeX.HideBadges & HDBADGES_SHOW) {
if (ThemeX.HideBadges & HDBADGES_SWAP) {
Entry->BadgeImage = egCopyScaledImage(Entry->DriveImage, ThemeX.BadgeScale);
} else {
Entry->BadgeImage = egCopyScaledImage((Entry->Image).ToEGImage(), ThemeX.BadgeScale);
}
}
#else
if (GlobalConfig.HideBadges & HDBADGES_SHOW) {
if (GlobalConfig.HideBadges & HDBADGES_SWAP) {
Entry->BadgeImage = egCopyScaledImage(Entry->DriveImage, GlobalConfig.BadgeScale);
} else {
Entry->BadgeImage = egCopyScaledImage(Entry->Image, GlobalConfig.BadgeScale);
}
}
}
#endif
Entry->Volume = Volume;
Entry->DevicePathString = Volume->DevicePathString;
Entry->LoadOptions = (Volume->DiskKind == DISK_KIND_OPTICAL) ? L"CD" : ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? L"USB" : L"HD");

View File

@ -688,19 +688,41 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
Entry->ShortcutLetter = (Hotkey == 0) ? ShortcutLetter : Hotkey;
// get custom volume icon if present
#if USE_XTHEME
if (ThemeX.CustomIcons && FileExists(Volume->RootDir, L"\\.VolumeIcon.icns")){
Entry->Image = LoadIcns(Volume->RootDir, L"\\.VolumeIcon.icns", 128);
DBG("using VolumeIcon.icns image from Volume\n");
} else if (Image) {
Entry->Image.FromEGImage(Image);
} else {
Entry->Image = ThemeX.GetIcon("unknown");
}
#else
if (GlobalConfig.CustomIcons && FileExists(Volume->RootDir, L"\\.VolumeIcon.icns")){
Entry->Image = LoadIcns(Volume->RootDir, L"\\.VolumeIcon.icns", 128);
DBG("using VolumeIcon.icns image from Volume\n");
} else if (Image) {
Entry->Image = Image;
Entry->Image = Image;
} else {
Entry->Image = LoadOSIcon(OSIconName, L"unknown", 128, FALSE, TRUE);
Entry->Image = LoadOSIcon(OSIconName, L"unknown", 128, FALSE, TRUE);
}
#endif
// Load DriveImage
Entry->DriveImage = (DriveImage != NULL) ? DriveImage : ScanVolumeDefaultIcon(Volume, Entry->LoaderType, Volume->DevicePath);
// DBG("HideBadges=%d Volume=%s ", GlobalConfig.HideBadges, Volume->VolName);
#if USE_XTHEME
if (ThemeX.HideBadges & HDBADGES_SHOW) {
if (ThemeX.HideBadges & HDBADGES_SWAP) {
Entry->BadgeImage = egCopyScaledImage(Entry->DriveImage, ThemeX.BadgeScale);
// DBG(" Show badge as Drive.");
} else {
Entry->BadgeImage = egCopyScaledImage((Entry->Image).ToEGImage(), GlobalConfig.BadgeScale);
// DBG(" Show badge as OSImage.");
}
}
#else
if (GlobalConfig.HideBadges & HDBADGES_SHOW) {
if (GlobalConfig.HideBadges & HDBADGES_SWAP) {
Entry->BadgeImage = egCopyScaledImage(Entry->DriveImage, GlobalConfig.BadgeScale);
@ -710,7 +732,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
// DBG(" Show badge as OSImage.");
}
}
#endif
if (BootBgColor != NULL) {
Entry->BootBgColor = BootBgColor;
}

View File

@ -100,7 +100,11 @@ class REFIT_ABSTRACT_MENU_ENTRY
UINTN Row;
CHAR16 ShortcutDigit;
CHAR16 ShortcutLetter;
#if USE_XTHEME
XImage Image;
#else
EG_IMAGE *Image;
#endif
EG_RECT Place;
ACTION AtClick;
ACTION AtDoubleClick;

View File

@ -209,6 +209,10 @@ void XImage::Fill(const EG_PIXEL* Color)
Fill((const EFI_GRAPHICS_OUTPUT_BLT_PIXEL&)Color);
}
void XImage::FillArea(const EG_PIXEL* Color, EG_RECT& Rect)
{
FillArea((const EFI_GRAPHICS_OUTPUT_BLT_PIXEL&)*Color, Rect);
}
void XImage::FillArea(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color, EG_RECT& Rect)
{
@ -473,6 +477,11 @@ void XImage::DrawWithoutCompose(INTN x, INTN y, UINTN width, UINTN height)
}
}
void XImage::Draw(INTN x, INTN y)
{
Draw(x, y, 0);
}
void XImage::Draw(INTN x, INTN y, float scale)
{
//prepare images
@ -480,7 +489,7 @@ void XImage::Draw(INTN x, INTN y, float scale)
return;
}
XImage Top(*this, scale);
XImage Top(*this, scale); //can accept 0 as scale
XImage Background(Width, Height);
Background.GetArea(x, y, Width, Height);
Background.Compose(0, 0, Top, true);
@ -609,8 +618,24 @@ void XImage::DummyImage(IN UINTN PixelSize)
*Ptr++ = ~0; //yellow
*Ptr++ = ~0;
}
*Ptr++ = ~111;
*Ptr++ = ~111; //opacity
}
YPtr += LineOffset;
}
}
void XImage::CopyRect(const XImage& Image, INTN XPos, INTN YPos)
{
for (UINTN y = 0; y < Height && (y + YPos) < Image.GetHeight(); ++y) {
for (UINTN x = 0; x < Width && (x + XPos) < Image.GetWidth(); ++x) {
PixelData[y * Width + x] = Image.GetPixel(x + XPos, y + YPos);
}
}
}
EG_IMAGE* XImage::ToEGImage()
{
EG_IMAGE* Tmp = egCreateImage(Width, Height, TRUE);
CopyMem(&Tmp->PixelData[0], &PixelData[0], GetSizeInBytes());
return Tmp;
}

View File

@ -54,7 +54,7 @@ public:
XImage();
XImage(UINTN W, UINTN H);
XImage(EG_IMAGE* egImage);
XImage(const XImage& Image, float scale);
XImage(const XImage& Image, float scale); //the constructor can accept 0 scale as 1.f
~XImage();
XImage& operator= (const XImage& other);
@ -81,17 +81,21 @@ public:
void Fill(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color = { 0, 0, 0, 0 });
void Fill(const EG_PIXEL* Color);
void FillArea(const EG_PIXEL* Color, EG_RECT& Rect);
void FillArea(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color, EG_RECT& Rect);
void CopyScaled(const XImage& Image, float scale);
void CopyRect(const XImage& Image, INTN X, INTN Y);
void Compose(INTN PosX, INTN PosY, const XImage& TopImage, bool Lowest); //instead of compose we often can Back.Draw(...) + Top.Draw(...)
void FlipRB(bool WantAlpha);
EFI_STATUS FromPNG(const UINT8 * Data, UINTN Lenght);
EFI_STATUS ToPNG(UINT8** Data, UINTN& OutSize);
EFI_STATUS FromSVG(const CHAR8 *SVGData, float scale);
EFI_STATUS FromEGImage(const EG_IMAGE* egImage);
EG_IMAGE* ToEGImage();
void GetArea(const EG_RECT& Rect);
void GetArea(INTN x, INTN y, UINTN W, UINTN H);
void Draw(INTN x, INTN y, float scale);
void Draw(INTN x, INTN y, float scale); //can accept 0 scale as 1.f
void Draw(INTN x, INTN y);
void DrawWithoutCompose(INTN x, INTN y, UINTN width = 0, UINTN height = 0);
//I changed the name because LoadImage is too widely used
// will be used instead of old egLoadImage

View File

@ -313,7 +313,7 @@ VOID egFreeImage(IN EG_IMAGE *Image)
}
//
// Basic file operations
// Basic file operations should be separated into separate file
//
EFI_STATUS egLoadFile(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName,
OUT UINT8 **FileData, OUT UINTN *FileDataLength)
@ -506,6 +506,7 @@ EFI_STATUS egMkDir(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *DirName)
return Status;
}
//will be replaced by Image.LoadXImage(BaseDir, Name);
//caller is responsible for free image
EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN BOOLEAN WantAlpha)
{
@ -536,6 +537,7 @@ EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN
return NewImage;
}
//will be replaced by ThemeX.LoadIcon(Name);
//caller is responsible for free image
EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN IconSize)
{
@ -596,6 +598,7 @@ EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN
// Compositing
//
// take part of other procedures, not needed
VOID egRestrictImageArea(IN EG_IMAGE *Image,
IN INTN AreaPosX, IN INTN AreaPosY,
IN OUT INTN *AreaWidth, IN OUT INTN *AreaHeight)
@ -617,6 +620,8 @@ VOID egRestrictImageArea(IN EG_IMAGE *Image,
}
}
//will be replaced by
// CompImage.Fill(Color)
VOID egFillImage(IN OUT EG_IMAGE *CompImage, IN EG_PIXEL *Color)
{
INTN i;
@ -636,6 +641,8 @@ VOID egFillImage(IN OUT EG_IMAGE *CompImage, IN EG_PIXEL *Color)
}
}
//will be replaced by
// CompImage.FillArea(Color, Rect)
VOID egFillImageArea(IN OUT EG_IMAGE *CompImage,
IN INTN AreaPosX, IN INTN AreaPosY,
IN INTN AreaWidth, IN INTN AreaHeight,
@ -668,6 +675,9 @@ VOID egFillImageArea(IN OUT EG_IMAGE *CompImage,
}
}
//will be replaced by
// TmpBuffer.CopyRect(Background, XPos, YPos);
VOID egRawCopy(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
IN INTN Width, IN INTN Height,
IN INTN CompLineOffset, IN INTN TopLineOffset)
@ -783,6 +793,8 @@ VOID egRawComposeOnFlat(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
}
}
//will be replaced by
// CompImage.Compose(IN XImage& TopImage, IN INTN PosX, IN INTN PosY)
VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN PosX, IN INTN PosY)
{
INTN CompWidth, CompHeight;

View File

@ -93,6 +93,7 @@
libeg/XImage.h
libeg/XPointer.cpp
libeg/XPointer.h
libeg/XTheme.cpp
libeg/XTheme.h
Platform/Posix/posix.h
Platform/Posix/limits.h

View File

@ -154,7 +154,9 @@ INTN ScrollbarYMovement;
//EG_IMAGE *SelectionImages[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
//EG_IMAGE *Buttons[4] = {NULL, NULL, NULL, NULL};
#if !USE_XTHEME
static EG_IMAGE *TextBuffer = NULL;
#endif
//EG_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff }; //non-trasparent
@ -2499,7 +2501,6 @@ UINTN REFIT_MENU_SCREEN::RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INT
INTN ShortcutEntry;
BOOLEAN HaveTimeout = FALSE;
INTN TimeoutCountdown = 0;
CHAR16 *TimeoutMessage;
UINTN MenuExit;
if (ChosenEntry == NULL) {
@ -2583,11 +2584,11 @@ UINTN REFIT_MENU_SCREEN::RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INT
if (HaveTimeout) {
#if USE_XTHEME
//TimeoutMessage = PoolPrint(L"%s in %d seconds", TimeoutText.data(), TimeoutCountdown);
XStringW TOMessage = TimeoutText + L" in " + WPrintf("%d", TimeoutCountdown) + L" seconds";
XStringW TOMessage = TimeoutText + L" in " + WPrintf("%lld", TimeoutCountdown) + L" seconds";
((*this).*(StyleFunc))(MENU_FUNCTION_PAINT_TIMEOUT, TOMessage.data());
// FreePool(TimeoutMessage);
#else
TimeoutMessage = PoolPrint(L"%s in %d seconds", TimeoutText, TimeoutCountdown);
CHAR16 *TimeoutMessage = PoolPrint(L"%s in %d seconds", TimeoutText, TimeoutCountdown);
((*this).*(StyleFunc))(MENU_FUNCTION_PAINT_TIMEOUT, TimeoutMessage);
FreePool(TimeoutMessage);
#endif
@ -3280,8 +3281,39 @@ VOID DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAl
}
}
#if USE_XTHEME
VOID DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor)
{
XImage TextBufferX(UGAWidth-XPos, TextHeight);
if (Cursor != 0xFFFF) {
TextBufferX.Fill(&MenuBackgroundPixel);
} else {
TextBufferX.Fill(&InputBackgroundPixel);
}
if (SelectedWidth > 0) {
// fill selection bar background
EG_RECT TextRect;
TextRect.Width = SelectedWidth;
TextRect.Height = TextHeight;
TextBufferX.FillArea(&SelectionBackgroundPixel, TextRect);
}
// render the text
if (ThemeX.TypeSVG) {
//clovy - text veltically centred on Height
egRenderText(Text, TextBufferX, 0,
(INTN)((TextHeight - (textFace[TextStyle].size * ThemeX.Scale)) / 2),
Cursor, TextStyle);
} else {
egRenderText(Text, TextBufferX, TEXT_XMARGIN, TEXT_YMARGIN, Cursor, TextStyle);
}
TextBufferX.Draw((INTN)XPos, (INTN)YPos);
}
#else
VOID DrawMenuText(IN CONST CHAR16 *Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor)
{
//use Text=null to reinit the buffer
@ -3319,14 +3351,16 @@ VOID DrawMenuText(IN CONST CHAR16 *Text, IN INTN SelectedWidth, IN INTN XPos, IN
if (GlobalConfig.TypeSVG) {
//clovy - text veltically centred on Height
egRenderText(Text, TextBuffer, 0,
(INTN)((TextHeight - (textFace[TextStyle].size * GlobalConfig.Scale)) / 2),
Cursor, TextStyle);
(INTN)((TextHeight - (textFace[TextStyle].size * GlobalConfig.Scale)) / 2),
Cursor, TextStyle);
} else {
egRenderText(Text, TextBuffer, TEXT_XMARGIN, TEXT_YMARGIN, Cursor, TextStyle);
}
BltImageAlpha(TextBuffer, (INTN)XPos, (INTN)YPos, &MenuBackgroundPixel, 16);
}
#endif
VOID FreeScrollBar(VOID)
{
@ -4277,7 +4311,8 @@ VOID DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN
if (Entry->Row == 0 && Entry->getDriveImage() && !(ThemeX.HideBadges & HDBADGES_SWAP)) {
MainImage.FromEGImage(Entry->getDriveImage());
} else {
MainImage.FromEGImage(Entry->Image);
// MainImage.FromEGImage(Entry->Image);
MainImage = Entry->Image;
}
//this should be inited by the Theme
if (MainImage.isEmpty()) {
@ -4423,8 +4458,10 @@ VOID DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN
VOID XTheme::FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Height)
{
XImage TmpBuffer(Width, Height);
TmpBuffer.CopyScaled(Background, 1.f);
TmpBuffer.Draw(XPos, YPos);
// TmpBuffer.CopyScaled(Background, 1.f);
INTN X = XPos - (Width >> 1); //X_IS_CENTRE
TmpBuffer.CopyRect(Background, X, YPos);
TmpBuffer.Draw(X, YPos);
}
#else
VOID FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Height, IN EG_PIXEL *Color, IN UINT8 XAlign)
@ -4449,6 +4486,43 @@ VOID FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Hei
}
#endif
#if USE_XTHEME
VOID REFIT_MENU_SCREEN::DrawMainMenuLabel(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos)
{
INTN TextWidth = 0;
INTN BadgeDim = (INTN)(BADGE_DIMENSION * ThemeX.Scale);
egMeasureText(Text, &TextWidth, NULL);
//Clear old text
if (OldTextWidth > TextWidth) {
ThemeX.FillRectAreaOfScreen(OldX, OldY, OldTextWidth, TextHeight);
}
if (!(ThemeX.BootCampStyle)
&& (ThemeX.HideBadges & HDBADGES_INLINE) && (!OldRow)
&& (OldTextWidth) && (OldTextWidth != TextWidth)) {
//Clear badge
ThemeX.FillRectAreaOfScreen((OldX - (OldTextWidth >> 1) - (BadgeDim + 16)),
(OldY - ((BadgeDim - TextHeight) >> 1)), 128, 128);
}
DrawTextXY(XStringW().takeValueFrom(Text), XPos, YPos, X_IS_CENTER);
//show inline badge
if (!(ThemeX.BootCampStyle) &&
(ThemeX.HideBadges & HDBADGES_INLINE) &&
(Entries[ScrollState.CurrentSelection].Row == 0)) {
// Display Inline Badge: small icon before the text
Entries[ScrollState.CurrentSelection].Image.Draw((XPos - (TextWidth >> 1) - (BadgeDim + 16)),
(YPos - ((BadgeDim - TextHeight) >> 1)));
}
OldX = XPos;
OldY = YPos;
OldTextWidth = TextWidth;
OldRow = Entries[ScrollState.CurrentSelection].Row;
}
#else
VOID REFIT_MENU_SCREEN::DrawMainMenuLabel(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos)
{
INTN TextWidth;
@ -4485,7 +4559,7 @@ VOID REFIT_MENU_SCREEN::DrawMainMenuLabel(IN CONST CHAR16 *Text, IN INTN XPos, I
OldTextWidth = TextWidth;
OldRow = Entries[ScrollState.CurrentSelection].Row;
}
#endif
VOID REFIT_MENU_SCREEN::CountItems()
{
INTN i;
@ -4570,12 +4644,19 @@ VOID REFIT_MENU_SCREEN::MainMenuVerticalStyle(IN UINTN Function, IN CONST CHAR16
INTN row0PosYRunning;
INTN VisibleHeight = 0; //assume vertical layout
INTN MessageHeight = 20;
#if USE_XTHEME
if (ThemeX.TypeSVG && textFace[1].valid) {
MessageHeight = (INTN)(textFace[1].size * RowHeightFromTextHeight * ThemeX.Scale);
} else {
MessageHeight = (INTN)(TextHeight * RowHeightFromTextHeight * ThemeX.Scale);
}
#else
if (GlobalConfig.TypeSVG && textFace[1].valid) {
MessageHeight = (INTN)(textFace[1].size * RowHeightFromTextHeight * GlobalConfig.Scale);
}
else {
} else {
MessageHeight = (INTN)(TextHeight * RowHeightFromTextHeight * GlobalConfig.Scale);
}
#endif
switch (Function) {
@ -4696,7 +4777,19 @@ VOID REFIT_MENU_SCREEN::MainMenuVerticalStyle(IN UINTN Function, IN CONST CHAR16
DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER);
MouseBirth();
break;
#if USE_XTHEME
case MENU_FUNCTION_PAINT_TIMEOUT:
i = (ThemeX.HideBadges & HDBADGES_INLINE)?3:1;
HidePointer();
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)){
ThemeX.FillRectAreaOfScreen((UGAWidth >> 1), textPosY + MessageHeight * i,
OldTimeoutTextWidth, TextHeight);
OldTimeoutTextWidth = DrawTextXY(XStringW().takeValueFrom(ParamText), (UGAWidth >> 1), textPosY + MessageHeight * i, X_IS_CENTER);
}
DrawTextCorner(TEXT_CORNER_REVISION, X_IS_LEFT);
break;
#else
case MENU_FUNCTION_PAINT_TIMEOUT:
i = (GlobalConfig.HideBadges & HDBADGES_INLINE)?3:1;
HidePointer();
@ -4708,6 +4801,7 @@ VOID REFIT_MENU_SCREEN::MainMenuVerticalStyle(IN UINTN Function, IN CONST CHAR16
DrawTextCorner(TEXT_CORNER_REVISION, X_IS_LEFT);
break;
#endif
}
}
@ -4816,21 +4910,40 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
DrawMainMenuEntry(&Entries[i], (i == ScrollState.CurrentSelection)?1:0,
itemPosX[i - ScrollState.FirstVisible], row0PosY);
// draw static text for the boot options, BootCampStyle
if (GlobalConfig.BootCampStyle && !(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)) {
#if USE_XTHEME
if (ThemeX.BootCampStyle && !(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) {
INTN textPosX = itemPosX[i - ScrollState.FirstVisible] + (row0TileSize / 2);
// clear the screen
ThemeX.FillRectAreaOfScreen(textPosX, textPosY, EntriesWidth + GlobalConfig.TileXSpace,
MessageHeight);
DrawBCSText(Entries[i].Title, textPosX, textPosY, X_IS_CENTER);
}
#else
if (GlobalConfig.BootCampStyle && !(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)) {
INTN textPosX = itemPosX[i - ScrollState.FirstVisible] + (row0TileSize / 2);
FillRectAreaOfScreen(textPosX, textPosY, EntriesWidth + GlobalConfig.TileXSpace,
MessageHeight, &MenuBackgroundPixel, X_IS_CENTER);
// draw the text
DrawBCSText(Entries[i].Title, textPosX, textPosY, X_IS_CENTER);
}
#endif
}
} else {
DrawMainMenuEntry(&Entries[i], (i == ScrollState.CurrentSelection)?1:0,
itemPosX[i], row1PosY);
}
}
#if USE_XTHEME
// clear the text from the second row, required by the BootCampStyle
if ((ThemeX.BootCampStyle) && (Entries[ScrollState.LastSelection].Row == 1)
&& (Entries[ScrollState.CurrentSelection].Row == 0) && !(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) {
ThemeX.FillRectAreaOfScreen((UGAWidth >> 1), FunctextPosY,
OldTextWidth, MessageHeight);
}
#else
// clear the text from the second row, required by the BootCampStyle
if ((GlobalConfig.BootCampStyle) && (Entries[ScrollState.LastSelection].Row == 1)
&& (Entries[ScrollState.CurrentSelection].Row == 0) && !(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)) {
@ -4838,10 +4951,20 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
// clovy OldTextWidth, TextHeight, &MenuBackgroundPixel, X_IS_CENTER);
OldTextWidth, MessageHeight, &MenuBackgroundPixel, X_IS_CENTER);
}
#endif
// something is wrong with the DrawMainMenuLabel or Entries[ScrollState.CurrentSelection]
// and it's required to create the first selection text from here
// used for the second row entries, when BootCampStyle is used
#if USE_XTHEME
if ((Entries[ScrollState.LastSelection].Row == 0) && (Entries[ScrollState.CurrentSelection].Row == 1)
&& ThemeX.BootCampStyle && !(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) {
DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title,
(UGAWidth >> 1), FunctextPosY);
}
if (!(ThemeX.BootCampStyle) && !(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) {
DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title,
(UGAWidth >> 1), textPosY);
}
#else
if ((Entries[ScrollState.LastSelection].Row == 0) && (Entries[ScrollState.CurrentSelection].Row == 1)
&& GlobalConfig.BootCampStyle && !(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)) {
DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title,
@ -4855,7 +4978,7 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title,
(UGAWidth >> 1), textPosY);
}
#endif
DrawTextCorner(TEXT_CORNER_HELP, X_IS_LEFT);
DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER);
DrawTextCorner(TEXT_CORNER_REVISION, X_IS_RIGHT);
@ -4882,7 +5005,17 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
DrawMainMenuEntry(&Entries[ScrollState.CurrentSelection], TRUE,
itemPosX[ScrollState.CurrentSelection], row1PosY);
}
#if USE_XTHEME
if ((ThemeX.BootCampStyle) && (!(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL))
&& Entries[ScrollState.CurrentSelection].Row == 1) {
DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title,
(UGAWidth >> 1), FunctextPosY);
}
if ((!(ThemeX.BootCampStyle)) && (!(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL))) {
DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title,
(UGAWidth >> 1), textPosY);
}
#else
// create dynamic text for the second row if BootCampStyle is used
if ((GlobalConfig.BootCampStyle) && (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL))
&& Entries[ScrollState.CurrentSelection].Row == 1) {
@ -4895,7 +5028,7 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title,
(UGAWidth >> 1), textPosY);
}
#endif
DrawTextCorner(TEXT_CORNER_HELP, X_IS_LEFT);
DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER);
DrawTextCorner(TEXT_CORNER_REVISION, X_IS_RIGHT);
@ -4904,7 +5037,25 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
DBG("can't bear mouse at sel! Status=%r\n", Status);
}
break;
#if USE_XTHEME
case MENU_FUNCTION_PAINT_TIMEOUT:
i = (ThemeX.HideBadges & HDBADGES_INLINE)?3:1;
HidePointer();
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)){
ThemeX.FillRectAreaOfScreen((UGAWidth >> 1), FunctextPosY + MessageHeight * i,
OldTimeoutTextWidth, MessageHeight);
OldTimeoutTextWidth = DrawTextXY(XStringW().takeValueFrom(ParamText), (UGAWidth >> 1), FunctextPosY + MessageHeight * i, X_IS_CENTER);
}
DrawTextCorner(TEXT_CORNER_HELP, X_IS_LEFT);
DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER);
DrawTextCorner(TEXT_CORNER_REVISION, X_IS_RIGHT);
Status = MouseBirth();
if(EFI_ERROR(Status)) {
DBG("can't bear mouse at timeout! Status=%r\n", Status);
}
break;
#else
case MENU_FUNCTION_PAINT_TIMEOUT:
i = (GlobalConfig.HideBadges & HDBADGES_INLINE)?3:1;
HidePointer();
@ -4922,7 +5073,7 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
DBG("can't bear mouse at timeout! Status=%r\n", Status);
}
break;
#endif
}
}
@ -4955,7 +5106,8 @@ REFIT_ABSTRACT_MENU_ENTRY* NewEntry_(REFIT_ABSTRACT_MENU_ENTRY *Entry, REFIT_MEN
// create the submenu
// *SubScreen = (__typeof_am__(*SubScreen))AllocateZeroPool(sizeof(**SubScreen));
*SubScreen = new REFIT_MENU_SCREEN();
(*SubScreen)->Title = EfiStrDuplicate(Entry->Title);
// (*SubScreen)->Title = EfiStrDuplicate(Entry->Title);
(*SubScreen)->Title = Entry->Title;
(*SubScreen)->TitleImage = Entry->Image;
(*SubScreen)->ID = ID;
(*SubScreen)->AnimeRun = (*SubScreen)->GetAnime();