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:

A C program which uses a ridiculously simple math library
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'
a file named "Dependencies" with:
[ Weyland::package('math', repository: 'deps/math') ]
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;
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]
a file named "deps/math/include/math/add.h" with:
int add(int a, int b);
a file named "deps/math/src/add.c" with:
#include "math/add.h"

int add(int a, int b) {
	return a + b;
I run weyland
the exit status should be 0
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 about 6 years ago by smkell.