Changeset View
Changeset View
Standalone View
Standalone View
cmake/build-pofiles.cmake
Show All 21 Lines | |||||
22 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
23 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
24 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
25 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
26 | # SUCH DAMAGE. | 26 | # SUCH DAMAGE. | ||
27 | 27 | | |||
28 | file(GLOB_RECURSE pofiles RELATIVE "${PO_DIR}" "${PO_DIR}/**.po") | 28 | file(GLOB_RECURSE pofiles RELATIVE "${PO_DIR}" "${PO_DIR}/**.po") | ||
29 | 29 | | |||
30 | include(ProcessorCount) | ||||
31 | ProcessorCount(numberOfProcesses) | ||||
32 | | ||||
33 | set(i 0) | ||||
34 | set(commands) | ||||
35 | | ||||
36 | function(_processCommands) | ||||
37 | if(NOT commands) | ||||
38 | return() | ||||
39 | endif() | ||||
40 | | ||||
41 | execute_process( | ||||
42 | ${commands} | ||||
43 | RESULT_VARIABLE code | ||||
44 | ) | ||||
45 | if(code) | ||||
sitter: I think `!(code EQUAL 0)` may be more explicit here. | |||||
46 | message(FATAL_ERROR "failed generating ${PO_DIR}") | ||||
47 | endif() | ||||
48 | endfunction() | ||||
49 | | ||||
30 | foreach(pofile IN LISTS pofiles) | 50 | foreach(pofile IN LISTS pofiles) | ||
31 | get_filename_component(name ${pofile} NAME) | 51 | get_filename_component(name ${pofile} NAME) | ||
32 | # Regex the basename, cmake only allows stripping the longest extension, we | 52 | # Regex the basename, cmake only allows stripping the longest extension, we | ||
33 | # need the shortest or we'll screw up "org.kde.plasma.kittens.po" | 53 | # need the shortest or we'll screw up "org.kde.plasma.kittens.po" | ||
34 | # https://bugs.kde.org/show_bug.cgi?id=379116 | 54 | # https://bugs.kde.org/show_bug.cgi?id=379116 | ||
35 | string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" name ${name}) | 55 | string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" name ${name}) | ||
36 | get_filename_component(langdir ${pofile} DIRECTORY) | 56 | get_filename_component(langdir ${pofile} DIRECTORY) | ||
37 | set(dest ${COPY_TO}/${langdir}/LC_MESSAGES) | 57 | set(dest ${COPY_TO}/${langdir}/LC_MESSAGES) | ||
38 | file(MAKE_DIRECTORY ${dest}) | 58 | file(MAKE_DIRECTORY ${dest}) | ||
39 | 59 | | |||
40 | message(STATUS "building... ${pofile} to ${name}.mo" ) | 60 | list(APPEND commands COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${dest}/${name}.mo ${PO_DIR}/${pofile}) | ||
41 | execute_process( | 61 | math(EXPR i "${i}+1") | ||
42 | COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${dest}/${name}.mo ${PO_DIR}/${pofile} | 62 | if(i EQUAL ${numberOfProcesses}) | ||
sitter: debug | |||||
43 | RESULT_VARIABLE code | 63 | _processCommands() | ||
sitter: no space after if. | |||||
44 | ) | 64 | set(i 0) | ||
sitter: debug | |||||
45 | if(code) | | |||
46 | message(FATAL_ERROR "failed at generating ${name}.mo") | | |||
47 | endif() | 65 | endif() | ||
48 | endforeach() | 66 | endforeach() | ||
67 | | ||||
68 | _processCommands() |
I think !(code EQUAL 0) may be more explicit here.