From e08b7fc35a754a17feeff663b20cf81b4b428ab7 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Thu, 2 May 2024 17:53:42 +0200 Subject: Add tests for object_only library --- tests/test_cases/deps/object/TARGETS | 36 +++++++++++++++++++++++++++++++++++ tests/test_cases/deps/object/bar.cpp | 3 +++ tests/test_cases/deps/object/bar.hpp | 9 +++++++++ tests/test_cases/deps/object/foo.cpp | 3 +++ tests/test_cases/deps/object/foo.hpp | 8 ++++++++ tests/test_cases/deps/object/main.cpp | 8 ++++++++ 6 files changed, 67 insertions(+) create mode 100644 tests/test_cases/deps/object/TARGETS create mode 100644 tests/test_cases/deps/object/bar.cpp create mode 100644 tests/test_cases/deps/object/bar.hpp create mode 100644 tests/test_cases/deps/object/foo.cpp create mode 100644 tests/test_cases/deps/object/foo.hpp create mode 100644 tests/test_cases/deps/object/main.cpp (limited to 'tests/test_cases/deps/object') diff --git a/tests/test_cases/deps/object/TARGETS b/tests/test_cases/deps/object/TARGETS new file mode 100644 index 0000000..bd69478 --- /dev/null +++ b/tests/test_cases/deps/object/TARGETS @@ -0,0 +1,36 @@ +{ "foo": + { "type": ["@", "rules", "CC", "library"] + , "name": ["foo"] + , "shared": ["yes"] + , "hdrs": ["foo.hpp"] + , "srcs": ["foo.cpp"] + , "deps": ["bar"] + , "stage": ["foo"] + } +, "bar": + { "type": ["@", "rules", "CC", "library"] + , "object_only": ["yes"] + , "hdrs": ["bar.hpp"] + , "srcs": ["bar.cpp"] + , "stage": ["bar"] + } +, "main": + { "type": ["@", "rules", "CC", "binary"] + , "name": ["main"] + , "srcs": ["main.cpp"] + , "private-deps": ["foo"] + } +, "test_main": + { "type": ["@", "rules", "shell/test", "script"] + , "name": ["test_main"] + , "test": ["test_main.sh"] + , "deps": ["main"] + } +, "test_main.sh": + { "type": "file_gen" + , "name": "test.sh" + , "data": "set -e\n[ \"$(./main)\" = \"Hello World and Galaxy\" ]" + } +, "install_main": + {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["main"]} +} diff --git a/tests/test_cases/deps/object/bar.cpp b/tests/test_cases/deps/object/bar.cpp new file mode 100644 index 0000000..5d7c616 --- /dev/null +++ b/tests/test_cases/deps/object/bar.cpp @@ -0,0 +1,3 @@ +#include + +std::string bar() { return "and Galaxy"; } diff --git a/tests/test_cases/deps/object/bar.hpp b/tests/test_cases/deps/object/bar.hpp new file mode 100644 index 0000000..9c97d54 --- /dev/null +++ b/tests/test_cases/deps/object/bar.hpp @@ -0,0 +1,9 @@ +#ifndef BAR_HPP +#define BAR_HPP + +#include + +// use this object lib to extend the public symbols of shared lib 'foo' by 'bar' +std::string bar(); + +#endif diff --git a/tests/test_cases/deps/object/foo.cpp b/tests/test_cases/deps/object/foo.cpp new file mode 100644 index 0000000..9687a6a --- /dev/null +++ b/tests/test_cases/deps/object/foo.cpp @@ -0,0 +1,3 @@ +#include "foo.hpp" + +std::string foo() { return "Hello World"; } diff --git a/tests/test_cases/deps/object/foo.hpp b/tests/test_cases/deps/object/foo.hpp new file mode 100644 index 0000000..d880c27 --- /dev/null +++ b/tests/test_cases/deps/object/foo.hpp @@ -0,0 +1,8 @@ +#ifndef FOO_HPP +#define FOO_HPP + +#include + +std::string foo(); + +#endif diff --git a/tests/test_cases/deps/object/main.cpp b/tests/test_cases/deps/object/main.cpp new file mode 100644 index 0000000..cfc2a4f --- /dev/null +++ b/tests/test_cases/deps/object/main.cpp @@ -0,0 +1,8 @@ +#include "bar/bar.hpp" +#include "foo/foo.hpp" +#include + +int main(int argc, char const *argv[]) { + std::cout << foo() << " " << bar() << std::endl; + return 0; +} -- cgit v1.2.3