Skip to content

Commit

Permalink
run gperf via wsl in wsl-as-helper case
Browse files Browse the repository at this point in the history
also split up the gperf commands when generating sw/generated/tokens.cxx

wsl has trouble appending using shell redirects, so use separate targets
and use cat in the final processing step for tokens.cxx
see also microsoft/WSL#4400

Change-Id: Id7a24d060e9be71113ec2827a389d347456f6522
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166338
Reviewed-by: Christian Lohmaier <[email protected]>
Tested-by: Jenkins
  • Loading branch information
cloph committed Apr 26, 2024
1 parent f7c5dd5 commit b87da3e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion editeng/CustomTarget_generated.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $(editeng_INC)/tokens.hxx $(editeng_INC)/tokens.gperf : $(editeng_SRC)/tokens.tx
$(call gb_ExternalExecutable_get_command,python) $(editeng_PY) $(editeng_SRC)/tokens.txt $(editeng_INC)/tokens.gperf

$(editeng_INC)/tokens.cxx : $(editeng_INC)/tokens.gperf
$(GPERF) --compare-strncmp --readonly-tables $(editeng_INC)/tokens.gperf \
$(call gb_Helper_wsl_path,$(GPERF) --compare-strncmp --readonly-tables $(editeng_INC)/tokens.gperf) \
| sed -e '/^#line/d' -e 's/(char\*)0/(char\*)0, XML_TOKEN_INVALID/g' > $@

$(call gb_CustomTarget_get_target,editeng/generated) : $(editeng_INC)/tokens.cxx
Expand Down
6 changes: 3 additions & 3 deletions filter/CustomTarget_svg.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ $(filter_GEN_svg_Tokens_hxx) : $(filter_GEN_svg_Tokens_gperf)

$(filter_GEN_svg_Tokens_cxx) : $(filter_GEN_svg_Tokens_gperf)
$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,GPF,1)
$(call gb_Helper_abbreviate_dirs, \
$(GPERF) --compare-strncmp -C -m 20 --switch=2 --readonly-tables $(filter_GEN_svg_Tokens_gperf) \
| sed -e '/^#line/d' -e 's/(char\*)0/(char\*)0$(COMMA) 0/g' > $@)
$(call gb_Helper_wsl_path,\
$(GPERF) --compare-strncmp -C -m 20 --switch=2 --readonly-tables $(filter_GEN_svg_Tokens_gperf)) \
| sed -e '/^#line/d' -e 's/(char\*)0/(char\*)0, 0/g' > $@

$(filter_GEN_svg_Script_hxx) : \
$(call gb_ExternalExecutable_get_dependencies,python) \
Expand Down
2 changes: 1 addition & 1 deletion sdext/CustomTarget_pdfimport.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $(call gb_CustomTarget_get_workdir,sdext/pdfimport)/hash.cxx : \
| $(call gb_CustomTarget_get_workdir,sdext/pdfimport)/.dir
$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),GPF,1)
$(call gb_Trace_StartRange,$(subst $(WORKDIR)/,,$@),GPF)
$(GPERF) -C -t -l -L C++ -m 20 --switch=2 --readonly-tables -Z PdfKeywordHash -k'4-5,$$' $< > $@
$(call gb_Helper_wsl_path,$(GPERF) -C -t -l -L C++ -m 20 --switch=2 --readonly-tables -Z PdfKeywordHash -k'4-5$(COMMA)$$' $<) > $@
$(call gb_Trace_EndRange,$(subst $(WORKDIR)/,,$@),GPF)

# vim:set shiftwidth=4 tabstop=4 noexpandtab:
2 changes: 1 addition & 1 deletion solenv/gbuild/CustomTarget.mk
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ define gb_CustomTarget_token_hash
$(call gb_CustomTarget_get_target,$(1)) : $(call gb_CustomTarget_get_workdir,$(1))/$(2)
$(call gb_CustomTarget_get_workdir,$(1))/$(2) : $(call gb_CustomTarget_get_workdir,$(1))/misc/$(3)
$$(call gb_Output_announce,$$(subst $(WORKDIR)/,,$$@),build,GPF,1)
$(GPERF) --compare-strncmp --switch=2 --readonly-tables $$< \
$$(call gb_Helper_wsl_path,$(GPERF) --compare-strncmp --switch=2 --readonly-tables $$<) \
| sed -e '/^#line/d' -e 's/(char\*)0/(char\*)0, 0/g' > $$@

