Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dedicated Third Party Targets in Project Tree #132

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 8 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ else()
endif()


ADD_SUBDIRECTORY(src)
### Third party libraries/targets
ADD_SUBDIRECTORY(third_party)

ADD_SUBDIRECTORY(src)

########### INSTALLATION ############

Expand All @@ -226,39 +228,6 @@ file(GLOB TMP_CONFIG_HEADER_REL RELATIVE ${ETISS_ROOT} ${PROJECT_BINARY_DIR}/inc
set(ETISS_HEADER ${ETISS_HEADER} ${TMP_CONFIG_HEADER_REL})


include(FetchContent)
FetchContent_Declare(elfio_srcs
GIT_REPOSITORY https://github.com/serge1/ELFIO.git
GIT_TAG Release_3.6
)
if(NOT elfio_srcs_POPULATED)
FetchContent_Populate(elfio_srcs)
FetchContent_GetProperties(elfio_srcs)
endif()

### simpleini
FetchContent_Declare(simpleini_srcs
GIT_REPOSITORY https://github.com/brofield/simpleini.git
GIT_TAG v4.19
)
if(NOT simpleini_srcs_POPULATED)
FetchContent_Populate(simpleini_srcs)
FetchContent_GetProperties(simpleini_srcs)
endif()
add_library(simpleini OBJECT
"${simpleini_srcs_SOURCE_DIR}/ConvertUTF.c"
)
set_target_properties(simpleini PROPERTIES
PUBLIC_HEADER "${simpleini_srcs_SOURCE_DIR}/SimpleIni.h;${simpleini_srcs_SOURCE_DIR}/ConvertUTF.h"
)
target_include_directories(simpleini PUBLIC
$<BUILD_INTERFACE:${simpleini_srcs_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/simpleini>
)
install(TARGETS simpleini
PUBLIC_HEADER DESTINATION include/simpleini
)

### Doxyfile
set(ETISS_DOX_LOCATIONS ${ETISS_DOX_LOCATIONS} ${PROJECT_BINARY_DIR}/include)
set(ETISS_DOX_LOCATIONS ${ETISS_DOX_LOCATIONS} ${PROJECT_BINARY_DIR}/include_c)
Expand Down Expand Up @@ -382,9 +351,12 @@ TARGET_INCLUDE_DIRECTORIES(ETISS PUBLIC
"${PROJECT_SOURCE_DIR}/include_c"
"${PROJECT_BINARY_DIR}/include_c"
${INCGEN_INC_DIR}
${elfio_srcs_SOURCE_DIR}
)
TARGET_LINK_LIBRARIES(ETISS PUBLIC simpleini)
TARGET_LINK_LIBRARIES(ETISS PUBLIC
simpleini
elfio
pugixml
)

GENERATE_EXPORT_HEADER(ETISS
BASE_NAME ETISS_PLUGIN
Expand Down
93 changes: 12 additions & 81 deletions JITImpl/TCC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
# Version 0.2
#


project(TCCJIT)

set(ETISS_TCC_SELINUX OFF CACHE BOOL "Enable SELinux support in the TCC JIT engine")
add_library(${PROJECT_NAME} SHARED
TCCJIT.cpp
TCCJIT.h
Expand All @@ -47,16 +45,6 @@ add_library(${PROJECT_NAME} SHARED
unset(TCCJIT_ARCH)
if(UNIX)
set(TCCJIT_ARCH unix)

# Try to detect SELinux and check if it is active
execute_process(
COMMAND getenforce
OUTPUT_VARIABLE ETISS_TCC_GETENFORCE_OUT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(ETISS_TCC_GETENFORCE_OUT STREQUAL "Enforcing")
set(ETISS_TCC_SELINUX ON)
endif()
elseif(WIN32)
set(PREBUILT_TOOL_PKGS_DIR "${PROJECT_SOURCE_DIR}/../toolpkgs")
set(TCC_PKG tcc-0.9.27)
Expand All @@ -70,69 +58,12 @@ else()
message(ERROR "cannot build TCCJIT on this unknown system")
endif()

if(ETISS_TCC_SELINUX)
set(ETISS_TCC_CONFIGURE_ARGS ${ETISS_TCC_CONFIGURE_ARGS} --with-selinux)
endif()

if(${TCCJIT_ARCH} STREQUAL unix)
include(ExternalProject)

set(TCC_ADDITIONAL_CFLAGS "-Ofast -Wall")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(TCC_ADDITIONAL_CFLAGS "-Og -g -Wall")
endif()

set(TCCJIT_BINARY_DIR ${ETISS_BINARY_DIR}/include/jit/tcc)
set(TinyCC_LIBNAME ${CMAKE_STATIC_LIBRARY_PREFIX}tcc${CMAKE_STATIC_LIBRARY_SUFFIX})
set(TinyCC_STD_LIBNAME ${CMAKE_STATIC_LIBRARY_PREFIX}tcc1${CMAKE_STATIC_LIBRARY_SUFFIX})

ExternalProject_Add(TinyCC
GIT_REPOSITORY https://github.com/TinyCC/tinycc.git
GIT_TAG d0c26ba4e50a36779456af71b06ec01985e406e5
GIT_CONFIG advice.detachedHead=false # deliberately checkout a commit hash

CONFIGURE_COMMAND bash <SOURCE_DIR>/configure
--prefix=<TMP_DIR> # we do not care about TCC long term. Only stdlib will be installed manually
"--extra-cflags=-fPIC ${TCC_ADDITIONAL_CFLAGS}"
${ETISS_TCC_CONFIGURE_ARGS}

BUILD_COMMAND make -j ${CMAKE_BUILD_PARALLEL_LEVEL}
BUILD_BYPRODUCTS <BINARY_DIR>/${CMAKE_STATIC_LIBRARY_PREFIX}tcc${CMAKE_STATIC_LIBRARY_SUFFIX}
<BINARY_DIR>/include

INSTALL_COMMAND "" # we only need the standard library which can be copied
LIST(APPEND TCCJIT_ADDITIONAL_LIBRARIES
tcc
pthread
dl
)
ExternalProject_Get_Property(TinyCC BINARY_DIR SOURCE_DIR)
set(TinyCC_SOURCE_DIR ${SOURCE_DIR})
set(TinyCC_BINARY_DIR ${BINARY_DIR})

# Import tcc library from External Project
add_library(tcc STATIC IMPORTED GLOBAL)
set_property(TARGET tcc PROPERTY IMPORTED_LOCATION ${TinyCC_BINARY_DIR}/${TinyCC_LIBNAME})
set_property(TARGET tcc PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${TinyCC_SOURCE_DIR}>
)
target_link_libraries(${PROJECT_NAME} PUBLIC tcc pthread dl)
# Let TCCJIT depend on external TinyCC project to force a fetch
add_dependencies(${PROJECT_NAME} TinyCC)

###################################################################################################################
# TCC JIT stdlib
# Need to copy TCC's stdlib with headers manually, because they are only copied by TCC on `make install`.
# ETISS Build JIT:
add_custom_command(TARGET TinyCC POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${TinyCC_SOURCE_DIR}/include/" "${TCCJIT_BINARY_DIR}/../tcc_stdlib/"
COMMAND ${CMAKE_COMMAND} -E copy "${TinyCC_BINARY_DIR}/${TinyCC_STD_LIBNAME}"
"${TCCJIT_BINARY_DIR}/${TinyCC_STD_LIBNAME}"
VERBATIM
COMMENT "[TCC] Copy stdlib and headers to build JIT"
)
# ETISS install JIT:
install(DIRECTORY ${TCCJIT_BINARY_DIR} DESTINATION "include/jit/" FILES_MATCHING REGEX "\.a")
install(DIRECTORY ${TCCJIT_BINARY_DIR}/../tcc_stdlib DESTINATION "include/jit/" FILES_MATCHING REGEX "\.h")

ETISSPlugin(${PROJECT_NAME})

elseif(${TCCJIT_ARCH} STREQUAL win64)
if (EXISTS ${PROJECT_SOURCE_DIR}/${TCC_PKG}-win64-bin.tar.bz2)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${PROJECT_SOURCE_DIR}/${TCC_PKG}-win64-bin.zip
Expand Down Expand Up @@ -162,12 +93,9 @@ elseif(${TCCJIT_ARCH} STREQUAL win64)
)
endif()
add_custom_target(gen_tcclib DEPENDS "${PROJECT_BINARY_DIR}/tcc_win64/libtcc.lib")
install(FILES "${PROJECT_BINARY_DIR}/tcc_win64/libtcc/libtcc.h"
DESTINATION include)
install(FILES "${PROJECT_BINARY_DIR}/tcc_win64/libtcc.lib"
DESTINATION lib)
install(FILES "${PROJECT_BINARY_DIR}/tcc_win64/libtcc.dll"
DESTINATION lib)
install(FILES "${PROJECT_BINARY_DIR}/tcc_win64/libtcc/libtcc.h" DESTINATION include)
install(FILES "${PROJECT_BINARY_DIR}/tcc_win64/libtcc.lib" DESTINATION lib)
install(FILES "${PROJECT_BINARY_DIR}/tcc_win64/libtcc.dll" DESTINATION lib)
set(${ETISS_PROJECT_NAME}_ADDITIONAL_LIBRARIES ${${ETISS_PROJECT_NAME}_ADDITIONAL_LIBRARIES} ${PROJECT_BINARY_DIR}/tcc_win64/libtcc.lib)
set(${ETISS_PROJECT_NAME}_ADDITIONAL_PROJECT_FILES ${${ETISS_PROJECT_NAME}_ADDITIONAL_PROJECT_FILES} ${PROJECT_BINARY_DIR}/tcc_win64/libtcc/libtcc.def ${PROJECT_BINARY_DIR}/tcc_win64/libtcc.dll ${PROJECT_BINARY_DIR}/tcc_win64/libtcc.lib)
list(APPEND TCC_H_FILES "tcc/lib/libtcc1-64.a,${TCC_H_PATH}/lib/libtcc1-64.a")
Expand Down Expand Up @@ -231,9 +159,12 @@ if (NOT ${TCCJIT_ARCH} STREQUAL unix)
endforeach()
RegisterJITFiles("${TCC_H_FILES}")

ETISSPlugin(${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} PUBLIC ${TCCJIT_ADDITIONAL_LIBRARIES})
if(${TCCJIT_ARCH} STREQUAL win64)
add_dependencies(${PROJECT_NAME} gen_tcclib)
endif()
endif()


target_link_libraries(${PROJECT_NAME} PUBLIC ${TCCJIT_ADDITIONAL_LIBRARIES})

ETISSPlugin(${PROJECT_NAME})
4 changes: 4 additions & 0 deletions include/etiss/VirtualStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
#include "etiss/Misc.h"
#include "etiss/fault/Injector.h"

#include "etiss/fault/Trigger.h"
#include "etiss/fault/Action.h"
#include "etiss/fault/Fault.h"

#include <cstddef>

#include <memory>
Expand Down
11 changes: 2 additions & 9 deletions include/etiss/fault/Action.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,12 @@
#include <stdint.h>

#ifndef NO_ETISS
#include "etiss/Misc.h"
#include "etiss/fault/Defs.h"
#include "etiss/fault/Fault.h"
#include "etiss/fault/InjectorAddress.h"
#include "etiss/fault/XML.h"
#else
#include "fault/Defs.h"
#include "fault/Fault.h"
#include "fault/InjectorAddress.h"
#include "fault/XML.h"
#endif

namespace etiss
Expand All @@ -73,6 +70,7 @@ namespace fault
{

class Fault;
class InjectorAddress;

class Action : public etiss::ToString
{
Expand Down Expand Up @@ -148,11 +146,6 @@ class Action : public etiss::ToString
namespace xml
{

template <>
bool parse<etiss::fault::Action>(pugi::xml_node node, etiss::fault::Action &f, Diagnostics &diag);
template <>
bool write<etiss::fault::Action>(pugi::xml_node node, const etiss::fault::Action &f, Diagnostics &diag);

} // namespace xml

#endif
Expand Down
17 changes: 2 additions & 15 deletions include/etiss/fault/Fault.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,10 @@
#include <vector>

#ifndef NO_ETISS
#include "etiss/fault/Action.h"
#include "etiss/Misc.h"
#include "etiss/fault/Defs.h"
#include "etiss/fault/Trigger.h"
#include "etiss/fault/XML.h"
#else
#include "fault/Action.h"
#include "fault/Defs.h"
#include "fault/Trigger.h"
#include "fault/XML.h"
#endif

/// if true then mutex will be used to create unique ids for faults in a threadsafe way
Expand All @@ -83,6 +78,7 @@ namespace fault
typedef uint64_t INT;

class Action;
class Trigger;

class Fault : public etiss::ToString
{
Expand All @@ -103,18 +99,9 @@ class Fault : public etiss::ToString

#if ETISS_FAULT_XML

bool parseXML(std::vector<Fault> &vec, std::istream &input, std::ostream &diagnostics_out = std::cout);

bool writeXML(const std::vector<Fault> &vec, std::ostream &out, std::ostream &diagnostics_out = std::cout);

namespace xml
{

template <>
bool parse<etiss::fault::Fault>(pugi::xml_node node, etiss::fault::Fault &f, Diagnostics &diag);
template <>
bool write<etiss::fault::Fault>(pugi::xml_node node, const etiss::fault::Fault &f, Diagnostics &diag);

} // namespace xml

#endif
Expand Down
10 changes: 8 additions & 2 deletions include/etiss/fault/Injector.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@
#define ETISS_INJECTOR_H_

#ifndef NO_ETISS
#include "etiss/fault/Fault.h"
#include "etiss/Misc.h"
#include "etiss/fault/Defs.h"
#include "etiss/fault/Misc.h"
#else
#include "fault/Fault.h"
#include "fault/Defs.h"
#include "fault/Misc.h"
#endif

#if CXX0X_UP_SUPPORTED
Expand All @@ -73,6 +76,9 @@ namespace fault
{

class Stressor;
class Fault;
class Trigger;
class Action;

class Injector
{
Expand Down
15 changes: 1 addition & 14 deletions include/etiss/fault/InjectorAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@
#ifndef NO_ETISS
#include "etiss/Misc.h"
#include "etiss/fault/Defs.h"
#include "etiss/fault/XML.h"
#else
#include "fault/Defs.h"
#include "fault/XML.h"
#endif

namespace etiss
Expand Down Expand Up @@ -100,18 +98,7 @@ class InjectorAddress : public etiss::ToString
namespace xml
{

template <>
bool parse<etiss::fault::InjectorAddress>(pugi::xml_node node, etiss::fault::InjectorAddress &dst, Diagnostics &diag);
template <>
bool write<etiss::fault::InjectorAddress>(pugi::xml_node node, const etiss::fault::InjectorAddress &src,
Diagnostics &diag);

template <>
bool parse<etiss::fault::InjectorAddress *>(pugi::xml_node node, etiss::fault::InjectorAddress *&dst,
Diagnostics &diag);
template <>
bool write<const etiss::fault::InjectorAddress *>(pugi::xml_node node, const etiss::fault::InjectorAddress *const &src,
Diagnostics &diag);


} // namespace xml

Expand Down
Loading