-
Notifications
You must be signed in to change notification settings - Fork 1
/
HACKING
95 lines (63 loc) · 3.03 KB
/
HACKING
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
-------------------------------------------------------------------------------
HACKING
-------------------------------------------------------------------------------
Coding style
------------
This project is programmed using the Linux kernel coding style, see
http://lxr.linux.no/linux/Documentation/CodingStyle for details.
Please use the same style for any code contributions, thanks!
As an exception, the GUI application uses the usual Qt / C++ conventions of
mixed-case variable names, capital letters for class names etc. However,
please do use an indention of one tab here too, just as with the other code.
The GTK GUI also uses the usual GTK naming conventions and so on, as far
as it makes sense, but otherwise also follows the kernel coding style.
This includes using one tab for indentation.
The Python decoders should also follow the usual Python conventions and use
Python idioms as far as it makes sense. The coding style should mostly follow
the Python PEP-8, which includes the convention of 4 spaces for indentation.
See http://www.python.org/dev/peps/pep-0008/ for details.
Random notes
------------
- Consistently use g_try_malloc() / g_try_malloc0() in libsigrok. Do not use
standard malloc()/calloc() if it can be avoided (sometimes other libs such
as libftdi can return malloc()'d memory, for example).
- Always properly match allocations with the proper *free() functions. If
glib's g_try_malloc()/g_try_malloc0() was used, use g_free() to free the
memory. Otherwise use standard free(). Never use the wrong function!
- Never use g_malloc() or g_malloc0() in libsigrok. These functions do not
return NULL if not enough memory is available but rather lead to an
exit() or segfault instead. This behaviour is not acceptable for libsigrok.
Use g_try_malloc()/g_try_malloc0() instead and check the return value.
- libsigrok should never print any messages (neither to stdout nor stderr nor
elsewhere) "manually" via e.g. printf() or g_log() or similar functions.
Only sr_err()/sr_warn()/sr_info()/sr_dbg() should be used.
Release engineering
-------------------
See
http://sigrok.org/wiki/Developers/Release_process
for a list of items that need to be done when releasing a new tarball.
Creating a Windows installer
----------------------------
In order to create a self-contained Windows installer EXE file for sigrok,
you can do the following (currently must be done on a Windows/MinGW system):
Build sigrok and install it into a temporary folder:
$ ./configure --prefix=$PWD/contrib/nsis/dist && make && make install
Build the Qt GUI:
$ cd gui
$ qmake
$ make
$ cd ..
Build the GTK+ GUI:
$ cd gtk
$ ./autogen.sh
$ ./configure
$ make
$ cd ..
Download the Windows Python 2.6.6 installer into contrib/nsis/dist:
$ cd contrib/nsis/dist
$ wget http://www.python.org/ftp/python/2.6.6/python-2.6.6.msi
$ cd ../../..
Create the installer (assumes all required libs in certain directories) via:
$ cd contrib/nsis
$ makensis sigrok.nsi
This will create a sigrok-installer-$VERSION.exe self-extracting installer.