Oliver Sauder
Oliver Sauder

Reputation: 1154

How to install a directory recursively with waf

I currently use following valadoc build task to generate a api documentation for my vala application:

doc = bld.new_task_gen (
  features = 'valadoc',
  output_dir = '../doc/html',
  package_name = bld.env['PACKAGE_NAME'],
  package_version = bld.env['VERSION'],
  packages = 'gtk+-3.0 gee-1.0 libxml-2.0 x11 gdk-x11-3.0 libpeas-gtk-1.0 libpeas-1.0 config xtst gdk-3.0',
  vapi_dirs = '../vapi',
  force = True)

path = bld.path.find_dir ('../src')
doc.files = path.ant_glob (incl='**/*.vala')

This tasks creates a directory html in the output directory including several subdirectories with html and picture files.

What I am know trying to do is to install such files to /usr/share/doc/projectname/html/. To do so I added the following to the wscript_build file (following the documentation I have found here):

output_dir = doc.bld.path.find_or_declare('../doc/html')
doc.outputs = output_dir.ant_glob (incl='**/*')
doc.bld.install_files('${PREFIX}/share/doc/projectname/html', doc.outputs)

However this leads to an error "Missing node signature". Does anyone know how to get around this error? Or is there a simple way to install a directory recursively with waf?

You can find a full-fledge sample here.

Upvotes: 3

Views: 1992

Answers (2)

Damascus Steel
Damascus Steel

Reputation: 323

There is an easier way using relative_trick.

bld.install_files(destination,
                  bld.path.ant_glob('../doc/html/**'),
                  cwd=bld.path.find_dir('../doc/html'),
                  relative_trick=True)

This gets a list of files from the glob, chops off the prefix, and puts it into the destination.

Upvotes: 0

Josh
Josh

Reputation: 46

I had a similar issue with generated files and had to update the signature for the corresponding Node objects. Try creating a task:

def signature_task(task):
    for x in task.generator.bld.path.find_dir('../doc/html').ant_glob('**/*', remove=False): 
        x.sig = Utils.h_file(x.abspath())

To the top of you build rule, try adding:

#Support running task groups serially
bld.post_mode = Build.POST_LAZY

Then at the end of your build, add:

#Previous tasks belong to a group
bld.add_group()
#This task runs last
bld(rule=signature_task, always=True, name="signature_task")

Upvotes: 3

Related Questions