Logo: Relish

  1. Sign in

Project: Weyland 0.1.0

Build package definition

In Weyland, a Package is a group of tasks which are executed to produce one
or more results. In Weyland tasks cannot exist outside of a Package; though
as we will see later, they can be defined externally and then imported into
a Package for reusability.

When Weyland is invoked it is done so in the context of a single root package,
however tasks within that root package can freely depend on tasks from any
number of external packages.

Packages are defined in a file named, by convention, Weylandfile.
Weylandfiles are Ruby files, so you can execute any arbitrary logic you need
in order to manipulate and define tasks.

Weylandfiles are parsed, and executed by the Weyland command. It should be
noted that the Weylandfile must return a Weyland object in order for the
build to be executed. This means that if your Weylandfile contains any logic
other than iniitalizing a package it must explicitly return the package
object that should be used as the root of the build.

Scenarios
A simple Weylandfile with no tasks
Given
a file named "Weylandfile" with:
Weyland::package("simple")
When
I run weyland
Then
the exit status should be 0
And
the output should contain:
Building package simple#any...
A simple Weylandfile with a versioned package
Given
a file named "Weylandfile" with:
Weyland::package("simple", "0.1.0")
When
I run weyland
Then
the exit status should be 0
And
the output should contain:
Building package simple#0.1.0...
A Weylandfile which explicitly returns a package
Given
a file named "Weylandfile" with:
pkg = Weyland::package("simple", "0.1.0")
puts "1 + 2 = #{1 + 2}"
pkg
When
I run weyland
Then
the exit status should be 0
And
the output should contain:
1 + 2 = 3
And
the output should contain:
Building package simple#0.1.0...
A simple Weylandfile with a task to build a c program
Given
a file named "Weylandfile" with:
require 'weyland/c'

Weyland::package("simple") do |pkg|
	pkg.c_program "example_prog", sources: ["src/main.c"]
end 
And
a file named "src/main.c" with:
#include <stdio.h>

int main(int argc, char** argv) {
	printf("Hello, from Weyland!");
	return 0;
}
When
I run weyland
Then
the exit status should be 0
And
the output should contain:
TASK       simple:example_prog
CC         build/simple/obj/example_prog/src/main.o
LINK       build/simple/bin/example_prog
And
a file named "build/simple/obj/example_prog/src/main.o" should exist
And
a file matching %r<build/simple/bin/example_prog(.exe)?> should exist

Last published over 5 years ago by smkell.