From 8ebbe99328248d45f3937c4f15f936d5d36f4a58 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 18 Feb 2008 12:17:34 +0000 Subject: FS#8482 take two. Make the language files built first, so that the largest size can be used as buffer size for languages. Work to this also contributed by Jonas Haggqvist. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16343 a1c6a512-1295-4272-9138-f99709370657 --- apps/FILES | 1 + apps/lang/Makefile | 37 +++++++++++++++++++++++++++++++++++++ apps/lang/SOURCES | 35 +++++++++++++++++++++++++++++++++++ apps/language.h | 12 +++++++++--- tools/buildzip.pl | 35 ++--------------------------------- tools/configure | 16 +++++++++++++--- tools/make.inc | 10 +++++++++- tools/makesrc.inc | 4 ++-- 8 files changed, 108 insertions(+), 42 deletions(-) diff --git a/apps/FILES b/apps/FILES index 36e3924..956b12a 100644 --- a/apps/FILES +++ b/apps/FILES @@ -41,6 +41,7 @@ codecs/Tremor/* eqs/*.cfg gui/*.[ch] keymaps/*.[ch] +lang/SOURCES lang/*.lang menus/*.[ch] metadata/*.[ch] diff --git a/apps/lang/Makefile b/apps/lang/Makefile index e69de29..bcaaa69 100644 --- a/apps/lang/Makefile +++ b/apps/lang/Makefile @@ -0,0 +1,37 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id: $ +# + +# the header we generate +HEADER = $(BUILDDIR)/max_language_size.h + +# This sets up 'SRC' based on the files mentioned in SOURCES +include $(TOOLSDIR)/makesrc.inc +SOURCES=$(SRC) + +# OUTP is the list of files to depend upon +OUTP = $(patsubst %.lang,$(OBJDIR)/%.lng, $(SOURCES)) + +# the generated file with features specified genlang-style +FEATS=$(BUILDDIR)/apps/genlang-features + +ifndef V +SILENT=@ +endif +PRINTS=$(SILENT)$(call info,$(1)) + +all: $(HEADER) + +# generic rule for creating .lng from .lang +$(OBJDIR)/%.lng : %.lang $(FEATS) + $(call PRINTS,GENLANG $<) + $(SILENT)$(TOOLSDIR)/genlang -e=$(APPSDIR)/lang/english.lang -t=$(MODELNAME)`cat $(FEATS)` -i=$(TARGET_ID) -b=$@ $< + +$(HEADER): $(OUTP) + $(call PRINTS,Make $(HEADER)) + echo "#define MAX_LANGUAGE_SIZE `du -b $(OBJDIR)/* |sort -n |tail -n 1 |cut -f 1`" > $(HEADER) diff --git a/apps/lang/SOURCES b/apps/lang/SOURCES index e69de29..af54646 100644 --- a/apps/lang/SOURCES +++ b/apps/lang/SOURCES @@ -0,0 +1,35 @@ +#ifdef HAVE_LCD_BITMAP /* Not for the Player */ +*.lang +#else +afrikaans.lang +bulgarian.lang +catala.lang +czech.lang +dansk.lang +deutsch.lang +eesti.lang +english.lang +espanol.lang +esperanto.lang +finnish.lang +francais.lang +galego.lang +greek.lang +hebrew.lang +islenska.lang +italiano.lang +magyar.lang +nederlands.lang +norsk.lang +norsk-nynorsk.lang +polski.lang +portugues-brasileiro.lang +portugues.lang +romaneste.lang +russian.lang +slovenscina.lang +svenska.lang +tagalog.lang +turkce.lang +wallisertitsch.lang +#endif /* HAVE_LCD_BITMAP */ diff --git a/apps/language.h b/apps/language.h index d8f899b..14c8084 100644 --- a/apps/language.h +++ b/apps/language.h @@ -1,3 +1,5 @@ +#ifndef __LANGUAGE_H +#define __LANGUAGE_H /*************************************************************************** * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ @@ -7,7 +9,7 @@ * \/ \/ \/ \/ \/ * $Id$ * - * Copyright (C) 2002 Daniel Stenberg + * Copyright (C) 2002, 2008 Daniel Stenberg * * All files in this archive are subject to the GNU General Public License. * See the file COPYING in the source tree root for full license agreement. @@ -17,8 +19,10 @@ * ****************************************************************************/ -/* size of the buffer used for loadable, translated strings */ -#define MAX_LANGUAGE_SIZE 23500 +/* The following header is generated by the build system and only defines + MAX_LANGUAGE_SIZE to be the size of the largest currently available + language! */ +#include "max_language_size.h" /* both these must match the two initial bytes in the binary lang file */ #define LANGUAGE_COOKIE 0x1a @@ -29,3 +33,5 @@ void lang_init(void); /* load a given language file */ int lang_load(const char *filename); + +#endif diff --git a/tools/buildzip.pl b/tools/buildzip.pl index 4c21ae8..4faa38a 100755 --- a/tools/buildzip.pl +++ b/tools/buildzip.pl @@ -154,30 +154,6 @@ sub filesize { return $size; } -sub buildlangs { - my ($outputlang)=@_; - my $dir = "$ROOT/apps/lang"; - opendir(DIR, $dir); - my @files = grep { /\.lang$/ } readdir(DIR); - closedir(DIR); - - # Exclude some bad languages (uncomment and adjust in case of release - # and/or End Times) - # @files = grep(!/(afrikaans|hindi|slovenscina|turkce)\.lang/, @files); - - # Exclude more languages on the player which won't work on charcell display - if ($archos =~ /^"?player:/ ) { - @files = grep(!/(chinese-simp|chinese-trad|hindi|japanese|korean|thai)\.lang/, @files); - } - - for(@files) { - my $output = $_; - $output =~ s/(.*)\.lang/$1.lng/; - print "$ROOT/tools/genlang -e=$dir/english.lang -t=$archos -i=$target_id -b=$outputlang/$output $dir/$_\n" if($verbose); - system ("$ROOT/tools/genlang -e=$dir/english.lang -t=$archos -i=$target_id -b=$outputlang/$output $dir/$_ >/dev/null 2>&1"); - } -} - sub buildzip { my ($zip, $image, $fonts)=@_; @@ -413,15 +389,8 @@ STOP # and the info file system("cp rockbox-info.txt .rockbox/"); - # now copy the file made for reading on the unit: - #if($notplayer) { - # `cp $webroot/docs/Help-JBR.txt .rockbox/docs/`; - #} - #else { - # `cp $webroot/docs/Help-Stu.txt .rockbox/docs/`; - #} - - buildlangs(".rockbox/langs"); + # copy the already built lng files + `cp apps/lang/*lng .rockbox/langs/` } diff --git a/tools/configure b/tools/configure index 49773e1..e1ca5be 100755 --- a/tools/configure +++ b/tools/configure @@ -1785,6 +1785,11 @@ else voicetoolset="voicefont wavtrim" fi +if test "$apps" = "apps"; then + # only when we build "real" apps we build the .lng files + buildlangs="langs" +fi + sed > Makefile \ -e "s,@ROOTDIR@,${rootdir},g" \ -e "s,@DEBUG@,${debug},g" \ @@ -1842,6 +1847,7 @@ sed > Makefile \ -e "s,@TTS_ENGINE@,${TTS_ENGINE},g" \ -e "s,@TTS_OPTS@,${TTS_OPTS},g" \ -e "s,@VOICETOOLSET@,${voicetoolset},g" \ + -e "s,@LANGS@,${buildlangs},g" \ < $(DEPFILE); \ + done | sed -e "s:[^[:space:]]*lang.h:$(OBJDIR)/lang.o:" \ + -e "s:[^[:space:]]*sysfont.h:$(BUILDDIR)/sysfont.h:" \ + -e "s:[^[:space:]]*max_language_size.h:$(BUILDDIR)/max_language_size.h:" \ + > $(DEPFILE); \ echo "oo" > /dev/null ) tags: diff --git a/tools/makesrc.inc b/tools/makesrc.inc index 78d97f3..846df8c 100644 --- a/tools/makesrc.inc +++ b/tools/makesrc.inc @@ -10,5 +10,5 @@ # to make this do right when used on Mac OS X. SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) \ -$(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - | \ -grep -v "^\#") +$(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - 2>/dev/null \ +| grep -v "^\#") -- cgit v1.1