1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

OP-305: add Windows unix-like build system scripts and README.txt

This commit is contained in:
Oleg Semyonov 2011-05-02 20:12:57 +03:00
parent d9221fac06
commit 21c4837f95
3 changed files with 225 additions and 0 deletions

107
make/win32/README.txt Normal file
View File

@ -0,0 +1,107 @@
This set of scripts is to provide a unix-like build environment on Windows.
---------------------------------------------------------------------------
Why do I need that?
-------------------
It allows to use the "Big Hammer", that is, to build whole OpenPilot system
with a single command "make all" using the top level Makefile originally
written for Linux and Mac only.
Also any routine task automation could use the same set of scripts and
commands on all platforms (Linux, Mac and Windows) if scripts are written in
the shell language. It is particularly important for cross-paltform projects
like the OpenPilot.
How to install this?
--------------------
Fortunately, it requires only few small text files since all others
components should already be installed on your system as parts of msysGit,
QtSDK and CodeSourcery G++ packages required to build the OpenPilot.
It is expected that you have the following tools installed into the listed
locations (but any other locations are fine as well):
- Python in C:\Python27
- CodeSourcery G++ in C:\CodeSourcery
- QtSDK in C:\Qt\2010.05
- msysGit in C:\Program Files\Git
Also it is assumed that you have the C:\Program Files\Git\cmd\ directory in
the PATH. Usually this is the case for msysGit installation if you have
chosen the 2nd option: put only git and gitk in the PATH (it is recommended
option).
Now you need to copy two files to your msysGit installation folders.
Assuming that you installed the msysGit into C:\Program Files\Git\,
you have to copy:
make\win32\make -> C:\Program Files\Git\bin\
make\win32\sh.cmd -> C:\Program Files\Git\cmd\
If you have msysGit installed into another directory, you need to update
paths accordingly. Also if you have tools installed into different
directories and they are not in the PATH, then you may want to update paths
in the sh.cmd script too (it is self-documented).
How to use it?
--------------
Interactive mode:
1) Type:
C:\> sh
and the bash prompt should appear:
user@pc /
$
2) Enter your OpenPilot directory:
user@pc /
$ cd D:/Work/OpenPilot/git
user@pc /d/Work/OpenPilot/git (master)
$
Note the current git branch in parentheses (master), if it exists.
The path format is also printed according to MSYS notation. And you
have to use forward slashes in paths, not backslashes.
3) Enter make command with required options and target list:
user@pc /d/Work/OpenPilot/git (master)
$ make all
The building should be started, and you will have full system including
ground software and flight firmware built in the end.
4) To build parts of the system you can use, for example, such commands:
user@pc /d/Work/OpenPilot/git (master)
$ make -j2 USE_BOOTLOADER=YES GCS_BUIL_CONF=release gcs coptercontrol bl_coptercontrol
or to completely remove the build directory:
user@pc /d/Work/OpenPilot/git (master)
$ make all_clean
Batch mode:
1) Create a shell script file containing all required commands, for instance:
#!/bin/sh
# This is the cc_make_release.sh file used to build CC release software
cd D:/Work/OpenPilot/git
make -j2 USE_BOOTLOADER=YES GCS_BUIL_CONF=release gcs coptercontrol bl_coptercontrol
echo RC=$?
2) Run it typing:
C:\> sh cc_make_release.sh
3) Of course, a lot of other shell commands can be used in scripts.

12
make/win32/make Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
#
# This file is to be put into C:\Program Files\Git\bin\ subdirectory
# (or similar, depeding on where the msysGit package was installed)
# to provide a make command to unix-like build environment on Windows.
#
# See also:
# README.txt
# http://wiki.openpilot.org/display/Doc/GCS+Development+on+Windows
#
mingw32-make.exe $*

106
make/win32/sh.cmd Normal file
View File

@ -0,0 +1,106 @@
@echo off
rem
rem This file is to be put into C:\Program Files\Git\cmd\ subdirectory
rem (or similar, depeding on where the msysGit package was installed)
rem to provide a shell prompt in the unix-like build environment on Windows.
rem
rem Currently supported on NT-class systems only (Windows XP and above).
rem
rem See also:
rem README.txt
rem http://wiki.openpilot.org/display/Doc/GCS+Development+on+Windows
rem
rem Based on the msys.bat file from the MSYS package
rem http://www.mingw.org/wiki/msys
rem
rem this should let run MSYS shell on x64
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
SET COMSPEC=%WINDIR%\SysWOW64\cmd.exe
)
rem some MSYS environment variables
if "x%MSYSTEM%" == "x" set MSYSTEM=MINGW32
if not "x%DISPLAY%" == "x" set DISPLAY=
rem --------------------------------------------------------------------------
rem To build the OpenPilot software we need few tools in the PATH.
rem Here we attempt to guess tools location using PATH or set them
rem directly using hard-coded locations, if not found in PATH.
rem You may want to update paths according to your installation.
rem --------------------------------------------------------------------------
set NOT_FOUND=
call :which PYTHON "C:\Python27" python.exe
call :which CODESOURCERY "C:\CodeSourcery\bin" cs-make.exe
call :which QTSDK "C:\Qt\2010.05\qt\bin" qmake.exe
call :which QTMINGW "C:\Qt\2010.05\mingw\bin" mingw32-make.exe
call :which MSYSGIT "%ProgramFiles%\Git\bin" git.exe
call :which UNSIS "%ProgramFiles%\NSIS\Unicode" makensis.exe
if "%NOT_FOUND%" == "" goto set_path
echo:
echo Some tools were not found in the PATH or expected location:
for %%f in (%NOT_FOUND%) do echo %%f
echo You may want to install them and/or update paths in the %0 file.
echo:
rem --------------------------------------------------------------------------
rem Provide a clean environment for command line build. We remove the
rem msysGit cmd subdirectory as well, so no recursive sh call can occur.
rem --------------------------------------------------------------------------
:set_path
set PATH=%SYSTEMROOT%\system32;%SYSTEMROOT%
set PATH=%MSYSGIT%;%QTMINGW%;%QTSDK%;%CODESOURCERY%;%PYTHON%;%UNSIS%;%PATH%
rem echo PATH: %PATH%
rem --------------------------------------------------------------------------
rem Start a shell.
rem Any shell script can be passed to it via command line of this batch file.
rem --------------------------------------------------------------------------
if not exist "%MSYSGIT%\bash.exe" goto no_bash
call %COMSPEC% /c "%MSYSGIT%\bash" --login -i %*
goto :eof
:no_bash
echo Cannot find bash, exiting with error
exit 1
rem --------------------------------------------------------------------------
rem Attempt to find executable in the PATH or at expected location.
rem --------------------------------------------------------------------------
:which
rem search in the PATH first
for %%F in (%3) do set FP=%%~$PATH:F
if exist "%FP%" goto found_in_path
rem search at expected location last
for %%F in (%2) do set FP=%%~F\%3
if exist "%FP%" goto found_directly
:not_found
for %%F in (%2) do set FP=%%~F
rem echo %3: not found, expected in %FP%
set FP=
set NOT_FOUND=%NOT_FOUND% %3
goto set
:found_in_path
for %%F in ("%FP%") do set FP=%%~dpsF
rem echo %3: found in the PATH: %FP%
goto set
:found_directly
for %%F in ("%FP%") do set FP=%%~dpsF
rem echo %3: found at: %FP%
:set
rem set results regardless of was it found or not
set %1=%FP%
rem echo %1=%FP%
goto :eof