diff options
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | cmake/ApiDsl.cmake | 19 | ||||
-rwxr-xr-x | other/astyle/format-source | 1 | ||||
-rw-r--r-- | other/travis/env-linux.sh | 2 |
4 files changed, 23 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c0d10c20..b4e18274 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -263,6 +263,8 @@ target_link_modules(toxencryptsave toxcore) | |||
263 | 263 | ||
264 | set(TEST_TIMEOUT_SECONDS "" CACHE STRING "Limit runtime of each test to the number of seconds specified") | 264 | set(TEST_TIMEOUT_SECONDS "" CACHE STRING "Limit runtime of each test to the number of seconds specified") |
265 | 265 | ||
266 | option(FORMAT_TEST "Require the format_test to be executed; fail cmake if it can't" OFF) | ||
267 | |||
266 | if(APIDSL AND ASTYLE) | 268 | if(APIDSL AND ASTYLE) |
267 | add_test( | 269 | add_test( |
268 | NAME format_test | 270 | NAME format_test |
@@ -271,6 +273,8 @@ if(APIDSL AND ASTYLE) | |||
271 | "${APIDSL}" | 273 | "${APIDSL}" |
272 | "${ASTYLE}") | 274 | "${ASTYLE}") |
273 | set_tests_properties(format_test PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}") | 275 | set_tests_properties(format_test PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}") |
276 | elseif(FORMAT_TEST) | ||
277 | message(FATAL_ERROR "format_test can not be run, because either APIDSL (${APIDSL}) or ASTYLE (${ASTYLE}) could not be found") | ||
274 | endif() | 278 | endif() |
275 | 279 | ||
276 | function(auto_test target) | 280 | function(auto_test target) |
diff --git a/cmake/ApiDsl.cmake b/cmake/ApiDsl.cmake index 777714ab..759f7f05 100644 --- a/cmake/ApiDsl.cmake +++ b/cmake/ApiDsl.cmake | |||
@@ -10,14 +10,29 @@ find_program(APIDSL NAMES | |||
10 | apidsl.byte | 10 | apidsl.byte |
11 | ${CMAKE_SOURCE_DIR}/../apidsl/apigen.native) | 11 | ${CMAKE_SOURCE_DIR}/../apidsl/apigen.native) |
12 | find_program(ASTYLE NAMES | 12 | find_program(ASTYLE NAMES |
13 | astyle) | 13 | astyle |
14 | $ENV{ASTYLE}) | ||
14 | 15 | ||
15 | function(apidsl) | 16 | function(apidsl) |
16 | if(APIDSL AND ASTYLE) | 17 | if(APIDSL AND ASTYLE) |
17 | foreach(in_file ${ARGN}) | 18 | foreach(in_file ${ARGN}) |
18 | get_filename_component(dirname ${in_file} DIRECTORY) | 19 | # Get the directory component of the input file name. |
20 | if(CMAKE_VERSION VERSION_LESS 3.0) | ||
21 | execute_process( | ||
22 | COMMAND dirname ${in_file} | ||
23 | OUTPUT_VARIABLE dirname | ||
24 | OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
25 | else() | ||
26 | get_filename_component(dirname ${in_file} DIRECTORY) | ||
27 | endif() | ||
28 | |||
29 | # Get the name without extension (i.e. without ".api.h"). | ||
19 | get_filename_component(filename ${in_file} NAME_WE) | 30 | get_filename_component(filename ${in_file} NAME_WE) |
31 | |||
32 | # Put them together, with the new extension that is ".h". | ||
20 | set(out_file ${CMAKE_SOURCE_DIR}/${dirname}/${filename}.h) | 33 | set(out_file ${CMAKE_SOURCE_DIR}/${dirname}/${filename}.h) |
34 | |||
35 | # Run apidsl. | ||
21 | add_custom_command( | 36 | add_custom_command( |
22 | OUTPUT ${out_file} | 37 | OUTPUT ${out_file} |
23 | COMMAND "${APIDSL}" "${CMAKE_SOURCE_DIR}/${in_file}" | 38 | COMMAND "${APIDSL}" "${CMAKE_SOURCE_DIR}/${in_file}" |
diff --git a/other/astyle/format-source b/other/astyle/format-source index 624864ab..d623926d 100755 --- a/other/astyle/format-source +++ b/other/astyle/format-source | |||
@@ -27,6 +27,7 @@ if ! which "$APIDSL"; then | |||
27 | APIDSL=../apidsl/apigen.native | 27 | APIDSL=../apidsl/apigen.native |
28 | else | 28 | else |
29 | APIDSL=apidsl_curl | 29 | APIDSL=apidsl_curl |
30 | fi | ||
30 | fi | 31 | fi |
31 | 32 | ||
32 | apidsl_curl() { | 33 | apidsl_curl() { |
diff --git a/other/travis/env-linux.sh b/other/travis/env-linux.sh index 16dbb8cc..a8b1d5ae 100644 --- a/other/travis/env-linux.sh +++ b/other/travis/env-linux.sh | |||
@@ -1,7 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | CMAKE=cmake | 3 | CMAKE=cmake |
4 | CMAKE_EXTRA_FLAGS="" | 4 | CMAKE_EXTRA_FLAGS="-DFORMAT_TEST=ON" |
5 | NPROC=`nproc` | 5 | NPROC=`nproc` |
6 | CURDIR=$PWD | 6 | CURDIR=$PWD |
7 | 7 | ||