Integrating Ragel 5 with Xcode 2

Using a single custom build rule for C, C++, Objective-C and Objective-C++

By naming your source files as you intend the output to be, then appending rather than replacing the extension with '.rl', Xcode can use the following single build rule to process '.rl' files targeting C, C++, Objective-C, and Objective-C++.

Screenshot of configured build rule

Build Rule Settings

Source files with names matching:

*.c.rl *.cpp.rl *.cp.rl *.cxx.rl *.m.rl *.mm.rl

This script uses an intermediate file with the extension '.ragel', this same file is processed by 'rlcodegen' to generate the source code and '.dot' graph.

Custom script:

RAGEL=/opt/local/bin/ragel
RLCODEGEN=/opt/local/bin/rlcodegen
${RAGEL} -o ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.ragel ${INPUT_FILE_PATH} || exit
${RLCODEGEN} -G2 -C -o ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE} ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.ragel || exit
${RLCODEGEN} -V ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.ragel > ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.dot

Output files:

$(DERIVED_FILES_DIR)/$(INPUT_FILE_BASE)
$(DERIVED_FILES_DIR)/$(INPUT_FILE_BASE).dot

Links

In case you want to download the latest: