Fixed check script; added --check flag to build script; added argument parsing to check and build script; added documentation to NoneTextDisplay; renamed multiboot2 section to bootheader
This commit is contained in:
parent
296135901b
commit
bf9c3f10a7
6 changed files with 144 additions and 25 deletions
49
kernel/build
49
kernel/build
|
@ -1,7 +1,50 @@
|
|||
#!/bin/bash
|
||||
|
||||
(
|
||||
set -e
|
||||
set -o errexit -o pipefail -o noclobber
|
||||
|
||||
HAVE_GETOPT=true
|
||||
getopt --test > /dev/null && true
|
||||
if [[ $? -ne 4 ]]; then
|
||||
if [[ -n "EXIT_WITHOUT_GETOPT" ]]; then
|
||||
echo '`getopt --test` failed. Exiting.'
|
||||
exit 1
|
||||
else
|
||||
echo '`getopt --test` failed. Continuing and ignoring command line flags. (note that $1 will still be used for the target)'
|
||||
echo '(to exit instead of ignoring, set the environment variable `EXIT_WITHOUT_GETOPT` to a non-null value)'
|
||||
HAVE_GETOPT=false
|
||||
fi
|
||||
fi
|
||||
|
||||
check=false
|
||||
|
||||
if [[ "$HAVE_GETOPT" = "true" ]]; then
|
||||
LONGOPTS=check
|
||||
OPTIONS=c
|
||||
|
||||
PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@") || (
|
||||
echo '`getopt` failed to parse command line arguments. Check the arguments passed.'
|
||||
exit 1
|
||||
)
|
||||
eval set -- "$PARSED"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-c|--check)
|
||||
check=true
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
export KERNEL_DIR=$(readlink -e .)
|
||||
|
||||
|
@ -38,6 +81,9 @@
|
|||
real_target=${!target}
|
||||
real_target=$(basename $real_target)
|
||||
echo "Compiling target $target(with rust target of $real_target)"
|
||||
if [[ $check = "true" ]]; then
|
||||
cargo check --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target
|
||||
else
|
||||
cargo build --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target
|
||||
cp "target/$(echo $real_target | sed 's/\.json//')/release/entrypoint_$target" kernel-$target
|
||||
|
||||
|
@ -54,6 +100,7 @@
|
|||
cp aphrodite-grub-$target.iso aphrodite-$target.iso
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $# -ge 1 ]]; then
|
||||
|
|
88
kernel/check
88
kernel/check
|
@ -1,14 +1,88 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Build the file
|
||||
./build
|
||||
(
|
||||
set -o errexit -o pipefail -o noclobber
|
||||
|
||||
if grub-file --is-x86-multiboot2 kernel.flat; then
|
||||
HAVE_GETOPT=true
|
||||
getopt --test > /dev/null && true
|
||||
if [[ $? -ne 4 ]]; then
|
||||
if [[ -n "EXIT_WITHOUT_GETOPT" ]]; then
|
||||
echo '`getopt --test` failed. Exiting.'
|
||||
exit 1
|
||||
else
|
||||
echo '`getopt --test` failed. Continuing and ignoring command line flags. (note that $1 will still be used for the target)'
|
||||
echo '(to exit instead of ignoring, set the environment variable `EXIT_WITHOUT_GETOPT` to a non-null value)'
|
||||
HAVE_GETOPT=false
|
||||
fi
|
||||
fi
|
||||
|
||||
real_check=false
|
||||
|
||||
if [[ "$HAVE_GETOPT" = "true" ]]; then
|
||||
LONGOPTS=real_check
|
||||
OPTIONS=c
|
||||
|
||||
PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@") || (
|
||||
echo '`getopt` failed to parse command line arguments. Check the arguments passed.'
|
||||
exit 1
|
||||
)
|
||||
eval set -- "$PARSED"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-c|--real_check)
|
||||
real_check=true
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $real_check = "true" ]]; then
|
||||
./build --check $!
|
||||
else
|
||||
./build $!
|
||||
fi
|
||||
|
||||
rm ./check_results
|
||||
|
||||
target="$1"
|
||||
|
||||
if [[ -z "$target" || "$target" = "x86" || "$target" = "mips64" || "$target" = "mipsel" || "$target" = "mipsle" ]]; then
|
||||
if [[ -z "$target" ]]; then
|
||||
# -f makes it so it won't error out if the file doesn't exist
|
||||
rm -f targets.tmp
|
||||
envsubst < "targets" > "targets.tmp"
|
||||
|
||||
export $(grep -Ev '^#' targets.tmp | xargs)
|
||||
|
||||
for target in $TARGETS; do
|
||||
if grub-file --is-x86-multiboot2 kernel-$target; then
|
||||
echo "Multiboot2 header valid" > ./check_results
|
||||
else
|
||||
else
|
||||
echo "Multiboot2 header INVALID!" > ./check_results
|
||||
fi
|
||||
fi
|
||||
done
|
||||
else
|
||||
if grub-file --is-x86-multiboot2 kernel-$target; then
|
||||
echo "Multiboot2 header valid" > ./check_results
|
||||
else
|
||||
echo "Multiboot2 header INVALID!" > ./check_results
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Multiboot2 header not checked as neither x86 nor mips is being built" > ./check_results
|
||||
fi
|
||||
|
||||
echo
|
||||
echo
|
||||
|
||||
cat check_results
|
||||
cat check_results
|
||||
)
|
|
@ -4,7 +4,7 @@ OUTPUT_FORMAT(elf32-i386)
|
|||
SECTIONS {
|
||||
.text : {
|
||||
. = ALIGN(8);
|
||||
KEEP(*(.multiboot2))
|
||||
KEEP(*(.bootheader))
|
||||
KEEP(*(.start))
|
||||
KEEP(*(.text))
|
||||
KEEP(*(.panic))
|
||||
|
|
|
@ -20,7 +20,7 @@ use aphrodite::output::*;
|
|||
use aphrodite::display::COLOR_DEFAULT;
|
||||
|
||||
#[cfg(not(CONFIG_DISABLE_MULTIBOOT2_SUPPORT))]
|
||||
#[unsafe(link_section = ".multiboot2")]
|
||||
#[unsafe(link_section = ".bootheader")]
|
||||
#[unsafe(no_mangle)]
|
||||
static MULTIBOOT2_HEADER: [u8; 24] = [
|
||||
0xd6, 0x50, 0x52, 0xe8, // Magic number
|
||||
|
|
|
@ -71,6 +71,7 @@ impl dyn TextDisplay + '_ {
|
|||
}
|
||||
}
|
||||
|
||||
/// An implementation of [TextDisplay]. Returns (1,1) for the size and always returns Ok(()) for all functions.
|
||||
pub struct NoneTextDisplay {}
|
||||
|
||||
impl TextDisplay for NoneTextDisplay {
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
Loading…
Add table
Reference in a new issue