1

I've got a program which is split into some files located in two main folders, src and include, with the header .h files in the include folder while .cpp and .cu files in the other. Here is a little drawing for the whole routine

enter image description here

Note#1 this is not exactly what I want to achieve but it may be a starting point.

Note#2 here you can find the meaning of the word routine, but here I mean just a complex application split into multiple files.

Is there a standard way to represent the tree of the files which a program is composed of? I mean the file tree, along with the folders tree. I'm looking for some solution to even add some of the relations within the files with some arrows. I'd like to use tikz if possible.

Right now this is my poor, far-to-be-optimized tikz img I realized

\documentclass[]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\usetikzlibrary{calc}
\tikzset{
    %Define standard arrow tip
    >=stealth',
    pil/.style={
           ->,
           thick,
           shorten <=2pt,
           shorten >=2pt,},
    gpufile/.style={
            rectangle,
            rounded corners,
            draw=red, very thick,
            minimum height=2em,
            minimum width=8em,
            text centered
            },
    cpufile/.style={
            rectangle,
            rounded corners,
            draw=black, thick,
            minimum height=2em,
            text centered
            },
    header/.style={
            rectangle,
            draw=gray, thin,
            minimum height=2em,
            minimum width=5em,
            text centered
            },
    folder/.style={
            rectangle,
            draw=yellow, thin,
            minimum height=3em,
            minimum width=5em,
            text centered
            }
}

\begin{document}
\begin{tikzpicture}[node distance=1.5cm, auto,]
\tikzstyle{every path}=[-latex,thick]
\node[
        folder,
        xshift=-2cm] (src) {src};
\node[
        cpufile, 
        right of=src,
        xshift=40pt] (main) {\texttt{main.cpp}};
\node[
        gpufile, 
        right of=main,
        xshift=40pt,
        yshift=0pt] (trbdf2) {\texttt{tr-bdf2.cu}}
    ;
\node[
        gpufile,
        right of=trbdf2,
        xshift=40pt,
        yshift=0cm
        ] (jacobian) {\texttt{jacobian.cu}};
\node[  
        gpufile,
        right of=jacobian,
        xshift=60pt
        ] (inversion) {\texttt{matrix\_inversion.cu}};
\node[
        gpufile,
        right of=inversion,
        xshift=60pt] (tr) {\texttt{newton\char`_tr.cu}};
\node[
        gpufile,
        right of=tr,
        xshift=60pt] (bdf2) {\texttt{newton\char`_bdf2.cu}};
\node[
        folder,
        below of=src,
        yshift=-1cm] (include) {include};
\node[
        header,
        right of=include,
        xshift=40pt] (libs) {\texttt{libs.h}};
\node[
        header,
        right of=libs,
        xshift=40pt] (constants) {\texttt{constants.h}};
\node[
        header,
        right of=constants,
        xshift=40pt] (fdefs) {\texttt{functions\char`_defs.h}};
\node[
        header,
        right of=fdefs,
        xshift=40pt] (defs) {\texttt{defs.h}};
\node[
        header,
        right of=defs,
        xshift=40pt] (linsolver) {\texttt{linear\char`_solver.h}};
;
\end{tikzpicture}
\end{document}

enter image description here

I need to highlight .cu files in the project, they have a different meaning from the clasic .cpp files.

While sliding through the tikz library samples the closest I found to what I mean is this example, which is recommended just for a filesystem directory tree though.

Please correct the tags if necessary, I'm not experienced yet in tags for this site.

  • 1
    Your code is not compileable at this moment. I added the missing code ans a picture of the output. – Dr. Manuel Kuehner Feb 11 '17 at 9:01
  • Thank you @Dr. Manuel Kuehner, I updated the picture as well – Eugenio Feb 11 '17 at 9:18
  • Your question is not clear to me. What do you mean by a coding routine which is composed of folders? These concepts don't really fit well together for me. Maybe you can give an example to show what you want to acchieve (maybe draw it quickly by hand)? – pschulz Feb 11 '17 at 9:21
  • @pschulz Done! Not exactly what I want to achieve but I hope it explains – Eugenio Feb 11 '17 at 9:33
  • I'm sorry, i still don't understand what you want to acchieve. For me, a routine is something you do. Now, in this context the term folders makes no sense. Language aside, i still don't get it. Here's my guess: you want to show the process how the program is build (using make). During this, you want to highlight the current used (and included) files. If this is the case, i would use a different approach. Drop the notion of two different folders, just show that files are included. But then, i don't know what a standard representation would be, and i feel that there is none. – pschulz Feb 11 '17 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.