mirror of https://github.com/CGAL/cgal
More buid/svn tree managment scripts
This commit is contained in:
parent
5051b403e4
commit
77982c3048
|
|
@ -3153,9 +3153,13 @@ Scripts/developer_scripts/common_impl.rb -text
|
|||
Scripts/developer_scripts/create_assertions.sh eol=lf
|
||||
Scripts/developer_scripts/create_macosx_installer -text
|
||||
Scripts/developer_scripts/list_package_files.rb -text
|
||||
Scripts/developer_scripts/list_pkg_files_impl.rb -text
|
||||
Scripts/developer_scripts/list_package_files_impl.rb -text
|
||||
Scripts/developer_scripts/mirror_all_packages.rb -text
|
||||
Scripts/developer_scripts/mirror_package.rb -text
|
||||
Scripts/developer_scripts/mirror_package_files.rb -text
|
||||
Scripts/developer_scripts/mirror_pkg_files_impl.rb -text
|
||||
Scripts/developer_scripts/mirror_package_impl.rb -text
|
||||
Scripts/developer_scripts/remove_package_files_from_build_tree.rb -text
|
||||
Scripts/developer_scripts/remove_package_files_from_build_tree_impl.rb -text
|
||||
SearchStructures/doc_tex/SearchStructures/d-range.eps -text svneol=unset#application/postscript
|
||||
SearchStructures/doc_tex/SearchStructures/d-range.gif -text svneol=unset#image/gif
|
||||
SearchStructures/doc_tex/SearchStructures/d-range.pdf -text svneol=unset#application/pdf
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
require 'Pathname'
|
||||
|
||||
class Logger
|
||||
|
||||
attr_accessor(:device)
|
||||
|
|
@ -13,20 +11,16 @@ class Logger
|
|||
end
|
||||
end
|
||||
|
||||
ENDL = "\n" unless defined?(ENDL)
|
||||
ENDL = "\n"
|
||||
|
||||
$debout = Logger.new($stdout)
|
||||
$report = Logger.new($stdout)
|
||||
|
||||
def as_pathname(path)
|
||||
return path.kind_of?(Pathname) ? path : Pathname.new(path)
|
||||
end
|
||||
|
||||
def assert_exist!(path, what)
|
||||
raise "CGAL ERROR: Could not found #{what}: #{path}" unless FileTest.exist?(path)
|
||||
raise "CGAL ERROR: Could not found #{what}: #{path}" unless File.exist?(path)
|
||||
end
|
||||
|
||||
$test_pkg_dir = '../../Straight_skeleton_2'
|
||||
$test_build_dir = '../../Build'
|
||||
|
||||
TEST_PKG_ROOT = '../..'
|
||||
TEST_BUILD_ROOT = '../../Build'
|
||||
TEST_PKG_DIR = '../../Straight_skeleton_2'
|
||||
|
||||
|
|
|
|||
|
|
@ -9,48 +9,51 @@
|
|||
#
|
||||
# == Usage
|
||||
#
|
||||
# list_package_files [OPTIONS]
|
||||
# list_package_files [OPTIONS] package_folder
|
||||
#
|
||||
# OPTIONS:
|
||||
#
|
||||
# -h, --help:
|
||||
# show help
|
||||
#
|
||||
# -d, -package_dir DIR:
|
||||
# Directory where the package exist. Default is the current directory.
|
||||
#
|
||||
# -a, --all_files
|
||||
# Do not exclude internal 'dont submit' files.
|
||||
# -i, --include_internal
|
||||
# Include internal files (excluded by default).
|
||||
#
|
||||
|
||||
|
||||
require 'getoptlong'
|
||||
require 'rdoc/usage'
|
||||
|
||||
load 'list_pkg_files_impl.rb'
|
||||
require 'list_package_files_impl.rb'
|
||||
|
||||
opts = GetoptLong.new( [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
||||
[ '--package_dir', '-d', GetoptLong::OPTIONAL_ARGUMENT ],
|
||||
[ '--all_files', '-a', GetoptLong::OPTIONAL_ARGUMENT ]
|
||||
# -- TEST --
|
||||
# ARGV = [TEST_PKG_DIR]
|
||||
# ARGV = ['-i',TEST_PKG_DIR]
|
||||
# -- TEST --
|
||||
|
||||
opts = GetoptLong.new( [ '--help' , '-h', GetoptLong::NO_ARGUMENT ],
|
||||
[ '--include_internal', '-i', GetoptLong::NO_ARGUMENT ]
|
||||
)
|
||||
|
||||
package_dir = '.'
|
||||
|
||||
exclude_internal = true
|
||||
include_internal = false
|
||||
|
||||
opts.each do |opt, arg|
|
||||
case opt
|
||||
when '--help'
|
||||
RDoc::usage
|
||||
when '--package_dir'
|
||||
package_dir = arg
|
||||
when '--all_files'
|
||||
exclude_internal = false
|
||||
when '--include_internal'
|
||||
include_internal = true
|
||||
end
|
||||
end
|
||||
|
||||
dont_submit = exclude_internal ? pkg_dont_submit_list(package_dir) : ExcludedFiles.new()
|
||||
|
||||
puts list_pkg_files(dont_submit,package_dir)
|
||||
if ARGV.length > 0
|
||||
package_dir = ARGV.shift
|
||||
puts list_package_files(package_dir, include_internal)
|
||||
else
|
||||
RDoc::usage
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
require 'Pathname'
|
||||
|
||||
require 'common_impl.rb'
|
||||
|
||||
# The list can contain wildcards
|
||||
def matches_any_filename_in_list(filename,list)
|
||||
list.each do |item|
|
||||
return true if File.fnmatch(item.chomp,filename)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
#
|
||||
# Returns an array listing the entries that should be excluded from the package file list.
|
||||
# This includes fixed entries hard-coded here and those read from a 'dont_submit' text file, if exits.
|
||||
#
|
||||
def get_internal_package_files_list(package_dir)
|
||||
|
||||
list = ['TODO',
|
||||
'dont_submit',
|
||||
'maintainer',
|
||||
'description.txt',
|
||||
'changes.txt',
|
||||
'doc_tex',
|
||||
'.svn'
|
||||
]
|
||||
|
||||
dont_submit_file = package_dir + '/dont_submit'
|
||||
|
||||
list += IO.readlines(dont_submit_file) if File.exist?(dont_submit_file)
|
||||
|
||||
return list ;
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Fills the 'list' array with relative pathnames to the files in the 'package_dir' folder.
|
||||
# Subdirectories are recursed.
|
||||
# Directory entries mathching any filename in 'internal_files' are skipped.
|
||||
#
|
||||
def list_package_files(package_dir, include_internal = false )
|
||||
|
||||
internal_files = include_internal ? [] : get_internal_package_files_list(package_dir)
|
||||
|
||||
__aux_list_package_files(package_dir, '', [], internal_files )
|
||||
|
||||
end
|
||||
|
||||
def __aux_list_package_files(package_dir, local_subdir, list, internal_files )
|
||||
|
||||
assert_exist!(package_dir, 'package directory' )
|
||||
|
||||
subdir_from_cwd = package_dir + '/' + local_subdir ;
|
||||
|
||||
# Process each entry in the package's folder
|
||||
Dir.foreach(subdir_from_cwd) do |entry|
|
||||
|
||||
entry.chomp!
|
||||
|
||||
unless entry == '.' || entry == '..'
|
||||
|
||||
unless matches_any_filename_in_list(entry, internal_files)
|
||||
|
||||
path_from_cwd = subdir_from_cwd + '/' + entry
|
||||
path_from_package = local_subdir + '/' + entry
|
||||
|
||||
# Recurse if this entry is a sub folder
|
||||
if File.directory?( path_from_cwd )
|
||||
__aux_list_package_files(package_dir, path_from_package, list, internal_files )
|
||||
else
|
||||
list << path_from_package
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return list
|
||||
end
|
||||
|
||||
|
||||
# -- TEST --
|
||||
#puts get_internal_package_files_list(TEST_PKG_DIR)
|
||||
#puts list_package_files(TEST_PKG_DIR, false)
|
||||
#puts list_package_files(TEST_PKG_DIR)
|
||||
#puts list_package_files('inexistent_folder')
|
||||
# -- TEST --
|
||||
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
require 'Pathname'
|
||||
|
||||
load 'common_impl.rb'
|
||||
|
||||
#
|
||||
# excluded files filter
|
||||
#
|
||||
# uses fnmatch to filter out entries that should not be included in the package list
|
||||
# this allows the 'don_submit' listing to use wildcards
|
||||
#
|
||||
class ExcludedFiles < Array
|
||||
def exclude? ( entry )
|
||||
self.each do |to_exclude|
|
||||
return true if File.fnmatch(to_exclude.chomp,entry)
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# Fills the 'list' array with relative pathnames to the files in the 'package_dir' folder.
|
||||
# Subdirectories are recursed.
|
||||
# Directory entries mathching any string in the 'excluded' array are skipped.
|
||||
#
|
||||
def list_pkg_files(filter, package_dir, list = [] )
|
||||
__aux_list_pkg_files(filter, as_pathname(package_dir), as_pathname(''), list)
|
||||
end
|
||||
|
||||
def __aux_list_pkg_files(filter, package_dir, local_subdir, list = [] )
|
||||
|
||||
assert_exist!(package_dir, 'package directory' )
|
||||
|
||||
filter = ExcludedFiles.new unless filter
|
||||
|
||||
subdir_from_cwd = package_dir + local_subdir ;
|
||||
|
||||
# Process each entry in the package's folder
|
||||
Dir.foreach(subdir_from_cwd) do |entry|
|
||||
|
||||
unless entry == '.' || entry == '..'
|
||||
|
||||
unless filter.exclude?(entry)
|
||||
|
||||
path_from_cwd = subdir_from_cwd + entry
|
||||
path_from_package = local_subdir + entry
|
||||
|
||||
# Recurse if this entry is a sub folder
|
||||
if FileTest.directory?( path_from_cwd )
|
||||
__aux_list_pkg_files(filter, package_dir, path_from_package, list)
|
||||
else
|
||||
list << path_from_package
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return list
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# Returns an array listing the entries that should be excluded from the package file list.
|
||||
# This includes fixed entries hard-coded here and those read from a 'dont_submit' text file, if exits.
|
||||
#
|
||||
def pkg_dont_submit_list(package_dir)
|
||||
|
||||
list = ['TODO',
|
||||
'dont_submit',
|
||||
'maintainer',
|
||||
'description.txt',
|
||||
'changes.txt',
|
||||
'doc_tex',
|
||||
'.svn'
|
||||
]
|
||||
|
||||
dont_submit_file = package_dir + '/dont_submit'
|
||||
|
||||
list += IO.readlines(dont_submit_file) if FileTest.exist?(dont_submit_file)
|
||||
|
||||
return ExcludedFiles.new(list)
|
||||
|
||||
end
|
||||
|
||||
#puts pkg_dont_submit_list($test_pkg_dir)
|
||||
#puts list_pkg_files(pkg_dont_submit_list($test_pkg_dir), $test_pkg_dir)
|
||||
#puts list_pkg_files(nil, $test_pkg_dir)
|
||||
#puts list_pkg_files(nil, 'unexitent_folder')
|
||||
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
#! /bin/ruby
|
||||
|
||||
# == Synopsis
|
||||
#
|
||||
# "Mirrors" package files into a build folder for compilation.
|
||||
#
|
||||
# The package files are taken from a source package directory
|
||||
# (typically a folder under an svn working copy)
|
||||
#
|
||||
# The directory structure under the package folder is replicated under
|
||||
# a target build directory (creating subdirs as neccesary)
|
||||
#
|
||||
# "Mirroring" a package file consist on creating within the build directory a "view"
|
||||
# to the file located into the package directory.
|
||||
# This allows compilation within a "CGAL build directory structure" while
|
||||
# keeping the source files in its original location within an svn working copy.
|
||||
#
|
||||
# In true POSIX platforms this is done via a symlink.
|
||||
#
|
||||
# In Windows platforms hardlinks are used instead. To ensure that broken hardlinks
|
||||
# are properly syncronized, these are re-created whenever the source file is newer.
|
||||
#
|
||||
# The mirroring operation is automatically selected according to the platform,
|
||||
# but can be overrided if needed via the '--mirror_operation' option.
|
||||
#
|
||||
# Unless specified otherwise using the '-all' option, internal "dont_submit" files
|
||||
# are excluded.
|
||||
#
|
||||
# == Usage
|
||||
#
|
||||
# mirror_all_packages [OPTIONS] PACKAGES_ROOT BUILD_ROOT
|
||||
#
|
||||
# PACKAGE_DIR the source package directory
|
||||
#
|
||||
# BUILD_DIR the destination build directory
|
||||
#
|
||||
# OPTIONS:
|
||||
#
|
||||
# -h, --help:
|
||||
# show help
|
||||
#
|
||||
# -o, -mirror_operation [symlink|hardlink]
|
||||
# Mirroring operation
|
||||
# symlink is the default in platforms supporting it (*nix)
|
||||
# hardlink is the default in platforms not supporting symlinks (windows)
|
||||
#
|
||||
# -i, --include_internal
|
||||
# Include internal files (excluded by default).
|
||||
#
|
||||
|
||||
require 'getoptlong'
|
||||
require 'rdoc/usage'
|
||||
|
||||
require 'list_package_files_impl.rb'
|
||||
require 'mirror_package_impl.rb'
|
||||
|
||||
# -- TEST --
|
||||
ARGV = [TEST_PKG_ROOT, TEST_BUILD_ROOT]
|
||||
# ARGV = ['-i',TEST_PKG_DIR, TEST_BUILD_ROOT]
|
||||
# -- TEST --
|
||||
|
||||
opts = GetoptLong.new( [ '--help' , '-h', GetoptLong::NO_ARGUMENT ],
|
||||
[ '--mirror_operation', '-o', GetoptLong::REQUIRED_ARGUMENT ],
|
||||
[ '--include_internal', '-i', GetoptLong::NO_ARGUMENT ]
|
||||
)
|
||||
|
||||
include_internal = false
|
||||
|
||||
mirror_operation = default_mirror_op
|
||||
|
||||
opts.each do |opt, arg|
|
||||
case opt
|
||||
when '--help'
|
||||
RDoc::usage
|
||||
|
||||
when '--mirror_operation'
|
||||
case arg
|
||||
when 'symlink'
|
||||
mirror_operation = :symlink
|
||||
when 'hardlink'
|
||||
mirror_operation = :hardlink
|
||||
else
|
||||
$stderr << "Invalid mirror operation: " << arg
|
||||
end
|
||||
|
||||
when '--include_internal'
|
||||
include_internal = true
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
src_package_root = ARGV.length >= 1 ? ARGV.shift : ''
|
||||
tgt_build_root = ARGV.length >= 1 ? ARGV.shift : ''
|
||||
|
||||
unless src_package_root.empty? || tgt_build_root.empty? then
|
||||
|
||||
assert_exist!(src_package_root, 'packages root directory' )
|
||||
assert_exist!(tgt_build_root , 'build root directory' )
|
||||
|
||||
include_in_release_file = src_package_root + '/Maintenance/release_building/include_in_release'
|
||||
|
||||
assert_exist!(include_in_release_file, 'include_in_release file')
|
||||
|
||||
packages = IO.readlines(include_in_release_file)
|
||||
|
||||
packages.each do |package|
|
||||
|
||||
package.chomp!
|
||||
|
||||
src_package_subdir = src_package_root + '/' + package
|
||||
|
||||
package_files = list_package_files(src_package_subdir,include_internal)
|
||||
|
||||
mirror_package(package_files,src_package_subdir,tgt_build_root,mirror_operation)
|
||||
end
|
||||
|
||||
else
|
||||
RDoc::usage
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
#! /bin/ruby
|
||||
|
||||
# == Synopsis
|
||||
#
|
||||
# "Mirrors" package files into a build folder for compilation.
|
||||
#
|
||||
# The package files are taken from a source package directory
|
||||
# (typically a folder under an svn working copy)
|
||||
#
|
||||
# The directory structure under the package folder is replicated under
|
||||
# a target build directory (creating subdirs as neccesary)
|
||||
#
|
||||
# "Mirroring" a package file consist on creating within the build directory a "view"
|
||||
# to the file located into the package directory.
|
||||
# This allows compilation within a "CGAL build directory structure" while
|
||||
# keeping the source files in its original location within an svn working copy.
|
||||
#
|
||||
# In true POSIX platforms this is done via a symlink.
|
||||
#
|
||||
# In Windows platforms hardlinks are used instead. To ensure that broken hardlinks
|
||||
# are properly syncronized, these are re-created whenever the source file is newer.
|
||||
#
|
||||
# The mirroring operation is automatically selected according to the platform,
|
||||
# but can be overrided if needed via the '--mirror_operation' option.
|
||||
#
|
||||
# Unless specified otherwise using the '-all' option, internal "dont_submit" files
|
||||
# are excluded.
|
||||
#
|
||||
# == Usage
|
||||
#
|
||||
# mirror_package [OPTIONS] PACKAGE_SUBDIR BUILD_ROOT
|
||||
#
|
||||
# PACKAGE_SUBDIR the source package sub directory
|
||||
#
|
||||
# BUILD_ROOT the destination build root directory
|
||||
#
|
||||
# OPTIONS:
|
||||
#
|
||||
# -h, --help:
|
||||
# show help
|
||||
#
|
||||
# -o, --mirror_operation [symlink|hardlink]
|
||||
# Mirroring operation
|
||||
# symlink is the default in platforms supporting it (*nix)
|
||||
# hardlink is the default in platforms not supporting symlinks (windows)
|
||||
#
|
||||
# -i, --include_internal
|
||||
# Include internal files (excluded by default).
|
||||
#
|
||||
|
||||
require 'getoptlong'
|
||||
require 'rdoc/usage'
|
||||
|
||||
require 'list_package_files_impl.rb'
|
||||
require 'mirror_package_impl.rb'
|
||||
|
||||
# -- TEST --
|
||||
ARGV = [TEST_PKG_ROOT, TEST_BUILD_ROOT]
|
||||
# ARGV = ['-i',TEST_PKG_DIR, TEST_BUILD_ROOT]
|
||||
# -- TEST --
|
||||
|
||||
opts = GetoptLong.new( [ '--help' , '-h', GetoptLong::NO_ARGUMENT ],
|
||||
[ '--mirror_operation', '-o', GetoptLong::REQUIRED_ARGUMENT ],
|
||||
[ '--include_internal', '-i', GetoptLong::NO_ARGUMENT ]
|
||||
)
|
||||
|
||||
include_internal = false
|
||||
|
||||
mirror_operation = default_mirror_op
|
||||
|
||||
opts.each do |opt, arg|
|
||||
case opt
|
||||
when '--help'
|
||||
RDoc::usage
|
||||
|
||||
when '--mirror_operation'
|
||||
case arg
|
||||
when 'symlink'
|
||||
mirror_operation = :symlink
|
||||
when 'hardlink'
|
||||
mirror_operation = :hardlink
|
||||
else
|
||||
$stderr << "Invalid mirror operation: " << arg
|
||||
end
|
||||
|
||||
when '--include_internal'
|
||||
include_internal = true
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
src_package_subdir = ARGV.length >= 1 ? ARGV.shift : ''
|
||||
tgt_build_root = ARGV.length >= 1 ? ARGV.shift : ''
|
||||
|
||||
unless src_package_subdir.empty? || tgt_build_root.empty? then
|
||||
|
||||
files = list_package_files(src_package_subdir,include_internal)
|
||||
|
||||
mirror_package(files,src_package_subdir,tgt_build_root,mirror_operation)
|
||||
|
||||
else
|
||||
RDoc::usage
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -1,16 +1,18 @@
|
|||
require 'Pathname'
|
||||
require 'FileUtils'
|
||||
|
||||
load 'common_impl.rb'
|
||||
require 'common_impl.rb'
|
||||
require 'list_package_files_impl.rb'
|
||||
|
||||
def default_mirror_op
|
||||
return RUBY_PLATFORM =~ /mswin32|cygwin|mingw|bccwin/ ? :hardlink : :symlink
|
||||
end
|
||||
|
||||
#
|
||||
# "Mirror" the listed files from a given package folder into a given target folder.
|
||||
# "Mirror" the listed 'files' from a given source 'package_subdir' folder
|
||||
# into a given target 'build_root' folder.
|
||||
# Entries in the file list are pathnames relative to the package folder.
|
||||
# The directory structure under the package folder is replicated in the build folder,
|
||||
# The directory structure under the package folder is replicated in the build root folder,
|
||||
# creating new folders as neccesary
|
||||
#
|
||||
# "Mirroring" a file consist on creating within the build folder a view to a file located into the package folder.
|
||||
|
|
@ -22,21 +24,18 @@ end
|
|||
#
|
||||
# By setting mirror_op = :copy, this function can also be used to create
|
||||
# a clean copy (instead of a mirror) of the package files inside a build folder.
|
||||
# In this case, if the destination file must not exist.
|
||||
# In this case, the destination file must not exist. Use remove_package_from_buildtree to remove them first.
|
||||
#
|
||||
def mirror_pkg_files(files,
|
||||
package_dir,
|
||||
build_dir,
|
||||
mirror_op = default_mirror_op
|
||||
)
|
||||
def mirror_package(files,
|
||||
package_subdir,
|
||||
build_root,
|
||||
mirror_op = default_mirror_op
|
||||
)
|
||||
|
||||
package_dir = as_pathname(package_dir)
|
||||
build_dir = as_pathname(build_dir)
|
||||
|
||||
assert_exist!(package_dir, 'package directory' )
|
||||
assert_exist!(build_dir , 'build directory' )
|
||||
assert_exist!(package_subdir, 'package sub directory' )
|
||||
assert_exist!(build_root , 'build root directory' )
|
||||
|
||||
$report << "Mirroring package [#{package_dir}] into [#{build_dir}]\n"
|
||||
$report << "Mirroring package [#{package_subdir}] into [#{build_root}]\n"
|
||||
|
||||
# Keep a local hash of subfolders to avoid accessing the filesystem redudantly
|
||||
subdir_exist = {}
|
||||
|
|
@ -47,8 +46,8 @@ def mirror_pkg_files(files,
|
|||
|
||||
dir_name, file_name = File.split(file)
|
||||
|
||||
src_file = package_dir + dir_name + file_name
|
||||
dst_file = build_dir + dir_name + file_name
|
||||
src_file = package_subdir + '/' + dir_name + '/' + file_name
|
||||
dst_file = build_root + '/' + dir_name + '/' + file_name
|
||||
|
||||
assert_exist!(src_file, 'source file')
|
||||
|
||||
|
|
@ -70,7 +69,7 @@ def mirror_pkg_files(files,
|
|||
#
|
||||
Pathname.new(dir_name).descend do |local_subdir|
|
||||
|
||||
dst_subdir = build_dir + local_subdir
|
||||
dst_subdir = build_root + '/' + local_subdir
|
||||
|
||||
unless subdir_exist[dst_subdir]
|
||||
unless FileTest.exist?(dst_subdir)
|
||||
|
|
@ -107,8 +106,9 @@ def mirror_pkg_files(files,
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
#mirror_pkg_files(["include/CGAL/Straight_skeleton_2.h"],$test_pkg_dir, $test_build_dir)
|
||||
#mirror_pkg_files(list_pkg_files(pkg_dont_submit_list($test_pkg_dir), $test_pkg_dir),$test_pkg_dir, $test_build_dir)
|
||||
# -- TEST --
|
||||
#mirror_package(["include/CGAL/Straight_skeleton_2.h"],TEST_PKG_DIR, TEST_BUILD_ROOT)
|
||||
#mirror_package(list_package_files(TEST_PKG_DIR,false),TEST_PKG_DIR, TEST_BUILD_ROOT)
|
||||
# -- TEST --
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
#! /bin/ruby
|
||||
|
||||
# == Synopsis
|
||||
#
|
||||
# Remove package files from a build folder.
|
||||
#
|
||||
# The list of files to remove are taken from a source package directory
|
||||
# (typically a folder under an svn working copy)
|
||||
# (see list_package_files.rb script)
|
||||
#
|
||||
# == Usage
|
||||
#
|
||||
# remove_package_files_from_buid_tree [OPTIONS] PACKAGE_SUBDIR BUILD_ROOT
|
||||
#
|
||||
# PACKAGE_SUBDIR the source package sub directory used to generate the file list
|
||||
#
|
||||
# BUILD_ROOT the destination build root directory where the files will be removed
|
||||
#
|
||||
# OPTIONS:
|
||||
#
|
||||
# -h, --help:
|
||||
# show help
|
||||
#
|
||||
# -r, -rename
|
||||
# Rename files instead, adding a ".removed" suffix
|
||||
#
|
||||
|
||||
require 'getoptlong'
|
||||
require 'rdoc/usage'
|
||||
|
||||
require 'list_package_files_impl.rb'
|
||||
require 'remove_package_files_from_build_tree_impl.rb'
|
||||
|
||||
# -- TEST --
|
||||
ARGV = [TEST_PKG_DIR, TEST_BUILD_ROOT]
|
||||
# ARGV = ['-r','-i',TEST_PKG_DIR, TEST_BUILD_ROOT]
|
||||
# -- TEST --
|
||||
|
||||
opts = GetoptLong.new( [ '--help' , '-h', GetoptLong::NO_ARGUMENT ],
|
||||
[ '--rename' , '-r', GetoptLong::NO_ARGUMENT ],
|
||||
[ '--include_internal', '-i', GetoptLong::NO_ARGUMENT ]
|
||||
)
|
||||
|
||||
rename_instead = false
|
||||
include_internal = false
|
||||
|
||||
opts.each do |opt, arg|
|
||||
case opt
|
||||
when '--help'
|
||||
RDoc::usage
|
||||
|
||||
when '--rename'
|
||||
rename_instead = true
|
||||
|
||||
when '--include_internal'
|
||||
include_internal = true
|
||||
end
|
||||
end
|
||||
|
||||
src_package_subdir = ARGV.length >= 1 ? ARGV.shift : ''
|
||||
tgt_build_root = ARGV.length >= 1 ? ARGV.shift : ''
|
||||
|
||||
unless src_package_subdir.empty? || tgt_build_root.empty? then
|
||||
|
||||
files = list_package_files(src_package_subdir,include_internal)
|
||||
|
||||
remove_package_files_from_build_tree(files,src_package_subdir,tgt_build_root,:rename_instead => rename_instead )
|
||||
else
|
||||
RDoc::usage
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
require 'Pathname'
|
||||
require 'FileUtils'
|
||||
|
||||
require 'common_impl.rb'
|
||||
require 'list_package_files_impl.rb'
|
||||
|
||||
|
||||
#
|
||||
# Removes (or renames) a list of 'files' from a given 'build_root'
|
||||
# Entries in the file list are pathnames relative to the 'package_subdir'
|
||||
#
|
||||
def remove_package_files_from_build_tree(files,
|
||||
package_subdir,
|
||||
build_root,
|
||||
options = { :rename_instead => false }
|
||||
)
|
||||
|
||||
assert_exist!(package_subdir, 'package sub directory' )
|
||||
assert_exist!(build_root , 'build root directory' )
|
||||
|
||||
$report << "Removing package [#{package_subdir}] from [#{build_root}]\n"
|
||||
|
||||
files.each do |file|
|
||||
|
||||
begin # exception block
|
||||
|
||||
dir_name, file_name = File.split(file)
|
||||
|
||||
src_file = package_subdir + '/' + dir_name + '/' + file_name
|
||||
dst_file = build_root + '/' + dir_name + '/' + file_name
|
||||
|
||||
assert_exist!(src_file, 'source file')
|
||||
|
||||
if ( File.exist?(dst_file) ) then
|
||||
if ( options[:rename_instead] ) then
|
||||
$report << "Renaming [#{dst_file}] to [#{dst_file}.removed].\n"
|
||||
File.rename(dst_file, dst_file + ".removed" )
|
||||
else
|
||||
$report << "Removing [#{dst_file}].\n"
|
||||
File.delete(dst_file)
|
||||
end
|
||||
else
|
||||
$report << "[#{dst_file}] does not exist in the build tree.\n"
|
||||
end
|
||||
|
||||
rescue Exception => e
|
||||
$report << "Error removig #{file}: #{e}" << ENDL
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# -- TEST --
|
||||
#remove_package_files_from_build_tree(["include/CGAL/Straight_skeleton_2.h"],TEST_PKG_DIR, TEST_BUILD_ROOT, :rename_instead => false )
|
||||
#remove_package_files_from_build_tree(list_package_files(TEST_PKG_DIR,false),TEST_PKG_DIR, TEST_BUILD_ROOT, :rename_instead => false )
|
||||
# -- TEST --
|
||||
|
||||
|
||||
Loading…
Reference in New Issue