Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/mcg-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: cmake
run: cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -B build -S .
run: cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -B build -S .
- name: build
run: cmake --build build --parallel
- name: install
Expand All @@ -58,6 +58,12 @@ jobs:
run: |
CMAKE_PREFIX_PATH=install/lib/cmake/metacg cmake -S graph/test/install -B build-install-test
cmake --build build-install-test
- name: metacg-config-test
run: |
MCG_CFG=install/bin/metacg-config
stat $MCG_CFG
[[ "$($MCG_CFG --prefix)" == "$(cd install; pwd)" ]] || exit 1
[[ "$($MCG_CFG --revision)" == "$(git rev-parse HEAD)" ]] || exit 1

build-container:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,5 @@ option(
if(METACG_BUILD_PYMETACG)
add_subdirectory(pymetacg)
endif()

add_subdirectory(utils)
8 changes: 1 addition & 7 deletions cmake/ToolchainOptions.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
include(json)
include(spdlog)

if(METACG_BUILD_GRAPH_TOOLS
OR METACG_BUILD_CGCOLLECTOR
OR METACG_BUILD_PGIS
)
include(cxxopts-lib)
endif()
include(cxxopts-lib)

# Internal dependencies
function(add_metacg target)
Expand Down
2 changes: 1 addition & 1 deletion graph/test/integration/TargetCollector/TestRunner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ done
echo "Running integration test for TargetCollector script"

echo "{}" > src/wholeProgramCG-${CI_CONCURRENT_ID}.ipcg
test_command=(python3 ../../../../TargetCollector.py \
test_command=(python3 ../../../../utils/TargetCollector.py \
-a=".." \
-g=both \
-b=build-${CI_CONCURRENT_ID} \
Expand Down
1 change: 1 addition & 0 deletions utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(config)
File renamed without changes.
6 changes: 6 additions & 0 deletions utils/config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
add_executable(metacg-config MCGConfig.cpp)
add_config_include(metacg-config)
target_compile_definitions(metacg-config PRIVATE INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
add_cxxopts(metacg-config)

install(TARGETS metacg-config DESTINATION ${CMAKE_INSTALL_BINDIR})
50 changes: 50 additions & 0 deletions utils/config/MCGConfig.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* File: MCGConfig.cpp
* License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at
* https://github.com/tudasc/metacg/LICENSE.txt
*/
#include "config.h"

#include <iostream>

#include "cxxopts.hpp"

int main(int argc, char** argv) {
cxxopts::Options options("metacg-config", "MetaCG configuration tool");
options.add_options("commands")("v,version", "Prints the version of this MetaCG installation")(
"revision", "Prints the revision hash of this MetaCG installation")(
"prefix", "Prints the installation prefix of this MetaCG installation.")("h,help", "Print help");

const cxxopts::ParseResult result = options.parse(argc, argv);

if (result.contains("help")) {
std::cout << options.help() << std::endl;
return EXIT_SUCCESS;
}

// Exactly one of these is allowed at the same time
int optCount = result.count("version") + result.count("revision") + result.count("prefix");
if (optCount == 0) {
std::cerr << "Error: No command specified.\n";
return EXIT_FAILURE;
} else if (optCount > 1) {
std::cerr << "Warning: Multiple mutually exclusive commands specified. Only one of them will be processed.\n";
}

if (result.contains("version")) {
std::cout << MetaCG_VERSION_MAJOR << "." << MetaCG_VERSION_MINOR;
return EXIT_SUCCESS;
}

if (result.contains("revision")) {
std::cout << MetaCG_GIT_SHA;
return EXIT_SUCCESS;
}

if (result.contains("prefix")) {
std::cout << INSTALL_PREFIX;
return EXIT_SUCCESS;
}

return EXIT_SUCCESS;
}