~phablet-team/properties-cpp/trunk

« back to all changes in this revision

Viewing changes to cmake/PrePush.cmake

  • Committer: thomas-voss
  • Date: 2013-11-13 09:19:50 UTC
  • Revision ID: thomas.voss@canonical.com-20131113091950-c5hhan2r51kt3pn7
Initial commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#######################################################################
 
2
# A convenience target that carries out the following steps:
 
3
#   - Apply astyle to all source files of interest.
 
4
#   - Build & test in a chroot, comparable setup to CI/Autolanding
 
5
#     and ppa builders. Will fail if new files have not been added.
 
6
#   - Build & test for android.
 
7
#
 
8
# NOTE: This target is very sensitive to the availability of all
 
9
#       all required dependencies. For that, we prefer to fail the
 
10
#       target if deps are missing to make the problem very visible.
 
11
#
 
12
# TODO:
 
13
#   - Wire up the style-check target once we have reached a state
 
14
#     where trunk actually passes the style check.
 
15
#######################################################################
 
16
add_custom_target(
 
17
  pre-push
 
18
 
 
19
  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}  
 
20
)
 
21
 
 
22
#######################################################################
 
23
#      Add target for running astyle with the correct options         #
 
24
#######################################################################
 
25
find_program(ASTYLE_EXECUTABLE astyle)
 
26
 
 
27
if (ASTYLE_EXECUTABLE)
 
28
  add_custom_target(
 
29
    astyle 
 
30
    ${ASTYLE_EXECUTABLE} --style=allman -s4 --indent=spaces=4 --pad-header --align-pointer=type --recursive ${CMAKE_SOURCE_DIR}/include/*.h
 
31
    COMMAND ${ASTYLE_EXECUTABLE} --recursive --style=allman -s4 --indent=spaces=4 --pad-header --align-pointer=type ${CMAKE_SOURCE_DIR}/tests/*.cpp
 
32
    COMMAND ${ASTYLE_EXECUTABLE} --recursive --style=allman -s4 --indent=spaces=4 --pad-header --align-pointer=type ${CMAKE_SOURCE_DIR}/examples/*.h  ${CMAKE_CURRENT_SOURCE_DIR}/examples/*.cpp
 
33
    VERBATIM
 
34
  )
 
35
endif (ASTYLE_EXECUTABLE)
 
36
 
 
37
#######################################################################
 
38
#      Add target for creating a source tarball with bzr export       #
 
39
#######################################################################
 
40
add_custom_target(
 
41
  pre-push-source-tarball
 
42
 
 
43
  COMMAND rm -rf pre-push-build-area
 
44
  COMMAND mkdir pre-push-build-area
 
45
  COMMAND bzr export --root pre-push pre-push-build-area/${PROJECT_NAME}_${DBUS_CPP_VERSION_MAJOR}.${DBUS_CPP_VERSION_MAJOR}.${DBUS_CPP_VERSION_MAJOR}.orig.tar.bz2 ${CMAKE_SOURCE_DIR}
 
46
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
 
47
  COMMENT "Preparing source tarball for pre-push build & test"
 
48
)
 
49
 
 
50
#######################################################################
 
51
#      Add target for extracting source tarball for pdebuild          #
 
52
#######################################################################
 
53
add_custom_target(
 
54
  extract-pre-push-tarball
 
55
  COMMAND tar -xf {PROJECT_NAME}_${DBUS_CPP_VERSION_MAJOR}.${DBUS_CPP_VERSION_MAJOR}.${DBUS_CPP_VERSION_MAJOR}.orig.tar.bz2
 
56
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/pre-push-build-area VERBATIM
 
57
)
 
58
 
 
59
#######################################################################
 
60
#  Builds & tests the last committed revision of the current branch   #
 
61
#######################################################################
 
62
find_program(PDEBUILD_EXECUTABLE pdebuild)
 
63
if(NOT PDEBUILD_EXECUTABLE)
 
64
  message(STATUS "pdebuild NOT found, pre-push is going to FAIL")
 
65
endif()
 
66
 
 
67
add_custom_target(
 
68
  pdebuild
 
69
  COMMAND ${PDEBUILD_EXECUTABLE}
 
70
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/pre-push-build-area/pre-push 
 
71
  COMMENT "Building & testing in chroot'd environment"
 
72
  VERBATIM  
 
73
)
 
74
 
 
75
#######################################################################
 
76
# pdebuild: make tarball -> extract to build area -> pdebuild         #
 
77
# android-build: invoke cross-compile script                          #
 
78
#######################################################################
 
79
add_dependencies(extract-pre-push-tarball pre-push-source-tarball)
 
80
add_dependencies(pdebuild extract-pre-push-tarball)
 
81
 
 
82
add_dependencies(pre-push pdebuild android-build)