~ci-train-bot/location-service/location-service-ubuntu-yakkety-1895

« back to all changes in this revision

Viewing changes to cmake/PrePush.cmake

  • Committer: Thomas Voß
  • Date: 2013-05-28 14:20:45 UTC
  • Revision ID: thomas.voss@canonical.com-20130528142045-kq5umqdmm4o53vwk
Initial push.

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
    VERBATIM
 
33
  )
 
34
endif (ASTYLE_EXECUTABLE)
 
35
 
 
36
#######################################################################
 
37
#      Add target for creating a source tarball with bzr export       #
 
38
#######################################################################
 
39
add_custom_target(
 
40
  pre-push-source-tarball
 
41
 
 
42
  COMMAND rm -rf pre-push-build-area
 
43
  COMMAND mkdir pre-push-build-area
 
44
  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}
 
45
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
 
46
  COMMENT "Preparing source tarball for pre-push build & test"
 
47
)
 
48
 
 
49
#######################################################################
 
50
#      Add target for extracting source tarball for pdebuild          #
 
51
#######################################################################
 
52
add_custom_target(
 
53
  extract-pre-push-tarball
 
54
  COMMAND tar -xf {PROJECT_NAME}_${DBUS_CPP_VERSION_MAJOR}.${DBUS_CPP_VERSION_MAJOR}.${DBUS_CPP_VERSION_MAJOR}.orig.tar.bz2
 
55
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/pre-push-build-area VERBATIM
 
56
)
 
57
 
 
58
#######################################################################
 
59
#  Builds & tests the last committed revision of the current branch   #
 
60
#######################################################################
 
61
find_program(PDEBUILD_EXECUTABLE pdebuild)
 
62
if(NOT PDEBUILD_EXECUTABLE)
 
63
  message(STATUS "pdebuild NOT found, pre-push is going to FAIL")
 
64
endif()
 
65
 
 
66
add_custom_target(
 
67
  pdebuild
 
68
  COMMAND ${PDEBUILD_EXECUTABLE}
 
69
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/pre-push-build-area/pre-push 
 
70
  COMMENT "Building & testing in chroot'd environment"
 
71
  VERBATIM  
 
72
)
 
73
 
 
74
#######################################################################
 
75
# pdebuild: make tarball -> extract to build area -> pdebuild         #
 
76
# android-build: invoke cross-compile script                          #
 
77
#######################################################################
 
78
add_dependencies(extract-pre-push-tarball pre-push-source-tarball)
 
79
add_dependencies(pdebuild extract-pre-push-tarball)
 
80
 
 
81
add_dependencies(pre-push pdebuild android-build)