Otok public index

apotocki/icu4c

apotocki/icu4c 79.1 (r1, windows)

Library
icu4c
Variant
windows, target windows
Channel
stable
Published
2026-11-07
Recipe source
https://github.com/otok-dev/recipes.git
32756a87cf5bd189ca4c9825159bf0713ea8cf5e in recipes/icu4c/79/windows/
Recipe SHA-256
47b55508fbe956ec42feeca0163b5997a9a63bdc129ef12ef8411f53845b21ed

Recipe files changed

Inputs

source.sha25606fa63ecb521048f8082f12ad988f6b678d90cbd88aafce24cbc94902b191d99
source.urlhttps://github.com/unicode-org/icu/releases/download/release-79.1/icu4c-79.1-sources.tgz
resource data.sha25672489fb316a60ae1c1da205866edd01b17e8fbf8354ad0615e6cc60f74e08811
resource data.urlhttps://github.com/unicode-org/icu/releases/download/release-79.1/icu4c-79.1-data-bin-l.zip
resource data_sources.sha256b3a430009bb5fab77b1a4b98fab85cc8f887e26d4e4166121724298ae14d7224
resource data_sources.urlhttps://github.com/unicode-org/icu/releases/download/release-79.1/icu4c-79.1-data.zip

Platforms

windows

Options

OptionTypeDefaultDescription
data enum of ["static", "file", "none"] "static" Where the ICU data is. static: in libicudata, linked into the product. file: in icudt79l.dat, which otok delivers in data/ of the output, and libicudata is a stub; the application gives ICU the file before its first use, with u_setDataDirectory (the directory holding icudt79l.dat) or udata_setCommonData (its contents in memory). none: the stub only, and no file; the application brings the data itself.
data-filter file no file A data filter of ICU's data build tool (JSON, https://unicode-org.github.io/icu/userguide/icu_data/buildtool.html): the data is built from its sources with what the filter keeps, for data = static or file. Needs Python 3.
no-renaming bool false No version suffixes on the C entry points (u_strlen, not u_strlen_79), so that Swift, which sees no function-like macros, can call ICU directly. Two such ICUs in one process collide. On iOS and the other Apple platforms but macOS the names are those of the private API of the system libicucore, and App Store review rejects an app whose executable still has them as symbols (ITMS-90338): strip it, or use this option outside the App Store.

Toolchains

Recipe files

build.lua 6789 bytes · raw
-- ICU's own autotools build. build_tools builds ICU for the build machine once; its tools (icupkg,
-- pkgdata, genccode, …) package the data of every slice (--with-cross-build), which therefore builds
-- no tools of its own.

-- The source tree for configure, whose path it returns. `dat`: the data, icudt79l.dat, as data/in/ of ICU's build has
-- it; without it the data sources, which the release archive leaves out, built by ICU's Python build tool as the
-- project's filter says.
local function configure(slice, dat)
    if dat then
        otok.copy(dat, slice.source .. "/source/data/in/icudt79l.dat")
    else
        otok.remove(slice.source .. "/source/data")
        otok.copy(slice.resources.data_sources, slice.source .. "/source/data")
    end
    return slice.source .. "/source/configure"
end

-- The data every slice packages: the prebuilt data, or with a filter the data build_tools built from its sources once
-- (in a slice, `slice.tools.prefix`; in build_tools, nothing: it builds it).
local function data_of(slice, filter, tools)
    if not filter then return slice.resources.data .. "/icudt79l.dat" end
    return tools and tools .. "/data/icudt79l.dat" or nil
end

local common = { "--disable-extras", "--disable-tests", "--disable-samples", "--disable-dyload" }

-- the Python configure runs; with a filter, ICU's Python build tool builds the data as it says (build_tools only)
local function data_env(slice, filter)
    if not filter then return { PYTHON = slice.toolchains.python } end
    return { ICU_DATA_FILTER_FILE = filter, PYTHON = slice.toolchains.python }
end

