Verified Commit 30c8e586 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Remove `config` module

parent 8d8f3f85
Loading
Loading
Loading
Loading

src/config/CMakeLists.txt

deleted100644 → 0
+0 −34
Original line number Diff line number Diff line
################################################################################
# Copyright 2022-2023, Barcelona Supercomputing Center (BSC), Spain            #
#                                                                              #
# This software was partially supported by the EuroHPC-funded project ADMIRE   #
#   (Project ID: 956748, https://www.admire-eurohpc.eu).                       #
#                                                                              #
# This file is part of Cargo.                                                  #
#                                                                              #
# Cargo is free software: you can redistribute it and/or modify                #
# it under the terms of the GNU General Public License as published by         #
# the Free Software Foundation, either version 3 of the License, or            #
# (at your option) any later version.                                          #
#                                                                              #
# Cargo is distributed in the hope that it will be useful,                     #
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
# GNU General Public License for more details.                                 #
#                                                                              #
# You should have received a copy of the GNU General Public License            #
# along with Cargo.  If not, see <https://www.gnu.org/licenses/>.              #
#                                                                              #
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################

add_subdirectory(config)

# Since some of the sources will be auto-generated, we need to search for
# includes in ${CMAKE_CURRENT_BINARY_DIR}
target_include_directories(
  config PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
                ${CMAKE_CURRENT_BINARY_DIR}
)

set_property(TARGET config PROPERTY POSITION_INDEPENDENT_CODE ON)

src/config/config/CMakeLists.txt

deleted100644 → 0
+0 −84
Original line number Diff line number Diff line
################################################################################
# Copyright 2022-2023, Barcelona Supercomputing Center (BSC), Spain            #
#                                                                              #
# This software was partially supported by the EuroHPC-funded project ADMIRE   #
#   (Project ID: 956748, https://www.admire-eurohpc.eu).                       #
#                                                                              #
# This file is part of Cargo.                                                  #
#                                                                              #
# Cargo is free software: you can redistribute it and/or modify                #
# it under the terms of the GNU General Public License as published by         #
# the Free Software Foundation, either version 3 of the License, or            #
# (at your option) any later version.                                          #
#                                                                              #
# Cargo is distributed in the hope that it will be useful,                     #
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
# GNU General Public License for more details.                                 #
#                                                                              #
# You should have received a copy of the GNU General Public License            #
# along with Cargo.  If not, see <https://www.gnu.org/licenses/>.              #
#                                                                              #
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################

# Create a config target for all configuration code
add_library(config STATIC)

target_include_directories(
  config PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
)

target_sources(
  config
  PRIVATE config.hpp
          defaults.hpp
          ${CMAKE_CURRENT_BINARY_DIR}/defaults.cpp
          ${CMAKE_CURRENT_BINARY_DIR}/config_options.hpp
          ${CMAKE_CURRENT_BINARY_DIR}/keywords.hpp
          parsers.cpp
          parsers.hpp
          settings.cpp
          settings.hpp
)

target_link_libraries(config PRIVATE utils file_options::file_options)

# ##############################################################################
# Produce several auto-generated files for 'config'
# ##############################################################################

# Default values for options
configure_file(defaults.cpp.in defaults.cpp)

# Automatic generation of file_options schemas. To facilitate the management of
# any file-based configuration options, we generate a C++ schema from a YAML
# file that allows the 'file_options' library to parse them fromm a
# configuration file. The process works as follows:
#  1. We define the desired options in 'file_options.yml'
#  2. We rely on the 'genopts' tool to generate valid C++ schemas for the
#     'file_options' library. This tool can be configured using a 'genopts.yml'
#     configuration file.
#  3. In the daemon code, we use the facilities provided by the 'file_options'
#     library to access the options values.

# Since the configuration in genopts.yml can be path-dependant, we rely on
# CMake to substitute any special @variables@ for their actual values
configure_file(genopts.yml.in genopts.yml @ONLY)

