File: merge_cmake_install.py

package info (click to toggle)
pcl 1.15.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 143,128 kB
  • sloc: cpp: 520,234; xml: 28,792; ansic: 8,212; python: 334; lisp: 93; sh: 49; makefile: 30
file content (36 lines) | stat: -rw-r--r-- 1,058 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/env python
# file: merge_cmake_install.py

import sys, math
import fnmatch
import os
import shutil

if len(sys.argv) != 2: 
  # stop the program and print an error message
  sys.exit("Must provide a cmake binary folder")

base_folder = sys.argv[1]

string_to_remove_debug = "IF(\"${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^([Dd][Ee][Bb][Uu][Gg])$\")"
string_to_remove_release = "IF(\"${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$\")"

matches = []
for root, dirnames, filenames in os.walk(base_folder):
  for filename in fnmatch.filter(filenames, 'cmake_install.cmake'):
      matches.append(os.path.join(root, filename))
	  
for one_match in matches:
	#print one_match, "\n"
	shutil.move( one_match, one_match+"~" )
	destination= open( one_match, "w" )
	source= open( one_match+"~", "r" )
	for line in source:
		if string_to_remove_debug in line:
			destination.write( "\n" )
		elif string_to_remove_release in line:
			destination.write( "\n" )
		else:
			destination.write( line )
	source.close()
	destination.close()