Skip to content

Commit

Permalink
cxx-qt-cli: add feature for outputting absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing authored and ahayzen-kdab committed Jul 19, 2022
1 parent e7ea193 commit 8931138
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ add_subdirectory(examples)
# Create helper method which adds relevent cargo tests for a given manifest
function(add_test_cargo TEST_NAME_PREFIX MANIFEST_PATH ADD_DOCTESTS)
# Add cargo as a test
add_test(NAME ${TEST_NAME_PREFIX}_cargo_tests COMMAND cargo test --all-targets --all-features --manifest-path ${MANIFEST_PATH})
add_test(NAME ${TEST_NAME_PREFIX}_cargo_tests COMMAND cargo test --all-targets --manifest-path ${MANIFEST_PATH})
# Check if we should enable doc tests
if (${ADD_DOCTESTS} STREQUAL "DOCTESTS_ON")
# Add cargo docs as a test
add_test(NAME ${TEST_NAME_PREFIX}_cargo_doc_tests COMMAND cargo test --doc --manifest-path ${MANIFEST_PATH})
endif()
# Add clippy as a test
add_test(NAME ${TEST_NAME_PREFIX}_cargo_clippy COMMAND cargo clippy --all-targets --all-features --manifest-path ${MANIFEST_PATH} -- -D warnings)
add_test(NAME ${TEST_NAME_PREFIX}_cargo_clippy COMMAND cargo clippy --all-targets --manifest-path ${MANIFEST_PATH} -- -D warnings)
# Add rustfmt as a test
add_test(NAME ${TEST_NAME_PREFIX}_cargo_fmt COMMAND cargo fmt --manifest-path ${MANIFEST_PATH} -- --check)
endfunction()
Expand Down
6 changes: 6 additions & 0 deletions cxx-qt-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ path = "src/main.rs"
[dependencies]
cxx-qt-build = { path = "../cxx-qt-build" }
clap = { version = "^3.2.12", features = [ "derive" ] }

[features]
# Requires nightly compiler until std::path::absolute is stabilized
# https://github.com/rust-lang/rust/issues/92750
# TODO: enable by default when stabilized
absolute-paths = []
4 changes: 4 additions & 0 deletions cxx-qt-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
// SPDX-FileContributor: Be Wilson <be.wilson@kdab.com>
// SPDX-License-Identifier: MIT OR Apache-2.0
#![cfg_attr(feature = "absolute-paths", feature(absolute_path))]

use clap::Parser;
use cxx_qt_build::GeneratedCpp;
Expand All @@ -25,6 +26,9 @@ fn main() {
let output_file_paths = generated_code.write_to_directory(&cli.output);

for output_file_path in output_file_paths {
#[cfg(feature = "absolute-paths")]
let output_file_path = std::path::absolute(output_file_path).unwrap();

println!("{}", output_file_path.display());
}
}

0 comments on commit 8931138

Please sign in to comment.