Skip to content

variable_substitution

Samantha Marshall edited this page Jul 11, 2016 · 2 revisions

Variable Substitution

The pyconfig language was written with variable subsitution as a first-class feature. By default it will assume you are going to be using different build configurations to denote differences in expected settings.

Example:

setting OTHER_LDFLAGS {
	for Debug {
		-lz,
		-framework "Reveal"
	}
	for Release
}

Will generate the following assignments:

OTHER_LDFLAGS_Debug = -lz -framework "Reveal"
OTHER_LDFLAGS_Release = 
OTHER_LDFLAGS = $(OTHER_LDFLAGS_$(CONFIGURATION))

Since this is a powerful way to conditionally supply specific values to the build system you can extend the substitution behavior by supplying your own variable to subtitute using the use keyword.

setting PRODUCT_NAME use WRAPPER_EXTENSION {
	for app {
		"My App"
	}
	for xctest {
		"Unit Test Bundle"
	}
	for bundle {
		"Generic Bundle"
	}
}

This will cause pyconfig to generate the following variables in the .xcconfig file:

PRODUCT_NAME_app = "My App"
PRODUCT_NAME_xctest = "Unit Test Bundle"
PRODUCT_NAME_bundle = "Generic Bundle"
PRODUCT_NAME = $(PRODUCT_NAME_$(WRAPPER_EXTENSION))

Clone this wiki locally