Skip to content

Commit

Permalink
Addressing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanStojanovic committed Jun 7, 2024
1 parent 5bc081d commit a539dde
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
14 changes: 12 additions & 2 deletions icu4c/source/common/unicode/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,16 @@
# define U_REAL_MSVC
#endif

/**
* \def U_CLANG_CL
* Defined if the compiler is Clang compatible with MSVC (Clang on Windows).
* Otherwise undefined.
* @internal
*/
#if (defined(_MSC_VER) && defined(__clang__) && __clang__)
# define U_CLANG_CL
#endif

/**
* \def CYGWINMSVC
* Defined if this is Windows with Cygwin, but using MSVC rather than gcc.
Expand All @@ -235,7 +245,7 @@
/**
* \def U_PLATFORM_USES_ONLY_WIN32_API
* Defines whether the platform uses only the Win32 API.
* Set to 1 for Windows/MSVC and MinGW but not Cygwin.
* Set to 1 for Windows/MSVC, ClangCL and MinGW but not Cygwin.
* @internal
*/
#ifdef U_PLATFORM_USES_ONLY_WIN32_API
Expand All @@ -250,7 +260,7 @@
/**
* \def U_PLATFORM_HAS_WIN32_API
* Defines whether the Win32 API is available on the platform.
* Set to 1 for Windows/MSVC, MinGW and Cygwin.
* Set to 1 for Windows/MSVC, ClangCL, MinGW and Cygwin.
* @internal
*/
#ifdef U_PLATFORM_HAS_WIN32_API
Expand Down
10 changes: 10 additions & 0 deletions icu4c/source/tools/genccode/genccode.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ enum {
#ifdef CAN_GENERATE_OBJECTS
kOptObject,
kOptMatchArch,
#ifdef U_CLANG_CL
kOptCpuArch,
#endif
kOptSkipDllExport,
#endif
kOptFilename,
Expand All @@ -87,7 +89,9 @@ static UOption options[]={
#ifdef CAN_GENERATE_OBJECTS
/*6*/UOPTION_DEF("object", 'o', UOPT_NO_ARG),
UOPTION_DEF("match-arch", 'm', UOPT_REQUIRES_ARG),
#ifdef U_CLANG_CL
UOPTION_DEF("cpu-arch", 'c', UOPT_REQUIRES_ARG),
#endif
UOPTION_DEF("skip-dll-export", '\0', UOPT_NO_ARG),
#endif
UOPTION_DEF("filename", 'f', UOPT_REQUIRES_ARG),
Expand Down Expand Up @@ -133,7 +137,9 @@ main(int argc, char* argv[]) {
"\t-o or --object write a .obj file instead of .c\n"
"\t-m or --match-arch file.o match the architecture (CPU, 32/64 bits) of the specified .o\n"
"\t ELF format defaults to i386. Windows defaults to the native platform.\n"
#ifdef U_CLANG_CL
"\t-c or --cpu-arch Specify a CPU architecture for which to write a .obj file for ClangCL on Windows\n"
#endif
"\t--skip-dll-export Don't export the ICU data entry point symbol (for use when statically linking)\n");
#endif
fprintf(stderr,
Expand Down Expand Up @@ -199,7 +205,11 @@ main(int argc, char* argv[]) {
writeObjectCode(filename, options[kOptDestDir].value,
options[kOptEntryPoint].doesOccur ? options[kOptEntryPoint].value : NULL,
options[kOptMatchArch].doesOccur ? options[kOptMatchArch].value : NULL,
#ifdef U_CLANG_CL
options[kOptCpuArch].doesOccur ? options[kOptCpuArch].value : NULL,
#else
NULL,
#endif
options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL,
NULL,
0,
Expand Down
7 changes: 5 additions & 2 deletions icu4c/source/tools/toolutil/pkg_genc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,14 +858,17 @@ getArchitecture(
// this would potentially be problematic when cross-compiling as this code
// would most likely be ran on host machine to generate the .obj file for
// the target architecture.
# if defined(__clang__)
# ifdef U_CLANG_CL
if (strcmp(optCpuArch, "x64") == 0) {
*pCPU = IMAGE_FILE_MACHINE_AMD64;
} else if (strcmp(optCpuArch, "x86") == 0) {
*pCPU = IMAGE_FILE_MACHINE_I386;
} else if (strcmp(optCpuArch, "arm64") == 0) {
*pCPU = IMAGE_FILE_MACHINE_ARM64;
} else {
// This should never happen.
*pCPU = IMAGE_FILE_MACHINE_UNKNOWN;
fprintf(stderr, "genccode: unable to process %s CPU architecture\n", optCpuArch);
exit(U_ILLEGAL_ARGUMENT_ERROR);
}
# else
*pCPU = IMAGE_FILE_MACHINE_UNKNOWN;
Expand Down

0 comments on commit a539dde

Please sign in to comment.