build: Refactor the build structure of the project
Moved all header files to `include` and all cpp files to `src`.
Updated the meson.build accordingly.
Change-Id: I9e26197b9c73b5e284cfc9d0d78a234546c282ad
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/binarystore.hpp b/include/binarystore.hpp
similarity index 100%
rename from binarystore.hpp
rename to include/binarystore.hpp
diff --git a/binarystore_interface.hpp b/include/binarystore_interface.hpp
similarity index 100%
rename from binarystore_interface.hpp
rename to include/binarystore_interface.hpp
diff --git a/binarystore_mock.hpp b/include/binarystore_mock.hpp
similarity index 100%
rename from binarystore_mock.hpp
rename to include/binarystore_mock.hpp
diff --git a/handler.hpp b/include/handler.hpp
similarity index 100%
rename from handler.hpp
rename to include/handler.hpp
diff --git a/include/meson.build b/include/meson.build
new file mode 100644
index 0000000..e4ada8f
--- /dev/null
+++ b/include/meson.build
@@ -0,0 +1 @@
+blobstore_includes = include_directories('.')
diff --git a/parse_config.hpp b/include/parse_config.hpp
similarity index 100%
rename from parse_config.hpp
rename to include/parse_config.hpp
diff --git a/sys.hpp b/include/sys.hpp
similarity index 100%
rename from sys.hpp
rename to include/sys.hpp
diff --git a/sys_file.hpp b/include/sys_file.hpp
similarity index 100%
rename from sys_file.hpp
rename to include/sys_file.hpp
diff --git a/sys_file_impl.hpp b/include/sys_file_impl.hpp
similarity index 100%
rename from sys_file_impl.hpp
rename to include/sys_file_impl.hpp
diff --git a/meson.build b/meson.build
index 4d2e011..5b8da86 100644
--- a/meson.build
+++ b/meson.build
@@ -10,7 +10,6 @@
]
)
-
cpp = meson.get_compiler('cpp')
cpp.has_header('boost/endian/arithmetic.hpp')
cpp.has_header('nlohmann/json.hpp')
@@ -19,42 +18,8 @@
phosphor_logging_dep = dependency('phosphor-logging')
subdir('proto')
-
-binarystoreblob_pre = declare_dependency(
- include_directories: [
- include_directories('.'),
- include_directories('proto')],
- dependencies: [
- protobuf_dep,
- ipmi_blob_dep,
- phosphor_logging_dep,
- ])
-
-binarystoreblob_lib = library(
- 'binarystore',
- 'binarystore.cpp',
- 'sys.cpp',
- 'sys_file_impl.cpp',
- 'handler.cpp',
- proto,
- implicit_include_directories: false,
- dependencies: binarystoreblob_pre,
- install: true,
- install_dir: get_option('libdir') / 'blob-ipmid')
-
-binarystoreblob_dep = declare_dependency(
- link_with: binarystoreblob_lib,
- dependencies: binarystoreblob_pre)
-
-if not get_option('blobtool').disabled()
- executable(
- 'blobtool',
- 'blobtool.cpp',
- implicit_include_directories: false,
- dependencies: binarystoreblob_dep,
- install: true)
-endif
-
+subdir('include')
+subdir('src')
if not get_option('tests').disabled()
subdir('test')
diff --git a/proto/meson.build b/proto/meson.build
index 0600083..02d46d9 100644
--- a/proto/meson.build
+++ b/proto/meson.build
@@ -1,4 +1,4 @@
-proto = custom_target(
+src_pb = custom_target(
'proto',
command: [
find_program('protoc', native: true),
@@ -11,3 +11,20 @@
'binaryblob.pb.h',
],
input: 'binaryblob.proto')
+
+binaryblobproto_pre = declare_dependency(
+ include_directories: include_directories('.'),
+ dependencies: dependency('protobuf')
+)
+
+binaryblobproto_lib = static_library(
+ 'binaryblob_proto',
+ src_pb,
+ implicit_include_directories: false,
+ dependencies: binaryblobproto_pre
+)
+
+binaryblobproto_dep = declare_dependency(
+ dependencies: binaryblobproto_pre,
+ link_with: binaryblobproto_lib
+)
diff --git a/binarystore.cpp b/src/binarystore.cpp
similarity index 100%
rename from binarystore.cpp
rename to src/binarystore.cpp
diff --git a/blobtool.cpp b/src/blobtool.cpp
similarity index 100%
rename from blobtool.cpp
rename to src/blobtool.cpp
diff --git a/handler.cpp b/src/handler.cpp
similarity index 100%
rename from handler.cpp
rename to src/handler.cpp
diff --git a/main.cpp b/src/main.cpp
similarity index 100%
rename from main.cpp
rename to src/main.cpp
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..a8917ac
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,40 @@
+binarystoreblob_pre = declare_dependency(
+ include_directories: [
+ include_directories('.'),
+ blobstore_includes,
+ ],
+ dependencies: [
+ protobuf_dep,
+ ipmi_blob_dep,
+ phosphor_logging_dep,
+ binaryblobproto_dep,
+ ]
+)
+
+binarystoreblob_lib = library(
+ 'binarystore',
+ 'binarystore.cpp',
+ 'sys.cpp',
+ 'sys_file_impl.cpp',
+ 'handler.cpp',
+ src_pb,
+ implicit_include_directories: false,
+ dependencies: binarystoreblob_pre,
+ install: true,
+ install_dir: get_option('libdir') / 'blob-ipmid'
+)
+
+binarystoreblob_dep = declare_dependency(
+ link_with: binarystoreblob_lib,
+ dependencies: binarystoreblob_pre
+)
+
+if not get_option('blobtool').disabled()
+ executable(
+ 'blobtool',
+ 'blobtool.cpp',
+ implicit_include_directories: false,
+ dependencies: binarystoreblob_dep,
+ install: true
+ )
+endif
diff --git a/sys.cpp b/src/sys.cpp
similarity index 100%
rename from sys.cpp
rename to src/sys.cpp
diff --git a/sys_file_impl.cpp b/src/sys_file_impl.cpp
similarity index 100%
rename from sys_file_impl.cpp
rename to src/sys_file_impl.cpp