summaryrefslogtreecommitdiff
path: root/HACKING
blob: b6d35906d377cc513004fb952dfe4a240b52c4be (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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
====== Midori - Contribute ======

**This document is licensed under the LGPL 2.1.**

====== Check out the sources ======

bzr branch lp:midori

The development **trunk** (master, tip) is the latest iteration of the next release. Browse it online and look for other branches at http://code.launchpad.net/midori or http://bazaar.launchpad.net/~midori/midori/trunk/tarball download a tarball of the latest revision.

//The code used to be hosted in git.xfce.org/apps/midori.//

Keep your copy updated:

bzr merge --pull
====== Join IRC chat rooms ======

Join irc://irc.freenode.net/midori #midori on Freenode https://kiwiirc.com/client/irc.freenode.net/midori or use webchat to talk about Midori, discuss bugs and new ideas.
====== Contribute other than touching code ======

  * http://bugs.launchpad.net/midori Go through problem reports and check Unconfirmed bugs or those lacking information and mark any duplicates you spot
  * https://www.bountysource.com/#trackers/130181-midori Add a bounty for a feature or bug you'd like to support
  * https://translations.launchpad.net/midori/trunk/+pots/trunk Translate to your own language
  * https://github.com/eustasy/midori-browser.org/issues Report website bugs
  * Write http://wiki.xfce.org/midori/tutorial your own extension - granted that's code, too, but maybe a little easier than hacking the core.

====== Documentation resources ======

  * https://wiki.gnome.org/Projects/Vala/Tutorial Vala Tutorial
  * http://midori-browser.org/docs/api/vala/midori/ Midori Vala Docs
  * http://midori-browser.org/docs/api/c/html/ Midori C Docs

====== Build the code ======

mkdir _build
cd _build
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
make
sudo make install
sudo gtk-update-icon-cache /usr/share/icons/hicolor


//Advanced Tip: Pass "-G Ninja" to cmake to use http://martine.github.io/ninja/ Ninja instead of make (usually packaged as ninja or ninja-build).//

If using GTK+3 you'll want to add -DUSE_GTK3=1 to the cmake command line.

You can build Midori using another C Compiler for example Clang. Just
add -DCMAKE_C_COMPILER=/path/to/compiler to the cmake arguments.
Then you can build following your normal procedure. Like this:
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_COMPILER=/usr/bin/clang ..
make

Midori can be **run without being installed**.

_build/midori/midori

You can use a **temporary folder for testing** without affecting normal settings

_build/midori/midori -c /tmp/midoridev

You'll want to **unit test** the code if you're testing a new version or contributed your own changes:

xvfb-run make check

Automated daily builds in Launchpad (https://launchpad.net/~elementary-os/+archive/daily ppa:elementary-os/daily and https://launchpad.net/~midori/+archive/midori-dev ppa:midori/midori-dev) run these tests as well.
====== Debugging issues ======

Testing an installed release may reveal crashers or memory corruption which require investigating from a local build and obtaining a stacktrace (backtrace, crash log).

_build/midori/midori -g [OPTIONAL ARGUMENTS]

If the problem is a warning, not a crash GLib has a handy feature

env G_DEBUG=all _build/midori/midori -g

For more specific debugging output, depending on the feature in question you may use

env MIDORI_DEBUG=help _build/midori/midori

Whilst -g is convenient you may want to use proper gdb:

gdb
file _build/midori/midori
run
…
bt

On Windows you can open the folder where Midori is installed and double-click gdb.exe. A black command line window should appear.

file midori.exe
run
…
bt

To verify a regression you might need to revert a particular change:


# Revert only r6304
bzr merge . -r 6304..6303

====== Coding style and quality ======

Midori code should in general have:

  * 4 space indentation, no tabs
  * Between 80 to 120 columns
  * Prefer /* */ style comments
  * Call variables //animal// and //animal_shelter// instead of <del>camelCase</del>
  * Keep a space between functions/ keywords and round parentheses

For Vala:

  * Prefer //new Gtk.Widget ()// over //using Gtk; new Widget ()//
  * Stick to standard Vala-style curly parentheses on the same line
  * Cuddled //} else {// and //} catch (Error error) {//

For C:

  * Always keep { and } on their own line

//Extensions may historically diverge from the standard styling on a case-by-case basis//

====== Committing code ======

Tell Bazaar your name if you haven't yet
    bzr whoami "Real Name <email@address>"

See what you did so far
    bzr diff

Get an overview of changed and new files
    bzr status

Add new files, move/ rename or delete
    bzr add FILENAME
    bzr mv OLDFILE NEWFILE
    bzr rm FILENAME

Commit all current changes - Bazaar automatically picks up edited files. //If you're used to git, think of an implicit staging area.//
    bzr commit -p

If you have one or more related bug reports you should pass them as arguments. Once these commits are merged the bug will automatically be closed and the commit log shows clickable links to the reports.
    bzr commit -p --fixes=lp:1111999

If you've done several commits
    bzr log | less
    bzr log -p | less

In the case you committed something wrong or want to ammend it:
    bzr uncommit

If you end up with unrelated debugging code or other patches in the current changes, it's sometimes handy to temporarily clean up. //This may be seen as bzr's version of git stash.//
    bzr shelve
    bzr commit -p
    bzr unshelve

Remember to keep your branch updated:
    bzr merge --pull

As a general rule of thumb, ''bzr help COMMAND'' gives you an explanation of any command and ''bzr help commands'' lists all available commands.

//If you're a die-hard git user, http://zyga.github.io/git-lp/ checkout git-lp to use git commands with the Bazaar repository.//
====== Push proposed changes ======

If you haven't yet, https://launchpad.net/~/+editsshkeys check that Launchpad has your SSH key - you can create an SSH key with **Passwords and Keys** aka **Seahorse** or ''ssh-keygen -t rsa'' - and use ''bzr launchpad-login'' to make youself known to bzr locally.

If you checked out trunk, and added your patch(es), just **push it under your username** in Launchpad and you can **propose it for merging into trunk**. This will automatically request a **review from other developers** who can then comment on it and provide feedback.

bzr push --remember lp:~USERNAME/midori/fix-bug1120383 && bzr lp-propose-merge lp:midori

lp-propose-merge command may not be working on some distributions like Arch or Fedora.
In case you get error like //bzr: ERROR: Unable to import library "launchpadlib": No module named launchpadlib// just use Launchpad's Web UI to propose a merge.


**What happens to all the branches?**

Leave the branches alone, **approved branches are cleared automatically** by Launchpad.

For larger feature branches, **use the team** in Launchpad to allow other developers to work on the code with you.

bzr push --remember lp:~midori/midori/featuritis && bzr lp-propose-merge lp:midori

What if I want to help out on an **existing merge request** that I can't push to?


bzr branch ~OTHERPERSON/midori/fix-bug1120383
cd fix-bug1120383
# make commits
bzr push lp:USERNAME~/midori/fix-bug1120383
bzr lp-propose-merge ~OTHERPERSON/midori/fix-bug1120383


Updating a branch that may be out of sync with trunk:


bzr pull
bzr: ERROR: These branches have diverged
bzr merge lp:midori
# Hand-edit conflicting changes
bzr resolve FILENAME
# If any conflicts remain continue fixing
bzr commit -m 'Merge lp:midori'


Save a little bandwidth, **branch from an existing local copy** that you keep around:


bzr branch lp:midori midori
bzr branch midori midori.fix-bug1120383
cd midori.fix-bug1120383
bzr pull lp:midori


====== Backwards compatibility ======
As of Midori 0.5.4 the formula is:
  * Required dependencies need to be available on the previous stable https://apps.fedoraproject.org/packages/s/webkit Fedora and http://packages.ubuntu.com/search?suite=quantal&keywords=webkit&searchon=names Ubuntu
  * For reference http://openports.se/www/webkit OpenBSD
  * Windows XP through 8 are to date ABI compatible, all dependencies are included

^ package ^ F17 (2012-05-29) ^ U 12.10 (2012-10-18) ^
| glib2 | 2.32.4 | 2.34.0 |
| vala | 0.16.1 | 0.16 |
| gtk3 | 3.4.4 | 3.6.0 |
| gtk2 | 2.24.13 | 2.24.13 |
| soup | 2.38.1 | 2.40 |
| webkit | 1.8.3-1.fc17 | 1.10.0-0ubuntu1 |
====== Midori with(out) Granite ======
When built with Granite (-DUSE_GRANITE=1 or --enable-granite) there're a few key differences:
  * Preferences uses a http://valadoc.elementaryos.org/Granite/Granite.Widgets.StaticNotebook.html Granite.Widgets.StaticNotebook
  * URL completion styling is slightly different
  * Clear Private Data uses **Granite.Widgets.LightWindow**
  * Edit Bookmark and Security Details use http://valadoc.elementaryos.org/Granite/Granite.Widgets.PopOver.html Granite.Widgets.PopOver instead of Gtk.Window

====== Midori for Windows ======

===== For Linux developers =====
==== Dependencies ====
Midori for Windows is compiled on a Linux host and MinGW stack. For the current build Fedora 18 packages are used. Packages needed are listed below:

yum install gcc vala intltool

For a native build
yum install libsoup-devel webkitgtk3-devel sqlite-devel

For cross-compilation
yum install mingw{32,64}-webkitgtk3 mingw{32,64}-glib-networking mingw{32,64}-gdb mingw{32,64}-gstreamer-plugins-good

Packages needed when assembling the archive
 yum install faenza-icon-theme p7zip mingw32-nsis greybird-gtk3-theme

Installing those should get you the packages needed to successfully build and develop Midori for Win32.
==== Building ====
For 32-bit builds:

mkdir _mingw32
cd _mingw32
mingw32-cmake .. -DUSE_ZEITGEIST=0 -DUSE_GTK3=1 -DCMAKE_INSTALL_PREFIX=/usr/i686-w64-mingw32/sys-root/mingw -DCMAKE_VERBOSE_MAKEFILE=0
make
sudo make install

For 64-bit builds:

mkdir _mingw64
cd _mingw64
mingw64-cmake .. -DUSE_ZEITGEIST=0 -DUSE_GTK3=1 -DCMAKE_INSTALL_PREFIX=/usr/x86_64-w64-mingw32/sys-root/mingw -DCMAKE_VERBOSE_MAKEFILE=0
make
sudo make install

Once built and tested you can assemble the Midori archive with a helper script
32-bit build:
env MINGW_PREFIX="/usr/i686-w64-mingw32/sys-root/mingw" ./win32/makedist/makedist.midori
64-bit build:
env MINGW_PREFIX="/usr/x86_64-w64-mingw32/sys-root/mingw/" ./win32/makedist/makedist.midori x64
===== Testing =====
For testing your changes unfortuantely a real system is needed because Midori and WebKitGTK+ don't work properly under Wine. Even if it works some problems are not visible when using Wine, but are present when running under a real Windows system and vice versa.

One way around it is to virtualize Windows on a Linux host and mount your MinGW directories as a network drive or shared folder.

===== For Windows developers =====
Rough list of prerequisites for building with MinGW on Windows

If in doubt whether to get 32 or 64 bit versions use 32 bit ones, they are more 
universal and tend to be less broken.


==== MinGW compiler ====
Compiler should match the one that was used to build packages ideally.

  * We will user *mingw64 rubenvb* release
  * Lastest stable release is gcc 4.8.0

[[http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting
%20Win64/Personal%20Builds/rubenvb/gcc-4.8-release/|Releases]]

[[http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting
%20Win64/Personal%20Builds/rubenvb/gcc-4.8-release/x86_64-w64-mingw32-gcc-4.8.0-
win32_rubenvb.7z/download|Download]]


==== 7zip ====
We will need 7zip to extract various archives

http://www.7-zip.org/download.html Homepage


http://downloads.sourceforge.net/sevenzip/7z920.exe 32bit Installer


==== Python3 (to extract rpms) ====
We will need python3 to use download-mingw-rpm.py script. 
If you don't plan to use it you can safely skip this step.

We get python3, whatever is the lastes stable release.

http://www.python.org/download/releases/3.3.5 Releases

http://www.python.org/downloads/release/python-335/ Download

http://www.python.org/ftp/python/3.3.5/python-3.3.5.amd64.msi Installer

Install Python and be sure to check "addd python.exe to path" installer checkbox.

==== download-mingw-rpm.py ====
We get download-mingw-rpm.py script from github. It uses Python3 and should fetch and 
unpack rpm files for us.

[[https://github.com/mkbosmans/download-mingw-rpm/blob/master/download-
mingw-rpm.py|View Script]]

[[https://github.com/mkbosmans/download-mingw-rpm/raw/master/download-
mingw-rpm.py|Download Script]]

Usage:

  * Launch cmd.exe
  * Navigate to folder where the script was saved
  * Make sure that python can access 7z.exe
  * Run command and wait, it should extract the packages into your current directory

c:\Python33\python.exe download-mingw-rpm.py -u http://ftp.wsisiz.edu.pl/pub/linux/fedora/linux/updates/18/i386/ --deps mingw32-webkitgtk mingw32-glib-networking mingw32-gdb mingw32-gstreamer-plugins-good

[[http://dl.fedoraproject.org/pub/fedora/linux/releases/18/Everything/i386/os/Packages
/m/|Fedora 18 packages]]

The above URL for some reason does not work with the script.

==== MSYS ====
Msys contains shell and some small utilities

[[http://sourceforge.net/projects/mingw-w64/files/External%20binary
%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29/MSYS-20111123.zip/download|Download]]


==== CMake ====
http://www.cmake.org/cmake/resources/software.html Homepage
http://www.cmake.org/files/v2.8/cmake-2.8.12.2-win32-x86.exe Installer

When installing check the installer checkbox "add to path"


==== Bazaar ====
http://wiki.bazaar.canonical.com/WindowsDownloads Homepage

We will get 2.4 Stable Release (standalone) 

http://launchpad.net/bzr/2.4/2.4.2/+download/bzr-2.4.2-1-setup.exe Installer

When installing check the installer checkbox "add to path"

==== Vala ====
http://ftp.gnome.org/pub/gnome/sources/vala/0.20/vala-0.20.0.tar.xz Source

==== Globbing it all together ====

Extracted rpms msys and mingw packages should form uniform unix like folder.
You use msys.bat to launch a shell

====== Jargon ======
    * freeze: a period of bug fixes only eg. 4/2 cycle means 4 weeks of features and 2 weeks to focus on resolving existing problems
    * MR: merge request, a branch proposed for review
    * ninja: an internal tab, usually empty label, used for taking screenshots
    * fortress: user of an ancient release like 0.4.3 as found on Raspberry Pie, Debian, Ubuntu
    * katze, sokoke, tabby: API names and coincidentally cat breeds