QBS build system: Complex artifact transformation

30 Views Asked by At

How would be possible to:

  1. Compile a .c file resulting an .o object file;
  2. Apply a command like xxd (hex dump) over the generated object file resulting a .h header file;
  3. Use that generated header in a C/C++ library.
1

There are 1 best solutions below

1
On

Possibly the circularity can be broken by having the object file as the target artifact of a dedicated project, e.g. something like this (sketch, untested):

Project {
    Product {
        name: "dep"
        type: "obj"
        Depends { name: "cpp" }
        files: "myfile.c"
    }
    Product {
        Depends { name: "dep" }
        Depends { name: "cpp" }
        cpp.includePaths: product.buildDirectory // So the generated header will be found
        Rule {
            inputsFromDependencies: "obj"
            Artifact { filePath: "theHeader.h"; fileTags: "hpp" }
            prepare: {
                var cmd = new Command("xxd", [input.filePath, output.filePath]);
                cmd.description = "generating " + output.fileName;
                return cmd;
            } 
        }            
    }
}