Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 2.8)
project(clReflect)
cmake_minimum_required(VERSION 3.0)
project(clReflect] VERSION 0.5.12)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Add path for custom modules
set(CMAKE_MODULE_PATH
Expand Down Expand Up @@ -33,7 +36,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CL_REFLECT_LIB_DIRECTORY}")
file(MAKE_DIRECTORY "${CL_REFLECT_GEN_DIRECTORY}")

# Test for clang
if (CMAKE_CXX_COMPILER MATCHES ".*clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if (CMAKE_CXX_COMPILER MATCHES ".*clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_COMPILER_IS_CLANGXX 1)
endif ()

Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ add_subdirectory(clReflectCpp)
add_subdirectory(clReflectExport)
add_subdirectory(clReflectMerge)
add_subdirectory(clReflectScan)
add_subdirectory(clReflectTest)
#add_subdirectory(clReflectTest)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this absolutely necessary?

add_subdirectory(clReflectUtil)
5 changes: 5 additions & 0 deletions src/clReflectCore/DatabaseTextSerialiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ namespace
void cldb::WriteTextDatabase(const char* filename, const Database& db)
{
FILE* fp = fopen(filename, "w");
if( !fp )
{
printf("Failed to open database file for writing: %s\n", filename );
exit(1);
}

// Write the header
fputs("\nclReflect Database\n", fp);
Expand Down
2 changes: 1 addition & 1 deletion src/clReflectCpp/clcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ CLCPP_API void clcpp::internal::Assert(bool expression)
int 3h
}
#else
asm("int $0x3\n");
__builtin_debugtrap();
#endif // CLCPP_USING_MSVC

// Leave the program with no continuation
Expand Down
39 changes: 25 additions & 14 deletions src/clReflectScan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
set(LLVM_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../extern/llvm"
CACHE PATH "Path to LLVM source.")

