Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is packaging still done for MAVLink? #74

Open
hamishwillee opened this issue Jul 5, 2018 · 0 comments
Open

Is packaging still done for MAVLink? #74

hamishwillee opened this issue Jul 5, 2018 · 0 comments
Assignees
Labels

Comments

@hamishwillee
Copy link
Collaborator

Mavlink.org had a topic about packaging MAVLink (old source below). This seems to cover making a windows installer and "building mavlink".
What is this about? I thought mavlink wasn't "built" but rather "generated". Why would we need a windows installer?

The only useful stuff here seems to be the toolchain explanation: "Pymavlink is used to generate the C source code from the message definitions.".

THoughts?

====== MAVLink Packaging ======

//This page is intended for MAVLink developers only. If you just want to use the common message set, head to [[:mavlink:installation]], if you want to generate your own messages / your own dialect, head to [[:mavlink:generator]].//

===== Message Definitions =====

All mavlink messages are generated off of the definitions under the message_definitions of the mavlink git repository root directory.

===== PyMAVLink Generation =====

Pymavlink is used to generate the C source code from the message definitions. This is the portion of the cmake file that automates this build process. CMake is used here to manage file dependencies and automate package generation as shown later.

<code cmake>
# mavlink generation
macro(generateMavlink version definitions)
    foreach(definition ${definitions})
        set(targetName ${definition}-v${version})
        set(definitionAbsPath ${CMAKE_SOURCE_DIR}/message_definitions/v${version}/${definition})
        message(STATUS "processing: ${definitionAbsPath}")
        add_custom_command( 
            OUTPUT ${targetName}-stamp
            COMMAND ${PYTHON_EXECUTABLE} ${mavgen} --lang=C --wire-protocol=${version}
                --output=include/v${version} ${definitionAbsPath}
            COMMAND touch ${targetName}-stamp
            DEPENDS ${definitionAbsPath} ${mavgen}
            )
        add_custom_target(${targetName} ALL DEPENDS ${targetName}-stamp)
    endforeach()
endmacro()

# build
set(mavgen ${CMAKE_CURRENT_SOURCE_DIR}/pymavlink/generator/mavgen.py)
</code>

===== Packaging MAVLink Releases =====

==== Windows ====

  - Download cmake version 2.8 or later:http://www.cmake.org/cmake/resources/software.html
  - Download and setup git on windows: http://www.sparkfun.com/tutorials/165 (Great Sparkfun tutorial on this.)
  - Using Tortoise git, clone MAVLink.
  - <code>git clone git://github.com/mavlink/mavlink.git -b pymavlink_merge </code>
  - Use cmake gui, click configure, then click build.
  - Now navigate to the cmake build directory and type cpack. A nullsoft installer will be produced.

==== Linux ====

=== Install CMake and Download MAVLink ===

<code bash>
sudo apt-get install cmake
mkdir -P ~/home/Projects && cd ~/home/Projects
git clone git://github.com/mavlink/mavlink.git -b pymavlink_merge
cd mavlink
mkdir -P build
cd build && cmake ..
</code>

=== Compile MAVLink ===
<code bash>
cd ~/src/Projects/mavlink
mkdir -P build
cd build && cmake ..
</code>

=== Create a linux installer ===

If you are running Mac/ or a non-debian linux distribution this will create a self-extracting tarball package.
If you are running debian/ubunut it will create a debian installer that you can use to install mavlink on your system.

<code bash>
cd ~/src/Projects/mavlink/build-mingw && cpack
</code>

==== Cross-compiling on Linux for Windows ====

=== Install mingw cross env ===
This will take around 10 hours to complete so do it overnight. You can type make library for a specific library but this ends up being more work.

<code bash>
sudo apt-get install mercurial
mkdir -P ~/home/Projects && cd ~/home/Projects
http://mingw-cross-env.nongnu.org/
hg clone http://hg.savannah.nongnu.org/hgweb/mingw-cross-env
cd mingw-cross-env && make install
</code>

=== Run ranlib over all libs ===
Some libraries may fail to link correctly. To prevent this rerun ranlib over all the static libraries.
 
<code bash>
for file in $(find ./usr/i686-pc-mingw32/lib -regex ".+\.a")
do
    echo fixing $file
   ./user/bin/i686-pc-ming32-ranlib $file
done
</code>

=== Setup path for cmake-mingw ===

In the file ~/.profile you should create an alias for cmake-mingw

<code bash>
alias cmake-mingw=cmake -DCMAKE_TOOLCHAIN_FILE=~/home/Projects/mingw-cross-env/usr/i686-pc-mingw32/share/cmake/mingw-cross-env-conf.cmake
</code>

=== Download and compile the code ===

<code bash>
mkdir -P ~/home/Projects && cd ~/home/Projects
git clone git://github.com/mavlink/mavlink.git -b pymavlink_merge
cd mavlink
mkdir -P build-mingw
cd build-mingw && cmake-mingw ..
</code>

=== Create a windows installer ===

This step will create a nullsoft installer that you can use to install mavlink on your system.

<code bash>
cd ~/src/Projects/mavlink/build-mingw && cpack
</code>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants