meson: add src/ folder
This creates a conventional structure of src/ and test/ which helps to
separate top-level files such as meson.build, OWNERS, ...
from implementation files.
Git history of individual files is still accessible via e.g.
```
git log --follow -- src/thresholds.hpp
```
Tested: code compiles.
Change-Id: Ifff8b3e70437bc6a25cd6f65afd07d8a563d1a8c
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/meson.build b/meson.build
index fc8ca68..b2d4227 100644
--- a/meson.build
+++ b/meson.build
@@ -19,25 +19,7 @@
exprtk = declare_dependency(include_directories: 'subprojects/exprtk')
endif
-executable(
- 'virtual-sensor',
- [
- 'calculate.cpp',
- 'dbusSensor.cpp',
- 'dbusUtils.cpp',
- 'main.cpp',
- 'virtualSensor.cpp',
- ],
- dependencies: [
- dependency('nlohmann_json', include_type: 'system'),
- dependency('phosphor-dbus-interfaces'),
- dependency('phosphor-logging'),
- dependency('sdbusplus'),
- exprtk,
- ],
- install: true,
- install_dir: get_option('libexecdir') / meson.project_name(),
-)
+subdir('src')
packagedir = join_paths(
get_option('prefix'),
@@ -58,6 +40,8 @@
install_dir: systemd.get_variable('systemd_system_unit_dir'),
)
+src_inc = include_directories('src')
+
build_tests = get_option('tests')
if build_tests.allowed()
subdir('test')
diff --git a/calculate.cpp b/src/calculate.cpp
similarity index 100%
rename from calculate.cpp
rename to src/calculate.cpp
diff --git a/calculate.hpp b/src/calculate.hpp
similarity index 100%
rename from calculate.hpp
rename to src/calculate.hpp
diff --git a/dbusSensor.cpp b/src/dbusSensor.cpp
similarity index 100%
rename from dbusSensor.cpp
rename to src/dbusSensor.cpp
diff --git a/dbusSensor.hpp b/src/dbusSensor.hpp
similarity index 100%
rename from dbusSensor.hpp
rename to src/dbusSensor.hpp
diff --git a/dbusUtils.cpp b/src/dbusUtils.cpp
similarity index 100%
rename from dbusUtils.cpp
rename to src/dbusUtils.cpp
diff --git a/dbusUtils.hpp b/src/dbusUtils.hpp
similarity index 100%
rename from dbusUtils.hpp
rename to src/dbusUtils.hpp
diff --git a/exprtkTools.hpp b/src/exprtkTools.hpp
similarity index 100%
rename from exprtkTools.hpp
rename to src/exprtkTools.hpp
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..43f7f96
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,19 @@
+executable(
+ 'virtual-sensor',
+ [
+ 'calculate.cpp',
+ 'dbusSensor.cpp',
+ 'dbusUtils.cpp',
+ 'main.cpp',
+ 'virtualSensor.cpp',
+ ],
+ dependencies: [
+ dependency('nlohmann_json', include_type: 'system'),
+ dependency('phosphor-dbus-interfaces'),
+ dependency('phosphor-logging'),
+ dependency('sdbusplus'),
+ exprtk,
+ ],
+ install: true,
+ install_dir: get_option('libexecdir') / meson.project_name(),
+)
diff --git a/thresholds.hpp b/src/thresholds.hpp
similarity index 100%
rename from thresholds.hpp
rename to src/thresholds.hpp
diff --git a/virtualSensor.cpp b/src/virtualSensor.cpp
similarity index 100%
rename from virtualSensor.cpp
rename to src/virtualSensor.cpp
diff --git a/virtualSensor.hpp b/src/virtualSensor.hpp
similarity index 100%
rename from virtualSensor.hpp
rename to src/virtualSensor.hpp
diff --git a/test/meson.build b/test/meson.build
index e14fd5c..8f27ad2 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -1,7 +1,6 @@
gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
gmock = dependency('gmock', disabler: true, required: build_tests)
test_inc = include_directories('.')
-src_inc = include_directories('..')
common_dep = [gtest, gmock]