mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-4501 Update samples to use the current data building procedure and fix a few other problems found along the way.
This helps with debugging some of the cause of the data loading problems. X-SVN-Rev: 17550
This commit is contained in:
parent
ae051c6701
commit
264d88b4b3
7 changed files with 34 additions and 35 deletions
|
@ -14,7 +14,7 @@ LDFLAGS =$(shell icu-config --ldflags)
|
|||
LDFLAGS_USTDIO =$(shell icu-config --ldflags-icuio)
|
||||
INVOKE=$(shell icu-config --invoke)
|
||||
GENRB=$(shell icu-config --invoke=genrb)
|
||||
GENRBOPT=--package-name $(RESNAME)
|
||||
GENRBOPT=
|
||||
PKGDATA=$(shell icu-config --invoke=pkgdata)
|
||||
SO=$(shell icu-config --so)
|
||||
PKGDATAOPTS=-v -d .
|
||||
|
@ -25,4 +25,4 @@ RESMODE=$(shell icu-config --icudata-mode)
|
|||
### Project independent things (common)
|
||||
### We depend on gmake for the bulk of the work
|
||||
|
||||
RMV=rm -rf
|
||||
RMV=rm -rf
|
||||
|
|
|
@ -17,14 +17,18 @@ res-install: $(RESTARGET)
|
|||
|
||||
# clean out files
|
||||
distclean clean: $(CLEAN_SUBDIR)
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
-rm $(OBJECTS) $(TARGET) $(RESTARGET) $(RESFILES)
|
||||
-test -z "$(CLEANFILES)" || rm -rf $(CLEANFILES)
|
||||
-rm -rf $(OBJECTS) $(TARGET) $(RESTARGET) $(RESFILES)
|
||||
|
||||
# Make check: simply runs the sample, logged to a file
|
||||
check: $(TARGET)
|
||||
$(INVOKE) $(CHECK_VARS) ./$(TARGET) $(CHECK_ARGS) | tee $(TARGET).out
|
||||
|
||||
## resources
|
||||
$(RESNAME)_%.res: %.txt
|
||||
%.res: %.txt
|
||||
@echo "generating $@"
|
||||
$(GENRB) $(GENRBOPT) $^
|
||||
|
||||
$(RESNAME)/%.res: %.txt
|
||||
@echo "generating $@"
|
||||
$(GENRB) $(GENRBOPT) $^
|
||||
|
|
|
@ -28,17 +28,22 @@ include ../../defs.mk
|
|||
|
||||
# No conventional target - this dir is resources only.
|
||||
TARGET=
|
||||
CLEANFILES += *.mak *.[co] *.lst *.a *.$(SO) $(RESFILES) *.ao README*resources.txt
|
||||
CLEANFILES += *.[co] *.lst $(RESNAME)_*.mak $(RESNAME).dat $(RESFILES) *.ao README*resources.txt
|
||||
|
||||
include ../fortunedefs.mk
|
||||
|
||||
# target file for resource bundle - this must be set, or 'make all' won't
|
||||
# build any resources.
|
||||
ifeq ($(RESMODE),dll)
|
||||
RESTARGET=lib$(RESNAME).$(SO)
|
||||
endif
|
||||
ifeq ($(RESMODE),static)
|
||||
RESTARGET=lib$(RESNAME).a
|
||||
endif
|
||||
|
||||
# Resource files. Add new ones for additional locales here.
|
||||
# keep in sync with the file RESLIST
|
||||
RESFILES=$(RESNAME)_root.res $(RESNAME)_es.res
|
||||
RESFILES=root.res es.res
|
||||
|
||||
# list of resource bundles - keep in sync with RESFILES
|
||||
RESLIST=res-file-list.txt
|
||||
|
@ -49,6 +54,7 @@ include ../../rules.mk
|
|||
# for installing the library
|
||||
install: res-install
|
||||
|
||||
$(RESNAME)_es.res: es.txt
|
||||
es.res: es.txt
|
||||
@echo "generating $@"
|
||||
$(GENRB) $(GENRBOPT) -e latin-1 $^
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
fortune_resources_root.res
|
||||
fortune_resources_es.res
|
||||
root.res
|
||||
es.res
|
||||
|
|
|
@ -100,13 +100,13 @@ int main(int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
|
||||
/* ICU's ustdio package provides a convenient way to write Unicode
|
||||
/* ICU's icuio package provides a convenient way to write Unicode
|
||||
* data to stdout. The string data that we get from resources
|
||||
* will be UChar * strings, which ustdio can handle nicely.
|
||||
* will be UChar * strings, which icuio can handle nicely.
|
||||
*/
|
||||
u_stdout = u_finit(stdout, NULL /*locale*/, NULL /*codepage */);
|
||||
if (verbose) {
|
||||
u_fprintf(u_stdout, "%s: checking output via ustdio.\n", programName);
|
||||
u_fprintf(u_stdout, "%s: checking output via icuio.\n", programName);
|
||||
}
|
||||
|
||||
#ifndef UFORTUNE_NOSETAPPDATA
|
||||
|
@ -117,7 +117,7 @@ int main(int argc, char **argv)
|
|||
*/
|
||||
udata_setAppData("fortune_resources", &fortune_resources_dat, &err);
|
||||
if (U_FAILURE(err)) {
|
||||
fprintf(stderr, "%s: ures_open failed with error \"%s\"\n", programName, u_errorName(err));
|
||||
fprintf(stderr, "%s: udata_setAppData failed with error \"%s\"\n", programName, u_errorName(err));
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
|
@ -183,7 +183,7 @@ int main(int argc, char **argv)
|
|||
exit(-1);
|
||||
}
|
||||
if (numFortunes <= 0) {
|
||||
fprintf(stderr, "%s: no fortunes found.\n");
|
||||
fprintf(stderr, "%s: no fortunes found.\n", programName);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ ifeq ($(strip $(ICU_PATH)),)
|
|||
ICU_PATH=$(ICU_DEFAULT_PATH)
|
||||
endif
|
||||
|
||||
GENRBOPT = -s. -d. --package-name $(PKG)
|
||||
GENRBOPT = -s. -d.
|
||||
|
||||
# Name of your target
|
||||
TARGET=uresb
|
||||
PKG=$(TARGET)
|
||||
RES_SRC=root.txt en.txt sr.txt
|
||||
RESOURCES=$(RES_SRC:%.txt=$(PKG)_%.res)
|
||||
RESOURCES=$(RES_SRC:%.txt=%.res)
|
||||
|
||||
# All object files (C or C++)
|
||||
OBJECTS=uresb.o
|
||||
|
@ -45,16 +45,16 @@ LDFLAGS += -L$(ICU_PATH)/source/tools/toolutil $(shell icu-config --ldflags-tool
|
|||
|
||||
distclean clean:
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
-$(RMV) $(OBJECTS) $(TARGET)
|
||||
-$(RMV) $(OBJECTS) $(TARGET) $(RESOURCES)
|
||||
|
||||
|
||||
## resources
|
||||
$(PKG)_%.res: %.txt
|
||||
%.res: %.txt
|
||||
@echo "generating $@"
|
||||
$(GENRB) $(GENRBOPT) $^
|
||||
|
||||
## Special for a special codepage
|
||||
$(PKG)_sr.res : sr.txt
|
||||
sr.res : sr.txt
|
||||
@echo "generating $@"
|
||||
$(GENRB) $(GENRBOPT) -e cp1251 $?
|
||||
|
||||
|
@ -75,14 +75,3 @@ $(TARGET).report: check $(TARGET).cpp
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -122,8 +122,8 @@ main(int argc, char* argv[]) {
|
|||
}
|
||||
} else {
|
||||
strcpy(resPathBuffer, currdir);
|
||||
strcat(resPathBuffer, U_FILE_SEP_STRING);
|
||||
strcat(resPathBuffer, "uresb");
|
||||
/*strcat(resPathBuffer, U_FILE_SEP_STRING);
|
||||
strcat(resPathBuffer, "uresb");*/
|
||||
resPath = resPathBuffer; /* we'll just dump uresb samples resources */
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,6 @@ static UChar *quotedString(const UChar *string) {
|
|||
}
|
||||
|
||||
void printOutBundle(UFILE *out, UResourceBundle *resource, int32_t indent, UErrorCode *status) {
|
||||
int32_t noOfElements = ures_getSize(resource);
|
||||
int32_t i = 0;
|
||||
const char *key = ures_getKey(resource);
|
||||
|
||||
|
@ -355,7 +354,7 @@ void printOutBundle(UFILE *out, UResourceBundle *resource, int32_t indent, UErro
|
|||
}
|
||||
|
||||
void reportError(UErrorCode *status) {
|
||||
u_fprintf(outerr, "Error %d : %U happened!\n", *status, getErrorName(*status));
|
||||
u_fprintf(outerr, "Error %d(%s) : %U happened!\n", *status, u_errorName(*status), getErrorName(*status));
|
||||
}
|
||||
|
||||
|
||||
|
@ -379,3 +378,4 @@ const UChar *getErrorName(UErrorCode errorNumber) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue