summaryrefslogtreecommitdiffstats
path: root/bin/make_vers
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2011-07-01 20:09:44 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2011-07-01 20:09:44 (GMT)
commit06880aeb4d098504b36160b532188a048a2455a1 (patch)
treecd41ac9261ae012f0fa06a5cce18aab4b2a90da0 /bin/make_vers
parent11349c2361ff12c0cbe4940c078cb3bf4a16ce90 (diff)
downloadhdf5-06880aeb4d098504b36160b532188a048a2455a1.zip
hdf5-06880aeb4d098504b36160b532188a048a2455a1.tar.gz
hdf5-06880aeb4d098504b36160b532188a048a2455a1.tar.bz2
[svn-r21063] Description:
Tweak make_vers script so that it indents preprocessor commands inside #ifdefs, is more forgiving and informative about the input file's prefix, and is better parameterized with the global variables at the beginning of the script. When major versions are branched from the trunk, the $max_idx value should be the only value that needs to be changed in the version of the script on the trunk. Changes to H5version.h file are just indention. Tested on: Mac OS X/32 10.6.8 (amazon) (too minor to require h5committest)
Diffstat (limited to 'bin/make_vers')
-rwxr-xr-xbin/make_vers80
1 files changed, 57 insertions, 23 deletions
diff --git a/bin/make_vers b/bin/make_vers
index 8541501..0bc3b62 100755
--- a/bin/make_vers
+++ b/bin/make_vers
@@ -2,6 +2,10 @@
require 5.003;
# Global settings
+# (The max_idx parameter is the only thing that needs to be changed when adding
+# support for a new major release. If support for a prior major release
+# is added (like support for 1.4, etc), the min_sup_idx parameter will
+# need to be decremented. - QAK)
# Max. library "index" (0 = v1.0, 1 = 1.2, etc)
$max_idx = 5;
@@ -9,6 +13,9 @@ $max_idx = 5;
# Min. supported previous library version "index" (0 = v1.0, 1 = 1.2, etc)
$min_sup_idx = 3;
+# Number of spaces to indent preprocessor commands inside ifdefs
+$indent = 2;
+
#
# Copyright by The HDF Group.
# Copyright by the Board of Trustees of the University of Illinois.
@@ -82,13 +89,34 @@ sub print_startprotect ($$) {
# Print check for conflicting version macro settings
#
sub print_checkoptions ($) {
- my $fh = shift;
+ my $fh = shift; # File handle for output file
+ my $curr_idx; # Current API version index
# Print the option checking
print $fh "\n/* Issue error if contradicting macros have been defined. */\n";
- print $fh "#if (defined(H5_USE_16_API) || defined(H5_USE_18_API)) && defined(H5_NO_DEPRECATED_SYMBOLS)\n";
- print $fh "#error \"Can't choose old API versions when deprecated APIs are disabled\"\n";
- print $fh "#endif /* (defined(H5_USE_16_API) || defined(H5_USE_18_API)) && defined(H5_NO_DEPRECATED_SYMBOLS) */\n";
+
+ # Print the #ifdef
+ print $fh "#if (";
+ for $curr_idx ($min_sup_idx .. ($max_idx - 1)) {
+ print $fh "defined(H5_USE_1", ($curr_idx * 2), "_API)";
+ if($curr_idx < ($max_idx - 1)) {
+ print $fh " || ";
+ }
+ }
+ print $fh ") && defined(H5_NO_DEPRECATED_SYMBOLS)\n";
+
+ # Print the error for bad API version chosen
+ print $fh ' ' x $indent, "#error \"Can't choose old API versions when deprecated APIs are disabled\"\n";
+
+ # Print the #endif
+ print $fh "#endif /* (";
+ for $curr_idx ($min_sup_idx .. ($max_idx - 1)) {
+ print $fh "defined(H5_USE_1", ($curr_idx * 2), "_API)";
+ if($curr_idx < ($max_idx - 1)) {
+ print $fh " || ";
+ }
+ }
+ print $fh ") && defined(H5_NO_DEPRECATED_SYMBOLS) */\n";
}
##############################################################################
@@ -110,7 +138,7 @@ sub print_globalapivers ($) {
# Print API version ifdef
print $fh "#if defined(H5_USE_1", ($curr_idx * 2), "_API_DEFAULT) && !defined(H5_USE_1", ($curr_idx * 2), "_API)\n";
# Print API version definition
- print $fh "#define H5_USE_1", ($curr_idx * 2), "_API 1\n";
+ print $fh " " x $indent, "#define H5_USE_1", ($curr_idx * 2), "_API 1\n";
# Print API version endif
print $fh "#endif /* H5_USE_1", ($curr_idx * 2), "_API_DEFAULT && !H5_USE_1", ($curr_idx * 2), "_API */\n\n";
}
@@ -127,7 +155,7 @@ sub print_globalapivers ($) {
print $fh "/*************/\n";
for $name (sort keys %{$func_vers[$curr_idx]}) {
print $fh "\n#if !defined(", $name, "_vers)\n";
- print $fh "#define ", $name, "_vers $func_vers[$curr_idx]{$name}\n";
+ print $fh " " x $indent, "#define ", $name, "_vers $func_vers[$curr_idx]{$name}\n";
print $fh "#endif /* !defined(", $name, "_vers) */\n";
}
@@ -138,7 +166,7 @@ sub print_globalapivers ($) {
print $fh "/************/\n";
for $name (sort keys %{$type_vers[$curr_idx]}) {
print $fh "\n#if !defined(", $name, "_t_vers)\n";
- print $fh "#define ", $name, "_t_vers $type_vers[$curr_idx]{$name}\n";
+ print $fh " " x $indent, "#define ", $name, "_t_vers $type_vers[$curr_idx]{$name}\n";
print $fh "#endif /* !defined(", $name, "_t_vers) */\n";
}
@@ -180,25 +208,25 @@ sub print_defaultapivers ($) {
# Set up default/latest version name mapping
print $fh "\n#if !defined($curr_vers_name) || $curr_vers_name == $curr_vers\n";
- print $fh "#ifndef $curr_vers_name\n";
- print $fh "#define $curr_vers_name $curr_vers\n";
- print $fh "#endif /* $curr_vers_name */\n";
- print $fh "#define $curr_name $curr_name$curr_vers\n";
+ print $fh " " x $indent, "#ifndef $curr_vers_name\n";
+ print $fh " " x ($indent * 2), "#define $curr_vers_name $curr_vers\n";
+ print $fh " " x $indent, "#endif /* $curr_vers_name */\n";
+ print $fh " " x $indent, "#define $curr_name $curr_name$curr_vers\n";
# Print function's dependent parameter types
foreach(sort(@param_list)) {
- print $fh "#define ${_}_t $_${curr_vers}_t\n";
+ print $fh " " x $indent, "#define ${_}_t $_${curr_vers}_t\n";
}
# Loop to print earlier version name mappings
$curr_vers--;
while($curr_vers > 0) {
print $fh "#elif $curr_vers_name == $curr_vers\n";
- print $fh "#define $curr_name $curr_name$curr_vers\n";
+ print $fh " " x $indent, "#define $curr_name $curr_name$curr_vers\n";
# Print function's dependent parameter types
foreach(sort(@param_list)) {
- print $fh "#define ${_}_t $_${curr_vers}_t\n";
+ print $fh " " x $indent, "#define ${_}_t $_${curr_vers}_t\n";
}
$curr_vers--;
@@ -206,7 +234,7 @@ sub print_defaultapivers ($) {
# Finish up with error for unknown version and endif
print $fh "#else /* $curr_vers_name */\n";
- print $fh "#error \"$curr_vers_name set to invalid value\"\n";
+ print $fh " " x $indent, "#error \"$curr_vers_name set to invalid value\"\n";
print $fh "#endif /* $curr_vers_name */\n";
}
@@ -224,22 +252,22 @@ sub print_defaultapivers ($) {
# Set up default/latest version name mapping
print $fh "\n#if !defined($curr_vers_name) || $curr_vers_name == $curr_vers\n";
- print $fh "#ifndef $curr_vers_name\n";
- print $fh "#define $curr_vers_name $curr_vers\n";
- print $fh "#endif /* $curr_vers_name */\n";
- print $fh "#define ${curr_name}_t $curr_name${curr_vers}_t\n";
+ print $fh " " x $indent, "#ifndef $curr_vers_name\n";
+ print $fh " " x ($indent * 2), "#define $curr_vers_name $curr_vers\n";
+ print $fh " " x $indent, "#endif /* $curr_vers_name */\n";
+ print $fh " " x $indent, "#define ${curr_name}_t $curr_name${curr_vers}_t\n";
# Loop to print earlier version name mappings
$curr_vers--;
while($curr_vers > 0) {
print $fh "#elif $curr_vers_name == $curr_vers\n";
- print $fh "#define ${curr_name}_t $curr_name${curr_vers}_t\n";
+ print $fh " " x $indent, "#define ${curr_name}_t $curr_name${curr_vers}_t\n";
$curr_vers--;
}
# Finish up with error for unknown version and endif
print $fh "#else /* $curr_vers_name */\n";
- print $fh "#error \"$curr_vers_name set to invalid value\"\n";
+ print $fh " " x $indent, "#error \"$curr_vers_name set to invalid value\"\n";
print $fh "#endif /* $curr_vers_name */\n\n";
}
}
@@ -436,7 +464,13 @@ for $file (@ARGV) {
my $prefix; # Local prefix for generated files
#print "file = '$file'\n";
- ($prefix) = ($file =~ /(^.*\/)/);
+ # Check for directory prefix on input file
+ if($file =~ /\//) {
+ ($prefix) = ($file =~ /(^.*\/)/);
+ }
+ else {
+ $prefix = "";
+ }
#print "prefix = '$prefix'\n";
# Read in the entire file
open SOURCE, $file or die "$file: $!\n";
@@ -450,7 +484,7 @@ for $file (@ARGV) {
close SOURCE;
# Create header files
- print "Generating 'H5version.h'\n";
+ print "Generating '", $prefix, "H5version.h'\n";
create_public($prefix);
#for $name (sort keys %functions) {