Logo: Relish

  1. Sign in

Project: Weyland 0.1.0

Defining external dependencies

We've seen how a task can define dependencies on other tasks within its
parent package, but how do we define tasks on external packages?

The notation for a full package reference to a task is
{package name}:{task name}. So for a task to define a dependency on a
task in a package other than its own it simple adds the key:
depends_on: '{package:name}:{task name}' to its definition.

Weyland locates external packages using a file named, by convention,
Dependencies. This file, like a Weylandfile is a ruby file which
is evaluated by Weyland. The return value of this file should be an
array of packages. These package objects should contain a name, and
optionally a version, and URL in order to resolve the external
package's build file.

Here's some examples:

Scenarios
A C program which uses a ridiculously simple math library
Given
a file named "Weylandfile" with:
require 'weyland/c'

Weyland::package('simple_with_deps') do |pkg|
	pkg.c_program 'simple_add', sources: ['src/main.c'], depends_on: 'math:adder'
end
And
a file named "Dependencies" with:
[ Weyland::package('math', repository: 'deps/math') ]
And
a file named "src/main.c" with:
#include <stdio.h>
#include "math/add.h"

int main(int argc, char** argv) {
	printf("%d\n", add(1, 2));
	return 0;
}
And
a file named "deps/math/Weylandfile" with:
require 'weyland/c'

Weyland::package('math', '1.0.0') do |pkg|
	pkg.c_staticlib 'adder', sources: ['src/add.c'], include_dirs: ['include'], exports: [:include_dirs]
end
And
a file named "deps/math/include/math/add.h" with:
int add(int a, int b);
And
a file named "deps/math/src/add.c" with:
#include "math/add.h"

int add(int a, int b) {
	return a + b;
}
When
I run weyland
Then
the exit status should be 0
And
the output should contain:
Building package simple_with_deps#any...
TASK       simple_with_deps:simple_add
TASK       math:adder
CC         build/math/obj/adder/src/add.o
LINK       build/math/lib/libadder.a
CC         build/simple_with_deps/obj/simple_add/src/main.o
LINK       build/simple_with_deps/bin/simple_add

Last published over 5 years ago by smkell.