diff options
author | Michael Meeks <michael.meeks@suse.com> | 2013-05-13 13:53:05 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-05-15 09:37:41 +0100 |
commit | 99f7690bee0bf787a579e3e28bbd63074000940e (patch) | |
tree | cb4d74802d3851ebbf45c6393fe54406e7b3580b /solenv | |
parent | 19276d3ddffdc80f004c8ce518b80f063108935b (diff) |
gallery: cleanup makefiles for new gallery naming and translation.
Change-Id: I9ec5192c007df6d0ce15f5e61cb53cf6ea04db08
Diffstat (limited to 'solenv')
-rw-r--r-- | solenv/bin/desktop-translate.pl | 16 | ||||
-rw-r--r-- | solenv/gbuild/Gallery.mk | 55 |
2 files changed, 51 insertions, 20 deletions
diff --git a/solenv/bin/desktop-translate.pl b/solenv/bin/desktop-translate.pl index 245ebaf5f279..21d80ab91a76 100644 --- a/solenv/bin/desktop-translate.pl +++ b/solenv/bin/desktop-translate.pl @@ -29,6 +29,7 @@ eval 'exec perl -wS $0 ${1+"$@"}' my ($prefix, $ext, $key); my $productname = "LibreOffice"; my $workdir = "."; +my $template_dir; while ($_ = $ARGV[0], /^-/) { shift; @@ -53,6 +54,14 @@ while ($_ = $ARGV[0], /^-/) { $ext = $ARGV[0]; shift; } + if (/^--template-dir/) { + $template_dir = $ARGV[0]; + shift; + } +} + +if (!defined $template_dir) { + $template_dir = "$workdir/$prefix"; } # hack for unity section @@ -65,8 +74,7 @@ my %templates; # open input file unless (open(SOURCE, $ARGV[0])) { - print STDERR "Can't open $ARGV[0] file: $!\n"; - return; + die "Can't open $ARGV[0] file: $!\n"; } # currently read template @@ -81,7 +89,7 @@ while (<SOURCE>) { my %entry; # For every section in the specified ulf file there should exist # a template file in $workdir .. - $entry{'outfile'} = "$workdir/$prefix$template.$ext"; + $entry{'outfile'} = "$template_dir$template.$ext"; my %translations; $entry{'translations'} = \%translations; $templates{$template} = \%entry; @@ -115,7 +123,7 @@ foreach $template (keys %templates) { # open the template file - ignore sections for which no # templates exist unless(open(TEMPLATE, $outfile)) { - print STDERR "Warning: No template found for item $_: $outfile: $!\n"; + print STDERR "Warning: No template found for item '$template' : '$outfile' : '$_': $!\n"; exit -1; } diff --git a/solenv/gbuild/Gallery.mk b/solenv/gbuild/Gallery.mk index 28a8f00a3591..0e3f84b1dd55 100644 --- a/solenv/gbuild/Gallery.mk +++ b/solenv/gbuild/Gallery.mk @@ -30,6 +30,8 @@ gb_Gallery__UNO_TYPES := \ offapi \ udkapi +gb_Gallery_TRANSLATE := $(SOLARENV)/bin/desktop-translate.pl + # TODO: this should be in RepositoryExternal.mk, but it would lead to # duplication. Fix. gb_Gallery_EXTRA_DEPENCENCIES := \ @@ -93,15 +95,6 @@ $(call gb_Gallery_get_clean_target,%) : $(call gb_Gallery_get_workdir,$*) \ ) -$(WORKDIR)/Gallery/%.sdv : - touch $@ - -$(WORKDIR)/Gallery/%.thm : - touch $@ - -$(WORKDIR)/Gallery/%.sdg : - touch $@ - gb_Gallery_get_packagename = Gallery/$(1) # Create a gallery. @@ -115,21 +108,26 @@ $(call gb_Gallery__Gallery_impl,$(1),$(call gb_Gallery_get_packagename,$(1)),$(2 endef + +gb_Gallery_basedir = $(patsubst %/,%,$(dir $(SRCDIR)/$(1))) + # gb_Gallery__Gallery_impl gallery package basedir name define gb_Gallery__Gallery_impl $(call gb_Package_Package_internal,$(2),$(call gb_Gallery_get_workdir,$(1))) $(call gb_Package_set_outdir,$(2),$(INSTDIR)) -$(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).sdg,sg1.sdg) -$(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).sdv,sg1.sdv) -$(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).thm,sg1.thm) +$(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).sdg,$(1).sdg) +$(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).sdv,$(1).sdv) +$(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).thm,$(1).thm) +$(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).str,$(1).str) # strip URL, without / to help the internal gallery system -$(call gb_Gallery_get_target,$(1)) : GALLERY_BASEDIR := $(patsubst %/,%,$(call gb_Helper_make_url,$(dir $(SRCDIR)/$(3)))) +$(call gb_Gallery_get_target,$(1)) : GALLERY_BASEDIR := $(call gb_Helper_make_url,$(call gb_Gallery_basedir,$(3))) $(call gb_Gallery_get_target,$(1)) : GALLERY_FILES := -$(call gb_Gallery_get_target,$(1)) : GALLERY_NAME := $(4) +$(call gb_Gallery_get_target,$(1)) : GALLERY_NAME := $(1) -$(call gb_Gallery_get_workdir,$(1))/sg1.sdv \ -$(call gb_Gallery_get_workdir,$(1))/sg1.thm : $(call gb_Gallery_get_target,$(1)) +$(call gb_Gallery_get_workdir,$(1))/$(1).sdg \ +$(call gb_Gallery_get_workdir,$(1))/$(1).sdv \ +$(call gb_Gallery_get_workdir,$(1))/$(1).thm : $(call gb_Gallery_get_target,$(1)) $(call gb_Gallery__get_final_target,$(1)) : $(call gb_Package_get_target,$(2)) $(call gb_Gallery_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(2)) $(call gb_Gallery_get_target,$(1)) :| $(dir $(call gb_Gallery_get_target,$(1))).dir \ @@ -138,6 +136,31 @@ $(call gb_Gallery_get_target,$(1)) :| $(dir $(call gb_Gallery_get_target,$(1))). $$(eval $$(call gb_Module_register_target,$(call gb_Gallery__get_final_target,$(1)),$(call gb_Gallery_get_clean_target,$(1)))) $(call gb_Helper_make_userfriendly_targets,$(1),Gallery,$(call gb_Gallery__get_final_target,$(1))) + +# this should probably be done with more general rules: but how ? +ifneq ($(WITH_LANG),) +$$(call gb_Gallery_get_workdir,$(1))/$(1).ulf : \ + $$(call gb_Gallery_basedir,$(3))/share/gallery_names.ulf | $$(call gb_Executable_get_runtime_dependencies,ulfex) \ + $(call gb_Gallery_get_target,$(1)) # that rule pre-cleans our output directory + $$(call gb_Output_announce,$@,$(true),SUM,1) + MERGEINPUT=`$(gb_MKTEMP)` && \ + echo $(foreach lang,$(gb_TRANS_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(3))).po) > $$$${MERGEINPUT} && \ + $(call gb_Helper_abbreviate_dirs,\ + $$(call gb_Executable_get_command,ulfex) -i $$< -o $$@ -m $$$${MERGEINPUT} -l all ) && \ + rm -rf $$$${MERGEINPUT} +else +$$(call gb_Gallery_get_workdir,$(1))/$(1).ulf : $$(call gb_Gallery_basedir,$(3))/share/gallery_names.ulf + cp $< $@ +endif + +$(call gb_Gallery_get_workdir,$(1))/$(1).str : $(gb_Gallery_TRANSLATE) \ + $$(call gb_Gallery_get_workdir,$(1))/$(1).ulf + cp -f $(SRCDIR)/$(3)/$(1).str $(call gb_Gallery_get_workdir,$(1))/$(1).str && \ + $(PERL) $(gb_Gallery_TRANSLATE) -d $(WORKDIR)/$* \ + --ext "str" --key "name" \ + --template-dir $$(call gb_Gallery_get_workdir,$(1))/ \ + $$(call gb_Gallery_get_workdir,$(1))/$(1).ulf + endef # Add a file to the gallery. |