Skip to content

Commit abfa2bb

Browse files
committed
convert most of core to header only
1 parent 45404a4 commit abfa2bb

17 files changed

+84
-2
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,14 @@ if (NOT HWY_CMAKE_HEADER_ONLY)
179179
hwy/abort.cc
180180
hwy/aligned_allocator.cc
181181
hwy/nanobenchmark.cc
182-
hwy/per_target.cc
183182
hwy/print.cc
184183
hwy/targets.cc
185184
hwy/timer.cc
186185
)
187186
endif()
188187

188+
list(APPEND HWY_SOURCES hwy/per_target.cc)
189+
189190
set(HWY_TEST_SOURCES
190191
hwy/tests/hwy_gtest.h
191192
hwy/tests/test_util-inl.h

hwy/abort.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
namespace hwy {
2121

2222
namespace {
23+
24+
#ifdef HWY_HEADER_ONLY
25+
inline
26+
#endif
2327
std::string GetBaseName(std::string const& file_name) {
2428
auto last_slash = file_name.find_last_of("/\\");
2529
return file_name.substr(last_slash + 1);

hwy/abort.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ AbortFunc SetAbortFunc(AbortFunc func);
2323

2424
} // namespace hwy
2525

26+
#ifdef HWY_HEADER_ONLY
27+
#include "abort.cc"
28+
#endif
29+
2630
#endif // HIGHWAY_HWY_ABORT_H_

hwy/abort_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
namespace hwy {
1313

1414
#ifdef GTEST_HAS_DEATH_TEST
15+
#ifndef HWY_HEADER_ONLY
1516
namespace {
1617
std::string GetBaseName(std::string const& file_name) {
1718
auto last_slash = file_name.find_last_of("/\\");
1819
return file_name.substr(last_slash + 1);
1920
}
2021
} // namespace
22+
#endif
2123

2224
TEST(AbortDeathTest, AbortDefault) {
2325
std::string expected = std::string("Abort at ") + GetBaseName(__FILE__) +

hwy/aligned_allocator.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
#include <limits>
2424

2525
#include "hwy/base.h"
26+
#ifdef HWY_HEADER_ONLY
27+
#include "hwy/abort.h"
28+
#endif
29+
2630

2731
namespace hwy {
2832
namespace {

hwy/aligned_allocator.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,4 +420,9 @@ class AlignedNDArray {
420420
};
421421

422422
} // namespace hwy
423+
424+
#ifdef HWY_HEADER_ONLY
425+
#include "aligned_allocator.cc"
426+
#endif
427+
423428
#endif // HIGHWAY_HWY_ALIGNED_ALLOCATOR_H_

hwy/aligned_allocator_test.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#include <vector>
2626

2727
#include "hwy/base.h"
28+
#ifdef HWY_HEADER_ONLY
29+
#include "hwy/abort.h"
30+
#endif
2831
#include "hwy/per_target.h"
2932
#include "hwy/tests/hwy_gtest.h"
3033
#include "hwy/tests/test_util-inl.h" // HWY_ASSERT_EQ

hwy/base_test.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
// limitations under the License.
1515

1616
#include "hwy/base.h"
17+
#ifdef HWY_HEADER_ONLY
18+
#include "hwy/abort.h"
19+
#endif
1720

1821
#include <limits>
1922

hwy/examples/profiler_example.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include "hwy/base.h" // Abort
1818
#include "hwy/profiler.h"
1919
#include "hwy/timer.h"
20+
#ifdef HWY_HEADER_ONLY
21+
#include "hwy/abort.h"
22+
#endif
2023

2124
namespace hwy {
2225
namespace {

hwy/nanobenchmark.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#include "hwy/robust_statistics.h"
2828
#include "hwy/timer-inl.h"
2929
#include "hwy/timer.h"
30+
#ifdef HWY_HEADER_ONLY
31+
#include "hwy/abort.h"
32+
#endif
3033

3134
namespace hwy {
3235
namespace {

0 commit comments

Comments
 (0)