Skip to content

Commit 4c685d8

Browse files
committed
Add conditional compiliation attributes for modules
1 parent d81faf8 commit 4c685d8

File tree

3 files changed

+63
-66
lines changed

3 files changed

+63
-66
lines changed

Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ exclude = [
1414
"arrayfire/*",
1515
]
1616

17+
[features]
18+
algorithm = []
19+
arithmetic = []
20+
blas = []
21+
data = []
22+
indexing = []
23+
graphics = []
24+
image = []
25+
lapack = []
26+
macros = []
27+
random = []
28+
signal = []
29+
sparse = []
30+
statistics = []
31+
vision = []
32+
default = ["algorithm", "arithmetic", "blas", "data", "indexing", "graphics", "image", "lapack",
33+
"macros", "random", "signal", "sparse", "statistics", "vision"]
34+
1735
[dependencies]
1836
libc = "0.2.11"
1937
num = "0.1.32"

src/array.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use self::libc::{uint8_t, c_void, c_int, c_uint, c_longlong, c_char};
88
use std::ffi::CString;
99

1010
// Some unused functions from array.h in C-API of ArrayFire
11-
// af_create_handle
1211
// af_copy_array
1312
// af_write_array
1413
// af_get_data_ref_count

src/lib.rs

Lines changed: 45 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -34,50 +34,36 @@
3434
#[macro_use]
3535
extern crate lazy_static;
3636

37-
pub use array::Array;
38-
pub use array::{print, print_gen, eval_multiple, is_eval_manual, set_manual_eval};
37+
pub use array::*;
3938
mod array;
4039

41-
//pub use algorithm::{sum_nan, product_nan, sum_nan_all, product_nan_all};
42-
pub use algorithm::{sum, product, min, max, all_true, any_true, count, sum_nan, product_nan};
43-
pub use algorithm::{sum_all, product_all, min_all, max_all, sum_nan_all, product_nan_all};
44-
pub use algorithm::{all_true_all, any_true_all, count_all, imin, imax, imin_all, imax_all};
45-
pub use algorithm::{accum, locate, diff1, diff2, sort, sort_index, sort_by_key};
46-
pub use algorithm::{set_unique, set_union, set_intersect, scan, scan_by_key};
40+
#[cfg(feature="algorithm")]
41+
pub use algorithm::*;
42+
#[cfg(feature="algorithm")]
4743
mod algorithm;
4844

49-
pub use arith::{add, sub, div, mul, lt, gt, le, ge, eq, neq, and, or, minof, maxof, rem};
50-
pub use arith::{bitand, bitor, bitxor, shiftl, shiftr};
51-
pub use arith::{abs, sign, round, trunc, floor, ceil, modulo, sigmoid, clamp};
52-
pub use arith::{sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh};
53-
pub use arith::{atan2, cplx2, arg, cplx, real, imag, conjg, hypot};
54-
pub use arith::{sqrt, log, log1p, log10, log2, pow2, exp, expm1, erf, erfc, root, pow};
55-
pub use arith::{cbrt, factorial, tgamma, lgamma, iszero, isinf, isnan};
45+
#[cfg(feature="arithmetic")]
46+
pub use arith::*;
47+
#[cfg(feature="arithmetic")]
5648
mod arith;
5749

58-
pub use backend::{set_backend, get_backend_count, get_available_backends, get_active_backend};
50+
pub use backend::*;
5951
mod backend;
6052

61-
pub use blas::{matmul, dot, transpose, transpose_inplace};
53+
#[cfg(feature="blas")]
54+
pub use blas::*;
55+
#[cfg(feature="blas")]
6256
mod blas;
6357

64-
pub use data::{constant, range, iota, identity};
65-
pub use data::{diag_create, diag_extract, lower, upper};
66-
pub use data::{join, join_many, tile};
67-
pub use data::{reorder, shift, moddims, flat, flip};
68-
pub use data::{select, selectl, selectr, replace, replace_scalar};
69-
pub use data::{range_t, iota_t, identity_t, constant_t};
58+
#[cfg(feature="data")]
59+
pub use data::*;
60+
#[cfg(feature="data")]
7061
mod data;
7162

72-
pub use device::{get_version, get_revision, info, info_string, device_info, init, device_count, is_double_available, set_device, get_device};
73-
pub use device::{device_mem_info, print_mem_info, set_mem_step_size, get_mem_step_size, device_gc, sync};
63+
pub use device::*;
7464
mod device;
7565

76-
pub use defines::{DType, AfError, Backend, ColorMap, YCCStd, HomographyType};
77-
pub use defines::{InterpType, BorderType, MatchType, NormType};
78-
pub use defines::{Connectivity, ConvMode, ConvDomain, ColorSpace, MatProp};
79-
pub use defines::{MarkerType, MomentType, SparseFormat, BinaryOp, RandomEngineType};
80-
pub use defines::{PHILOX, THREEFRY, MERSENNE, DEFAULT_RANDOM_ENGINE, Scalar};
66+
pub use defines::*;
8167
mod defines;
8268