set(LLVM_BUILD_DIR_PREDICTION "${CMAKE_CURRENT_SOURCE_DIR}/../../extern/llvm-build")
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
set(LLVM_BUILD_DIR_PREDICTION "${CMAKE_CURRENT_SOURCE_DIR}/../../extern/llvm-build-gnu")
endif (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
cmake_policy(SET CMP0057 NEW)

set(LLVM_BUILD_DIR ${LLVM_BUILD_DIR_PREDICTION}
CACHE PATH "Path to LLVM build.")
set( LLVM_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../extern/llvm-build-gnu/lib/cmake/llvm" )
set( CLANG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../extern/llvm-build-gnu/lib/cmake/clang" )

Include_directories("${LLVM_INSTALL_DIR}/include/")
include_directories("${LLVM_INSTALL_DIR}/tools/clang/include")
include_directories("${LLVM_BUILD_DIR}/include/")
include_directories("${LLVM_BUILD_DIR}/tools/clang/include")
find_package(LLVM REQUIRED CONFIG)
find_package(CLANG REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
message(STATUS "Found CLANG ${CLANG_PACKAGE_VERSION}")
message(STATUS "Using ClangConfig.cmake in: ${CLANG_DIR}")

if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
# GCC/Clang flags for stdint.h types
Expand All @@ -29,10 +28,19 @@ endif (MSVC)

link_directories("${LLVM_BASE_LIB_DIR}")

## LLVM
include_directories(${LLVM_INCLUDE_DIRS})
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
add_definitions(${LLVM_DEFINITIONS_LIST})

# Clang
include_directories(${CLANG_INCLUDE_DIRS})
separate_arguments(CLANG_DEFINITIONS_LIST NATIVE_COMMAND ${CLANG_DEFINITIONS})
add_definitions(${CLANG_DEFINITIONS_LIST})

add_clreflect_executable(clReflectScan
ASTConsumer.cpp
AttributeParser.cpp
ClangFrontend.cpp
Main.cpp
ReflectionSpecs.cpp
)
Expand All @@ -48,9 +56,7 @@ set(CL_REFLECT_SCAN_LIBS
clangDriver
clangAST
clangEdit
LLVMSupport
LLVMCore
LLVMMC
clangTooling
)

if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
Expand All @@ -65,3 +71,8 @@ target_link_libraries(clReflectScan
${CL_REFLECT_SCAN_LIBS}
${CMAKE_DL_LIBS}
)

# Find the LLVM libraries that correspond to the LLVM components
# that we wish to use
llvm_map_components_to_libnames(llvm_libs support core mc x86asmparser x86codegen )
target_link_libraries(clReflectScan ${llvm_libs})
14 changes: 6 additions & 8 deletions src/clReflectTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ target_link_libraries(clReflectTest
# Map file handling
option(CL_REFLECT_GENERATE_MAP_FILE_FOR_TEST "Generate map file for test" ON)
if(CL_REFLECT_GENERATE_MAP_FILE_FOR_TEST)
get_property(CL_REFLECT_TEST_EXECUTABLE TARGET clReflectTest PROPERTY LOCATION)

# generates map file
if (MSVC)
# Generates path for map file
string(REPLACE ".exe" ".map" CL_REFLECT_TEST_MAP ${CL_REFLECT_TEST_EXECUTABLE})
string(REPLACE ".exe" ".map" CL_REFLECT_TEST_MAP "$<TARGET_FILE:clReflectTest>")

# From what I see, currently cmake can set the map link flags,
# but cmake does not support appending customized map file name(I may
Expand All @@ -44,16 +42,15 @@ if(CL_REFLECT_GENERATE_MAP_FILE_FOR_TEST)

if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
# On Linux/Mac, executables have no extensions
set(CL_REFLECT_TEST_MAP "${CL_REFLECT_TEST_EXECUTABLE}.map")
set(CL_REFLECT_TEST_MAP "$<TARGET_FILE:clReflectTest>.map")

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CL_REFLECT_TEST_MAP_CMD_ARGUMENT "-Wl,-map,${CL_REFLECT_TEST_MAP}")
else ()
set(CL_REFLECT_TEST_MAP_CMD_ARGUMENT "-Wl,-Map,${CL_REFLECT_TEST_MAP}")
endif()

set_target_properties(clReflectTest PROPERTIES LINK_FLAGS
"${CL_REFLECT_TEST_MAP_CMD_ARGUMENT}")
target_link_options(clReflectTest PRIVATE "${CL_REFLECT_TEST_MAP_CMD_ARGUMENT}")
endif (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)

# uses map file during exporting
Expand All @@ -63,7 +60,7 @@ endif()
# add project include path
get_property(inc_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
foreach(inc ${inc_dirs})
set(GEN_CPPBIN_INCLUDE_PATH ${GEN_CPPBIN_INCLUDE_PATH} -i ${inc})
set(GEN_CPPBIN_INCLUDE_PATH ${GEN_CPPBIN_INCLUDE_PATH} -I ${inc})
endforeach(inc)

# add system include path
Expand All @@ -88,7 +85,7 @@ if ((${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
endif ()

foreach(sys_inc ${sys_inc_dirs})
set(GEN_CPPBIN_INCLUDE_PATH ${GEN_CPPBIN_INCLUDE_PATH} -i ${sys_inc})
set(GEN_CPPBIN_INCLUDE_PATH ${GEN_CPPBIN_INCLUDE_PATH} -I ${sys_inc})
endforeach(sys_inc)

foreach(src_file ${CL_REFLECT_TEST_SOURCES})
Expand All @@ -103,6 +100,7 @@ foreach(src_file ${CL_REFLECT_TEST_SOURCES})
-output ${CL_REFLECT_GEN_DIRECTORY}/${csv_file}
-ast_log ${CL_REFLECT_GEN_DIRECTORY}/${astlog_file}
-spec_log ${CL_REFLECT_GEN_DIRECTORY}/${speclog_file}
--
${GEN_CPPBIN_INCLUDE_PATH}
DEPENDS clReflectScan ${src_file})

Expand Down
2 changes: 1 addition & 1 deletion src/clReflectTest/TestFunctionSerialise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace Funcs
wb.WriteStr(data);

clutl::ReadBuffer rb(wb);
if (!clutl::BuildParameterObjectCache_JSON(poc, function, rb))
if (!clutl::BuildParameterObjectCache_JSON(poc, function, rb, 0))
printf(" FAILED\n");
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/clReflectTest/TestSerialiseJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace
write_buffer.Write(test, strlen(test));
clutl::ReadBuffer read_buffer(write_buffer);

clutl::JSONError error = clutl::LoadJSON(read_buffer, 0, (clcpp::Type*)0);
clutl::JSONError error = clutl::LoadJSON(read_buffer, 0, (clcpp::Type*)0, 0);
if (error.code == clutl::JSONError::NONE)
{
printf("PASS\n");
Expand Down Expand Up @@ -414,10 +414,10 @@ void TestSerialiseJSON(clcpp::Database& db)

clutl::WriteBuffer write_buffer;
jsontest::AllFields a;
clutl::SaveJSON(write_buffer, &a, clcpp::GetType<jsontest::AllFields>(), 0, clutl::JSONFlags::EMIT_HEX_FLOATS);
clutl::SaveJSON(write_buffer, &a, clcpp::GetType<jsontest::AllFields>(), 0, clutl::JSONFlags::EMIT_HEX_FLOATS, 0);
clutl::ReadBuffer read_buffer(write_buffer);
jsontest::AllFields b(jsontest::NO_INIT);
clutl::LoadJSON(read_buffer, &b, clcpp::GetType<jsontest::AllFields>());
clutl::LoadJSON(read_buffer, &b, clcpp::GetType<jsontest::AllFields>(), 0);

if (a == b)
printf("STRUCT PASS!\n");
Expand Down