From 30ff7be0e40c38104b94d5a0ded01c8d433ad389 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 15 Jun 2019 02:34:39 -0500 Subject: [PATCH] [ox] Make code only compile as PIC if a bare metal build --- deps/ox/CMakeLists.txt | 1 + deps/ox/src/ox/fs/CMakeLists.txt | 15 +++++++-------- deps/ox/src/ox/fs/filesystem/filesystem.hpp | 2 +- deps/ox/src/ox/mc/CMakeLists.txt | 14 ++++++++------ deps/ox/src/ox/model/CMakeLists.txt | 14 ++++++++------ deps/ox/src/ox/std/CMakeLists.txt | 14 ++++++++------ 6 files changed, 33 insertions(+), 27 deletions(-) diff --git a/deps/ox/CMakeLists.txt b/deps/ox/CMakeLists.txt index e9908a33..a15dc707 100644 --- a/deps/ox/CMakeLists.txt +++ b/deps/ox/CMakeLists.txt @@ -8,6 +8,7 @@ include(address_sanitizer) set(OX_BUILD_EXEC "ON" CACHE STRING "Build executables (ON/OFF)") set(OX_RUN_TESTS "ON" CACHE STRING "Run tests (ON/OFF)") set(OX_USE_STDLIB "ON" CACHE STRING "Build libraries that need the std lib (ON/OFF)") +set(OX_BARE_METAL FALSE CACHE STRING "Bare metal build (TRUE/FALSE)") # can't run tests without building them if(OX_BUILD_EXEC STREQUAL "OFF" OR OX_USE_STDLIB STREQUAL "OFF") diff --git a/deps/ox/src/ox/fs/CMakeLists.txt b/deps/ox/src/ox/fs/CMakeLists.txt index d879fae1..9caea74c 100644 --- a/deps/ox/src/ox/fs/CMakeLists.txt +++ b/deps/ox/src/ox/fs/CMakeLists.txt @@ -9,12 +9,18 @@ add_library( filesystem/passthroughfs.cpp ) -if(OX_USE_STDLIB) +if(NOT OX_BARE_METAL) target_link_libraries( OxFS PUBLIC $<$:c++fs> $<$:stdc++fs> ) + set_property( + TARGET + OxFS + PROPERTY + POSITION_INDEPENDENT_CODE ON + ) endif() target_link_libraries( @@ -22,13 +28,6 @@ target_link_libraries( OxMetalClaw ) -set_property( - TARGET - OxFS - PROPERTY - POSITION_INDEPENDENT_CODE ON -) - if(OX_BUILD_EXEC STREQUAL "ON") #add_executable( # oxfstool diff --git a/deps/ox/src/ox/fs/filesystem/filesystem.hpp b/deps/ox/src/ox/fs/filesystem/filesystem.hpp index 64b66900..8873435a 100644 --- a/deps/ox/src/ox/fs/filesystem/filesystem.hpp +++ b/deps/ox/src/ox/fs/filesystem/filesystem.hpp @@ -148,8 +148,8 @@ FileSystemTemplate::~FileSystemTemplate() { template Error FileSystemTemplate::format(void *buff, uint64_t buffSize) { oxReturnError(FileStore::format(buff, buffSize)); - FileStore fs(buff, buffSize); + constexpr auto rootDirInode = MaxValue / 2; Directory rootDir(fs, rootDirInode); oxReturnError(rootDir.init()); diff --git a/deps/ox/src/ox/mc/CMakeLists.txt b/deps/ox/src/ox/mc/CMakeLists.txt index c840220f..c9f6aa3b 100644 --- a/deps/ox/src/ox/mc/CMakeLists.txt +++ b/deps/ox/src/ox/mc/CMakeLists.txt @@ -11,12 +11,14 @@ target_link_libraries( OxStd ) -set_property( - TARGET - OxMetalClaw - PROPERTY - POSITION_INDEPENDENT_CODE ON -) +if(NOT OX_BARE_METAL) + set_property( + TARGET + OxMetalClaw + PROPERTY + POSITION_INDEPENDENT_CODE ON + ) +endif() install( FILES diff --git a/deps/ox/src/ox/model/CMakeLists.txt b/deps/ox/src/ox/model/CMakeLists.txt index 45a054c5..5d7d1ce5 100644 --- a/deps/ox/src/ox/model/CMakeLists.txt +++ b/deps/ox/src/ox/model/CMakeLists.txt @@ -9,12 +9,14 @@ target_link_libraries( OxStd ) -set_property( - TARGET - OxModel - PROPERTY - POSITION_INDEPENDENT_CODE ON -) +if(NOT OX_BARE_METAL) + set_property( + TARGET + OxModel + PROPERTY + POSITION_INDEPENDENT_CODE ON + ) +endif() install( FILES diff --git a/deps/ox/src/ox/std/CMakeLists.txt b/deps/ox/src/ox/std/CMakeLists.txt index 8d2629f7..e83e2ca2 100644 --- a/deps/ox/src/ox/std/CMakeLists.txt +++ b/deps/ox/src/ox/std/CMakeLists.txt @@ -11,12 +11,14 @@ add_library( trace.cpp ) -set_property( - TARGET - OxStd - PROPERTY - POSITION_INDEPENDENT_CODE ON -) +if(NOT OX_BARE_METAL) + set_property( + TARGET + OxStd + PROPERTY + POSITION_INDEPENDENT_CODE ON + ) +endif() target_link_libraries( OxStd PUBLIC