summaryrefslogtreecommitdiffstats
path: root/scripts/950_pulse_dep_tree
blob: f2a2c79d0da4f612a8adddcf72437c67eecb57d6 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#--------------------------------------------------------------------------------------------------
# Standard modularization template
# --------------------------------
#
# The script will start execution from <QTDIR>.
#
# Available variables:
#     $qtdir    = <QTDIR> or where you started the modularize script from
#     $basepath = path for the modularize script, and basepath for the modularization repo
#     $OStype   = <n> where <n> is one of 0 = Windows, 1 = Unix, 2 = Mac
#
# To execute a command:
#     run("git mv foo bar")        # runs command, reports error possition and dies
#     runNotDie("git mv foo bar")  # runs command, reports error possition, returns error code
#                                    and continues. Use ($? >> 8) to get the real exit code.
#     ensureDir("qtkernel")        # Ensures that qtkernel exists and is a directory. Will create
#                                    it if it does not exist.
#--------------------------------------------------------------------------------------------------

my $debugScript = 0;

my %dep_to_sync_profile_map = (
    "QtCore" => "qtkernel/sync.profile",
    "QtGui" => "qtkernel/sync.profile",
    "QtXml" => "qtkernel/sync.profile",
    "QtSql" => "qtkernel/sync.profile",
    "QtTest" => "qtkernel/sync.profile",
    "QtNetwork" => "qtkernel/sync.profile",
    "QtDBus" => "qtkernel/sync.profile",
    "QtOpenGL" => "qtkernel/sync.profile",
    "QtOpenVG" => "qtkernel/sync.profile",
    "QtUiTools" => "qtkernel/sync.profile",
    "QtXmlPatterns" => "qtxmlpatterns/sync.profile",
    "phonon" => "phonon/sync.profile",
    "QtSvg" => "qtsvg/sync.profile",
    "QtDesigner" => "qttools/sync.profile",
    "QtHelp" => "qttools/sync.profile",
    "assistant" => "qttools/sync.profile",
    "designer" => "qttools/sync.profile",
    "linguist" => "qttools/sync.profile",
    "qtdemo" => "qtdoc/sync.profile",
    "qdoc3" => "qtdoc/sync.profile",
    "QtScript" => "qtscript/sync.profile",
    "QtScriptTools" => "qtscript/sync.profile",
    "qtwebkit-examples-and-demos" => "qtwebkit-examples-and-demos/sync.profile",
    "Qt3Support" => "qt3support/sync.profile",
    "QtWebKit" => "qtwebkit/Source/sync.profile",
    "QtWebKit-tests" => "qtwebkit/Source/sync.profile",
    "QtDeclarative" => "qtdeclarative/sync.profile",
    "QtMultimedia" => "qtmultimedia/sync.profile",
    "ActiveQt" => "activeqt/sync.profile",
);
# Reverse map as well, with key = string, value = (@modules).
my %sync_profile_to_dep_map;
foreach my $key (keys %dep_to_sync_profile_map) {
    if (!defined($sync_profile_to_dep_map{$dep_to_sync_profile_map{$key}})) {
        $sync_profile_to_dep_map{$dep_to_sync_profile_map{$key}} = [];
    }
    push(@{$sync_profile_to_dep_map{$dep_to_sync_profile_map{$key}}}, $key);
}

