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/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ jobs:
archive="ptfkit-native-${version}.tar.gz"
tar --sort=name --mtime="UTC 1970-01-01" --owner=0 --group=0 --numeric-owner \
--transform="s,^targets/ptfkit-native,ptfkit-native-${version}," \
-czf "$archive" targets/ptfkit-native
-czf "$archive" \
targets/ptfkit-native/CMakeLists.txt \
targets/ptfkit-native/LICENSE \
targets/ptfkit-native/README.md \
targets/ptfkit-native/cmake \
targets/ptfkit-native/cpp \
targets/ptfkit-native/include
sha256sum "$archive" > "$archive.sha256"
echo "archive=$archive" >> "$GITHUB_ENV"
- name: Attest native archive provenance
Expand Down
10 changes: 1 addition & 9 deletions codegen/src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@ layout!(
C_HEADER,
Formatter::Cpp
);
layout!(
NATIVE_CPP_CMAKE,
"targets/ptfkit-native/cmake",
"targets/ptfkit-native/cmake",
PYTHON_HEADER,
Formatter::None
);
layout!(
NATIVE_C_TEST,
"targets/ptfkit-native/tests/c",
Expand All @@ -130,7 +123,7 @@ layout!(
Formatter::Cpp
);

pub(crate) const LAYOUTS: [&Layout; 13] = [
pub(crate) const LAYOUTS: [&Layout; 12] = [
&CATALOG,
&REFERENCE_C,
&REFERENCE_CPP,
Expand All @@ -141,7 +134,6 @@ pub(crate) const LAYOUTS: [&Layout; 13] = [
&PYTHON_TEST,
&NATIVE_C,
&NATIVE_CPP_MODULE,
&NATIVE_CPP_CMAKE,
&NATIVE_C_TEST,
&NATIVE_CPP_TEST,
];
Expand Down
1 change: 0 additions & 1 deletion codegen/src/targets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ pub(crate) fn run(root: &Path, entries: Vec<Entry>) -> Result<()> {
Output::new(&output::PYTHON_TEST, python.tests),
Output::new(&output::NATIVE_C, native.c_headers),
Output::new(&output::NATIVE_CPP_MODULE, native.cpp_modules),
Output::new(&output::NATIVE_CPP_CMAKE, native.cpp_cmake),
Output::new(&output::NATIVE_C_TEST, native.c_tests),
Output::new(&output::NATIVE_CPP_TEST, native.cpp_tests),
],
Expand Down
11 changes: 0 additions & 11 deletions codegen/src/targets/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ use crate::{
};

pub(super) const HEADER: &str = "/* @generated by ptfkit-codegen; DO NOT EDIT. */\n";
pub(super) const CMAKE_HEADER: &str = "# @generated by ptfkit-codegen; DO NOT EDIT.\n";

pub(super) struct OutputFiles {
pub(super) c_headers: Vec<GeneratedFile>,
pub(super) cpp_modules: Vec<GeneratedFile>,
pub(super) cpp_cmake: Vec<GeneratedFile>,
pub(super) c_tests: Vec<GeneratedFile>,
pub(super) cpp_tests: Vec<GeneratedFile>,
}
Expand Down Expand Up @@ -57,18 +55,9 @@ pub(super) fn render(functions: &[CompiledFunction]) -> Result<OutputFiles> {

cpp_modules.push(file("ptfkit.cppm", root_module.into_string()));

let mut cmake = Writer::new();
cmake.write(format_args!("{CMAKE_HEADER}\nset(PTFKIT_CPP_MODULES\n"));
cmake.indented(|writer| {
for path in &module_paths {
writer.line(format_args!("\"${{CMAKE_CURRENT_LIST_DIR}}/../{path}\""));
}
});
cmake.line(")");
Ok(OutputFiles {
c_headers,
cpp_modules,
cpp_cmake: vec![file("ptfkitModules.cmake", cmake.into_string())],
c_tests,
cpp_tests,
})
Expand Down
35 changes: 11 additions & 24 deletions targets/ptfkit-native/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.21)

include(cmake/ptfkitVersion.cmake)
project(ptfkit VERSION ${PTFKIT_VERSION} LANGUAGES C CXX)
project(ptfkit VERSION ${PTFKIT_VERSION} LANGUAGES C)

include(CMakePackageConfigHelpers)
include(CMakeDependentOption)
Expand All @@ -11,7 +11,12 @@ add_library(ptfkit_c INTERFACE)
add_library(ptfkit::c ALIAS ptfkit_c)
set_target_properties(ptfkit_c PROPERTIES EXPORT_NAME c)
target_compile_features(ptfkit_c INTERFACE c_std_11)
target_compile_definitions(ptfkit_c INTERFACE PTFKIT_VERSION=\"${PROJECT_VERSION}\")
target_compile_definitions(ptfkit_c INTERFACE
PTFKIT_VERSION=\"${PROJECT_VERSION}\"
)
if(UNIX)
target_link_libraries(ptfkit_c INTERFACE m)
endif()
target_include_directories(ptfkit_c INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
Expand All @@ -26,21 +31,9 @@ cmake_dependent_option(
)

if(PTFKIT_BUILD_CPP_MODULES)
include(cmake/ptfkitModules.cmake)
add_library(ptfkit_cpp)
add_library(ptfkit::cpp ALIAS ptfkit_cpp)
set_target_properties(ptfkit_cpp PROPERTIES
EXPORT_NAME cpp CXX_SCAN_FOR_MODULES ON
)
target_compile_features(ptfkit_cpp PUBLIC cxx_std_20)
target_compile_definitions(ptfkit_cpp PUBLIC PTFKIT_VERSION=\"${PROJECT_VERSION}\")
target_compile_options(ptfkit_cpp PUBLIC
$<$<CXX_COMPILER_ID:GNU>:-fmodules-ts>
)
target_sources(ptfkit_cpp PUBLIC
FILE_SET CXX_MODULES
FILES ${PTFKIT_CPP_MODULES}
)
enable_language(CXX)
add_subdirectory(cpp)
set(INSTALL_EXPORT_ARGS CXX_MODULES_DIRECTORY cxx-modules)
endif()

install(TARGETS ptfkit_c EXPORT ptfkitTargets)
Expand All @@ -52,17 +45,11 @@ install(
FILES README.md LICENSE
DESTINATION ${CMAKE_INSTALL_DOCDIR}
)
if(PTFKIT_BUILD_CPP_MODULES)
install(
TARGETS ptfkit_cpp
EXPORT ptfkitTargets
FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_LIBDIR}/ptfkit/modules
)
endif()
install(
EXPORT ptfkitTargets
NAMESPACE ptfkit::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ptfkit
${INSTALL_EXPORT_ARGS}
)
configure_package_config_file(
cmake/ptfkitConfig.cmake.in
Expand Down
26 changes: 0 additions & 26 deletions targets/ptfkit-native/cmake/ptfkitModules.cmake

This file was deleted.

22 changes: 22 additions & 0 deletions targets/ptfkit-native/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
add_library(ptfkit_cpp)
add_library(ptfkit::cpp ALIAS ptfkit_cpp)
set_target_properties(ptfkit_cpp PROPERTIES
EXPORT_NAME cpp CXX_SCAN_FOR_MODULES ON
)
target_compile_features(ptfkit_cpp PUBLIC cxx_std_20)
target_compile_definitions(ptfkit_cpp PUBLIC
PTFKIT_VERSION=\"${PROJECT_VERSION}\"
)
target_compile_options(ptfkit_cpp PUBLIC
$<$<CXX_COMPILER_ID:GNU>:-fmodules-ts>
)
file(GLOB_RECURSE PTFKIT_CPP_MODULES CONFIGURE_DEPENDS *.cppm)
target_sources(ptfkit_cpp PUBLIC
FILE_SET CXX_MODULES
FILES ${PTFKIT_CPP_MODULES}
)
install(
TARGETS ptfkit_cpp
EXPORT ptfkitTargets
FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_LIBDIR}/ptfkit/modules
)
8 changes: 7 additions & 1 deletion targets/ptfkit-native/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ endfunction()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

add_subdirectory(c)
add_subdirectory(cpp_fallback)

include(CheckLanguage)
check_language(CXX)
if(CMAKE_CXX_COMPILER)
enable_language(CXX)
add_subdirectory(cpp_fallback)
endif()

if(PTFKIT_BUILD_CPP_MODULES)
add_subdirectory(cpp)
Expand Down