Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add local tests with pipol.
[simgrid.git] / buildtools / Cmake / GenerateDoc.cmake
1 message("\tBIBTEX2HTML  : ${BIBTEX2HTML}")
2
3 if(BIBTEX2HTML)
4 set(BIBTEX2HTML_PATH ${BIBTEX2HTML})
5 else(BIBTEX2HTML)
6 find_path(BIBTEX2HTML_PATH      NAMES bibtex2html       PATHS NO_DEFAULT_PATHS)
7 endif(BIBTEX2HTML)
8
9 find_path(FIG2DEV_PATH  NAMES fig2dev   PATHS NO_DEFAULT_PATHS)
10 find_path(DOXYGEN_PATH  NAMES doxygen   PATHS NO_DEFAULT_PATHS)
11 find_path(BIBTOOL_PATH  NAMES bibtool   PATHS NO_DEFAULT_PATHS)
12 find_path(ICONV_PATH    NAMES iconv     PATHS NO_DEFAULT_PATHS)
13
14 message("\tFIG2DEV_PATH : ${FIG2DEV_PATH}")
15 message("\tDOXYGEN_PATH : ${DOXYGEN_PATH}")
16 message("\tBIBTOOL_PATH : ${BIBTOOL_PATH}")
17 message("\tICONV_PATH   : ${ICONV_PATH}")
18 message("\tBIBTEX2HTML_PATH   : ${BIBTEX2HTML_PATH}")
19
20 exec_program("${BIBTEX2HTML_PATH}/bibtex2html -version" OUTPUT_VARIABLE SORTIE_BIBTEX2HTML_VERSION)
21 STRING(REPLACE "[-bibtex]" "" SORTIE_BIBTEX2HTML_VERSION_2 ${SORTIE_BIBTEX2HTML_VERSION})
22
23 if(BIBTEX2HTML_PATH)
24         if(${SORTIE_BIBTEX2HTML_VERSION_2} STREQUAL ${SORTIE_BIBTEX2HTML_VERSION}) # mauvaise version
25                 message("\nERROR --> NEED to set bibtex2html path with \"ccmake ./\" or with \"cmake -DBIBTEX2HTML=<path_to> ./\"")
26                 message("\nTake care having install the good bibtex2html \n\t(download it : ftp://ftp-sop.inria.fr/epidaure/Softs/bibtex2html/bibtex2html-1.02.tar.gz)")
27                 message(FATAL_ERROR "\n")
28         endif(${SORTIE_BIBTEX2HTML_VERSION_2} STREQUAL ${SORTIE_BIBTEX2HTML_VERSION})
29 endif(BIBTEX2HTML_PATH)
30
31 exec_program("${CMAKE_COMMAND} -E remove_directory ${PROJECT_DIRECTORY}/doc/html"  "${PROJECT_DIRECTORY}/doc/")
32 exec_program("${CMAKE_COMMAND} -E make_directory ${PROJECT_DIRECTORY}/doc/html"  "${PROJECT_DIRECTORY}/doc/")
33
34 file(GLOB_RECURSE LISTE_UNE
35 "${PROJECT_DIRECTORY}/tools/gras/*.[chl]"
36 "${PROJECT_DIRECTORY}/src/*.[chl]"
37 "${PROJECT_DIRECTORY}/include/*.[chl]"
38 )
39
40 file(GLOB_RECURSE LISTE_DEUX
41 "${PROJECT_DIRECTORY}/*.doc"
42 )
43 string(REGEX REPLACE ";.*logcategories.doc" "" LISTE_DEUX "${LISTE_DEUX}")
44
45 set(DOCSSOURCES "${LISTE_UNE}\n${LISTE_DEUX}")
46 string(REPLACE "\n" ";" DOCSSOURCES ${DOCSSOURCES})
47
48 set(FIGS
49 ${PROJECT_DIRECTORY}/doc/fig/simgrid_modules.fig
50 ${PROJECT_DIRECTORY}/doc/fig/simgrid_modules2.fig
51 ${PROJECT_DIRECTORY}/doc/fig/amok_bw_test.fig
52 ${PROJECT_DIRECTORY}/doc/fig/amok_bw_sat.fig
53 ${PROJECT_DIRECTORY}/doc/fig/gras_comm.fig
54 )
55
56 set(PNGS 
57 ${PROJECT_DIRECTORY}/doc/webcruft/simgrid_logo.png
58 ${PROJECT_DIRECTORY}/doc/webcruft/simgrid_logo_small.png
59 ${PROJECT_DIRECTORY}/doc/webcruft/poster_thumbnail.png
60 )
61
62 if(DOXYGEN_PATH AND FIG2DEV_PATH)
63         
64         exec_program("${FIG2DEV_PATH}/fig2dev -Lmap ${PROJECT_DIRECTORY}/doc/fig/simgrid_modules.fig" OUTPUT_VARIABLE output_fig2dev)
65         string(REPLACE "\n" ";" output_fig2dev "${output_fig2dev}")
66         
67         file(REMOVE ${PROJECT_DIRECTORY}/doc/simgrid_modules.map)       
68
69         foreach(line ${output_fig2dev})
70                 string(REGEX MATCH "IMG" test_oki1 "${line}")
71                 string(REGEX MATCH "MAP" test_oki2 "${line}")
72                 string(REGEX MATCH "AREA" test_oki3 "${line}")
73                 if(test_oki1 OR test_oki2 OR test_oki3)
74                         string(REPLACE "imagemap"       "simgrid_modules" line "${line}")
75                         string(REPLACE ".gif"   ".png" line "${line}")
76                         string(REPLACE "<IMG"   "<IMG style=\"border:0px\""  line "${line}")
77                 file(APPEND ${PROJECT_DIRECTORY}/doc/simgrid_modules.map "${line}\n")
78                 endif(test_oki1 OR test_oki2 OR test_oki3)      
79         endforeach(line ${output_fig2dev})
80
81         foreach(file ${FIGS})
82                 string(REPLACE ".fig" ".png" tmp_file ${file})
83                 string(REPLACE "${PROJECT_DIRECTORY}/doc/fig/" "${PROJECT_DIRECTORY}/doc/html/" tmp_file ${tmp_file})
84                 exec_program("${FIG2DEV_PATH}/fig2dev -Lpng ${file} > ${tmp_file}"  "${PROJECT_DIRECTORY}/doc/")
85         endforeach(file ${FIGS})
86
87
88         exec_program("${CMAKE_COMMAND} -E touch ${PROJECT_DIRECTORY}/doc/index-API.doc ${PROJECT_DIRECTORY}/doc/.FAQ.doc.toc ${PROJECT_DIRECTORY}/doc/.index.doc.toc ${PROJECT_DIRECTORY}/doc/.contrib.doc.toc ${PROJECT_DIRECTORY}/doc/.history.doc.toc"  "${PROJECT_DIRECTORY}/doc/")
89         
90         if(NOT EXISTS ${PROJECT_DIRECTORY}/doc/html)
91                 file(MAKE_DIRECTORY ${PROJECT_DIRECTORY}/doc/html)
92         endif(NOT EXISTS ${PROJECT_DIRECTORY}/doc/html)
93
94         foreach(file ${PNGS})
95                 exec_program("${CMAKE_COMMAND} -E copy ${file} ${PROJECT_DIRECTORY}/doc/html/"  "${PROJECT_DIRECTORY}/doc/")
96         endforeach(file ${PNGS})
97
98         exec_program("${CMAKE_COMMAND} -E copy ${PROJECT_DIRECTORY}/doc/webcruft/Paje_MSG_screenshot_thn.jpg ${PROJECT_DIRECTORY}/doc/webcruft/Paje_MSG_screenshot.jpg ${PROJECT_DIRECTORY}/doc/html/"  "${PROJECT_DIRECTORY}/doc/")
99         exec_program("${CMAKE_COMMAND} -E copy ${PROJECT_DIRECTORY}/doc/triva-time_interval.png ${PROJECT_DIRECTORY}/doc/html/"  "${PROJECT_DIRECTORY}/doc/")
100         exec_program("${CMAKE_COMMAND} -E copy ${PROJECT_DIRECTORY}/doc/triva-graph_configuration.png ${PROJECT_DIRECTORY}/doc/html/"  "${PROJECT_DIRECTORY}/doc/")
101         exec_program("${CMAKE_COMMAND} -E copy ${PROJECT_DIRECTORY}/doc/triva-graph_visualization.png ${PROJECT_DIRECTORY}/doc/html/"  "${PROJECT_DIRECTORY}/doc/")
102         exec_program("${CMAKE_COMMAND} -E copy ${PROJECT_DIRECTORY}/doc/simgrid.css ${PROJECT_DIRECTORY}/doc/html/"  "${PROJECT_DIRECTORY}/doc/") 
103
104         set(top_srcdir "..")
105         set(WARNING "This file is generated, do not edit")
106         set(srcdir ".")
107         configure_file(${PROJECT_DIRECTORY}/doc/Doxyfile.in ${PROJECT_DIRECTORY}/doc/Doxyfile @ONLY)
108 # First pass
109         exec_program("${DOXYGEN_PATH}/doxygen ${PROJECT_DIRECTORY}/doc/Doxyfile" "${PROJECT_DIRECTORY}/doc/")
110
111         exec_program("${PROJECT_DIRECTORY}/tools/doxygen/index_create.pl" "${PROJECT_DIRECTORY}/doc/"
112         ARGS simgrid.tag index-API.doc)
113         exec_program("${PROJECT_DIRECTORY}/tools/doxygen/toc_create.pl" "${PROJECT_DIRECTORY}/doc/"
114         ARGS FAQ.doc index.doc contrib.doc gtut-introduction.doc history.doc)
115 # Second pass
116         exec_program("${DOXYGEN_PATH}/doxygen ${PROJECT_DIRECTORY}/doc/Doxyfile" "${PROJECT_DIRECTORY}/doc/")
117 # Post-processing
118
119         exec_program("${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/doc/html/dir*"  "${PROJECT_DIRECTORY}/doc/")
120
121         exec_program("${PROJECT_DIRECTORY}/tools/doxygen/index_php.pl""${PROJECT_DIRECTORY}/doc/"
122         ARGS index.php.in html/index.html index.php)
123         exec_program("${PROJECT_DIRECTORY}/tools/doxygen/doxygen_postprocesser.pl"  "${PROJECT_DIRECTORY}/doc/")
124
125 #html/gras.html:
126         exec_program("${CMAKE_COMMAND} -E echo \"<html><META HTTP-EQUIV='Refresh' content='0;URL=http://simgrid.gforge.inria.fr/doc/group__GRAS__API.html'>\" > ${PROJECT_DIRECTORY}/doc/html/gras.html"  "${PROJECT_DIRECTORY}/doc/")
127         exec_program("${CMAKE_COMMAND} -E echo \"<center><h2><br><a href='http://simgrid.gforge.inria.fr/doc/group__GRAS__API.html'>Grid Reality And Simulation.</a></h2></center></html>\" >> ${PROJECT_DIRECTORY}/doc/html/gras.html"  "${PROJECT_DIRECTORY}/doc/")
128 #html/amok.html:
129         exec_program("${CMAKE_COMMAND} -E echo \"<html><META HTTP-EQUIV='Refresh' content='0;URL=http://simgrid.gforge.inria.fr/doc/group__AMOK__API.html'>\" > ${PROJECT_DIRECTORY}/doc/html/amok.html"  "${PROJECT_DIRECTORY}/doc/")
130         exec_program("${CMAKE_COMMAND} -E echo \"<center><h2><br><a href='http://simgrid.gforge.inria.fr/doc/group__AMOK__API.html'>Advanced Metacomputing Overlay Kit.</a></h2></center></html>\" >> ${PROJECT_DIRECTORY}/doc/html/amok.html"  "${PROJECT_DIRECTORY}/doc/")
131 #html/msg.html:
132         exec_program("${CMAKE_COMMAND} -E echo \"<html><META HTTP-EQUIV='Refresh' content='0;URL=http://simgrid.gforge.inria.fr/doc/group__MSG__API.html'>\" > ${PROJECT_DIRECTORY}/doc/html/msg.html"  "${PROJECT_DIRECTORY}/doc/")
133         exec_program("${CMAKE_COMMAND} -E echo \"<center><h2><br><a href='http://simgrid.gforge.inria.fr/doc/group__MSG__API.html'>Meta SimGrid.</a></h2></center></html>\" >> ${PROJECT_DIRECTORY}/doc/html/msg.html"  "${PROJECT_DIRECTORY}/doc/")
134 #html/simdag.html:
135         exec_program("${CMAKE_COMMAND} -E echo \"<html><META HTTP-EQUIV='Refresh' content='0;URL=http://simgrid.gforge.inria.fr/doc/group__SD__API.html'>\" > ${PROJECT_DIRECTORY}/doc/html/simdag.html"  "${PROJECT_DIRECTORY}/doc/")
136         exec_program("${CMAKE_COMMAND} -E echo \"<center><h2><br><a href='http://simgrid.gforge.inria.fr/doc/group__SD__API.html'>DAG Simulator.</a></h2></center></html>\" >> ${PROJECT_DIRECTORY}/doc/html/simdag.html"  "${PROJECT_DIRECTORY}/doc/")
137
138 if(BIBTOOL_PATH AND BIBTEX2HTML_PATH AND ICONV_PATH)
139
140 #publis_count.html: all.bib
141         exec_program("${PROJECT_DIRECTORY}/tools/doxygen/bibtex2html_table_count.pl < ${PROJECT_DIRECTORY}/doc/all.bib > ${PROJECT_DIRECTORY}/doc/publis_count.html"  "${PROJECT_DIRECTORY}/doc/")
142
143 #publis_core.bib: all.bib 
144         exec_program("${BIBTOOL_PATH}/bibtool -- 'select.by.string={category \"core\"}' -- 'preserve.key.case={on}' -- 'preserve.keys={on}' ${PROJECT_DIRECTORY}/doc/all.bib -o ${PROJECT_DIRECTORY}/doc/publis_core.bib"  "${PROJECT_DIRECTORY}/doc/")
145
146 #publis_extern.bib: all.bib 
147         exec_program("${BIBTOOL_PATH}/bibtool -- 'select.by.string={category \"extern\"}' -- 'preserve.key.case={on}' -- 'preserve.keys={on}' ${PROJECT_DIRECTORY}/doc/all.bib -o ${PROJECT_DIRECTORY}/doc/publis_extern.bib"  "${PROJECT_DIRECTORY}/doc/")
148
149 #publis_intra.bib: all.bib 
150         exec_program("${BIBTOOL_PATH}/bibtool -- 'select.by.string={category \"intra\"}' -- 'preserve.key.case={on}' -- 'preserve.keys={on}' ${PROJECT_DIRECTORY}/doc/all.bib -o ${PROJECT_DIRECTORY}/doc/publis_intra.bib"  "${PROJECT_DIRECTORY}/doc/")
151
152 #%_bib.latin1.html: %.bib
153         file(GLOB_RECURSE LISTE_QUATRE
154         "${PROJECT_DIRECTORY}/doc/*.bib"
155         )
156         foreach(file ${LISTE_QUATRE})
157                 string(REPLACE ".bib" "_bib.latin1.html" file_tmp "${file}")
158                 string(REPLACE ".html" ".html.tmp" file_tmp2 "${file_tmp}")
159                 exec_program("${BIBTEX2HTML_PATH}/bibtex2html -single-output -nv -force -sort year -copy-icons ${file} -output ${file_tmp2} 2>&1" "${PROJECT_DIRECTORY}/doc/") 
160                 file(READ ${file_tmp2} READ_TMP)
161                 file(REMOVE ${file_tmp2})
162                 string(REPLACE "\n" ";" READ_TMP ${READ_TMP})
163                 
164                 foreach(line ${READ_TMP})
165                         string(REGEX MATCH "WARNING: unknown field type" line1 ${line})
166                         if(NOT line1)
167                                 file(APPEND   ${file_tmp2} "${line}\n")
168                         endif(NOT line1)
169                 endforeach(line ${READ_TMP})
170                 exec_program("${PROJECT_DIRECTORY}/tools/doxygen/bibtex2html_postprocessor.pl < ${file_tmp2} > ${file_tmp}"  "${PROJECT_DIRECTORY}/doc/")
171         endforeach(file ${LISTE_QUATRE})
172
173
174 #%_bib.html: %_bib.latin1.html
175         file(GLOB_RECURSE LISTE_CINQ
176         "${PROJECT_DIRECTORY}/doc/*_bib.latin1.html"
177         )
178         foreach(file ${LISTE_CINQ})
179                 string(REPLACE "_bib.latin1.html" "_bib.html" file_tmp "${file}")
180                 exec_program("${ICONV_PATH}/iconv --from-code latin1 --to-code utf8 ${file} --output ${file_tmp}"  "${PROJECT_DIRECTORY}/doc/")
181         endforeach(file ${LISTE_CINQ})
182 endif(BIBTOOL_PATH AND BIBTEX2HTML_PATH AND ICONV_PATH)
183
184 endif(DOXYGEN_PATH AND FIG2DEV_PATH)
185
186 file(REMOVE ${PROJECT_DIRECTORY}/doc/logcategories.doc)
187 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.doc "/* Generated file, do not edit */\n")
188 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.doc "/** \\addtogroup XBT_log_cats\n")
189 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.doc "        @{\n")
190 exec_program("${PROJECT_DIRECTORY}/tools/doxygen/xbt_log_extract_hierarchy.pl" "${PROJECT_DIRECTORY}/src" OUTPUT_VARIABLE output_log_extract_hierarchy)
191 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.doc "${output_log_extract_hierarchy}\n")
192 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.doc  "@}*/")
193
194 file(WRITE ${PROJECT_DIRECTORY}/doc/realtoc.sh  "\#! /bin/sh")
195
196 message("Check individual TOCs")
197 file(GLOB_RECURSE LISTE_GTUT
198 "${PROJECT_DIRECTORY}/doc/gtut-tour-*.doc"
199 )
200
201
202
203 foreach(file_name ${LISTE_GTUT})
204         file(REMOVE ${PROJECT_DIRECTORY}/doc/tmp.curtoc)
205         file(REMOVE ${PROJECT_DIRECTORY}/doc/tmp.realtoc)
206         
207         file(READ "${file_name}" file_content)
208         string(REGEX MATCH "Table of Contents.*<hr>" valeur_line "${file_content}")
209         string(REPLACE "\n" ";" valeur_line "${valeur_line}")
210         string(REPLACE "\n" ";" file_content "${file_content}")
211         
212         foreach(line ${file_content})
213                 string(REGEX MATCH "[\\]s?u?b?s?u?b?section.*" line2 "${line}")
214                 string(REGEX MATCH ".*_toc.*" line3 "${line}")
215                 if(line2 AND NOT line3)
216                         string(REPLACE "\\section " "" line2 ${line2})
217                         string(REPLACE "\\subsection " "subsection" line2 ${line2})
218                         string(REPLACE "\\subsubsection " "subsubsection" line2 ${line2})
219                         string(REGEX REPLACE " .*" "" line2 ${line2})
220                         set(line2                               " - \\ref ${line2}")
221                         string(REPLACE " - \\ref subsection"    "   - \\ref " line2 ${line2})
222                         string(REPLACE " - \\ref subsubsection" "     - \\ref " line2 ${line2})
223                         file(APPEND ${PROJECT_DIRECTORY}/doc/tmp.realtoc "${line2}\n")
224                 endif(line2 AND NOT line3)
225         endforeach(line ${file_content})
226         
227         foreach(line ${valeur_line})
228                 string(REGEX MATCH ".*ref.*" line_ok ${line})
229                 if(line_ok)
230                         file(APPEND ${PROJECT_DIRECTORY}/doc/tmp.curtoc "${line_ok}\n")
231                 endif(line_ok)
232         endforeach(line ${valeur_line})
233         
234         exec_program("${CMAKE_COMMAND} -E compare_files ${PROJECT_DIRECTORY}/doc/tmp.curtoc ${PROJECT_DIRECTORY}/doc/tmp.realtoc" OUTPUT_VARIABLE compare_files)
235         if(compare_files)
236                 message("Wrong toc for ${file_name}. Should be:")
237                 file(READ "${PROJECT_DIRECTORY}/doc/tmp.realtoc" file_content)
238                 message("${file_content}")
239                 exec_program("diff -u ${PROJECT_DIRECTORY}/doc/tmp.curtoc ${PROJECT_DIRECTORY}/doc/tmp.realtoc")
240         endif(compare_files)
241 endforeach(file_name ${LISTE_GTUT})
242
243 file(REMOVE ${PROJECT_DIRECTORY}/doc/tmp.curtoc)
244 file(REMOVE ${PROJECT_DIRECTORY}/doc/tmp.realtoc)
245
246 message("Check main TOC")
247
248 foreach(file_name ${LISTE_GTUT})
249         file(READ "${file_name}" file_content)  
250         string(REGEX MATCH "Table of Contents.*<hr>" valeur_line "${file_content}")
251         string(REPLACE "\n" ";" valeur_line "${valeur_line}")
252         string(REPLACE "\n" ";" file_content "${file_content}")
253         
254         foreach(line ${file_content})
255                 string(REGEX MATCH ".*@page.*" line2 "${line}")
256                 if(line2)
257                         string(REPLACE "@page " "" line2 "${line2}")
258                         string(REGEX REPLACE " .*" "" line2 "${line2}")
259                         set(line2 " - \\ref ${line2}")
260                         file(APPEND ${PROJECT_DIRECTORY}/doc/tmp.realtoc "${line2}\n")
261                 endif(line2)
262         endforeach(line ${file_content})
263         
264         foreach(line ${valeur_line})
265                 string(REGEX MATCH ".*toc.*" line1 "${line}")
266                 string(REGEX MATCH ".*<hr>.*" line2 "${line}")
267                 string(REGEX MATCH "^[ ]*$" line3 "${line}")
268                 string(REGEX MATCH "Table of Contents" line4 "${line}")
269                 if(NOT line1 AND NOT line2 AND NOT line3 AND NOT line4)
270                         file(APPEND ${PROJECT_DIRECTORY}/doc/tmp.realtoc "   ${line}\n")
271                 endif(NOT line1 AND NOT line2 AND NOT line3 AND NOT line4)
272         endforeach(line ${valeur_line})
273 endforeach(file_name ${LISTE_GTUT})     
274
275 file(READ "${PROJECT_DIRECTORY}/doc/gtut-tour.doc" file_content)
276 string(REPLACE "\n" ";" file_content "${file_content}")
277 foreach(line ${file_content})
278         string(REGEX MATCH "^[ ]+.*\\ref" line1 "${line}")
279         if(line1)
280                 file(APPEND ${PROJECT_DIRECTORY}/doc/tmp.curtoc "${line}\n")
281         endif(line1)
282 endforeach(line ${file_content})
283         
284 exec_program("${CMAKE_COMMAND} -E compare_files ${PROJECT_DIRECTORY}/doc/tmp.curtoc ${PROJECT_DIRECTORY}/doc/tmp.realtoc" OUTPUT_VARIABLE compare_files)
285 if(compare_files)
286         message("Wrong toc for gtut-tour.doc Right one is in tmp.realtoc")
287         exec_program("diff -u ${PROJECT_DIRECTORY}/doc/tmp.curtoc ${PROJECT_DIRECTORY}/doc/tmp.realtoc")
288 else(compare_files)
289         file(REMOVE ${PROJECT_DIRECTORY}/doc/tmp.realtoc)
290 endif(compare_files)    
291   
292 file(REMOVE ${PROJECT_DIRECTORY}/doc/tmp.curtoc)
293