Targets

The define_target block specifies a buildable target, along with what it provides, it's dependencies, and how to build it.

define_target 'my-project-library' do |target|
	target.build do
		source_root = target.package.path + 'source'
		copy headers: source_root.glob('MyProject/**/*.{h,hpp}')
		build static_library: 'MyProject', source_files: source_root.glob('MyProject/**/*.cpp')
	end
	
	target.depends 'Build/Files'
	target.depends 'Build/Clang'
	
	target.depends :platform
	target.depends 'Language/C++14', private: true
	
	target.provides 'Library/MyProject' do
		append linkflags [
			->{install_prefix + 'lib/libMyProject.a'},
		]
	end
end

target.build generates a dependency graph by executing Ruby code. The specific functions are provided by other packages.

target.depends are used to specify what things are needed in the environment in order to successfully build the target.

target.provides indicates the things that this target can provide. Multiple packages can provide the same thing, in which case they may need a priority or manual disambiguation.

Build Environments

Build environments are fundamental to how teapot builds source code. An environment encapsulates all build rules, variables, and associated meta-data.

A simple example would be variants, a package which configures the build environment for different kinds of builds, e.g. debug, release.

A more complex example would be unit-test which provides custom rules for compiling and running unit tests.

Every aspect of the teapot build process is exposed as a package.

Generators

Generators are semantically unique targets in that they create and update files in your project directly.

define_target "generate-travis" do |target|
	target.description = <<-EOF
		Generates a `.travis.yml` file suitable for executing tests.
	EOF
	
	target.depends "Generate/Template"
	target.provides "Generate/Travis"
	
	target.build do
		source_path = Build::Files::Directory.new(target.package.path + "templates/travis")
		
		substitutions = target.context.substitutions
		
		generate source: source_path, prefix: target.context.root, substitutions: substitutions
	end
end

Generators use the merge algorithms from build-text to conveniently create class files, unit tests, etc.