Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Clean some files and target
[simgrid.git] / buildtools / Cmake / GenerateUserGuide.cmake
1 #### Generate the html documentation for the user guide.
2
3 file(GLOB_RECURSE source_doxygen
4         "${CMAKE_HOME_DIRECTORY}/tools/gras/*.[chl]"
5         "${CMAKE_HOME_DIRECTORY}/src/*.[chl]"
6         "${CMAKE_HOME_DIRECTORY}/include/*.[chl]"
7 )
8
9 if(FIG2DEV_PATH)
10         set(DOC_PNGS 
11                 ${CMAKE_HOME_DIRECTORY}/doc/webcruft/simgrid_logo_2011.png
12                 ${CMAKE_HOME_DIRECTORY}/doc/webcruft/simgrid_logo_2011_small.png                
13                 ${CMAKE_HOME_DIRECTORY}/doc/webcruft/poster_thumbnail.png
14                 ${CMAKE_HOME_DIRECTORY}/doc/webcruft/win_install_01.png
15                 ${CMAKE_HOME_DIRECTORY}/doc/webcruft/win_install_02.png
16                 ${CMAKE_HOME_DIRECTORY}/doc/webcruft/win_install_03.png
17                 ${CMAKE_HOME_DIRECTORY}/doc/webcruft/win_install_04.png
18                 ${CMAKE_HOME_DIRECTORY}/doc/webcruft/win_install_05.png
19                 ${CMAKE_HOME_DIRECTORY}/doc/webcruft/win_install_06.png
20         )
21         
22         configure_file(${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/UserGuideDoxyfile.in ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/UserGuideDoxyfile @ONLY)
23         
24         ADD_CUSTOM_TARGET(user_guide
25                 COMMENT "Generating the SimGrid user guide..."
26                 DEPENDS ${USER_GUIDE_SOURCES} ${DOC_FIGS} ${source_doxygen}
27                 COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_HOME_DIRECTORY}/doc/user_guide/html
28             COMMAND ${CMAKE_COMMAND} -E make_directory   ${CMAKE_HOME_DIRECTORY}/doc/user_guide/html            
29                 WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen
30         )
31                 
32         ADD_CUSTOM_COMMAND(TARGET user_guide
33                 DEPENDS ${source_doxygen}
34                 COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_HOME_DIRECTORY}/doc/logcategories.doc
35                 COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/xbt_log_extract_hierarchy.pl > ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/logcategories.doc
36                 WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
37         )
38
39         foreach(file ${DOC_FIGS})
40                 string(REPLACE ".fig" ".png" tmp_file ${file})
41                 string(REPLACE "${CMAKE_HOME_DIRECTORY}/doc/shared/fig/" "${CMAKE_HOME_DIRECTORY}/doc/user_guide/html/" tmp_file ${tmp_file})           
42                 ADD_CUSTOM_COMMAND(TARGET user_guide
43                         COMMAND ${FIG2DEV_PATH}/fig2dev -Lpng -S 4 ${file} ${tmp_file}
44                 )
45         endforeach(file ${DOC_FIGS})
46         
47         foreach(file ${DOC_PNGS})
48                 ADD_CUSTOM_COMMAND(TARGET user_guide
49                         COMMAND ${CMAKE_COMMAND} -E copy ${file} ${CMAKE_HOME_DIRECTORY}/doc/user_guide/html/
50                 )
51         endforeach(file ${DOC_PNGS})
52
53         ADD_CUSTOM_COMMAND(TARGET user_guide
54                 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/doc/webcruft/Paje_MSG_screenshot_thn.jpg ${CMAKE_HOME_DIRECTORY}/doc/user_guide/html/
55                 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/doc/webcruft/Paje_MSG_screenshot.jpg     ${CMAKE_HOME_DIRECTORY}/doc/user_guide/html/
56                 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/doc/triva-graph_configuration.png        ${CMAKE_HOME_DIRECTORY}/doc/user_guide/html/
57                 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/doc/triva-graph_visualization.png        ${CMAKE_HOME_DIRECTORY}/doc/user_guide/html/
58                 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/doc/AS_hierarchy.png        ${CMAKE_HOME_DIRECTORY}/doc/user_guide/html/               
59                 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/doc/simgrid.css                          ${CMAKE_HOME_DIRECTORY}/doc/user_guide/html/
60         )
61         
62         ADD_CUSTOM_COMMAND(TARGET user_guide
63            COMMAND ${FIG2DEV_PATH}/fig2dev -Lmap ${CMAKE_HOME_DIRECTORY}/doc/shared/fig/simgrid_modules.fig | perl -pe 's/imagemap/simgrid_modules/g'| perl -pe 's/<IMG/<IMG style=border:0px/g' | ${CMAKE_HOME_DIRECTORY}/tools/doxygen/fig2dev_postprocessor.pl > ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/simgrid_modules.map
64             COMMAND ${CMAKE_COMMAND} -E echo "XX First Doxygen pass"
65                 COMMAND ${DOXYGEN_PATH}/doxygen UserGuideDoxyfile
66                 COMMAND ${CMAKE_HOME_DIRECTORY}/tools/doxygen/index_create.pl simgriduserguide.tag index-API.doc
67                 
68                 COMMAND ${CMAKE_COMMAND} -E echo "XX Second Doxygen pass"
69                 COMMAND ${DOXYGEN_PATH}/doxygen UserGuideDoxyfile
70                 
71                 COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/doc/user_guide/html/dir*
72                                 
73                 WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen
74         )
75         
76 else(FIG2DEV_PATH)
77
78         ADD_CUSTOM_TARGET(user_guide
79                         COMMENT "Generating the SimGrid user guide..."
80                         )
81
82         ADD_CUSTOM_COMMAND(TARGET user_guide
83                         COMMAND ${CMAKE_COMMAND} -E echo "DOXYGEN_PATH          = ${DOXYGEN_PATH}"
84                         COMMAND ${CMAKE_COMMAND} -E echo "FIG2DEV_PATH          = ${FIG2DEV_PATH}"
85                         COMMAND ${CMAKE_COMMAND} -E echo "IN ORDER TO GENERATE THE DOCUMENTATION YOU NEED ALL TOOLS !!!"
86                         COMMAND ${CMAKE_COMMAND} -E echo "FAIL TO MAKE SIMGRID DOCUMENTATION see previous messages for details ..."
87                         COMMAND false
88                         )
89
90                 
91 endif(FIG2DEV_PATH)
92
93 ##############################################################################"
94
95 #message(STATUS "Check individual TOCs")
96 #set(LISTE_GTUT
97 #       doc/user_guide/doxygen/gtut-tour-00-install.doc
98 #       doc/user_guide/doxygen/gtut-tour-01-bones.doc
99 #       doc/user_guide/doxygen/gtut-tour-02-simple.doc
100 #       doc/user_guide/doxygen/gtut-tour-03-args.doc
101 #       doc/user_guide/doxygen/gtut-tour-04-callback.doc
102 #       doc/user_guide/doxygen/gtut-tour-05-globals.doc
103 #       doc/user_guide/doxygen/gtut-tour-06-logs.doc
104 #       doc/user_guide/doxygen/gtut-tour-07-timers.doc
105 #       doc/user_guide/doxygen/gtut-tour-08-exceptions.doc
106 #       doc/user_guide/doxygen/gtut-tour-09-simpledata.doc
107 #       doc/user_guide/doxygen/gtut-tour-10-rpc.doc
108 #       doc/user_guide/doxygen/gtut-tour-11-explicitwait.doc
109 #       doc/user_guide/doxygen/gtut-tour-recap-messages.doc
110 #       doc/user_guide/doxygen/gtut-tour-12-staticstruct.doc
111 #       doc/user_guide/doxygen/gtut-tour-13-pointers.doc
112 #       doc/user_guide/doxygen/gtut-tour-14-dynar.doc
113 #       doc/user_guide/doxygen/gtut-tour-15-manualdatadef.doc
114 #       doc/user_guide/doxygen/gtut-tour-16-exchangecb.doc
115 #)
116 #
117 #foreach(file_name ${LISTE_GTUT})
118 #       file(REMOVE ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.curtoc)
119 #       file(REMOVE ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.realtoc)
120 #       
121 #       file(READ "${file_name}" file_content)
122 #       string(REGEX MATCH "Table of Contents.*<hr>" valeur_line "${file_content}")
123 #       string(REPLACE "\n" ";" valeur_line "${valeur_line}")
124 #       string(REPLACE "\n" ";" file_content "${file_content}")
125 #              
126 #       file(APPEND ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.realtoc "\n") # make sure it exists
127 #       foreach(line ${file_content})
128 #               string(REGEX MATCH "[\\]s?u?b?s?u?b?section.*" line2 "${line}")
129 #               string(REGEX MATCH ".*_toc.*" line3 "${line}")
130 #               if(line2 AND NOT line3)
131 #                       string(REPLACE "\\section " "" line2 ${line2})
132 #                       string(REPLACE "\\subsection " "subsection" line2 ${line2})
133 #                       string(REPLACE "\\subsubsection " "subsubsection" line2 ${line2})
134 #                       string(REGEX REPLACE " .*" "" line2 ${line2})
135 #                       set(line2                               " - \\ref ${line2}")
136 #                       string(REPLACE " - \\ref subsection"    "   - \\ref " line2 ${line2})
137 #                       string(REPLACE " - \\ref subsubsection" "     - \\ref " line2 ${line2})
138 #                       file(APPEND ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.realtoc "${line2}\n")
139 #               endif(line2 AND NOT line3)
140 #       endforeach(line ${file_content})
141 #       
142 #       file(APPEND ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.curtoc "\n") # make sure it exists
143 #       foreach(line ${valeur_line})
144 #               string(REGEX MATCH ".*ref.*" line_ok ${line})
145 #               if(line_ok)
146 #                       file(APPEND ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.curtoc "${line_ok}\n")
147 #               endif(line_ok)
148 #       endforeach(line ${valeur_line})
149 #       
150 #       exec_program("${CMAKE_COMMAND} -E compare_files ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.curtoc ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.realtoc" OUTPUT_VARIABLE compare_files)
151 #       if(compare_files)
152 #               message(STATUS "Wrong toc for ${file_name}. Should be:")
153 #               file(READ "${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.realtoc" file_content)
154 #               message("${file_content}")
155 #               exec_program("diff -u ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.curtoc ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.realtoc")
156 #        endif(compare_files)
157 #endforeach(file_name ${LISTE_GTUT})
158 #
159 #file(REMOVE ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.curtoc)
160 #file(REMOVE ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.realtoc)
161 #
162 #message(STATUS "Check main TOC")
163 #
164 #foreach(file_name ${LISTE_GTUT})
165 #       file(READ "${file_name}" file_content)  
166 #       string(REGEX MATCH "Table of Contents.*<hr>" valeur_line "${file_content}")
167 #       string(REPLACE "\n" ";" valeur_line "${valeur_line}")
168 #       string(REPLACE "\n" ";" file_content "${file_content}")
169 #       
170 #       foreach(line ${file_content})
171 #               string(REGEX MATCH ".*@page.*" line2 "${line}")
172 #               if(line2)
173 #                       string(REPLACE "@page " "" line2 "${line2}")
174 #                       string(REGEX REPLACE " .*" "" line2 "${line2}")
175 #                       set(line2 " - \\ref ${line2}")
176 #                       file(APPEND ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.realtoc "${line2}\n")
177 #               endif(line2)
178 #       endforeach(line ${file_content})
179 #       
180 #       foreach(line ${valeur_line})
181 #               string(REGEX MATCH ".*toc.*" line1 "${line}")
182 #               string(REGEX MATCH ".*<hr>.*" line2 "${line}")
183 #               string(REGEX MATCH "^[ ]*$" line3 "${line}")
184 #               string(REGEX MATCH "Table of Contents" line4 "${line}")
185 #               if(NOT line1 AND NOT line2 AND NOT line3 AND NOT line4)
186 #                       file(APPEND ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.realtoc "   ${line}\n")
187 #               endif(NOT line1 AND NOT line2 AND NOT line3 AND NOT line4)
188 #       endforeach(line ${valeur_line})
189 #endforeach(file_name ${LISTE_GTUT})    
190 #
191 #file(READ "${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/gtut-tour.doc" file_content)
192 #string(REPLACE "\n" ";" file_content "${file_content}")
193 #foreach(line ${file_content})
194 #       string(REGEX MATCH "^[ ]+.*\\ref" line1 "${line}")
195 #       if(line1)
196 #               file(APPEND ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.curtoc "${line}\n")
197 #       endif(line1)
198 #endforeach(line ${file_content})
199 #       
200 #exec_program("${CMAKE_COMMAND} -E compare_files ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.curtoc ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.realtoc" OUTPUT_VARIABLE compare_files)
201 #if(compare_files)
202 #       message(STATUS "Wrong toc for gtut-tour.doc Right one is in tmp.realtoc")
203 #       exec_program("diff -u ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.curtoc ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.realtoc")
204 #else(compare_files)
205 #       file(REMOVE ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.realtoc)
206 #endif(compare_files)   
207 #  
208 #file(REMOVE ${CMAKE_HOME_DIRECTORY}/doc/user_guide/doxygen/tmp.curtoc)
209
210 ADD_CUSTOM_TARGET(user_guide_pdf
211     COMMAND ${CMAKE_COMMAND} -E echo "XX First pass simgrid_user_guide.pdf"
212     COMMAND make clean
213     COMMAND make pdf || true
214     COMMAND ${CMAKE_COMMAND} -E echo "XX Second pass simgrid_user_guide.pdf"
215     COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/doc/latex/refman.pdf
216     COMMAND make pdf || true
217     COMMAND ${CMAKE_COMMAND} -E echo "XX Write Simgrid_documentation.pdf"
218     COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_HOME_DIRECTORY}/doc/latex/refman.pdf ${CMAKE_HOME_DIRECTORY}/doc/latex/simgrid_documentation.pdf
219   
220     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc/latex/
221 )
222 add_dependencies(user_guide_pdf user_guide)