Skip to content

Commit

Permalink
build: repair the build on Windows (#20)
Browse files Browse the repository at this point in the history
Replicate the behaviour from upstream ICU:
  ```
  #if defined(U_TIMEZONE) || defined(U_HAVE_TIMEZONE)
      /* Use the predefined value. */
  #elif U_PLATFORM == U_PF_ANDROID
  #   define U_TIMEZONE timezone
  #elif defined(__UCLIBC__)
      // uClibc does not have __timezone or _timezone.
  #elif defined(_NEWLIB_VERSION)
  #   define U_TIMEZONE _timezone
  #elif defined(__GLIBC__)
      // glibc
  #   define U_TIMEZONE __timezone
  #elif U_PLATFORM_IS_LINUX_BASED
      // not defined
  #elif U_PLATFORM_USES_ONLY_WIN32_API
  #   define U_TIMEZONE _timezone
  #elif U_PLATFORM == U_PF_BSD && !defined(__NetBSD__)
     /* not defined */
  #elif U_PLATFORM == U_PF_OS400
     /* not defined */
  #elif U_PLATFORM == U_PF_IPHONE
     /* not defined */
  #else
  #   define U_TIMEZONE timezone
  #endif
  ```

With this change, ICU at least builds, but it is unclear if it functions
properly on Windows.
  • Loading branch information
compnerd authored Mar 29, 2024
1 parent 40b9706 commit c7ed2ab
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ var buildSettings: [CXXSetting] = [
.define("U_SHOW_CPLUSPLUS_API", to: "1"),
.define("U_SHOW_INTERNAL_API", to: "1"),
.define("U_STATIC_IMPLEMENTATION"),
.define("U_TIMEZONE", to: "timezone"),
.define("U_TIMEZONE", to: "_timezone", .when(platforms: [.windows])),
.define("U_TIMEZONE", to: "timezone",
.when(platforms: [
.iOS,
.macOS,
.tvOS,
.watchOS,
.macCatalyst,
.driverKit,
.android,
.linux,
.wasi
])),
.define("U_TIMEZONE_PACKAGE", to: "\"icutz44l\""),
.define("FORTIFY_SOURCE", to: "2"),
.define("STD_INSPIRED"),
Expand Down

0 comments on commit c7ed2ab

Please sign in to comment.