Skip to content

Serialization common #193

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

Merged
merged 10 commits into from
Feb 13, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions bootstrap/src/build_buildcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ void buildcc_cb(BaseTarget &target, const BaseGenerator &schema_gen,
target.AddIncludeDir("lib/env/include");
target.GlobHeaders("lib/env/include/env");

// SCHEMA
target.GlobSources("schema/src");
target.AddIncludeDir("schema/include");
target.GlobHeaders("schema/include/schema");
target.GlobHeaders("schema/include/schema/interface");
target.GlobHeaders("schema/include/schema/private");

// TOOLCHAIN
target.GlobSources("lib/toolchain/src/api");
target.AddIncludeDir("lib/toolchain/include");
Expand All @@ -72,8 +79,6 @@ void buildcc_cb(BaseTarget &target, const BaseGenerator &schema_gen,
target.GlobHeaders("lib/target/include/target/common");
target.GlobHeaders("lib/target/include/target/friend");
target.GlobHeaders("lib/target/include/target/interface");
target.GlobHeaders("lib/target/include/target/private");
target.GlobHeaders("lib/target/include/target/serialization");

// ARGS
target.GlobSources("lib/args/src");
Expand Down
6 changes: 3 additions & 3 deletions buildcc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
set(BUILDCC_INSTALL_LIB_PREFIX "lib/cmake")
set(BUILDCC_INSTALL_HEADER_PREFIX "include/buildcc")

# Flatbuffers schema
add_subdirectory(schema)

if(${BUILDCC_BUILD_AS_SINGLE_LIB})
add_library(buildcc STATIC
buildcc.h
Expand All @@ -31,6 +28,9 @@ if(${BUILDCC_BUILD_AS_SINGLE_LIB})
endif()
endif()

# Flatbuffers schema
add_subdirectory(schema)

# Environment
add_subdirectory(lib/env)

Expand Down
14 changes: 1 addition & 13 deletions buildcc/lib/target/cmake/common_target_src.cmake
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
set(COMMON_TARGET_SRCS
# Interfaces
include/target/interface/builder_interface.h
include/target/interface/serialization_interface.h

# Common
src/common/target_config.cpp
src/common/target_state.cpp
include/target/common/target_file_ext.h
include/target/common/target_config.h
include/target/common/target_state.h
include/target/common/target_file_ext.h
include/target/common/target_env.h
include/target/common/target_type.h

src/common/util.cpp
include/target/common/util.h

include/target/common/path.h

# API
src/api/source_api.cpp
src/api/include_api.cpp
Expand All @@ -39,10 +35,6 @@ set(COMMON_TARGET_SRCS
include/target/api/target_info_getter.h
include/target/api/target_getter.h

# Base Generator
src/generator/generator_serialization.cpp
include/target/serialization/generator_serialization.h

# Generator
src/generator/generator.cpp
include/target/generator.h
Expand All @@ -55,10 +47,6 @@ set(COMMON_TARGET_SRCS
include/target/friend/compile_object.h
include/target/friend/link_target.h

# Base Target
src/target/target_serialization.cpp
include/target/serialization/target_serialization.h

# Target
src/target/target.cpp
src/target/build.cpp
Expand Down
5 changes: 1 addition & 4 deletions buildcc/lib/target/cmake/mock_target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ add_library(mock_target STATIC
target_include_directories(mock_target PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/mock
${SCHEMA_BUILD_DIR}
)

target_compile_options(mock_target PUBLIC ${TEST_COMPILE_FLAGS} ${BUILD_COMPILE_FLAGS})
target_link_options(mock_target PUBLIC ${TEST_LINK_FLAGS} ${BUILD_LINK_FLAGS})
target_link_libraries(mock_target PUBLIC
flatbuffers_header_only
Taskflow

mock_schema
mock_toolchain

CppUTest
Expand All @@ -36,5 +35,3 @@ if (${MINGW})
message(WARNING "-Wl,--allow-multiple-definition for MINGW")
target_link_options(mock_target PUBLIC -Wl,--allow-multiple-definition)
endif()

add_dependencies(mock_target fbs_to_header)
11 changes: 1 addition & 10 deletions buildcc/lib/target/cmake/target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ if(${BUILDCC_BUILD_AS_SINGLE_LIB})
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${BUILDCC_INSTALL_HEADER_PREFIX}>
)
target_include_directories(buildcc PRIVATE
${SCHEMA_BUILD_DIR}
)
add_dependencies(buildcc fbs_to_header)
endif()

if(${BUILDCC_BUILD_AS_INTERFACE})
Expand All @@ -32,15 +28,10 @@ if(${BUILDCC_BUILD_AS_INTERFACE})
$<INSTALL_INTERFACE:${BUILDCC_INSTALL_HEADER_PREFIX}>
)
target_link_libraries(target PUBLIC
schema
toolchain
flatbuffers_header_only
Taskflow
)

target_include_directories(target PRIVATE
${SCHEMA_BUILD_DIR}
)
target_compile_options(target PRIVATE ${BUILD_COMPILE_FLAGS})
target_link_options(target PRIVATE ${BUILD_LINK_FLAGS})
add_dependencies(target fbs_to_header)
endif()
2 changes: 1 addition & 1 deletion buildcc/lib/target/include/target/api/target_getter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <filesystem>
#include <string>

#include "target/common/target_type.h"
#include "schema/target_type.h"

#include "toolchain/toolchain.h"

Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/include/target/api/target_info_getter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef TARGET_API_TARGET_INFO_GETTER_H_
#define TARGET_API_TARGET_INFO_GETTER_H_

#include "target/common/path.h"
#include "schema/path.h"

#include "target/common/target_config.h"
#include "target/common/target_state.h"
Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/include/target/common/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <string>
#include <vector>

#include "target/common/path.h"
#include "schema/path.h"

namespace buildcc::internal {

Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/include/target/friend/compile_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include <filesystem>

#include "target/common/path.h"
#include "schema/path.h"

#include "taskflow/core/task.hpp"
#include "taskflow/taskflow.hpp"
Expand Down
4 changes: 2 additions & 2 deletions buildcc/lib/target/include/target/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@

#include "target/interface/builder_interface.h"

#include "target/serialization/generator_serialization.h"
#include "schema/generator_serialization.h"
#include "schema/path.h"

#include "target/common/path.h"
#include "target/common/target_env.h"

namespace buildcc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include "env/assert_fatal.h"

#include "target/common/path.h"
#include "target/common/util.h"

namespace buildcc::internal {
Expand Down
6 changes: 3 additions & 3 deletions buildcc/lib/target/include/target/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
#include "target/target_info.h"

// Common
#include "target/common/target_type.h"
#include "schema/target_type.h"

// Friend
#include "target/friend/compile_object.h"
#include "target/friend/compile_pch.h"
#include "target/friend/link_target.h"

// Internal
#include "target/common/path.h"
#include "target/serialization/target_serialization.h"
#include "schema/path.h"
#include "schema/target_serialization.h"

// Env
#include "env/env.h"
Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/include/target/target_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "target/api/sync_api.h"
#include "target/api/target_info_getter.h"

#include "target/serialization/target_serialization.h"
#include "schema/target_serialization.h"

namespace buildcc {

Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/src/common/target_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "env/assert_fatal.h"

#include "target/common/path.h"
#include "schema/path.h"

#include "fmt/format.h"

Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/src/target/friend/compile_pch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "target/friend/compile_pch.h"

#include "target/common/path.h"
#include "schema/path.h"
#include "target/target.h"

#include "env/util.h"
Expand Down
4 changes: 3 additions & 1 deletion buildcc/lib/target/test/path/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ target_include_directories(${TEST_NAME} PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/generated
)
target_link_libraries(${TEST_NAME} PRIVATE
mock_env
mock_env
mock_schema

CppUTest
CppUTestExt
gcov
Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/test/path/test_path.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Internal
#include "target/common/path.h"
#include "schema/path.h"

#include "env/assert_fatal.h"

Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/test/target/test_builder_interface.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "target/interface/builder_interface.h"

#include "target/common/path.h"
#include "schema/path.h"

// NOTE, Make sure all these includes are AFTER the system and header includes
#include "CppUTest/CommandLineTestRunner.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "target/interface/serialization_interface.h"
#include "schema/interface/serialization_interface.h"

// NOTE, Make sure all these includes are AFTER the system and header includes
#include "CppUTest/CommandLineTestRunner.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "target/target.h"

#include "target/serialization/target_serialization.h"
#include "schema/target_serialization.h"

#include <iostream>
#include <unistd.h>
Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/test/target/test_target_flags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "env/env.h"

//
#include "target/serialization/target_serialization.h"
#include "schema/target_serialization.h"

// Third Party

Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/test/target/test_target_lib_dep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "target/target.h"

//
#include "target/serialization/target_serialization.h"
#include "schema/target_serialization.h"

#include <iostream>
#include <unistd.h>
Expand Down
2 changes: 1 addition & 1 deletion buildcc/plugins/src/buildcc_find.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "env/host_os_util.h"
#include "env/logging.h"

#include "target/common/path.h"
#include "schema/path.h"

namespace {
constexpr const char *const kEnvVarNotFound =
Expand Down
28 changes: 2 additions & 26 deletions buildcc/schema/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,2 @@
# Generate files
set(SCHEMA_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated CACHE PATH "Generate path of flatbuffer schema")

set(FBS_FILES
${CMAKE_CURRENT_SOURCE_DIR}/path.fbs
${CMAKE_CURRENT_SOURCE_DIR}/generator.fbs
${CMAKE_CURRENT_SOURCE_DIR}/target.fbs
)
set(FBS_GEN_FILES
${SCHEMA_BUILD_DIR}/path_generated.h
${SCHEMA_BUILD_DIR}/generator_generated.h
${SCHEMA_BUILD_DIR}/target_generated.h
)
set(FBS_GEN_OPTIONS
-I ${CMAKE_CURRENT_SOURCE_DIR}
--gen-object-api
)

add_custom_command(OUTPUT ${FBS_GEN_FILES}
COMMAND flatc -o ${SCHEMA_BUILD_DIR} ${FBS_GEN_OPTIONS} --cpp ${FBS_FILES}
DEPENDS flatc ${FBS_FILES}
)

add_custom_target(fbs_to_header
DEPENDS ${FBS_GEN_FILES}
)
include(cmake/schema_generate.cmake)
include(cmake/schema.cmake)
Loading