my %deps = (
    "QtCore" => [],
    "QtGui" => ["QtCore"],
    "QtXml" => ["QtCore"],
    "QtSql" => ["QtCore"],
    "QtTest" => ["QtCore"],
    "QtNetwork" => ["QtCore"],
    "QtDBus" => ["QtCore", "QtXml"],
    "QtOpenGL" => ["QtCore", "QtGui"],
    "QtOpenVG" => ["QtCore", "QtGui"],
    "QtUiTools" => ["QtCore", "QtGui"],
    "QtXmlPatterns" => ["QtCore", "QtNetwork"],
    "phonon" => ["QtCore", "QtXml", "QtDBus", "QtGui"],
    "QtSvg" => ["QtCore", "QtGui"],
    "QtDesigner" => ["QtCore", "QtGui", "QtScript", "QtXml"],
    "QtHelp" => ["QtCore", "QtGui", "QtSql", "QtXml"],
    "assistant" => ["QtWebKit", "QtHelp", "QtNetwork", "QtGui", "QtSql", "QtXml", "QtCore"],
    "designer" => ["QtNetwork", "QtGui",  "QtXml", "QtDesigner", "QtScript", "QtCore"],
    "linguist" => ["QtGui",  "QtDesigner", "QtUiTools", "QtXml", "QtCore"],
    "qtdemo" => ["QtHelp", "QtXml", "QtOpenGL", "QtDeclarative", "QtScript", "QtSvg", "QtGui", "QtXmlPatterns", "QtNetwork", "QtSql", "QtCore"],
    "qdoc3" => ["QtXml", "QtCore"],
    "QtScript" => ["QtCore"],
    "QtScriptTools" => ["QtCore", "QtGui", "QtScript"],
    "qtwebkit-examples-and-demos" => ["QtWebKit"],
    "Qt3Support" => ["QtNetwork", "QtGui", "QtSql", "QtXml", "QtCore"],
    "QtWebKit" => ["QtDBus", "QtXml", "QtGui", "QtXmlPatterns", "QtNetwork", "QtCore", "phonon", "QtDeclarative"],
    "QtWebKit-tests" => ["QtWebKit", "QtDeclarative"],
    "QtDeclarative" => ["QtScript", "QtSvg", "QtGui", "QtXmlPatterns", "QtNetwork", "QtSql", "QtCore"],
    "QtMultimedia" => ["QtCore", "QtGui"],
    "ActiveQt" => ["QtCore", "QtGui"],
);

my %done_deps;

chdir("qt");

#sub run {
#    print("@_\n");
#}

sub resolveAndCommitDependencies {
    my $dep = $_[0];
    print("Entering $dep\n") if ($debugScript);
    my @dependees;
    my $syncProfile = $dep_to_sync_profile_map{$dep};
    my @sameSyncProfileModules = @{$sync_profile_to_dep_map{$syncProfile}};
    foreach my $sameSyncProfileModule (@sameSyncProfileModules) {
        push(@dependees, @{$deps{$sameSyncProfileModule}});
    }
    if ($debugScript) {
        print("vars: syncProfile=$syncProfile, "
              . "sameSyncProfileModules=@sameSyncProfileModules, "
              . "dependees=@dependees\n");
    }
    foreach my $dependee (@dependees) {
        next if ($syncProfile eq $dep_to_sync_profile_map{$dependee});
        if (!$done_deps{$dependee}) {
            resolveAndCommitDependencies($dependee);
        }
    }

    return if ($done_deps{$dep});

    print("Finishing $dep\n") if ($debugScript);

    my $syncProfileFd;
    open($syncProfileFd, ">> $syncProfile") or die("Could not open $syncProfile");
    print($syncProfileFd "# Modules and programs, and their dependencies.\n");
    print($syncProfileFd "# Each of the module version specifiers can take one of the following values:\n");
    print($syncProfileFd "#   - A specific Git revision.\n");
    print($syncProfileFd "#   - \"LATEST_REVISION\", to always test against the latest revision.\n");
    print($syncProfileFd "#   - \"LATEST_RELEASE\", to always test against the latest public release.\n");
    print($syncProfileFd "#   - \"THIS_REPOSITORY\", to indicate that the module is in this repository.\n");
    print($syncProfileFd "\%dependencies = (\n");
    foreach my $module (@sameSyncProfileModules) {
        print($syncProfileFd "    \"$module\" => {\n");
        foreach my $dependee (@{$deps{$module}}) {
            my $rev = $done_deps{$dependee} ? $done_deps{$dependee} : "THIS_REPOSITORY";
            $rev =~ s/[\r\n]//g;
            print($syncProfileFd "        \"$dependee\" => \"$rev\",\n");
        }
        print($syncProfileFd "    },\n");
    }
    print($syncProfileFd ");\n");

    $syncProfile =~ m,^([^/]+)/(.+)$, or die("Shouldn't happen! Check the module maps!");
    my $repo = $1;
    my $syncProInsideRepo = $2;
    chdir($repo);
    run("git add $syncProInsideRepo");
    run("git commit -q --author=\"axis <qt-info\@nokia.com>\" "
        . "-m \"Added dependency information to the sync.profile.\"");
    my $committedSha = `git rev-parse HEAD`;
    chdir("..");

    foreach my $sameSyncProfileModule (@sameSyncProfileModules) {
        $done_deps{$sameSyncProfileModule} = $committedSha;
    }
}

foreach my $dep (keys %deps) {
    resolveAndCommitDependencies($dep);
}

run("git commit -aq --author=\"axis <qt-info\@nokia.com>\" "
    . "-m \"Committed dependency information to all modules.\"");

return 1;