Scons-Wiki: Adding tagfile to targets and html templates to sources (Boehme)

Robert Lupton noted that you have to change the source paths if you keep your Doxyfile in a subdirectory and use relative paths.
I found that I had to do the same for the target path in the Doxyfile. (see after line 160)

The following code adds the tagfile to the target list. I added it in line 166:

   # add the tag file if neccessary:
   tagfile = data.get("GENERATE_TAGFILE", "")
   if tagfile != "":
      if not os.path.isabs(tagfile):
         conf_dir = os.path.dirname(str(source[0]))
         tagfile = os.path.join(conf_dir, tagfile)
      targets.append(env.File(tagfile));

To add the html templates from the Doxyfile to the list of sources,
you need to apply Robert Lupton's change and add the following snippet in line 137:

   # Add additional files to the list ouf source files:
   def append_additional_source(option):
      file = data.get(option, "")
      if file != "":
         if not os.path.isabs(file):
            file = os.path.join(conf_dir, file)
         if os.path.isfile(file):
            sources.append(file)

   append_additional_source("HTML_STYLESHEET")
   append_additional_source("HTML_HEADER")
   append_additional_source("HTML_FOOTER")

You can easily add dependencies on other output file templates by adding additional calls to append_additional_source().

__Addendum 18 July 2007__: I added some code to add tagfiles to the list of sources.
Since the tagfiles-option allows for equal-signs in the value, I had to change the parsing code a bit.
The code now also includes the other changes I proposed.
This commit is contained in:
Christoph Boehme 2007-07-18 00:00:00 +02:00 committed by Ichthyostega
commit ad3e94a567

View file

@ -63,7 +63,11 @@ def DoxyfileParse(file_contents):
if not data.has_key(key):
data[key] = list()
elif token == "=":
data[key] = list()
if key == "TAGFILES" and data.has_key(key):
append_data( data, key, False, "=" )
new_data=False
else:
data[key] = list()
else:
append_data( data, key, new_data, token )
new_data = True
@ -81,7 +85,7 @@ def DoxyfileParse(file_contents):
data.pop(k)
# items in the following list will be kept as lists and not converted to strings
if k in ["INPUT", "FILE_PATTERNS", "EXCLUDE_PATTERNS"]:
if k in ["INPUT", "FILE_PATTERNS", "EXCLUDE_PATTERNS", "TAGFILES"]:
continue
if len(v) == 1:
@ -117,7 +121,15 @@ def DoxySourceScan(node, env, path):
file_patterns = data.get("FILE_PATTERNS", default_file_patterns)
exclude_patterns = data.get("EXCLUDE_PATTERNS", default_exclude_patterns)
# We're running in the top-level directory, but the doxygen
# configuration file is in the same directory as node; this means
# that relative pathnames in node must be adjusted before they can
# go onto the sources list
conf_dir = os.path.dirname(str(node))
for node in data.get("INPUT", []):
if not os.path.isabs(node):
node = os.path.join(conf_dir, node)
if os.path.isfile(node):
sources.append(node)
elif os.path.isdir(node):
@ -135,6 +147,26 @@ def DoxySourceScan(node, env, path):
for pattern in file_patterns:
sources.extend(glob.glob("/".join([node, pattern])))
# Add tagfiles to the list of source files:
for node in data.get("TAGFILES", []):
file = node.split("=")[0]
if not os.path.isabs(file):
file = os.path.join(conf_dir, file)
sources.append(file)
# Add additional files to the list of source files:
def append_additional_source(option):
file = data.get(option, "")
if file != "":
if not os.path.isabs(file):
file = os.path.join(conf_dir, file)
if os.path.isfile(file):
sources.append(file)
append_additional_source("HTML_STYLESHEET")
append_additional_source("HTML_HEADER")
append_additional_source("HTML_FOOTER")
sources = map( lambda path: env.File(path), sources )
return sources
@ -158,12 +190,23 @@ def DoxyEmitter(source, target, env):
targets = []
out_dir = data.get("OUTPUT_DIRECTORY", ".")
if not os.path.isabs(out_dir):
conf_dir = os.path.dirname(str(source[0]))
out_dir = os.path.join(conf_dir, out_dir)
# add our output locations
for (k, v) in output_formats.items():
if data.get("GENERATE_" + k, v[0]) == "YES":
targets.append(env.Dir( os.path.join(out_dir, data.get(k + "_OUTPUT", v[1]))) )
# add the tag file if neccessary:
tagfile = data.get("GENERATE_TAGFILE", "")
if tagfile != "":
if not os.path.isabs(tagfile):
conf_dir = os.path.dirname(str(source[0]))
tagfile = os.path.join(conf_dir, tagfile)
targets.append(env.File(tagfile))
# don't clobber targets
for node in targets:
env.Precious(node)
@ -185,13 +228,12 @@ def generate(env):
scan_check = DoxySourceScanCheck,
)
doxyfile_builder = env.Builder(
action = env.Action("cd ${SOURCE.dir} && ${DOXYGEN} ${SOURCE.file}"),
import SCons.Builder
doxyfile_builder = SCons.Builder.Builder(
action = "cd ${SOURCE.dir} && ${DOXYGEN} ${SOURCE.file}",
emitter = DoxyEmitter,
target_factory = env.fs.Entry,
single_source = True,
source_scanner = doxyfile_scanner,
)