On Tue, Jun 02, 2009 at 04:49:09PM +0100, Stuart Henderson wrote:
> - CJK font tables use loads of compiler memory (500M+ even
> with -O0); skip them on arch with fewer resources so they
> actually build
I found another approach for the compilation of resources.
Instead of generating a C file containing files as hex dumps, I generate an
assembly file with a .incbin directive.
As a result, the compilation of the fonts doesn't need this huge amount of
resources anymore.
I only have i386 to play with, so I don't know if generated assembly is
portable. At least it works under OpenBSD and mingw on i386.
attached:
patch-mupdf_Jamfile : to place in the port's "patch" folder
fontres.c : to move to ${WRKSRC}/mupdf/
I'll send a patch upstream, but I'd like to ensure portability here before.
>
> tested on i386, amd64.
>
> builds on sparc64 and arm, but mine are headless and mupdf
> tries to do SHM so I can't test them.
couldn't you use a remote display ?
also, concerning this port, I suggest to delete the _darcs/ folder from the
rolled tarball ( 15.2M !!! ), and to remove fontdump and cmapdump from PLIST as
they only are needed during the build process.
$OpenBSD$
--- mupdf/Jamfile.orig Mon Jun 1 04:26:01 2009
+++ mupdf/Jamfile Thu Jun 18 13:33:42 2009
@@ -4,7 +4,7 @@
SubDir TOP mupdf ;
-Main fontdump : fontdump.c ;
+Main fontres : fontres.c ;
Main cmapdump : cmapdump.c ;
LinkLibraries cmapdump : libfitz ;
@@ -167,27 +167,27 @@ Library libcmaps : cmap_korean.c ;
SubDir TOP fonts ;
-GenFile font_misc.c : fontdump
+GenFile font_misc.s : fontres
Dingbats.cff
StandardSymL.cff
URWChanceryL-MediItal.cff
;
-GenFile font_mono.c : fontdump
+GenFile font_mono.s : fontres
NimbusMonL-Regu.cff
NimbusMonL-ReguObli.cff
NimbusMonL-Bold.cff
NimbusMonL-BoldObli.cff
;
-GenFile font_serif.c : fontdump
+GenFile font_serif.s : fontres
NimbusRomNo9L-Regu.cff
NimbusRomNo9L-ReguItal.cff
NimbusRomNo9L-Medi.cff
NimbusRomNo9L-MediItal.cff
;
-GenFile font_sans.c : fontdump
+GenFile font_sans.s : fontres
NimbusSanL-Bold.cff
NimbusSanL-BoldItal.cff
NimbusSanL-Regu.cff
@@ -195,17 +195,17 @@ GenFile font_sans.c : fontdump
;
Library libfonts :
- font_misc.c
- font_mono.c
- font_serif.c
- font_sans.c
+ font_misc.s
+ font_mono.s
+ font_serif.s
+ font_sans.s
;
if ! ( NOCJK in $(DEFINES) )
{
SubDir TOP fonts droid ;
- GenFile font_cjk.c : fontdump DroidSansFallback.ttf ;
- Library libfonts : font_cjk.c ;
+ GenFile font_cjk.s : fontres DroidSansFallback.ttf ;
+ Library libfonts : font_cjk.s ;
}
/*
* Copyright (c) 2009 Roberto Fernandez
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
int
main(int argc, char **argv)
{
FILE *fi, *fo;
char name[256], *basename, *p;
int i;
long len;
if (argc < 3)
{
fprintf(stderr, "usage: %s output.s input.dat [input2.dat
...]\n",
argv[0]);
return 1;
}
fo = fopen(argv[1], "wb");
if (!fo)
{
fprintf(stderr, "%s: could not open output file \"%s\"\n",
argv[0], argv[1]);
return 1;
}
for (i = 2; i < argc; i++)
{
fi = fopen(argv[i], "rb");
if (!fi)
{
fprintf(stderr, "%s: could not open input file
\"%s\"\n",
argv[0], argv[i]);
return 1;
}
basename = strrchr(argv[i], '/');
#ifdef WIN32
if (!basename)
basename = strrchr(argv[i], '\\');
#endif
if (basename)
basename++;
else
basename = argv[i];
#ifdef WIN32
strncpy(name, "_pdf_font_", 255);
strncat(name, basename, 245);
#else
strncpy(name, "pdf_font_", 255);
strncat(name, basename, 246);
#endif
p = name;
while (*p)
{
if ((*p == '/') || (*p == '.') || (*p == '\\') || (*p
== '-'))
*p = '_';
p ++;
}
fseek(fi, 0, SEEK_END);
len = ftell(fi);
fprintf(fo, ".globl %s_buf\n", name);
fprintf(fo, ".align 32\n");
fprintf(fo, "%s_buf:\n", name);
fprintf(fo, ".incbin \"%s\"\n\n", argv[i]);
fprintf(fo, ".globl %s_len\n", name);
fprintf(fo, ".align 4\n");
fprintf(fo, "%s_len:\n", name);
fprintf(fo, ".long %d\n\n\n", len);
fclose(fi);
}
return 0;
}