Framework is now dynamically linked
This commit is contained in:
@@ -43,9 +43,12 @@ file(GLOB_RECURSE photon_libc_headers ${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/in
|
|||||||
|
|
||||||
file(GLOB photon_libc_crt
|
file(GLOB photon_libc_crt
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/machine/${machine}/crt*.s)
|
${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})
|
add_custom_target(crt ALL
|
||||||
target_compile_options(crt PRIVATE -c -ffreestanding -nostdlib)
|
DEPENDS ${photon_libc_crt}
|
||||||
|
COMMAND mx.clang -c -ffreestanding ${photon_libc_crt}
|
||||||
|
COMMENT "Generating CRT files")
|
||||||
|
|
||||||
file(GLOB platform_sources
|
file(GLOB platform_sources
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/*.c
|
${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_sources ${photon_libc_sources} ${malloc_sources} ${platform_sources})
|
||||||
set(photon_libc_headers ${photon_libc_headers} ${platform_headers})
|
set(photon_libc_headers ${photon_libc_headers} ${platform_headers})
|
||||||
|
|
||||||
add_framework(photon STATIC
|
add_framework(photon SHARED
|
||||||
BUNDLE_ID net.doorstuck.photon
|
BUNDLE_ID net.doorstuck.photon
|
||||||
SOURCES ${photon_libc_sources} ${photon_libc_headers}
|
SOURCES ${photon_libc_sources} ${photon_libc_headers}
|
||||||
HEADERS ${CMAKE_CURRENT_BINARY_DIR}/sysroot/usr/include/*)
|
HEADERS ${CMAKE_CURRENT_BINARY_DIR}/sysroot/usr/include/*)
|
||||||
|
|
||||||
bundle_compile_options(photon PRIVATE -ffreestanding -nostdlib -fPIC -fPIE)
|
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_link_frameworks(photon ${photon_platform_frameworks})
|
||||||
|
|
||||||
bundle_include_directories(photon PRIVATE
|
bundle_include_directories(photon PRIVATE
|
||||||
|
|||||||
@@ -23,9 +23,11 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct __io_file FILE;
|
typedef struct __io_file FILE;
|
||||||
|
|
||||||
extern FILE *stdin;
|
extern FILE *__get_stdio_file(int);
|
||||||
extern FILE *stdout;
|
|
||||||
extern FILE *stderr;
|
#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 *fopen(const char *path, const char *mode);
|
||||||
extern FILE *freopen(const char *path, const char *mode, FILE *fp);
|
extern FILE *freopen(const char *path, const char *mode, FILE *fp);
|
||||||
|
|||||||
@@ -1,19 +1,30 @@
|
|||||||
|
#include <stdio.h>
|
||||||
#include "sys/types.h"
|
#include "sys/types.h"
|
||||||
#include "__fio.h"
|
#include "__fio.h"
|
||||||
|
|
||||||
struct __io_file __stdin = {};
|
static struct __io_file __stdin = {};
|
||||||
struct __io_file __stdout = {};
|
static struct __io_file __stdout = {};
|
||||||
struct __io_file __stderr = {};
|
static struct __io_file __stderr = {};
|
||||||
|
|
||||||
struct __io_file *stdin = &__stdin;
|
|
||||||
struct __io_file *stdout = &__stdout;
|
|
||||||
struct __io_file *stderr = &__stderr;
|
|
||||||
|
|
||||||
static int flags_from_mode(const char *r)
|
static int flags_from_mode(const char *r)
|
||||||
{
|
{
|
||||||
return 0;
|
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)
|
void __fio_init(int in, int out, int err)
|
||||||
{
|
{
|
||||||
__stdin.fd = in;
|
__stdin.fd = in;
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
framework_path=$1
|
framework_path=$1
|
||||||
binary_dir=$2
|
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
|
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
|
cp -f $crt_file $out
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user