Skip to content

Commit f965eae

Browse files
committed
fix broken windows help in f28+
1 parent fccfbdc commit f965eae

10 files changed

+1355
-1853
lines changed

doc/i18n reminder for developers.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html
5353

5454
Then, in in your build directory, run:
5555

56-
$ make handbook
56+
$ make mhelp
5757

5858
This will create the corresponding <LANG> folder and the <LANG>.po file into
5959
this folder.
@@ -63,7 +63,7 @@ this folder.
6363

6464
go to your CMake build folder and run:
6565

66-
make help_pot
66+
make mhelp_pot
6767

6868
This takes the list of Mallard pages, extracts the translatable strings and
6969
merges them into a PO template (POT) file which will be named xiphos.pot.
@@ -80,7 +80,7 @@ file.
8080

8181
In your build directory, run
8282

83-
make help_<LANG>.po
83+
make mhelp_<LANG>.po
8484

8585
The POT file is then merged in the current PO file.
8686

@@ -90,5 +90,5 @@ The POT file is then merged in the current PO file.
9090

9191
go to your CMake build folder and run:
9292

93-
make help_po
93+
make mhelp_po
9494

doc/targets for developpers.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ build xiphos_html lib
2626

2727
build help
2828

29-
$ make handbook
29+
$ make mhelp
3030

3131

3232
targets for updating source files:
@@ -45,12 +45,12 @@ updating a specific po file
4545

4646
updating help pot file
4747

48-
$ make help_pot
48+
$ make mhelp_pot
4949

5050
updating help all po files
5151

52-
$ make help_po
52+
$ make mhelp_po
5353

5454
updating a specific help po file
5555

56-
$ make help_<lang>.po
56+
$ make mhelp_<lang>.po

mhelp/CMakeLists.txt

+53-109
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ if (HELP)
5757
# list of figures
5858
list (APPEND help_figures
5959
figures/first_start.png
60-
figures/gtkhtml3-vs-mozembed.png
6160
figures/interface_biblepane-options.png
6261
figures/interface_biblepane.png
6362
figures/interface_commentarypane.png
@@ -81,7 +80,6 @@ if (HELP)
8180
figures/preferences_general-biblesync.png
8281
figures/preferences_modules-misc.png
8382
figures/preferences_modules-parallel.png
84-
figures/preferences.png
8583
figures/search_search.png
8684
figures/studypad.png
8785
figures/sword3.png
@@ -93,7 +91,8 @@ if (HELP)
9391
figures/xiphos-trail-icon.png
9492
)
9593

96-
add_custom_target(handbook) # help is a reserved keyword
94+
# we use 'mhelp' (mallard help) as 'help' is a CMake reserved keyword
95+
add_custom_target(mhelp)
9796

9897
# read languages from LINGUAS
9998
file (READ ${CMAKE_CURRENT_SOURCE_DIR}/HELP_LINGUAS linguas)
@@ -112,7 +111,7 @@ if (HELP)
112111
add_custom_target(help-C-pages
113112
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/C/pages.timestamp
114113
)
115-
add_dependencies(handbook help-C-pages)
114+
add_dependencies(mhelp help-C-pages)
116115

117116
# 2. create translated pages for all other languages than C
118117
foreach (lang ${help_locales})
@@ -162,7 +161,7 @@ if (HELP)
162161
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${lang}/pages.timestamp
163162
)
164163

165-
add_dependencies(handbook help-${lang}-pages)
164+
add_dependencies(mhelp help-${lang}-pages)
166165

167166
endforeach (lang)
168167

@@ -181,7 +180,7 @@ if (HELP)
181180
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${lang}/validate.txt
182181
)
183182

184-
add_dependencies(handbook validate-${lang}-pages)
183+
add_dependencies(mhelp validate-${lang}-pages)
185184

186185
endforeach (lang)
187186

