mulle-bootstrap: Understanding mulle-bootstrap (I)
Explains the workings for the most simplistic scenario: build a single dependency in Release configuration using cmake. (This text describes the workings of mulle-bootstrap 1.0)
You have a project bar where you just happen to need foo, a sophisticated library written by yours truly. foo does one thing and one thing only: it knows its version number.
So this is your code:
main.c
#include <stdio.h>
#include <foo.h>
main()
{
printf( "%d\n", foo_version);
}
How do you get foo ? With mulle-bootstrap of course. It will provide the header in dependencies/include/foo
and the library in dependencies/lib
, so you build your code with:
cc -c -Idependencies/include main.c
cc -o bar -Ldependencies/lib main.o -lfoo
But first you need to bootstrap…
Using mulle-bootstrap
mulle-bootstrap init
mulle-bootstrap init
will create a folder .bootstrap
and a file within it named repositories
. You edit repositories
to contain the URL of foo, which is https://github.com/mulle-nat/foo.git
.
mulle-bootstrap init
# ".bootstrap folder has been set up.
# Now add your repositories to ".bootstrap/repositories
# Edit the repositories file now ? (y/N) > n
echo "https://github.com/mulle-nat/foo.git" > .bootstrap/repositories
mulle-bootstrap fetch
mulle-bootstrap fetch
will now clone foo from Github into a folder called .repos
.
mulle-bootstrap fetch
# Cloning https://github.com/mulle-nat/foo.git ...
# Cloning into '.repos/foo'...
# remote: Counting objects: 12, done.
# remote: Compressing objects: 100% (8/8), done.
# remote: Total 12 (delta 1), reused 8 (delta 1), pack-reused 0
# Unpacking objects: 100% (12/12), done.
# Checking connectivity... done.
mulle-bootstrap build
mulle-boostrap build
is actually a three step process of
-
cmake/make<p> mulle-bootstrap will create a build folder to hold the compiler and linker output in
build
. The default configuration isRelease
so the destination folder isbuild/foo/Release
. -
make install<p> Instead of installing into
/usr/local
make install
is directed to install intodependencies/tmp
-
collect and dispense<p> In a final pass, the files in
dependencies/tmp
are collected and dispensed into a standardized directory structure independencies
.
mulle-bootstrap build
# Let cmake do a Release build of foo for SDK Default in "build/.repos/Release/foo" ...
# CMake Warning:
# Manually-specified variables were not used by the project:
#
# DEPENDENCIES_DIR
#
#
# Write-protecting dependencies to avoid spurious header edits
What is the collect and dispense pass good for ?
Let’s say you don’t want to “pollute” your root include files with foo.h
, but would prefer your code to look like this:
main.c
#include <stdio.h>
#include <foo/foo.h>
main()
{
printf( "%d\n", foo_version);
}
For that you do the following (mulle-bootstrap 2.0):
mkdir -p .bootstrap/foo
echo "/include/foo" > .bootstrap/foo/dispense_headers_path
mulle-bootstrap build
Then the dependencies
contents will look like this:
Understanding mulle-bootstrap clean
The following “big” picture should help to understand, what gets thrown away
when running mulle-bootstrap clean
:
Post a comment
All comments are held for moderation; basic HTML formatting accepted.