mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 23:10:32 +00:00
Compare commits
4 commits
796640e329
...
ca40d0955a
Author | SHA1 | Date | |
---|---|---|---|
|
ca40d0955a | ||
|
a95d5559de | ||
|
5bd76304ec | ||
|
06a79a1a06 |
5 changed files with 98 additions and 30 deletions
33
meta/check_code.py
Executable file
33
meta/check_code.py
Executable file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
os.chdir(os.path.realpath(os.path.dirname(__file__))+'/../src')
|
||||||
|
|
||||||
|
for f in Path(os.getcwd()).glob('**/*'):
|
||||||
|
if not f.is_file():
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not os.path.basename(f).lower().endswith('.zc'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
contents = b''
|
||||||
|
with open(f, 'r+b') as file:
|
||||||
|
contents = file.read()
|
||||||
|
|
||||||
|
n = contents.find(b'\x05')
|
||||||
|
byte = contents[n]
|
||||||
|
|
||||||
|
if n == -1: continue
|
||||||
|
if contents[n-1] == 0 or contents[n-1] > 127: continue
|
||||||
|
if n+1 < len(contents) and contents[n+1] == 5: continue
|
||||||
|
if contents[n-1] <= 0x1F and (not contents[n-1] in b'\n\r'): continue
|
||||||
|
if n+1 < len(contents) and contents[n+1] <= 0x1F and (not contents[n+1] in b'\n\r'): continue
|
||||||
|
|
||||||
|
contents = contents[0:n:]
|
||||||
|
|
||||||
|
file.seek(0)
|
||||||
|
file.truncate()
|
||||||
|
file.write(contents)
|
||||||
|
|
8
meta/install_hooks.sh
Executable file
8
meta/install_hooks.sh
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
||||||
|
cd "${script_path}/.." || exit 1
|
||||||
|
|
||||||
|
mkdir -p .git/hooks
|
||||||
|
cp meta/pre-commit .git/hooks/.
|
||||||
|
|
25
meta/pre-commit
Executable file
25
meta/pre-commit
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
||||||
|
cd "${script_path}/.." || exit 1
|
||||||
|
pwd | grep -q '.git' && cd ..
|
||||||
|
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
FAILURES=0
|
||||||
|
|
||||||
|
set +e
|
||||||
|
|
||||||
|
echo "Running meta/check_code.sh"
|
||||||
|
if time meta/check_code.sh "$@" && git diff --exit-code; then
|
||||||
|
echo -e "[${GREEN}GOOD${NC}]: meta/check_code.sh"
|
||||||
|
else
|
||||||
|
echo -e "[${RED}FAIL${NC}]: meta/check_code.sh"
|
||||||
|
((FAILURES+=1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit "${FAILURES}"
|
|
@ -1,43 +1,40 @@
|
||||||
# Nuke built-in rules and variables.
|
# Nuke built-in rules and variables.
|
||||||
override MAKEFLAGS += -rR
|
MAKEFLAGS += -rR
|
||||||
|
.SUFFIXES:
|
||||||
|
|
||||||
# This is the name that our final executable will have.
|
# This is the name that our final executable will have.
|
||||||
# Change as needed.
|
# Change as needed.
|
||||||
override OUTPUT := kernel
|
override OUTPUT := kernel
|
||||||
|
|
||||||
# Convenience macro to reliably declare user overridable variables.
|
# Convenience macro to reliably declare user overridable variables.
|
||||||
define DEFAULT_VAR =
|
override USER_VARIABLE = $(if $(filter $(origin $(1)),default undefined),$(eval override $(1) := $(2)))
|
||||||
ifeq ($(origin $1),default)
|
|
||||||
override $(1) := $(2)
|
|
||||||
endif
|
|
||||||
ifeq ($(origin $1),undefined)
|
|
||||||
override $(1) := $(2)
|
|
||||||
endif
|
|
||||||
endef
|
|
||||||
|
|
||||||
# User controllable C compiler command.
|
# User controllable C compiler command.
|
||||||
override DEFAULT_KCC := cc
|
$(call USER_VARIABLE,KCC,cc)
|
||||||
$(eval $(call DEFAULT_VAR,KCC,$(DEFAULT_KCC)))
|
|
||||||
|
|
||||||
# User controllable linker command.
|
# User controllable linker command.
|
||||||
override DEFAULT_KLD := ld
|
$(call USER_VARIABLE,KLD,ld)
|
||||||
$(eval $(call DEFAULT_VAR,KLD,$(DEFAULT_KLD)))
|
|
||||||
|
|
||||||
# User controllable C flags.
|
# User controllable C flags.
|
||||||
override DEFAULT_KCFLAGS := -g -O2 -pipe
|
$(call USER_VARIABLE,KCFLAGS,-g -O2 -pipe)
|
||||||
$(eval $(call DEFAULT_VAR,KCFLAGS,$(DEFAULT_KCFLAGS)))
|
|
||||||
|
|
||||||
# User controllable C preprocessor flags. We set none by default.
|
# User controllable C preprocessor flags. We set none by default.
|
||||||
override DEFAULT_KCPPFLAGS :=
|
$(call USER_VARIABLE,KCPPFLAGS,)
|
||||||
$(eval $(call DEFAULT_VAR,KCPPFLAGS,$(DEFAULT_KCPPFLAGS)))
|
|
||||||
|
|
||||||
# User controllable nasm flags.
|
# User controllable nasm flags.
|
||||||
override DEFAULT_KNASMFLAGS := -F dwarf -g
|
$(call USER_VARIABLE,KNASMFLAGS,-F dwarf -g)
|
||||||
$(eval $(call DEFAULT_VAR,KNASMFLAGS,$(DEFAULT_KNASMFLAGS)))
|
|
||||||
|
|
||||||
# User controllable linker flags. We set none by default.
|
# User controllable linker flags. We set none by default.
|
||||||
override DEFAULT_KLDFLAGS :=
|
$(call USER_VARIABLE,KLDFLAGS,)
|
||||||
$(eval $(call DEFAULT_VAR,KLDFLAGS,$(DEFAULT_KLDFLAGS)))
|
|
||||||
|
# Check if KCC is Clang.
|
||||||
|
override KCC_IS_CLANG := $(shell ! $(KCC) --version 2>/dev/null | grep 'clang' >/dev/null 2>&1; echo $$?)
|
||||||
|
|
||||||
|
# If the C compiler is Clang, set the target as needed.
|
||||||
|
ifeq ($(KCC_IS_CLANG),1)
|
||||||
|
override KCC += \
|
||||||
|
-target x86_64-unknown-none
|
||||||
|
endif
|
||||||
|
|
||||||
# Internal C flags that should not be changed by the user.
|
# Internal C flags that should not be changed by the user.
|
||||||
override KCFLAGS += \
|
override KCFLAGS += \
|
||||||
|
|
|
@ -9,9 +9,10 @@ ENTRY(kmain)
|
||||||
/* process. */
|
/* process. */
|
||||||
PHDRS
|
PHDRS
|
||||||
{
|
{
|
||||||
text PT_LOAD;
|
requests PT_LOAD;
|
||||||
rodata PT_LOAD;
|
text PT_LOAD;
|
||||||
data PT_LOAD;
|
rodata PT_LOAD;
|
||||||
|
data PT_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
|
@ -22,6 +23,16 @@ SECTIONS
|
||||||
/* that is the beginning of the region. */
|
/* that is the beginning of the region. */
|
||||||
. = 0xffffffff80000000;
|
. = 0xffffffff80000000;
|
||||||
|
|
||||||
|
/* Define a section to contain the Limine requests and assign it to its own PHDR */
|
||||||
|
.requests : {
|
||||||
|
KEEP(*(.requests_start_marker))
|
||||||
|
KEEP(*(.requests))
|
||||||
|
KEEP(*(.requests_end_marker))
|
||||||
|
} :requests
|
||||||
|
|
||||||
|
/* Move to the next memory page for .text */
|
||||||
|
. = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
|
|
||||||
.text : {
|
.text : {
|
||||||
*(.text .text.*)
|
*(.text .text.*)
|
||||||
} :text
|
} :text
|
||||||
|
@ -38,12 +49,6 @@ SECTIONS
|
||||||
|
|
||||||
.data : {
|
.data : {
|
||||||
*(.data .data.*)
|
*(.data .data.*)
|
||||||
|
|
||||||
/* Place the sections that contain the Limine requests as part of the .data */
|
|
||||||
/* output section. */
|
|
||||||
KEEP(*(.requests_start_marker))
|
|
||||||
KEEP(*(.requests))
|
|
||||||
KEEP(*(.requests_end_marker))
|
|
||||||
} :data
|
} :data
|
||||||
|
|
||||||
/* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */
|
/* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */
|
||||||
|
|
Loading…
Reference in a new issue