Framework is now dynamically linked

This commit is contained in:
Max Wash
2020-11-05 21:23:34 +00:00
parent 635059acc3
commit f7df90bc0f
4 changed files with 32 additions and 16 deletions

View File

@@ -43,9 +43,12 @@ file(GLOB_RECURSE photon_libc_headers ${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/in
file(GLOB photon_libc_crt
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/machine/${machine}/crt*.s)
message(STATUS "CRT files: ${photon_libc_crt}")
add_library(crt OBJECT ${photon_libc_crt})
target_compile_options(crt PRIVATE -c -ffreestanding -nostdlib)
add_custom_target(crt ALL
DEPENDS ${photon_libc_crt}
COMMAND mx.clang -c -ffreestanding ${photon_libc_crt}
COMMENT "Generating CRT files")
file(GLOB platform_sources
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/*.c
@@ -76,13 +79,13 @@ file(GLOB platform_headers
set(photon_libc_sources ${photon_libc_sources} ${malloc_sources} ${platform_sources})
set(photon_libc_headers ${photon_libc_headers} ${platform_headers})
add_framework(photon STATIC
add_framework(photon SHARED
BUNDLE_ID net.doorstuck.photon
SOURCES ${photon_libc_sources} ${photon_libc_headers}
HEADERS ${CMAKE_CURRENT_BINARY_DIR}/sysroot/usr/include/*)
bundle_compile_options(photon PRIVATE -ffreestanding -nostdlib -fPIC -fPIE)
bundle_link_libraries(photon ${photon_platform_libs})
bundle_link_libraries(photon ${photon_platform_libs} -ffreestanding)
bundle_link_frameworks(photon ${photon_platform_frameworks})
bundle_include_directories(photon PRIVATE

View File

@@ -23,9 +23,11 @@ extern "C" {
typedef struct __io_file FILE;
extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
extern FILE *__get_stdio_file(int);
#define stdin (__get_stdio_file(0))
#define stdout (__get_stdio_file(0))
#define stderr (__get_stdio_file(0))
extern FILE *fopen(const char *path, const char *mode);
extern FILE *freopen(const char *path, const char *mode, FILE *fp);

View File

@@ -1,19 +1,30 @@
#include <stdio.h>
#include "sys/types.h"
#include "__fio.h"
struct __io_file __stdin = {};
struct __io_file __stdout = {};
struct __io_file __stderr = {};
struct __io_file *stdin = &__stdin;
struct __io_file *stdout = &__stdout;
struct __io_file *stderr = &__stderr;
static struct __io_file __stdin = {};
static struct __io_file __stdout = {};
static struct __io_file __stderr = {};
static int flags_from_mode(const char *r)
{
return 0;
}
FILE *__get_stdio_file(int i)
{
switch (i) {
case 0:
return &__stdin;
case 1:
return &__stdout;
case 2:
return &__stderr;
default:
return NULL;
}
}
void __fio_init(int in, int out, int err)
{
__stdin.fd = in;

View File

@@ -3,9 +3,9 @@
framework_path=$1
binary_dir=$2
crt_files=$(find $binary_dir -name "crt*.s.o")
crt_files=$(find $binary_dir -name "crt*.o")
for crt_file in $crt_files; do
out="$framework_path/Binary/$(basename $crt_file .s.o).o"
out="$framework_path/bin/$(basename $crt_file .o).o"
cp -f $crt_file $out
done