2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-12 12:02:24 +00:00

Gettext improvements. Allow main target in sources for 'gettext.update'

rule. Improve 'stage' target to help installting gettext files.


[SVN r18903]
This commit is contained in:
Vladimir Prus
2003-07-01 11:48:53 +00:00
parent 03e377c4a1
commit 950d24ffce
2 changed files with 71 additions and 18 deletions

View File

@@ -16,7 +16,7 @@
# - Decide on a file name which will contain translations and
# what main target name will be used to update it. For example::
#
# gettext.update update-russian : russian.po a.cpp b.cpp ;
# gettext.update update-russian : russian.po a.cpp my_app ;
#
# - Create the initial translation file by running
#
@@ -54,6 +54,7 @@ import generators ;
import errors ;
import feature : feature ;
import toolset : flags ;
import regex ;
.path = "" ;
@@ -75,18 +76,22 @@ rule init ( path ? # Path where all tools are located. If not specified,
# Creates a main target 'name', which, when updated, will cause
# file 'existing-translation' to be updated with translations
# extracted from 'sources' --- which, for now, must be names
# of source files.
# extracted from 'sources'. It's possible to specify main target
# in sources --- it which case all target from dependency graph
# of those main targets will be scanned, provided they are of
# appropricate type. The 'gettext.types' feature can be used to
# control the types.
#
# The target will be updated only if explicitly requested on the
# command line.
rule update ( name : existing-translation sources + )
rule update ( name : existing-translation sources + : requirements * )
{
local project = [ CALLER_MODULE ] ;
targets.main-target-alternative
[ new update-translations-class $(name) : $(project) :
$(existing-translation) $(sources)
: [ targets.main-target-requirements $(requirements) : $(project) ]
] ;
local project-target = [ project.target $(project) ] ;
$(project-target).mark-target-as-explicit $(name) ;
@@ -101,34 +106,71 @@ type.register gettext.catalog : mo : : main ;
# sources.
type.register gettext.POT : pot ;
# Identifies the keyword that should be used when scanning sources.
# Default: i18n
feature gettext.keyword : : free ;
# Contains space-separated list of sources types which should be scanned.
# Default: "C CPP"
feature gettext.types : : free ;
generators.register-standard gettext.compile : gettext.PO : gettext.catalog ;
rule update-translations-class ( name : project : sources * )
rule update-translations-class ( name : project : sources * : requirements )
{
basic-target.__init__ $(name) : $(project) : $(sources) : $(requirements)
: $(default-build) ;
IMPORT gettext : regex.split : $(__name__) : regex.split ;
rule construct ( source-targets * : property-set )
{
local types = [ $(property-set).get <gettext.types> ] ;
types ?= "C CPP" ;
types = [ regex.split $(types) " " ] ;
property-set = [ property-set.empty ] ;
if ! $(.constructed)
{
local new-messages = [ new file-target $(self.name) : gettext.POT : $(self.project) ] ;
local extract =
[ new action $(new-messages) : $(source-targets[2-]) : gettext.extract ] ;
$(new-messages).action $(extract) ;
# First deterime the list of sources that must be scanned to
# messages.
local all-sources ;
for local s in $(source-targets[2-])
{
all-sources += [ virtual-target.traverse $(s) : : include-sources ] ;
}
local right-sources ;
for local s in $(all-sources)
{
if [ $(s).type ] in $(types)
{
right-sources += $(s) ;
}
}
local r = [ new notfile-target $(self.name) : $(self.project) ] ;
local a = [ new action $(r) : $(source-targets[1]) $(new-messages)
: gettext.update-po-dispatch ] ;
$(r).action $(a) ;
.constructed = [ virtual-target.register $(r) ] ;
if $(right-sources)
{
local new-messages = [ new file-target $(self.name) : gettext.POT : $(self.project) ] ;
local extract =
[ new action $(new-messages) : $(right-sources) : gettext.extract ] ;
$(new-messages).action $(extract) ;
local r = [ new notfile-target $(self.name) : $(self.project) ] ;
local a = [ new action $(r) : $(source-targets[1]) $(new-messages)
: gettext.update-po-dispatch ] ;
$(r).action $(a) ;
.constructed = [ virtual-target.register $(r) ] ;
}
else
{
errors.error "No source could be scanned by gettext tools" ;
}
}
return $(.constructed) ;
}
rule check-for-unused-sources ( result * : sources * )
{
}
}
class update-translations-class : basic-target ;
@@ -147,7 +189,7 @@ actions extract
# When file to be updated does not exist (during the
# first run), we need to copy the file created from sources.
# In all other cases, we need to update the file.
local rule update-po-dispatch
rule update-po-dispatch
{
NOCARE $(>[1]) ;
gettext.create-po $(<) : $(>) ;
@@ -167,9 +209,9 @@ actions quietly existing updated create-po bind EXISTING_PO
cp$(_)"$(>[1])"$(_)"$(EXISTING_PO)"$($(>[2]:E=ok))
}
actions updated update-po
actions updated update-po bind EXISTING_PO
{
$(.path)msgmerge$(_)-U$(_)"$(>[1])"$(_)"$(>[2])"
$(.path)msgmerge$(_)-U$(_)"$(EXISTING_PO)"$(_)"$(>[1])"
}
actions gettext.compile

View File

@@ -37,6 +37,12 @@ rule stage-target-class ( name-and-dir : project : sources * : requirements * :
rule construct ( source-targets * : property-set )
{
local name = [ $(property-set).get <name> ] ;
if $(name) && $(source-targets[2])
{
errors.error "<name> property cannot be specified when staging several targets" ;
}
local location = [ feature.get-values <location> :
[ $(property-set).raw ] ] ;
if ! $(location)
@@ -65,7 +71,12 @@ rule stage-target-class ( name-and-dir : project : sources * : requirements * :
}
else
{
local n = [ $(i).name ] ;
local n = [ $(i).name ] ;
if $(name)
{
n = $(name) ;
}
i2 = [ new file-target $(n:D=) : [ $(i).type ]
: $(self.project) ] ;
local a = [ new action $(i2) : $(i) : common.copy ] ;