summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--cmake/ApiDsl.cmake19
-rwxr-xr-xother/astyle/format-source1
-rw-r--r--other/travis/env-linux.sh2
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
264set(TEST_TIMEOUT_SECONDS "" CACHE STRING "Limit runtime of each test to the number of seconds specified") 264set(TEST_TIMEOUT_SECONDS "" CACHE STRING "Limit runtime of each test to the number of seconds specified")
265 265
266option(FORMAT_TEST "Require the format_test to be executed; fail cmake if it can't" OFF)
267
266if(APIDSL AND ASTYLE) 268if(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}")
276elseif(FORMAT_TEST)
277 message(FATAL_ERROR "format_test can not be run, because either APIDSL (${APIDSL}) or ASTYLE (${ASTYLE}) could not be found")
274endif() 278endif()
275 279
276function(auto_test target) 280function(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)
12find_program(ASTYLE NAMES 12find_program(ASTYLE NAMES
13 astyle) 13 astyle
14 $ENV{ASTYLE})
14 15
15function(apidsl) 16function(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
30fi 31fi
31 32
32apidsl_curl() { 33apidsl_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
3CMAKE=cmake 3CMAKE=cmake
4CMAKE_EXTRA_FLAGS="" 4CMAKE_EXTRA_FLAGS="-DFORMAT_TEST=ON"
5NPROC=`nproc` 5NPROC=`nproc`
6CURDIR=$PWD 6CURDIR=$PWD
7 7