Compare commits

..

No commits in common. "1c6e48c0757990fb7334d5fcabc127d1fde9bcd0" and "8bb56b32463ed4ba90b987c1731e398b8ec7c163" have entirely different histories.

25 changed files with 46 additions and 218 deletions

View File

@ -1,230 +1,58 @@
#!/bin/bash #!/bin/bash
echo "|================| NightLoader Build-Script v0.1 |================|" echo "|==== Building the NightLoader with Build-Script v0.1 ====|"
echo " "
# Legacy Bootloader for old BIOS-platforms
echo "STARTING TO BUILD LEGACY-BIOS LOADER!"
# Build the stage-1 bootloader; the first disk-sector.
cd code/legacy-bios/bootsector
bash build.sh $1 $2
mv bootsector.bin ../../../
cd ..
# Build the stage 2 - starter; it is just there to jump
# to the *executable file* which the UEFI-codepath also uses.
cd starter
bash build.sh $1 $2
mv starter.bin ../../../
cd ../../../
mv bootsector.bin build/objects/
mv starter.bin build/objects/
echo "FINISHED BUILDING LEGACY-BIOS LOADER"
echo " "
echo " " echo " "
echo " " echo " "
BUILD_ROOT=$PWD
QUIET="FALSE"
VERBOSE="FALSE"
echo "Creating disk image for a basic NightLoader-installation"
if [[ $2 == "-q" ]]; then # Create the partition's image-file by allocating 256MB and
QUIET="TRUE" # creating a FAT32 - partition which then resides there.
fi truncate -s 256M partition.bin
mkfs.fat -F32 -nNIGHT partition.bin
if [[ $3 == "-q" ]]; then # Mount the partition-image to a specific directory (needs
QUIET="TRUE" # root-permissions), copy over the freshly built binaries to
fi # the path they belobng to and unmount the partition.
mount partition.bin partition/
mkdir -p partition/nightloader/
cp starter.bin partition/
umount partition.bin
mv partition.bin build/objects/
if [[ $4 == "-q" ]]; then # Create a disk image by including the first disk sector.
QUIET="TRUE" cat build/objects/bootsector.bin > nightloader.bin
fi cat build/objects/partition.bin >> nightloader.bin
if [[ $5 == "-q" ]]; then echo " "
QUIET="TRUE" echo " "
fi echo "Finished building the NightLoader!"
echo " "
if [[ $2 == "-v" ]]; then
VERBOSE="TRUE"
fi
if [[ $3 == "-v" ]]; then
VERBOSE="TRUE"
fi
if [[ $4 == "-v" ]]; then
VERBOSE="TRUE"
fi
if [[ $5 == "-v" ]]; then
VERBOSE="TRUE"
fi
if [[ $QUIET == "TRUE" ]]; then
if [[ $VERBOSE == "TRUE" ]]; then
echo "ERROR: '-v' and 'q' cannot coexist!"
exit
fi
fi
log() {
if [[ $QUIET -eq "TRUE" ]]; then
return
fi
echo $1
}
# START OF ACTION FUNCTIONS
initialize_build_environment() {
cd $BUILD_ROOT/libs/original/posix-uefi
bash build.bash $BUILD_ROOT
}
clean_build_environment() {
echo "TODO: Clean Environment"
}
build_debug() {
# Legacy Bootloader for old BIOS-platforms
log "Building legacy-bootloader for target 'debug'"
# Build the stage-1 bootloader; the first disk-sector.
cd code/legacy-bios/bootsector
bash build.bash $BUILD_ROOT "debug"
cd ..
# Build the stage 2 - starter; it is just there to jump
# to the *executable file* which the UEFI-codepath also uses.
cd starter
bash build.bash $BUILD_ROOT "debug"
cd ../../../
log "Legacy-bootloader was built for target 'debug'"
log " "
log " "
log " "
log "Building UEFI-bootloader for target 'debug'"
cd code/uefi/stage_2
bash build.bash $BUILD_ROOT "debug"
log "UEFI-bootloader was built for target 'debug'"
log " "
log " "
log " "
cd ../../../
log "Creating disk image for a basic NightLoader-installation"
# Create the partition's image-file by allocating 256MB and
# creating a FAT32 - partition which then resides there.
truncate -s 256M partition.bin
mkfs.fat -F32 -nNIGHT partition.bin
# Mount the partition-image to a specific directory (needs
# root-permissions), copy over the freshly built binaries to
# the path they belobng to and unmount the partition.
mount partition.bin partition/
mkdir -p partition/nightloader/
cp starter.bin partition/
umount partition.bin
mv partition.bin build/objects/
# Create a disk image by including the first disk sector.
cat build/objects/bootsector.bin > nightloader.bin
cat build/objects/partition.bin >> nightloader.bin
log " "
log " "
log "Finished building the NightLoader!"
log " "
}
build_release() {
echo "TODO: Release-Build"
}
build_all() {
build_debug
build_release
}
print_help() {
echo "NightLoader Short Help for 'build.bash', for a more thorough help use '$0 manual'"
echo " "
echo "Available Commands are: 'all', 'clean', 'debug', 'help', 'init', 'manual' 'release'"
echo "| all: Initializes the environment (if needed) build all targets (debug & release)"
echo "| but does NOT clean up the environment's build-files, etc.. The version of"
echo "| the build is needed as an argument. See: Example [1]"
echo "|"
echo "| clean: Removes all cached files."
echo "|"
echo "| debug: Builds the 'debug'-target. The 'debug'-target has more information which"
echo "| is needed for contributing to the NightLoader. This shouldn't be used for"
echo "| actual usage as it bloats the executable size quite a bit."
echo "|"
echo "| init: Updates & Initializes the dependencies and performs a one-time setup."
echo "| There can be one argument which tells which dependency should be updated."
echo "| Possible values are:"
echo "| - 'posix-uefi': Clone and build POSIX-UEFI."
echo "| - 'all-depends': Update (download) and build all dependencies."
echo "| For further information, see: Examples [4] [5]"
echo "|"
echo "| manual: A longer manual to the NightLoader, referencing the documentation in the"
echo "| './docs/'-folder and making it interactive."
echo "| For further information, see: Examples [6] [7] [8] [9] [10]"
echo "|"
echo "| release: Builds the 'release'-target. This target should be used for building the"
echo "| optimized version of the NightLoader which can actually be suitable for"
echo "| using in, for example, a hobbyist's operating system. This requires the"
echo "| current version of the NightLoader as an argument. See: Example [11]"
echo " "
echo "Additional options:"
echo "| -q : Disable as much output as possible"
echo "| -v : Output as much as possible; will be passed to all sub-commands"
echo " "
echo "Examples:"
echo "[1] \$ $1 all v0.1.0"
echo "[2] \$ $1 clean"
echo "[3] \$ $1 debug v0.1.0"
echo "[4] \$ $1 init all-depends"
echo "[5] \$ $1 init posix-uefi"
echo "[6] \$ $1 manual"
echo "[7] \$ $1 manual interactive"
echo "[8] \$ $1 manual list"
echo "[9] \$ $1 manual bios"
echo "[10] \$ $1 manual uefi"
echo "[11] \$ $1 release v0.1.0"
echo "[12] \$ $1 help # You obviously alreay know this. ^^"
}
print_manual() {
echo "TODO: Print Manual"
}
# START OF ACTION CHOOSER
case $1 in
"all")
build_all "$0"
;;
"clean")
clean_build_environment "$0"
;;
"debug")
build_debug "$0"
;;
"help")
print_help "$0"
;;
"init")
initialize_build_environment "$0"
;;
"manual")
print_manual "$0"
;;
"release")
build_release "$0"
;;
esac