<commit_before># **********************************************************
# 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
# 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 ()
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 "")
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_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)<commit_msg>add arg for packing 64-bit build<commit_after># **********************************************************
# 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)
{'fraction_non_alphanumeric': 0.14481877694395656, 'fraction_numerical': 0.01181542391825004, 'mean_word_length': 4.970924690181125, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2793421', 'n_tokens_mistral': 4554, 'n_tokens_neox': 4291, 'n_words': 1206}