# Define the command that will generate config_options.hpp and keywords.hpp.
# It will be executed since there is a direct dependency between 'config'
# (defined below) and these output files.
# We also make the command depend on file_options.yml and genopts.yml so that
# it gets re-executed if they change.
add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/config_options.hpp
         ${CMAKE_CURRENT_BINARY_DIR}/keywords.hpp
  COMMENT "Generating config_options.hpp, keywords.hpp"
  DEPENDS genopts_virtualenv file_options.yml
          ${CMAKE_CURRENT_BINARY_DIR}/genopts.yml
  COMMAND
    Genopts::Python3_Interpreter -m genopts --config
    ${CMAKE_CURRENT_BINARY_DIR}/genopts.yml
    ${CMAKE_CURRENT_LIST_DIR}/file_options.yml
)

src/config/config/config.hpp

deleted100644 → 0
+0 −31
Original line number Diff line number Diff line
/******************************************************************************
 * Copyright 2022-2023, Barcelona Supercomputing Center (BSC), Spain
 *
 * This software was partially supported by the EuroHPC-funded project ADMIRE
 *   (Project ID: 956748, https://www.admire-eurohpc.eu).
 *
 * This file is part of Cargo.
 *
 * Cargo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Cargo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Cargo.  If not, see <https://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *****************************************************************************/

#ifndef CONFIG_HPP
#define CONFIG_HPP

#include "defaults.hpp"
#include "settings.hpp"

#endif /* CONFIG_HPP */

src/config/config/defaults.cpp.in

deleted100644 → 0
+0 −52
Original line number Diff line number Diff line
/******************************************************************************
 * Copyright 2022-2023, Barcelona Supercomputing Center (BSC), Spain
 *
 * This software was partially supported by the EuroHPC-funded project ADMIRE
 *   (Project ID: 956748, https://www.admire-eurohpc.eu).
 *
 * This file is part of Cargo.
 *
 * Cargo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Cargo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Cargo.  If not, see <https://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *****************************************************************************/

/* DO NOT MODIFY: This file is autogenerated by CMake */
#include <thread>
#include <filesystem>
#include <config/defaults.hpp>
#include <netinet/in.h>
#include <cstdint>

namespace config::defaults {

const char* progname = "@CMAKE_PROJECT_NAME@";
const bool daemonize = true;
const bool use_syslog = false;
const bool use_console = false;
const std::filesystem::path log_file = {};
const uint32_t log_file_max_size = static_cast<uint32_t>(16 * 1024 * 1024);

const char* transport_protocol = "ofi+tcp";
const char* bind_address = "127.0.0.1";
const in_port_t remote_port = 42000;
const char* pidfile =
        "@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/@CMAKE_PROJECT_NAME@.pid";

const uint32_t workers_in_pool = std::thread::hardware_concurrency();
const uint32_t backlog_size = 128;
const char* config_file =
        "@CMAKE_INSTALL_FULL_SYSCONFDIR@/@CMAKE_PROJECT_NAME@.conf";

} // namespace config::defaults

src/config/config/defaults.hpp

deleted100644 → 0
+0 −53
Original line number Diff line number Diff line
/******************************************************************************
 * Copyright 2022-2023, Barcelona Supercomputing Center (BSC), Spain
 *
 * This software was partially supported by the EuroHPC-funded project ADMIRE
 *   (Project ID: 956748, https://www.admire-eurohpc.eu).
 *
 * This file is part of Cargo.
 *
 * Cargo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Cargo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Cargo.  If not, see <https://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *****************************************************************************/

#ifndef CONFIG_DEFAULTS_HPP
#define CONFIG_DEFAULTS_HPP

#include <cstdint>
#include <netinet/in.h>
#include <filesystem>

namespace fs = std::filesystem;

namespace config::defaults {

extern const char* progname;
extern const bool daemonize;
extern const bool use_syslog;
extern const bool use_console;
extern const fs::path log_file;
extern const uint32_t log_file_max_size;
extern const char* transport_protocol;
extern const char* bind_address;
extern const in_port_t remote_port;
extern const char* pidfile;
extern const uint32_t workers_in_pool;
extern const char* staging_directory;
extern const uint32_t backlog_size;
extern const char* config_file;

} // namespace config::defaults

#endif /* CONFIG_DEFAULTS_HPP */
Loading