summaryrefslogtreecommitdiffstats
path: root/scripts/200_examples
blob: 5376183fc05836f0cb690a45b0951caa816ea8ac (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
#--------------------------------------------------------------------------------------------------
# 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.
#--------------------------------------------------------------------------------------------------

require("non-module-helpers");

use File::Basename;

my $debugExamplesScript = 0;

# First the exceptions.
ensureDir("qtsvg/examples/network");
ensureDir("qtsvg/examples/draganddrop");
ensureDir("qtsvg/examples/painting");
ensureDir("qtsvg/examples/richtext");
ensureDir("qtsvg/examples/desktop");
ensureDir("qtsvg/examples/opengl");
run("git mv examples/network/bearercloud qtsvg/examples/network");
run("git mv examples/draganddrop/delayedencoding qtsvg/examples/draganddrop");
run("git mv examples/painting/svggenerator qtsvg/examples/painting");
run("git mv examples/painting/svgviewer qtsvg/examples/painting");
run("git mv examples/richtext/textobject qtsvg/examples/richtext");
run("git mv examples/desktop/systray qtsvg/examples/desktop");
run("git mv examples/opengl/framebufferobject qtsvg/examples/opengl");

ensureDir("qt3support/examples/graphicsview");
run("git mv examples/graphicsview/portedcanvas qt3support/examples/graphicsview");
run("git mv examples/graphicsview/portedasteroids qt3support/examples/graphicsview");

ensureDir("qtkernel/examples");
run("git mv examples/qmake qtkernel/examples");
run("git mv examples/graphicsview qtkernel/examples");
run("git mv examples/ja_JP qtkernel/examples");
run("git mv examples/symbianpkgrules.pri qtkernel/examples");
run("git mv examples/richtext qtkernel/examples");
run("git mv examples/draganddrop qtkernel/examples");
run("git mv examples/painting qtkernel/examples");
run("git mv examples/desktop qtkernel/examples");
run("git mv examples/opengl qtkernel/examples");

ensureDir("qttools/examples");
run("git mv examples/designer qttools/examples");
run("git mv examples/help qttools/examples");
createSubdirProfile("qttools/examples");

if ($isMaster) {
    ensureDir("qtkernel/examples/scroller");
    run("git mv examples/scroller/graphicsview qtkernel/examples/scroller/graphicsview");
    ensureDir("qtwebkit-examples-and-demos/examples/scroller");
    run("git mv examples/scroller/plot qtwebkit-examples-and-demos/examples/scroller/plot");
    run("git mv examples/scroller/wheel qtwebkit-examples-and-demos/examples/scroller/wheel");
    run("git rm -q examples/scroller/scroller.pro");
    createSubdirProfile("qtwebkit-examples-and-demos/examples/scroller");
    createSubdirProfile("qtkernel/examples/scroller");
}

ensureDir("qtscript/examples");
run("git mv examples/script qtscript/examples");


if ($isMaster) {
    ensureDir("qtwebkit-examples-and-demos/examples/xmlpatterns");
    run("git mv examples/xmlpatterns/qobjectxmlmodel qtwebkit-examples-and-demos/examples/xmlpatterns/qobjectxmlmodel");
    ensureDir("qtwebkit-examples-and-demos/examples/xmlpatterns/shared");
    fsCopy("-r", "examples/xmlpatterns/shared/*", "qtwebkit-examples-and-demos/examples/xmlpatterns/shared");
    run("git add qtwebkit-examples-and-demos/examples/xmlpatterns");
    run("git rm -q examples/xmlpatterns/xmlpatterns.pro");
    # move other examples to qtxmlpatterns module
    ensureDir("qtxmlpatterns/examples");
    run("git mv examples/xmlpatterns qtxmlpatterns/examples");
    # recreate the '.pro' files.
    createSubdirProfile("qtwebkit-examples-and-demos/examples/xmlpatterns");
    createSubdirProfile("qtxmlpatterns/examples/xmlpatterns");
} else {
    ensureDir("qtxmlpatterns/examples");
    # Uses both xmlpatterns and webkit.
    run("git mv examples/xmlpatterns qtxmlpatterns/examples");
}

ensureDir("activeqt/examples");
run("git mv examples/activeqt activeqt/examples");
createSubdirProfile("activeqt/examples");

# Then the rest that we haven't handled.
my @examples = findFiles("examples", ".*", 1);
foreach (@examples) {
    next if (!-d $_);

    my $example = "$_";

    my $dir = findDirectoryForApplication($example);
    if ($dir) {
        $dir =~ s,qtwebkit$,qtwebkit-examples-and-demos,;
        print("$example -> $dir/$example\n") if ($debugExamplesScript);
        my $containingDir = dirname("$dir/$example");
        ensureDir($containingDir);
        run("git mv $example $dir/$example");
    }
}

run("git mv examples/examples.pro qtkernel/examples/");
run("git mv examples/README qtkernel/examples/");
run("git mv examples/tutorials/tutorials.pro qtkernel/examples/tutorials/");
run("git mv examples/tutorials/README qtkernel/examples/tutorials");

#everything must have been moved
fsRmdirWithParents("examples/tutorials/gettingStarted");

# Create profiles
createSubdirProfile("qtsvg/examples/network");
createSubdirProfile("qtsvg/examples/draganddrop");
createSubdirProfile("qtsvg/examples/painting");
createSubdirProfile("qtsvg/examples/richtext");
createSubdirProfile("qtsvg/examples/desktop");
createSubdirProfile("qtsvg/examples/opengl");
createSubdirProfile("qtsvg/examples");
createSubdirProfile("qtscript/examples");
createSubdirProfile("qtxmlpatterns/examples");
createSubdirProfile("qtquick/examples");
createSubdirProfile("phonon/examples");
createSubdirProfile("qtmultimedia/examples");
createSubdirProfile("qtwebkit-examples-and-demos/examples");
createSubdirProfile("qt3support/examples/graphicsview");
createSubdirProfile("qt3support/examples");

foreach (@repos) {
    my $module = $_;
    #printf("Module %s\n", $module);
    next if ($_ eq "activeqt" || $_ eq "phonon");

    my @pros = findFiles("$module/examples/", "\\.pr[io]", 1);
    if ($OStype == WINDOWS) {
        run('perl -pi.org -e "s,\$\$\[QT_INSTALL_EXAMPLES\]\/,\$\$\[QT_INSTALL_EXAMPLES\]/' . $module .'/,g" ' . join(" ", @pros)) if (@pros);
    } else {
        run("perl -pi.org -e 's,\\\$\\\$\\[QT_INSTALL_EXAMPLES\\]\\/,\\\$\\\$\\[QT_INSTALL_EXAMPLES\\]/$module/,g' " . join(" ", @pros)) if (@pros);
    }
    foreach my $pro (@pros) {
        fsRm("${pro}.org");
    }
}

return 1;