mirror of
https://git.yoctoproject.org/poky
synced 2026-05-23 20:27:55 +02:00
oe-selftest: add a cpp-example recipe
This simple C++ project supports compilation with CMake and Meson. (Autotool support could be added later on.) It's supposed to be used with oe-selftest. An artificial project has several advantages over compiling a normal CMake or Meson based project for testing purposes: - It is much faster because it can be kept minimalistic - It can cover multiple odd corner cases - No one will change it in an unpredictable way - It can support multiple build tools with only one C++ codebase (From OE-Core rev: 4904e772470b0d6e5d98ef0344b3f2bf54214661) Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
d7c05e4eed
commit
2df986746b
33
meta-selftest/recipes-test/cpp/files/cpp-example-lib.cpp
Normal file
33
meta-selftest/recipes-test/cpp/files/cpp-example-lib.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright OpenEmbedded Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <json-c/json.h>
|
||||
#include "cpp-example-lib.hpp"
|
||||
|
||||
const std::string &CppExample::get_string()
|
||||
{
|
||||
return test_string;
|
||||
}
|
||||
|
||||
const char *CppExample::get_json_c_version()
|
||||
{
|
||||
return json_c_version();
|
||||
}
|
||||
|
||||
void CppExample::print_json()
|
||||
{
|
||||
struct json_object *jobj;
|
||||
const int flag = JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY;
|
||||
|
||||
jobj = json_object_new_object();
|
||||
json_object_object_add(jobj, "test_string", json_object_new_string(test_string.c_str()));
|
||||
|
||||
std::cout << json_object_to_json_string_ext(jobj, flag) << std::endl;
|
||||
|
||||
json_object_put(jobj); // Delete the json object
|
||||
}
|
||||
Reference in New Issue
Block a user