@@ -222,7 +221,7 @@ if (HELP)
222221
foreach(page ${help_pages})
223222
list(APPEND pot_pages ${CMAKE_CURRENT_BINARY_DIR}/C/${page})
224223
endforeach(page)
225-
add_custom_target (help_pot
224+
add_custom_target (mhelp_pot
226225
COMMAND ${ITSTOOL} -o ${help_pot} ${pot_pages}
227226
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
228227
COMMENT "Updating help pot file."
@@ -231,7 +230,7 @@ if (HELP)
231230
# target for updating a given .po file
232231
set (help_po_update_all echo)
233232
foreach (lang ${help_locales})
234-
add_custom_target (help_${lang}.po
233+
add_custom_target (mhelp_${lang}.po
235234
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --update --verbose ${lang}.po ${help_pot}
236235
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${lang}
237236
COMMENT "Updating ${lang}.po file"
@@ -241,7 +240,7 @@ if (HELP)
241240
endforeach()
242241

243242
# target for updating all po files
244-
add_custom_target (help_po
243+
add_custom_target (mhelp_po
245244
COMMAND ${help_po_update_all}
246245
VERBATIM
247246
)
@@ -284,11 +283,11 @@ if (HELP)
284283
COMMENT "Generating '${lang}' ePub Help file"
285284
)
286285

287-
add_custom_target(${lang}-epub-help
286+
add_custom_target(mhelp-epub-${lang}
288287
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${lang}/${PROJECT_NAME}-${lang}.epub
289288
)
290289

291-
add_dependencies(handbook ${lang}-epub-help)
290+
add_dependencies(mhelp mhelp-epub-${lang})
292291

293292
# install ePub file
294293
install (FILES
@@ -313,21 +312,20 @@ if (HELP)
313312
list(APPEND mallard_pages ${CMAKE_CURRENT_BINARY_DIR}/${lang}/${page})
314313
endforeach(page)
315314

316-
# use a custom css (specify font size, hide footer..)
317-
set(custom_css ${CMAKE_CURRENT_SOURCE_DIR}/xml/html.css.custom.xsl)
318315
# convert Mallard pages into html files
319316
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${lang}/html.timestamp
320-
COMMAND ${YELP_BUILD} html -x ${custom_css} ${mallard_pages}
317+
COMMAND ${CMAKE_COMMAND} -E make_directory html
318+
COMMAND ${YELP_BUILD} html -o html ${mallard_pages}
321319
# make a tarball of all the .html files
322-
COMMAND ${CMAKE_COMMAND} -E tar cvzf xiphos-html-help.tar.gz *.html
320+
COMMAND ${CMAKE_COMMAND} -E tar cvzf xiphos-html-help.tar.gz html
323321
DEPENDS validate-${lang}-pages
324322
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${lang}
325323
COMMENT "Generating '${lang}' html files"
326324
)
327-
add_custom_target(${lang}-html-help
325+
add_custom_target(mhelp-html-${lang}
328326
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${lang}/html.timestamp
329327
)
330-
add_dependencies(handbook ${lang}-html-help)
328+
add_dependencies(mhelp mhelp-html-${lang})
331329

332330
# install HTML files
333331
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${lang}/xiphos-html-help.tar.gz
@@ -351,106 +349,52 @@ if (HELP)
351349
# 2. Error: Anchor undefined:
352350
# due to missing anchors in index.html
353351

354-
# generate a .chm file for each <lang>
355352
foreach (lang ${help_all_langs})
356-
# Create xiphos.hhp file (PROJECT)
357-
# 1. find the according Microsoft language ID
358-
file(STRINGS win32/ms-langID ms_langID REGEX "^${lang}[ ]")
359-
# if empty, default to the en-US langID
360-
if (NOT ms_langID)
361-
set(ms_langID "C 0x0409 English (United States)")
362-
endif ()
363-
# remove lang, keep only langID and country values
364-
string(LENGTH ${lang} len_lang)
365-
math(EXPR len_lang "${len_lang} + 1")
366-
string(SUBSTRING ${ms_langID} ${len_lang} -1 MS_LANGUAGE_CODE)
367-
368-
# 2. set the .chm output file name
369-
set(MS_COMPILED_FILE "xiphos_${lang}.chm")
353+
# make a distinct directory
354+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${lang}/chm)
370355

371-
# 3. set the list of files to compile
372-
foreach(line ${help_pages})
373-
set(MS_FILES_LIST "${MS_FILES_LIST}${line}\n")
374-
endforeach()
375-
foreach(line ${help_figures})
376-
set(MS_FILES_LIST "${MS_FILES_LIST}${line}\n")
377-
endforeach()
378-
379-
# 4. create HHP file (Project file)
380-
configure_file(${PROJECT_SOURCE_DIR}/mhelp/win32/xiphos.hhp.in
381-
${CMAKE_CURRENT_BINARY_DIR}/${lang}/xiphos.hhp)
382-
383-
# Create xiphos.hhc (TOC)
384-
# 1. find MS codepage for lang
385-
file(STRINGS win32/ms-codepages ms_codepage REGEX "^${lang}[ ]")
386-
# if codepage unset, default to windows-1252
387-
if (${lang} STREQUAL ${ms_codepage})
388-
message(WARNING "No codepage set for ${lang}, please add it to the win32/ms-codepages file")
389-
set(ms_codepage "${lang} windows-1252")
390-
endif ()
391-
# remove lang
392-
string(LENGTH ${lang} len_lang)
393-
math(EXPR len_lang "${len_lang} + 1")
394-
string(SUBSTRING ${ms_codepage} ${len_lang} -1 MS_WINDOWS_CODEPAGE)
395-
396-
# 3. create XSLT file
397-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/win32/toc.xsl.in
398-
${CMAKE_CURRENT_BINARY_DIR}/${lang}/toc.xsl)
399-
400-
# 4. build HHC file
401-
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${lang}/xiphos.hhc
402-
# Create HHC file (TOC)
403-
COMMAND ${XSLTPROC} --html ${CMAKE_CURRENT_BINARY_DIR}/${lang}/toc.xsl ${CMAKE_CURRENT_BINARY_DIR}/${lang}/index.html > ${CMAKE_CURRENT_BINARY_DIR}/${lang}/xiphos.hhc
404-
# Compile HTML files
405-
DEPENDS ${lang}-html-help
406-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${lang}
407-
COMMENT "Generating '${lang}' Windows HHC (Table of Contents) file"
408-
)
356+
# list pages to convert
357+
set (mallard_pages)
358+
foreach(page ${help_pages})
359+
list(APPEND mallard_pages ${CMAKE_CURRENT_BINARY_DIR}/${lang}/${page})
360+
endforeach(page)
409361

410-
# 6. TODO: Create a valid HHK file (Index file)
411-
# here is a workaround:
412-
file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/${lang}/xiphos.hhk
413-
"<!DOCTYPE html>"
414-
"<html>"
415-
"<head>"
416-
"<!-- Sitemap 1.0 -->"
417-
"</head><body>"
418-
"<object type=\"text/site properties\">"
419-
"</object>"
420-
"<ul>"
421-
"</ul>"
422-
"</body></html>"
423-
)
362+
# use a custom css for generating HTML4 copatible pages
363+
set(custom_css ${CMAKE_CURRENT_SOURCE_DIR}/xml/html.css.custom.xsl)
424364

425-
# 7. Build CHM
426-
if (WIN32 AND NOT CMAKE_CROSSCOMPILING)
427-
# pure Windows: building help with HHC.EXE [NOTE: First switch to XSLT]
428-
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${lang}/${MS_COMPILED_FILE}
429-
COMMAND ${HHC_EXE} xiphos.hhp
430-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${lang}
431-
COMMENT "Generating '${lang}' Windows© Help file - HHC.EXE"
432-
)
433-
else (WIN32 AND NOT CMAKE_CROSSCOMPILING)
434-
# Linux: building help using the chmcmd utility from Free Pascal
435-
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${lang}/${MS_COMPILED_FILE}
436-
# Compile HTML files
437-
COMMAND ${CHMCMD} xiphos.hhp
438-
COMMAND chmod 644 ${CMAKE_CURRENT_BINARY_DIR}/${lang}/${MS_COMPILED_FILE}
439-
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${lang}/xiphos.hhc
440-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${lang}
365+
# use a Mallard cache file
366+
set(cache_cache ${CMAKE_CURRENT_BINARY_DIR}/${lang}/chm/cache.xml)
367+
368+
# use XSLT to create HtmlHelp files
369+
set(mal2hh_xslt ${CMAKE_CURRENT_SOURCE_DIR}/xml/mal2hh.xsl)
370+
371+
# set the output file name
372+
set(MS_COMPILED_FILE "xiphos_${lang}.chm")
373+
374+
# Compile the Microsoft Windows Help File (.chm)
375+
if (WIN32 AND CMAKE_CROSSCOMPILING)
376+
# Linux: build help with the chmcmd utility (from Free Pascal Compiler)
377+
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${lang}/chm/${MS_COMPILED_FILE}
378+
COMMAND ${YELP_BUILD} cache -o ${cache_cache} ${mallard_pages}
379+
COMMAND ${YELP_BUILD} html -c ${cache_cache} -x ${custom_css} ${mallard_pages}
380+
COMMAND ${XSLTPROC} --stringparam htmlhelp.chm "${MS_COMPILED_FILE}" ${mal2hh_xslt} ${cache_cache}
381+
COMMAND ${CHMCMD} htmlhelp.hhp
382+
COMMAND chmod 644 ${CMAKE_CURRENT_BINARY_DIR}/${lang}/chm/${MS_COMPILED_FILE}
383+
DEPENDS validate-${lang}-pages
384+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${lang}/chm
441385
COMMENT "Generating '${lang}' Windows© Help file - chmcmd"
442386
)
443-
endif(WIN32 AND NOT CMAKE_CROSSCOMPILING)
387+
endif(WIN32 AND CMAKE_CROSSCOMPILING)
444388

