Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions doxygen/doxygen.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ def _swift_doxygen_impl(ctx):
# this performs a CMake-like replacement of @VAR@ based on the vars dict
config = configure_file_impl(ctx, vars, ctx.attr.name + "_Doxyfile")[0].files.to_list()[0]

# Create a processed config file for sed operations
processed_config = ctx.actions.declare_file(ctx.attr.name + "_processed_Doxyfile")

# First action: Create the processed config file and apply sed replacements
ctx.actions.run_shell(
inputs = [config] + ctx.files.deps,
outputs = [doxygen_out],
inputs = [config],
outputs = [processed_config],
env = vars,
command = """
DOXYGEN_DOT_FOUND=NO
Expand All @@ -36,18 +40,26 @@ def _swift_doxygen_impl(ctx):

PRW=`pwd`

# backward compatibility with old CMake-style doxygen config files
sed -i "s|@DOXYGEN_DOT_FOUND@|$DOXYGEN_DOT_FOUND|g" {config}
sed -i "s|@DOXYGEN_DOT_PATH@|$DOXYGEN_DOT_PATH|g" {config}
sed -i "s|@PLANTUML_JAR_PATH@|/usr/local/bin/plantuml.jar|g" {config}
sed -i "s|@INPUT_DIR@|$PROJECT_SOURCE_DIR|g" {config}
sed -i "s|@PROJECT_NAME@|$PROJECT_NAME|g" {config}
sed -i "s|@STABLE_GIT_TAG@|$STABLE_GIT_TAG|g" {config}
sed -i "s|@DOXYGEN_EXCLUDE@|$DOXYGEN_EXCLUDE|g" {config}
sed -i "s|@PROJECT_SOURCE_DIR@|$PRW|g" {config}
# Apply backward compatibility sed replacements
sed "s|@DOXYGEN_DOT_FOUND@|$DOXYGEN_DOT_FOUND|g" {original_config} | \
sed "s|@DOXYGEN_DOT_PATH@|$DOXYGEN_DOT_PATH|g" | \
sed "s|@PLANTUML_JAR_PATH@|/usr/local/bin/plantuml.jar|g" | \
sed "s|@INPUT_DIR@|$PROJECT_SOURCE_DIR|g" | \
sed "s|@PROJECT_NAME@|$PROJECT_NAME|g" | \
sed "s|@STABLE_GIT_TAG@|$STABLE_GIT_TAG|g" | \
sed "s|@DOXYGEN_EXCLUDE@|$DOXYGEN_EXCLUDE|g" | \
sed "s|@PROJECT_SOURCE_DIR@|$PRW|g" > {processed_config}
""".format(original_config = config.path, processed_config = processed_config.path),
)

# Second action: Run doxygen with the processed config
ctx.actions.run_shell(
inputs = [processed_config] + ctx.files.deps,
outputs = [doxygen_out],
env = vars,
command = """
PATH=$PATH doxygen {config}
""".format(config = config.path),
""".format(config = processed_config.path),
)

return [DefaultInfo(files = depset([doxygen_out, config]))]
Expand Down
Loading