From 236963e7563be3e3f8220dac7bb4af446928e194 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 24 Jun 2024 22:55:29 -0400 Subject: Clean out for expt Signed-off-by: Ian Moffett --- tools/cross.sh | 164 ------------------------------------------------- tools/kconf/.gitignore | 4 -- tools/kconf/Makefile | 9 --- tools/kconf/grammer.y | 86 -------------------------- tools/kconf/scan.l | 60 ------------------ tools/ksyms | 12 ---- tools/meta-rip | 46 -------------- tools/sysexport | 32 ---------- tools/update-copyright | 11 ---- 9 files changed, 424 deletions(-) delete mode 100644 tools/cross.sh delete mode 100644 tools/kconf/.gitignore delete mode 100644 tools/kconf/Makefile delete mode 100644 tools/kconf/grammer.y delete mode 100644 tools/kconf/scan.l delete mode 100755 tools/ksyms delete mode 100755 tools/meta-rip delete mode 100755 tools/sysexport delete mode 100755 tools/update-copyright (limited to 'tools') diff --git a/tools/cross.sh b/tools/cross.sh deleted file mode 100644 index 52e7b1b..0000000 --- a/tools/cross.sh +++ /dev/null @@ -1,164 +0,0 @@ -#!/bin/bash - -# -# Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of Hyra nor the names of its contributors may be used -# to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -################################################################ -# Toolchain configuration -################################################################ - -set -e - -if [ "$1" == "amd64" ] -then - TARGET="x86_64-hyra" -else - TARGET="$1-elf" -fi - -BINUTILS_VERSION=2.42 -GCC_VERSION=13.2.0 -BINUTILS_NAME="binutils-$BINUTILS_VERSION" -BINUTILS_TARBALL="$BINUTILS_NAME.tar.xz" -BINUTILS_URL="https://ftp.gnu.org/gnu/binutils/$BINUTILS_TARBALL" -GCC_NAME="gcc-$GCC_VERSION" -GCC_TARBALL="$GCC_NAME.tar.xz" -GCC_URL="https://ftp.gnu.org/gnu/gcc/gcc-$GCC_VERSION/$GCC_TARBALL" - -# Remove debugging information, it takes up a lot of space -export CFLAGS="-g0" -export CXXFLAGS="-g0" - -# System-dependent configuration -SYSTEM_NAME="$(uname -s)" -MAKE="make" -NPROC="nproc" -if [ "$SYSTEM_NAME" = "OpenBSD" ]; then - MAKE="gmake" - NPROC="sysctl -n hw.ncpuonline" -elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then - MAKE="gmake" - NPROC="sysctl -n hw.ncpu" -elif [ "$SYSTEM_NAME" = "Darwin" ]; then - NPROC="sysctl -n hw.ncpu" -fi -CORES="$($NPROC)" - -# Set build paths -PREFIX="$(pwd)/cross" -export PATH="$PREFIX/bin:$PATH" - -# Create build directory -mkdir -p "$PREFIX/build" -cd "$PREFIX/build" - -################################################################ -# Download and extract sources -################################################################ - -if [ ! -f $BINUTILS_TARBALL ]; then - echo "Downloading binutils..." - curl $BINUTILS_URL -o $BINUTILS_TARBALL -fi -if [ ! -f $GCC_TARBALL ]; then - echo "Downloading gcc..." - curl $GCC_URL -o $GCC_TARBALL -fi - -echo "Extracting binutils..." -rm -rf $BINUTILS_NAME -tar -xf $BINUTILS_TARBALL -echo "Extracting gcc..." -rm -rf $GCC_NAME -tar -xf $GCC_TARBALL - -################################################################ -# Build packages -################################################################ - -echo "Removing previous builds..." -rm -rf build-gcc build-binutils - -# Binutils build -clear -mkdir build-binutils - -echo "Applying binutils patch" -cp -r $BINUTILS_NAME $BINUTILS_NAME-copy -patch -s -p0 < ../../builddeps/binutils.patch -rm -rf $BINUTILS_NAME-copy - -echo "Configuring $BINUTILS_NAME..." -cd build-binutils -../$BINUTILS_NAME/configure --target="$TARGET" --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror --enable-targets=all -echo "Building $BINUTILS_NAME..." -$MAKE -j$CORES -echo "Installing $BINUTILS_NAME..." -$MAKE install -echo "Cleaning $BINUTILS_NAME..." -cd .. -rm -rf $BINUTILS_NAME build-binutils - -# GCC build -clear -echo "Downloading prerequisites for $GCC_NAME..." -cd $GCC_NAME -contrib/download_prerequisites -cd .. - -echo "Applying GCC patch" -cp -r $GCC_NAME $GCC_NAME-copy -patch -s -p0 < ../../builddeps/gcc.patch -rm -rf $GCC_NAME-copy - -echo "Configuring $GCC_NAME..." -mkdir build-gcc -cd build-gcc -../$GCC_NAME/configure --target="$TARGET" --with-sysroot=/ --prefix="$PREFIX" --disable-nls --enable-languages=c,c++,lto --disable-multilib -echo "Building all-gcc..." -$MAKE all-gcc -j"$CORES" -echo "Building all-target-libgcc..." -$MAKE all-target-libgcc -j"$CORES" -echo "Installing $GCC_NAME..." -$MAKE install-gcc -echo "Installing target-libgcc..." -$MAKE install-target-libgcc -echo "Cleaning $GCC_NAME..." -cd .. -rm -rf $GCC_NAME build-gcc - -################################################################ -# Cleanup -################################################################ - -clear -"$TARGET"-ld -v -"$TARGET"-gcc --version | head -n1 -echo "Build complete, binaries are in $PREFIX" -echo "Finished in $(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds" diff --git a/tools/kconf/.gitignore b/tools/kconf/.gitignore deleted file mode 100644 index 4b51a2a..0000000 --- a/tools/kconf/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.tab.c -*.tab.h -*.yy.c -kconf diff --git a/tools/kconf/Makefile b/tools/kconf/Makefile deleted file mode 100644 index c6df7ee..0000000 --- a/tools/kconf/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -kconf: - bison -d grammer.y - flex scan.l - gcc lex.yy.c grammer.tab.c -lfl -o kconf - -clean: - rm grammer.tab.* - rm lex.yy.c - rm kconf diff --git a/tools/kconf/grammer.y b/tools/kconf/grammer.y deleted file mode 100644 index 2f131fc..0000000 --- a/tools/kconf/grammer.y +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -%{ -#include -#include - -int yylex(); -int yyerror(char *s); -%} - -%union { - char *str; - int num; -} - -%token OPTION SETVAL -%token IDENTIFIER -%token YES NO -%token NUMBER STRING - -%type str STRING -%type yes_or_no YES NO -%type num NUMBER - -%% - -input: - | line input - ; - -line: OPTION IDENTIFIER yes_or_no { - printf("-D__%s=%d ", $2, $3); - free($2); - } - | SETVAL IDENTIFIER num { - printf("-D__%s=%d " , $2, $3); - free($2); - } - | SETVAL IDENTIFIER str { - printf("-D__%s=%s ", $2, $3); - free($2); - free($3); - } - -yes_or_no: YES { $$ = 1; } - | NO { $$ = 0; } - ; - -num: NUMBER { $$ = $1; } -str: STRING { $$ = $1; } - -%% - -int -main(void) -{ - yyparse(); - printf("\n"); -} diff --git a/tools/kconf/scan.l b/tools/kconf/scan.l deleted file mode 100644 index e416241..0000000 --- a/tools/kconf/scan.l +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -%{ - #include - #include - #include "grammer.tab.h" - - int yyerror(char *e); -%} - -%% - -"option" { return OPTION; } -"setval" { return SETVAL; } -"yes" { return YES; } -"no" { return NO; } -\"([^\"])*\" { yylval.str = strdup(yytext); return STRING; } -[a-zA-Z_][a-zA-Z0-9_]+ { yylval.str = strdup(yytext); return IDENTIFIER; } -[0-9]+ { yylval.num = atoi(yytext); return NUMBER; } -[ \t] { /* Ignore */ } -[\/\/.*] { /* Ignore */ } -\n { /* IGnore */ } -"//".* { /* Ignore */ } -. { /* Ignore */ } - -%% - -int -yyerror(char *e) -{ - printf("\n** kconf: %s **", e); - return 0; -} diff --git a/tools/ksyms b/tools/ksyms deleted file mode 100755 index 643c3e1..0000000 --- a/tools/ksyms +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -rm -f $1 -printf "#ifndef _KSYMS_H_\n" > $1 -printf "#define _KSYMS_H_\n\n" >> $1 -printf "#include \n\nstruct kernel_symbol" >> $1 -printf " {\n\tuint64_t addr;\n\tchar* name;\n};\n\n" >> $1 -printf "const struct kernel_symbol g_ksym_table[] = {\n" >> $1 -nm $2 | grep " [tT] " | awk '{ print " { .addr = 0x"$1", .name = \""$3"\" }," }' | sort >> $1 -printf " { .addr = (size_t)-1, .name = \"\" }\n};\n\n" >> $1 -printf "const int ksym_elem_count = sizeof(g_ksym_table) / sizeof(*g_ksym_table);\n" >> $1 -printf "\n#endif /* !_KSYMS_H_ */\n" >> $1 diff --git a/tools/meta-rip b/tools/meta-rip deleted file mode 100755 index 45e811f..0000000 --- a/tools/meta-rip +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -if [[ ! -f $1 ]] -then - echo "File not found: $1" - exit -fi - -readelf -S $1 | grep -q "\.meta\.note" > /dev/null -if [ $? -ne 0 ] -then - echo "No metadata in ELF; '.meta.note' non-existent" - exit -fi - -meta=$(objcopy $1 /dev/null --dump-section .meta.note=/dev/stdout | cat | tr -d '\0') - -# Remove the leading and trailing '$' characters -meta=${meta#'$'} -meta=${meta%'$'} - -# Use regular expression to extract the cookie, filename, author, and description -if [[ $meta =~ ^([^:]+):\s*([^,]+),\s*([^,]+),\s*(.*)$ ]]; then - cookie=${BASH_REMATCH[1]} - filename=${BASH_REMATCH[2]} - author=${BASH_REMATCH[3]} - description=${BASH_REMATCH[4]} - cookie=${cookie%?} # Remove the last character -fi - -if [[ $cookie != "Hyra" ]] -then - echo "Invalid cookie found!" - exit -fi - -# Trim leading spaces -cookie=$(echo "$cookie" | sed -e 's/^[[:space:]]*//') -filename=$(echo "$filename" | sed -e 's/^[[:space:]]*//') -author=$(echo "$author" | sed -e 's/^[[:space:]]*//') -description=$(echo "$description" | sed -e 's/^[[:space:]]*//') - -echo "Cookie: $cookie" -echo "Filename: $filename" -echo "Author: $author" -echo "Description: $description" diff --git a/tools/sysexport b/tools/sysexport deleted file mode 100755 index 8426e8d..0000000 --- a/tools/sysexport +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# To be ran during the build process to export -# system headers -# - -TARGET_DIR=lib/libc/include/sys -SYS_DIR=../../../../sys/include/sys - -if [ -f $TARGET_DIR/.sys_export ] -then - exit 0 -fi - -. builddeps/sysexports - -echo "Exporting sys headers..." -cd $TARGET_DIR - -for i in $sys_headers -do - if [ -s "$i" ] - then - echo "HEADER CONFLICT ($TARGET_DIR/$i)" - continue - fi - - echo "sys/include/sys/$i -> lib/libc/include/sys/$i" - echo include/sys/$i >>.sys_export - echo "$i" >>.gitignore - ln -sf $SYS_DIR/$i . -done diff --git a/tools/update-copyright b/tools/update-copyright deleted file mode 100755 index 0f2ba80..0000000 --- a/tools/update-copyright +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# Set the current year as a variable -current_year=$(date +"%Y") - -# Find all files in the sys/ directory and its subdirectories -find . -type f -print0 | while read -d $'\0' file -do - # Replace the old copyright notice with the new one - sed -i "s/\(Copyright (c) \)2023-[0-9]\{4\}\(.*\)/\12023-${current_year}\2/g" "${file}" -done -- cgit v1.2.3