Add extracted tools: CitrineOS, OpenOCPP, ShapeShifter
- CitrineOS core extracted (CSMS OCPP 2.0.1) - OpenOCPP extracted (firmware OCPP 1.6J/2.0.1) - ShapeShifter library installed (pip install -e) - ShapeShifter specification extracted - EVerest extracted TODO updated with progress
This commit is contained in:
20
tools/EVerest-main/lib/everest/run_application/BUILD.bazel
Normal file
20
tools/EVerest-main/lib/everest/run_application/BUILD.bazel
Normal file
@@ -0,0 +1,20 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
|
||||
cc_library(
|
||||
name = "run_application",
|
||||
srcs = [
|
||||
"src/run_application.cpp",
|
||||
],
|
||||
hdrs = [
|
||||
"include/everest/run_application/run_application.hpp",
|
||||
],
|
||||
copts = ["-std=c++17"],
|
||||
includes = ["include"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"@boost.process",
|
||||
"@com_github_fmtlib_fmt//:fmt",
|
||||
"//lib/everest/framework:framework",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
# EVerest run application helper functions
|
||||
|
||||
add_library(everest_run_application STATIC)
|
||||
add_library(everest::run_application ALIAS everest_run_application)
|
||||
ev_register_library_target(everest_run_application)
|
||||
|
||||
target_sources(everest_run_application
|
||||
PRIVATE
|
||||
src/run_application.cpp
|
||||
)
|
||||
|
||||
target_include_directories(everest_run_application
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
target_link_libraries(everest_run_application
|
||||
PRIVATE
|
||||
Boost::headers
|
||||
fmt::fmt
|
||||
everest::log
|
||||
)
|
||||
|
||||
set_target_properties(everest_run_application PROPERTIES EXPORT_NAME run_application)
|
||||
|
||||
if (DISABLE_EDM)
|
||||
install(
|
||||
TARGETS everest_run_application
|
||||
EXPORT everest-core-targets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
|
||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/everest
|
||||
TYPE INCLUDE
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,33 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace everest::run_application {
|
||||
|
||||
/// \brief Used in the output_callback of run_application to indicate if the application should Continue to run or
|
||||
/// Terminate
|
||||
enum class CmdControl {
|
||||
Continue, ///< Continue application executiong
|
||||
Terminate ///< Terminate application
|
||||
};
|
||||
|
||||
/// \brief Output and exit code of an application ran by run_application
|
||||
struct CmdOutput {
|
||||
std::string output; ///< Full stdout output
|
||||
std::vector<std::string> split_output; ///< The stdout output split after every line
|
||||
int exit_code; ///< Exit code of the application
|
||||
};
|
||||
|
||||
/// \brief Run the application specified by its \p name which can either be a full path or a binary name in PATH with
|
||||
/// the provided \p args.
|
||||
/// A \p output_callback can be provided that gets called after every line of stdout that is also passed to this
|
||||
/// callback. The callback must return a CmdContol of either Continue or Terminate, which decide if the application will
|
||||
/// continue running or terminated early
|
||||
CmdOutput run_application(const std::string& name, std::vector<std::string> args,
|
||||
const std::function<CmdControl(const std::string& output_line)> output_callback = nullptr);
|
||||
|
||||
} // namespace everest::run_application
|
||||
@@ -0,0 +1,62 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright Pionix GmbH and Contributors to EVerest
|
||||
#include <everest/run_application/run_application.hpp>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
#if BOOST_VERSION >= 108600
|
||||
#include <boost/process/v1/args.hpp>
|
||||
#include <boost/process/v1/child.hpp>
|
||||
#include <boost/process/v1/cmd.hpp>
|
||||
#include <boost/process/v1/io.hpp>
|
||||
#include <boost/process/v1/pipe.hpp>
|
||||
#include <boost/process/v1/search_path.hpp>
|
||||
namespace everest_boost_process = boost::process::v1;
|
||||
#else
|
||||
#include <boost/process.hpp>
|
||||
namespace everest_boost_process = boost::process;
|
||||
#endif
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include <everest/logging.hpp>
|
||||
|
||||
namespace everest::run_application {
|
||||
CmdOutput run_application(const std::string& name, std::vector<std::string> args,
|
||||
const std::function<CmdControl(const std::string& output_line)> output_callback) {
|
||||
|
||||
// search_path requires basename and not a full path
|
||||
boost::filesystem::path path = name;
|
||||
|
||||
if (path.is_relative()) {
|
||||
path = everest_boost_process::search_path(name);
|
||||
}
|
||||
|
||||
if (path.empty()) {
|
||||
EVLOG_debug << fmt::format("The application '{}' could not be found", name);
|
||||
return CmdOutput{"", {}, 1};
|
||||
}
|
||||
|
||||
everest_boost_process::ipstream stream;
|
||||
everest_boost_process::child cmd(path, everest_boost_process::args(args), everest_boost_process::std_out > stream);
|
||||
std::string output;
|
||||
std::vector<std::string> split_output;
|
||||
std::string temp;
|
||||
auto condition = CmdControl::Continue;
|
||||
while (std::getline(stream, temp)) {
|
||||
output += temp + "\n";
|
||||
if (output_callback != nullptr) {
|
||||
condition = output_callback(temp);
|
||||
}
|
||||
split_output.push_back(temp);
|
||||
if (condition != CmdControl::Continue) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (condition == CmdControl::Continue) {
|
||||
cmd.wait();
|
||||
} else {
|
||||
cmd.terminate();
|
||||
}
|
||||
return CmdOutput{output, split_output, cmd.exit_code()};
|
||||
}
|
||||
} // namespace everest::run_application
|
||||
Reference in New Issue
Block a user