Skip to content

Commit 2287c5c

Browse files
committed
Move AF_REVISION and AF_COMPILER_STR to backend/version.hpp
* AF_REVISION was in version.h which is included in defines.h * Which meant with each new commit, the entire source would have to be rebuilt * AF_REVISION is only required by src/backend/*/platform.cpp * So AF_REVISION has been moved into backend/version.hpp and is compiled into the library * Renamed AF_CMPLR_STR to AF_COMPILER_STR * Moved AF_COMPILER_STR into version.hpp as it is also only required by backend/platform.cpp * src/backend/version.hpp is generated by CMake using Version.cmake and version.hpp.in
1 parent b1ee11c commit 2287c5c

File tree

7 files changed

+24
-4
lines changed

7 files changed

+24
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ GRTAGS
99
GPATH
1010
.dir-locals.el
1111
include/af/version.h
12+
src/backend/version.hpp
1213
docs/details/examples.dox

CMakeModules/Version.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ CONFIGURE_FILE(
3636
${CMAKE_MODULE_PATH}/version.h.in
3737
${CMAKE_SOURCE_DIR}/include/af/version.h
3838
)
39+
40+
CONFIGURE_FILE(
41+
${CMAKE_MODULE_PATH}/version.hpp.in
42+
${CMAKE_SOURCE_DIR}/src/backend/version.hpp
43+
)

CMakeModules/version.h.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@
1414
#define AF_VERSION_MINOR @AF_VERSION_MINOR@
1515
#define AF_VERSION_PATCH @AF_VERSION_PATCH@
1616
#define AF_API_VERSION_CURRENT @AF_API_VERSION_CURRENT@
17-
#define AF_REVISION "@GIT_COMMIT_HASH@"
18-
#define AF_CMPLR_STR "@AF_COMPILER_STRING@"

CMakeModules/version.hpp.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*******************************************************
2+
* Copyright (c) 2014, ArrayFire
3+
* All rights reserved.
4+
*
5+
* This file is distributed under 3-clause BSD license.
6+
* The complete license agreement can be obtained at:
7+
* http://arrayfire.com/licenses/BSD-3-Clause
8+
********************************************************/
9+
10+
#pragma once
11+
12+
#define AF_REVISION "@GIT_COMMIT_HASH@"
13+
#define AF_COMPILER_STR "@AF_COMPILER_STRING@"

src/backend/cpu/platform.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <iostream>
1616
#include <string>
1717
#include <defines.hpp>
18+
#include <version.hpp>
1819

1920
#ifdef _WIN32
2021
#include <limits.h>
@@ -203,7 +204,7 @@ std::string getInfo()
203204
info << string("[0] ") << cinfo.vendor() <<": " << cinfo.model() << " ";
204205
info << "Max threads("<< cinfo.threads()<<") ";
205206
#ifndef NDEBUG
206-
info << AF_CMPLR_STR;
207+
info << AF_COMPILER_STR;
207208
#endif
208209
info << std::endl;
209210
return info.str();
@@ -220,7 +221,7 @@ void devprop(char* d_name, char* d_platform, char *d_toolkit, char* d_compute)
220221
snprintf(d_name, 64, "%s", cinfo.vendor().c_str());
221222
snprintf(d_platform, 10, "CPU");
222223
// report the compiler for toolkit
223-
snprintf(d_toolkit, 64, "%s", AF_CMPLR_STR);
224+
snprintf(d_toolkit, 64, "%s", AF_COMPILER_STR);
224225
snprintf(d_compute, 10, "%s", "0.0");
225226
}
226227

src/backend/cuda/platform.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <af/cuda.h>
1212
#include <platform.hpp>
1313
#include <defines.hpp>
14+
#include <version.hpp>
1415
#include <driver.h>
1516
#include <vector>
1617
#include <string>

src/backend/opencl/platform.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <af/version.h>
2828
#include <af/opencl.h>
2929
#include <defines.hpp>
30+
#include <version.hpp>
3031
#include <platform.hpp>
3132
#include <functional>
3233
#include <algorithm>

0 commit comments

Comments
 (0)