- Move scripts/cgal_conditional_include* scripts to developer_scripts/
(probably obsolete, certainly not public)
This commit is contained in:
+127
@@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# Copyright (c) 1999,2005,2006 Utrecht University (The Netherlands),
|
||||
# ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
|
||||
# INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
|
||||
# (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
|
||||
# and Tel-Aviv University (Israel). All rights reserved.
|
||||
#
|
||||
# This file is part of CGAL (www.cgal.org); 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.
|
||||
# See the file LICENSE.LGPL distributed with CGAL.
|
||||
#
|
||||
# Licensees holding a valid commercial license may use this file in
|
||||
# accordance with the commercial license agreement provided with the software.
|
||||
#
|
||||
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# $URL$
|
||||
# $Id$
|
||||
#
|
||||
# Author(s) : Geert-Jan Giezeman
|
||||
|
||||
# usage: cgal_conditional_include file1 ...
|
||||
|
||||
# Protects CGAL and other include directives in the following way:
|
||||
|
||||
# #include <CGAL/Handle>
|
||||
#
|
||||
# is converted to
|
||||
#
|
||||
# #ifndef CGAL_HANDLE_H
|
||||
# #include <CGAL/Handle>
|
||||
# #endif
|
||||
|
||||
# #include <stdlib.h>
|
||||
#
|
||||
# is converted to
|
||||
#
|
||||
# #ifndef CGAL_PROTECT_STDLIB_H
|
||||
# #include <stdlib.h>
|
||||
# #define CGAL_PROTECT_STDLIB_H
|
||||
# #endif
|
||||
|
||||
# The only filenames that are not protected are the ones that figure in
|
||||
# the following list (with .h suffix added).
|
||||
|
||||
@non_protected_files = (
|
||||
'LEDA/REDEFINE_NAMES',
|
||||
'LEDA/UNDEFINE_NAMES',
|
||||
'assert');
|
||||
|
||||
$tmpfilename = "CondIncl$$";
|
||||
FILE:
|
||||
foreach $filename (@ARGV) {
|
||||
if (!open("infile", $filename)) {
|
||||
print STDERR "Could not open ${filename} for reading\n$!\n";
|
||||
next FILE;
|
||||
}
|
||||
open("tmpfile", ">$tmpfilename")
|
||||
|| die "Could not open temp file for writing\n$!\n";
|
||||
$last = '';
|
||||
Line:
|
||||
while (<infile>) {
|
||||
if (($leading_space, $basename) = m|^([\s]*)#[\s]*include[\s]*<CGAL/(.*)\.h>[\s]*|)
|
||||
{
|
||||
# protect CGAL header files
|
||||
$protect_name = $basename;
|
||||
$protect_name =~ s'/'_'g;
|
||||
$protect_name =~ tr/a-z/A-Z/;
|
||||
$protect_name = "CGAL_" . $protect_name . '_H';
|
||||
$protect_line = '#ifndef ' . $protect_name . "\n";
|
||||
if ( $last !~ m|^[\s]*$protect_line|) {
|
||||
print tmpfile $leading_space;
|
||||
print tmpfile $protect_line;
|
||||
# print tmpfile "#include <CGAL/$basename.h>\n";
|
||||
print tmpfile $_;
|
||||
print tmpfile $leading_space;
|
||||
print tmpfile "#endif // $protect_name\n";
|
||||
} else {
|
||||
print tmpfile $_;
|
||||
}
|
||||
$last = '';
|
||||
} elsif (($leading_space, $basename) = m|^([\s]*)#[\s]*include[\s]*<(.*)\.h>[\s]*|) {
|
||||
# protect other header files
|
||||
foreach $special_name (@non_protected_files) {
|
||||
if ($basename =~ m#^$special_name$#) {
|
||||
print tmpfile $_;
|
||||
$last = '';
|
||||
next Line;
|
||||
}
|
||||
}
|
||||
$protect_name = $basename;
|
||||
$protect_name =~ s'/'_'g;
|
||||
$protect_name =~ tr/a-z/A-Z/;
|
||||
$protect_name = 'CGAL_PROTECT_' . $protect_name . '_H';
|
||||
$protect_line = '#ifndef ' . $protect_name . "\n";
|
||||
if ( $last !~ m|^[\s]*$protect_line|) {
|
||||
print tmpfile $leading_space;
|
||||
print tmpfile $protect_line;
|
||||
print tmpfile $_;
|
||||
print tmpfile $leading_space;
|
||||
print tmpfile "#define $protect_name\n";
|
||||
print tmpfile $leading_space;
|
||||
print tmpfile "#endif // $protect_name\n";
|
||||
} else {
|
||||
print tmpfile $_;
|
||||
}
|
||||
$last = '';
|
||||
} else {
|
||||
# copy other lines
|
||||
print tmpfile $_;
|
||||
$last = $_;
|
||||
}
|
||||
}
|
||||
close infile;
|
||||
close tmpfile;
|
||||
if ($?) {
|
||||
print STDERR "Conversion of ${filename} failed\n$!\n";
|
||||
next FILE;
|
||||
}
|
||||
if (!rename($tmpfilename,${filename})) {
|
||||
print STDERR "Cannot rename $tmpfilename to ${filename}.\n$!\n";
|
||||
print STDERR "Conversion of ${filename} failed\n";
|
||||
}
|
||||
}
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# Copyright (c) 1999,2005,2006 Utrecht University (The Netherlands),
|
||||
# ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
|
||||
# INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
|
||||
# (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
|
||||
# and Tel-Aviv University (Israel). All rights reserved.
|
||||
#
|
||||
# This file is part of CGAL (www.cgal.org); 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.
|
||||
# See the file LICENSE.LGPL distributed with CGAL.
|
||||
#
|
||||
# Licensees holding a valid commercial license may use this file in
|
||||
# accordance with the commercial license agreement provided with the software.
|
||||
#
|
||||
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# $URL$
|
||||
# $Id$
|
||||
#
|
||||
# Author(s) : Geert-Jan Giezeman
|
||||
|
||||
# usage: cgal_conditional_include file1 ...
|
||||
|
||||
# Protects CGAL and other include directives in the following way:
|
||||
|
||||
# #ifndef CGAL_HANDLE_H
|
||||
# #include <CGAL/Handle>
|
||||
# #endif
|
||||
#
|
||||
# is converted to
|
||||
#
|
||||
# #include <CGAL/Handle>
|
||||
|
||||
# #ifndef CGAL_PROTECT_STDLIB_H
|
||||
# #include <stdlib.h>
|
||||
# #define CGAL_PROTECT_STDLIB_H
|
||||
# #endif
|
||||
#
|
||||
# is converted to
|
||||
#
|
||||
# #include <stdlib.h>
|
||||
|
||||
use strict;
|
||||
|
||||
my $protect_name;
|
||||
my $suffix;
|
||||
|
||||
my $tmpfilename = "CondIncl$$";
|
||||
my $filename;
|
||||
my $skipped = 0;
|
||||
|
||||
FILE:
|
||||
foreach $filename (@ARGV) {
|
||||
if (!open(INFILE, $filename)) {
|
||||
print STDERR "Could not open ${filename} for reading\n$!\n";
|
||||
next FILE;
|
||||
}
|
||||
open(TMPFILE, ">$tmpfilename")
|
||||
|| die "Could not open temp file for writing\n$!\n";
|
||||
my $last = '';
|
||||
Line:
|
||||
while (<INFILE>) {
|
||||
if (($protect_name,$suffix) =
|
||||
m|^[\s]*#[\s]*ifndef[\s]+CGAL_PROTECT_(.*?)(_H)?\b|)
|
||||
{
|
||||
my $protect_line = $_;
|
||||
$_ = <INFILE>;
|
||||
my $include_file;
|
||||
if ( !(($include_file) =
|
||||
m|^[\s]*#[\s]*include[\s]*<(.*?)(?:\.h)?>[\s]*|)) {
|
||||
warn "'#include <...>' missing in line ",
|
||||
$.-$skipped," ($filename)\n";
|
||||
print TMPFILE $protect_line;
|
||||
redo;
|
||||
}
|
||||
my $include_line = $_;
|
||||
$include_file =~ s'/'_'g;
|
||||
$include_file =~ tr/a-z/A-Z/;
|
||||
if ($include_file ne $protect_name) {
|
||||
warn "'#ifndef CGAL_PROTECT_$protect_name$suffix'",
|
||||
" followed by non corresponding #include in line ",
|
||||
$.-$skipped," ($filename)\n";
|
||||
print TMPFILE $protect_line;
|
||||
print TMPFILE $include_line;
|
||||
next;
|
||||
}
|
||||
$_ = <INFILE>;
|
||||
my $protect_name2;
|
||||
if (!(($protect_name2) =
|
||||
m|^[\s]*#[\s]*define[\s]+CGAL_PROTECT_(.*?)(?:_H)?[\s]*$|)) {
|
||||
warn "'#define CGAL_PROTECT_$protect_name$suffix' missing in line ",
|
||||
$.-$skipped," ($filename)\n";
|
||||
print TMPFILE $protect_line;
|
||||
print TMPFILE $include_line;
|
||||
redo;
|
||||
}
|
||||
my $protect_line2 = $_;
|
||||
if ($protect_name2 ne $protect_name) {
|
||||
warn "'#ifndef CGAL_PROTECT_$protect_name$suffix' lacks ",
|
||||
"'#define CGAL_PROTECT_$protect_name$suffix' in line ",
|
||||
$.-$skipped," ($filename)\n";
|
||||
print TMPFILE $protect_line;
|
||||
print TMPFILE $include_line;
|
||||
print TMPFILE $protect_line2;
|
||||
next;
|
||||
}
|
||||
$_ = <INFILE>;
|
||||
if ( ! m|^[\s]*#[\s]*endif|) {
|
||||
warn "'#ifndef CGAL_PROTECT_$protect_name$suffix' lacks ",
|
||||
"'#endif' in line ", $.-$skipped," ($filename)\n";
|
||||
print TMPFILE $protect_line;
|
||||
print TMPFILE $include_line;
|
||||
print TMPFILE $protect_line2;
|
||||
redo;
|
||||
}
|
||||
print TMPFILE $include_line;
|
||||
$skipped += 3;
|
||||
}
|
||||
elsif ((($protect_name,$suffix) =
|
||||
m|^[\s]*#[\s]*ifndef[\s]+CGAL_(.*?)(_H)?[\s]*$|))
|
||||
{
|
||||
my $protect_line;
|
||||
$protect_line = $_;
|
||||
$_ = <INFILE>;
|
||||
my $include_file;
|
||||
if ( !(($include_file) =
|
||||
m|^[\s]*#[\s]*include[\s]*<CGAL\/(.*?)(?:\.h)?>[\s]*|)) {
|
||||
print TMPFILE $protect_line;
|
||||
redo;
|
||||
}
|
||||
my $include_line = $_;
|
||||
$include_file =~ s'/'_'g;
|
||||
$include_file =~ tr/a-z/A-Z/;
|
||||
if ($include_file ne $protect_name) {
|
||||
warn "'#ifndef CGAL_$protect_name$suffix'",
|
||||
" followed by non corresponding #include in line ",
|
||||
$.-$skipped," ($filename)\n";
|
||||
print TMPFILE $protect_line;
|
||||
print TMPFILE $include_line;
|
||||
next;
|
||||
}
|
||||
$_ = <INFILE>;
|
||||
if ( ! m|^[\s]*#[\s]*endif|) {
|
||||
warn "'#ifndef CGAL_$protect_name$suffix' lacks ",
|
||||
"'#endif' in line ", $.-$skipped," ($filename)\n";
|
||||
print TMPFILE $protect_line;
|
||||
print TMPFILE $include_line;
|
||||
redo;
|
||||
}
|
||||
print TMPFILE $include_line;
|
||||
$skipped += 2;
|
||||
} else
|
||||
{
|
||||
# copy other lines
|
||||
print TMPFILE $_;
|
||||
}
|
||||
}
|
||||
close INFILE;
|
||||
close TMPFILE;
|
||||
if ($?) {
|
||||
print STDERR "Conversion of ${filename} failed\n$!\n";
|
||||
next FILE;
|
||||
}
|
||||
if (!rename($tmpfilename,${filename})) {
|
||||
print STDERR "Cannot rename $tmpfilename to ${filename}.\n$!\n";
|
||||
print STDERR "Conversion of ${filename} failed\n";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user