Add deprecated headers support to syncqt

When renaming classes, or when moving classes from one module to
another, it's useful to have a simple way of supporting the old
API/location for some time. To this end, syncqt shall now recognize
a "deprecatedheaders" section in sync.profile. It looks like this:

%deprecatedheaders = (
    "QtDeclarative" => {
        "qquickcanvas.h" => "QtQuick2/qquickcanvas.h",
        "qquickitem.h" => "QtQuick2/qquickitem.h",
        "QQuickCanvas" => "QtQuick2/QQuickCanvas",
        "QQuickItem" => "QtQuick2/QQuickItem",
    }
);

In the above example, syncqt would generate a header called
qquickcanvas.h for the QtDeclarative module; when included, this
header will issue a warning and include <QtQuick2/qquickcanvas.h>.
And so on, for the other entries.

Deprecated headers are installed along with the module's normal
headers.

Change-Id: Ie2518b42275c2b2ff44216f07d376ccf5be6dc45
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
This commit is contained in:
Kent Hansen 2011-11-25 14:53:39 +01:00 committed by Qt by Nokia
parent 3aeeb53d73
commit d4349b0482

View File

@ -69,7 +69,7 @@ $qtbasedir = dirname(dirname($0)) if (!$qtbasedir);
$qtbasedir =~ s=\\=/=g if (defined $qtbasedir);
# will be defined based on the modules sync.profile
our (%modules, %moduleheaders, @allmoduleheadersprivate, %classnames, %mastercontent, %modulepris, %explicitheaders);
our (%modules, %moduleheaders, @allmoduleheadersprivate, %classnames, %mastercontent, %modulepris, %explicitheaders, %deprecatedheaders);
# global variables (modified by options)
my $isunix = 0;
@ -1119,6 +1119,64 @@ foreach my $lib (@modules_to_sync) {
$master_contents .= "#endif\n";
unless($showonly) {
# create deprecated headers
my $first = 1;
while (my ($header, $include) = each %{$deprecatedheaders{$lib}}) {
my $public_header = 0;
$public_header = 1 unless ($allheadersprivate || ($header =~ /_p\.h$/));
next unless ($public_header || $create_private_headers);
my $header_path = "$out_basedir/include/$lib/";
unless ($public_header) {
if ($module_version) {
$header_path .= "$module_version/$lib/private/";
} else {
$header_path .= "private/";
}
}
$header_path .= "$header";
unless (-e $header_path) {
my $guard = "DEPRECATED_HEADER_" . $lib . "_" . $header;
$guard =~ s/([^a-zA-Z0-9_])/_/g;
open HEADER, ">$header_path" || die "Could not open $header_path for writing!\n";
print HEADER "#ifndef $guard\n";
print HEADER "#define $guard\n";
my $warning = "Header <$lib/";
$warning .= "private/" unless ($public_header);
$warning .= "$header> is deprecated. Please include <$include> instead.";
print HEADER "#warning $warning\n";
print HEADER "#include <$include>\n";
if ($public_header) {
print HEADER "#if 0\n";
print HEADER "#pragma qt_no_master_include\n";
print HEADER "#endif\n";
}
print HEADER "#endif\n";
close HEADER;
if ($verbose_level < 3) {
my $line_prefix = ",";
$line_prefix = "$lib: created deprecated header(s) {" if ($first);
print "$line_prefix $header";
} else {
print "$lib: created deprecated header $header => $include\n";
}
my $addendum = fixPaths($header_path, $dir) . " ";
if ($public_header) {
$pri_install_files .= $addendum;
} else {
$pri_install_pfiles .= $addendum;
}
$first = 0;
}
}
if ($verbose_level < 3) {
print " }\n" unless ($first);
}
my @master_includes;
push @master_includes, "$out_basedir/include/$lib/$lib";
push @master_includes, "$out_basedir/include/phonon_compat/Phonon/Phonon" if ($lib eq "phonon");