summaryrefslogtreecommitdiff
path: root/util/mkdist-javascriptcore
blob: 30d90dae840a1fda60f145ba1ea91c1292158e6c (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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/bash

die() {
    echo $*
    exit 1
}

default_tag="javascriptcore-snapshot-02022010"

if [ $# -eq 0 ]; then
    tag="$default_tag"
elif [ $# -eq 1 ]; then
    tag=$1
else
    die "usage: $0 [commit (defaults to $default_tag)]"
fi

repository=`git config qtwebkit.url`
if [ -z "$repository" ]; then
    die "error: cannot locate webkit git repository. please run git config --global qtwebkit.url /path-or-url/to/webkit/repo"
fi

excluded_directories="$excluded_directories JavaScriptCore/Makefile"
excluded_directories="$excluded_directories JavaScriptCore/GNUmakefile.am"
excluded_directories="$excluded_directories JavaScriptCore/Configurations"
excluded_directories="$excluded_directories JavaScriptCore/JavaScriptCore.exp"
excluded_directories="$excluded_directories JavaScriptCore/JavaScriptCore.xcodeproj"
excluded_directories="$excluded_directories JavaScriptCore/tests"
excluded_directories="$excluded_directories JavaScriptCore/API/tests"
excluded_directories="$excluded_directories JavaScriptCore/JavaScriptCore.vcproj"
excluded_directories="$excluded_directories JavaScriptCore/wtf/wx"
excluded_directories="$excluded_directories JavaScriptCore/wtf/gtk"
excluded_directories="$excluded_directories JavaScriptCore/wtf/mac"
excluded_directories="$excluded_directories JavaScriptCore/wtf/win"
excluded_directories="$excluded_directories JavaScriptCore/wtf/chromium"
excluded_directories="$excluded_directories JavaScriptCore/wtf/haiku"
excluded_directories="$excluded_directories JavaScriptCore/icu"
excluded_directories="$excluded_directories JavaScriptCore/qt"
excluded_directories="$excluded_directories JavaScriptCore/JavaScriptCore.gyp"


files_to_remove=""
files_to_remove="$files_to_remove JavaScriptCore/AllInOneFile.cpp"
files_to_remove="$files_to_remove JavaScriptCore/JavaScriptCoreSources.bkl"
files_to_remove="$files_to_remove JavaScriptCore/jscore.bkl"
files_to_remove="$files_to_remove JavaScriptCore/jsc.pro"
files_to_remove="$files_to_remove JavaScriptCore/JavaScriptCore.pro"
files_to_remove="$files_to_remove JavaScriptCore/DerivedSources.pro"
files_to_remove="$files_to_remove JavaScriptCore/create_rvct_stubs"

require_clean_work_tree() {
    # test if working tree is dirty
    git rev-parse --verify HEAD > /dev/null &&
    git update-index --refresh &&
    git diff-files --quiet &&
    git diff-index --cached --quiet HEAD ||
    die "Working tree is dirty"
}

which qmake >/dev/null 2>/dev/null
if [ "$?" != 0 ]; then
    die "abort: Could not locate qmake in your PATH"
fi

test -z "$(git rev-parse --show-cdup)" || {
       exit=$?
       echo >&2 "You need to run this command from the toplevel of the working tree."
       exit $exit
}

echo "checking working tree"
require_clean_work_tree

revCount=`git ls-remote $repository | grep $tag | awk '{print $1}' | wc -l`
if [ "$revCount" != 1 ]; then
    die "Cannot parse $tag into a revision. It seems ambiguous".
fi

rev=`git ls-remote $repository | grep -E "^.+$tag$" | awk '{print $1}'`

tarball=`mktemp /tmp/webkit-snapshot.tar.XXXXXX` || exit 1
echo "creating $tarball"

echo "archiving webkit from $repository $tag ( $rev )"

git archive --remote=$repository $rev JavaScriptCore WebKit.pri > $tarball || exit 1

echo "removing unwanted files and directories"
for dir in $excluded_directories; do
    echo "    removing $dir"
    tar --delete --file=$tarball $dir
done

for item in $exclude_with_exceptions_list; do
    dir=`echo $item | awk -F : '{print $1}'`
    include=`echo $item | awk -F : '{print $2}'`
    echo "    removing $dir except $include"
    files=`tar --list --file=$tarball $dir | grep -v -E "^$dir\$" | grep -v $include`
    tar --delete --file=$tarball $files
done

for file in $files_to_remove; do
    echo "    removing $file"
    tar --delete --file=$tarball $file
done

echo "done!"

srcdir=src/3rdparty/javascriptcore
absSrcDir=$PWD/$srcdir
localDiff=
lastImportRevison=

echo "replacing $srcdir"
if [  -d $srcdir ]; then
    git ls-files $srcdir | xargs rm
    git ls-files -z src/3rdparty/javascriptcore | git update-index --force-remove -z --stdin
else
    mkdir -p $srcdir
fi

(cd $srcdir && tar xf $tarball)
git add $srcdir

echo "generating extra sources"
(
  for proj in JavaScriptCore; do
      cd $absSrcDir/$proj &&
      rm -rf tmp &&
      mkdir tmp &&
      cd tmp &&
      mkdir -p ../generated &&
      qmake -o Makefile CONFIG-=QTDIR_build QT_CONFIG+=phonon GENERATED_SOURCES_DIR=`pwd`/../generated  OUTPUT_DIR=`pwd` ../$proj.pro &&
      make generated_files &&
      perl -pi -e "s,$absSrcDir/,,g" ../generated/*.cpp ../generated/*.h &&
      git add ../generated &&
      cd .. &&
      rm -rf tmp &&
      cd ..
  done
)
rm -rf $srcdir/WebKitBuild

cat >$srcdir/VERSION <<EOT
This is a snapshot of JavaScriptCore from

        git://gitorious.org/qtwebkit/qtwebkit.git

The commit imported was from the

        $tag branch/tag

and has the sha1 checksum

        $rev
EOT
git add $srcdir/VERSION

git diff-files --name-only -z | git update-index --remove -z --stdin

echo "removing $tarball"
rm -f $tarball

cat >commitlog.txt <<EOT
Updated JavaScriptCore from $repository to $tag ( $rev )
EOT

if [ -d "$repository/.git" -a -n "$lastImportRevison" ]; then
    echo >>commitlog.txt
    echo "Changes in WebKit/qt since the last update:" >>commitlog.txt
    echo >>commitlog.txt
    git --git-dir=$repository/.git diff $lastImportRevison $rev -- WebKit/qt/ChangeLog | sed -n -e "s,^\+\(.*\),\1,p" >>commitlog.txt
fi

echo "Changes:"
echo
git --no-pager diff --name-status --cached $srcdir

echo
echo "Wrote commitlog.txt. Use with"
echo
echo "    git commit -e -F commitlog.txt"
echo
echo "to commit your changes"

if [ -n "$localDiff" ]; then
    echo
    echo "The changes that were locally stored in Perforce are now stored as a git patch in $localDiff"
    echo "You may want to appy them with"
    echo
    echo "    git am -3 $localDiff"
    echo
fi