Skip to content

More flexible create module.py

This is a continuation of https://codereview.appspot.com/343030043/

Consider a project in contrib which wants this structure pulled from a single repo:

contrib/
    wscript
    project/
        .repo            // could be .git or .hg, for example
        main/
            wscript      // builds executable 'project' from main.cc and other.cc
            main.cc
            other.cc
        modules/
            moduleA/     // Contains normal module structure
              wscript
              model/
              ...
            moduleB/     // Contains normal module structure
        data/            // No source code here, so no wscript

One can't do this at the moment for two reasons:

  • contrib/wscript won't recognize the project directory because the top level does not contain a wscript file

  • Each "normal" module directory has to be created by hand, or created in src, then moved to its final location.

This patch provides two enhancements to enable this kind of project:

  1. Enable the create-module.py script to create modules in the contrib directory, as well as the src directory.

  2. Enable modules in the contrib directory to have arbitrary structure.

To accomplish these goals the patch modifies a couple of heuristics:

  • create-module.py accepts arbitrary paths, using the last path element as the name of the module.

  • contrib/wscript walks the directory tree, looking for directories containing wscript files. When found, add that directory to the list of contrib modules to process. It is not an error for a tree under contrib not to contain any wscript files; this tree is simply ignored. (The data directory above is an example.)

Since create-module.py is more general, this patch moves it to the utils directory.

Merge request reports