OP-1516 fixed boundf mistake
[librepilot.git] / make / winx86 / README.txt
blob1dc0a1668b1683a46f080d324170b869144f2fb5
1 This set of scripts is to provide a unix-like build environment on Windows.\r
2 ---------------------------------------------------------------------------\r
3 \r
4 1. Why do I need it?\r
5 2. How to install?\r
6 3. How to use it?\r
7 3.1. Interactive mode\r
8 3.2. Batch mode\r
9 4. Advanced usage\r
10 5. Limitations of use\r
11 6. Credits and license\r
14 1. Why do I need it?\r
15 --------------------\r
16 It allows to use the "Big Hammer", that is, to build whole OpenPilot system\r
17 with a single command "make all" using the top level Makefile originally\r
18 written for Linux and Mac only.\r
20 Also any routine task automation could use the same set of scripts and commands\r
21 on all platforms (Linux, Mac and Windows) if scripts are written in the shell\r
22 language. It is particularly important for cross-paltform projects like the\r
23 OpenPilot.\r
26 2. How to install?\r
27 ------------------\r
28 Fortunately, it requires only few small text files since all others components\r
29 should already be installed on your system as parts of msysGit, QtSDK and\r
30 Arm compiler packages required to build the OpenPilot.\r
32 It is expected that you have the following tools installed into the listed\r
33 locations (but any other locations are fine as well):\r
35  - Python            in C:\Python27\r
36  - QtSDK             in C:\QtSDK (depending on SDK version)\r
37  - CodeSourcery G++  in %ProgramFiles%\CodeSourcery\Sourcery G++ Lite\r
38  - msysGit           in %ProgramFiles%\Git\r
39  - Unicode NSIS      in %ProgramFiles%\NSIS\Unicode\r
40  - OpenOCD           in C:\OpenOCD\0.4.0\bin (optional)\r
42 The SDL and SSL libraries and headers should be installed into Qt directories to \r
43 build the GCS. Check the wiki or ground/openpilotgcs/copydata.pro for details.\r
45 Also it is assumed that you have the C:\Program Files\Git\cmd\ directory in\r
46 the PATH. Usually this is the case for msysGit installation if you have chosen\r
47 the 2nd option: put only git and gitk in the PATH (it is recommended option).\r
49 Now you need to copy few files to your msysGit installation folders.\r
50 Assuming that you installed the msysGit into C:\Program Files\Git\,\r
51 you have to copy:\r
53    make\winx86\bin\*  ->  C:\Program Files\Git\bin\\r
54    make\winx86\cmd\*  ->  C:\Program Files\Git\cmd\\r
56 If you have msysGit installed into another directory, you need to update paths\r
57 accordingly. Also if you have tools installed into different directories and\r
58 they are not in the PATH, then you may want to update paths in the sh.cmd\r
59 script too (it is self-documented).\r
61 Note for Windows 64-bit users: 64-bit systems use %ProgramFiles(x86)% folder\r
62 as default for program files instead of %ProgramFiles%. You have to check where\r
63 your tools are installed and update paths above accordingly.\r
66 3. How to use it?\r
67 -----------------\r
69 3.1. Interactive mode\r
70 ---------------------\r
72 1) Type:\r
74    C:\> sh\r
76 and the bash prompt should appear:\r
78    user@pc /\r
79    $\r
81 2) Enter your OpenPilot directory:\r
83    user@pc /\r
84    $ cd D:/Work/OpenPilot/git\r
86    user@pc /d/Work/OpenPilot/git (master)\r
87    $\r
89 Note the current git branch in parentheses (master), if it exists. The path\r
90 format is also printed according to MSYS notation. And you have to use forward\r
91 slashes in paths, not backslashes.\r
93 3) Enter make command with required options and target list:\r
95    user@pc /d/Work/OpenPilot/git (master)\r
96    $ make all\r
98 The building should be started, and you will have full system including ground\r
99 software and flight firmware built in the end.\r
101 4) To build parts of the system you can use, for example, such commands:\r
103    user@pc /d/Work/OpenPilot/git (master)\r
104    $ make -j2 GCS_BUILD_CONF=release gcs coptercontrol\r
106 or to completely remove the build directory:\r
108    user@pc /d/Work/OpenPilot/git (master)\r
109    $ make all_clean\r
112 3.2. Batch mode\r
113 ---------------\r
115 1) Create a shell script file containing all required commands, for instance:\r
117    #!/bin/sh\r
118    # This is the cc_make_release.sh file used to build CC release software\r
119    cd D:/Work/OpenPilot/git\r
120    make -j2 GCS_BUILD_CONF=release gcs coptercontrol\r
121    echo RC=$?\r
123 2) Run it typing:\r
125    C:\> sh cc_make_release.sh\r
127 3) Of course, a lot of other shell commands can be used in scripts.\r
130 4. Advanced usage\r
131 -----------------\r
133 It is possible to go further and integrate shell scripting into Windows system\r
134 like any other executables. This allows:\r
136  - double click on any .sh file in the Explorer window to execute it;\r
137  - type name of .sh file with any arguments on the command line to run script;\r
138  - omit .sh extension typing names since it is now recognized automatically;\r
139  - call .sh scripts even from .bat and .cmd files as Windows command;\r
140  - execute scripts which are in any directory in the PATH;\r
141  - return and check exit code from .sh scripts to .bat or .cmd batch files.\r
143 In short, you may have quite powerful and cross-platform bash scripting on\r
144 Windows.\r
146 In order to integrate bash scripting into Windows system you need to:\r
148  - double click on the included shell_script.reg file to register .sh\r
149    extension in the system. Thus, any click on .sh script will execute it\r
150    automatically assuming that the sh.cmd is in the PATH;\r
151  - register .sh extension as an executable file type, so you can omit the\r
152    .sh typing commands. To do so open "My Computer" properties dialog, choose\r
153    the "Advanced" tab, "Environment variables", in the "System variables"\r
154    find the variable called "PATHEXT". It contains the list of "executable"\r
155    file extensions separated by semicolon. You want to add a ";.SH" to the\r
156    end of its value. Then click OK to apply.\r
158 Now any .sh script can be run just by typing its name, optionally with\r
159 parameters.\r
161 As an example, you can create a shell script named make.sh in the cmd/\r
162 subdirectory of Git installation with the following content:\r
164    exec /bin/make $*\r
166 and then build the OpenPilot software typing\r
168    make all\r
170 directly from Windows command line or from a batch file.\r
172 You also may want to rename or remove "C:\Program Files\Git\etc\motd" file\r
173 to get rid of git bash welcome message on every script invocation.\r
176 5. Limitations of use\r
177 ---------------------\r
179 Currently there may be some problems running scripts which contain spaces in\r
180 file names or located in directories which contain spaces in full paths.\r
181 It results in strange "file not found" or other errors.\r
183 It is recommended to avoid using such names with spaces.\r
186 6. Credits and license\r
187 ----------------------\r
189 This set of scripts uses the MSYS package included into the msysGit\r
190 distribution and MinGW make included into the QtSDK package.\r
192 The sh.cmd, shell_script.reg and this README.txt files were written\r
193 by Oleg Semyonov (os@openpilot.org) for the OpenPilot project and\r
194 are licensed under CC-BY-SA terms:\r
196     http://creativecommons.org/licenses/by-sa/3.0/\r
198 Feel free to contact me for additions and improvements.\r
200 Happy bashing!\r