445389
# add target to current target
446-
add_custom_target(${lang}-windows-help
447-
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${lang}/${MS_COMPILED_FILE}
390+
add_custom_target(mhelp-windows-${lang}
391+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${lang}/chm/${MS_COMPILED_FILE}
448392
)
449393

450-
add_dependencies(handbook ${lang}-windows-help)
394+
add_dependencies(mhelp mhelp-windows-${lang})
451395

452396
# install MS-Help files
453-
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${lang}/${MS_COMPILED_FILE}
397+
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${lang}/chm/${MS_COMPILED_FILE}
454398
DESTINATION ${CMAKE_INSTALL_DATADIR}/help
455399
COMPONENT data
456400
)
@@ -468,17 +412,17 @@ if (HELP)
468412
# convert from ePub to PDF
469413
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${lang}/xiphos.pdf
470414
COMMAND ${EBOOK_CONVERT} xiphos-C.epub xiphos.pdf --base-font-size 8 --linearize-tables --chapter //h:h1 --use-auto-toc
471-
DEPENDS ${lang}-epub-help
415+
DEPENDS mhelp-epub-${lang}
472416
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${lang}
473417
COMMENT "Generating '${lang}' PDF file"
474418
)
475419

476420
# add target to current target
477-
add_custom_target(${lang}-pdf-help
421+
add_custom_target(mhelp-pdf-${lang}
478422
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${lang}/xiphos.pdf
479423
)
480424

481-
add_dependencies(handbook ${lang}-pdf-help)
425+
add_dependencies(mhelp mhelp-pdf-${lang})
482426

483427
# install PDF file
484428
install (FILES
@@ -489,6 +433,6 @@ if (HELP)
489433

490434
endif (PDFHELP)
491435

492-
add_dependencies(xiphos handbook)
436+
add_dependencies(xiphos mhelp)
493437

494438
endif (HELP)

mhelp/win32/bdd.odb

-56 KB
Binary file not shown.

0 commit comments

Comments
 (0)