-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpackage.cmake
184 lines (170 loc) · 6.42 KB
/
package.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# **********************************************************
# Copyright (c) 2010-2011 Google, Inc. All rights reserved.
# Copyright (c) 2009-2010 VMware, Inc. All rights reserved.
# **********************************************************
# Dr. Memory: the memory debugger
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation;
# version 2.1 of the License, and no later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Combines debug and release DrMemory builds into a single package.
# Uses ctest command mode.
#
# Uses same base as DynamoRIO's make/package.cmake.
#
# Invoke like this: "ctest -S package.cmake,dr=<path-to-DynamoRIO>\;build=<build#>"
cmake_minimum_required (VERSION 2.2)
# arguments are a ;-separated list (must escape as \; from ctest_run_script())
set(arg_build "") # build #
set(arg_DR_dir "") # DynamoRIO dir: else builds from local sources
# optional args:
set(arg_ubuild "") # unique build #
set(arg_version "") # version #
set(arg_outdir ".") # directory in which to place deliverables
set(arg_cacheappend "")# string to append to every build's cache
set(arg_drmem_only OFF) # do not include Dr. Heapstat
set(arg_x64_build OFF) # do not include x64 build
# also takes args parsed by runsuite_common_pre.cmake, in particular:
set(arg_preload "") # cmake file to include prior to each 32-bit build
set(arg_preload64 "") # cmake file to include prior to each 64-bit build
set(arg_use_nmake OFF) # use nmake even if gnu make is present
set(arg_cpackappend "")# string to append to CPackConfig.cmake before packaging
foreach (arg ${CTEST_SCRIPT_ARG})
if (${arg} MATCHES "^build=")
string(REGEX REPLACE "^build=" "" arg_build "${arg}")
endif ()
if (${arg} MATCHES "^ubuild=")
string(REGEX REPLACE "^ubuild=" "" arg_ubuild "${arg}")
endif ()
if (${arg} MATCHES "^dr=")
string(REGEX REPLACE "^dr=" "" arg_DR_dir "${arg}")
endif ()
if (${arg} MATCHES "^DR=") # support both caps and lowercase
string(REGEX REPLACE "^DR=" "" arg_DR_dir "${arg}")
endif ()
if (${arg} MATCHES "^version=")
string(REGEX REPLACE "^version=" "" arg_version "${arg}")
endif ()
if (${arg} MATCHES "^outdir=")
string(REGEX REPLACE "^outdir=" "" arg_outdir "${arg}")
endif ()
if (${arg} MATCHES "^cacheappend=")
string(REGEX REPLACE "^cacheappend=" "" arg_cacheappend "${arg}")
endif ()
if (${arg} MATCHES "^cpackappend=")
string(REGEX REPLACE "^cpackappend=" "" arg_cpackappend "${arg}")
endif ()
if (${arg} MATCHES "^drmem_only" OR
${arg} MATCHES "^drmemory_only")
set(arg_drmem_only ON)
endif ()
if (${arg} MATCHES "^x64_build")
set(arg_x64_build ON)
endif ()
endforeach (arg)
if ("${arg_build}" STREQUAL "")
message(FATAL_ERROR "build number not set: pass as build= arg")
endif()
if ("${arg_ubuild}" STREQUAL "")
set(arg_ubuild "${arg_build}")
endif()
if (NOT "${arg_DR_dir}" STREQUAL "")
if (NOT EXISTS "${arg_DR_dir}")
message(FATAL_ERROR "invalid DynamoRIO dr= arg")
endif ()
set(DR_entry "DynamoRIO_DIR:PATH=${arg_DR_dir}")
set(runsuite_include_path "${arg_DR_dir}")
else ()
set(DR_entry "")
# include from source instead of exports dir
set(runsuite_include_path "${CTEST_SCRIPT_DIRECTORY}/dynamorio/suite")
endif()
set(CTEST_PROJECT_NAME "DrMemory")
set(cpack_project_name "DrMemory")
set(run_tests OFF)
set(CTEST_SOURCE_DIRECTORY "${CTEST_SCRIPT_DIRECTORY}")
include("${runsuite_include_path}/runsuite_common_pre.cmake")
# i#1099: be sure to set BUILDING_PACKAGE
set(base_cache "
${DR_entry}
TOOL_BUILD_NUMBER:STRING=${arg_build}
UNIQUE_BUILD_NUMBER:STRING=${arg_ubuild}
BUILD_TOOL_TESTS:BOOL=OFF
BUILDING_PACKAGE:BOOL=ON
${arg_cacheappend}
${base_cache}
")
# version is optional
if (arg_version)
set(base_cache "${base_cache}
TOOL_VERSION_NUMBER:STRING=${arg_version}")
endif (arg_version)
# the build dir names here must match those in tests/runsuite.cmake to
# support running ctest using gobuild-packaged builds (PR 518715, PR 544430).
# perhaps the two scripts should be further merged.
if ("${arg_cacheappend}" MATCHES "VMKERNEL:BOOL=ON")
set(name_sfx "vmk-")
elseif ("${arg_cacheappend}" MATCHES "USE_DRSYMS:BOOL=OFF")
set(name_sfx "cygwin-")
else ()
set(name_sfx "")
endif ()
if (NOT arg_drmem_only)
testbuild_ex("drheapstat-${name_sfx}release-32" OFF "
TOOL_DR_HEAPSTAT:BOOL=ON
CMAKE_BUILD_TYPE:STRING=Release
" OFF ON "")
testbuild_ex("drheapstat-${name_sfx}debug-32" OFF "
TOOL_DR_HEAPSTAT:BOOL=ON
CMAKE_BUILD_TYPE:STRING=Debug
" OFF ON "")
if (arg_x64_build)
testbuild_ex("drheapstat-${name_sfx}release-64" ON "
TOOL_DR_HEAPSTAT:BOOL=ON
CMAKE_BUILD_TYPE:STRING=Release
" OFF ON "")
testbuild_ex("drheapstat-${name_sfx}debug-64" ON "
TOOL_DR_HEAPSTAT:BOOL=ON
CMAKE_BUILD_TYPE:STRING=Debug
" OFF ON "")
endif (arg_x64_build)
endif (NOT arg_drmem_only)
testbuild_ex("drmemory-${name_sfx}release-32" OFF "
CMAKE_BUILD_TYPE:STRING=Release
" OFF ON "")
testbuild_ex("drmemory-${name_sfx}debug-32" OFF "
CMAKE_BUILD_TYPE:STRING=Debug
" OFF ON "")
if (arg_x64_build)
testbuild_ex("drmemory-${name_sfx}release-64" ON "
CMAKE_BUILD_TYPE:STRING=Release
" OFF ON "")
testbuild_ex("drmemory-${name_sfx}debug-64" ON "
CMAKE_BUILD_TYPE:STRING=Debug
" OFF ON "")
endif (arg_x64_build)
if (arg_cpackappend)
# ${last_package_build_dir} is a global var set in parent scope by
# testbuild_ex to communicate with runsuite_common_post. We use it to access
# the CPackConfig.cmake file.
file(APPEND "${last_package_build_dir}/CPackConfig.cmake"
"\n${arg_cpackappend}\n")
endif ()
set(build_package ON)
include("${runsuite_include_path}/runsuite_common_post.cmake")
# copy the final archive into cur dir
# "cmake -E copy" only takes one file so use 'z' => .tar.gz or .zip
file(GLOB results ${last_build_dir}/DrMemory-*)
foreach (f ${results})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${f} "${arg_outdir}")
endforeach (f)