Skip to content
Snippets Groups Projects
Commit 88553bd4 authored by Dominic Kempf's avatar Dominic Kempf
Browse files

Merge branch 'minted-build' into 'master'

Update UseLatexMk and fix minted+standalone build

See merge request !81

(cherry picked from commit 3d1b5105)

2d280206 Update UseLatexMk and fix minted+standalone build
parent 48f5bc97
Branches cherry-pick-3d1b5105
No related tags found
1 merge request!82Merge branch 'minted-build' into 'master'
......@@ -7,6 +7,8 @@
# [REQUIRED]
# [FATHER_TARGET father1 [father2 ...]]
# [RCFILE rcfile1 [rcfile2 ...]]
# [INSTALL destination]
# [BUILD_ON_INSTALL]
# )
#
# The arguments:
......@@ -14,6 +16,8 @@
# Required argument with a single tex source that defines the document to be built
# TARGET
# An optional target name, defaults to a suitable mangling of the given source and its path.
# An additional target with _clean appended will be added as well, which cleans the output
# and all auxiliary files.
# EXCLUDE_FROM_ALL
# Set this to avoid the target from being built by default. If the FATHER_TARGET
# parameter is set, this option is automatically set.
......@@ -31,7 +35,16 @@
# You may also use CMake variables within @'s (like @CMAKE_CURRENT_BINARY_DIR@) and have
# them replaced with the matching CMake variables (see cmake's configure_file command).
# Note, that this is a powerful, but advanced feature. For details on what can be achieved
# see the latexmk manual.
# see the latexmk manual. Note, that triggering non-PDF builds through latexmkrc files might
# cause problems with other features of UseLatexMk.
# INSTALL
# Set this option to an install directory to create an installation rule for this document.
# BUILD_ON_INSTALL
# Set this option, if you want to trigger a build of this document during installation.
#
# Furthermore, UseLatexMk defines a CMake target clean_latex which cleans the build tree from
# all PDF output and all auxiliary files. Note, that (at least for the Unix Makefiles generator)
# it is not possible to connect this process with the builtin clean target.
#
# Please note the following security restriction:
#
......@@ -101,12 +114,22 @@ find_file(LATEXMKRC_TEMPLATE
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/cmake
${CMAKE_SOURCE_DIR}/cmake/modules
NO_CMAKE_FIND_ROOT_PATH
)
# Add the clean_latex target
if(TARGET clean_latex)
message(WARNING "clean_latex target already exists. UseLatexMk attaches clean rules to it!")
else()
add_custom_target(clean_latex)
endif()
set(LATEXMK_SOURCES_BUILD_FROM)
function(add_latexmk_document)
# Parse the input parameters to the function
set(OPTION REQUIRED EXCLUDE_FROM_ALL)
set(SINGLE SOURCE TARGET)
set(OPTION REQUIRED EXCLUDE_FROM_ALL BUILD_ON_INSTALL)
set(SINGLE SOURCE TARGET INSTALL)
set(MULTI FATHER_TARGET RCFILE)
include(CMakeParseArguments)
cmake_parse_arguments(LMK "${OPTION}" "${SINGLE}" "${MULTI}" ${ARGN})
......@@ -129,6 +152,20 @@ function(add_latexmk_document)
if(LMK_FATHER_TARGET)
set(LMK_EXCLUDE_FROM_ALL TRUE)
endif()
if(LMK_BUILD_ON_INSTALL AND (NOT LMK_INSTALL))
message(WARNING "Specified to build on installation, but not installing!")
endif()
# Verify that each source is used exactly once
set(ABS_SOURCE ${LMK_SOURCE})
if(NOT IS_ABSOLUTE ${ABS_SOURCE})
get_filename_component(ABS_SOURCE ${ABS_SOURCE} ABSOLUTE)
endif()
list(FIND LATEXMK_SOURCES_BUILD_FROM ${ABS_SOURCE} ALREADY_BUILT)
if(NOT "${ALREADY_BUILT}" STREQUAL "-1")
message(FATAL_ERROR "UseLatexMk: You are building twice from the same source, which is unsupported!")
endif()
set(LATEXMK_SOURCES_BUILD_FROM ${LATEXMK_SOURCES_BUILD_FROM} ${ABS_SOURCE} PARENT_SCOPE)
# Check the existence of the latexmk executable and skip/fail if not present
if(NOT (LATEXMK_FOUND AND PDFLATEX_COMPILER))
......@@ -139,6 +176,10 @@ function(add_latexmk_document)
endif()
endif()
# Determine the output name
get_filename_component(output ${LMK_SOURCE} NAME_WE)
set(OUTPUT_PDF ${CMAKE_CURRENT_BINARY_DIR}/${output}.pdf)
# Inspect the EXCLUDE_FROM_ALL option
if(LMK_EXCLUDE_FROM_ALL)
set(ALL_OPTION "")
......@@ -165,20 +206,26 @@ function(add_latexmk_document)
# Add the BYPRODUCTS parameter, if the CMake version supports it
set(BYPRODUCTS_PARAMETER "")
if (CMAKE_VERSION VERSION_GREATER "3.2")
# Determine output PDF
get_filename_component(output ${LMK_SOURCE} NAME_WE)
set(BYPRODUCTS_PARAMETER BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/${output}.pdf)
set(BYPRODUCTS_PARAMETER BYPRODUCTS ${OUTPUT_PDF})
endif()
# Maybe allow latexmk the use of absolute paths
set(ENV_COMMAND "")
if(NOT LATEXMK_PARANOID)
set($ENV{openout_any} "a")
set(ENV_COMMAND ${CMAKE_COMMAND} -E env openout_any="a")
endif()
# Get an absolute path to the source
set(LMK_SOURCE_REPLACED ${CMAKE_CURRENT_BINARY_DIR}/${LMK_TARGET}_source.cc)
configure_file(${LMK_SOURCE} ${LMK_SOURCE_REPLACED} @ONLY)
# Call the latexmk executable
# NB: Using add_custom_target here results in the target always being outofdate.
# This offloads the dependency tracking from cmake to latexmk. This is an
# intentional decision of UseLatexMk to avoid listing dependencies of the tex source.
add_custom_target(${LMK_TARGET}
${ALL_OPTION}
COMMAND ${LATEXMK_EXECUTABLE} ${LATEXMKRC_OPTIONS} ${LMK_SOURCE}
COMMAND ${ENV_COMMAND} ${LATEXMK_EXECUTABLE} ${LATEXMKRC_OPTIONS} ${LMK_SOURCE_REPLACED}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Building PDF from ${LMK_SOURCE}..."
${BYPRODUCTS_PARAMETER}
......@@ -191,4 +238,22 @@ function(add_latexmk_document)
endif()
add_dependencies(${father} ${LMK_TARGET})
endforeach()
# Add installation rules
if(LMK_BUILD_ON_INSTALL)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} --build . --target ${LMK_TARGET} --config $<CONFIGURATION>)")
endif()
if(LMK_INSTALL)
install(FILES ${OUTPUT_PDF}
DESTINATION ${LMK_INSTALL}
OPTIONAL)
endif()
# Add a clean up rule to the clean_latex target
add_custom_target(${LMK_TARGET}_clean
COMMAND ${ENV_COMMAND} ${LATEXMK_EXECUTABLE} -C ${LATEXMKRC_OPTIONS} ${LMK_SOURCE_REPLACED}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Cleaning build results from target ${LMK_TARGET}"
)
add_dependencies(clean_latex ${LMK_TARGET}_clean)
endfunction()
File added
\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgf}
\usetikzlibrary{arrows,positioning,backgrounds,calc}
\usepackage{hyperref}
\begin{document}
\setlength{\parindent}{0pt} % Einrücken der ersten Zeile
\setlength{\parskip}{10pt} % Abstand zwischen den Absätzen
\tikzstyle{materia_blue}=[draw, fill=blue!20, text width=6.0em, text centered,
minimum height=1.5em]
\begin{tikzpicture}[transform shape]
\path node (p1) [materia_blue, text width=18em, minimum width=10em, minimum height=3em, rounded corners]{Mathematical problem\\{\scriptsize\textit{PDE problem in residual formulation}}};
\path (p1.south) + (0.0, -1.0) node (p2) [materia_blue, text width=18em, minimum width=10em, minimum height=3em, rounded corners]{UFL\\{\scriptsize\textit{Python formulation in domain specific language}}};
\path (p2.south) + (0.0, -1.0) node (p3) [materia_blue, text width=18em, minimum width=10em, minimum height=3em, rounded corners]{preprocessed UFL\\{\scriptsize\textit{Apply preprocessing from UFL with custom extensions}}};
\path (p3.south) + (0.0, -2.0) node (p4) [materia_blue, text width=18em, minimum width=10em, minimum height=3em, rounded corners]{loo.py: intermediate representation\\{\scriptsize\textit{of the loop nest for the PDE kernel}}};
\path (p4.south) + (0.0, -3.0) node (p5) [materia_blue, text width=18em, minimum width=10em, minimum height=3em, rounded corners]{C++ PDELab code\\{\scriptsize\textit{LocalOperator, driver and parameter class}}};
\path (p5.east) + (3.0, 0.0) node (p6) [materia_blue, text width=10em, minimum width=6em, minimum height=3em, rounded corners]{Vectorization Backend\\{\scriptsize\textit{VC, VCL: C++ intrisics wrapper}}};
\path (p5.south) + (0.0, -1.0) node (p7) [materia_blue, text width=18em, minimum width=6em, minimum height=3em, rounded corners]{Automated analysis and profiling\\{\scriptsize\textit{of compiled source}}};
\path (p5.west) + (-3.0, 0.0) node (p15) [materia_blue, text width=10em, minimum width=6em, minimum height=3em, rounded corners]{Dune Highlevel Backend\\{\scriptsize\textit{to grid, geometry and basis}}};
\draw[-latex] (p1.south) -- (p2.north);
\draw[-latex] (p2.south) -- (p3.north);
\draw[-latex] (p3.south) -- (p4.north);
\draw ($ (p4.north) + (0.0, -2.25) $) node[text width=18em, text centered]{transformations};
\draw ($ (p2.north) + (-6.25, -0.25) $) node[text width=18em, text centered]{Numerics};
\draw ($ (p2.north) + (6.25, -0.25) $) node[text width=18em, text centered]{Hardware};
\draw [-latex] ($ (p4.south) + (0, -0.15)$) arc [start angle=-260, end angle=80, x radius=.8cm, y radius=.8cm];
\begin{pgfonlayer}{background}
\draw[draw=black!50, rounded corners=2mm, fill = yellow!20] ($ (p4.north) + (-4.0, 0.6) $) rectangle ($ (4.0, 0.5) + (p5.north) $);
\draw[draw=black!50, rounded corners=2mm, fill = green!20] ($ (p2.north) + (-8.0, 0.0) $) rectangle ($ (-4.5, 0.5) + (p5.north) $);
\draw[draw=black!50, rounded corners=2mm, fill = red!20] ($ (p2.north) + (8.0, 0.0) $) rectangle ($ (4.5, 0.5) + (p5.north) $);
\end{pgfonlayer}
\draw[-latex] ($ (p4.south) + (-2.0, 0.0) $) -- ($ (p5.north) + (-2.0, 0.0) $);
\draw[-latex] ($ (p6.north) + (0.0, 1.0) $) -- (p6.north);
\draw[-latex] (p6.west) -- (p5.east);
\draw[-latex] (p15.east) -- (p5.west);
\draw[-latex] ($ (p15.north) + (0.0, 1.0) $) -- (p15.north);
\draw[-latex] (p5.south) -- (p7.north);
\draw[-latex] (p7.east) -- ++(0.4, 0.0) -- ++(0.0, 2.3) -- ++(-1.0,0.0) -- ++(0.0, 0.6);
\draw[-latex] ($ (4.5, 1.0) + (p5.north) $) -- ++(-1.0, 0.0);
\draw[-latex] ($ (4.5, 2.0) + (p5.north) $) -- ++(-1.0, 0.0);
\draw[-latex] ($ (4.5, 3.0) + (p5.north) $) -- ++(-1.0, 0.0);
\draw[-latex] ($ (4.5, 4.0) + (p5.north) $) -- ++(-1.0, 0.0);
\draw[-latex] ($ (-4.5, 1.0) + (p5.north) $) -- ++(1.0, 0.0);
\draw[-latex] ($ (-4.5, 2.0) + (p5.north) $) -- ++(1.0, 0.0);
\draw[-latex] ($ (-4.5, 3.0) + (p5.north) $) -- ++(1.0, 0.0);
\draw[-latex] ($ (-4.5, 4.0) + (p5.north) $) -- ++(1.0, 0.0);
\path (p2.south) + (-6.25, -0.5) node (p8) [materia_blue, text width=8em, minimum width=6em, minimum height=3em, rounded corners]{Basis structure};
\path (p8.south) + (0.0, -1.0) node (p9) [materia_blue, text width=8em, minimum width=6em, minimum height=3em, rounded corners]{Polynomial Degree};
\path (p9.south) + (0.0, -1.0) node (p10) [materia_blue, text width=8em, minimum width=6em, minimum height=3em, rounded corners]{Grid};
\path (p10.south) + (0.0, -1.0) node (p11) [materia_blue, text width=8em, minimum width=6em, minimum height=3em, rounded corners]{...};
\path (p2.south) + (6.25, -0.5) node (p12) [materia_blue, text width=8em, minimum width=6em, minimum height=3em, rounded corners]{Multithreading};
\path (p12.south) + (0.0, -1.0) node (p13) [materia_blue, text width=8em, minimum width=6em, minimum height=3em, rounded corners]{Memory bandwidth};
\path (p13.south) + (0.0, -1.0) node (p14) [materia_blue, text width=8em, minimum width=6em, minimum height=3em, rounded corners]{SIMD units};
\path (p14.south) + (0.0, -1.0) node (p16) [materia_blue, text width=8em, minimum width=6em, minimum height=3em, rounded corners]{...};
\end{tikzpicture}
\end{document}
......@@ -42,7 +42,7 @@
keywordstyle=\color{black}\bfseries, tabsize=4, stringstyle=\ttfamily,
commentstyle=\it, extendedchars=true, escapeinside={/*@}{@*/}}
\usepackage{minted}
\usepackage[outputdir=@CMAKE_CURRENT_BINARY_DIR@]{minted}
\usepackage{curves}
%\usepackage{epic}
\usepackage{calc}
......@@ -304,7 +304,7 @@
\begin{frame}
\frametitle{Form Compiler Approach}
\centering
\includegraphics[width=4.5in]{figures/approach.pdf}
\includegraphics[width=4.5in]{./figures/approach.pdf}
\end{frame}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment