mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-3933 Fix compiler warnings and update to handle gcc on windows without cygwin.
X-SVN-Rev: 25049
This commit is contained in:
parent
962dd1352a
commit
e5d30afa11
1 changed files with 33 additions and 121 deletions
|
@ -53,6 +53,13 @@ U_CDECL_BEGIN
|
|||
#include "makefile.h"
|
||||
U_CDECL_END
|
||||
|
||||
#if defined(U_WINDOWS) && !defined(__GNUC__)
|
||||
#define WINDOWS_WITH_MSVC
|
||||
#endif
|
||||
#if !defined(WINDOWS_WITH_MSVC) && !defined(U_LINUX)
|
||||
#define BUILD_DATA_WITHOUT_ASSEMBLY
|
||||
#endif
|
||||
|
||||
#define LARGE_BUFFER_MAX_SIZE 2048
|
||||
#define SMALL_BUFFER_MAX_SIZE 512
|
||||
|
||||
|
@ -60,20 +67,22 @@ static void loadLists(UPKGOptions *o, UErrorCode *status);
|
|||
|
||||
static int32_t pkg_executeOptions(UPKGOptions *o);
|
||||
|
||||
#ifdef U_WINDOWS
|
||||
#ifdef WINDOWS_WITH_MSVC
|
||||
static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, UPKGOptions *o);
|
||||
#endif
|
||||
static int32_t pkg_createSymLinks(const char *targetDir);
|
||||
static int32_t pkg_installLibrary(const char *installDir, const char *dir);
|
||||
|
||||
#ifdef BUILD_DATA_WITHOUT_ASSEMBLY
|
||||
static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetDir, const char mode);
|
||||
#endif
|
||||
|
||||
static int32_t pkg_createWithAssemblyCode(const char *targetDir, const char mode, const char *gencFilePath);
|
||||
static int32_t pkg_generateLibraryFile(const char *targetDir, const char mode, const char *objectFile, char *command);
|
||||
static int32_t pkg_archiveLibrary(const char *targetDir, const char *version, UBool reverseExt);
|
||||
static void createFileNames(const char *version_major, const char *version, const char *libName, const UBool reverseExt);
|
||||
|
||||
static int32_t pkg_getOptionsFromICUConfig(UOption *option);
|
||||
/* always have this fcn, just might not do anything */
|
||||
static void fillInMakefileFromICUConfig(UOption *option);
|
||||
|
||||
/* This sets the modes that are available */
|
||||
static struct
|
||||
|
@ -219,7 +228,8 @@ main(int argc, char* argv[]) {
|
|||
UBool needsHelp = FALSE;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
/* char tmp[1024]; */
|
||||
int32_t i;
|
||||
uint32_t i;
|
||||
int32_t n;
|
||||
|
||||
U_MAIN_INIT_ARGS(argc, argv);
|
||||
|
||||
|
@ -248,7 +258,7 @@ main(int argc, char* argv[]) {
|
|||
}
|
||||
|
||||
|
||||
#ifndef U_WINDOWS
|
||||
#ifndef WINDOWS_WITH_MSVC
|
||||
if(!options[BLDOPT].doesOccur) {
|
||||
if (pkg_getOptionsFromICUConfig(&options[BLDOPT]) != 0) {
|
||||
fprintf(stderr, " required parameter is missing: -O is required \n");
|
||||
|
@ -366,7 +376,7 @@ main(int argc, char* argv[]) {
|
|||
|
||||
o.verbose = options[VERBOSE].doesOccur;
|
||||
|
||||
#ifndef U_WINDOWS /* on UNIX, we'll just include the file... */
|
||||
#ifndef WINDOWS_WITH_MSVC /* on UNIX, we'll just include the file... */
|
||||
o.options = options[BLDOPT].value;
|
||||
#endif
|
||||
if(options[COPYRIGHT].doesOccur) {
|
||||
|
@ -411,8 +421,8 @@ main(int argc, char* argv[]) {
|
|||
|
||||
/* OK options are set up. Now the file lists. */
|
||||
tail = NULL;
|
||||
for( i=1; i<argc; i++) {
|
||||
if ( !uprv_strcmp(argv[i] , "-") ) {
|
||||
for( n=1; n<argc; n++) {
|
||||
if ( !uprv_strcmp(argv[n] , "-") ) {
|
||||
/* stdin */
|
||||
if( o.hadStdin == TRUE ) {
|
||||
fprintf(stderr, "Error: can't specify '-' twice!\n"
|
||||
|
@ -422,7 +432,7 @@ main(int argc, char* argv[]) {
|
|||
o.hadStdin = TRUE;
|
||||
}
|
||||
|
||||
o.fileListFiles = pkg_appendToList(o.fileListFiles, &tail, uprv_strdup(argv[i]));
|
||||
o.fileListFiles = pkg_appendToList(o.fileListFiles, &tail, uprv_strdup(argv[n]));
|
||||
}
|
||||
|
||||
/* load the files */
|
||||
|
@ -518,10 +528,10 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
#ifndef U_WINDOWS
|
||||
#ifndef WINDOWS_WITH_MSVC
|
||||
/* Get the version major number. */
|
||||
if (o->version != NULL) {
|
||||
for (int32_t i = 0;i < sizeof(version_major);i++) {
|
||||
for (uint32_t i = 0;i < sizeof(version_major);i++) {
|
||||
if (o->version[i] == '.') {
|
||||
version_major[i] = 0;
|
||||
break;
|
||||
|
@ -574,14 +584,14 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
|
|||
return -1;
|
||||
}
|
||||
} else {
|
||||
#if defined(U_WINDOWS) || defined(U_LINUX)
|
||||
#if defined(WINDOWS_WITH_MSVC) || defined(U_LINUX)
|
||||
writeObjectCode(datFileNamePath, o->tmpDir, o->entryName, NULL, NULL, gencFilePath);
|
||||
#ifdef U_LINUX
|
||||
result = pkg_generateLibraryFile(targetDir, mode, gencFilePath, NULL);
|
||||
#else U_WINDOWS
|
||||
#else /* WINDOWS_WITH_MSVC */
|
||||
return pkg_createWindowsDLL(mode, gencFilePath, o);
|
||||
#endif
|
||||
#else
|
||||
#elif defined(BUILD_DATA_WITHOUT_ASSEMBLY)
|
||||
result = pkg_createWithoutAssemblyCode(o, targetDir, mode);
|
||||
#endif
|
||||
if (result != 0) {
|
||||
|
@ -589,7 +599,7 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
|
|||
return result;
|
||||
}
|
||||
}
|
||||
#ifndef U_WINDOWS
|
||||
#ifndef WINDOWS_WITH_MSVC
|
||||
/* Certain platforms uses archive library. (e.g. AIX) */
|
||||
result = pkg_archiveLibrary(targetDir, o->version, reverseExt);
|
||||
if (result != 0) {
|
||||
|
@ -838,6 +848,7 @@ static int32_t pkg_createWithAssemblyCode(const char *targetDir, const char mode
|
|||
return pkg_generateLibraryFile(targetDir, mode, tempObjectFile, cmd);
|
||||
}
|
||||
|
||||
#ifdef BUILD_DATA_WITHOUT_ASSEMBLY
|
||||
/*
|
||||
* Generation of the data library without assembly code needs to compile each data file
|
||||
* individually and then link it all together.
|
||||
|
@ -953,8 +964,9 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD
|
|||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef U_WINDOWS
|
||||
#ifdef WINDOWS_WITH_MSVC
|
||||
#define LINK_CMD "link.exe /nologo /release /out:"
|
||||
#define LINK_FLAGS "/DLL /NOENTRY /MANIFEST:NO /base:0x4ad00000 /implib:"
|
||||
#define LIB_CMD "LIB.exe /nologo /out:"
|
||||
|
@ -1067,9 +1079,9 @@ static void extractFlag(char* buffer, int32_t bufferSize, char* flag) {
|
|||
}
|
||||
|
||||
static void pkg_checkFlag(UPKGOptions *o) {
|
||||
#ifdef U_AIX
|
||||
char *flag = NULL;
|
||||
int32_t length = 0;
|
||||
#ifdef U_AIX
|
||||
char tmpbuffer[SMALL_BUFFER_MAX_SIZE];
|
||||
const char MAP_FILE_EXT[] = ".map";
|
||||
FileStream *f = NULL;
|
||||
|
@ -1133,6 +1145,9 @@ static void pkg_checkFlag(UPKGOptions *o) {
|
|||
T_FileStream_close(f);
|
||||
}
|
||||
#elif defined(U_CYGWIN)
|
||||
char *flag = NULL;
|
||||
int32_t length = 0;
|
||||
|
||||
flag = pkgDataFlags[GENLIB];
|
||||
length = uprv_strlen(pkgDataFlags[GENLIB]);
|
||||
|
||||
|
@ -1155,7 +1170,7 @@ static void pkg_checkFlag(UPKGOptions *o) {
|
|||
static int32_t pkg_readInFlags(const char *fileName) {
|
||||
int32_t result = 0;
|
||||
|
||||
#ifdef U_WINDOWS
|
||||
#ifdef WINDOWS_WITH_MSVC
|
||||
/* Zero out the flags since it is not being used. */
|
||||
for (int32_t i = 0; i < PKGDATA_FLAGS_SIZE; i++) {
|
||||
pkgDataFlags[i][0] = 0;
|
||||
|
@ -1352,106 +1367,3 @@ static int32_t pkg_getOptionsFromICUConfig(UOption *option) {
|
|||
#endif
|
||||
return -1;
|
||||
}
|
||||
/* Try calling icu-config directly to get information */
|
||||
static void fillInMakefileFromICUConfig(UOption *option)
|
||||
{
|
||||
#if 0
|
||||
#if U_HAVE_POPEN
|
||||
FILE *p;
|
||||
size_t n;
|
||||
static char buf[512] = "";
|
||||
static const char cmd[] = "icu-config --incfile";
|
||||
|
||||
if(options[5].doesOccur)
|
||||
{
|
||||
/* informational */
|
||||
fprintf(stderr, "%s: No -O option found, trying '%s'.\n", progname, cmd);
|
||||
}
|
||||
|
||||
p = popen(cmd, "r");
|
||||
|
||||
if(p == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s: icu-config: No icu-config found. (fix PATH or use -O option)\n", progname);
|
||||
return;
|
||||
}
|
||||
|
||||
n = fread(buf, 1, 511, p);
|
||||
|
||||
pclose(p);
|
||||
|
||||
if(n<=0)
|
||||
{
|
||||
fprintf(stderr,"%s: icu-config: Could not read from icu-config. (fix PATH or use -O option)\n", progname);
|
||||
return;
|
||||
}
|
||||
|
||||
if(buf[strlen(buf)-1]=='\n')
|
||||
{
|
||||
buf[strlen(buf)-1]=0;
|
||||
}
|
||||
|
||||
if(buf[0] == 0)
|
||||
{
|
||||
fprintf(stderr, "%s: icu-config: invalid response from icu-config (fix PATH or use -O option)\n", progname);
|
||||
return;
|
||||
}
|
||||
|
||||
if(options[5].doesOccur)
|
||||
{
|
||||
/* informational */
|
||||
fprintf(stderr, "%s: icu-config: using '-O %s'\n", progname, buf);
|
||||
}
|
||||
option->value = buf;
|
||||
option->doesOccur = TRUE;
|
||||
#else /* ! U_HAVE_POPEN */
|
||||
|
||||
#ifdef U_WINDOWS
|
||||
char pathbuffer[_MAX_PATH] = {0};
|
||||
char *fullEXEpath = NULL;
|
||||
char *pathstuff = NULL;
|
||||
|
||||
if (strchr(progname, U_FILE_SEP_CHAR) != NULL || strchr(progname, U_FILE_ALT_SEP_CHAR) != NULL) {
|
||||
/* pkgdata was executed with relative path */
|
||||
fullEXEpath = _fullpath(pathbuffer, progname, sizeof(pathbuffer));
|
||||
pathstuff = (char *)options[1].value;
|
||||
|
||||
if (fullEXEpath) {
|
||||
pathstuff = strrchr(fullEXEpath, U_FILE_SEP_CHAR);
|
||||
if (pathstuff) {
|
||||
pathstuff[1] = 0;
|
||||
uprv_memmove(fullEXEpath + 2, fullEXEpath, uprv_strlen(fullEXEpath)+1);
|
||||
fullEXEpath[0] = PKGDATA_DERIVED_PATH;
|
||||
fullEXEpath[1] = ':';
|
||||
option->value = uprv_strdup(fullEXEpath);
|
||||
option->doesOccur = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* pkgdata was executed from the path */
|
||||
/* Search for file in PATH environment variable: */
|
||||
_searchenv("pkgdata.exe", "PATH", pathbuffer );
|
||||
if( *pathbuffer != '\0' ) {
|
||||
fullEXEpath = pathbuffer;
|
||||
pathstuff = strrchr(pathbuffer, U_FILE_SEP_CHAR);
|
||||
if (pathstuff) {
|
||||
pathstuff[1] = 0;
|
||||
uprv_memmove(fullEXEpath + 2, fullEXEpath, uprv_strlen(fullEXEpath)+1);
|
||||
fullEXEpath[0] = PKGDATA_DERIVED_PATH;
|
||||
fullEXEpath[1] = ':';
|
||||
option->value = uprv_strdup(fullEXEpath);
|
||||
option->doesOccur = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* else can't determine the path */
|
||||
#endif
|
||||
|
||||
/* no popen available */
|
||||
/* Put other OS specific ways to search for the Makefile.inc type
|
||||
information or else fail.. */
|
||||
|
||||
#endif
|
||||
#endif /* End of #if 0 */
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue