mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-13 08:53:20 +00:00
ICU-2487 move collation data into new tree
X-SVN-Rev: 14967
This commit is contained in:
parent
90cbe55253
commit
207167f8be
19 changed files with 460 additions and 241 deletions
|
@ -386,7 +386,14 @@ writeCCode(const char *filename, const char *destdir) {
|
|||
exit(U_FILE_ACCESS_ERROR);
|
||||
}
|
||||
|
||||
getOutFilename(filename, destdir, buffer, entry, ".c");
|
||||
if(options[kOptName].doesOccur) { /* prepend 'icudt28_' */
|
||||
strcpy(entry, options[kOptName].value);
|
||||
strcat(entry, "_");
|
||||
} else {
|
||||
entry[0] = 0;
|
||||
}
|
||||
|
||||
getOutFilename(filename, destdir, buffer, entry+uprv_strlen(entry), ".c");
|
||||
out=T_FileStream_open(buffer, "w");
|
||||
if(out==NULL) {
|
||||
fprintf(stderr, "genccode: unable to open output file %s\n", buffer);
|
||||
|
@ -400,7 +407,7 @@ writeCCode(const char *filename, const char *destdir) {
|
|||
entry[i]='_';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef OS400
|
||||
/*
|
||||
TODO: Fix this once the compiler implements this feature. Keep in sync with udatamem.c
|
||||
|
|
|
@ -98,6 +98,7 @@ typedef struct {
|
|||
|
||||
static File files[MAX_FILE_COUNT];
|
||||
static uint32_t fileCount=0;
|
||||
static UBool embed = FALSE;
|
||||
|
||||
/* prototypes --------------------------------------------------------------- */
|
||||
|
||||
|
@ -110,6 +111,9 @@ allocString(uint32_t length);
|
|||
static int
|
||||
compareFiles(const void *file1, const void *file2);
|
||||
|
||||
static char *
|
||||
pathToFullPath(const char *path);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static UOption options[]={
|
||||
|
@ -122,7 +126,9 @@ static UOption options[]={
|
|||
/*6*/ UOPTION_DEF( "name", 'n', UOPT_REQUIRES_ARG),
|
||||
/*7*/ UOPTION_DEF( "type", 't', UOPT_REQUIRES_ARG),
|
||||
/*8*/ UOPTION_DEF( "source", 'S', UOPT_NO_ARG),
|
||||
/*9*/ UOPTION_DEF( "entrypoint", 'e', UOPT_REQUIRES_ARG)
|
||||
/*9*/ UOPTION_DEF( "entrypoint", 'e', UOPT_REQUIRES_ARG),
|
||||
/*10*/UOPTION_SOURCEDIR,
|
||||
/*11*/ UOPTION_DEF( "embed", 'E', UOPT_NO_ARG)
|
||||
};
|
||||
|
||||
static char *symPrefix = NULL;
|
||||
|
@ -144,6 +150,7 @@ main(int argc, char* argv[]) {
|
|||
options[4].value=u_getDataDirectory();
|
||||
options[6].value=COMMON_DATA_NAME;
|
||||
options[7].value=DATA_TYPE;
|
||||
options[10].value=".";
|
||||
argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);
|
||||
|
||||
/* error handling, printing usage message */
|
||||
|
@ -154,6 +161,11 @@ main(int argc, char* argv[]) {
|
|||
} else if(argc<2) {
|
||||
argc=-1;
|
||||
}
|
||||
|
||||
if(options[11].doesOccur) {
|
||||
embed = TRUE;
|
||||
}
|
||||
|
||||
if(argc<0 || options[0].doesOccur || options[1].doesOccur) {
|
||||
FILE *where = argc < 0 ? stderr : stdout;
|
||||
|
||||
|
@ -314,7 +326,7 @@ main(int argc, char* argv[]) {
|
|||
length=files[i].fileSize;
|
||||
|
||||
if (nread != files[i].fileSize) {
|
||||
fprintf(stderr, "gencmn: unable to read %s properly (got %ld/%ld byte%s)\n", files[i].pathname, (long)nread, (long)files[i].fileSize, files[i].fileSize == 1 ? "" : "s");
|
||||
fprintf(stderr, "gencmn: unable to read %s properly (got %ld/%ld byte%s)\n", files[i].pathname, (long)nread, (long)files[i].fileSize, files[i].fileSize == 1 ? "" : "s");
|
||||
exit(U_FILE_ACCESS_ERROR);
|
||||
}
|
||||
}
|
||||
|
@ -368,16 +380,18 @@ main(int argc, char* argv[]) {
|
|||
|
||||
|
||||
#if 0
|
||||
symPrefix = (char *) uprv_malloc(uprv_strlen(entrypointName) + 2);
|
||||
|
||||
/* test for NULL */
|
||||
if (symPrefix == NULL) {
|
||||
if(!embed) {
|
||||
symPrefix = (char *) uprv_malloc(uprv_strlen(entrypointName) + 2);
|
||||
|
||||
/* test for NULL */
|
||||
if (symPrefix == NULL) {
|
||||
sprintf(buffer, "U_MEMORY_ALLOCATION_ERROR");
|
||||
exit(U_MEMORY_ALLOCATION_ERROR);
|
||||
}
|
||||
|
||||
uprv_strcpy(symPrefix, entrypointName);
|
||||
uprv_strcat(symPrefix, "_");
|
||||
}
|
||||
|
||||
uprv_strcpy(symPrefix, entrypointName);
|
||||
uprv_strcat(symPrefix, "_");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* write the source file */
|
||||
|
@ -453,6 +467,7 @@ static void
|
|||
addFile(const char *filename, UBool sourceTOC, UBool verbose) {
|
||||
char *s;
|
||||
uint32_t length;
|
||||
char *fullPath = NULL;
|
||||
|
||||
if(fileCount==MAX_FILE_COUNT) {
|
||||
fprintf(stderr, "gencmn: too many files, maximum is %d\n", MAX_FILE_COUNT);
|
||||
|
@ -461,39 +476,54 @@ addFile(const char *filename, UBool sourceTOC, UBool verbose) {
|
|||
|
||||
if(!sourceTOC) {
|
||||
FileStream *file;
|
||||
char *fullPath;
|
||||
|
||||
fullPath = pathToFullPath(filename);
|
||||
|
||||
/* store the pathname */
|
||||
length = (uint32_t)(uprv_strlen(filename) + 1);
|
||||
s=allocString(length);
|
||||
uprv_memcpy(s, filename, length);
|
||||
files[fileCount].pathname=s;
|
||||
if(!embed) {
|
||||
length = (uint32_t)(uprv_strlen(filename) + 1 + uprv_strlen(options[6].value) + 1);
|
||||
s=allocString(length);
|
||||
uprv_strcpy(s, options[6].value);
|
||||
uprv_strcat(s, U_TREE_SEPARATOR_STRING);
|
||||
uprv_strcat(s, filename);
|
||||
} else {
|
||||
/* compatibility mode */
|
||||
const char *base;
|
||||
base = findBasename(filename);
|
||||
length = (uint32_t)(uprv_strlen(base) + 1);
|
||||
s=allocString(length);
|
||||
uprv_memcpy(s, base, length);
|
||||
}
|
||||
|
||||
/* get the basename */
|
||||
s=(char *)findBasename(s);
|
||||
files[fileCount].basename=s;
|
||||
length = (uint32_t)(uprv_strlen(s) + 1);
|
||||
files[fileCount].basenameLength=length;
|
||||
|
||||
files[fileCount].pathname=fullPath;
|
||||
|
||||
basenameTotal+=length;
|
||||
|
||||
/* try to open the file */
|
||||
file=T_FileStream_open(filename, "rb");
|
||||
file=T_FileStream_open(fullPath, "rb");
|
||||
if(file==NULL) {
|
||||
fprintf(stderr, "gencmn: unable to open listed file %s\n", filename);
|
||||
fprintf(stderr, "gencmn: unable to open listed file %s\n", fullPath);
|
||||
exit(U_FILE_ACCESS_ERROR);
|
||||
}
|
||||
|
||||
/* get the file length */
|
||||
length=T_FileStream_size(file);
|
||||
if(T_FileStream_error(file) || length<=20) {
|
||||
fprintf(stderr, "gencmn: unable to get length of listed file %s\n", filename);
|
||||
fprintf(stderr, "gencmn: unable to get length of listed file %s\n", fullPath);
|
||||
exit(U_FILE_ACCESS_ERROR);
|
||||
}
|
||||
|
||||
T_FileStream_close(file);
|
||||
|
||||
/* do not add files that are longer than maxSize */
|
||||
if(maxSize && length>maxSize) {
|
||||
if (verbose) {
|
||||
printf("%s ignored (size %ld > %ld)\n", filename, (long)length, (long)maxSize);
|
||||
printf("%s ignored (size %ld > %ld)\n", fullPath, (long)length, (long)maxSize);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -501,17 +531,29 @@ addFile(const char *filename, UBool sourceTOC, UBool verbose) {
|
|||
} else {
|
||||
char *t;
|
||||
|
||||
if(embed) {
|
||||
filename = findBasename(filename);
|
||||
}
|
||||
/* get and store the basename */
|
||||
filename=findBasename(filename);
|
||||
length = (uint32_t)(uprv_strlen(filename) + 1);
|
||||
s=allocString(length);
|
||||
uprv_memcpy(s, filename, length);
|
||||
if(!embed) {
|
||||
/* need to include the package name */
|
||||
length = (uint32_t)(uprv_strlen(filename) + 1 + uprv_strlen(options[6].value) + 1);
|
||||
s=allocString(length);
|
||||
uprv_strcpy(s, options[6].value);
|
||||
uprv_strcat(s, "/");
|
||||
uprv_strcat(s, filename);
|
||||
} else {
|
||||
length = (uint32_t)(uprv_strlen(filename) + 1);
|
||||
s=allocString(length);
|
||||
uprv_memcpy(s, filename, length);
|
||||
}
|
||||
files[fileCount].basename=s;
|
||||
|
||||
|
||||
/* turn the basename into an entry point name and store in the pathname field */
|
||||
t=files[fileCount].pathname=allocString(length);
|
||||
while(--length>0) {
|
||||
if(*s=='.' || *s=='-') {
|
||||
if(*s=='.' || *s=='-' || *s=='/') {
|
||||
*t='_';
|
||||
} else {
|
||||
*t=*s;
|
||||
|
@ -521,7 +563,6 @@ addFile(const char *filename, UBool sourceTOC, UBool verbose) {
|
|||
}
|
||||
*t=0;
|
||||
}
|
||||
|
||||
++fileCount;
|
||||
}
|
||||
|
||||
|
@ -539,6 +580,38 @@ allocString(uint32_t length) {
|
|||
return p;
|
||||
}
|
||||
|
||||
static char *
|
||||
pathToFullPath(const char *path) {
|
||||
int32_t length;
|
||||
int32_t newLength;
|
||||
char *fullPath;
|
||||
int32_t n;
|
||||
|
||||
length = (uint32_t)(uprv_strlen(path) + 1);
|
||||
newLength = (length + 1 + uprv_strlen(options[10].value));
|
||||
fullPath = uprv_malloc(newLength);
|
||||
if(options[10].doesOccur) {
|
||||
uprv_strcpy(fullPath, options[10].value);
|
||||
uprv_strcat(fullPath, U_FILE_SEP_STRING);
|
||||
} else {
|
||||
fullPath[0] = 0;
|
||||
}
|
||||
n = uprv_strlen(fullPath);
|
||||
uprv_strcat(fullPath, path);
|
||||
|
||||
if(!embed) {
|
||||
if(U_FILE_SEP_CHAR != U_TREE_SEPARATOR) {
|
||||
/* replace tree separator (such as '/') with file sep char (such as ':' or '\\') */
|
||||
for(;fullPath[n];n++) {
|
||||
if(fullPath[n] == U_TREE_SEPARATOR) {
|
||||
fullPath[n] = U_FILE_SEP_CHAR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
static int
|
||||
compareFiles(const void *file1, const void *file2) {
|
||||
/* sort by basename */
|
||||
|
|
|
@ -277,7 +277,7 @@ main(int argc, char* argv[]) {
|
|||
T_FileStream_close(in);
|
||||
|
||||
/* create the output file */
|
||||
out=udata_create(options[DESTDIR].value, DATA_TYPE, U_ICUDATA_NAME "_" DATA_NAME, &dataInfo,
|
||||
out=udata_create(options[DESTDIR].value, DATA_TYPE, DATA_NAME, &dataInfo,
|
||||
options[COPYRIGHT].doesOccur ? U_COPYRIGHT_STRING : NULL, &errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
fprintf(stderr, "gencnval: unable to open output file - error %s\n", u_errorName(errorCode));
|
||||
|
|
|
@ -321,7 +321,7 @@ main(int argc, char* argv[]) {
|
|||
"Usage: %s [-1[+|-]] [-v[+|-]] [-c[+|-]] filename\n"
|
||||
"\n"
|
||||
"Read the UnicodeData.txt file and \n"
|
||||
"create a binary file " U_ICUDATA_NAME "_" DATA_NAME "." DATA_TYPE " with the character names\n"
|
||||
"create a binary file " DATA_NAME "." DATA_TYPE " with the character names\n"
|
||||
"\n"
|
||||
"\tfilename absolute path/filename for the Unicode database text file\n"
|
||||
"\t\t(default: standard input)\n"
|
||||
|
@ -846,7 +846,7 @@ generateData(const char *dataDir) {
|
|||
long dataLength;
|
||||
int16_t token;
|
||||
|
||||
pData=udata_create(dataDir, DATA_TYPE,U_ICUDATA_NAME "_" DATA_NAME, &dataInfo,
|
||||
pData=udata_create(dataDir, DATA_TYPE,DATA_NAME, &dataInfo,
|
||||
haveCopyright ? U_COPYRIGHT_STRING : NULL, &errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
fprintf(stderr, "gennames: unable to create data memory, error %d\n", errorCode);
|
||||
|
|
|
@ -1809,7 +1809,7 @@ generateData(const char *dataDir) {
|
|||
#endif
|
||||
|
||||
/* write the data */
|
||||
pData=udata_create(dataDir, DATA_TYPE, U_ICUDATA_NAME "_" DATA_NAME, &dataInfo,
|
||||
pData=udata_create(dataDir, DATA_TYPE, DATA_NAME, &dataInfo,
|
||||
haveCopyright ? U_COPYRIGHT_STRING : NULL, &errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
fprintf(stderr, "gennorm: unable to create the output file, error %d\n", errorCode);
|
||||
|
|
|
@ -1095,7 +1095,7 @@ int genpname::MMain(int argc, char* argv[])
|
|||
debug < 0 || debug > 9) {
|
||||
fprintf(stderr,
|
||||
"usage: %s [-options]\n"
|
||||
"\tcreate " U_ICUDATA_NAME "_" PNAME_DATA_NAME "." PNAME_DATA_TYPE "\n"
|
||||
"\tcreate " PNAME_DATA_NAME "." PNAME_DATA_TYPE "\n"
|
||||
"options:\n"
|
||||
"\t-h or -? or --help this usage text\n"
|
||||
"\t-v or --verbose turn on verbose output\n"
|
||||
|
@ -1196,7 +1196,7 @@ int32_t genpname::writeDataFile(const char *destdir, const Builder& builder) {
|
|||
UNewDataMemory *pdata;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
pdata = udata_create(destdir, PNAME_DATA_TYPE, U_ICUDATA_NAME "_" PNAME_DATA_NAME, &dataInfo,
|
||||
pdata = udata_create(destdir, PNAME_DATA_TYPE, PNAME_DATA_NAME, &dataInfo,
|
||||
useCopyright ? U_COPYRIGHT_STRING : 0, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
die("Unable to create data memory");
|
||||
|
|
|
@ -817,7 +817,7 @@ generateData(const char *dataDir) {
|
|||
}
|
||||
|
||||
/* write the data */
|
||||
pData=udata_create(dataDir, DATA_TYPE, U_ICUDATA_NAME "_" DATA_NAME, &dataInfo,
|
||||
pData=udata_create(dataDir, DATA_TYPE, DATA_NAME, &dataInfo,
|
||||
haveCopyright ? U_COPYRIGHT_STRING : NULL, &errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
fprintf(stderr, "genprops: unable to create data memory, %s\n", u_errorName(errorCode));
|
||||
|
|
|
@ -147,7 +147,7 @@ main(int argc, char* argv[]) {
|
|||
options[SOURCEDIR].value="";
|
||||
options[UNICODE_VERSION].value="0"; /* don't assume the unicode version */
|
||||
options[BUNDLE_NAME].value = DATA_NAME;
|
||||
options[PACKAGE_NAME].value = U_ICUDATA_NAME;
|
||||
options[PACKAGE_NAME].value = NULL;
|
||||
options[NORMALIZE].value = "";
|
||||
|
||||
argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);
|
||||
|
|
|
@ -615,9 +615,13 @@ generateData(const char *dataDir, const char *packageName, const char* bundleNam
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
uprv_strcpy(fileName,packageName);
|
||||
uprv_strcat(fileName,"_");
|
||||
|
||||
if(packageName != NULL) {
|
||||
uprv_strcpy(fileName,packageName);
|
||||
uprv_strcat(fileName,"_");
|
||||
} else {
|
||||
fileName[0]=0;
|
||||
}
|
||||
uprv_strcat(fileName,bundleName);
|
||||
/* write the data */
|
||||
pData=udata_create(dataDir, DATA_TYPE, fileName, &dataInfo,
|
||||
|
|
|
@ -353,7 +353,7 @@ static void writeOutInverseData(InverseUCATableHeader *data,
|
|||
uprv_memcpy(&invUcaInfo, &invUcaDataInfo, sizeof(UDataInfo));
|
||||
u_getUnicodeVersion(invUcaInfo.dataVersion);
|
||||
|
||||
pData=udata_create(outputDir, INVC_DATA_TYPE, U_ICUDATA_NAME "_" INVC_DATA_NAME, &invUcaInfo,
|
||||
pData=udata_create(outputDir, INVC_DATA_TYPE, INVC_DATA_NAME, &invUcaInfo,
|
||||
copyright, status);
|
||||
|
||||
if(U_FAILURE(*status)) {
|
||||
|
@ -364,7 +364,7 @@ static void writeOutInverseData(InverseUCATableHeader *data,
|
|||
/* write the data to the file */
|
||||
if (VERBOSE) {
|
||||
fprintf(stdout, "Writing out inverse UCA table: %s%c%s.%s\n", outputDir, U_FILE_SEP_CHAR,
|
||||
U_ICUDATA_NAME "_" INVC_DATA_NAME,
|
||||
INVC_DATA_NAME,
|
||||
INVC_DATA_TYPE);
|
||||
}
|
||||
udata_writeBlock(pData, data, data->byteSize);
|
||||
|
@ -700,7 +700,7 @@ void writeOutData(UCATableHeader *data,
|
|||
uprv_memcpy(&ucaInfo, &ucaDataInfo, sizeof(UDataInfo));
|
||||
u_getUnicodeVersion(ucaInfo.dataVersion);
|
||||
|
||||
pData=udata_create(outputDir, UCA_DATA_TYPE, U_ICUDATA_NAME "_" UCA_DATA_NAME, &ucaInfo,
|
||||
pData=udata_create(outputDir, UCA_DATA_TYPE, UCA_DATA_NAME, &ucaInfo,
|
||||
copyright, status);
|
||||
|
||||
if(U_FAILURE(*status)) {
|
||||
|
@ -1104,16 +1104,16 @@ int main(int argc, char* argv[]) {
|
|||
UNewDataMemory *pData;
|
||||
const char *msg;
|
||||
|
||||
msg = "genuca writes dummy " U_ICUDATA_NAME "_" UCA_DATA_NAME "." UCA_DATA_TYPE " because of UCONFIG_NO_COLLATION, see uconfig.h";
|
||||
msg = "genuca writes dummy " UCA_DATA_NAME "." UCA_DATA_TYPE " because of UCONFIG_NO_COLLATION, see uconfig.h";
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
pData = udata_create(destdir, UCA_DATA_TYPE, U_ICUDATA_NAME "_" UCA_DATA_NAME, &dummyDataInfo,
|
||||
pData = udata_create(destdir, UCA_DATA_TYPE, UCA_DATA_NAME, &dummyDataInfo,
|
||||
NULL, &status);
|
||||
udata_writeBlock(pData, msg, strlen(msg));
|
||||
udata_finish(pData, &status);
|
||||
|
||||
msg = "genuca writes dummy " U_ICUDATA_NAME "_" INVC_DATA_NAME "." INVC_DATA_TYPE " because of UCONFIG_NO_COLLATION, see uconfig.h";
|
||||
msg = "genuca writes dummy " INVC_DATA_NAME "." INVC_DATA_TYPE " because of UCONFIG_NO_COLLATION, see uconfig.h";
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
pData = udata_create(destdir, INVC_DATA_TYPE, U_ICUDATA_NAME "_" INVC_DATA_NAME, &dummyDataInfo,
|
||||
pData = udata_create(destdir, INVC_DATA_TYPE, INVC_DATA_NAME, &dummyDataInfo,
|
||||
NULL, &status);
|
||||
udata_writeBlock(pData, msg, strlen(msg));
|
||||
udata_finish(pData, &status);
|
||||
|
|
|
@ -241,9 +241,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
if(!options[6].doesOccur)
|
||||
{
|
||||
fprintf(stderr, "%s : option -p (package name) is required.\n",
|
||||
argv[0]);
|
||||
exit(1);
|
||||
pkgName=NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -75,8 +75,13 @@ void pkg_mode_common(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
|
|||
sprintf(tmp, "all: $(TARGET)\n\n");
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
|
||||
if(!o->embed) {
|
||||
T_FileStream_writeLine(makefile, "$(TARGET): $(CMNLIST) $(DATAFILEPATHS)\n"
|
||||
"\t$(INVOKE) $(GENCMN) -n $(CNAME) -c -d $(TARGETDIR) 0 $(CMNLIST)\n\n");
|
||||
"\t$(INVOKE) $(GENCMN) -n $(CNAME) -c -s $(SRCDIR) -d $(TARGETDIR) 0 $(CMNLIST)\n\n");
|
||||
} else {
|
||||
T_FileStream_writeLine(makefile, "$(TARGET): $(CMNLIST) $(DATAFILEPATHS)\n"
|
||||
"\t$(INVOKE) $(GENCMN) -n $(CNAME) -c -d $(TARGETDIR) 0 -E $(CMNLIST)\n\n");
|
||||
}
|
||||
|
||||
if(o->hadStdin == FALSE) { /* shortcut */
|
||||
T_FileStream_writeLine(makefile, "$(CMNLIST): $(LISTFILES)\n"
|
||||
|
|
|
@ -41,7 +41,7 @@ void pkg_mode_dll(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
|
|||
return;
|
||||
}
|
||||
|
||||
uprv_strcpy(tmp, LIB_PREFIX "$(NAME)" UDATA_SO_SUFFIX);
|
||||
uprv_strcpy(tmp, LIB_PREFIX "$(LIBNAME)" 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));
|
||||
|
@ -60,11 +60,11 @@ void pkg_mode_dll(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
|
|||
|
||||
/*390port start*/
|
||||
#ifdef OS390BATCH
|
||||
if (uprv_strcmp(o->shortName, U_LIBICUDATA_NAME) == 0)
|
||||
if (uprv_strcmp(o->libName, U_LIBICUDATA_NAME) == 0)
|
||||
sprintf(tmp, "# File to make:\nBATCH_TARGET=\"//'${LOADMOD}(IXMI" U_ICU_VERSION_SHORT "DA)'\"\n\n");
|
||||
else if (uprv_strcmp(o->shortName, "testdata") == 0)
|
||||
else if (uprv_strcmp(o->libName, "testdata") == 0)
|
||||
sprintf(tmp, "# File to make:\nBATCH_TARGET=\"//'${LOADMOD}(IXMI" U_ICU_VERSION_SHORT "TE)'\"\n\n");
|
||||
else if (uprv_strcmp(o->shortName, U_LIBICUDATA_NAME"_stub") == 0)
|
||||
else if (uprv_strcmp(o->libName, U_LIBICUDATA_NAME"_stub") == 0)
|
||||
sprintf(tmp, "# File to make:\nBATCH_TARGET=\"//'${LOADMOD}(IXMI" U_ICU_VERSION_SHORT "D1)'\"\n\n");
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
#endif
|
||||
|
@ -145,9 +145,14 @@ void pkg_mode_dll(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
|
|||
|
||||
T_FileStream_writeLine(makefile, "# 'TOCOBJ' contains C Table of Contents objects [if any]\n");
|
||||
|
||||
sprintf(tmp, "$(TEMP_DIR)/$(NAME)_dat.c: $(CMNLIST)\n"
|
||||
"\t$(INVOKE) $(GENCMN) -e $(ENTRYPOINT) -n $(NAME) -S -d $(TEMP_DIR) 0 $(CMNLIST)\n\n");
|
||||
|
||||
if(!o->embed) {
|
||||
sprintf(tmp, "$(TEMP_DIR)/$(NAME)_dat.c: $(CMNLIST)\n"
|
||||
"\t$(INVOKE) $(GENCMN) -e $(ENTRYPOINT) -n $(NAME) -S -s $(SRCDIR) -d $(TEMP_DIR) 0 $(CMNLIST)\n\n");
|
||||
} else {
|
||||
sprintf(tmp, "$(TEMP_DIR)/$(NAME)_dat.c: $(CMNLIST)\n"
|
||||
"\t$(INVOKE) $(GENCMN) -e $(ENTRYPOINT) -n $(NAME) -S -E -d $(TEMP_DIR) 0 $(CMNLIST)\n\n");
|
||||
}
|
||||
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
sprintf(tmp, "TOCOBJ= $(NAME)_dat%s \n\n", OBJ_SUFFIX);
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
|
|
|
@ -33,15 +33,17 @@ char linebuf[2048];
|
|||
void
|
||||
pkg_mak_writeHeader(FileStream *f, const UPKGOptions *o)
|
||||
{
|
||||
sprintf(linebuf, "## Makefile for %s created by pkgdata\n"
|
||||
sprintf(linebuf, "## Makefile for %s (%s) created by pkgdata\n"
|
||||
"## from ICU Version %s\n"
|
||||
"\n",
|
||||
o->shortName,
|
||||
o->libName,
|
||||
U_ICU_VERSION);
|
||||
T_FileStream_writeLine(f, linebuf);
|
||||
|
||||
sprintf(linebuf, "NAME=%s%s\n"
|
||||
"CNAME=%s\n"
|
||||
"SRCDIR=%s\n"
|
||||
"TARGETDIR=%s\n"
|
||||
"TEMP_DIR=%s\n"
|
||||
"MODE=%s\n"
|
||||
|
@ -52,6 +54,7 @@ pkg_mak_writeHeader(FileStream *f, const UPKGOptions *o)
|
|||
o->shortName,
|
||||
(o->version ? o->version : ""),
|
||||
o->cShortName,
|
||||
o->srcDir,
|
||||
o->targetDir,
|
||||
o->tmpDir,
|
||||
o->mode,
|
||||
|
@ -144,19 +147,23 @@ pkg_mak_writeHeader(FileStream *f, const UPKGOptions *o)
|
|||
T_FileStream_writeLine(f, linebuf);
|
||||
|
||||
sprintf(linebuf, "NAME=%s\n"
|
||||
"LIBNAME=%s\n"
|
||||
"CNAME=%s\n"
|
||||
"TARGETDIR=%s\n"
|
||||
"TEMP_DIR=%s\n"
|
||||
"srcdir=$(TEMP_DIR)\n"
|
||||
"SRCDIR=%s\n"
|
||||
"MODE=%s\n"
|
||||
"MAKEFILE=%s\n"
|
||||
"ENTRYPOINT=%s\n"
|
||||
"include %s\n"
|
||||
"\n\n\n",
|
||||
o->shortName,
|
||||
o->libName,
|
||||
o->cShortName,
|
||||
o->targetDir,
|
||||
o->tmpDir,
|
||||
o->srcDir,
|
||||
o->mode,
|
||||
o->makeFile,
|
||||
o->entryName,
|
||||
|
@ -256,8 +263,15 @@ pkg_mak_writeObjRules(UPKGOptions *o, FileStream *makefile, CharList **objects,
|
|||
int32_t genFileOffset = 0; /* offset from beginning of .c and .o file name, use to chop off package name for AS/400 */
|
||||
static int serNo = 0; /* counter for numeric file names */
|
||||
char serName[100];
|
||||
|
||||
infiles = o->filePaths;
|
||||
int32_t pkgNameOffset;
|
||||
|
||||
pkgNameOffset = uprv_strlen(o->shortName) + 1; /* "icudt28l/" */
|
||||
|
||||
if(o->embed) {
|
||||
infiles = o->filePaths;
|
||||
} else {
|
||||
infiles = o->files; /* raw files - no paths other than tree paths */
|
||||
}
|
||||
|
||||
#if defined (OS400)
|
||||
if(infiles != NULL) {
|
||||
|
@ -270,71 +284,102 @@ pkg_mak_writeObjRules(UPKGOptions *o, FileStream *makefile, CharList **objects,
|
|||
#endif
|
||||
|
||||
for(;infiles;infiles = infiles->next) {
|
||||
baseName = findBasename(infiles->str);
|
||||
p = uprv_strrchr(baseName, '.');
|
||||
if( (p == NULL) || (*p == '\0' ) ) {
|
||||
continue;
|
||||
if(o->embed) {
|
||||
baseName = findBasename(infiles->str);
|
||||
} else {
|
||||
baseName = infiles->str + pkgNameOffset; /* skip the icudt28b/ part */
|
||||
}
|
||||
p = uprv_strrchr(baseName, '.');
|
||||
if( (p == NULL) || (*p == '\0' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(o->numeric) {
|
||||
sprintf(serName, "t%04x", serNo++);
|
||||
uprv_strcpy(tmp,serName);
|
||||
uprv_strcat(tmp, objSuffix);
|
||||
} else {
|
||||
uprv_strncpy(tmp, baseName, p-baseName);
|
||||
p++;
|
||||
|
||||
uprv_strcpy(tmp+(p-1-baseName), "_"); /* to append */
|
||||
uprv_strcat(tmp, p);
|
||||
uprv_strcat(tmp, objSuffix );
|
||||
|
||||
/* iSeries cannot have '-' in the .o objects. */
|
||||
for( tmpPtr = tmp; *tmpPtr; tmpPtr++ ) {
|
||||
if ( *tmpPtr == U_FILE_SEP_CHAR ) { /* map tree names with underscores */
|
||||
*tmpPtr = '_';
|
||||
}
|
||||
if ( *tmpPtr == '-' ) {
|
||||
*tmpPtr = '_';
|
||||
}
|
||||
}
|
||||
|
||||
if(o->numeric) {
|
||||
sprintf(serName, "t%04x", serNo++);
|
||||
uprv_strcpy(tmp,serName);
|
||||
uprv_strcat(tmp, objSuffix);
|
||||
} else {
|
||||
uprv_strncpy(tmp, baseName, p-baseName);
|
||||
p++;
|
||||
|
||||
uprv_strcpy(tmp+(p-1-baseName), "_"); /* to append */
|
||||
uprv_strcat(tmp, p);
|
||||
uprv_strcat(tmp, objSuffix );
|
||||
|
||||
/* iSeries cannot have '-' in the .o objects. */
|
||||
for( tmpPtr = tmp; *tmpPtr; tmpPtr++ ) {
|
||||
if ( *tmpPtr == '-' ) {
|
||||
*tmpPtr = '_';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*objects = pkg_appendToList(*objects, &oTail, uprv_strdup(tmp + genFileOffset)); /* Offset for AS/400 */
|
||||
|
||||
/* write source list */
|
||||
strcpy(cfile,tmp);
|
||||
strcpy(cfile+strlen(cfile)-strlen(objSuffix), ".c" ); /* replace .o with .c */
|
||||
|
||||
/* Make up parents.. */
|
||||
}
|
||||
|
||||
*objects = pkg_appendToList(*objects, &oTail, uprv_strdup(tmp + genFileOffset)); /* Offset for AS/400 */
|
||||
|
||||
/* write source list */
|
||||
strcpy(cfile,tmp);
|
||||
strcpy(cfile+strlen(cfile)-strlen(objSuffix), ".c" ); /* replace .o with .c */
|
||||
|
||||
/* Make up parents.. */
|
||||
if(!o->embed) {
|
||||
char *parentPath;
|
||||
parentPath = uprv_malloc(strlen(baseName) + uprv_strlen("$(SRCDIR)/"));
|
||||
sprintf(parentPath, "$(SRCDIR)/%s", baseName);
|
||||
parents = pkg_appendToList(parents, NULL, parentPath);
|
||||
} else {
|
||||
parents = pkg_appendToList(parents, NULL, uprv_strdup(infiles->str));
|
||||
|
||||
/* make up commands.. */
|
||||
sprintf(stanza, "@$(INVOKE) $(GENCCODE) -n $(ENTRYPOINT) -d $(TEMP_DIR) $<");
|
||||
|
||||
if(o->numeric) {
|
||||
strcat(stanza, " -f ");
|
||||
strcat(stanza,serName);
|
||||
}
|
||||
|
||||
/* make up commands.. */
|
||||
if(!o->embed) {
|
||||
/* search for tree.. */
|
||||
const char *tchar;
|
||||
char tree[1024];
|
||||
if(tchar=uprv_strchr(baseName, '/')) {
|
||||
tree[0]='_';
|
||||
strncpy(tree+1,baseName,tchar-baseName);
|
||||
tree[tchar-baseName+1]=0;
|
||||
} else {
|
||||
tree[0] = 0;
|
||||
}
|
||||
|
||||
sprintf(stanza, "$(INVOKE) $(GENCCODE) -n $(CNAME)%s -d $(TEMP_DIR) $<", tree);
|
||||
} else {
|
||||
sprintf(stanza, "$(INVOKE) $(GENCCODE) -d $(TEMP_DIR) $<");
|
||||
}
|
||||
|
||||
if(o->numeric) {
|
||||
strcat(stanza, " -f ");
|
||||
strcat(stanza,serName);
|
||||
} else if(!o->embed && uprv_strchr(baseName, '/')) {
|
||||
/* append actual file - ex: coll_en_res otherwise the tree name will be lost */
|
||||
strcat(stanza, " -f ");
|
||||
strncat(stanza, tmp, (strlen(tmp)-strlen(objSuffix)));
|
||||
}
|
||||
|
||||
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
|
||||
|
||||
if(genFileOffset > 0) { /* for AS/400 */
|
||||
sprintf(stanza, "@mv $(TEMP_PATH)%s $(TEMP_PATH)%s", cfile, cfile+genFileOffset);
|
||||
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
|
||||
|
||||
if(genFileOffset > 0) { /* for AS/400 */
|
||||
sprintf(stanza, "@mv $(TEMP_PATH)%s $(TEMP_PATH)%s", cfile, cfile+genFileOffset);
|
||||
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
|
||||
}
|
||||
|
||||
sprintf(stanza, "@$(COMPILE.c) -o $@ $(TEMP_DIR)/%s", cfile+genFileOffset); /* for AS/400 */
|
||||
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
|
||||
|
||||
sprintf(stanza, "@$(RMV) $(TEMP_DIR)/%s", cfile+genFileOffset);
|
||||
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
|
||||
|
||||
sprintf(stanza, "$(TEMP_PATH)%s", tmp+genFileOffset); /* for AS/400 */
|
||||
pkg_mak_writeStanza(makefile, o, stanza, parents, commands);
|
||||
|
||||
pkg_deleteList(parents);
|
||||
pkg_deleteList(commands);
|
||||
parents = NULL;
|
||||
commands = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sprintf(stanza, "@$(COMPILE.c) -o $@ $(TEMP_DIR)/%s", cfile+genFileOffset); /* for AS/400 */
|
||||
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
|
||||
|
||||
sprintf(stanza, "@$(RMV) $(TEMP_DIR)/%s", cfile+genFileOffset);
|
||||
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
|
||||
|
||||
sprintf(stanza, "$(TEMP_PATH)%s", tmp+genFileOffset); /* for AS/400 */
|
||||
pkg_mak_writeStanza(makefile, o, stanza, parents, commands);
|
||||
|
||||
pkg_deleteList(parents);
|
||||
pkg_deleteList(commands);
|
||||
parents = NULL;
|
||||
commands = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* #ifdef WIN32 */
|
||||
|
@ -348,7 +393,11 @@ pkg_mak_writeAssemblyHeader(FileStream *f, const UPKGOptions *o)
|
|||
T_FileStream_writeLine(f, "BASE_OBJECTS=$(NAME)_dat.o\n");
|
||||
T_FileStream_writeLine(f, "\n");
|
||||
T_FileStream_writeLine(f, "$(TEMP_DIR)/$(NAME).dat: $(CMNLIST) $(DATAFILEPATHS)\n");
|
||||
T_FileStream_writeLine(f, "\t$(INVOKE) $(GENCMN) -c -e $(ENTRYPOINT) -n $(NAME) -t dat -d $(TEMP_DIR) 0 $(CMNLIST)\n");
|
||||
if(!o->embed) {
|
||||
T_FileStream_writeLine(f, "\t$(INVOKE) $(GENCMN) -c -e $(ENTRYPOINT) -n $(NAME) -s $(SRCDIR) -t dat -d $(TEMP_DIR) 0 $(CMNLIST)\n");
|
||||
} else {
|
||||
T_FileStream_writeLine(f, "\t$(INVOKE) $(GENCMN) -c -e $(ENTRYPOINT) -n $(NAME) -E -t dat -d $(TEMP_DIR) 0 $(CMNLIST)\n");
|
||||
}
|
||||
T_FileStream_writeLine(f, "\n");
|
||||
T_FileStream_writeLine(f, "$(TEMP_DIR)/$(NAME)_dat.o : $(TEMP_DIR)/$(NAME).dat\n");
|
||||
T_FileStream_writeLine(f, "\t$(INVOKE) $(GENCCODE) $(GENCCODE_ASSEMBLY) -n $(NAME) -e $(ENTRYPOINT) -d $(TEMP_DIR) $<\n");
|
||||
|
|
|
@ -92,10 +92,13 @@ static UOption options[]={
|
|||
/*16*/ UOPTION_DEF( "revision", 'r', UOPT_REQUIRES_ARG),
|
||||
/*17*/ UOPTION_DEF( 0, 'M', UOPT_REQUIRES_ARG),
|
||||
/*18*/ UOPTION_DEF( "force-prefix", 'f', UOPT_NO_ARG),
|
||||
/*19*/ UOPTION_DEF( "numerictmp", 'N', UOPT_NO_ARG)
|
||||
/*19*/ UOPTION_DEF( "numerictmp", 'N', UOPT_NO_ARG),
|
||||
/*20*/ UOPTION_DEF( "embed", 'E', UOPT_NO_ARG),
|
||||
/*21*/ UOPTION_DEF( "libname", 'L', UOPT_REQUIRES_ARG),
|
||||
/*22*/ UOPTION_DEF( "compat", 'Z', UOPT_NO_ARG)
|
||||
};
|
||||
|
||||
const char options_help[][160]={
|
||||
const char options_help[][320]={
|
||||
"Set the data name",
|
||||
#ifdef WIN32
|
||||
"The directory where the ICU is located (e.g. <ICUROOT> which contains the bin directory)",
|
||||
|
@ -119,7 +122,10 @@ const char options_help[][160]={
|
|||
"Specify a version when packaging in DLL or static mode",
|
||||
"Pass the next argument to make(1)",
|
||||
"Add package to all file names if not present",
|
||||
"Use short numeric temporary file names such as t1234.c"
|
||||
"Use short numeric temporary file names such as t1234.c",
|
||||
"Use Embedded paths (such as 'mypackage_') - for compatibility.",
|
||||
"Library name to build (if different than package name)",
|
||||
"Collation compatibility mode. All paths reduced to basenames, 'x.crs' maps to coll/x.res. This internal-use-only option will be removed in future ICU versions- do not use. "
|
||||
};
|
||||
|
||||
const char *progname = "PKGDATA";
|
||||
|
@ -268,6 +274,18 @@ main(int argc, char* argv[]) {
|
|||
o.cShortName = csname;
|
||||
}
|
||||
|
||||
if(options[21].doesOccur) { /* get libname from shortname, or explicit -L parameter */
|
||||
o.libName = options[21].value;
|
||||
} else {
|
||||
o.libName = o.shortName;
|
||||
}
|
||||
|
||||
if(options[22].doesOccur) {
|
||||
o.compatMode = TRUE;
|
||||
} else {
|
||||
o.compatMode = FALSE;
|
||||
}
|
||||
|
||||
o.verbose = options[5].doesOccur;
|
||||
#ifdef WIN32 /* format is R:pathtoICU or D:pathtoICU */
|
||||
{
|
||||
|
@ -313,12 +331,12 @@ main(int argc, char* argv[]) {
|
|||
o.clean = options[9].doesOccur;
|
||||
o.nooutput = options[10].doesOccur;
|
||||
o.rebuild = options[11].doesOccur;
|
||||
|
||||
o.numeric = options[19].doesOccur;
|
||||
if(o.numeric) {
|
||||
o.rebuild = TRUE; /* force rebuild if numeric */
|
||||
}
|
||||
|
||||
o.embed = options[20].doesOccur;
|
||||
|
||||
if( options[12].doesOccur ) {
|
||||
o.tmpDir = options[12].value;
|
||||
|
@ -466,12 +484,12 @@ static void loadLists(UPKGOptions *o, UErrorCode *status)
|
|||
char line[16384];
|
||||
char *linePtr, *lineNext;
|
||||
const uint32_t lineMax = 16300;
|
||||
char tmp[1024], tmp2[1024];
|
||||
char tmp[1024];
|
||||
char pkgPrefix[1024];
|
||||
int32_t pkgPrefixLen;
|
||||
const char *baseName;
|
||||
char *s;
|
||||
int32_t ln;
|
||||
int32_t ln=0; /* line number */
|
||||
UBool fixPrefix;
|
||||
|
||||
|
||||
|
@ -485,123 +503,141 @@ static void loadLists(UPKGOptions *o, UErrorCode *status)
|
|||
fprintf(stdout, "# Reading %s..\n", l->str);
|
||||
}
|
||||
/* TODO: stdin */
|
||||
in = T_FileStream_open(l->str, "r");
|
||||
in = T_FileStream_open(l->str, "r"); /* open files list */
|
||||
|
||||
if(!in) {
|
||||
fprintf(stderr, "Error opening <%s>.\n", l->str);
|
||||
*status = U_FILE_ACCESS_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
ln = 0;
|
||||
|
||||
while(T_FileStream_readLine(in, line, sizeof(line))!=NULL) {
|
||||
ln++;
|
||||
if(uprv_strlen(line)>lineMax) {
|
||||
fprintf(stderr, "%s:%d - line too long (over %d chars)\n", l->str, ln, lineMax);
|
||||
exit(1);
|
||||
|
||||
while(T_FileStream_readLine(in, line, sizeof(line))!=NULL) { /* for each line */
|
||||
if((ln == 0) && (!o->embed)) {
|
||||
/* determine if we need to run in 'embed' (compatibility) mode */
|
||||
if(!strncmp(findBasename(line), pkgPrefix, pkgPrefixLen)) {
|
||||
fprintf(stderr, "Warning: Found path '%s' in file name. Assuming compatibility (-E) mode.\n", pkgPrefix);
|
||||
o->embed = 1;
|
||||
}
|
||||
/* remove spaces at the beginning */
|
||||
linePtr = line;
|
||||
while(isspace(*linePtr)) {
|
||||
linePtr++;
|
||||
}
|
||||
ln++;
|
||||
if(uprv_strlen(line)>lineMax) {
|
||||
fprintf(stderr, "%s:%d - line too long (over %d chars)\n", l->str, ln, lineMax);
|
||||
exit(1);
|
||||
}
|
||||
/* remove spaces at the beginning */
|
||||
linePtr = line;
|
||||
while(isspace(*linePtr)) {
|
||||
linePtr++;
|
||||
}
|
||||
s=linePtr;
|
||||
/* remove trailing newline characters */
|
||||
while(*s!=0) {
|
||||
if(*s=='\r' || *s=='\n') {
|
||||
*s=0;
|
||||
break;
|
||||
}
|
||||
s=linePtr;
|
||||
/* remove trailing newline characters */
|
||||
while(*s!=0) {
|
||||
if(*s=='\r' || *s=='\n') {
|
||||
*s=0;
|
||||
break;
|
||||
}
|
||||
++s;
|
||||
}
|
||||
if((*linePtr == 0) || (*linePtr == '#')) {
|
||||
continue; /* comment or empty line */
|
||||
}
|
||||
|
||||
/* Now, process the line */
|
||||
lineNext = NULL;
|
||||
|
||||
while(linePtr && *linePtr) { /* process space-separated items */
|
||||
while(*linePtr == ' ') {
|
||||
linePtr++;
|
||||
}
|
||||
if((*linePtr == 0) || (*linePtr == '#')) {
|
||||
continue; /* comment or empty line */
|
||||
}
|
||||
|
||||
/* Now, process the line */
|
||||
lineNext = NULL;
|
||||
|
||||
while(linePtr && *linePtr) {
|
||||
while(*linePtr == ' ') {
|
||||
linePtr++;
|
||||
}
|
||||
/* Find the next */
|
||||
if(linePtr[0] == '"')
|
||||
{
|
||||
lineNext = uprv_strchr(linePtr+1, '"');
|
||||
if(lineNext == NULL) {
|
||||
fprintf(stderr, "%s:%d - missing trailing double quote (\")\n",
|
||||
l->str, ln);
|
||||
exit(1);
|
||||
} else {
|
||||
lineNext++;
|
||||
if(*lineNext) {
|
||||
if(*lineNext != ' ') {
|
||||
fprintf(stderr, "%s:%d - malformed quoted line at position %d, expected ' ' got '%c'\n",
|
||||
l->str, ln, lineNext-line, (*lineNext)?*lineNext:'0');
|
||||
exit(1);
|
||||
}
|
||||
*lineNext = 0;
|
||||
lineNext++;
|
||||
}
|
||||
}
|
||||
/* Find the next quote */
|
||||
if(linePtr[0] == '"')
|
||||
{
|
||||
lineNext = uprv_strchr(linePtr+1, '"');
|
||||
if(lineNext == NULL) {
|
||||
fprintf(stderr, "%s:%d - missing trailing double quote (\")\n",
|
||||
l->str, ln);
|
||||
exit(1);
|
||||
} else {
|
||||
lineNext = uprv_strchr(linePtr, ' ');
|
||||
if(lineNext) {
|
||||
*lineNext = 0; /* terminate at space */
|
||||
lineNext++;
|
||||
lineNext++;
|
||||
if(*lineNext) {
|
||||
if(*lineNext != ' ') {
|
||||
fprintf(stderr, "%s:%d - malformed quoted line at position %d, expected ' ' got '%c'\n",
|
||||
l->str, ln, lineNext-line, (*lineNext)?*lineNext:'0');
|
||||
exit(1);
|
||||
}
|
||||
*lineNext = 0;
|
||||
lineNext++;
|
||||
}
|
||||
}
|
||||
|
||||
/* add the file */
|
||||
s = (char*)getLongPathname(linePtr);
|
||||
|
||||
baseName = findBasename(s);
|
||||
|
||||
if(s != baseName) {
|
||||
/* s was something 'long' with a path */
|
||||
if(fixPrefix && uprv_strncmp(pkgPrefix, baseName, pkgPrefixLen)) {
|
||||
/* path don't have the prefix, add package prefix to short and longname */
|
||||
uprv_strcpy(tmp, pkgPrefix);
|
||||
uprv_strcpy(tmp+pkgPrefixLen, baseName);
|
||||
|
||||
uprv_strncpy(tmp2, s, uprv_strlen(s)-uprv_strlen(baseName)); /* should be: dirpath only, ending in sep */
|
||||
tmp2[uprv_strlen(s)-uprv_strlen(baseName)]=0;
|
||||
uprv_strcat(tmp2, pkgPrefix);
|
||||
uprv_strcat(tmp2, baseName);
|
||||
|
||||
o->files = pkg_appendToList(o->files, &tail, uprv_strdup(tmp));
|
||||
o->filePaths = pkg_appendToList(o->filePaths, &tail2, uprv_strdup(tmp2));
|
||||
} else {
|
||||
/* paths already have the prefix */
|
||||
o->files = pkg_appendToList(o->files, &tail, uprv_strdup(baseName));
|
||||
o->filePaths = pkg_appendToList(o->filePaths, &tail2, uprv_strdup(s));
|
||||
}
|
||||
|
||||
} else { /* s was just a basename, we want to prepend source dir*/
|
||||
/* check for prefix of package */
|
||||
uprv_strcpy(tmp, o->srcDir);
|
||||
uprv_strcat(tmp, o->srcDir[uprv_strlen(o->srcDir)-1]==U_FILE_SEP_CHAR?"":U_FILE_SEP_STRING);
|
||||
|
||||
if(fixPrefix && strncmp(pkgPrefix,s, pkgPrefixLen)) {
|
||||
/* didn't have the prefix - add it */
|
||||
uprv_strcat(tmp, pkgPrefix);
|
||||
/* make up a new basename */
|
||||
uprv_strcpy(tmp2, pkgPrefix);
|
||||
uprv_strcat(tmp2, s);
|
||||
o->files = pkg_appendToList(o->files, &tail, uprv_strdup(tmp2));
|
||||
} else {
|
||||
o->files = pkg_appendToList(o->files, &tail, uprv_strdup(baseName));
|
||||
}
|
||||
uprv_strcat(tmp, s);
|
||||
o->filePaths = pkg_appendToList(o->filePaths, &tail2, uprv_strdup(tmp));
|
||||
}
|
||||
linePtr = lineNext;
|
||||
} else {
|
||||
lineNext = uprv_strchr(linePtr, ' ');
|
||||
if(lineNext) {
|
||||
*lineNext = 0; /* terminate at space */
|
||||
lineNext++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* add the file */
|
||||
s = (char*)getLongPathname(linePtr);
|
||||
|
||||
if(o->compatMode) {
|
||||
const char *theBase = findBasename(s);
|
||||
if(uprv_strstr(theBase, ".crs")) {
|
||||
uprv_strcpy(tmp, "coll");
|
||||
uprv_strcat(tmp, U_TREE_SEPARATOR_STRING);
|
||||
uprv_strcat(tmp, theBase);
|
||||
uprv_strcpy(tmp+uprv_strlen(tmp)-uprv_strlen(".crs"),".res");
|
||||
o->files = pkg_appendToList(o->files, &tail, uprv_strdup(tmp));
|
||||
|
||||
uprv_strcpy(tmp, o->srcDir);
|
||||
uprv_strcat(tmp, U_FILE_SEP_STRING);
|
||||
uprv_strcat(tmp, "coll");
|
||||
uprv_strcat(tmp, U_FILE_SEP_STRING);
|
||||
uprv_strcat(tmp, theBase);
|
||||
uprv_strcpy(tmp+uprv_strlen(tmp)-uprv_strlen(".crs"),".res");
|
||||
o->filePaths = pkg_appendToList(o->filePaths, &tail2, uprv_strdup(tmp));
|
||||
} else {
|
||||
uprv_strcpy(tmp, theBase);
|
||||
o->files = pkg_appendToList(o->files, &tail, uprv_strdup(tmp));
|
||||
|
||||
uprv_strcpy(tmp, o->srcDir);
|
||||
uprv_strcat(tmp, U_FILE_SEP_STRING);
|
||||
uprv_strcat(tmp, theBase);
|
||||
o->filePaths = pkg_appendToList(o->filePaths, &tail2, uprv_strdup(tmp));
|
||||
}
|
||||
} else if(o->embed == 0) {
|
||||
/* Normal mode Assume ALL paths are relative to srcdir */
|
||||
uprv_strcpy(tmp, o->shortName);
|
||||
uprv_strcat(tmp, U_TREE_SEPARATOR_STRING);
|
||||
uprv_strcat(tmp, linePtr);
|
||||
o->files = pkg_appendToList(o->files, &tail, uprv_strdup(tmp));
|
||||
|
||||
uprv_strcpy(tmp, o->srcDir);
|
||||
uprv_strcat(tmp, o->srcDir[uprv_strlen(o->srcDir)-1]==U_FILE_SEP_CHAR?"":U_FILE_SEP_STRING);
|
||||
uprv_strcat(tmp, s);
|
||||
o->filePaths = pkg_appendToList(o->filePaths, &tail2, uprv_strdup(tmp));
|
||||
} else {/* compatibliity mode */
|
||||
baseName = findBasename(s);
|
||||
|
||||
if(s != baseName) {
|
||||
/* s was something 'long' with a path */
|
||||
/* paths already have the prefix */
|
||||
o->files = pkg_appendToList(o->files, &tail, uprv_strdup(baseName));
|
||||
o->filePaths = pkg_appendToList(o->filePaths, &tail2, uprv_strdup(s));
|
||||
} else { /* s was just a basename, we want to prepend source dir*/
|
||||
/* check for prefix of package */
|
||||
uprv_strcpy(tmp, o->srcDir);
|
||||
uprv_strcat(tmp, o->srcDir[uprv_strlen(o->srcDir)-1]==U_FILE_SEP_CHAR?"":U_FILE_SEP_STRING);
|
||||
o->files = pkg_appendToList(o->files, &tail, uprv_strdup(baseName));
|
||||
uprv_strcat(tmp, s);
|
||||
o->filePaths = pkg_appendToList(o->filePaths, &tail2, uprv_strdup(tmp));
|
||||
}
|
||||
} /* end compatibility mode */
|
||||
linePtr = lineNext;
|
||||
} /* for each entry on line */
|
||||
} /* for each line */
|
||||
T_FileStream_close(in);
|
||||
}
|
||||
} /* for each file list file */
|
||||
}
|
||||
|
||||
/* Try calling icu-config directly to get information */
|
||||
|
|
|
@ -198,6 +198,38 @@ CharList *pkg_appendToList(CharList *l, CharList** end, const char *str)
|
|||
return l;
|
||||
}
|
||||
|
||||
CharList *pkg_appendFromStrings(CharList *l, CharList** end, const char *s, int32_t len)
|
||||
{
|
||||
CharList *endptr = NULL;
|
||||
const char *p;
|
||||
char *t;
|
||||
const char *targ;
|
||||
if(end == NULL) {
|
||||
end = &endptr;
|
||||
}
|
||||
|
||||
if(len==-1) {
|
||||
len = uprv_strlen(s);
|
||||
}
|
||||
targ = s+len;
|
||||
|
||||
while(*s && s<targ) {
|
||||
while(s<targ&&isspace(*s)) s++;
|
||||
for(p=s;s<targ&&!isspace(*p);p++);
|
||||
if(p!=s) {
|
||||
t = uprv_malloc(p-s+1);
|
||||
uprv_strncpy(t,s,p-s);
|
||||
t[p-s]=0;
|
||||
l=pkg_appendToList(l,end,t);
|
||||
fprintf(stderr, " P %s\n", t);
|
||||
}
|
||||
s=p;
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Delete list
|
||||
*/
|
||||
|
|
|
@ -71,9 +71,6 @@ UBool pkg_listContains(CharList *l, const char *str);
|
|||
*/
|
||||
void pkg_deleteList(CharList *l);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Mode package function
|
||||
*/
|
||||
|
@ -102,8 +99,9 @@ typedef struct UPKGOptions_
|
|||
const char *shortName; /* name of what we're building */
|
||||
const char *cShortName; /* name of what we're building as a C identifier */
|
||||
const char *entryName; /* special entrypoint name */
|
||||
const char *targetDir;
|
||||
const char *tmpDir;
|
||||
const char *targetDir; /* dir for packaged data to go */
|
||||
const char *dataDir; /* parent of dir for package (default: tmpdir) */
|
||||
const char *tmpDir;
|
||||
const char *srcDir;
|
||||
const char *options; /* Options arg */
|
||||
const char *mode; /* Mode of building */
|
||||
|
@ -113,13 +111,16 @@ typedef struct UPKGOptions_
|
|||
const char *makeFile; /* Makefile path */
|
||||
const char *install; /* Where to install to (NULL = don't install) */
|
||||
const char *icuroot; /* where does ICU lives */
|
||||
|
||||
const char *libName; /* name for library (default: shortName) */
|
||||
UBool compatMode;
|
||||
UBool rebuild;
|
||||
UBool clean;
|
||||
UBool nooutput;
|
||||
UBool verbose;
|
||||
UBool hadStdin; /* Stdin was a dependency - don't make anything depend on the file list coming in. */
|
||||
UBool numeric; /* use numeric, short, temporary file names */
|
||||
|
||||
int32_t embed; /* embedded package - i.e. .../mypkg_myfile.res files */
|
||||
|
||||
UPKGMODE *fcn; /* Handler function */
|
||||
} UPKGOptions;
|
||||
|
|
|
@ -194,8 +194,13 @@ void pkg_mode_static(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
|
|||
|
||||
T_FileStream_writeLine(makefile, "# 'TOCOBJ' contains C Table of Contents objects [if any]\n");
|
||||
|
||||
if(!o->embed) {
|
||||
sprintf(tmp, "$(TEMP_PATH)$(NAME)_dat.c: $(CMNLIST)\n"
|
||||
"\t$(INVOKE) $(GENCMN) -e $(ENTRYPOINT) -n $(NAME) -S -d $(TEMP_DIR) 0 $(CMNLIST)\n\n");
|
||||
"\t$(INVOKE) $(GENCMN) -e $(ENTRYPOINT) -n $(NAME) -S -s $(SRCDIR) -d $(TEMP_DIR) 0 $(CMNLIST)\n\n");
|
||||
} else {
|
||||
sprintf(tmp, "$(TEMP_PATH)$(NAME)_dat.c: $(CMNLIST)\n"
|
||||
"\t$(INVOKE) $(GENCMN) -e $(ENTRYPOINT) -n $(NAME) -S -E -d $(TEMP_DIR) 0 $(CMNLIST)\n\n");
|
||||
}
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
|
||||
sprintf(tmp, "TOCOBJ= $(NAME)_dat%s \n\n", OBJ_SUFFIX);
|
||||
|
|
|
@ -40,13 +40,17 @@ void writeCmnRules(UPKGOptions *o, FileStream *makefile)
|
|||
char tmp[1024];
|
||||
CharList *infiles;
|
||||
|
||||
infiles = o->filePaths;
|
||||
|
||||
if(o->compatMode) {
|
||||
infiles = o->files;
|
||||
} else {
|
||||
infiles = o->filePaths;
|
||||
}
|
||||
sprintf(tmp, "\"$(TARGETDIR)\\$(CMNTARGET)\" : $(DATAFILEPATHS)\n"
|
||||
"\t@\"$(GENCMN)\" %s%s%s-d \"$(TARGETDIR)\" -n \"$(NAME)\" 0 <<\n",
|
||||
"\t@\"$(GENCMN)\" %s%s%s-d \"$(TARGETDIR)\" %s -n \"$(NAME)\" 0 <<\n",
|
||||
(o->comment ? "-C \"" : ""),
|
||||
(o->comment ? o->comment : ""),
|
||||
(o->comment ? "\" " : ""));
|
||||
(o->comment ? "\" " : ""),
|
||||
(o->embed ? "-E" : ""));
|
||||
T_FileStream_writeLine(makefile, tmp);
|
||||
|
||||
pkg_writeCharList(makefile, infiles, "\n", -1);
|
||||
|
|
Loading…
Add table
Reference in a new issue