1. Dependencies in C++
using std::cpp oct-2014
@diegorlosada
Why there is no SerialPort in C/C++?
2. I just wanted a SerialPort!
$ pip install pyserial
>>> import serial
>>> ser = serial.Serial(0)
>>> print ser.name
>>> ser.write("hello")
>>> ser.close()
3. Serial Port in MRPT
>5K files, 70 Mb
First class robotics SW.
CSerializable, CObject…
5. DONT MAKE ME USE YOUR DESIGN
•Let me use your functionality without using your design
–Functionality, core value should be independent, easily isolated:
•Easily testable, mockable
•Easily understandable
•Easily reusable
SerialPort
CStream<SerialPort>
Cserializable<T>
Matrix
Algorithm
MyApp
CStream<T>
12. THE PROBLEM: NO DEP MANAGER
•That wouldnt happen with a dep manager:
–Install and manage deps per project
–Portable: the same in all plaforms
–Simple and fast to upload/share
15. •OS based (package managers)
–Apt-get, brew, MSI, vagrant
•Dev system based
–make, nuget, cmake
DEP TOOLS FOR C/C++
16. Advanced Packaging Tool, or APT, is a free user interface that works with core libraries to handle the installation and removal of software
•Install:
–Applications
–Libraries –dev
–Debug –dbg
•apt-get install opencv-dev
APT
20. Apt-get pros & cons
•Pros
–Mature
–Transitive dependencies, conflict detection
–GUIs
•Cons
–Linux only
–Difficult to publish to debian/ubuntu repos, certain policies to be followed. Being part of such organizations non trivial.
–Possible to run an apt repo (add to /etc/apt/sources.list) with reprepro, but manage infraestructure
–May be slow (e.g. Ubuntu 12.04LTS cmake 2.8.7)
APT Pros & Cons
21. MAC
•Handles all above problems with one command. For OS X:
–MacPorts
–Fink
–Homebrew
–pkgsrc: binary packages for Mac OS X (more info)
–etc.
•In general, they:
–take a single command as input, defining which package is to be installed
–download source code (Fink downloads a pre-built application)
–figures out dependencies
–download missing dependencies
–builds and install dependencies
–builds and install the requested package
–Usage example: brew install imagemagick
MAC OS
22. category
Rudix
MacPorts
Fink
Homebrew
pkgsrc / pkgin Homepage rudix.org MacPorts.org fink.thetis.ig42.org brew.sh pkgsrc.org andpkgin.net Year project started 2005 2002 2001 2009 Support for Darwin in 2001
Number of packages
488 (but `rudix available | wc - l` says 351)
17,680 (but `port list | wc -l` says 17,686)
7,951. `apt- cache search . | wc -l` says 209 stable binary .deps)
2,498. `brew search | wc -l` says 2,591. This is not counting various extra "taps"
8,884 binaries for OS X (according to `pkgin available | wc -l`) Source/binary/ both? Binary only Traditionally only source Option for both Source, but also binaries through "bottles" Both.
Language written in
Python
Tcl
Perl (front- end)
Ruby
C License BSD BSD GPL :( BSD BSD Default prefix Directly to /usr/local /opt/local /sw /usr/local/Cellar. Programs symlink to /usr/local/bin /usr/pkg Lastest GCC available Not available 4.8.1 4.8 4.9 No binary available but pkgsrc has 4.8 Installation of packages Extremely easy Slow, since it builds from source The source builds are understandably slow, but the binaries are quick Source compilation is obviously slow. I've had some linking issues sometimes. Trivially easy
Uninstallation of packages
Easy and painless
Easy
Easy and fast
Very easy
Trivially easy
MAC PKG MANAGERS
23. •macports
oPortfile (tcl script)
oEl código puede estar en un CVS
oTe tienen que aprobar el nuevo port (proceso manual)
obrew
oen el cual es necesario que tus paquetes sean open source para ser aceptados, pero es un proceso relativamente rápido tener una biblioteca en brew.
SHARING PACKAGES
24. msi: Windows Installer, software component used for the installation, maintenance, and removal of software on modern Microsoft Windows systems
Build a msi package with Visual Studio
Video: https://www.youtube.com/watch?v=HpiZ_o5EgCo
WINDOWS: MSI
25. •Support for every Windows release since 2000
•Extensive support for installation of 64-bit applications
•Supports creation of a single EXE to install your program for easy online distribution.
•Standard Windows 2000/XP-style wizard interface.
•Customizable setup types.
•Complete uninstall capabilities.
•Installation of files
•Includes integrated support for "deflate", bzip2, and 7-Zip LZMA/LZMA2 file compression.
•Creation of shortcuts anywhere, including in the Start Menu and on the desktop.
•Creation of registry and .INI entries.
•Support for passworded and encrypted installs.
•Support for digitally signed installs and uninstalls.
•Unicode installs.
•Full source code is available (Borland Delphi 2.0-5.0 and 2009).
; -- Example.iss --
; Creates its icon in the Programs folder of the start Menu instead of in a subfolder, and also creates a desktop icon.
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}My Program
; Since no icons will be created in "{group}", we don't need the wizard to ask for a Start Menu folder name:
DisableProgramGroupPage=yes
UninstallDisplayIcon={app}MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
[Icons]
Name: "{commonprograms}My Program"; Filename: "{app}MyProg.exe"
Name: "{commondesktop}My Program"; Filename: "{app}MyProg.exe"
INNO SETUP
26. If we run the *.iss with Inno, a SetUp Wizard is opened and
INNO SETUP
27. chocolatey
•Motor global de ejecución de PowerShell utilizando la infraestructura de empaquetado NuGet.
•Como apt-get, pero construido para Windows . PowerShell. Se puede desarrollar herramientas y aplicaciones con NuGet y liberarlos con Chocolatey.
$> cist vim
$> cup all
A la hora de subir tus paquetes:
•Fácil de usar con aplicación sin dependencias.
•Ficheros de configuración muy extensos y complejos cuando se tienen dependencias de otros paquetes.
CHOCOLATEY
29. PROVISIONERS: bash, puppet, chef, docker...
Empty VM
$ mkdir vm_dev
$ VAGRANT INIT
DEV VM
$ VAGRANT UP
$ VAGRANT DESTROY
Make based
CONTAINERS AND VIRTUALIZATION
30. •OS based (package managers)
–Apt-get, brew, MSI, vagrant
•Dev system based
–make, nuget, cmake
DEP TOOLS FOR C/C++
31. Make based
myapp: ${SRC_CPP} ${LIB_DIR}other_team.lib ... ${LIB_DIR}other_team.lib: /shared_folder/latest/other_team.lib
cp /shared_folder/latest/other_team.lib ${LIB_DIR}other_team.lib
MAKE BASED
32. •git submodule
–git submodule add git://github.com/chneukirchen/rack.git rack
•git subtree
–git subtree add --prefix .vim/bundle/tpope-vim- surround https://bitbucket.org/vim-plugins- mirror/vim-surround.git master --squash
•As usual, with all things git, there is a learning curve to make the most of the feature.
•The user responsible for commits to subprojects
•Contributing back might be complex
GIT Based
36. find_package(FOO): no download packages, only find “my_lib” library in your system if exists.
It would need a file named foo-config.cmake to set all the variables where the files are saved (include and lib folder)
CMAKE and FindPackage