tools/emory: add stub loader executable

This commit is contained in:
Danny Robson 2019-04-27 10:44:33 +10:00
parent d83601755c
commit 8b620dc4f5
2 changed files with 55 additions and 4 deletions

View File

@ -11,7 +11,7 @@ include_directories(.)
###############################################################################
add_library(emory
add_library(libemory
acl.cpp
acl.hpp
emory/chunk/fwd.cpp
@ -34,8 +34,8 @@ add_library(emory
emory/fs/xattr.hpp
)
target_link_libraries(emory cruft acl)
target_link_libraries(libemory cruft acl)
set_target_properties(libemory PROPERTIES OUTPUT_NAME emory)
###############################################################################
@ -53,5 +53,11 @@ add_subdirectory(cruft/crypto)
###############################################################################
foreach (t analyse compare stat)
add_executable ("${t}" "tools/${t}.cpp")
target_link_libraries("${t}" emory cruft-crypto cruft)
target_link_libraries ("${t}" libemory cruft-crypto cruft)
set_target_properties ("${t}" PROPERTIES
OUTPUT_NAME "emory-${t}"
)
endforeach()
add_executable (emory tools/emory.cpp)
target_link_libraries (emory libemory)

45
tools/emory.cpp Normal file
View File

@ -0,0 +1,45 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 2019 Danny Robson <danny@nerdcruft.net>
*/
#include <iostream>
#include <cstddef>
#include <sstream>
#include <unistd.h>
#include <cruft/util/debug.hpp>
#include <cruft/util/posix/except.hpp>
enum {
ARG_SELF,
ARG_CHILD,
NUM_ARGS
};
static void print_usage (std::ostream &os, int argc, char **argv)
{
(void)argc;
os << "Usage: " << argv[ARG_SELF] << " <command> [args] ...\n";
}
int main (int argc, char **argv)
{
if (argc < NUM_ARGS) {
print_usage (std::cerr, argc, argv);
return EXIT_FAILURE;
}
std::ostringstream os;
os << argv[ARG_SELF] << '-' << argv[ARG_CHILD];
cruft::posix::error::try_call (execv, os.str ().c_str (), argv + 1);
unreachable ();
}