-- MSVC through MSYS2 (runConfigureICU MSYS/MSVC): ICU knows it as a mingw host with a compiler other than gcc. The build
-- machine's architecture and the slice's: when they differ configure cross-compiles, running nothing it built
local mingw = { x86_64 = "x86_64-pc-mingw64", arm64 = "aarch64-pc-mingw64" }
local function msvc(slice, args, env)
    args[#args + 1] = "--build=" .. mingw[slice.host:match("%-(.*)$")]
    args[#args + 1] = "--host=" .. mingw[slice.arch]
    -- by name, from the PATH of Visual Studio's environment: autoconf cannot run a compiler whose path has spaces
    env.CC = "cl"
    env.CXX = "cl"
    env.AR = false
    env.RANLIB = false
    -- MSVC's options with '-': MSYS2 takes /O2 for a path and turns it into C:/…/O2 for native programs
    for _, name in ipairs{ "CFLAGS", "CXXFLAGS", "LDFLAGS" } do
        local flags = {}
        local from = name == "CFLAGS" and slice.toolchain.cflags or name == "CXXFLAGS" and slice.toolchain.cxxflags or slice.toolchain.ldflags
        for _, f in ipairs(from) do flags[#flags + 1] = (f:gsub("^/", "-")) end
        env[name] = table.concat(flags, " ")
    end
    -- ICU needs C++17, which it asks for gcc and clang only; a project's standard is in the flags already
    if not slice.cxx_standard then env.CXXFLAGS = env.CXXFLAGS .. " -std:c++20" end
end

function build_tools(slice, options, deps)
    -- the tools, built with the data the slices have: the prebuilt data is not fetched with a filter
    local filter = options["data-filter"]
    local args = { table.unpack(common) }
    local env = data_env(slice, filter)
    msvc(slice, args, env)
    otok.autotools{ configure = configure(slice, data_of(slice, filter)), args = args, cwd = slice.build, targets = { "all" }, env = env }
    -- what a cross build reads from the build tree it is given: the tools and their settings
    otok.copy(slice.build .. "/bin", slice.prefix .. "/bin")
    for _, f in ipairs{ "icucross.mk", "icucross.inc" } do
        otok.copy(slice.build .. "/config/" .. f, slice.prefix .. "/config/" .. f)
    end
    -- the data built from its sources, once: the slices package it as they package the prebuilt data
    if filter then otok.copy(slice.build .. "/data/out/tmp/icudt79l.dat", slice.prefix .. "/data/icudt79l.dat") end
end

function build(slice, options, deps)
    local dynamic = slice.linkage == "dynamic"
    local filter = options["data-filter"]
    if filter and options.data == "none" then
        error("data-filter needs data = \"static\" or \"file\": with \"none\" there is no data to filter")
    end
    -- static and library: the data in libicudata; archive: icudt79l.dat, and the stub libicudata
    local packaging = options.data ~= "static" and "archive" or dynamic and "library" or "static"
    local args = { "--with-cross-build=" .. slice.tools.prefix, "--disable-tools", "--with-data-packaging=" .. packaging }
    for _, a in ipairs(common) do args[#args + 1] = a end
    if options["no-renaming"] then args[#args + 1] = "--disable-renaming" end
    local env = data_env(slice, nil)
    msvc(slice, args, env)
    -- ICU's debug libraries: the suffix d (icuucd.lib, icuuc79d.dll) and its own assertions
    local debug = slice.configuration == "debug"
    if debug then
        args[#args + 1] = "--enable-debug"
        args[#args + 1] = "--disable-release"
    end
    if dynamic then
        -- the version resource of the data DLL waits for out/tmp/dirs.timestamp, which only the build of the data
        -- from its sources makes, in build_tools; before the build, which makes the data already when cross-compiling
        -- (an arm64 slice on an x86_64 machine)
        otok.write(slice.build .. "/data/out/tmp/dirs.timestamp", "")
    end
    otok.autotools{ configure = configure(slice, data_of(slice, filter, slice.tools.prefix)), args = args, cwd = slice.build, env = env }
    -- without tools ICU builds the data only when cross-compiling, which a slice for the build machine
    -- is not: it would install the stub; the data's Makefile takes the tools of --with-cross-build
    otok.make{ "install", cwd = slice.build .. "/data", env = env }

    -- MSVC's names: icuuc.lib with icuuc79.dll (icuucd.lib with icuucd79.dll in debug), the static sicuuc.lib;
    -- i18n is in and the data dt. The DLLs are in lib/, also without the version, which nothing imports.
    local p = slice.prefix
    local libraries = {}
    local suffix = debug and "d" or ""
    for name, stub in pairs{ uc = "uc", i18n = "in", io = "io", data = "dt" } do
        if dynamic then
            local dll = p .. "/lib/icu" .. stub .. suffix .. "79.dll"
            assert(otok.exists(dll), "ICU installed no " .. dll)
            libraries[name] = { link = p .. "/lib/icu" .. stub .. suffix .. ".lib", runtime = dll }
        else
            libraries[name] = p .. "/lib/sicu" .. stub .. suffix .. ".lib"
        end
    end
    local data = nil
    if options.data == "file" then
        -- share/icud/ for ICU's debug build
        data = { ["icudt79l.dat"] = p .. "/share/icu" .. suffix .. "/79.1/icudt79l.dat" }
    end
    return { libraries = libraries, headers = p .. "/include", data = data }
end
recipe.toml 3519 bytes · raw
# The otok recipe of ICU4C (https://github.com/apotocki/otok): libicuuc, libicui18n, libicuio and the
# ICU data for Windows, from the release archive with the prebuilt data, or with the data
# built from its sources by the project's filter; the data in libicudata, as a file of its own or not at all;
# static or dynamic. Built with MSVC under MSYS2, the tree of the make recipe.
[recipe]
api = 1
library = "icu4c"
name = "icu4c"
version = "79.1"
revision = 1
license = "Unicode-3.0"
license-files = ["LICENSE"]
homepage = "https://icu.unicode.org"
description = "ICU, the International Components for Unicode (libicuuc, libicui18n, libicuio, the data)."
keywords = ["unicode", "i18n", "icu"]
linkage = ["static", "dynamic"]
cxx-standard = ">= 17"

# the sources of the release carry no data sources, only the data the build itself needs
[source]
url = "https://github.com/unicode-org/icu/releases/download/release-79.1/icu4c-79.1-sources.tgz"
sha256 = "06fa63ecb521048f8082f12ad988f6b678d90cbd88aafce24cbc94902b191d99"

# the prebuilt little-endian data, unless the data is filtered
[[resource]]
name = "data"
url = "https://github.com/unicode-org/icu/releases/download/release-79.1/icu4c-79.1-data-bin-l.zip"
sha256 = "72489fb316a60ae1c1da205866edd01b17e8fbf8354ad0615e6cc60f74e08811"
when = { not = { option = "data-filter" } }

# the sources of the data, which ICU's Python build tool builds as a filter chooses
[[resource]]
name = "data_sources"
url = "https://github.com/unicode-org/icu/releases/download/release-79.1/icu4c-79.1-data.zip"
sha256 = "b3a430009bb5fab77b1a4b98fab85cc8f887e26d4e4166121724298ae14d7224"
when = { option = "data-filter" }

[platforms]
supported = ["windows"]
build-on = ["windows/msvc"]

[options.no-renaming]
type = "bool"
default = false
doc = "No version suffixes on the C entry points (u_strlen, not u_strlen_79), so that Swift, which sees no function-like macros, can call ICU directly. Two such ICUs in one process collide. On iOS and the other Apple platforms but macOS the names are those of the private API of the system libicucore, and App Store review rejects an app whose executable still has them as symbols (ITMS-90338): strip it, or use this option outside the App Store."

[options.data]
type = "enum"
values = ["static", "file", "none"]
default = "static"
doc = "Where the ICU data is. static: in libicudata, linked into the product. file: in icudt79l.dat, which otok delivers in data/ of the output, and libicudata is a stub; the application gives ICU the file before its first use, with u_setDataDirectory (the directory holding icudt79l.dat) or udata_setCommonData (its contents in memory). none: the stub only, and no file; the application brings the data itself."

[options.data-filter]
type = "file"
doc = "A data filter of ICU's data build tool (JSON, https://unicode-org.github.io/icu/userguide/icu_data/buildtool.html): the data is built from its sources with what the filter keeps, for data = static or file. Needs Python 3."

[toolchains]
make = { version = ">= 3.81", default-recipe = "apotocki/make" }
# configure runs any Python it finds (PYTHONPATH=… python -m icutools…), for the rules of the test data too: it is
# given this one
python = { version = ">= 3.9", default-recipe = "apotocki/python" }

[[product]]
name = "ICU"
libraries = ["io", "i18n", "uc", "data"]
link = { runtime = "c++" }
headers = "uc"
# the installed headers do not record --disable-renaming
defines = [{ define = "U_DISABLE_RENAMING=1", when = { option = "no-renaming" } }]