build: embed lmo in the build process
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 9 Jul 2009 15:05:02 +0000 (15:05 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 9 Jul 2009 15:05:02 +0000 (15:05 +0000)
Makefile
build/i18n-po2lua.pl
build/module.mk
contrib/package/luci/Makefile

index 13438848ed138d911935fff3c6dc225395bdc68e..775820cb1b43022de83299188099dfe3590524c1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,7 @@ all: build
 build: gccbuild luabuild
 
 gccbuild:
+       make -C libs/lmo CC="cc" CFLAGS="" LDFLAGS="" host-install
        for i in $(MODULES); do \
                make -C$$i compile || { \
                        echo "*** Compilation of $$i failed!"; \
@@ -27,7 +28,7 @@ i18nbuild:
        ./build/i18n-po2lua.pl ./po host/lua-po
 
 clean:
-       rm -rf docs
+       make -C libs/lmo host-clean
        for i in $(MODULES); do make -C$$i clean; done
 
 
index c57198fd5cdf515178d28198262e03797dd890fb..5129055ffbd1bd33b86f371f524799b294e27ce1 100755 (executable)
@@ -10,67 +10,17 @@ if( ! -d $target_dir )
        system('mkdir', '-p', $target_dir);
 }
 
-
-my %target_strings;
-
-
 if( open F, "find $source_dir -type f -name '*.po' |" )
 {
        while( chomp( my $file = readline F ) )
        {
-               if( open L, "< $file" )
-               {
-                       my $content = 0;
-                       my ( $lang, $basename ) = $file =~ m{.+/(\w+)/([^/]+)\.po$};
-                       $lang = lc $lang;
-                       $lang =~ s/_/-/g;
-                       
-                       if( open D, "> $target_dir/$basename.$lang.lua" )
-                       {
-                               printf "Generating %-40s ", "$target_dir/$basename.$lang.lua";
-
-                               my ( $k, $v );
-
-                               while( chomp( my $line = readline L ) || ( defined($k) && defined($v) ) )
-                               {
-                                       if( $line =~ /^msgid "(.+)"/ )
-                                       {
-                                               $k = $1;
-                                       }
-                                       elsif( $k && $line =~ /^msgstr "(.*)"/ )
-                                       {
-                                               $v = $1;
-                                       }
-                                       elsif( $k && defined($v) && $line =~ /^"(.+)"/ )
-                                       {
-                                               $v .= $1;
-                                       }
-                                       else
-                                       {
-                                               if( $k && defined($v) && length($v) > 0 )
-                                               {
-                                                       $v =~ s/\\(['"\\])/$1/g;
-                                                       $v =~ s/(['\\])/\\$1/g;
-
-                                                       printf D "%s='%s'\n", $k, $v;
-                                                       $content++;
-                                               }
-               
-                                               $k = $v = undef;
-                                       }
-                               }
-
-                               print $content ? "done ($content strings)\n" : "empty\n";
-
-                               close D;
-
-
-                               unlink("$target_dir/$basename.$lang.lua")
-                                       unless( $content > 0 );
-                       }
+               my ( $lang, $basename ) = $file =~ m{.+/(\w+)/([^/]+)\.po$};
+               $lang = lc $lang;
+               $lang =~ s/_/-/g;
 
-                       close L;
-               }
+               printf "Generating %-40s ", "$target_dir/$basename.$lang.lmo";
+               system("./build/po2lmo", $file, "$target_dir/$basename.$lang.lmo");
+               print ( -f "$target_dir/$basename.$lang.lmo" ? "done\n" : "empty\n" );
        }
 
        close F;
index 569de101d63a879a5ad4976c376b698ee7b58289..8d64d6bb412a11398f828f80c53c90e3510cd621 100644 (file)
@@ -27,7 +27,7 @@ luasource:
   ifneq ($(PO),)
        mkdir -p dist$(LUCI_I18NDIR)
        for file in $(PO); do \
-         cp $(HOST)/lua-po/$$file.$(if $(PO_LANG),$(PO_LANG),*).lua dist$(LUCI_I18NDIR)/ 2>/dev/null || true; \
+         cp $(HOST)/lua-po/$$file.$(if $(PO_LANG),$(PO_LANG),*).* dist$(LUCI_I18NDIR)/ 2>/dev/null || true; \
        done
   endif
 
index 22e233a81fb93b3b90575632e72740a35f0cfe88..41d6bab32a45a0c4c174570e127b4b99a799ca26 100644 (file)
@@ -215,6 +215,16 @@ define Package/luci-json/install
 endef
 
 
+define Package/luci-lmo
+  $(call Package/luci/libtemplate)
+  TITLE:=lmo
+endef
+
+define Package/luci-lmo/install
+       $(call Package/luci/install/template,$(1),libs/lmo)
+endef
+
+
 define Package/luci-luanet
   $(call Package/luci/libtemplate)
   TITLE:=luanet
@@ -302,7 +312,7 @@ endef
 
 define Package/luci-web
   $(call Package/luci/libtemplate)
-  DEPENDS+=+luci-http +luci-sys +luci-uci +luci-lucid +luci-sgi-cgi
+  DEPENDS+=+luci-http +luci-sys +luci-uci +luci-lucid +luci-sgi-cgi +luci-lmo
   TITLE:=MVC Webframework
   $(call Config,luci.main.lang,string,en,Default Language)
 endef
@@ -889,6 +899,9 @@ endif
 ifneq ($(CONFIG_PACKAGE_luci-json),)
        PKG_SELECTED_MODULES+=libs/json
 endif
+ifneq ($(CONFIG_PACKAGE_luci-lmo),)
+       PKG_SELECTED_MODULES+=libs/lmo
+endif
 ifneq ($(CONFIG_PACKAGE_luci-luanet),)
        PKG_SELECTED_MODULES+=libs/luanet
 endif
@@ -1082,6 +1095,7 @@ $(eval $(call BuildPackage,luci-http))
 $(eval $(call BuildPackage,luci-httpclient))
 $(eval $(call BuildPackage,luci-ipkg))
 $(eval $(call BuildPackage,luci-json))
+$(eval $(call BuildPackage,luci-lmo))
 $(eval $(call BuildPackage,luci-luanet))
 $(eval $(call BuildPackage,luci-lucid))
 $(eval $(call BuildPackage,luci-nixio))