mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-08-03 17:26:08 -04:00
Ensure that tlib headers are not included in kernel
This commit is contained in:
parent
1884649766
commit
47266f5ed9
10
cpp.mk
10
cpp.mk
@ -36,10 +36,10 @@ COMMON_LINK_FLAGS=-lgcc
|
|||||||
|
|
||||||
KERNEL_LINK_FLAGS=$(COMMON_LINK_FLAGS) -T linker.ld
|
KERNEL_LINK_FLAGS=$(COMMON_LINK_FLAGS) -T linker.ld
|
||||||
|
|
||||||
LIB_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -mcmodel=small -fPIC -ffunction-sections -fdata-sections
|
TLIB_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -mcmodel=small -fPIC -ffunction-sections -fdata-sections -DTHOR_TLIB=yes
|
||||||
LIB_LINK_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -mcmodel=small -fPIC -Wl,-gc-sections
|
TLIB_LINK_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -mcmodel=small -fPIC -Wl,-gc-sections
|
||||||
|
|
||||||
PROGRAM_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -I../../tlib/include/ -I../../printf/include/ -static -L../../tlib/debug/ -ltlib -mcmodel=small -fPIC -DTHOR_PROGRAM
|
PROGRAM_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -I../../tlib/include/ -I../../printf/include/ -static -L../../tlib/debug/ -ltlib -mcmodel=small -fPIC -DTHOR_PROGRAM=yes
|
||||||
PROGRAM_LINK_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) $(COMMON_LINK_FLAGS) -static -L../../tlib/debug/ -mcmodel=small -fPIC -z max-page-size=0x1000 -T ../linker.ld
|
PROGRAM_LINK_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) $(COMMON_LINK_FLAGS) -static -L../../tlib/debug/ -mcmodel=small -fPIC -z max-page-size=0x1000 -T ../linker.ld
|
||||||
|
|
||||||
NO_COLOR=\x1b[0m
|
NO_COLOR=\x1b[0m
|
||||||
@ -133,12 +133,12 @@ define tlib_compile_cpp_folder
|
|||||||
|
|
||||||
debug/$(1)/%.cpp.d: $(1)/%.cpp
|
debug/$(1)/%.cpp.d: $(1)/%.cpp
|
||||||
@ mkdir -p debug/$(1)/
|
@ mkdir -p debug/$(1)/
|
||||||
@ $(CXX) $(LIB_FLAGS) -MM -MT debug/$(1)/$$*.cpp.o $(1)/$$*.cpp | sed -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $$@
|
@ $(CXX) $(TLIB_FLAGS) -MM -MT debug/$(1)/$$*.cpp.o $(1)/$$*.cpp | sed -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $$@
|
||||||
|
|
||||||
debug/$(1)/%.cpp.o: $(1)/%.cpp
|
debug/$(1)/%.cpp.o: $(1)/%.cpp
|
||||||
@ mkdir -p debug/$(1)/
|
@ mkdir -p debug/$(1)/
|
||||||
@ echo -e "$(MODE_COLOR)[debug]$(NO_COLOR) Compile (tlib) $(FILE_COLOR)$(1)/$$*.cpp$(NO_COLOR)"
|
@ echo -e "$(MODE_COLOR)[debug]$(NO_COLOR) Compile (tlib) $(FILE_COLOR)$(1)/$$*.cpp$(NO_COLOR)"
|
||||||
@ $(CXX) $(LIB_FLAGS) -c $$< -o $$@
|
@ $(CXX) $(TLIB_FLAGS) -c $$< -o $$@
|
||||||
|
|
||||||
folder_cpp_files := $(wildcard $(1)/*.cpp)
|
folder_cpp_files := $(wildcard $(1)/*.cpp)
|
||||||
folder_d_files := $$(folder_cpp_files:%.cpp=debug/%.cpp.d)
|
folder_d_files := $$(folder_cpp_files:%.cpp=debug/%.cpp.d)
|
||||||
|
33
tlib/include/tlib/config.hpp
Normal file
33
tlib/include/tlib/config.hpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//=======================================================================
|
||||||
|
// Copyright Baptiste Wicht 2013-2016.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
#ifndef TLIB_CONFIG_HPP
|
||||||
|
#define TLIB_CONFIG_HPP
|
||||||
|
|
||||||
|
namespace tlib {
|
||||||
|
|
||||||
|
constexpr bool is_thor_program(){
|
||||||
|
#ifdef THOR_PROGRAM
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool is_thor_lib(){
|
||||||
|
#ifdef THOR_TLIB
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end of namespace tlib
|
||||||
|
|
||||||
|
#define ASSERT_ONLY_THOR_PROGRAM static_assert(tlib::is_thor_program() || tlib::is_thor_lib(), __FILE__ " can only be used in Thor programs");
|
||||||
|
|
||||||
|
#endif
|
@ -14,6 +14,9 @@
|
|||||||
|
|
||||||
#include "tlib/stat_info.hpp"
|
#include "tlib/stat_info.hpp"
|
||||||
#include "tlib/statfs_info.hpp"
|
#include "tlib/statfs_info.hpp"
|
||||||
|
#include "tlib/config.hpp"
|
||||||
|
|
||||||
|
ASSERT_ONLY_THOR_PROGRAM
|
||||||
|
|
||||||
namespace tlib {
|
namespace tlib {
|
||||||
|
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
|
|
||||||
#include <types.hpp>
|
#include <types.hpp>
|
||||||
|
|
||||||
|
#include "tlib/config.hpp"
|
||||||
|
|
||||||
|
ASSERT_ONLY_THOR_PROGRAM
|
||||||
|
|
||||||
namespace tlib {
|
namespace tlib {
|
||||||
|
|
||||||
namespace graphics {
|
namespace graphics {
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
#include <expected.hpp>
|
#include <expected.hpp>
|
||||||
|
|
||||||
#include "tlib/ioctl_codes.hpp"
|
#include "tlib/ioctl_codes.hpp"
|
||||||
|
#include "tlib/config.hpp"
|
||||||
|
|
||||||
|
ASSERT_ONLY_THOR_PROGRAM
|
||||||
|
|
||||||
namespace tlib {
|
namespace tlib {
|
||||||
|
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
#define USERLIB_MALLOC_H
|
#define USERLIB_MALLOC_H
|
||||||
|
|
||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
|
#include "tlib/config.hpp"
|
||||||
|
|
||||||
|
ASSERT_ONLY_THOR_PROGRAM
|
||||||
|
|
||||||
void* operator new(uint64_t size);
|
void* operator new(uint64_t size);
|
||||||
void operator delete(void* p);
|
void operator delete(void* p);
|
||||||
|
@ -10,7 +10,10 @@
|
|||||||
|
|
||||||
#include <expected.hpp>
|
#include <expected.hpp>
|
||||||
|
|
||||||
#include "net_constants.hpp"
|
#include "tlib/net_constants.hpp"
|
||||||
|
#include "tlib/config.hpp"
|
||||||
|
|
||||||
|
ASSERT_ONLY_THOR_PROGRAM
|
||||||
|
|
||||||
namespace tlib {
|
namespace tlib {
|
||||||
|
|
||||||
|
@ -8,7 +8,9 @@
|
|||||||
#ifndef USER_PRINT_HPP
|
#ifndef USER_PRINT_HPP
|
||||||
#define USER_PRINT_HPP
|
#define USER_PRINT_HPP
|
||||||
|
|
||||||
//TODO Rename in console
|
#include "tlib/config.hpp"
|
||||||
|
|
||||||
|
ASSERT_ONLY_THOR_PROGRAM
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
#include <string.hpp>
|
#include <string.hpp>
|
||||||
|
|
||||||
#include "tlib/datetime.hpp"
|
#include "tlib/datetime.hpp"
|
||||||
|
#include "tlib/config.hpp"
|
||||||
|
|
||||||
|
ASSERT_ONLY_THOR_PROGRAM
|
||||||
|
|
||||||
namespace tlib {
|
namespace tlib {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user