xref: /OK3568_Linux_fs/buildroot/docs/manual/using-buildroot-development.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun// -*- mode:doc; -*-
2*4882a593Smuzhiyun// vim: set syntax=asciidoc:
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun==== Using Buildroot during development
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunThe normal operation of Buildroot is to download a tarball, extract
7*4882a593Smuzhiyunit, configure, compile and install the software component found inside
8*4882a593Smuzhiyunthis tarball. The source code is extracted in
9*4882a593Smuzhiyun+output/build/<package>-<version>+, which is a temporary directory:
10*4882a593Smuzhiyunwhenever +make clean+ is used, this directory is entirely removed, and
11*4882a593Smuzhiyunre-created at the next +make+ invocation. Even when a Git or
12*4882a593SmuzhiyunSubversion repository is used as the input for the package source
13*4882a593Smuzhiyuncode, Buildroot creates a tarball out of it, and then behaves as it
14*4882a593Smuzhiyunnormally does with tarballs.
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunThis behavior is well-suited when Buildroot is used mainly as an
17*4882a593Smuzhiyunintegration tool, to build and integrate all the components of an
18*4882a593Smuzhiyunembedded Linux system. However, if one uses Buildroot during the
19*4882a593Smuzhiyundevelopment of certain components of the system, this behavior is not
20*4882a593Smuzhiyunvery convenient: one would instead like to make a small change to the
21*4882a593Smuzhiyunsource code of one package, and be able to quickly rebuild the system
22*4882a593Smuzhiyunwith Buildroot.
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunMaking changes directly in +output/build/<package>-<version>+ is not
25*4882a593Smuzhiyunan appropriate solution, because this directory is removed on +make
26*4882a593Smuzhiyunclean+.
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunTherefore, Buildroot provides a specific mechanism for this use case:
29*4882a593Smuzhiyunthe +<pkg>_OVERRIDE_SRCDIR+ mechanism. Buildroot reads an _override_
30*4882a593Smuzhiyunfile, which allows the user to tell Buildroot the location of the
31*4882a593Smuzhiyunsource for certain packages.
32*4882a593Smuzhiyun
33*4882a593SmuzhiyunThe default location of the override file is +$(CONFIG_DIR)/local.mk+,
34*4882a593Smuzhiyunas defined by the +BR2_PACKAGE_OVERRIDE_FILE+ configuration option.
35*4882a593Smuzhiyun+$(CONFIG_DIR)+ is the location of the Buildroot +.config+ file, so
36*4882a593Smuzhiyun+local.mk+ by default lives side-by-side with the +.config+ file,
37*4882a593Smuzhiyunwhich means:
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun* In the top-level Buildroot source directory for in-tree builds
40*4882a593Smuzhiyun  (i.e., when +O=+ is not used)
41*4882a593Smuzhiyun* In the out-of-tree directory for out-of-tree builds (i.e., when
42*4882a593Smuzhiyun  +O=+ is used)
43*4882a593Smuzhiyun
44*4882a593SmuzhiyunIf a different location than these defaults is required, it can be
45*4882a593Smuzhiyunspecified through the +BR2_PACKAGE_OVERRIDE_FILE+ configuration
46*4882a593Smuzhiyunoption.
47*4882a593Smuzhiyun
48*4882a593SmuzhiyunIn this _override_ file, Buildroot expects to find lines of the form:
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun------------------
51*4882a593Smuzhiyun<pkg1>_OVERRIDE_SRCDIR = /path/to/pkg1/sources
52*4882a593Smuzhiyun<pkg2>_OVERRIDE_SRCDIR = /path/to/pkg2/sources
53*4882a593Smuzhiyun------------------
54*4882a593Smuzhiyun
55*4882a593SmuzhiyunFor example:
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun------------------
58*4882a593SmuzhiyunLINUX_OVERRIDE_SRCDIR = /home/bob/linux/
59*4882a593SmuzhiyunBUSYBOX_OVERRIDE_SRCDIR = /home/bob/busybox/
60*4882a593Smuzhiyun------------------
61*4882a593Smuzhiyun
62*4882a593SmuzhiyunWhen Buildroot finds that for a given package, an
63*4882a593Smuzhiyun+<pkg>_OVERRIDE_SRCDIR+ has been defined, it will no longer attempt to
64*4882a593Smuzhiyundownload, extract and patch the package. Instead, it will directly use
65*4882a593Smuzhiyunthe source code available in the specified directory and +make clean+
66*4882a593Smuzhiyunwill not touch this directory. This allows to point Buildroot to your
67*4882a593Smuzhiyunown directories, that can be managed by Git, Subversion, or any other
68*4882a593Smuzhiyunversion control system. To achieve this, Buildroot will use _rsync_ to
69*4882a593Smuzhiyuncopy the source code of the component from the specified
70*4882a593Smuzhiyun+<pkg>_OVERRIDE_SRCDIR+ to +output/build/<package>-custom/+.
71*4882a593Smuzhiyun
72*4882a593SmuzhiyunThis mechanism is best used in conjunction with the +make
73*4882a593Smuzhiyun<pkg>-rebuild+ and +make <pkg>-reconfigure+ targets. A +make
74*4882a593Smuzhiyun<pkg>-rebuild all+ sequence will _rsync_ the source code from
75*4882a593Smuzhiyun+<pkg>_OVERRIDE_SRCDIR+ to +output/build/<package>-custom+ (thanks to
76*4882a593Smuzhiyun_rsync_, only the modified files are copied), and restart the build
77*4882a593Smuzhiyunprocess of just this package.
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunIn the example of the +linux+ package above, the developer can then
80*4882a593Smuzhiyunmake a source code change in +/home/bob/linux+ and then run:
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun-----------------------
83*4882a593Smuzhiyunmake linux-rebuild all
84*4882a593Smuzhiyun-----------------------
85*4882a593Smuzhiyun
86*4882a593Smuzhiyunand in a matter of seconds gets the updated Linux kernel image in
87*4882a593Smuzhiyun+output/images+. Similarly, a change can be made to the BusyBox source
88*4882a593Smuzhiyuncode in +/home/bob/busybox+, and after:
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun-----------------------
91*4882a593Smuzhiyunmake busybox-rebuild all
92*4882a593Smuzhiyun-----------------------
93*4882a593Smuzhiyun
94*4882a593Smuzhiyunthe root filesystem image in +output/images+ contains the updated
95*4882a593SmuzhiyunBusyBox.
96*4882a593Smuzhiyun
97*4882a593SmuzhiyunSource trees for big projects often contain hundreds or thousands of
98*4882a593Smuzhiyunfiles which are not needed for building, but will slow down the process
99*4882a593Smuzhiyunof copying the sources with _rsync_. Optionally, it is possible define
100*4882a593Smuzhiyun+<pkg>_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS+ to skip syncing certain files
101*4882a593Smuzhiyunfrom the source tree. For example, when working on the +webkitgtk+
102*4882a593Smuzhiyunpackage, the following will exclude the tests and in-tree builds from
103*4882a593Smuzhiyuna local WebKit source tree:
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun------------------
106*4882a593SmuzhiyunWEBKITGTK_OVERRIDE_SRCDIR = /home/bob/WebKit
107*4882a593SmuzhiyunWEBKITGTK_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS = \
108*4882a593Smuzhiyun	--exclude JSTests --exclude ManualTests --exclude PerformanceTests \
109*4882a593Smuzhiyun	--exclude WebDriverTests --exclude WebKitBuild --exclude WebKitLibraries \
110*4882a593Smuzhiyun	--exclude WebKit.xcworkspace --exclude Websites --exclude Examples
111*4882a593Smuzhiyun------------------
112*4882a593Smuzhiyun
113*4882a593SmuzhiyunBy default, Buildroot skips syncing of VCS artifacts (e.g., the *.git* and
114*4882a593Smuzhiyun*.svn* directories). Some packages prefer to have these VCS directories
115*4882a593Smuzhiyunavailable during build, for example for automatically determining a precise
116*4882a593Smuzhiyuncommit reference for version information. To undo this built-in filtering at a
117*4882a593Smuzhiyuncost of a slower speed, add these directories back:
118*4882a593Smuzhiyun
119*4882a593Smuzhiyun------------------
120*4882a593SmuzhiyunLINUX_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS = --include .git
121*4882a593Smuzhiyun------------------
122