Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

add nodes

here we assume that we already have structs that implements M::Node, in our example we have 3 implementations :

  • CFile for .c files
  • HFile for .h files
  • OFile for object files
  • XFile for executable files

see section …

in our example, for the demo add the nodes manually.

#![allow(unused)]
fn main() {
    let main_c = g.add_root_node(CFile::new("project_C/main.c")).unwrap();
    let main_o = g
        .add_node(OFile::new("project_C/main.o", vec![], vec![]))
        .unwrap();
    let add_c = g.add_root_node(CFile::new("project_C/add.c")).unwrap();
    let add_o = g
        .add_node(OFile::new(
            "project_C/add.o",
            vec![],
            vec!["-DYYY_defined".to_string()],
        ))
        .unwrap();
    let _add_h = g.add_root_node(HFile::new("project_C/add.h")).unwrap();
    let _wrapper_h = g.add_root_node(HFile::new("project_C/wrapper.h")).unwrap();
    let project_a = g.add_node(AFile::new("project_C/libproject.a")).unwrap();
    let app = g.add_node(XFile::new("project_C/app")).unwrap();
}

in a real project

in a real project, you might want to :

  • scan the srcdir to find the .c and .h files (what you do manually in a Makefile )
  • for each .c, create a .o node ( the implicit rule of a Makefile )
  • as in an real Makefile, you would need to explicit which objects and libraries you need to build, with their sources

use the sandbox

here for instance, use the sandbox as the search path for the header ( the -I ) option of compilation. Always refer to paths in the sandbox and not in the srcdir, because when using built artefacts it will fail when using the srcdir

Caution

everything, except the mount, happens in the sandbox. All paths are relative, and understood from the sandbox.


paths are unique

Caution

paths are unique : two nodes cannot have the same path, that would yield an error