cleanup: remove test programs/libraries
This commit is contained in:
@@ -1,74 +0,0 @@
|
||||
# Makefile for libhello shared library
|
||||
# Builds libhello.lib as an ELF shared object (ET_DYN).
|
||||
|
||||
# Target architecture.
|
||||
ARCH := x86_64
|
||||
|
||||
# Toolchain
|
||||
TOOLCHAIN_PREFIX := $(shell cd ../../.. && pwd)/toolchain/local/bin/x86_64-elf-
|
||||
CXX := $(TOOLCHAIN_PREFIX)g++
|
||||
LD := $(TOOLCHAIN_PREFIX)ld
|
||||
NM := $(TOOLCHAIN_PREFIX)nm
|
||||
STRIP := $(TOOLCHAIN_PREFIX)strip
|
||||
|
||||
# Compiler flags: freestanding, no stdlib
|
||||
# Build as PIC so the final ET_DYN image can be relocated by the kernel loader.
|
||||
override CXXFLAGS := \
|
||||
-std=gnu++20 \
|
||||
-g -O2 -pipe \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-nostdinc \
|
||||
-ffreestanding \
|
||||
-fno-stack-protector \
|
||||
-fno-stack-check \
|
||||
-fPIC \
|
||||
-fno-rtti \
|
||||
-fno-exceptions \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-m64 \
|
||||
-march=x86-64 \
|
||||
-mno-80387 \
|
||||
-mno-mmx \
|
||||
-mno-red-zone \
|
||||
-mcmodel=small \
|
||||
-I ../../include \
|
||||
-isystem ../../include/libc \
|
||||
-isystem ../../include/montauk \
|
||||
-isystem ../../include/gui \
|
||||
-isystem ../../../kernel/freestnd-c-hdrs/x86_64/include \
|
||||
-isystem ../../../kernel/freestnd-cxx-hdrs/x86_64/include
|
||||
|
||||
# Linker flags for a bare-metal ELF shared object.
|
||||
override LDFLAGS := \
|
||||
-shared \
|
||||
--build-id=none \
|
||||
--hash-style=sysv \
|
||||
-m elf_x86_64 \
|
||||
-z max-page-size=0x1000
|
||||
|
||||
# Output
|
||||
OUTDIR := ../../bin/os
|
||||
LIBNAME := libhello
|
||||
LIBSRC := src/libhello.cpp
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(OUTDIR)/$(LIBNAME).lib
|
||||
|
||||
$(OUTDIR):
|
||||
mkdir -p $@
|
||||
|
||||
src/libhello.o: src/libhello.cpp Makefile | $(OUTDIR)
|
||||
$(CXX) $(CXXFLAGS) -c src/libhello.cpp -o $@
|
||||
|
||||
src/stb_truetype_impl.o: src/stb_truetype_impl.cpp Makefile | $(OUTDIR)
|
||||
$(CXX) $(CXXFLAGS) -c src/stb_truetype_impl.cpp -o $@
|
||||
|
||||
$(OUTDIR)/$(LIBNAME).lib: src/libhello.o src/stb_truetype_impl.o
|
||||
rm -f $(OUTDIR)/$(LIBNAME).lib.sym
|
||||
$(LD) $(LDFLAGS) src/libhello.o src/stb_truetype_impl.o -o $@
|
||||
|
||||
clean:
|
||||
rm -rf ../../bin/os/$(LIBNAME).lib ../../bin/os/$(LIBNAME).lib.sym src/libhello.o src/stb_truetype_impl.o
|
||||
@@ -1,13 +0,0 @@
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x400000;
|
||||
.text : {
|
||||
*(.text)
|
||||
}
|
||||
.eh_frame : {
|
||||
*(.eh_frame)
|
||||
}
|
||||
.rodata : {
|
||||
*(.rodata)
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* libhello.cpp
|
||||
* Sample shared GUI library for MontaukOS
|
||||
* Creates a window and renders text as a demo of the shared library + GUI system
|
||||
* Copyright (c) 2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
#include <montauk/syscall.h>
|
||||
#include <gui/truetype.hpp>
|
||||
|
||||
// Heap allocation test - allocates, writes, reads, frees
|
||||
// Returns 0 on success, -1 on failure
|
||||
extern "C" int hello_malloc_test() {
|
||||
// Test 1: Allocate 256 bytes
|
||||
void* buf = montauk::malloc(256);
|
||||
if (!buf) {
|
||||
montauk::print(" [libhello] malloc(256) failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Test 2: Write a pattern and verify it
|
||||
uint8_t* bytes = (uint8_t*)buf;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
bytes[i] = (uint8_t)(i & 0xFF);
|
||||
}
|
||||
for (int i = 0; i < 256; i++) {
|
||||
if (bytes[i] != (uint8_t)(i & 0xFF)) {
|
||||
montauk::print(" [libhello] read verification failed\n");
|
||||
montauk::mfree(buf);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
montauk::mfree(buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int hello_run() {
|
||||
// Create window
|
||||
static constexpr int kInitialWidth = 320;
|
||||
static constexpr int kInitialHeight = 200;
|
||||
static constexpr uint32_t kBackgroundColor = 0xFFFFFFFF;
|
||||
montauk::abi::WinCreateResult wres;
|
||||
if (montauk::win_create("libhello Demo", kInitialWidth, kInitialHeight, &wres) < 0 || wres.id < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int winId = wres.id;
|
||||
uint32_t* pixels = (uint32_t*)(uintptr_t)wres.pixelVa;
|
||||
int width = kInitialWidth;
|
||||
int height = kInitialHeight;
|
||||
|
||||
gui::TrueTypeFont* font = (gui::TrueTypeFont*)montauk::malloc(sizeof(gui::TrueTypeFont));
|
||||
if (!font) {
|
||||
montauk::win_destroy(winId);
|
||||
return -1;
|
||||
}
|
||||
montauk::memset(font, 0, sizeof(gui::TrueTypeFont));
|
||||
if (!font->init("0:/fonts/Roboto-Medium.ttf")) {
|
||||
montauk::mfree(font);
|
||||
montauk::win_destroy(winId);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Simple render - fill with a color pattern
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
pixels[y * width + x] = kBackgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
// Render text using TrueType
|
||||
gui::Color text_color;
|
||||
text_color.r = 0x11;
|
||||
text_color.g = 0x11;
|
||||
text_color.b = 0x11;
|
||||
text_color.a = 255;
|
||||
font->draw_to_buffer(pixels, width, height, 20, 20, "Hello from libhello!", text_color, 16);
|
||||
|
||||
// Present the initial frame
|
||||
montauk::win_present(winId);
|
||||
|
||||
// Event loop
|
||||
while (true) {
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = montauk::win_poll(winId, &ev);
|
||||
|
||||
if (r < 0) {
|
||||
break;
|
||||
}
|
||||
if (r == 0) {
|
||||
montauk::sleep_ms(16);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ev.type == 3) { // close
|
||||
break;
|
||||
}
|
||||
if (ev.type == 2) { // resize
|
||||
width = ev.resize.w;
|
||||
height = ev.resize.h;
|
||||
pixels = (uint32_t*)(uintptr_t)montauk::win_resize(winId, width, height);
|
||||
|
||||
// Re-render on resize
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
pixels[y * width + x] = kBackgroundColor;
|
||||
}
|
||||
}
|
||||
font->draw_to_buffer(pixels, width, height, 20, 20, "Hello from libhello!", text_color, 16);
|
||||
montauk::win_present(winId);
|
||||
}
|
||||
}
|
||||
|
||||
montauk::win_destroy(winId);
|
||||
montauk::mfree(font);
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* stb_truetype_impl.cpp
|
||||
* Single compilation unit for stb_truetype in libhello
|
||||
* Copyright (c) 2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <montauk/heap.h>
|
||||
#include <montauk/string.h>
|
||||
#include <gui/stb_math.h>
|
||||
|
||||
#define STBTT_ifloor(x) ((int) stb_floor(x))
|
||||
#define STBTT_iceil(x) ((int) stb_ceil(x))
|
||||
#define STBTT_sqrt(x) stb_sqrt(x)
|
||||
#define STBTT_pow(x,y) stb_pow(x,y)
|
||||
#define STBTT_fmod(x,y) stb_fmod(x,y)
|
||||
#define STBTT_cos(x) stb_cos(x)
|
||||
#define STBTT_acos(x) stb_acos(x)
|
||||
#define STBTT_fabs(x) stb_fabs(x)
|
||||
|
||||
#define STBTT_malloc(x,u) ((void)(u), montauk::malloc(x))
|
||||
#define STBTT_free(x,u) ((void)(u), montauk::mfree(x))
|
||||
|
||||
#define STBTT_memcpy(d,s,n) montauk::memcpy(d,s,n)
|
||||
#define STBTT_memset(d,v,n) montauk::memset(d,v,n)
|
||||
|
||||
#define STBTT_strlen(x) montauk::slen(x)
|
||||
|
||||
#define STBTT_assert(x) ((void)(x))
|
||||
|
||||
#define STB_TRUETYPE_IMPLEMENTATION
|
||||
#include <gui/stb_truetype.h>
|
||||
Binary file not shown.
@@ -1,66 +0,0 @@
|
||||
# Makefile for libmath shared library
|
||||
# Builds libmath.lib as an ELF shared object (ET_DYN).
|
||||
|
||||
# Target architecture.
|
||||
ARCH := x86_64
|
||||
|
||||
# Toolchain
|
||||
TOOLCHAIN_PREFIX := $(shell cd ../../.. && pwd)/toolchain/local/bin/x86_64-elf-
|
||||
CXX := $(TOOLCHAIN_PREFIX)g++
|
||||
LD := $(TOOLCHAIN_PREFIX)ld
|
||||
NM := $(TOOLCHAIN_PREFIX)nm
|
||||
STRIP := $(TOOLCHAIN_PREFIX)strip
|
||||
|
||||
# Compiler flags: freestanding, no stdlib
|
||||
# Build as PIC so the final ET_DYN image can be relocated by the kernel loader.
|
||||
override CXXFLAGS := \
|
||||
-std=gnu++20 \
|
||||
-g -O2 -pipe \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-nostdinc \
|
||||
-ffreestanding \
|
||||
-fno-stack-protector \
|
||||
-fno-stack-check \
|
||||
-fPIC \
|
||||
-fno-rtti \
|
||||
-fno-exceptions \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-m64 \
|
||||
-march=x86-64 \
|
||||
-mno-80387 \
|
||||
-mno-mmx \
|
||||
-mno-sse \
|
||||
-mno-sse2 \
|
||||
-mno-red-zone \
|
||||
-mcmodel=small \
|
||||
-I ../../include \
|
||||
-isystem ../../include/libc \
|
||||
-isystem ../../include/montauk
|
||||
|
||||
# Linker flags for a bare-metal ELF shared object.
|
||||
override LDFLAGS := \
|
||||
-shared \
|
||||
--build-id=none \
|
||||
--hash-style=sysv \
|
||||
-m elf_x86_64 \
|
||||
-z max-page-size=0x1000
|
||||
|
||||
# Output
|
||||
OUTDIR := ../../bin/os
|
||||
LIBNAME := libmath
|
||||
LIBSRC := src/libmath.cpp
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(OUTDIR)/$(LIBNAME).lib
|
||||
|
||||
$(OUTDIR)/$(LIBNAME).lib: $(LIBSRC) Makefile
|
||||
@mkdir -p $(OUTDIR)
|
||||
rm -f $(OUTDIR)/$(LIBNAME).lib.sym
|
||||
$(CXX) $(CXXFLAGS) -c $(LIBSRC) -o src/libmath.o
|
||||
$(LD) $(LDFLAGS) src/libmath.o -o $@
|
||||
|
||||
clean:
|
||||
rm -rf ../../bin/os/$(LIBNAME).lib ../../bin/os/$(LIBNAME).lib.sym src/libmath.o
|
||||
@@ -1,10 +0,0 @@
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x400000;
|
||||
.text : {
|
||||
*(.text)
|
||||
}
|
||||
.eh_frame : {
|
||||
*(.eh_frame)
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* libmath.cpp
|
||||
* Sample shared math library for MontaukOS
|
||||
* Copyright (c) 2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
|
||||
// Basic math functions
|
||||
|
||||
int math_add(int a, int b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
int math_sub(int a, int b) {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
int math_mul(int a, int b) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
int math_div(int a, int b) {
|
||||
if (b == 0) return 0;
|
||||
return a / b;
|
||||
}
|
||||
|
||||
int math_mod(int a, int b) {
|
||||
if (b == 0) return 0;
|
||||
return a % b;
|
||||
}
|
||||
|
||||
// Comparison
|
||||
int math_max(int a, int b) {
|
||||
return (a > b) ? a : b;
|
||||
}
|
||||
|
||||
int math_min(int a, int b) {
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
int math_abs(int a) {
|
||||
return (a < 0) ? -a : a;
|
||||
}
|
||||
|
||||
// Utility
|
||||
int math_pow(int base, int exp) {
|
||||
int result = 1;
|
||||
for (int i = 0; i < exp; i++) {
|
||||
result *= base;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
Binary file not shown.
Reference in New Issue
Block a user