8369
pub use dim4::Dim4;
@@ -86,68 +72,62 @@ mod dim4;
8672
pub use error::{Callback, ErrorCallback, register_error_handler, handle_error_general};
8773
mod error;
8874

89-
pub use index::{Indexer, index, row, rows, col, cols, slice, slices,
90-
set_row, set_rows, set_col, set_cols, set_slice, set_slices,
91-
lookup, assign_seq, index_gen, assign_gen};
75+
#[cfg(feature="indexing")]
76+
pub use index::*;
77+
#[cfg(feature="indexing")]
9278
mod index;
9379

9480
pub use seq::Seq;
9581
mod seq;
9682

83+
#[cfg(feature="graphics")]
9784
pub use graphics::Window;
85+
#[cfg(feature="graphics")]
9886
mod graphics;
9987

100-
pub use image::{gaussian_kernel, load_image, load_image_native, save_image, save_image_native};
101-
pub use image::{resize, transform, rotate, translate, scale, skew};
102-
pub use image::{dilate, dilate3, erode, erode3, minfilt, maxfilt};
103-
pub use image::{gradient, histogram, hist_equal, regions};
104-
pub use image::{gray2rgb, rgb2gray, hsv2rgb, rgb2hsv, color_space};
105-
pub use image::{bilateral, mean_shift, medfilt, sobel, medfilt1};
106-
pub use image::{unwrap, wrap, sat, rgb2ycbcr, ycbcr2rgb, is_imageio_available, transform_coords};
107-
pub use image::{moments, moments_all};
88+
#[cfg(feature="image")]
89+
pub use image::*;
90+
#[cfg(feature="image")]
10891
mod image;
10992

110-
pub use lapack::{svd, lu, qr, cholesky, solve, solve_lu, inverse, det, rank, norm};
111-
pub use lapack::{svd_inplace, lu_inplace, qr_inplace, cholesky_inplace, is_lapack_available};
93+
#[cfg(feature="lapack")]
94+
pub use lapack::*;
95+
#[cfg(feature="lapack")]
11296
mod lapack;
97+
98+
#[cfg(feature="macros")]
11399
mod macros;
114100
mod num;
115101

116-
pub use random::RandomEngine;
117-
pub use random::{set_seed, get_seed, randu, randn, random_uniform, random_normal};
118-
pub use random::{get_default_random_engine, set_default_random_engine_type};
102+
#[cfg(feature="random")]
103+
pub use random::*;
104+
#[cfg(feature="random")]
119105
mod random;
120106

121-
pub use signal::{approx1, approx2, set_fft_plan_cache_size};
122-
pub use signal::{fft, fft2, fft3, ifft, ifft2, ifft3};
123-
pub use signal::{fft_r2c, fft2_r2c, fft3_r2c, fft_c2r, fft2_c2r, fft3_c2r};
124-
pub use signal::{fft_inplace, fft2_inplace, fft3_inplace};
125-
pub use signal::{ifft_inplace, ifft2_inplace, ifft3_inplace};
126-
pub use signal::{convolve1, convolve2, convolve3, convolve2_sep};
127-
pub use signal::{fft_convolve1, fft_convolve2, fft_convolve3};
128-
pub use signal::{fir, iir};
107+
#[cfg(feature="signal")]
108+
pub use signal::*;
109+
#[cfg(feature="signal")]
129110
mod signal;
130111

131-
pub use sparse::{sparse, sparse_from_host, sparse_from_dense, sparse_convert_to};
132-
pub use sparse::{sparse_to_dense, sparse_get_info, sparse_get_values, sparse_get_nnz};
133-
pub use sparse::{sparse_get_row_indices, sparse_get_col_indices, sparse_get_format};
112+
#[cfg(feature="sparse")]
113+
pub use sparse::*;
114+
#[cfg(feature="sparse")]
134115
mod sparse;
135116

136-
pub use statistics::{mean, stdev, median, var, cov, corrcoef};
137-
pub use statistics::{mean_weighted, var_weighted};
138-
pub use statistics::{var_all, mean_all, stdev_all, median_all};
139-
pub use statistics::{mean_all_weighted, var_all_weighted};
117+
#[cfg(feature="statistics")]
118+
pub use statistics::*;
119+
#[cfg(feature="statistics")]
140120
mod statistics;
141121

142122
pub use util::{HasAfEnum, get_size};
143123
mod util;
144124

145-
pub use vision::Features;
146-
pub use vision::{fast, harris, orb, hamming_matcher, nearest_neighbour, match_template, susan, dog};
147-
pub use vision::{homography};
125+
#[cfg(feature="vision")]
126+
pub use vision::*;
127+
#[cfg(feature="vision")]
148128
mod vision;
149129

150-
// headers that are not exposed through rust wrapper are as follows:
130+
// headers that are not exposed through rust wrapper are given follows:
151131
// compatible.h
152132
// constants.h
153133
// complex.h

0 commit comments

Comments
 (0)