summaryrefslogtreecommitdiffstats
path: root/scripts/220_demos
blob: 065cff3f7309a87d08f0a8b6dae700b999866db9 (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
#--------------------------------------------------------------------------------------------------
# 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 $debugDemosScript = 0;

# First the exceptions.
ensureDir("qtdeclarative/demos");
run("git mv demos/declarative qtdeclarative/demos");

ensureDir("qtmultimedia/demos");
run("git mv demos/spectrum qtmultimedia/demos");

ensureDir("qtkernel/demos");
run("git mv demos/symbianpkgrules.pri qtkernel/demos");

ensureDir("qtdoc/demos");
run("git mv demos/qtdemo qtdoc/demos/");

ensureDir("qttools/demos");
run("git mv demos/arthurplugin/ qttools/demos");
fsCopy("-r", "demos/shared", "qttools/demos");
run("git add qttools/demos");

ensureDir("qtsvg/demos/embedded");
run("git mv demos/embedded/desktopservices qtsvg/demos/embedded");

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

    my $demo = "$_";

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

run("git mv demos/README qtkernel/demos/");
run("git mv demos/demos.pro qtkernel/demos/");
run("git mv demos/embedded/embedded.pro qtkernel/demos/embedded");

# Everything must have been moved
fsRm("demos/.gitignore");
fsRmdirWithParents("demos/embedded");

# Create profiles
createSubdirProfile("qtdeclarative/demos");
createSubdirProfile("qtdeclarative/demos/embedded");
createSubdirProfile("qtmultimedia/demos");
createSubdirProfile("qtdoc/demos");
createSubdirProfile("qtwebkit-examples-and-demos/demos/embedded");
createSubdirProfile("qtwebkit-examples-and-demos/demos");
createSubdirProfile("qtwebkit-examples-and-demos");

createSubdirProfile("qtsvg/demos/embedded");
createSubdirProfile("qtsvg/demos/embedded");
createSubdirProfile("qtsvg/demos");

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

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

    foreach my $pro (@pros) {
        fsRm("${pro}.org");
    }
}

return 1;