ICU-7717 Add installation of data file in pkgdata tool.
X-SVN-Rev: 28206
This commit is contained in:
parent
3a2936677e
commit
578c548289
@ -111,6 +111,7 @@ static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, U
|
||||
static int32_t pkg_createSymLinks(const char *targetDir, UBool specialHandling=FALSE);
|
||||
static int32_t pkg_installLibrary(const char *installDir, const char *dir);
|
||||
static int32_t pkg_installFileMode(const char *installDir, const char *srcDir, const char *fileListName);
|
||||
static int32_t pkg_installCommonMode(const char *installDir, const char *fileName);
|
||||
|
||||
#ifdef BUILD_DATA_WITHOUT_ASSEMBLY
|
||||
static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetDir, const char mode);
|
||||
@ -120,6 +121,7 @@ static int32_t pkg_createWithAssemblyCode(const char *targetDir, const char mode
|
||||
static int32_t pkg_generateLibraryFile(const char *targetDir, const char mode, const char *objectFile, char *command = NULL);
|
||||
static int32_t pkg_archiveLibrary(const char *targetDir, const char *version, UBool reverseExt);
|
||||
static void createFileNames(UPKGOptions *o, const char mode, const char *version_major, const char *version, const char *libName, const UBool reverseExt);
|
||||
static int32_t initializePkgDataFlags(UPKGOptions *o);
|
||||
|
||||
static int32_t pkg_getOptionsFromICUConfig(UBool verbose, UOption *option);
|
||||
static int runCommand(const char* command, UBool specialHandling=FALSE);
|
||||
@ -525,9 +527,8 @@ normal_command_mode:
|
||||
#define MODE_FILES 'f'
|
||||
|
||||
static int32_t pkg_executeOptions(UPKGOptions *o) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t result = 0;
|
||||
// char cmd[SMALL_BUFFER_MAX_SIZE] = "";
|
||||
|
||||
const char mode = o->mode[0];
|
||||
char targetDir[SMALL_BUFFER_MAX_SIZE] = "";
|
||||
char tmpDir[SMALL_BUFFER_MAX_SIZE] = "";
|
||||
@ -573,6 +574,8 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
|
||||
return result;
|
||||
}
|
||||
|
||||
initializePkgDataFlags(o);
|
||||
|
||||
if (mode == MODE_COMMON) {
|
||||
char targetFileNamePath[LARGE_BUFFER_MAX_SIZE] = "";
|
||||
|
||||
@ -596,48 +599,17 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
|
||||
fprintf(stderr, "Unable to move dat file (%s) to target location (%s).\n", datFileNamePath, targetFileNamePath);
|
||||
}
|
||||
|
||||
if (o->install != NULL) {
|
||||
result = pkg_installCommonMode(o->install, targetFileNamePath);
|
||||
}
|
||||
|
||||
return result;
|
||||
} else /* if (mode[0] == MODE_STATIC || mode[0] == MODE_DLL) */ {
|
||||
char gencFilePath[SMALL_BUFFER_MAX_SIZE] = "";
|
||||
char version_major[10] = "";
|
||||
UBool reverseExt = FALSE;
|
||||
|
||||
/* Initialize pkgdataFlags */
|
||||
pkgDataFlags = (char**)uprv_malloc(sizeof(char*) * PKGDATA_FLAGS_SIZE);
|
||||
if (pkgDataFlags != NULL) {
|
||||
for (int32_t i = 0; i < PKGDATA_FLAGS_SIZE; i++) {
|
||||
pkgDataFlags[i] = (char*)uprv_malloc(sizeof(char) * MEDIUM_BUFFER_MAX_SIZE);
|
||||
if (pkgDataFlags[i] != NULL) {
|
||||
pkgDataFlags[i][0] = 0;
|
||||
} else {
|
||||
fprintf(stderr,"Error allocating memory for pkgDataFlags.\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,"Error allocating memory for pkgDataFlags.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(o->verbose) {
|
||||
fprintf(stdout, "# pkgDataFlags=");
|
||||
for(int32_t i=0;i<PKGDATA_FLAGS_SIZE && pkgDataFlags[i][0];i++) {
|
||||
fprintf(stdout, "%c \"%s\"", (i>0)?',':' ',pkgDataFlags[i]);
|
||||
}
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
#if !defined(WINDOWS_WITH_MSVC) || defined(USING_CYGWIN)
|
||||
/* Read in options file. */
|
||||
if(o->verbose) {
|
||||
fprintf(stdout, "# Reading options file %s\n", o->options);
|
||||
}
|
||||
parseFlagsFile(o->options, pkgDataFlags, SMALL_BUFFER_MAX_SIZE, (int32_t)PKGDATA_FLAGS_SIZE, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
fprintf(stderr,"Unable to open or read \"%s\" option file. status = %s\n", o->options, u_errorName(status));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get the version major number. */
|
||||
if (o->version != NULL) {
|
||||
for (uint32_t i = 0;i < sizeof(version_major);i++) {
|
||||
@ -775,6 +747,51 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Initialize the pkgDataFlags with the option file given. */
|
||||
static int32_t initializePkgDataFlags(UPKGOptions *o) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t result = 0;
|
||||
/* Initialize pkgdataFlags */
|
||||
pkgDataFlags = (char**)uprv_malloc(sizeof(char*) * PKGDATA_FLAGS_SIZE);
|
||||
if (pkgDataFlags != NULL) {
|
||||
for (int32_t i = 0; i < PKGDATA_FLAGS_SIZE; i++) {
|
||||
pkgDataFlags[i] = (char*)uprv_malloc(sizeof(char) * MEDIUM_BUFFER_MAX_SIZE);
|
||||
if (pkgDataFlags[i] != NULL) {
|
||||
pkgDataFlags[i][0] = 0;
|
||||
} else {
|
||||
fprintf(stderr,"Error allocating memory for pkgDataFlags.\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,"Error allocating memory for pkgDataFlags.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(o->verbose) {
|
||||
fprintf(stdout, "# pkgDataFlags=");
|
||||
for(int32_t i=0;i<PKGDATA_FLAGS_SIZE && pkgDataFlags[i][0];i++) {
|
||||
fprintf(stdout, "%c \"%s\"", (i>0)?',':' ',pkgDataFlags[i]);
|
||||
}
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
#if !defined(WINDOWS_WITH_MSVC) || defined(USING_CYGWIN)
|
||||
/* Read in options file. */
|
||||
if(o->verbose) {
|
||||
fprintf(stdout, "# Reading options file %s\n", o->options);
|
||||
}
|
||||
parseFlagsFile(o->options, pkgDataFlags, SMALL_BUFFER_MAX_SIZE, (int32_t)PKGDATA_FLAGS_SIZE, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
fprintf(stderr,"Unable to open or read \"%s\" option file. status = %s\n", o->options, u_errorName(status));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Given the base libName and version numbers, generate the libary file names and store it in libFileNames.
|
||||
* Depending on the configuration, the library name may either end with version number or shared object suffix.
|
||||
@ -941,6 +958,33 @@ static int32_t pkg_installLibrary(const char *installDir, const char *targetDir)
|
||||
return pkg_createSymLinks(installDir, TRUE);
|
||||
}
|
||||
|
||||
static int32_t pkg_installCommonMode(const char *installDir, const char *fileName) {
|
||||
int32_t result = 0;
|
||||
char cmd[SMALL_BUFFER_MAX_SIZE] = "";
|
||||
|
||||
if (!T_FileStream_file_exists(installDir)) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
uprv_mkdir(installDir, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
fprintf(stderr, "Error creating installation directory: %s\n", installDir);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#ifndef U_WINDOWS_WITH_MSVC
|
||||
sprintf(cmd, "%s %s %s", pkgDataFlags[INSTALL_CMD], fileName, installDir);
|
||||
#else
|
||||
sprintf(cmd, "%s %s %s %s", WIN_INSTALL_CMD, fileName, installDir, WIN_INSTALL_CMD_FLAGS);
|
||||
#endif
|
||||
|
||||
result = runCommand(cmd);
|
||||
if (result != 0) {
|
||||
fprintf(stderr, "Failed to install data file with command: %s\n", cmd);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef U_WINDOWS_MSVC
|
||||
/* Copy commands for installing the raw data files on Windows. */
|
||||
#define WIN_INSTALL_CMD "xcopy"
|
||||
|
Loading…
Reference in New Issue
Block a user