ICU-360 pkgdata tool
X-SVN-Rev: 1618
This commit is contained in:
parent
965c217c57
commit
cd30713a6b
6
icu4c/source/configure
vendored
6
icu4c/source/configure
vendored
@ -3088,10 +3088,11 @@ ac_given_srcdir=$srcdir
|
||||
ac_given_INSTALL="$INSTALL"
|
||||
|
||||
trap 'rm -fr `echo "Makefile \
|
||||
common/Makefile config/Makefile i18n/Makefile \
|
||||
common/Makefile config/Makefile.inc i18n/Makefile \
|
||||
extra/Makefile extra/ustdio/Makefile \
|
||||
tools/Makefile tools/ctestfw/Makefile tools/makeconv/Makefile \
|
||||
tools/genrb/Makefile tools/gencol/Makefile \
|
||||
tools/pkgdata/Makefile tools/icupkg.inc \
|
||||
tools/rbdump/Makefile tools/genccode/Makefile tools/gencmn/Makefile tools/gencnval/Makefile tools/gentz/Makefile \
|
||||
tools/gennames/Makefile tools/toolutil/Makefile tools/gentest/Makefile tools/genprops/Makefile \
|
||||
test/Makefile test/intltest/Makefile test/cintltst/Makefile \
|
||||
@ -3222,10 +3223,11 @@ EOF
|
||||
cat >> $CONFIG_STATUS <<EOF
|
||||
|
||||
CONFIG_FILES=\${CONFIG_FILES-"Makefile \
|
||||
common/Makefile config/Makefile i18n/Makefile \
|
||||
common/Makefile config/Makefile.inc i18n/Makefile \
|
||||
extra/Makefile extra/ustdio/Makefile \
|
||||
tools/Makefile tools/ctestfw/Makefile tools/makeconv/Makefile \
|
||||
tools/genrb/Makefile tools/gencol/Makefile \
|
||||
tools/pkgdata/Makefile tools/icupkg.inc \
|
||||
tools/rbdump/Makefile tools/genccode/Makefile tools/gencmn/Makefile tools/gencnval/Makefile tools/gentz/Makefile \
|
||||
tools/gennames/Makefile tools/toolutil/Makefile tools/gentest/Makefile tools/genprops/Makefile \
|
||||
test/Makefile test/intltest/Makefile test/cintltst/Makefile \
|
||||
|
@ -461,6 +461,7 @@ AC_OUTPUT([Makefile \
|
||||
extra/Makefile extra/ustdio/Makefile \
|
||||
tools/Makefile tools/ctestfw/Makefile tools/makeconv/Makefile \
|
||||
tools/genrb/Makefile tools/gencol/Makefile \
|
||||
tools/pkgdata/Makefile tools/icupkg.inc \
|
||||
tools/rbdump/Makefile tools/genccode/Makefile tools/gencmn/Makefile tools/gencnval/Makefile tools/gentz/Makefile \
|
||||
tools/gennames/Makefile tools/toolutil/Makefile tools/gentest/Makefile tools/genprops/Makefile \
|
||||
test/Makefile test/intltest/Makefile test/cintltst/Makefile \
|
||||
|
@ -36,8 +36,19 @@ pkgincludedir = $(includedir)/@PACKAGE@
|
||||
top_builddir = ..
|
||||
subdir = tools
|
||||
|
||||
## Type of build
|
||||
@USE_MAPPED_TRUE@ DEFAULT_MODE=common
|
||||
@USE_MAPPED_FALSE@ DEFAULT_MODE=dll
|
||||
|
||||
## Allow overriding of package build mode
|
||||
ifeq ($(strip $(MODE)),)
|
||||
MODE=$(DEFAULT_MODE)
|
||||
endif
|
||||
|
||||
|
||||
|
||||
# OBJDATADIR must be a short path (with ..'s) to the data.
|
||||
# @RELATIVEDATADIR@ exists soley for this line.
|
||||
# @RELATIVEDATADIR@ exists solely for this line.
|
||||
|
||||
ICUDATADIR=$(pkgdatadir)/$(VERSION)
|
||||
SRCDATADIR=$(top_srcdir)/../data
|
||||
@ -60,24 +71,24 @@ VERSION = @VERSION@
|
||||
|
||||
|
||||
SUBDIRS = ctestfw toolutil makeconv genrb rbdump \
|
||||
genccode genprops gennames gencmn gencnval gentz gentest
|
||||
genccode genprops gennames gencmn gencnval gentz gentest pkgdata
|
||||
|
||||
## List of phony targets
|
||||
.PHONY : all all-local all-recursive install install-local install-everything install-files install-dlls build-data build-cmnfile build-dll \
|
||||
install-recursive clean clean-local clean-recursive distclean \
|
||||
distclean-local distclean-recursive dist dist-local dist-recursive \
|
||||
check check-local check-recursive build-testdlls build-basetestdata
|
||||
check check-local check-recursive build-testdlls build-basetestdata build-local
|
||||
|
||||
## Clear suffix list
|
||||
.SUFFIXES :
|
||||
|
||||
## List of standard targets
|
||||
all: all-recursive all-local
|
||||
install: install-recursive install-local
|
||||
clean: clean-recursive clean-local
|
||||
distclean : distclean-recursive distclean-local
|
||||
dist: dist-recursive dist-local
|
||||
check: check-recursive check-local
|
||||
all: all-recursive
|
||||
install: install-recursive
|
||||
clean: clean-recursive
|
||||
distclean : distclean-recursive
|
||||
dist: dist-recursive
|
||||
check: check-recursive
|
||||
|
||||
## Recursive targets
|
||||
all-recursive install-recursive clean-recursive distclean-recursive dist-recursive check-recursive:
|
||||
@ -100,8 +111,9 @@ all-recursive install-recursive clean-recursive distclean-recursive dist-recursi
|
||||
all-local: build-local
|
||||
|
||||
DAT_FILES=uprops.dat unames.dat cnvalias.dat tz.dat
|
||||
# ALL of these files can be deleted (the following BRK files) - they are copied
|
||||
BRK_FILES=char.brk line.brk line_th.brk sent.brk word.brk word_th.brk
|
||||
# don't include thaidict.brk - it goes into a resource bundle.
|
||||
# don't include thaidict.brk - it goes into a resource bundle - plus it isn't deleted
|
||||
|
||||
DATAFILESD=$(DAT_FILES:%=$(OBJDATADIR)/%)
|
||||
DATAFILESB=$(BRK_FILES:%=$(OBJDATADIR)/%)
|
||||
@ -135,128 +147,11 @@ DATAFILESR=$(RES_FILES)
|
||||
|
||||
DATAFILES=$(DATAFILESD) $(DATAFILESC) $(DATAFILESB) $(DATAFILESR)
|
||||
|
||||
SRCDATAFILESD=$(DATAFILESD:%.dat=%_dat.c)
|
||||
SRCDATAFILESR=$(DATAFILESR:%.res=%_res.c)
|
||||
SRCDATAFILESC=$(DATAFILESC:%.cnv=%_cnv.c)
|
||||
SRCDATAFILESB=$(DATAFILESB:%.brk=%_brk.c)
|
||||
|
||||
SRCDATAFILES=$(SRCDATAFILESD) $(SRCDATAFILESC) $(SRCDATAFILESB) $(SRCDATAFILESR) $(OBJDATADIR)/icudata_dat.c
|
||||
|
||||
|
||||
OBJDATAFILES=$(SRCDATAFILES:%.c=%.o)
|
||||
COMMONFILE=$(OBJDATADIR)/icudata.dat
|
||||
COMMONDLL=$(OBJDATADIR)/libicudata.$(SO)
|
||||
|
||||
#the files for creating the test data
|
||||
TESTDATAFILE=test.dat
|
||||
TESTDATAD=$(TESTDATAFILE:%=$(OBJDATADIR)/%)
|
||||
TESTDATAFILEC=$(TESTDATAD:.dat=_dat.c)
|
||||
OBJTESTFILE=$(TESTDATAFILEC:%.c=%.o)
|
||||
TESTDATADLL=$(OBJDATADIR)/libtest_dat.$(SO)
|
||||
BASEDATADLL=$(OBJDATADIR)/libbase_dat.$(SO)
|
||||
BASETESTDATADLL=$(OBJDATADIR)/libbase_test_dat.$(SO)
|
||||
|
||||
blah:
|
||||
echo $(SRCDATAFILES)
|
||||
|
||||
BASETESTDATA=base_test.dat
|
||||
build-basetestdata:
|
||||
@echo Generating the base test data file base_test.dat from test.dat
|
||||
@cp $(TESTDATAD) $(SRCDATADIR)/$(BASETESTDATA)
|
||||
@ls -l $(SRCDATADIR)/$(BASETESTDATA)
|
||||
|
||||
# the files to be installed -- the COMMON ones + any stragglers
|
||||
UDATA_FILES=icudata.dat
|
||||
UDATA_DLLS=libicudata.$(SO)
|
||||
|
||||
### use the "--enable-mapped=" option to configure, to get mapped file behavior.
|
||||
# the case where '--enable-mapped=yes'
|
||||
@USE_MAPPED_TRUE@build-local: build-data build-cmnfile build-basetestdata
|
||||
|
||||
# the case where '--enable-mapped=no' (DEFAULT)
|
||||
@USE_MAPPED_FALSE@build-local: build-data build-dll build-testdlls
|
||||
###
|
||||
|
||||
# check for any other generated data here
|
||||
install-data: $(DATAFILES)
|
||||
|
||||
build-cmnfile: $(COMMONFILE)
|
||||
|
||||
# the -Wpath [etc] has relative DLL paths in it
|
||||
# so we have to cd into the other dir..
|
||||
|
||||
gencmn/mkmap.tmp: Makefile $(DATAFILES)
|
||||
@echo -n Generating $@ list of data files
|
||||
@-$(RMV) gencmn/mkmap.tmp
|
||||
@for file in $(DATAFILES); do \
|
||||
echo `pwd`/$$file >> gencmn/mkmap.tmp; \
|
||||
done;
|
||||
|
||||
|
||||
$(COMMONFILE): $(DATAFILES) gencmn/mkmap.tmp
|
||||
@echo -n Generating common file $(COMMONFILE). Number of files: Objdata dir is $(OBJDATADIR)
|
||||
-@wc -l gencmn/mkmap.tmp
|
||||
-$(RMV) $(COMMONFILE)
|
||||
(cd gencmn ; ./gencmn -c -d ../$(OBJDATADIR) 1000000 mkmap.tmp )
|
||||
-@ls -l $(COMMONFILE)
|
||||
|
||||
build-dll: $(DATAFILES) gencmn/mkmap.tmp $(COMMONDLL)
|
||||
|
||||
build-testdlls: $(TESTDATADLL) $(BASEDATADLL) $(BASETESTDATADLL)
|
||||
|
||||
%_dat.c: %.dat
|
||||
(cd genccode ; ./genccode ../$< )
|
||||
|
||||
%_cnv.c: %.cnv
|
||||
(cd genccode ; ./genccode ../$< )
|
||||
|
||||
%_brk.c: %.brk
|
||||
(cd genccode ; ./genccode ../$< )
|
||||
|
||||
%_res.c: %.res
|
||||
(cd genccode ; ./genccode ../$< )
|
||||
|
||||
## Note: this generates a dummy C++ file to cause the HPUX CC linker
|
||||
## to load exception handling (when requested..)
|
||||
|
||||
hpux_junk_obj.cpp:
|
||||
echo "void to_emit_cxx_stuff_in_the_linker(){}" >> hpux_junk_obj.cpp
|
||||
|
||||
hpux_junk_obj.o: hpux_junk_obj.cpp
|
||||
$(COMPILE.cc) -o $@ $<
|
||||
|
||||
# strip is optional
|
||||
# -$(STRIP) $@
|
||||
|
||||
|
||||
# HPUX_JUNK_OBJ is usually unset except by mh-hpux-cc
|
||||
|
||||
$(OBJDATADIR)/icudata_dat.c: $(DATAFILES) gencmn/mkmap.tmp
|
||||
@(cd gencmn ; ./gencmn -S -d ../$(OBJDATADIR) 1000000 mkmap.tmp )
|
||||
|
||||
$(COMMONDLL): $(OBJDATAFILES) $(HPUX_JUNK_OBJ)
|
||||
$(SHLIB.c) -o $@ $^
|
||||
-ls -l $@
|
||||
|
||||
$(TESTDATADLL) $(BASEDATADLL) $(BASETESTDATADLL): $(OBJTESTFILE) $(HPUX_JUNK_OBJ)
|
||||
$(SHLIB.c) -o $@ $^
|
||||
-ls -l $@
|
||||
|
||||
srcs: $(SRCDATAFILES)
|
||||
|
||||
|
||||
## Files to remove for 'make clean'
|
||||
CLEANFILES = *~ $(BRK_FILES) $(OBJDATAFILES) $(HPUX_JUNK_OBJ) $(OBJTESTFILE) \
|
||||
$(COMMONDLL) $(TESTDATADLL) $(BASEDATADLL) $(BASETESTDATADLL)
|
||||
CLEANFILES = *~ $(BRK_FILES)
|
||||
|
||||
|
||||
### use the "--enable-mapped=" option to configure, to get mapped file behavior.
|
||||
# the case where '--enable-mapped=yes' - raw files [which can be mapped]
|
||||
@USE_MAPPED_TRUE@install-udata: install-files
|
||||
|
||||
# the case where '--enable-mapped=no' (DEFAULT) - DLL's [so's to you]
|
||||
@USE_MAPPED_FALSE@install-udata: install-dlls
|
||||
###
|
||||
install-udata: install-pkgdata
|
||||
|
||||
install-local: build-local install-udata
|
||||
|
||||
@ -283,7 +178,39 @@ clean-local:
|
||||
test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
|
||||
|
||||
distclean-local: clean-local
|
||||
$(RMV) Makefile $(SRCDATAFILES) $(DATAFILES) $(TESTDATAD) $(BASETESTDATA)
|
||||
$(RMV) Makefile $(SRCDATAFILES) $(DATAFILES) $(TESTDATAD) $(BASETESTDATA) icupkg.inc
|
||||
# Clean up any old variations..
|
||||
-@if [ -f @DATABUILDDIR@/icudata_dll.mak ]; then \
|
||||
(cd pkgdata; pkgdata -m dll -p icudata -O @DATABUILDDIR@/icupkg.inc @DATABUILDDIR@/icudata.lst -d @DATABUILDDIR@ --clean ) \
|
||||
fi
|
||||
-@if [ -f @DATABUILDDIR@/icudata_common.mak ]; then \
|
||||
(cd pkgdata; pkgdata -m common -p icudata -O @DATABUILDDIR@/icupkg.inc @DATABUILDDIR@/icudata.lst -d @DATABUILDDIR@ --clean ) \
|
||||
fi
|
||||
-@$(RMV) @DATABUILDDIR@/icudata.lst @DATABUILDDIR@/icupkg.inc @DATABUILDDIR@/*.o @DATABUILDDIR@/*.c @DATABUILDDIR@/*.mak @DATABUILDDIR@/*.lst
|
||||
|
||||
@DATABUILDDIR@/icudata.lst: Makefile
|
||||
@echo Generating $@ list of data files
|
||||
@-$(RMV) @DATABUILDDIR@/icudata.lst
|
||||
@for file in $(DATAFILES); do \
|
||||
echo `pwd`/$$file >@DATABUILDDIR@/icudata.lst; \
|
||||
done;
|
||||
|
||||
@DATABUILDDIR@/icupkg.inc: icupkg.inc
|
||||
cp icupkg.inc @DATABUILDDIR@/icupkg.inc
|
||||
|
||||
build-local build-pkgdata: @DATABUILDDIR@/icudata.lst @DATABUILDDIR@/icupkg.inc $(DATAFILES)
|
||||
(cd pkgdata; pkgdata -v -m $(MODE) -p icudata -O @DATABUILDDIR@/icupkg.inc @DATABUILDDIR@/icudata.lst -d @DATABUILDDIR@ )
|
||||
|
||||
install-pkgdata: @DATABUILDDIR@/icudata.lst @DATABUILDDIR@/icupkg.inc
|
||||
(cd pkgdata; pkgdata -v -m $(MODE) -p icudata -O @DATABUILDDIR@/icupkg.inc @DATABUILDDIR@/icudata.lst -d @DATABUILDDIR@ -I $(DESTDIR)$(pkgdatadir)/$(VERSION) )
|
||||
|
||||
icupkg.inc: $(srcdir)/icupkg.inc.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
clean-pkgdata: @DATABUILDDIR@/icudata.lst @DATABUILDDIR@/icupkg.inc
|
||||
-(cd pkgdata; pkgdata -m $(MODE) -p icudata -O @DATABUILDDIR@/icupkg.inc @DATABUILDDIR@/icudata.lst -d @DATABUILDDIR@ --clean )
|
||||
-$(RMV) @DATABUILDDIR@/icudata.lst @DATABUILDDIR@/icupkg.inc
|
||||
|
||||
check-local:
|
||||
|
||||
|
110
icu4c/source/tools/pkgdata/Makefile.in
Normal file
110
icu4c/source/tools/pkgdata/Makefile.in
Normal file
@ -0,0 +1,110 @@
|
||||
## Makefile.in for ICU - tools/pkgdata
|
||||
## Copyright (c) 1999-2000, International Business Machines Corporation and
|
||||
## others. All Rights Reserved.
|
||||
## Steven R. Loomis
|
||||
|
||||
## Shell to use
|
||||
SHELL = @SHELL@
|
||||
|
||||
## Install directory information
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
datadir = @datadir@
|
||||
libdir = @libdir@
|
||||
includedir = @includedir@
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
## Install program information
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
## Compiler/tools information
|
||||
CC = @CC@
|
||||
CXX = @CXX@
|
||||
PACKAGE = @PACKAGE@
|
||||
VERSION = @VERSION@
|
||||
|
||||
## Platform-specific setup
|
||||
@host_frag@
|
||||
|
||||
## Build directory information
|
||||
top_builddir = ../..
|
||||
subdir = tools/pkgdata
|
||||
|
||||
## Extra files to remove for 'make clean'
|
||||
CLEANFILES = *~ mkmap.tmp
|
||||
|
||||
## Target information
|
||||
TARGET = pkgdata
|
||||
|
||||
DEFS = @DEFS@
|
||||
CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/common -I$(top_srcdir)/common -I$(srcdir)/../toolutil -DUDATA_SO_SUFFIX=\".$(SO)\"
|
||||
CFLAGS = @CFLAGS@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
LDFLAGS = @LDFLAGS@ \
|
||||
$(LD_RPATH)$(LD_RPATH_PRE)$(libdir)@ld_rpath_suf@$(LD_RPATH_PRE)$(top_builddir)/common@ld_rpath_suf@$(LD_RPATH_PRE)$(top_builddir)/tools/toolutil
|
||||
LIBS = $(LIBICU-UC) @LIBS@ @LIB_M@ $(LIBICU-TOOLUTIL)
|
||||
|
||||
OBJECTS = pkgdata.o pkgtypes.o gmake.o dllmode.o cmnmode.o
|
||||
|
||||
DEPS = $(OBJECTS:.o=.d)
|
||||
|
||||
|
||||
## List of phony targets
|
||||
.PHONY : all all-local install install-local clean clean-local \
|
||||
distclean distclean-local dist dist-local check \
|
||||
check-local
|
||||
|
||||
## Clear suffix list
|
||||
.SUFFIXES :
|
||||
|
||||
## List of standard targets
|
||||
all: all-local
|
||||
install: install-local
|
||||
clean: clean-local
|
||||
distclean : distclean-local
|
||||
dist: dist-local
|
||||
check: check-local
|
||||
|
||||
all-local: $(TARGET) $(RES_FILES) $(TRANSLIT_RES) $(TEST_FILES)
|
||||
|
||||
install-local: all-local
|
||||
$(mkinstalldirs) $(DESTDIR)$(sbindir)
|
||||
$(INSTALL) $(TARGET) $(DESTDIR)$(sbindir)/$(TARGET)
|
||||
|
||||
dist-local:
|
||||
|
||||
clean-local:
|
||||
test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
|
||||
$(RMV) $(TARGET) $(OBJECTS)
|
||||
|
||||
distclean-local: clean-local
|
||||
$(RMV) Makefile $(DEPS) $(RES_FILES) $(TEST_FILES)
|
||||
|
||||
check-local:
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
$(TARGET) : $(OBJECTS)
|
||||
$(LINK.c) -o $@ $^ $(LIBS)
|
||||
|
||||
ifeq (,$(MAKECMDGOALS))
|
||||
-include $(DEPS)
|
||||
else
|
||||
ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),)
|
||||
-include $(DEPS)
|
||||
endif
|
||||
endif
|
112
icu4c/source/tools/pkgdata/cmnmode.c
Normal file
112
icu4c/source/tools/pkgdata/cmnmode.c
Normal file
@ -0,0 +1,112 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2000, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
* file name: pkgdata.c
|
||||
* encoding: ANSI X3.4 (1968)
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
* created on: 2000may15
|
||||
* created by: Steven \u24C7 Loomis
|
||||
*
|
||||
* This program packages the ICU data into different forms
|
||||
* (DLL, common data, etc.)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
#include "filestrm.h"
|
||||
#include "toolutil.h"
|
||||
#include "unewdata.h"
|
||||
#include "uoptions.h"
|
||||
#include "pkgtypes.h"
|
||||
#include "makefile.h"
|
||||
|
||||
void pkg_mode_common(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
|
||||
{
|
||||
char tmp[1024];
|
||||
CharList *tail = NULL;
|
||||
|
||||
uprv_strcpy(tmp, UDATA_CMN_PREFIX);
|
||||
uprv_strcat(tmp, o->shortName);
|
||||
uprv_strcat(tmp, UDATA_CMN_SUFFIX);
|
||||
|
||||
if(!uprv_strcmp(o->mode, "common")) {
|
||||
/* If we're not the main mode.. don't change the output file list */
|
||||
|
||||
/* We should be the only item. So we don't care about the order. */
|
||||
o->outFiles = pkg_appendToList(o->outFiles, &tail, uprv_strdup(tmp));
|
||||
|
||||
if(o->nooutput || o->verbose) {
|
||||
fprintf(stderr, "# Output file: %s%s%s\n", o->targetDir, U_FILE_SEP_STRING, tmp);
|
||||
}
|
||||
|
||||
if(o->nooutput) {
|
||||
*status = U_ZERO_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(tmp, "# File to make:\nTARGET=%s%s%s\n\nTARGETNAME=%s\n", o->targetDir,
|
||||
U_FILE_SEP_STRING,
|
||||
o->outFiles->str,
|
||||
o->outFiles->str);
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
} else {
|
||||
/* We're in another mode. but, set the target so they can find us.. */
|
||||
T_FileStream_writeLine(makefile, "TARGET=");
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
T_FileStream_writeLine(makefile, "\n\n");
|
||||
|
||||
} /* end [check to make sure we are in mode 'common' ] */
|
||||
|
||||
sprintf(tmp, "# List file for gencmn:\n"
|
||||
"CMNLIST=%s%s%s_common.lst\n\n",
|
||||
o->tmpDir,
|
||||
U_FILE_SEP_STRING,
|
||||
o->shortName);
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
|
||||
sprintf(tmp, "all: $(TARGET)\n\n");
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
|
||||
T_FileStream_writeLine(makefile, "$(TARGET): $(CMNLIST) $(DATAFILEPATHS)\n"
|
||||
"\t$(TOOL) $(GENCMN) -n $(NAME) -c -d $(TARGETDIR) 10000000 $(CMNLIST)\n\n");
|
||||
|
||||
#ifdef WIN32
|
||||
T_FileStream_writeLine(makefile, "$(CMNLIST): $(LISTFILES)\n\n\n");
|
||||
# error How do I do this??
|
||||
#else
|
||||
|
||||
if(o->hadStdin == FALSE) { /* shortcut */
|
||||
T_FileStream_writeLine(makefile, "$(CMNLIST): $(LISTFILES)\n"
|
||||
"\tcat $(LISTFILES) > $(CMNLIST)\n\n");
|
||||
} else {
|
||||
T_FileStream_writeLine(makefile, "$(CMNLIST): \n"
|
||||
"\t@echo Generating $@ list of data files\n"
|
||||
"\t@-$(RMV) $@\n"
|
||||
"\t@for file in $(DATAFILEPATHS); do \\\n"
|
||||
"\t echo $$file >> $@; \\\n"
|
||||
"\tdone;\n\n");
|
||||
}
|
||||
|
||||
if(!uprv_strcmp(o->mode, "common")) { /* only install/clean in our own mode */
|
||||
T_FileStream_writeLine(makefile, "CLEANFILES= $(CMNLIST) $(TARGET)\n\nclean:\n\t-$(RMV) $(CLEANFILES) $(MAKEFILE)");
|
||||
T_FileStream_writeLine(makefile, "\n\n");
|
||||
|
||||
sprintf(tmp, "install: $(TARGET)\n"
|
||||
"\t$(INSTALL-S) $(TARGET) $(INSTALLTO)%s$(TARGETNAME)\n\n",
|
||||
U_FILE_SEP_STRING);
|
||||
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
180
icu4c/source/tools/pkgdata/dllmode.c
Normal file
180
icu4c/source/tools/pkgdata/dllmode.c
Normal file
@ -0,0 +1,180 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2000, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
* file name: pkgdata.c
|
||||
* encoding: ANSI X3.4 (1968)
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
* created on: 2000may15
|
||||
* created by: Steven \u24C7 Loomis
|
||||
*
|
||||
* This program packages the ICU data into different forms
|
||||
* (DLL, common data, etc.)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
#include "filestrm.h"
|
||||
#include "toolutil.h"
|
||||
#include "unewdata.h"
|
||||
#include "uoptions.h"
|
||||
#include "pkgtypes.h"
|
||||
#include "makefile.h"
|
||||
|
||||
void findSuffixesAndObjects(CharList *infiles, CharList **suffixes, CharList **objects)
|
||||
{
|
||||
char *p;
|
||||
char tmp[1024];
|
||||
CharList *sTail = NULL, *oTail = NULL;
|
||||
|
||||
for(;infiles;infiles = infiles->next) {
|
||||
p = uprv_strrchr(infiles->str, '.');
|
||||
if( (p == NULL) || (*p == '\0' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uprv_strncpy(tmp, infiles->str, p-infiles->str);
|
||||
p++;
|
||||
|
||||
uprv_strcpy(tmp+(p-1-infiles->str), "_"); /* to append */
|
||||
uprv_strcat(tmp, p);
|
||||
uprv_strcat(tmp, OBJ_SUFFIX);
|
||||
|
||||
*objects = pkg_appendToList(*objects, &oTail, uprv_strdup(tmp));
|
||||
|
||||
if(pkg_listContains(*suffixes, p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
*suffixes = pkg_appendToList(*suffixes, &sTail, uprv_strdup(p));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void pkg_mode_dll(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
|
||||
{
|
||||
char tmp[1024];
|
||||
CharList *tail = NULL;
|
||||
CharList *suffixes =NULL, *objects = NULL;
|
||||
CharList *iter;
|
||||
|
||||
if(U_FAILURE(*status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uprv_strcpy(tmp, LIB_PREFIX);
|
||||
uprv_strcat(tmp, o->shortName);
|
||||
uprv_strcat(tmp, UDATA_SO_SUFFIX);
|
||||
|
||||
/* We should be the only item. So we don't care about the order. */
|
||||
o->outFiles = pkg_appendToList(o->outFiles, &tail, uprv_strdup(tmp));
|
||||
|
||||
if(o->nooutput || o->verbose) {
|
||||
fprintf(stderr, "# Output file: %s%s%s\n", o->targetDir, U_FILE_SEP_STRING, tmp);
|
||||
}
|
||||
|
||||
if(o->nooutput) {
|
||||
*status = U_ZERO_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
sprintf(tmp, "# File to make:\nDLLTARGET=%s\n\n", o->outFiles->str);
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
|
||||
sprintf(tmp, "all: $(TARGETDIR)\$(DLLTARGET)\n\n");
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
|
||||
/* now, import the rules for making a common file.. */
|
||||
pkg_mode_dll(o, makefile, status);
|
||||
|
||||
if(U_FAILURE(*status)) {
|
||||
fprintf(stderr, "# Dllmode: Error importing rules for 'common'.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
T_FileStream_writeLine(makefile, "CLEANFILES= $(CMNLIST) $(TARGET) $(TARGETDIR)\$(DLLTARGET)\n\nclean:\n\t-$(RMV) $(CLEANFILES) $(MAKEFILE)");
|
||||
T_FileStream_writeLine(makefile, "\n\n");
|
||||
|
||||
T_FileStream_writeLine(makefile, "install: $(TARGETDIR)\$(DLLTARGET)\n"
|
||||
"\tCOPY $(TARGETDIR)\$(DLLTARGET) $(INSTALL)/$(DLLTARGET)\n\n");
|
||||
|
||||
#else
|
||||
/* begin writing makefile ========================= */
|
||||
|
||||
|
||||
sprintf(tmp, "# File to make:\nTARGET=%s\n\n", o->outFiles->str);
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
|
||||
sprintf(tmp, "all: $(TARGETDIR)/$(TARGET)\n\n");
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
|
||||
/* Write compile rules */
|
||||
findSuffixesAndObjects(o->files, &suffixes, &objects);
|
||||
|
||||
sprintf(tmp, "# List file for gencmn:\n"
|
||||
"CMNLIST=%s%s%s_dll.lst\n\n",
|
||||
o->tmpDir,
|
||||
U_FILE_SEP_STRING,
|
||||
o->shortName);
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
|
||||
if(o->hadStdin == FALSE) { /* shortcut */
|
||||
T_FileStream_writeLine(makefile, "$(CMNLIST): $(LISTFILES)\n"
|
||||
"\tcat $(LISTFILES) > $(CMNLIST)\n\n");
|
||||
} else {
|
||||
T_FileStream_writeLine(makefile, "$(CMNLIST): \n"
|
||||
"\t@echo Generating $@ list of data files\n"
|
||||
"\t@-$(RMV) $@\n"
|
||||
"\t@for file in $(DATAFILEPATHS); do \\\n"
|
||||
"\t echo $$file >> $@; \\\n"
|
||||
"\tdone;\n\n");
|
||||
}
|
||||
|
||||
T_FileStream_writeLine(makefile, "icudata_dat.c: $(CMNLIST)\n\n"
|
||||
"\t$(TOOL) $(GENCMN) -S -d $(TARGETDIR) 0 $(CMNLIST)\n\n");
|
||||
|
||||
sprintf(tmp, "OBJECTS= icudata_dat%s ", OBJ_SUFFIX);
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
|
||||
pkg_writeCharListWrap(makefile, objects, " ", " \\\n");
|
||||
T_FileStream_writeLine(makefile, "\n\n");
|
||||
|
||||
for(iter=suffixes; iter; iter = iter->next) {
|
||||
sprintf(tmp, "%%_%s.c: %%.%s\n\t$(TOOL) $(GENCCODE) $<\n\n",
|
||||
iter->str,iter->str);
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
}
|
||||
|
||||
T_FileStream_writeLine(makefile,"build-objs: $(OBJECTS)\n\n");
|
||||
|
||||
T_FileStream_writeLine(makefile, "$(TARGETDIR)/$(TARGET): $(OBJECTS) $(HPUX_JUNK_OBJ) $(LISTFILES)\n"
|
||||
"\t$(SHLIB.c) -o $@ $(OBJECTS) $(HPUX_JUNK_OBJ)\n"
|
||||
"\t-ls -l $@\n\n");
|
||||
|
||||
T_FileStream_writeLine(makefile, "hpux_junk_obj.cpp:\n"
|
||||
" echo \"void to_emit_cxx_stuff_in_the_linker(){}\" >> hpux_junk_obj.cpp\n"
|
||||
"\n"
|
||||
"hpux_junk_obj.o: hpux_junk_obj.cpp\n"
|
||||
" $(COMPILE.cc) -o $@ $<\n"
|
||||
"\n");
|
||||
|
||||
T_FileStream_writeLine(makefile, "CLEANFILES= $(OBJECTS) $(HPUX_JUNK_OBJ) $(TARGETDIR)/$(TARGET)\n\nclean:\n\t-$(RMV) $(CLEANFILES) $(MAKEFILE)");
|
||||
T_FileStream_writeLine(makefile, "\n\n");
|
||||
|
||||
T_FileStream_writeLine(makefile, "install: $(TARGETDIR)/$(TARGET)\n"
|
||||
"\t$(INSTALL-S) $(TARGET) $(INSTALLTO)/$(TARGET)\n\n");
|
||||
|
||||
#endif /* NOT win32 */
|
||||
|
||||
*status = U_ZERO_ERROR;
|
||||
|
||||
}
|
||||
|
110
icu4c/source/tools/pkgdata/gmake.c
Normal file
110
icu4c/source/tools/pkgdata/gmake.c
Normal file
@ -0,0 +1,110 @@
|
||||
/* TODO:
|
||||
TOOL: setup libpaths/etc for running tools
|
||||
*/
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2000, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
***************************************************************************
|
||||
* file name: gmake.c
|
||||
* encoding: ANSI X3.4 (1968)
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
* created on: 2000may17
|
||||
* created by: Steven \u24C7 Loomis
|
||||
*
|
||||
* Emit a GNU makefile
|
||||
*/
|
||||
|
||||
#include "makefile.h"
|
||||
#include <stdio.h>
|
||||
|
||||
char linebuf[2048];
|
||||
|
||||
/* Write any setup/initialization stuff */
|
||||
void
|
||||
pkg_mak_writeHeader(FileStream *f, const UPKGOptions *o)
|
||||
{
|
||||
sprintf(linebuf, "## Makefile for %s created by pkgtool\n"
|
||||
"## from ICU Version %s\n"
|
||||
"\n"
|
||||
"include %s\n",
|
||||
o->shortName,
|
||||
U_ICU_VERSION,
|
||||
o->options);
|
||||
T_FileStream_writeLine(f, linebuf);
|
||||
|
||||
sprintf(linebuf, "NAME=%s\n"
|
||||
"TARGETDIR=%s\n"
|
||||
"TEMP_DIR=%s\n"
|
||||
"MODE=%s\n"
|
||||
"MAKEFILE=%s\n"
|
||||
"\n\n\n",
|
||||
o->shortName,
|
||||
o->targetDir,
|
||||
o->tmpDir,
|
||||
o->mode,
|
||||
o->makeFile);
|
||||
T_FileStream_writeLine(f, linebuf);
|
||||
|
||||
sprintf(linebuf, "## List files [%d] containing data files to process (note: - means stdin)\n"
|
||||
"LISTFILES= ",
|
||||
pkg_countCharList(o->fileListFiles));
|
||||
T_FileStream_writeLine(f, linebuf);
|
||||
|
||||
pkg_writeCharListWrap(f, o->fileListFiles, " ", " \\\n");
|
||||
|
||||
T_FileStream_writeLine(f, "\n\n\n");
|
||||
|
||||
sprintf(linebuf, "## Data Files [%d]\n"
|
||||
"DATAFILES= ",
|
||||
pkg_countCharList(o->files));
|
||||
|
||||
T_FileStream_writeLine(f, linebuf);
|
||||
|
||||
pkg_writeCharListWrap(f, o->files, " ", " \\\n");
|
||||
|
||||
T_FileStream_writeLine(f, "\n\n\n");
|
||||
|
||||
sprintf(linebuf, "## Data File Paths [%d]\n"
|
||||
"DATAFILEPATHS= ",
|
||||
pkg_countCharList(o->filePaths));
|
||||
|
||||
T_FileStream_writeLine(f, linebuf);
|
||||
|
||||
pkg_writeCharListWrap(f, o->filePaths, " ", " \\\n");
|
||||
|
||||
T_FileStream_writeLine(f, "\n\n\n");
|
||||
|
||||
}
|
||||
|
||||
/* Write a stanza in the makefile, with specified "target: parents... \n\n\tcommands" [etc] */
|
||||
void
|
||||
pkg_mak_writeStanza(FileStream *f, const UPKGOptions *o,
|
||||
const char *target,
|
||||
CharList* parents,
|
||||
CharList* commands)
|
||||
{
|
||||
T_FileStream_write(f, target, strlen(target));
|
||||
T_FileStream_write(f, " : ", 3);
|
||||
pkg_writeCharList(f, parents, " ");
|
||||
T_FileStream_write(f, "\n", 1);
|
||||
|
||||
if(commands)
|
||||
{
|
||||
T_FileStream_write(f, "\t", 1);
|
||||
pkg_writeCharList(f, commands, "\n\t");
|
||||
}
|
||||
T_FileStream_write(f, "\n\n", 2);
|
||||
}
|
||||
|
||||
/* write any cleanup/post stuff */
|
||||
void
|
||||
pkg_mak_writeFooter(FileStream *f, const UPKGOptions *o)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
42
icu4c/source/tools/pkgdata/makefile.h
Normal file
42
icu4c/source/tools/pkgdata/makefile.h
Normal file
@ -0,0 +1,42 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2000, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
***************************************************************************
|
||||
* file name: makefile.h
|
||||
* encoding: ANSI X3.4 (1968)
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
* created on: 2000may17
|
||||
* created by: Steven \u24C7 Loomis
|
||||
*
|
||||
* definition for code to create a makefile.
|
||||
* implementation is OS dependent (i.e. gmake.c, nmake.c, .. )
|
||||
*/
|
||||
|
||||
#ifndef _MAKEFILE
|
||||
#define _MAKEFILE
|
||||
|
||||
/* headers */
|
||||
#include "unicode/utypes.h"
|
||||
#include "pkgtypes.h"
|
||||
|
||||
|
||||
/* Write any setup/initialization stuff */
|
||||
void
|
||||
pkg_mak_writeHeader(FileStream *f, const UPKGOptions *o);
|
||||
|
||||
/* Write a stanza in the makefile, with specified "target: parents... \n\n\tcommands" [etc] */
|
||||
void
|
||||
pkg_mak_writeStanza(FileStream *f, const UPKGOptions *o,
|
||||
const char *target,
|
||||
CharList* parents,
|
||||
CharList* commands);
|
||||
|
||||
/* write any cleanup/post stuff */
|
||||
void
|
||||
pkg_mak_writeFooter(FileStream *f, const UPKGOptions *o);
|
||||
|
||||
#endif
|
346
icu4c/source/tools/pkgdata/pkgdata.c
Normal file
346
icu4c/source/tools/pkgdata/pkgdata.c
Normal file
@ -0,0 +1,346 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2000, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
* file name: pkgdata.c
|
||||
* encoding: ANSI X3.4 (1968)
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
* created on: 2000may15
|
||||
* created by: Steven \u24C7 Loomis
|
||||
*
|
||||
* This program packages the ICU data into different forms
|
||||
* (DLL, common data, etc.)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
#include "filestrm.h"
|
||||
#include "toolutil.h"
|
||||
#include "unewdata.h"
|
||||
#include "uoptions.h"
|
||||
#include "pkgtypes.h"
|
||||
#include "makefile.h"
|
||||
|
||||
#ifdef UDATA_SO_SUFFIX
|
||||
extern void pkg_mode_dll(UPKGOptions* o, FileStream *stream, UErrorCode *status);
|
||||
#endif
|
||||
extern void pkg_mode_common(UPKGOptions* o, FileStream *stream, UErrorCode *status);
|
||||
|
||||
static void loadLists(UPKGOptions *o, UErrorCode *status);
|
||||
|
||||
|
||||
/* This sets the modes that are available */
|
||||
static struct
|
||||
{
|
||||
const char *name;
|
||||
UPKGMODE *fcn;
|
||||
const char *desc;
|
||||
} modes[] =
|
||||
{
|
||||
#ifdef UDATA_SO_SUFFIX
|
||||
{ "dll", pkg_mode_dll, "Generates one shared library, <package>" UDATA_SO_SUFFIX },
|
||||
#endif
|
||||
{ "common", pkg_mode_common, "Generates one common data file, <package>.dat" }
|
||||
};
|
||||
|
||||
static UOption options[]={
|
||||
UOPTION_DEF( "name", 'p', UOPT_REQUIRES_ARG),
|
||||
UOPTION_DEF( "bldopt", 'O', UOPT_REQUIRES_ARG),
|
||||
UOPTION_DEF( "mode", 'm', UOPT_REQUIRES_ARG),
|
||||
UOPTION_HELP_H, /* -h */
|
||||
UOPTION_HELP_QUESTION_MARK, /* -? */
|
||||
UOPTION_VERBOSE, /* -v */
|
||||
UOPTION_COPYRIGHT, /* -c */
|
||||
UOPTION_DEF( "comment", 'C', UOPT_REQUIRES_ARG),
|
||||
UOPTION_DESTDIR, /* -d */
|
||||
UOPTION_DEF( "clean", 'k', UOPT_NO_ARG),
|
||||
UOPTION_DEF( "nooutput",'n', UOPT_NO_ARG),
|
||||
UOPTION_DEF( "rebuild", 'F', UOPT_NO_ARG),
|
||||
UOPTION_DEF( "tempdir", 'T', UOPT_REQUIRES_ARG),
|
||||
UOPTION_DEF( "install", 'I', UOPT_REQUIRES_ARG)
|
||||
};
|
||||
|
||||
const char options_help[][80]={
|
||||
"Set the data name",
|
||||
"Specify options for the builder",
|
||||
"Specify the mode of building (see below)",
|
||||
"This usage text",
|
||||
"This usage text",
|
||||
"Make the output verbose",
|
||||
"Use the standard ICU copyright",
|
||||
"Use a custom comment (instead of the copyright)",
|
||||
"Specify the destination directory for files",
|
||||
"Clean out generated & temporary files",
|
||||
"Suppress output of data, just list files to be created",
|
||||
"Force rebuilding of all data",
|
||||
"Specify temporary dir (default: output dir)",
|
||||
"Install the data (specify target)"
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
main(int argc, const char *argv[]) {
|
||||
FileStream *in, *out;
|
||||
UPKGOptions o;
|
||||
CharList *tail;
|
||||
const char *progname;
|
||||
bool_t needsHelp = FALSE;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
char tmp[1024];
|
||||
int32_t i;
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
/* read command line options */
|
||||
argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);
|
||||
|
||||
/* error handling, printing usage message */
|
||||
/* I've decided to simply print an error and quit. This tool has too
|
||||
many options to just display them all of the time. */
|
||||
|
||||
if(options[3].doesOccur || options[4].doesOccur) {
|
||||
needsHelp = TRUE;
|
||||
}
|
||||
else {
|
||||
if(!needsHelp && argc<0) {
|
||||
fprintf(stderr,
|
||||
"%s: error in command line argument \"%s\"\n",
|
||||
progname,
|
||||
argv[-argc]);
|
||||
fprintf(stderr, "Run '%s --help' for help.\n", progname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(! (options[0].doesOccur && options[1].doesOccur &&
|
||||
options[2].doesOccur) ) {
|
||||
fprintf(stderr, " required parameters are missing: -p AND -O AND -m \n");
|
||||
fprintf(stderr, "Run '%s --help' for help.\n", progname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(argc == 1) {
|
||||
fprintf(stderr,
|
||||
"No input files specified.\n"
|
||||
"Run '%s --help' for help.\n", progname);
|
||||
return 1;
|
||||
}
|
||||
} /* end !needsHelp */
|
||||
|
||||
if(argc<0 || needsHelp ) {
|
||||
fprintf(stderr,
|
||||
"usage: %s [-options] [-] [ filename1 filename2 ... ] \n"
|
||||
"\tProduce packaged ICU data from the given list(s) of files.\n"
|
||||
"\t'-' by itself means to read from stdin.\n",
|
||||
progname);
|
||||
|
||||
fprintf(stderr, "\n options:\n");
|
||||
for(i=0;i<(sizeof(options)/sizeof(options[0]));i++) {
|
||||
fprintf(stderr, "%-5s -%c or --%-10s %s\n",
|
||||
(i<3?"[REQ]":""),
|
||||
options[i].shortName,
|
||||
options[i].longName,
|
||||
options_help[i]);
|
||||
}
|
||||
|
||||
fprintf(stderr, "modes: (-m option)\n");
|
||||
for(i=0;i<(sizeof(modes)/sizeof(modes[0]));i++) {
|
||||
fprintf(stderr, " %-10s %s\n", modes[i].name, modes[i].desc);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* OK, fill in the options struct */
|
||||
uprv_memset(&o, 0, sizeof(o));
|
||||
|
||||
o.mode = options[2].value;
|
||||
|
||||
o.fcn = NULL;
|
||||
|
||||
for(i=0;i<sizeof(modes)/sizeof(modes[0]);i++) {
|
||||
if(!uprv_strcmp(modes[i].name, o.mode)) {
|
||||
o.fcn = modes[i].fcn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(o.fcn == NULL) {
|
||||
fprintf(stderr, "Error: invalid mode '%s' specified. Run '%s --help' to list valid modes.\n", o.mode, progname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
o.shortName = options[0].value;
|
||||
o.options = options[1].value;
|
||||
o.verbose = options[5].doesOccur;
|
||||
if(options[6].doesOccur) {
|
||||
o.comment = U_COPYRIGHT_STRING;
|
||||
} else if (options[7].doesOccur) {
|
||||
o.comment = options[7].value;
|
||||
}
|
||||
|
||||
if( options[8].doesOccur ) {
|
||||
o.targetDir = options[8].value;
|
||||
} else {
|
||||
o.targetDir = ""; /* cwd */
|
||||
}
|
||||
|
||||
o.clean = options[9].doesOccur;
|
||||
o.nooutput = options[10].doesOccur;
|
||||
o.rebuild = options[11].doesOccur;
|
||||
|
||||
if( options[12].doesOccur ) {
|
||||
o.tmpDir = options[12].value;
|
||||
} else {
|
||||
o.tmpDir = o.targetDir;
|
||||
}
|
||||
|
||||
if( options[13].doesOccur ) {
|
||||
o.install = options[13].value;
|
||||
}
|
||||
|
||||
/* OK options are set up. Now the file lists. */
|
||||
tail = NULL;
|
||||
for( i=1; i<argc; i++) {
|
||||
if ( !uprv_strcmp(argv[i] , "-") ) {
|
||||
/* stdin */
|
||||
if( o.hadStdin == TRUE ) {
|
||||
fprintf(stderr, "Error: can't specify '-' twice!\n"
|
||||
"Run '%s --help' for help.\n", progname);
|
||||
return 1;
|
||||
}
|
||||
o.hadStdin = TRUE;
|
||||
}
|
||||
|
||||
o.fileListFiles = pkg_appendToList(o.fileListFiles, &tail, uprv_strdup(argv[i]));
|
||||
}
|
||||
|
||||
/* load the files */
|
||||
loadLists(&o, &status);
|
||||
if( U_FAILURE(status) ) {
|
||||
fprintf(stderr, "error loading input file lists: %s\n", u_errorName(status));
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Makefile pathname */
|
||||
uprv_strcpy(tmp, o.tmpDir);
|
||||
uprv_strcat(tmp, U_FILE_SEP_STRING);
|
||||
uprv_strcat(tmp, o.shortName);
|
||||
uprv_strcat(tmp, "_");
|
||||
uprv_strcat(tmp, o.mode);
|
||||
uprv_strcat(tmp, ".mak"); /* MAY NEED TO CHANGE PER PLATFORM */
|
||||
|
||||
o.makeFile = uprv_strdup(tmp);
|
||||
|
||||
out = T_FileStream_open(o.makeFile, "w");
|
||||
|
||||
pkg_mak_writeHeader(out, &o); /* need to take status */
|
||||
|
||||
o.fcn(&o, out, &status);
|
||||
|
||||
pkg_mak_writeFooter(out, &o);
|
||||
|
||||
T_FileStream_close(out);
|
||||
|
||||
if(U_FAILURE(status)) {
|
||||
fprintf(stderr, "Error creating makefile [%s]: %s\n", o.mode,
|
||||
u_errorName(status));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(o.nooutput == TRUE) {
|
||||
return 0; /* nothing to do. */
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
# error how do you execute things on windows?
|
||||
#else
|
||||
/* POSIX - execute makefile */
|
||||
{
|
||||
char cmd[1024];
|
||||
char *make;
|
||||
int rc;
|
||||
|
||||
make = getenv("MAKE");
|
||||
|
||||
if(!make || !make[0]) {
|
||||
make = "gmake";
|
||||
}
|
||||
|
||||
sprintf(cmd, "cd %s && %s %s%s -f %s %s %s %s",
|
||||
o.tmpDir,
|
||||
make,
|
||||
o.install ? "INSTALLTO=" : "",
|
||||
o.install ? o.install : "",
|
||||
o.makeFile,
|
||||
o.clean ? "clean" : "",
|
||||
o.rebuild ? "rebuild" : "",
|
||||
o.install ? "install" : "");
|
||||
if(o.verbose) {
|
||||
puts(cmd);
|
||||
}
|
||||
|
||||
rc = system(cmd);
|
||||
|
||||
if(rc < 0) {
|
||||
fprintf(stderr, "# Failed, rc=%d\n", rc);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void loadLists(UPKGOptions *o, UErrorCode *status)
|
||||
{
|
||||
CharList *l, *tail = NULL, *tail2 = NULL;
|
||||
FileStream *in;
|
||||
char line[2048];
|
||||
char *s;
|
||||
|
||||
for(l = o->fileListFiles; l; l = l->next) {
|
||||
if(o->verbose) {
|
||||
fprintf(stderr, "# Reading %s..\n", l->str);
|
||||
}
|
||||
|
||||
/* TODO: stdin */
|
||||
in = T_FileStream_open(l->str, "r");
|
||||
|
||||
if(!in) {
|
||||
fprintf(stderr, "Error opening <%s>.\n", l->str);
|
||||
*status = U_FILE_ACCESS_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
while(T_FileStream_readLine(in, line, sizeof(line))!=NULL) {
|
||||
/* remove trailing newline characters */
|
||||
s=line;
|
||||
while(*s!=0) {
|
||||
if(*s=='\r' || *s=='\n') {
|
||||
*s=0;
|
||||
break;
|
||||
}
|
||||
++s;
|
||||
}
|
||||
if((*line == 0) || (*line == '#')) {
|
||||
continue; /* comment or empty line */
|
||||
}
|
||||
|
||||
/* add the file */
|
||||
s = (char*)getLongPathname(line);
|
||||
|
||||
o->files = pkg_appendToList(o->files, &tail, uprv_strdup(findBasename(s)));
|
||||
o->filePaths = pkg_appendToList(o->filePaths, &tail2, uprv_strdup(s));
|
||||
}
|
||||
|
||||
T_FileStream_close(in);
|
||||
}
|
||||
}
|
||||
|
||||
|
164
icu4c/source/tools/pkgdata/pkgtypes.c
Normal file
164
icu4c/source/tools/pkgdata/pkgtypes.c
Normal file
@ -0,0 +1,164 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2000, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
***************************************************************************
|
||||
* file name: pkgdata.c
|
||||
* encoding: ANSI X3.4 (1968)
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
* created on: 2000may16
|
||||
* created by: Steven \u24C7 Loomis
|
||||
*
|
||||
* common types for pkgdata
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
#include "pkgtypes.h"
|
||||
|
||||
const char *pkg_writeCharListWrap(FileStream *s, CharList *l, const char *delim, const char *brk)
|
||||
{
|
||||
int32_t ln = 0;
|
||||
while(l != NULL)
|
||||
{
|
||||
if(l->str)
|
||||
{
|
||||
T_FileStream_write(s, l->str, uprv_strlen(l->str));
|
||||
}
|
||||
|
||||
ln += uprv_strlen(l->str);
|
||||
|
||||
|
||||
if(l->next && delim)
|
||||
{
|
||||
if(ln > 60 && brk) {
|
||||
ln = 0;
|
||||
T_FileStream_write(s, brk, uprv_strlen(brk));
|
||||
}
|
||||
T_FileStream_write(s, delim, uprv_strlen(delim));
|
||||
}
|
||||
l = l->next;
|
||||
}
|
||||
}
|
||||
|
||||
const char *pkg_writeCharList(FileStream *s, CharList *l, const char *delim)
|
||||
{
|
||||
while(l != NULL)
|
||||
{
|
||||
if(l->str)
|
||||
{
|
||||
T_FileStream_write(s, l->str, uprv_strlen(l->str));
|
||||
}
|
||||
|
||||
if(l->next && delim)
|
||||
{
|
||||
T_FileStream_write(s, delim, uprv_strlen(delim));
|
||||
}
|
||||
l = l->next;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Count items . 0 if null
|
||||
*/
|
||||
uint32_t pkg_countCharList(CharList *l)
|
||||
{
|
||||
uint32_t c = 0;
|
||||
while(l != NULL)
|
||||
{
|
||||
c++;
|
||||
l = l->next;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepend string to CharList
|
||||
*/
|
||||
CharList *pkg_prependToList(CharList *l, const char *str)
|
||||
{
|
||||
CharList *newList;
|
||||
newList = uprv_malloc(sizeof(CharList));
|
||||
newList->str = str;
|
||||
newList->next = l;
|
||||
return newList;
|
||||
}
|
||||
|
||||
/*
|
||||
* append string to CharList. *end or even end can be null if you don't
|
||||
* know it.[slow]
|
||||
* Str is adopted!
|
||||
*/
|
||||
CharList *pkg_appendToList(CharList *l, CharList** end, const char *str)
|
||||
{
|
||||
CharList *endptr, *tmp;
|
||||
|
||||
if(end == NULL)
|
||||
{
|
||||
end = &endptr;
|
||||
}
|
||||
|
||||
/* FIND the end */
|
||||
if((*end == NULL) && (l != NULL))
|
||||
{
|
||||
tmp = l;
|
||||
while(tmp->next)
|
||||
{
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
*end = tmp;
|
||||
}
|
||||
|
||||
/* Create a new empty list and append it */
|
||||
if(l == NULL)
|
||||
{
|
||||
l = pkg_prependToList(NULL, str);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*end)->next = pkg_prependToList(NULL, str);
|
||||
}
|
||||
|
||||
/* Move the end pointer. */
|
||||
if(*end)
|
||||
{
|
||||
(*end) = (*end)->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
*end = l;
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete list
|
||||
*/
|
||||
void pkg_deleteList(CharList *l)
|
||||
{
|
||||
CharList *next;
|
||||
|
||||
while(l != NULL)
|
||||
{
|
||||
uprv_free((void*)l->str);
|
||||
l = l->next;
|
||||
}
|
||||
}
|
||||
|
||||
bool_t pkg_listContains(CharList *l, const char *str)
|
||||
{
|
||||
for(;l;l=l->next){
|
||||
if(!uprv_strcmp(l->str, str)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
130
icu4c/source/tools/pkgdata/pkgtypes.h
Normal file
130
icu4c/source/tools/pkgdata/pkgtypes.h
Normal file
@ -0,0 +1,130 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2000, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
***************************************************************************
|
||||
* file name: pkgdata.c
|
||||
* encoding: ANSI X3.4 (1968)
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
* created on: 2000may16
|
||||
* created by: Steven \u24C7 Loomis
|
||||
*
|
||||
* common types for pkgdata
|
||||
*/
|
||||
|
||||
#ifndef _PKGTYPES
|
||||
#define _PKGTYPES
|
||||
|
||||
/* headers */
|
||||
#include "unicode/utypes.h"
|
||||
#include "filestrm.h"
|
||||
|
||||
/* linked list */
|
||||
struct _CharList;
|
||||
|
||||
typedef struct _CharList
|
||||
{
|
||||
const char *str;
|
||||
struct _CharList *next;
|
||||
} CharList;
|
||||
|
||||
|
||||
/*
|
||||
* write CharList 'l' into stream 's' using deliminter 'delim' (delim can be NULL)
|
||||
*/
|
||||
const char *pkg_writeCharList(FileStream *s, CharList *l, const char *delim);
|
||||
|
||||
/*
|
||||
* Same, but use line breaks
|
||||
*/
|
||||
const char *pkg_writeCharListWrap(FileStream *s, CharList *l, const char *delim, const char *brk);
|
||||
|
||||
/*
|
||||
* Count items . 0 if null
|
||||
*/
|
||||
uint32_t pkg_countCharList(CharList *l);
|
||||
|
||||
/*
|
||||
* Prepend string to CharList. Str is adopted!
|
||||
*/
|
||||
CharList *pkg_prependToList(CharList *l, const char *str);
|
||||
|
||||
/*
|
||||
* append string to CharList. *end or even end can be null if you don't
|
||||
* know it.[slow]
|
||||
* Str is adopted!
|
||||
*/
|
||||
CharList *pkg_appendToList(CharList *l, CharList** end, const char *str);
|
||||
|
||||
/*
|
||||
* does list contain string? Returns: t/f
|
||||
*/
|
||||
bool_t pkg_listContains(CharList *l, const char *str);
|
||||
|
||||
/*
|
||||
* Delete list
|
||||
*/
|
||||
void pkg_deleteList(CharList *l);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Mode package function
|
||||
*/
|
||||
struct UPKGOptions_;
|
||||
typedef void (UPKGMODE)(struct UPKGOptions_ *, FileStream *s, UErrorCode *status);
|
||||
|
||||
/*
|
||||
* Options to be passed throughout the program
|
||||
*/
|
||||
|
||||
typedef struct UPKGOptions_
|
||||
{
|
||||
CharList *fileListFiles; /* list of files containing files for inclusion in the package */
|
||||
CharList *filePaths; /* All the files, with long paths */
|
||||
CharList *files; /* All the files */
|
||||
CharList *outFiles; /* output files [full paths] */
|
||||
|
||||
const char *shortName; /* name of what we're building */
|
||||
const char *targetDir;
|
||||
const char *tmpDir;
|
||||
const char *options; /* Options arg */
|
||||
const char *mode; /* Mode of building */
|
||||
const char *comment; /* comment string */
|
||||
const char *makeFile; /* Makefile path */
|
||||
const char *install; /* Where to install to (NULL = don't install) */
|
||||
bool_t rebuild;
|
||||
bool_t clean;
|
||||
bool_t nooutput;
|
||||
bool_t verbose;
|
||||
bool_t hadStdin; /* Stdin was a dependency - don't make anything depend on the file list coming in. */
|
||||
|
||||
UPKGMODE *fcn; /* Handler function */
|
||||
} UPKGOptions;
|
||||
|
||||
|
||||
/* set up common defines for library naming */
|
||||
|
||||
#ifdef WIN32
|
||||
# ifndef UDATA_SO_SUFFIX
|
||||
# define UDATA_SO_SUFFIX ".DLL"
|
||||
# endif
|
||||
# define LIB_PREFIX ""
|
||||
# define OBJ_SUFFIX ".obj"
|
||||
|
||||
#else /* POSIX? */
|
||||
# define LIB_PREFIX "lib"
|
||||
# define OBJ_SUFFIX ".o"
|
||||
#endif
|
||||
|
||||
|
||||
/* defines for common file names */
|
||||
#define UDATA_CMN_PREFIX ""
|
||||
#define UDATA_CMN_SUFFIX ".dat"
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user