ICU-11391 Add arch detection code in pkgdata tool
X-SVN-Rev: 36932
This commit is contained in:
parent
bc68cc5b15
commit
2ab0292209
@ -73,6 +73,11 @@ static int32_t pkg_installCommonMode(const char *installDir, const char *fileNam
|
||||
static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetDir, const char mode);
|
||||
#endif
|
||||
|
||||
#ifdef CAN_WRITE_OBJ_CODE
|
||||
static void pkg_createOptMatchArch(char *optMatchArch);
|
||||
static void pkg_destroyOptMatchArch(char *optMatchArch);
|
||||
#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 = NULL, UBool specialHandling=FALSE);
|
||||
static int32_t pkg_archiveLibrary(const char *targetDir, const char *version, UBool reverseExt);
|
||||
@ -730,7 +735,11 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
|
||||
#endif
|
||||
} else {
|
||||
#ifdef CAN_WRITE_OBJ_CODE
|
||||
writeObjectCode(datFileNamePath, o->tmpDir, o->entryName, NULL, NULL, gencFilePath);
|
||||
/* Try to detect the arch type, use NULL if unsuccessful */
|
||||
char optMatchArch[10] = { 0 };
|
||||
pkg_createOptMatchArch(optMatchArch);
|
||||
writeObjectCode(datFileNamePath, o->tmpDir, o->entryName, (optMatchArch[0] == 0 ? NULL : optMatchArch), NULL, gencFilePath);
|
||||
pkg_destroyOptMatchArch(optMatchArch);
|
||||
#if U_PLATFORM_IS_LINUX_BASED
|
||||
result = pkg_generateLibraryFile(targetDir, mode, gencFilePath);
|
||||
#elif defined(WINDOWS_WITH_MSVC)
|
||||
@ -2147,3 +2156,43 @@ static void loadLists(UPKGOptions *o, UErrorCode *status)
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CAN_WRITE_OBJ_CODE
|
||||
/* Create optMatchArch for genccode architecture detection */
|
||||
static void pkg_createOptMatchArch(char *optMatchArch) {
|
||||
const char* code = "void oma(){}";
|
||||
const char* source = "oma.c";
|
||||
const char* obj = "oma.obj";
|
||||
FileStream* stream = NULL;
|
||||
|
||||
stream = T_FileStream_open(source,"w");
|
||||
if (stream != NULL) {
|
||||
T_FileStream_writeLine(stream, code);
|
||||
T_FileStream_close(stream);
|
||||
|
||||
char cmd[SMALL_BUFFER_MAX_SIZE];
|
||||
sprintf(cmd, "%s %s -o %s",
|
||||
pkgDataFlags[COMPILER],
|
||||
source,
|
||||
obj);
|
||||
|
||||
if (runCommand(cmd) == 0){
|
||||
sprintf(optMatchArch, "%s", obj);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Failed to compile %s\n", source);
|
||||
}
|
||||
if(!T_FileStream_remove(source)){
|
||||
fprintf(stderr, "T_FileStream_remove failed to delete %s\n", source);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "T_FileStream_open failed to open %s for writing\n", source);
|
||||
}
|
||||
}
|
||||
static void pkg_destroyOptMatchArch(char *optMatchArch) {
|
||||
if(!T_FileStream_remove(optMatchArch)){
|
||||
fprintf(stderr, "T_FileStream_remove failed to delete %s\n", optMatchArch);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user