Skip to content

Commit

Permalink
Rename export_ to export- and remove unneeded .h files.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaander committed Aug 29, 2024
1 parent 59b03e6 commit ca1550f
Show file tree
Hide file tree
Showing 21 changed files with 98 additions and 245 deletions.
39 changes: 39 additions & 0 deletions CMake/freud-macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,42 @@ macro(find_package_config_first package)
endif()
endif()
endmacro()

# copy all given files from the current source directory to the current build directory
# files must be specified by relative path
#
# @param files: list of files to copy
# @param target: name of copy target
# @param validate_pattern: Check ${CMAKE_CURRENT_BINARY_DIR}/${validate_pattern} for files
# that are not in ${files} and issue a warning.
# @param Additional parameters: List of files to ignore
function(copy_files_to_build files target validate_pattern)
set(ignore_files ${ARGN})

file(RELATIVE_PATH relative_dir ${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})

foreach(file ${files})
add_custom_command (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${file} ${CMAKE_CURRENT_BINARY_DIR}/${file}
COMMENT "Copy ${relative_dir}/${file}"
)
endforeach()

add_custom_target(copy_${target} ALL DEPENDS ${files})

file(GLOB _matching_files "${CMAKE_CURRENT_BINARY_DIR}/${validate_pattern}")
foreach(file ${_matching_files})
# message("Matching files: ${_matching_files}")
file(RELATIVE_PATH relative_file ${CMAKE_CURRENT_BINARY_DIR} ${file})
# message("Expected files: ${files}")
list(FIND files ${relative_file} found)
if (found EQUAL -1 AND NOT ${relative_file} IN_LIST ignore_files)
message(WARNING "${file} exists but is not provided by the source. "
"Remove this file to prevent unexpected errors.")
endif()
endforeach()
endfunction()
20 changes: 10 additions & 10 deletions freud/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,18 @@ target_include_directories(freud SYSTEM PUBLIC ${PROJECT_SOURCE_DIR}/extern/)
# target_set_install_rpath(_environment)

# box
nanobind_add_module(_box box/module-box.cc box/export_Box.cc)
nanobind_add_module(_box box/module-box.cc box/export-Box.cc)
target_link_libraries(_box PUBLIC TBB::tbb)
target_set_install_rpath(_box)

# locality
nanobind_add_module(_locality locality/module-locality.cc
locality/export_BondHistogramCompute.cc
locality/export_NeighborQuery.cc
locality/export_NeighborList.cc
locality/export_Filter.cc
locality/export_PeriodicBuffer.cc
locality/export_Voronoi.cc
locality/export-BondHistogramCompute.cc
locality/export-NeighborQuery.cc
locality/export-NeighborList.cc
locality/export-Filter.cc
locality/export-PeriodicBuffer.cc
locality/export-Voronoi.cc
)
target_link_libraries(_locality PUBLIC freud TBB::tbb)
target_set_install_rpath(_locality)
Expand All @@ -201,9 +201,7 @@ target_link_libraries(_pmft PUBLIC freud)
target_set_install_rpath(_pmft)

# util
nanobind_add_module(_util util/module-util.cc
util/export_ManagedArray.h
util/export_Vector.h)
nanobind_add_module(_util util/module-util.cc util/export_ManagedArray.h util/export_Vector.h)
target_link_libraries(_util PUBLIC freud)
target_set_install_rpath(_util)

Expand All @@ -221,6 +219,8 @@ set(python_files
util.py)
# cluster.py density.py diffraction.py environment.py order.py interface.py msd.py)

copy_files_to_build("${python_files}" "freud" "*.py")

# install
if (SKBUILD)
install(FILES ${python_files} DESTINATION freud)
Expand Down
2 changes: 1 addition & 1 deletion freud/box/export_Box.cc → freud/box/export-Box.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2010-2024 The Regents of the University of Michigan
// This file is from the freud project, released under the BSD 3-Clause License.

#include "export_Box.h"
#include "export-Box.h"

namespace nb = nanobind;

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion freud/box/module-box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <nanobind/stl/vector.h>

#include "Box.h"
#include "export_Box.h"
#include "export-Box.h"

using namespace freud::box;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) 2010-2024 The Regents of the University of Michigan
// This file is from the freud project, released under the BSD 3-Clause License.

#include "export_BondHistogramCompute.h"

#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <nanobind/stl/shared_ptr.h>
#include <nanobind/stl/vector.h>

#include "BondHistogramCompute.h"

namespace nb = nanobind;

namespace freud { namespace locality {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
// Copyright (c) 2010-2024 The Regents of the University of Michigan
// This file is from the freud project, released under the BSD 3-Clause License.

#include "export_Filter.h"

#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <nanobind/stl/shared_ptr.h>

#include "NeighborQuery.h"
#include "FilterRAD.h"
#include "FilterSANN.h"

namespace nb = nanobind;

namespace freud { namespace locality {

template<typename T, typename shape>
using nb_array = nanobind::ndarray<T, shape, nanobind::device::cpu, nanobind::c_contig>;

namespace wrap {

void compute(std::shared_ptr<Filter> filter, std::shared_ptr<NeighborQuery> nq,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
// Copyright (c) 2010-2024 The Regents of the University of Michigan
// This file is from the freud project, released under the BSD 3-Clause License.

#include "export_NeighborList.h"

#include <nanobind/ndarray.h>
#include <nanobind/operators.h>
#include <nanobind/stl/shared_ptr.h>

#include "NeighborList.h"

namespace nb = nanobind;

namespace freud { namespace locality {

template<typename T, typename shape>
using nb_array = nanobind::ndarray<T, shape, nanobind::device::cpu, nanobind::c_contig>;

namespace wrap {

void ConstructFromArrays(NeighborList* nlist, nb_array<unsigned int, nb::ndim<1>> query_point_indices,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
// Copyright (c) 2010-2024 The Regents of the University of Michigan
// This file is from the freud project, released under the BSD 3-Clause License.

#include "export_NeighborQuery.h"

#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <nanobind/stl/shared_ptr.h>

#include "AABBQuery.h"
#include "LinkCell.h"
#include "RawPoints.h"

namespace nb = nanobind;

template<typename T, typename shape>
using nb_array = nanobind::ndarray<T, shape, nanobind::device::cpu, nanobind::c_contig>;

namespace freud { namespace locality {

namespace wrap {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) 2010-2024 The Regents of the University of Michigan
// This file is from the freud project, released under the BSD 3-Clause License.

#include "export_PeriodicBuffer.h"

#include <nanobind/stl/array.h>
#include <nanobind/stl/shared_ptr.h>

#include "PeriodicBuffer.h"

namespace nb = nanobind;

namespace freud { namespace locality { namespace detail {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) 2010-2024 The Regents of the University of Michigan
// This file is from the freud project, released under the BSD 3-Clause License.

#include "export_Voronoi.h"

#include <nanobind/nanobind.h>
#include <nanobind/stl/shared_ptr.h>

#include "Voronoi.h"

namespace nb = nanobind;

namespace freud { namespace locality {
Expand Down
34 changes: 0 additions & 34 deletions freud/locality/export_BondHistogramCompute.h

This file was deleted.

39 changes: 0 additions & 39 deletions freud/locality/export_Filter.h

This file was deleted.

43 changes: 0 additions & 43 deletions freud/locality/export_NeighborList.h

This file was deleted.

53 changes: 0 additions & 53 deletions freud/locality/export_NeighborQuery.h

This file was deleted.

Loading

0 comments on commit ca1550f

Please sign in to comment.