INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/halcc/include)
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(REQUIRED_PKGS REQUIRED dlog-redirect-stdout)
+
ADD_EXECUTABLE(${PROJECT_NAME} main.c)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES INSTALL_RPATH ${LIBDIR}/hal)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE libhalcc)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE libhalcc ${REQUIRED_PKGS_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
#include <errno.h>
#include <stdlib.h>
#include <getopt.h>
+#include <string.h>
+#include <dlog/dlog-redirect-stdout.h>
#include <hal-common.h>
#include <halcc/hal-compatibility-checker.h>
#define HCC_BUF_MAX (256)
#define BOLD(STR) "\e[1m"STR"\e[m"
+#define LOG_TAG_HAL_COMPATIBILITY_CHECKER "HAL_COMPATIBILITY_CHECKER"
+
enum {
OPT_START = 0,
OPT_HELP = OPT_START,
static int redirect_output(const char *file, int stdfd)
{
- int fd = open(file, O_WRONLY | O_APPEND | O_CREAT, 0644);
+ int fd = -1;
int newfd;
+ assert(file);
+
+ /* recognize special symbol "dlog" */
+ if (strncmp(file, "dlog", sizeof("dlog")) == 0)
+ return dlog_connect_fd(2 /* LOG_ID_SYSTEM */,
+ stdfd,
+ LOG_TAG_HAL_COMPATIBILITY_CHECKER,
+ stdfd == STDERR_FILENO ? 6 /* DLOG_ERROR */ : 4 /* DLOG_INFO */);
+
+ fd = open(file, O_WRONLY | O_APPEND | O_CREAT, 0644);
+
if (fd == -1) {
printf("hal-compatibility-checker: Failed to redirect output: %m\n");
return -1;
"\t\tskip compatibility check if there exists a result of compatibility.\n"
"\t\tif DIRECTORY is given, locate a result based on the given DIRECTORY.\n"
"\n"
- "\t--redirect-all=FILE\n"
- "\t\tredirect stdout/stderr to FILE.\n"
+ "\t--redirect-all=FILE|dlog\n"
+ "\t\tredirect stdout/stderr to FILE or dlog with tag "LOG_TAG_HAL_COMPATIBILITY_CHECKER".\n"
"\n"
- "\t--redirect-stdout=FILE\n"
- "\t\tredirect stdout to FILE.\n"
+ "\t--redirect-stdout=FILE|dlog\n"
+ "\t\tredirect stdout to FILE or dlog with tag "LOG_TAG_HAL_COMPATIBILITY_CHECKER".\n"
"\n"
- "\t--redirect-stderr=FILE\n"
- "\t\tredirect stderr to FILE.\n"
+ "\t--redirect-stderr=FILE|dlog\n"
+ "\t\tredirect stderr to FILE or dlog with tag "LOG_TAG_HAL_COMPATIBILITY_CHECKER".\n"
, default_platform_manifest_dir()
);
}