diff options
author | Nicolas Dechesne <nicolas.dechesne@linaro.org> | 2020-06-26 19:10:51 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-09-17 10:09:33 +0100 |
commit | 9bd69b1f1d71a9692189beeac75af9dfbad816cc (patch) | |
tree | 305347fca899074aed5610e0e82eaec180bf630c /documentation/adt-manual/adt-command.rst | |
parent | c40a8d5904c29046f1cbbeb998e6cd7c24f9b206 (diff) | |
download | poky-9bd69b1f1d71a9692189beeac75af9dfbad816cc.tar.gz |
sphinx: initial sphinx support
This commit is autogenerated pandoc to generate an inital set
of reST files based on DocBook XML files.
A .rst file is generated for each .xml files in all manuals with this
command:
cd <manual>
for i in *.xml; do \
pandoc -f docbook -t rst --shift-heading-level-by=-1 \
$i -o $(basename $i .xml).rst \
done
The conversion was done with: pandoc 2.9.2.1-91 (Arch Linux).
Also created an initial top level index file for each document, and
added all 'books' to the top leve index.rst file.
The YP manuals layout is organized as:
Book
Chapter
Section
Section
Section
Sphinx uses section headers to create the document structure.
ReStructuredText defines sections headers like that:
To break longer text up into sections, you use section headers. These
are a single line of text (one or more words) with adornment: an
underline alone, or an underline and an overline together, in dashes
"-----", equals "======", tildes "~~~~~~" or any of the
non-alphanumeric characters = - ` : ' " ~ ^ _ * + # < > that you feel
comfortable with. An underline-only adornment is distinct from an
overline-and-underline adornment using the same character. The
underline/overline must be at least as long as the title text. Be
consistent, since all sections marked with the same adornment style
are deemed to be at the same level:
Let's define the following convention when converting from Docbook:
Book => overline === (Title)
Chapter => overline *** (1.)
Section => ==== (1.1)
Section => ---- (1.1.1)
Section => ~~~~ (1.1.1.1)
Section => ^^^^ (1.1.1.1.1)
During the conversion with pandoc, we used --shift-heading-level=-1 to
convert most of DocBook headings automatically. However with this
setting, the Chapter header was removed, so I added it back
manually. Without this setting all headings were off by one, which was
more difficult to manually fix.
At least with this change, we now have the same TOC with Sphinx and
DocBook.
(From yocto-docs rev: 3c73d64a476d4423ee4c6808c685fa94d88d7df8)
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation/adt-manual/adt-command.rst')
-rw-r--r-- | documentation/adt-manual/adt-command.rst | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/documentation/adt-manual/adt-command.rst b/documentation/adt-manual/adt-command.rst new file mode 100644 index 0000000000..41bc41e149 --- /dev/null +++ b/documentation/adt-manual/adt-command.rst | |||
@@ -0,0 +1,178 @@ | |||
1 | ********************** | ||
2 | Using the Command Line | ||
3 | ********************** | ||
4 | |||
5 | Recall that earlier the manual discussed how to use an existing | ||
6 | toolchain tarball that had been installed into the default installation | ||
7 | directory, ``/opt/poky/DISTRO``, which is outside of the `Build | ||
8 | Directory <&YOCTO_DOCS_DEV_URL;#build-directory>`__ (see the section | ||
9 | "`Using a Cross-Toolchain | ||
10 | Tarball) <#using-an-existing-toolchain-tarball>`__". And, that sourcing | ||
11 | your architecture-specific environment setup script initializes a | ||
12 | suitable cross-toolchain development environment. | ||
13 | |||
14 | During this setup, locations for the compiler, QEMU scripts, QEMU | ||
15 | binary, a special version of ``pkgconfig`` and other useful utilities | ||
16 | are added to the ``PATH`` variable. Also, variables to assist | ||
17 | ``pkgconfig`` and ``autotools`` are also defined so that, for example, | ||
18 | ``configure.sh`` can find pre-generated test results for tests that need | ||
19 | target hardware on which to run. You can see the "`Setting Up the | ||
20 | Cross-Development | ||
21 | Environment <#setting-up-the-cross-development-environment>`__" section | ||
22 | for the list of cross-toolchain environment variables established by the | ||
23 | script. | ||
24 | |||
25 | Collectively, these conditions allow you to easily use the toolchain | ||
26 | outside of the OpenEmbedded build environment on both Autotools-based | ||
27 | projects and Makefile-based projects. This chapter provides information | ||
28 | for both these types of projects. | ||
29 | |||
30 | Autotools-Based Projects | ||
31 | ======================== | ||
32 | |||
33 | Once you have a suitable cross-toolchain installed, it is very easy to | ||
34 | develop a project outside of the OpenEmbedded build system. This section | ||
35 | presents a simple "Helloworld" example that shows how to set up, | ||
36 | compile, and run the project. | ||
37 | |||
38 | Creating and Running a Project Based on GNU Autotools | ||
39 | ----------------------------------------------------- | ||
40 | |||
41 | Follow these steps to create a simple Autotools-based project: | ||
42 | |||
43 | 1. *Create your directory:* Create a clean directory for your project | ||
44 | and then make that directory your working location: $ mkdir | ||
45 | $HOME/helloworld $ cd $HOME/helloworld | ||
46 | |||
47 | 2. *Populate the directory:* Create ``hello.c``, ``Makefile.am``, and | ||
48 | ``configure.in`` files as follows: | ||
49 | |||
50 | - For ``hello.c``, include these lines: #include <stdio.h> main() { | ||
51 | printf("Hello World!\n"); } | ||
52 | |||
53 | - For ``Makefile.am``, include these lines: bin_PROGRAMS = hello | ||
54 | hello_SOURCES = hello.c | ||
55 | |||
56 | - For ``configure.in``, include these lines: AC_INIT(hello.c) | ||
57 | AM_INIT_AUTOMAKE(hello,0.1) AC_PROG_CC AC_PROG_INSTALL | ||
58 | AC_OUTPUT(Makefile) | ||
59 | |||
60 | 3. *Source the cross-toolchain environment setup file:* Installation of | ||
61 | the cross-toolchain creates a cross-toolchain environment setup | ||
62 | script in the directory that the ADT was installed. Before you can | ||
63 | use the tools to develop your project, you must source this setup | ||
64 | script. The script begins with the string "environment-setup" and | ||
65 | contains the machine architecture, which is followed by the string | ||
66 | "poky-linux". Here is an example that sources a script from the | ||
67 | default ADT installation directory that uses the 32-bit Intel x86 | ||
68 | Architecture and the DISTRO_NAME Yocto Project release: $ source | ||
69 | /opt/poky/DISTRO/environment-setup-i586-poky-linux | ||
70 | |||
71 | 4. *Generate the local aclocal.m4 files and create the configure | ||
72 | script:* The following GNU Autotools generate the local | ||
73 | ``aclocal.m4`` files and create the configure script: $ aclocal $ | ||
74 | autoconf | ||
75 | |||
76 | 5. *Generate files needed by GNU coding standards:* GNU coding | ||
77 | standards require certain files in order for the project to be | ||
78 | compliant. This command creates those files: $ touch NEWS README | ||
79 | AUTHORS ChangeLog | ||
80 | |||
81 | 6. *Generate the configure file:* This command generates the | ||
82 | ``configure``: $ automake -a | ||
83 | |||
84 | 7. *Cross-compile the project:* This command compiles the project using | ||
85 | the cross-compiler. The | ||
86 | ```CONFIGURE_FLAGS`` <&YOCTO_DOCS_REF_URL;#var-CONFIGURE_FLAGS>`__ | ||
87 | environment variable provides the minimal arguments for GNU | ||
88 | configure: $ ./configure ${CONFIGURE_FLAGS} | ||
89 | |||
90 | 8. *Make and install the project:* These two commands generate and | ||
91 | install the project into the destination directory: $ make $ make | ||
92 | install DESTDIR=./tmp | ||
93 | |||
94 | 9. *Verify the installation:* This command is a simple way to verify | ||
95 | the installation of your project. Running the command prints the | ||
96 | architecture on which the binary file can run. This architecture | ||
97 | should be the same architecture that the installed cross-toolchain | ||
98 | supports. $ file ./tmp/usr/local/bin/hello | ||
99 | |||
100 | 10. *Execute your project:* To execute the project in the shell, simply | ||
101 | enter the name. You could also copy the binary to the actual target | ||
102 | hardware and run the project there as well: $ ./hello As expected, | ||
103 | the project displays the "Hello World!" message. | ||
104 | |||
105 | Passing Host Options | ||
106 | -------------------- | ||
107 | |||
108 | For an Autotools-based project, you can use the cross-toolchain by just | ||
109 | passing the appropriate host option to ``configure.sh``. The host option | ||
110 | you use is derived from the name of the environment setup script found | ||
111 | in the directory in which you installed the cross-toolchain. For | ||
112 | example, the host option for an ARM-based target that uses the GNU EABI | ||
113 | is ``armv5te-poky-linux-gnueabi``. You will notice that the name of the | ||
114 | script is ``environment-setup-armv5te-poky-linux-gnueabi``. Thus, the | ||
115 | following command works to update your project and rebuild it using the | ||
116 | appropriate cross-toolchain tools: $ ./configure | ||
117 | --host=armv5te-poky-linux-gnueabi \\ --with-libtool-sysroot=sysroot_dir | ||
118 | |||
119 | .. note:: | ||
120 | |||
121 | If the | ||
122 | configure | ||
123 | script results in problems recognizing the | ||
124 | --with-libtool-sysroot= | ||
125 | sysroot-dir | ||
126 | option, regenerate the script to enable the support by doing the | ||
127 | following and then run the script again: | ||
128 | :: | ||
129 | |||
130 | $ libtoolize --automake | ||
131 | $ aclocal -I ${OECORE_NATIVE_SYSROOT}/usr/share/aclocal \ | ||
132 | [-I dir_containing_your_project-specific_m4_macros] | ||
133 | $ autoconf | ||
134 | $ autoheader | ||
135 | $ automake -a | ||
136 | |||
137 | |||
138 | Makefile-Based Projects | ||
139 | ======================= | ||
140 | |||
141 | For Makefile-based projects, the cross-toolchain environment variables | ||
142 | established by running the cross-toolchain environment setup script are | ||
143 | subject to general ``make`` rules. | ||
144 | |||
145 | To illustrate this, consider the following four cross-toolchain | ||
146 | environment variables: | ||
147 | `CC <&YOCTO_DOCS_REF_URL;#var-CC>`__\ =i586-poky-linux-gcc -m32 | ||
148 | -march=i586 --sysroot=/opt/poky/1.8/sysroots/i586-poky-linux | ||
149 | `LD <&YOCTO_DOCS_REF_URL;#var-LD>`__\ =i586-poky-linux-ld | ||
150 | --sysroot=/opt/poky/1.8/sysroots/i586-poky-linux | ||
151 | `CFLAGS <&YOCTO_DOCS_REF_URL;#var-CFLAGS>`__\ =-O2 -pipe -g | ||
152 | -feliminate-unused-debug-types | ||
153 | `CXXFLAGS <&YOCTO_DOCS_REF_URL;#var-CXXFLAGS>`__\ =-O2 -pipe -g | ||
154 | -feliminate-unused-debug-types Now, consider the following three cases: | ||
155 | |||
156 | - *Case 1 - No Variables Set in the ``Makefile``:* Because these | ||
157 | variables are not specifically set in the ``Makefile``, the variables | ||
158 | retain their values based on the environment. | ||
159 | |||
160 | - *Case 2 - Variables Set in the ``Makefile``:* Specifically setting | ||
161 | variables in the ``Makefile`` during the build results in the | ||
162 | environment settings of the variables being overwritten. | ||
163 | |||
164 | - *Case 3 - Variables Set when the ``Makefile`` is Executed from the | ||
165 | Command Line:* Executing the ``Makefile`` from the command line | ||
166 | results in the variables being overwritten with command-line content | ||
167 | regardless of what is being set in the ``Makefile``. In this case, | ||
168 | environment variables are not considered unless you use the "-e" flag | ||
169 | during the build: $ make -e file If you use this flag, then the | ||
170 | environment values of the variables override any variables | ||
171 | specifically set in the ``Makefile``. | ||
172 | |||
173 | .. note:: | ||
174 | |||
175 | For the list of variables set up by the cross-toolchain environment | ||
176 | setup script, see the " | ||
177 | Setting Up the Cross-Development Environment | ||
178 | " section. | ||