Debian Codegraph @

third-party/pjproject/README-hacking.md

raw symbols SCIP
1 # Hacking on PJProject
2
3 ## Intro
4 There are times when you need to troubleshoot issues with bundled pjproject
5 or add new features that need to be pushed upstream but...
6
7 * The source directory created by extracting the pjproject tarball is not
8 scanned for code changes so you have to keep forcing rebuilds.
9 * The source directory isn't a git repo so you can't easily create patches,
10 do git bisects, etc.
11 * Accidentally doing a make distclean will ruin your day by wiping out the
12 source directory, and your changes.
13 * etc.
14
15 Well No More!
16
17 You can now replace the `source` directory that's normally created
18 by the Makefile extracting the tarball, with a symlink to a "real" pjproject
19 git clone. The Makefile will now detect that `source` is a real pjproject
20 repo and enable some advanced behaviors (and disable others).
21
22 ## Setup
23
24 Let's assume you have an Asterisk development environment like so:
25
26 ```plain
27 ~/dev/asterisk/
28 asterisk/
29 .git/
30 addons/
31 ...
32 third-party/
33 jansson/
34 pjproject/
35 ```
36
37 ### Cloning pjproject
38
39 Start by cloning a pjproject repository next to your asterisk repository.
40 The source of the clone depends on whether you anticipate pushing changes
41 back upstream or not. If you already have a good pjproject repository clone,
42 read this section anyway but you probably won't have to do anything.
43
44 * For pushing upstream: (Community Contributors)
45 * Make sure you have the proper ssh keys added to your github account
46 so you can push changes.
47 * Navigate to https://github.com/pjsip/pjproject
48 * Click the "Fork" button to create a fork under your own username.
49
50 Back on your own machine...
51
52 ```plain
53 $ cd ~/dev/asterisk
54 $ git clone [email protected]:<yourusername>/pjproject
55 ```
56
57 * For pushing upstream: (Asterisk Core Team Developers)
58 Asterisk Core Team Developers should clone the fork we have in our own
59 Asterisk github organization.
60
61 ```plain
62 $ cd ~/dev/asterisk
63 $ git clone [email protected]:asterisk/pjproject
64 ```
65
66 Regardless of how you got your repo, you'll need to create an "upstream"
67 remote that points to the original pjproject repo.
68
69 ```plain
70 $ cd pjproject
71 $ git remote add upstream https://github.com/pjsip/pjproject
72 ```
73
74 If you're just troubleshooting and don't plan on pushing changes upstream,
75 you can just clone directly from the upstream pjproject repo.
76
77 ```plain
78 $ cd ~/dev/asterisk
79 $ git clone https://github.com/pjsip/pjproject
80 ```
81
82 Your directory structure should now look something like:
83
84 ```plain
85 ~/dev/asterisk/
86 asterisk/
87 .git/
88 addons/
89 ...
90 third-party/
91 jansson/
92 pjproject/
93 pjproject/
94 .git
95 pjlib/
96 ...
97 ```
98
99 ### Adjusting Asterisk
100 Start with a "distcleaned" asterisk work tree then in the
101 asterisk/third-party/pjproject directory, create a symlink to the pjproject
102 clone you just created.
103
104 ```plain
105 $ cd ~/dev/asterisk/asterisk/
106 $ make distclean
107 $ cd third-party/pjproject
108 $ ln -s ../../../pjproject source
109 ```
110 The "source" directory is now a relative symlink to your pjproject
111 clone so your directory structure should now look something like:
112
113 ```plain
114 ~/dev/asterisk/
115 asterisk/
116 .git/
117 addons/
118 ...
119 third-party/
120 jansson/
121 pjproject/
122 source -> ../../../pjproject
123 pjproject/
124 .git
125 pjlib/
126 ...
127 ```
128
129 ### Adjust pjproject git ignores.
130 One final step is required to keep your pjproject repo from being dirtied
131 by the build process. Add the following lines to your pjproject (not asterisk)
132 repo's .git/info/exclude file...
133
134 ```plain
135 **/*.astdep
136 **/*asterisk_malloc_debug*
137 ```
138 Don't add these to the top-level .gitignore file! If you do, they'll become
139 part of any change you submit upstream.
140
141 ## Usage
142
143 Just run `./configure` and `make` as you would for any other asterisk build.
144 When you make changes to pjproject source files, they'll be automatically
145 recompiled the next time you build asterisk.
146
147 You can do git operations in the pjproject repo while it's still symlinked
148 into the asterisk source. Assuming you made the proper changes to
149 pjproject's .git/info/exclude file, a commit in the pjproject repo _should_ contain
150 only the changes you made.
151
152 You can run `make` commands directly in third-party/pjproject The only
153 requirement is that an asterisk top-level `configure` had to have been
154 run at least once.
155
156 You can always revert to standard bundled pjproject by running an asterisk
157 top-level `make distclean`, removing the third-party/pjproject/source
158 symlink, and re-running a top-level `configure`. That will download and
159 extract the pjproject tarball to the `third-party/pjproject/source`
160 directory as usual.
161
162 ### Notes
163
164 While your pjproject repo is symlinked into the asterisk source tree,
165 you should not run `configure` directly in the pjproject repo. You won't get
166 the proper options applied to be compatible with Asterisk. You can run
167 `make` though.
168
169 Although asterisk_malloc_debug.h and site_config.h are applied to the pjproject
170 repo, No patches from the `third-party/pjproject/patches` directory are
171 applied. Since you're probably working off the pjproject master branch,
172 the patches aren't needed. Also, applying the patches would contaminate
173 the pjproject repo and you wouldn't be able to do a clean commit there.
174
175 You may see compile and/or link warnings you wouldn't see with a normal
176 bundled build.
177
178 ## How it works
179
180 When an asterisk top-level `configure` is run, `third-party/pjproject/configure.m4 `
181 checks whether `third-party/pjproject/source` is a symlink or is a git
182 repository. If neither are true, the build isn't considered "out-of-tree"
183 and the normal pjproject bundled process occurs.
184 If either is true, it sets `PJPROJECT_BUNDLED_OOT=yes` for the Makefiles.
185
186 When a `make` is done, either from top-level asterisk or from the
187 third-party/pjproject directory, it checks `PJPROJECT_BUNDLED_OOT`
188 and if set to yes it...
189
190 * Alters the behavior of `clean` and `distclean` to just run
191 pjproject's `clean` or `distclean` targets and to NOT remove the
192 `source` directory or symlink as it would normally do.
193
194 * Generates `astdep` dependency files in the pjproject source tree
195 if they don't already exist. These are git-ignored by the edit
196 to pjproject's `.git/info/exclude` done above. You'll
197 see new progress messages during the make as the astdep files are
198 built.
199
200 * Copies asterisk_malloc_debug.h and config_site.h from the patches
201 directory into the pjproject source tree. These are also git-ignored
202 by the edit to pjproject's
203 `.git/info/exclude` file.
204
205 * Compiles only the out-of-date source files into their respective
206 libpj libraries. That in turn triggers the asterisk top-level
207 make to re-link main/libasteriskpj.so.
208
209
210