endef
Expand Down
34 changes: 19 additions & 15 deletions sw/CustomTarget_generated.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,26 @@ sw_SRC := $(SRCDIR)/sw/source/core/swg
sw_PY := $(SRCDIR)/solenv/bin/gentoken.py
sw_INC := $(call gb_CustomTarget_get_workdir,sw/generated)

$(sw_INC)/TextBlockTokens.gperf : $(sw_SRC)/TextBlockTokens.txt $(sw_PY) \
$(call gb_ExternalExecutable_get_dependencies,python)
mkdir -p $(sw_INC)
$(call gb_ExternalExecutable_get_command,python) $(sw_PY) $(sw_SRC)/TextBlockTokens.txt $(sw_INC)/TextBlockTokens.gperf

$(sw_INC)/BlockListTokens.gperf : $(sw_SRC)/BlockListTokens.txt $(sw_PY) \
$(call gb_ExternalExecutable_get_dependencies,python)
mkdir -p $(sw_INC)
$(call gb_ExternalExecutable_get_command,python) $(sw_PY) $(sw_SRC)/BlockListTokens.txt $(sw_INC)/BlockListTokens.gperf

$(sw_INC)/tokens.cxx : $(sw_INC)/TextBlockTokens.gperf $(sw_INC)/BlockListTokens.gperf
$(GPERF) --compare-strncmp --readonly-tables --output-file=$(sw_INC)/tokens.cxx \
--class-name=TextBlockTokens --word-array-name=textBlockList --enum $(sw_INC)/TextBlockTokens.gperf
# static pattern rule
$(sw_INC)/TextBlockTokens.gperf \
$(sw_INC)/BlockListTokens.gperf : $(sw_INC)/%.gperf : $(sw_SRC)/%.txt $(sw_PY) \
| $(call gb_ExternalExecutable_get_dependencies,python)
mkdir -p $(@D)
$(call gb_ExternalExecutable_get_command,python) $(sw_PY) $< $@

# appending when wrapping with wsl.exe is broken, will always replace from start instead of add
# https://github.com/microsoft/WSL/issues/4400 so create them as separate intermediates
$(sw_INC)/TextBlockTokens.processed : $(sw_INC)/TextBlockTokens.gperf
$(GPERF) --compare-strncmp --readonly-tables --class-name=TextBlockTokens \
--word-array-name=textBlockList --enum $(sw_INC)/TextBlockTokens.gperf > $@

$(sw_INC)/BlockListTokens.processed : $(sw_INC)/BlockListTokens.gperf
$(GPERF) --compare-strncmp --readonly-tables -T $(sw_INC)/BlockListTokens.gperf \
--class-name=BlockListTokens --word-array-name=blockListList >> $(sw_INC)/tokens.cxx
sed -i $(if $(filter MACOSX,$(OS_FOR_BUILD)),'') -e '/^#line/d' -e 's/(char\*)0/(char\*)0, XML_TOKEN_INVALID/g' $(sw_INC)/tokens.cxx
--class-name=BlockListTokens --word-array-name=blockListList > $@

$(sw_INC)/tokens.cxx : sw_INC:=$(call gb_Helper_wsl_path,$(sw_INC))
$(sw_INC)/tokens.cxx : $(sw_INC)/TextBlockTokens.processed $(sw_INC)/BlockListTokens.processed
sed -e '/^#line/d' -e 's/(char\*)0/(char\*)0, XML_TOKEN_INVALID/g' $^ > $@

$(call gb_CustomTarget_get_target,sw/generated) : $(sw_INC)/tokens.cxx

Expand Down

0 comments on commit b87da3e

Please sign in to comment.