[0-9]+(?:\.[0-9]+)*) # release segment
- (?P # pre-release
- [-_\.]?
- (?Palpha|a|beta|b|preview|pre|c|rc)
- [-_\.]?
- (?P[0-9]+)?
- )?
- (?P # post release
- (?:-(?P[0-9]+))
- |
- (?:
- [-_\.]?
- (?Ppost|rev|r)
- [-_\.]?
- (?P[0-9]+)?
- )
- )?
- (?P # dev release
- [-_\.]?
- (?Pdev)
- [-_\.]?
- (?P[0-9]+)?
- )?
- )
- (?:\+(?P[a-z0-9]+(?:[-_\.][a-z0-9]+)*))? # local version
-"""
-
-VERSION_PATTERN = _VERSION_PATTERN
-"""
-A string containing the regular expression used to match a valid version.
-
-The pattern is not anchored at either end, and is intended for embedding in larger
-expressions (for example, matching a version number as part of a file name). The
-regular expression should be compiled with the ``re.VERBOSE`` and ``re.IGNORECASE``
-flags set.
-
-:meta hide-value:
-"""
-
-
-class Version(_BaseVersion):
- """This class abstracts handling of a project's versions.
-
- A :class:`Version` instance is comparison aware and can be compared and
- sorted using the standard Python interfaces.
-
- >>> v1 = Version("1.0a5")
- >>> v2 = Version("1.0")
- >>> v1
-
- >>> v2
-
- >>> v1 < v2
- True
- >>> v1 == v2
- False
- >>> v1 > v2
- False
- >>> v1 >= v2
- False
- >>> v1 <= v2
- True
- """
-
- _regex = re.compile(r"^\s*" + VERSION_PATTERN + r"\s*$", re.VERBOSE | re.IGNORECASE)
- _key: CmpKey
-
- def __init__(self, version: str) -> None:
- """Initialize a Version object.
-
- :param version:
- The string representation of a version which will be parsed and normalized
- before use.
- :raises InvalidVersion:
- If the ``version`` does not conform to PEP 440 in any way then this
- exception will be raised.
- """
-
- # Validate the version and parse it into pieces
- match = self._regex.search(version)
- if not match:
- raise InvalidVersion(f"Invalid version: '{version}'")
-
- # Store the parsed out pieces of the version
- self._version = _Version(
- epoch=int(match.group("epoch")) if match.group("epoch") else 0,
- release=tuple(int(i) for i in match.group("release").split(".")),
- pre=_parse_letter_version(match.group("pre_l"), match.group("pre_n")),
- post=_parse_letter_version(
- match.group("post_l"), match.group("post_n1") or match.group("post_n2")
- ),
- dev=_parse_letter_version(match.group("dev_l"), match.group("dev_n")),
- local=_parse_local_version(match.group("local")),
- )
-
- # Generate a key which will be used for sorting
- self._key = _cmpkey(
- self._version.epoch,
- self._version.release,
- self._version.pre,
- self._version.post,
- self._version.dev,
- self._version.local,
- )
-
- def __repr__(self) -> str:
- """A representation of the Version that shows all internal state.
-
- >>> Version('1.0.0')
-
- """
- return f""
-
- def __str__(self) -> str:
- """A string representation of the version that can be rounded-tripped.
-
- >>> str(Version("1.0a5"))
- '1.0a5'
- """
- parts = []
-
- # Epoch
- if self.epoch != 0:
- parts.append(f"{self.epoch}!")
-
- # Release segment
- parts.append(".".join(str(x) for x in self.release))
-
- # Pre-release
- if self.pre is not None:
- parts.append("".join(str(x) for x in self.pre))
-
- # Post-release
- if self.post is not None:
- parts.append(f".post{self.post}")
-
- # Development release
- if self.dev is not None:
- parts.append(f".dev{self.dev}")
-
- # Local version segment
- if self.local is not None:
- parts.append(f"+{self.local}")
-
- return "".join(parts)
-
- @property
- def epoch(self) -> int:
- """The epoch of the version.
-
- >>> Version("2.0.0").epoch
- 0
- >>> Version("1!2.0.0").epoch
- 1
- """
- return self._version.epoch
-
- @property
- def release(self) -> Tuple[int, ...]:
- """The components of the "release" segment of the version.
-
- >>> Version("1.2.3").release
- (1, 2, 3)
- >>> Version("2.0.0").release
- (2, 0, 0)
- >>> Version("1!2.0.0.post0").release
- (2, 0, 0)
-
- Includes trailing zeroes but not the epoch or any pre-release / development /
- post-release suffixes.
- """
- return self._version.release
-
- @property
- def pre(self) -> Optional[Tuple[str, int]]:
- """The pre-release segment of the version.
-
- >>> print(Version("1.2.3").pre)
- None
- >>> Version("1.2.3a1").pre
- ('a', 1)
- >>> Version("1.2.3b1").pre
- ('b', 1)
- >>> Version("1.2.3rc1").pre
- ('rc', 1)
- """
- return self._version.pre
-
- @property
- def post(self) -> Optional[int]:
- """The post-release number of the version.
-
- >>> print(Version("1.2.3").post)
- None
- >>> Version("1.2.3.post1").post
- 1
- """
- return self._version.post[1] if self._version.post else None
-
- @property
- def dev(self) -> Optional[int]:
- """The development number of the version.
-
- >>> print(Version("1.2.3").dev)
- None
- >>> Version("1.2.3.dev1").dev
- 1
- """
- return self._version.dev[1] if self._version.dev else None
-
- @property
- def local(self) -> Optional[str]:
- """The local version segment of the version.
-
- >>> print(Version("1.2.3").local)
- None
- >>> Version("1.2.3+abc").local
- 'abc'
- """
- if self._version.local:
- return ".".join(str(x) for x in self._version.local)
- else:
- return None
-
- @property
- def public(self) -> str:
- """The public portion of the version.
-
- >>> Version("1.2.3").public
- '1.2.3'
- >>> Version("1.2.3+abc").public
- '1.2.3'
- >>> Version("1.2.3+abc.dev1").public
- '1.2.3'
- """
- return str(self).split("+", 1)[0]
-
- @property
- def base_version(self) -> str:
- """The "base version" of the version.
-
- >>> Version("1.2.3").base_version
- '1.2.3'
- >>> Version("1.2.3+abc").base_version
- '1.2.3'
- >>> Version("1!1.2.3+abc.dev1").base_version
- '1!1.2.3'
-
- The "base version" is the public version of the project without any pre or post
- release markers.
- """
- parts = []
-
- # Epoch
- if self.epoch != 0:
- parts.append(f"{self.epoch}!")
-
- # Release segment
- parts.append(".".join(str(x) for x in self.release))
-
- return "".join(parts)
-
- @property
- def is_prerelease(self) -> bool:
- """Whether this version is a pre-release.
-
- >>> Version("1.2.3").is_prerelease
- False
- >>> Version("1.2.3a1").is_prerelease
- True
- >>> Version("1.2.3b1").is_prerelease
- True
- >>> Version("1.2.3rc1").is_prerelease
- True
- >>> Version("1.2.3dev1").is_prerelease
- True
- """
- return self.dev is not None or self.pre is not None
-
- @property
- def is_postrelease(self) -> bool:
- """Whether this version is a post-release.
-
- >>> Version("1.2.3").is_postrelease
- False
- >>> Version("1.2.3.post1").is_postrelease
- True
- """
- return self.post is not None
-
- @property
- def is_devrelease(self) -> bool:
- """Whether this version is a development release.
-
- >>> Version("1.2.3").is_devrelease
- False
- >>> Version("1.2.3.dev1").is_devrelease
- True
- """
- return self.dev is not None
-
- @property
- def major(self) -> int:
- """The first item of :attr:`release` or ``0`` if unavailable.
-
- >>> Version("1.2.3").major
- 1
- """
- return self.release[0] if len(self.release) >= 1 else 0
-
- @property
- def minor(self) -> int:
- """The second item of :attr:`release` or ``0`` if unavailable.
-
- >>> Version("1.2.3").minor
- 2
- >>> Version("1").minor
- 0
- """
- return self.release[1] if len(self.release) >= 2 else 0
-
- @property
- def micro(self) -> int:
- """The third item of :attr:`release` or ``0`` if unavailable.
-
- >>> Version("1.2.3").micro
- 3
- >>> Version("1").micro
- 0
- """
- return self.release[2] if len(self.release) >= 3 else 0
-
-
-def _parse_letter_version(
- letter: Optional[str], number: Union[str, bytes, SupportsInt, None]
-) -> Optional[Tuple[str, int]]:
-
- if letter:
- # We consider there to be an implicit 0 in a pre-release if there is
- # not a numeral associated with it.
- if number is None:
- number = 0
-
- # We normalize any letters to their lower case form
- letter = letter.lower()
-
- # We consider some words to be alternate spellings of other words and
- # in those cases we want to normalize the spellings to our preferred
- # spelling.
- if letter == "alpha":
- letter = "a"
- elif letter == "beta":
- letter = "b"
- elif letter in ["c", "pre", "preview"]:
- letter = "rc"
- elif letter in ["rev", "r"]:
- letter = "post"
-
- return letter, int(number)
- if not letter and number:
- # We assume if we are given a number, but we are not given a letter
- # then this is using the implicit post release syntax (e.g. 1.0-1)
- letter = "post"
-
- return letter, int(number)
-
- return None
-
-
-_local_version_separators = re.compile(r"[\._-]")
-
-
-def _parse_local_version(local: Optional[str]) -> Optional[LocalType]:
- """
- Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
- """
- if local is not None:
- return tuple(
- part.lower() if not part.isdigit() else int(part)
- for part in _local_version_separators.split(local)
- )
- return None
-
-
-def _cmpkey(
- epoch: int,
- release: Tuple[int, ...],
- pre: Optional[Tuple[str, int]],
- post: Optional[Tuple[str, int]],
- dev: Optional[Tuple[str, int]],
- local: Optional[LocalType],
-) -> CmpKey:
-
- # When we compare a release version, we want to compare it with all of the
- # trailing zeros removed. So we'll use a reverse the list, drop all the now
- # leading zeros until we come to something non zero, then take the rest
- # re-reverse it back into the correct order and make it a tuple and use
- # that for our sorting key.
- _release = tuple(
- reversed(list(itertools.dropwhile(lambda x: x == 0, reversed(release))))
- )
-
- # We need to "trick" the sorting algorithm to put 1.0.dev0 before 1.0a0.
- # We'll do this by abusing the pre segment, but we _only_ want to do this
- # if there is not a pre or a post segment. If we have one of those then
- # the normal sorting rules will handle this case correctly.
- if pre is None and post is None and dev is not None:
- _pre: CmpPrePostDevType = NegativeInfinity
- # Versions without a pre-release (except as noted above) should sort after
- # those with one.
- elif pre is None:
- _pre = Infinity
- else:
- _pre = pre
-
- # Versions without a post segment should sort before those with one.
- if post is None:
- _post: CmpPrePostDevType = NegativeInfinity
-
- else:
- _post = post
-
- # Versions without a development segment should sort after those with one.
- if dev is None:
- _dev: CmpPrePostDevType = Infinity
-
- else:
- _dev = dev
-
- if local is None:
- # Versions without a local segment should sort before those with one.
- _local: CmpLocalType = NegativeInfinity
- else:
- # Versions with a local segment need that segment parsed to implement
- # the sorting rules in PEP440.
- # - Alpha numeric segments sort before numeric segments
- # - Alpha numeric segments sort lexicographically
- # - Numeric segments sort numerically
- # - Shorter versions sort before longer versions when the prefixes
- # match exactly
- _local = tuple(
- (i, "") if isinstance(i, int) else (NegativeInfinity, i) for i in local
- )
-
- return epoch, _release, _pre, _post, _dev, _local
diff --git a/tools/gyp/pyproject.toml b/tools/gyp/pyproject.toml
deleted file mode 100644
index 487cb75002d..00000000000
--- a/tools/gyp/pyproject.toml
+++ /dev/null
@@ -1,116 +0,0 @@
-[build-system]
-requires = ["setuptools>=61.0"]
-build-backend = "setuptools.build_meta"
-
-[project]
-name = "gyp-next"
-version = "0.22.2"
-authors = [
- { name="Node.js contributors", email="ryzokuken@disroot.org" },
-]
-description = "A fork of the GYP build system for use in the Node.js projects"
-readme = "README.md"
-license = "BSD-3-Clause"
-license-files = ["LICENSE"]
-requires-python = ">=3.9"
-dependencies = ["packaging>=24.0", "setuptools>=77.0.3"]
-classifiers = [
- "Development Status :: 3 - Alpha",
- "Environment :: Console",
- "Intended Audience :: Developers",
- "Natural Language :: English",
- "Programming Language :: Python",
- "Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.9",
- "Programming Language :: Python :: 3.10",
- "Programming Language :: Python :: 3.11",
- "Programming Language :: Python :: 3.12",
- "Programming Language :: Python :: 3.13",
- "Programming Language :: Python :: 3.14",
-]
-
-[project.optional-dependencies]
-dev = ["pytest", "ruff"]
-
-[project.scripts]
-gyp = "gyp:script_main"
-
-[project.urls]
-"Homepage" = "https://github.com/nodejs/gyp-next"
-
-[tool.ruff]
-extend-exclude = ["pylib/packaging"]
-line-length = 88
-
-[tool.ruff.lint]
-select = [
- "C4", # flake8-comprehensions
- "C90", # McCabe cyclomatic complexity
- "DTZ", # flake8-datetimez
- "E", # pycodestyle
- "F", # Pyflakes
- "G", # flake8-logging-format
- "ICN", # flake8-import-conventions
- "INT", # flake8-gettext
- "PL", # Pylint
- "PYI", # flake8-pyi
- "RSE", # flake8-raise
- "RUF", # Ruff-specific rules
- "T10", # flake8-debugger
- "TCH", # flake8-type-checking
- "TID", # flake8-tidy-imports
- "UP", # pyupgrade
- "W", # pycodestyle
- "YTT", # flake8-2020
- # "A", # flake8-builtins
- # "ANN", # flake8-annotations
- # "ARG", # flake8-unused-arguments
- # "B", # flake8-bugbear
- # "BLE", # flake8-blind-except
- # "COM", # flake8-commas
- # "D", # pydocstyle
- # "DJ", # flake8-django
- # "EM", # flake8-errmsg
- # "ERA", # eradicate
- # "EXE", # flake8-executable
- # "FBT", # flake8-boolean-trap
- # "I", # isort
- # "INP", # flake8-no-pep420
- # "ISC", # flake8-implicit-str-concat
- # "N", # pep8-naming
- # "NPY", # NumPy-specific rules
- # "PD", # pandas-vet
- # "PGH", # pygrep-hooks
- # "PIE", # flake8-pie
- # "PT", # flake8-pytest-style
- # "PTH", # flake8-use-pathlib
- # "Q", # flake8-quotes
- # "RET", # flake8-return
- # "S", # flake8-bandit
- # "SIM", # flake8-simplify
- # "SLF", # flake8-self
- # "T20", # flake8-print
- # "TRY", # tryceratops
-]
-ignore = [
- "PLR1714",
- "PLW0603",
- "PLW2901",
- "RUF005",
- "RUF012",
- "UP031",
-]
-
-[tool.ruff.lint.mccabe]
-max-complexity = 101
-
-[tool.ruff.lint.pylint]
-allow-magic-value-types = ["float", "int", "str"]
-max-args = 11
-max-branches = 108
-max-returns = 10
-max-statements = 286
-
-[tool.setuptools]
-package-dir = {"" = "pylib"}
-packages = ["gyp", "gyp.generator"]
diff --git a/tools/gyp/release-please-config.json b/tools/gyp/release-please-config.json
deleted file mode 100644
index b6cad32a2dd..00000000000
--- a/tools/gyp/release-please-config.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "last-release-sha": "78756421b0d7bb335992a9c7d26ba3cc8b619708",
- "packages": {
- ".": {
- "release-type": "python",
- "package-name": "gyp-next",
- "bump-minor-pre-major": true,
- "include-component-in-tag": false
- }
- }
-}
diff --git a/tools/gyp/test/fixtures/expected-darwin/cmake/CMakeLists.txt b/tools/gyp/test/fixtures/expected-darwin/cmake/CMakeLists.txt
deleted file mode 100644
index 90b95e75eb5..00000000000
--- a/tools/gyp/test/fixtures/expected-darwin/cmake/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
-cmake_policy(VERSION 2.8.8)
-project(test)
-set(configuration "Default")
-enable_language(ASM)
-set(builddir "${CMAKE_CURRENT_BINARY_DIR}")
-set(obj "${builddir}/obj")
-
-set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
-set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
-
-
-
-#*/gyp-next/test/fixtures/integration.gyp:test#target
-set(TARGET "test")
-set(TOOLSET "target")
-set(test__cxx_srcs "../../test.cc")
-link_directories( ../../mylib
-)
-add_executable(test ${test__cxx_srcs})
-set_target_properties(test PROPERTIES EXCLUDE_FROM_ALL "FALSE")
-set_target_properties(test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${builddir}")
-set_target_properties(test PROPERTIES PREFIX "")
-set_target_properties(test PROPERTIES RUNTIME_OUTPUT_NAME "test")
-set_target_properties(test PROPERTIES SUFFIX "")
-set_source_files_properties(${builddir}/test PROPERTIES GENERATED "TRUE")
-set(test__include_dirs "${CMAKE_CURRENT_LIST_DIR}/../../include")
-set_property(TARGET test APPEND PROPERTY INCLUDE_DIRECTORIES ${test__include_dirs})
-set_target_properties(test PROPERTIES COMPILE_FLAGS "-fasm-blocks -mpascal-strings -Os -gdwarf-2 -arch x86_64 ")
-unset(TOOLSET)
-unset(TARGET)
diff --git a/tools/gyp/test/fixtures/expected-darwin/make/test.target.mk b/tools/gyp/test/fixtures/expected-darwin/make/test.target.mk
deleted file mode 100644
index c9e16b63445..00000000000
--- a/tools/gyp/test/fixtures/expected-darwin/make/test.target.mk
+++ /dev/null
@@ -1,86 +0,0 @@
-# This file is generated by gyp; do not edit.
-
-TOOLSET := target
-TARGET := test
-DEFS_Default :=
-
-# Flags passed to all source files.
-CFLAGS_Default := \
- -fasm-blocks \
- -mpascal-strings \
- -Os \
- -gdwarf-2 \
- -arch \
- x86_64
-
-# Flags passed to only C files.
-CFLAGS_C_Default :=
-
-# Flags passed to only C++ files.
-CFLAGS_CC_Default :=
-
-# Flags passed to only ObjC files.
-CFLAGS_OBJC_Default :=
-
-# Flags passed to only ObjC++ files.
-CFLAGS_OBJCC_Default :=
-
-INCS_Default := \
- -I$(srcdir)/include
-
-OBJS := \
- $(obj).target/$(TARGET)/test.o
-
-# Add to the list of files we specially track dependencies for.
-all_deps += $(OBJS)
-
-# CFLAGS et al overrides must be target-local.
-# See "Target-specific Variable Values" in the GNU Make manual.
-$(OBJS): TOOLSET := $(TOOLSET)
-$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
-$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
-$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))
-$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))
-
-# Suffix rules, putting all outputs into $(obj).
-
-$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
- @$(call do_cmd,cxx,1)
-
-# Try building from generated source, too.
-
-$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
- @$(call do_cmd,cxx,1)
-
-$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
- @$(call do_cmd,cxx,1)
-
-# End of this set of suffix rules
-### Rules for final target.
-LDFLAGS_Default := \
- -arch \
- x86_64 \
- -L$(builddir) \
- -L$(srcdir)/mylib
-
-LIBTOOLFLAGS_Default :=
-
-LIBS :=
-
-$(builddir)/test: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
-$(builddir)/test: LIBS := $(LIBS)
-$(builddir)/test: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))
-$(builddir)/test: LD_INPUTS := $(OBJS)
-$(builddir)/test: TOOLSET := $(TOOLSET)
-$(builddir)/test: $(OBJS) FORCE_DO_CMD
- $(call do_cmd,link)
-
-all_deps += $(builddir)/test
-# Add target alias
-.PHONY: test
-test: $(builddir)/test
-
-# Add executable to "all" target.
-.PHONY: all
-all: $(builddir)/test
-
diff --git a/tools/gyp/test/fixtures/expected-darwin/ninja/test.ninja b/tools/gyp/test/fixtures/expected-darwin/ninja/test.ninja
deleted file mode 100644
index fcb13208633..00000000000
--- a/tools/gyp/test/fixtures/expected-darwin/ninja/test.ninja
+++ /dev/null
@@ -1,15 +0,0 @@
-defines =
-includes = -I../../include
-cflags = -fasm-blocks -mpascal-strings -Os -gdwarf-2 -arch x86_64
-cflags_c =
-cflags_cc =
-cflags_objc = $cflags_c
-cflags_objcc = $cflags_cc
-arflags =
-
-build obj/test.test.o: cxx ../../test.cc
-
-ldflags = -arch x86_64 -L./
-libs = -L../../mylib
-build test: link obj/test.test.o
- ld = $ldxx
diff --git a/tools/gyp/test/fixtures/expected-linux/cmake/CMakeLists.txt b/tools/gyp/test/fixtures/expected-linux/cmake/CMakeLists.txt
deleted file mode 100644
index 968642201ac..00000000000
--- a/tools/gyp/test/fixtures/expected-linux/cmake/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
-cmake_policy(VERSION 2.8.8)
-project(test)
-set(configuration "Default")
-enable_language(ASM)
-set(builddir "${CMAKE_CURRENT_BINARY_DIR}")
-set(obj "${builddir}/obj")
-
-set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
-set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
-
-set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1)
-
-
-#*/test/fixtures/integration.gyp:test#target
-set(TARGET "test")
-set(TOOLSET "target")
-set(test__cxx_srcs "../../test.cc")
-link_directories( ../../mylib
-)
-add_executable(test ${test__cxx_srcs})
-set_target_properties(test PROPERTIES EXCLUDE_FROM_ALL "FALSE")
-set_target_properties(test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${builddir}")
-set_target_properties(test PROPERTIES PREFIX "")
-set_target_properties(test PROPERTIES RUNTIME_OUTPUT_NAME "test")
-set_target_properties(test PROPERTIES SUFFIX "")
-set_source_files_properties(${builddir}/test PROPERTIES GENERATED "TRUE")
-set(test__include_dirs "${CMAKE_CURRENT_LIST_DIR}/../../include")
-set_property(TARGET test APPEND PROPERTY INCLUDE_DIRECTORIES ${test__include_dirs})
-set_target_properties(test PROPERTIES COMPILE_FLAGS "")
-unset(TOOLSET)
-unset(TARGET)
diff --git a/tools/gyp/test/fixtures/expected-linux/make/test.target.mk b/tools/gyp/test/fixtures/expected-linux/make/test.target.mk
deleted file mode 100644
index bae91717b42..00000000000
--- a/tools/gyp/test/fixtures/expected-linux/make/test.target.mk
+++ /dev/null
@@ -1,66 +0,0 @@
-# This file is generated by gyp; do not edit.
-
-TOOLSET := target
-TARGET := test
-DEFS_Default :=
-
-# Flags passed to all source files.
-CFLAGS_Default :=
-
-# Flags passed to only C files.
-CFLAGS_C_Default :=
-
-# Flags passed to only C++ files.
-CFLAGS_CC_Default :=
-
-INCS_Default := \
- -I$(srcdir)/include
-
-OBJS := \
- $(obj).target/$(TARGET)/test.o
-
-# Add to the list of files we specially track dependencies for.
-all_deps += $(OBJS)
-
-# CFLAGS et al overrides must be target-local.
-# See "Target-specific Variable Values" in the GNU Make manual.
-$(OBJS): TOOLSET := $(TOOLSET)
-$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
-$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
-
-# Suffix rules, putting all outputs into $(obj).
-
-$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
- @$(call do_cmd,cxx,1)
-
-# Try building from generated source, too.
-
-$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
- @$(call do_cmd,cxx,1)
-
-$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
- @$(call do_cmd,cxx,1)
-
-# End of this set of suffix rules
-### Rules for final target.
-LDFLAGS_Default := \
- -L$(srcdir)/mylib
-
-LIBS :=
-
-$(builddir)/test: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
-$(builddir)/test: LIBS := $(LIBS)
-$(builddir)/test: LD_INPUTS := $(OBJS)
-$(builddir)/test: TOOLSET := $(TOOLSET)
-$(builddir)/test: $(OBJS) FORCE_DO_CMD
- $(call do_cmd,link)
-
-all_deps += $(builddir)/test
-# Add target alias
-.PHONY: test
-test: $(builddir)/test
-
-# Add executable to "all" target.
-.PHONY: all
-all: $(builddir)/test
-
diff --git a/tools/gyp/test/fixtures/expected-linux/ninja/test.ninja b/tools/gyp/test/fixtures/expected-linux/ninja/test.ninja
deleted file mode 100644
index 15c6c3d6978..00000000000
--- a/tools/gyp/test/fixtures/expected-linux/ninja/test.ninja
+++ /dev/null
@@ -1,13 +0,0 @@
-defines =
-includes = -I../../include
-cflags =
-cflags_c =
-cflags_cc =
-arflags =
-
-build obj/test.test.o: cxx ../../test.cc
-
-ldflags =
-libs = -L../../mylib
-build test: link obj/test.test.o
- ld = $ldxx
diff --git a/tools/gyp/test/fixtures/expected-win32/msvs/integration.sln b/tools/gyp/test/fixtures/expected-win32/msvs/integration.sln
deleted file mode 100644
index 276e0693118..00000000000
--- a/tools/gyp/test/fixtures/expected-win32/msvs/integration.sln
+++ /dev/null
@@ -1,16 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{*}") = "test", "test.vcproj", "{*}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Default|Win32 = Default|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {*}.Default|Win32.ActiveCfg = Default|Win32
- {*}.Default|Win32.Build.0 = Default|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/tools/gyp/test/fixtures/expected-win32/msvs/test.vcproj b/tools/gyp/test/fixtures/expected-win32/msvs/test.vcproj
deleted file mode 100644
index 981a106ce47..00000000000
--- a/tools/gyp/test/fixtures/expected-win32/msvs/test.vcproj
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tools/gyp/test/fixtures/include/test.h b/tools/gyp/test/fixtures/include/test.h
deleted file mode 100644
index eacbb8d7731..00000000000
--- a/tools/gyp/test/fixtures/include/test.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-
-int foo();
diff --git a/tools/gyp/test/fixtures/integration.gyp b/tools/gyp/test/fixtures/integration.gyp
deleted file mode 100644
index c4835117002..00000000000
--- a/tools/gyp/test/fixtures/integration.gyp
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- 'targets': [
- {
- 'target_name': 'test',
- 'type': 'executable',
- 'sources': [
- 'test.cc',
- ],
- 'include_dirs': [
- 'include',
- ],
- 'library_dirs': [
- 'mylib'
- ],
- },
- ]
-}
diff --git a/tools/gyp/test/fixtures/test.cc b/tools/gyp/test/fixtures/test.cc
deleted file mode 100644
index 8b1ecf89811..00000000000
--- a/tools/gyp/test/fixtures/test.cc
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "test.h"
-
-int main() {
- return foo();
-}
-
-int foo() {
- return 0;
-}
diff --git a/tools/gyp/test/integration_test.py b/tools/gyp/test/integration_test.py
deleted file mode 100644
index 26d78763078..00000000000
--- a/tools/gyp/test/integration_test.py
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/env python3
-
-"""Integration test"""
-
-import os
-import re
-import shutil
-import sys
-import unittest
-
-import gyp
-
-fixture_dir = os.path.join(os.path.dirname(__file__), "fixtures")
-gyp_file = os.path.join(os.path.dirname(__file__), "fixtures/integration.gyp")
-
-if sys.platform == "win32":
- sysname = sys.platform
-else:
- sysname = os.uname().sysname.lower()
-expected_dir = os.path.join(fixture_dir, f"expected-{sysname}")
-
-
-def assert_file(test, actual, expected) -> None:
- actual_filepath = os.path.join(fixture_dir, actual)
- expected_filepath = os.path.join(expected_dir, expected)
-
- with open(expected_filepath) as in_file:
- in_bytes = in_file.read()
- in_bytes = in_bytes.strip()
- expected_bytes = re.escape(in_bytes)
- expected_bytes = expected_bytes.replace("\\*", ".*")
- expected_re = re.compile(expected_bytes)
-
- with open(actual_filepath) as in_file:
- actual_bytes = in_file.read()
- actual_bytes = actual_bytes.strip()
-
- try:
- test.assertRegex(actual_bytes, expected_re)
- except Exception:
- shutil.copyfile(actual_filepath, f"{expected_filepath}.actual")
- raise
-
-
-class TestGypUnix(unittest.TestCase):
- supported_sysnames = {"darwin", "linux"}
-
- def setUp(self) -> None:
- if sysname not in TestGypUnix.supported_sysnames:
- self.skipTest(f"Unsupported system: {sysname}")
- shutil.rmtree(os.path.join(fixture_dir, "out"), ignore_errors=True)
-
- def test_ninja(self) -> None:
- rc = gyp.main(["-f", "ninja", "--depth", fixture_dir, gyp_file])
- assert rc == 0
-
- assert_file(self, "out/Default/obj/test.ninja", "ninja/test.ninja")
-
- def test_make(self) -> None:
- rc = gyp.main(
- [
- "-f",
- "make",
- "--depth",
- fixture_dir,
- "--generator-output",
- "out",
- gyp_file,
- ]
- )
- assert rc == 0
-
- assert_file(self, "out/test.target.mk", "make/test.target.mk")
-
- def test_cmake(self) -> None:
- rc = gyp.main(["-f", "cmake", "--depth", fixture_dir, gyp_file])
- assert rc == 0
-
- assert_file(self, "out/Default/CMakeLists.txt", "cmake/CMakeLists.txt")
-
-
-class TestGypWindows(unittest.TestCase):
- def setUp(self) -> None:
- if sys.platform != "win32":
- self.skipTest("Windows-only test")
- shutil.rmtree(os.path.join(fixture_dir, "out"), ignore_errors=True)
-
- def test_msvs(self) -> None:
- rc = gyp.main(["-f", "msvs", "--depth", fixture_dir, gyp_file])
- assert rc == 0
-
- assert_file(self, "test.vcproj", "msvs/test.vcproj")
- assert_file(self, "integration.sln", "msvs/integration.sln")
diff --git a/tools/gyp/test_gyp.py b/tools/gyp/test_gyp.py
deleted file mode 100755
index 70c81ae8ca3..00000000000
--- a/tools/gyp/test_gyp.py
+++ /dev/null
@@ -1,260 +0,0 @@
-#!/usr/bin/env python3
-# Copyright (c) 2012 Google Inc. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""gyptest.py -- test runner for GYP tests."""
-
-import argparse
-import os
-import platform
-import subprocess
-import sys
-import time
-
-
-def is_test_name(f):
- return f.startswith("gyptest") and f.endswith(".py")
-
-
-def find_all_gyptest_files(directory):
- result = []
- for root, dirs, files in os.walk(directory):
- result.extend([os.path.join(root, f) for f in files if is_test_name(f)])
- result.sort()
- return result
-
-
-def main(argv=None):
- if argv is None:
- argv = sys.argv
-
- parser = argparse.ArgumentParser()
- parser.add_argument("-a", "--all", action="store_true", help="run all tests")
- parser.add_argument("-C", "--chdir", action="store", help="change to directory")
- parser.add_argument(
- "-f",
- "--format",
- action="store",
- default="",
- help="run tests with the specified formats",
- )
- parser.add_argument(
- "-G",
- "--gyp_option",
- action="append",
- default=[],
- help="Add -G options to the gyp command line",
- )
- parser.add_argument(
- "-l", "--list", action="store_true", help="list available tests and exit"
- )
- parser.add_argument(
- "-n",
- "--no-exec",
- action="store_true",
- help="no execute, just print the command line",
- )
- parser.add_argument(
- "--path", action="append", default=[], help="additional $PATH directory"
- )
- parser.add_argument(
- "-q",
- "--quiet",
- action="store_true",
- help="quiet, don't print anything unless there are failures",
- )
- parser.add_argument(
- "-v",
- "--verbose",
- action="store_true",
- help="print configuration info and test results.",
- )
- parser.add_argument("tests", nargs="*")
- args = parser.parse_args(argv[1:])
-
- if args.chdir:
- os.chdir(args.chdir)
-
- if args.path:
- extra_path = [os.path.abspath(p) for p in args.path]
- extra_path = os.pathsep.join(extra_path)
- os.environ["PATH"] = extra_path + os.pathsep + os.environ["PATH"]
-
- if not args.tests:
- if not args.all:
- sys.stderr.write("Specify -a to get all tests.\n")
- return 1
- args.tests = ["test"]
-
- tests = []
- for arg in args.tests:
- if os.path.isdir(arg):
- tests.extend(find_all_gyptest_files(os.path.normpath(arg)))
- else:
- if not is_test_name(os.path.basename(arg)):
- print(arg, "is not a valid gyp test name.", file=sys.stderr)
- sys.exit(1)
- tests.append(arg)
-
- if args.list:
- for test in tests:
- print(test)
- sys.exit(0)
-
- os.environ["PYTHONPATH"] = os.path.abspath("test/lib")
-
- if args.verbose:
- print_configuration_info()
-
- if args.gyp_option and not args.quiet:
- print("Extra Gyp options: %s\n" % args.gyp_option)
-
- if args.format:
- format_list = args.format.split(",")
- else:
- format_list = {
- "aix5": ["make"],
- "os400": ["make"],
- "freebsd7": ["make"],
- "freebsd8": ["make"],
- "openbsd5": ["make"],
- "cygwin": ["msvs"],
- "win32": ["msvs", "ninja"],
- "linux": ["make", "ninja"],
- "linux2": ["make", "ninja"],
- "linux3": ["make", "ninja"],
- # TODO: Re-enable xcode-ninja.
- # https://bugs.chromium.org/p/gyp/issues/detail?id=530
- # 'darwin': ['make', 'ninja', 'xcode', 'xcode-ninja'],
- "darwin": ["make", "ninja", "xcode"],
- }[sys.platform]
-
- gyp_options = []
- for option in args.gyp_option:
- gyp_options += ["-G", option]
-
- runner = Runner(format_list, tests, gyp_options, args.verbose)
- runner.run()
-
- if not args.quiet:
- runner.print_results()
-
- return 1 if runner.failures else 0
-
-
-def print_configuration_info():
- print("Test configuration:")
- if sys.platform == "darwin":
- sys.path.append(os.path.abspath("test/lib"))
- import TestMac # noqa: PLC0415
-
- print(f" Mac {platform.mac_ver()[0]} {platform.mac_ver()[2]}")
- print(f" Xcode {TestMac.Xcode.Version()}")
- elif sys.platform == "win32":
- sys.path.append(os.path.abspath("pylib"))
- import gyp.MSVSVersion # noqa: PLC0415
-
- print(" Win %s %s\n" % platform.win32_ver()[0:2])
- print(" MSVS %s" % gyp.MSVSVersion.SelectVisualStudioVersion().Description())
- elif sys.platform in ("linux", "linux2"):
- print(" Linux %s" % " ".join(platform.linux_distribution()))
- print(f" Python {platform.python_version()}")
- print(f" PYTHONPATH={os.environ['PYTHONPATH']}")
- print()
-
-
-class Runner:
- def __init__(self, formats, tests, gyp_options, verbose):
- self.formats = formats
- self.tests = tests
- self.verbose = verbose
- self.gyp_options = gyp_options
- self.failures = []
- self.num_tests = len(formats) * len(tests)
- num_digits = len(str(self.num_tests))
- self.fmt_str = "[%%%dd/%%%dd] (%%s) %%s" % (num_digits, num_digits)
- self.isatty = sys.stdout.isatty() and not self.verbose
- self.env = os.environ.copy()
- self.hpos = 0
-
- def run(self):
- run_start = time.time()
-
- i = 1
- for fmt in self.formats:
- for test in self.tests:
- self.run_test(test, fmt, i)
- i += 1
-
- if self.isatty:
- self.erase_current_line()
-
- self.took = time.time() - run_start
-
- def run_test(self, test, fmt, i):
- if self.isatty:
- self.erase_current_line()
-
- msg = self.fmt_str % (i, self.num_tests, fmt, test)
- self.print_(msg)
-
- start = time.time()
- cmd = [sys.executable, test] + self.gyp_options
- self.env["TESTGYP_FORMAT"] = fmt
- proc = subprocess.Popen(
- cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=self.env
- )
- proc.wait()
- took = time.time() - start
-
- stdout = proc.stdout.read().decode("utf8")
- if proc.returncode == 2:
- res = "skipped"
- elif proc.returncode:
- res = "failed"
- self.failures.append(f"({test}) {fmt}")
- else:
- res = "passed"
- res_msg = f" {res} {took:.3f}s"
- self.print_(res_msg)
-
- if stdout and not stdout.endswith(("PASSED\n", "NO RESULT\n")):
- print()
- print("\n".join(f" {line}" for line in stdout.splitlines()))
- elif not self.isatty:
- print()
-
- def print_(self, msg):
- print(msg, end="")
- index = msg.rfind("\n")
- if index == -1:
- self.hpos += len(msg)
- else:
- self.hpos = len(msg) - index
- sys.stdout.flush()
-
- def erase_current_line(self):
- print("\b" * self.hpos + " " * self.hpos + "\b" * self.hpos, end="")
- sys.stdout.flush()
- self.hpos = 0
-
- def print_results(self):
- num_failures = len(self.failures)
- if num_failures:
- print()
- if num_failures == 1:
- print("Failed the following test:")
- else:
- print("Failed the following %d tests:" % num_failures)
- print("\t" + "\n\t".join(sorted(self.failures)))
- print()
- print(
- "Ran %d tests in %.3fs, %d failed."
- % (self.num_tests, self.took, num_failures)
- )
- print()
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/tools/gyp/tools/README b/tools/gyp/tools/README
deleted file mode 100644
index 84a73d15214..00000000000
--- a/tools/gyp/tools/README
+++ /dev/null
@@ -1,15 +0,0 @@
-pretty_vcproj:
- Usage: pretty_vcproj.py "c:\path\to\vcproj.vcproj" [key1=value1] [key2=value2]
-
- They key/value pair are used to resolve vsprops name.
-
- For example, if I want to diff the base.vcproj project:
-
- pretty_vcproj.py z:\dev\src-chrome\src\base\build\base.vcproj "$(SolutionDir)=z:\dev\src-chrome\src\chrome\\" "$(CHROMIUM_BUILD)=" "$(CHROME_BUILD_TYPE)=" > original.txt
- pretty_vcproj.py z:\dev\src-chrome\src\base\base_gyp.vcproj "$(SolutionDir)=z:\dev\src-chrome\src\chrome\\" "$(CHROMIUM_BUILD)=" "$(CHROME_BUILD_TYPE)=" > gyp.txt
-
- And you can use your favorite diff tool to see the changes.
-
- Note: In the case of base.vcproj, the original vcproj is one level up the generated one.
- I suggest you do a search and replace for '"..\' and replace it with '"' in original.txt
- before you perform the diff.
\ No newline at end of file
diff --git a/tools/gyp/tools/Xcode/README b/tools/gyp/tools/Xcode/README
deleted file mode 100644
index 2492a2c2f8f..00000000000
--- a/tools/gyp/tools/Xcode/README
+++ /dev/null
@@ -1,5 +0,0 @@
-Specifications contains syntax formatters for Xcode 3. These do not appear to be supported yet on Xcode 4. To use these with Xcode 3 please install both the gyp.pbfilespec and gyp.xclangspec files in
-
-~/Library/Application Support/Developer/Shared/Xcode/Specifications/
-
-and restart Xcode.
\ No newline at end of file
diff --git a/tools/gyp/tools/Xcode/Specifications/gyp.pbfilespec b/tools/gyp/tools/Xcode/Specifications/gyp.pbfilespec
deleted file mode 100644
index 85e2e268a51..00000000000
--- a/tools/gyp/tools/Xcode/Specifications/gyp.pbfilespec
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- gyp.pbfilespec
- GYP source file spec for Xcode 3
-
- There is not much documentation available regarding the format
- of .pbfilespec files. As a starting point, see for instance the
- outdated documentation at:
- http://maxao.free.fr/xcode-plugin-interface/specifications.html
- and the files in:
- /Developer/Library/PrivateFrameworks/XcodeEdit.framework/Versions/A/Resources/
-
- Place this file in directory:
- ~/Library/Application Support/Developer/Shared/Xcode/Specifications/
-*/
-
-(
- {
- Identifier = sourcecode.gyp;
- BasedOn = sourcecode;
- Name = "GYP Files";
- Extensions = ("gyp", "gypi");
- MIMETypes = ("text/gyp");
- Language = "xcode.lang.gyp";
- IsTextFile = YES;
- IsSourceFile = YES;
- }
-)
diff --git a/tools/gyp/tools/Xcode/Specifications/gyp.xclangspec b/tools/gyp/tools/Xcode/Specifications/gyp.xclangspec
deleted file mode 100644
index 3b3506d319e..00000000000
--- a/tools/gyp/tools/Xcode/Specifications/gyp.xclangspec
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- Copyright (c) 2011 Google Inc. All rights reserved.
- Use of this source code is governed by a BSD-style license that can be
- found in the LICENSE file.
-
- gyp.xclangspec
- GYP language specification for Xcode 3
-
- There is not much documentation available regarding the format
- of .xclangspec files. As a starting point, see for instance the
- outdated documentation at:
- http://maxao.free.fr/xcode-plugin-interface/specifications.html
- and the files in:
- /Developer/Library/PrivateFrameworks/XcodeEdit.framework/Versions/A/Resources/
-
- Place this file in directory:
- ~/Library/Application Support/Developer/Shared/Xcode/Specifications/
-*/
-
-(
-
- {
- Identifier = "xcode.lang.gyp.keyword";
- Syntax = {
- Words = (
- "and",
- "or",
- " (caar gyp-parse-history) target-point)
- (setq gyp-parse-history (cdr gyp-parse-history))))
-
-(defun gyp-parse-point ()
- "The point of the last parse state added by gyp-parse-to."
- (caar gyp-parse-history))
-
-(defun gyp-parse-sections ()
- "A list of section symbols holding at the last parse state point."
- (cdar gyp-parse-history))
-
-(defun gyp-inside-dictionary-p ()
- "Predicate returning true if the parser is inside a dictionary."
- (not (eq (cadar gyp-parse-history) 'list)))
-
-(defun gyp-add-parse-history (point sections)
- "Add parse state SECTIONS to the parse history at POINT so that parsing can be
- resumed instantly."
- (while (>= (caar gyp-parse-history) point)
- (setq gyp-parse-history (cdr gyp-parse-history)))
- (setq gyp-parse-history (cons (cons point sections) gyp-parse-history)))
-
-(defun gyp-parse-to (target-point)
- "Parses from (point) to TARGET-POINT adding the parse state information to
- gyp-parse-state-history. Parsing stops if TARGET-POINT is reached or if a
- string literal has been parsed. Returns nil if no further parsing can be
- done, otherwise returns the position of the start of a parsed string, leaving
- the point at the end of the string."
- (let ((parsing t)
- string-start)
- (while parsing
- (setq string-start nil)
- ;; Parse up to a character that starts a sexp, or if the nesting
- ;; level decreases.
- (let ((state (parse-partial-sexp (gyp-parse-point)
- target-point
- -1
- t))
- (sections (gyp-parse-sections)))
- (if (= (nth 0 state) -1)
- (setq sections (cdr sections)) ; pop out a level
- (cond ((looking-at-p "['\"]") ; a string
- (setq string-start (point))
- (goto-char (scan-sexps (point) 1))
- (if (gyp-inside-dictionary-p)
- ;; Look for sections inside a dictionary
- (let ((section (gyp-section-name
- (buffer-substring-no-properties
- (+ 1 string-start)
- (- (point) 1)))))
- (setq sections (cons section (cdr sections)))))
- ;; Stop after the string so it can be fontified.
- (setq target-point (point)))
- ((looking-at-p "{")
- ;; Inside a dictionary. Increase nesting.
- (forward-char 1)
- (setq sections (cons 'unknown sections)))
- ((looking-at-p "\\[")
- ;; Inside a list. Increase nesting
- (forward-char 1)
- (setq sections (cons 'list sections)))
- ((not (eobp))
- ;; other
- (forward-char 1))))
- (gyp-add-parse-history (point) sections)
- (setq parsing (< (point) target-point))))
- string-start))
-
-(defun gyp-section-at-point ()
- "Transform the last parse state, which is a list of nested sections and return
- the section symbol that should be used to determine font-lock information for
- the string. Can return nil indicating the string should not have any attached
- section."
- (let ((sections (gyp-parse-sections)))
- (cond
- ((eq (car sections) 'conditions)
- ;; conditions can occur in a variables section, but we still want to
- ;; highlight it as a keyword.
- nil)
- ((and (eq (car sections) 'list)
- (eq (cadr sections) 'list))
- ;; conditions and sources can have items in [[ ]]
- (caddr sections))
- (t (cadr sections)))))
-
-(defun gyp-section-match (limit)
- "Parse from (point) to LIMIT returning by means of match data what was
- matched. The group of the match indicates what style font-lock should apply.
- See also `gyp-add-font-lock-keywords'."
- (gyp-invalidate-parse-states-after (point))
- (let ((group nil)
- (string-start t))
- (while (and (< (point) limit)
- (not group)
- string-start)
- (setq string-start (gyp-parse-to limit))
- (if string-start
- (setq group (cl-case (gyp-section-at-point)
- ('dependencies 1)
- ('variables 2)
- ('conditions 2)
- ('sources 3)
- ('defines 4)
- (nil nil)))))
- (if group
- (progn
- ;; Set the match data to indicate to the font-lock mechanism the
- ;; highlighting to be performed.
- (set-match-data (append (list string-start (point))
- (make-list (* (1- group) 2) nil)
- (list (1+ string-start) (1- (point)))))
- t))))
-
-;;; Please see http://code.google.com/p/gyp/wiki/GypLanguageSpecification for
-;;; canonical list of keywords.
-(defun gyp-add-font-lock-keywords ()
- "Add gyp-mode keywords to font-lock mechanism."
- ;; TODO(jknotten): Move all the keyword highlighting into gyp-section-match
- ;; so that we can do the font-locking in a single font-lock pass.
- (font-lock-add-keywords
- nil
- (list
- ;; Top-level keywords
- (list (concat "['\"]\\("
- (regexp-opt (list "action" "action_name" "actions" "cflags"
- "cflags_cc" "conditions" "configurations"
- "copies" "defines" "dependencies" "destination"
- "direct_dependent_settings"
- "export_dependent_settings" "extension" "files"
- "include_dirs" "includes" "inputs" "ldflags" "libraries"
- "link_settings" "mac_bundle" "message"
- "msvs_external_rule" "outputs" "product_name"
- "process_outputs_as_sources" "rules" "rule_name"
- "sources" "suppress_wildcard"
- "target_conditions" "target_defaults"
- "target_defines" "target_name" "toolsets"
- "targets" "type" "variables" "xcode_settings"))
- "[!/+=]?\\)") 1 'font-lock-keyword-face t)
- ;; Type of target
- (list (concat "['\"]\\("
- (regexp-opt (list "loadable_module" "static_library"
- "shared_library" "executable" "none"))
- "\\)") 1 'font-lock-type-face t)
- (list "\\(?:target\\|action\\)_name['\"]\\s-*:\\s-*['\"]\\([^ '\"]*\\)" 1
- 'font-lock-function-name-face t)
- (list 'gyp-section-match
- (list 1 'font-lock-function-name-face t t) ; dependencies
- (list 2 'font-lock-variable-name-face t t) ; variables, conditions
- (list 3 'font-lock-constant-face t t) ; sources
- (list 4 'font-lock-preprocessor-face t t)) ; preprocessor
- ;; Variable expansion
- (list "<@?(\\([^\n )]+\\))" 1 'font-lock-variable-name-face t)
- ;; Command expansion
- (list " "{dst}"')
-
- print("}")
-
-
-def main():
- if len(sys.argv) < 2:
- print(__doc__, file=sys.stderr)
- print(file=sys.stderr)
- print("usage: %s target1 target2..." % (sys.argv[0]), file=sys.stderr)
- return 1
-
- edges = LoadEdges("dump.json", sys.argv[1:])
-
- WriteGraph(edges)
- return 0
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/tools/gyp/tools/pretty_gyp.py b/tools/gyp/tools/pretty_gyp.py
deleted file mode 100755
index 562a73ee672..00000000000
--- a/tools/gyp/tools/pretty_gyp.py
+++ /dev/null
@@ -1,154 +0,0 @@
-#!/usr/bin/env python3
-
-# Copyright (c) 2012 Google Inc. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Pretty-prints the contents of a GYP file."""
-
-import re
-import sys
-
-# Regex to remove comments when we're counting braces.
-COMMENT_RE = re.compile(r"\s*#.*")
-
-# Regex to remove quoted strings when we're counting braces.
-# It takes into account quoted quotes, and makes sure that the quotes match.
-# NOTE: It does not handle quotes that span more than one line, or
-# cases where an escaped quote is preceded by an escaped backslash.
-QUOTE_RE_STR = r'(?P[\'"])(.*?)(? 0:
- after = True
-
- # This catches the special case of a closing brace having something
- # other than just whitespace ahead of it -- we don't want to
- # unindent that until after this line is printed so it stays with
- # the previous indentation level.
- if cnt < 0 and closing_prefix_re.match(stripline):
- after = True
- return (cnt, after)
-
-
-def prettyprint_input(lines):
- """Does the main work of indenting the input based on the brace counts."""
- indent = 0
- basic_offset = 2
- for line in lines:
- if COMMENT_RE.match(line):
- print(line)
- else:
- line = line.strip("\r\n\t ") # Otherwise doesn't strip \r on Unix.
- if len(line) > 0:
- (brace_diff, after) = count_braces(line)
- if brace_diff != 0:
- if after:
- print(" " * (basic_offset * indent) + line)
- indent += brace_diff
- else:
- indent += brace_diff
- print(" " * (basic_offset * indent) + line)
- else:
- print(" " * (basic_offset * indent) + line)
- else:
- print()
-
-
-def main():
- if len(sys.argv) > 1:
- data = open(sys.argv[1]).read().splitlines()
- else:
- data = sys.stdin.read().splitlines()
- # Split up the double braces.
- lines = split_double_braces(data)
-
- # Indent and print the output.
- prettyprint_input(lines)
- return 0
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/tools/gyp/tools/pretty_sln.py b/tools/gyp/tools/pretty_sln.py
deleted file mode 100755
index 70c91aefad4..00000000000
--- a/tools/gyp/tools/pretty_sln.py
+++ /dev/null
@@ -1,180 +0,0 @@
-#!/usr/bin/env python3
-
-# Copyright (c) 2012 Google Inc. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Prints the information in a sln file in a diffable way.
-
-It first outputs each projects in alphabetical order with their
-dependencies.
-
-Then it outputs a possible build order.
-"""
-
-import os
-import re
-import sys
-
-import pretty_vcproj
-
-__author__ = "nsylvain (Nicolas Sylvain)"
-
-
-def BuildProject(project, built, projects, deps):
- # if all dependencies are done, we can build it, otherwise we try to build the
- # dependency.
- # This is not infinite-recursion proof.
- for dep in deps[project]:
- if dep not in built:
- BuildProject(dep, built, projects, deps)
- print(project)
- built.append(project)
-
-
-def ParseSolution(solution_file):
- # All projects, their clsid and paths.
- projects = {}
-
- # A list of dependencies associated with a project.
- dependencies = {}
-
- # Regular expressions that matches the SLN format.
- # The first line of a project definition.
- begin_project = re.compile(
- r'^Project\("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942'
- r'}"\) = "(.*)", "(.*)", "(.*)"$'
- )
- # The last line of a project definition.
- end_project = re.compile("^EndProject$")
- # The first line of a dependency list.
- begin_dep = re.compile(r"ProjectSection\(ProjectDependencies\) = postProject$")
- # The last line of a dependency list.
- end_dep = re.compile("EndProjectSection$")
- # A line describing a dependency.
- dep_line = re.compile(" *({.*}) = ({.*})$")
-
- in_deps = False
- solution = open(solution_file)
- for line in solution:
- results = begin_project.search(line)
- if results:
- # Hack to remove icu because the diff is too different.
- if results.group(1).find("icu") != -1:
- continue
- # We remove "_gyp" from the names because it helps to diff them.
- current_project = results.group(1).replace("_gyp", "")
- projects[current_project] = [
- results.group(2).replace("_gyp", ""),
- results.group(3),
- results.group(2),
- ]
- dependencies[current_project] = []
- continue
-
- results = end_project.search(line)
- if results:
- current_project = None
- continue
-
- results = begin_dep.search(line)
- if results:
- in_deps = True
- continue
-
- results = end_dep.search(line)
- if results:
- in_deps = False
- continue
-
- results = dep_line.search(line)
- if results and in_deps and current_project:
- dependencies[current_project].append(results.group(1))
- continue
-
- # Change all dependencies clsid to name instead.
- for project, deps in dependencies.items():
- # For each dependencies in this project
- new_dep_array = []
- for dep in deps:
- # Look for the project name matching this cldis
- for project_info in projects:
- if projects[project_info][1] == dep:
- new_dep_array.append(project_info)
- dependencies[project] = sorted(new_dep_array)
-
- return (projects, dependencies)
-
-
-def PrintDependencies(projects, deps):
- print("---------------------------------------")
- print("Dependencies for all projects")
- print("---------------------------------------")
- print("-- --")
-
- for project, dep_list in sorted(deps.items()):
- print("Project : %s" % project)
- print("Path : %s" % projects[project][0])
- if dep_list:
- for dep in dep_list:
- print(" - %s" % dep)
- print()
-
- print("-- --")
-
-
-def PrintBuildOrder(projects, deps):
- print("---------------------------------------")
- print("Build order ")
- print("---------------------------------------")
- print("-- --")
-
- built = []
- for project, _ in sorted(deps.items()):
- if project not in built:
- BuildProject(project, built, projects, deps)
-
- print("-- --")
-
-
-def PrintVCProj(projects):
- for project in projects:
- print("-------------------------------------")
- print("-------------------------------------")
- print(project)
- print(project)
- print(project)
- print("-------------------------------------")
- print("-------------------------------------")
-
- project_path = os.path.abspath(
- os.path.join(os.path.dirname(sys.argv[1]), projects[project][2])
- )
-
- pretty = pretty_vcproj
- argv = [
- "",
- project_path,
- "$(SolutionDir)=%s\\" % os.path.dirname(sys.argv[1]),
- ]
- argv.extend(sys.argv[3:])
- pretty.main(argv)
-
-
-def main():
- # check if we have exactly 1 parameter.
- if len(sys.argv) < 2:
- print('Usage: %s "c:\\path\\to\\project.sln"' % sys.argv[0])
- return 1
-
- (projects, deps) = ParseSolution(sys.argv[1])
- PrintDependencies(projects, deps)
- PrintBuildOrder(projects, deps)
-
- if "--recursive" in sys.argv:
- PrintVCProj(projects)
- return 0
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/tools/gyp/tools/pretty_vcproj.py b/tools/gyp/tools/pretty_vcproj.py
deleted file mode 100755
index 82d47a0bdd4..00000000000
--- a/tools/gyp/tools/pretty_vcproj.py
+++ /dev/null
@@ -1,336 +0,0 @@
-#!/usr/bin/env python3
-
-# Copyright (c) 2012 Google Inc. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Make the format of a vcproj really pretty.
-
-This script normalize and sort an xml. It also fetches all the properties
-inside linked vsprops and include them explicitly in the vcproj.
-
-It outputs the resulting xml to stdout.
-"""
-
-import os
-import sys
-from xml.dom.minidom import Node, parse
-
-__author__ = "nsylvain (Nicolas Sylvain)"
-ARGUMENTS = None
-REPLACEMENTS = {}
-
-
-def cmp(x, y):
- return (x > y) - (x < y)
-
-
-class CmpTuple:
- """Compare function between 2 tuple."""
-
- def __call__(self, x, y):
- return cmp(x[0], y[0])
-
-
-class CmpNode:
- """Compare function between 2 xml nodes."""
-
- def __call__(self, x, y):
- def get_string(node):
- node_string = "node"
- node_string += node.nodeName
- if node.nodeValue:
- node_string += node.nodeValue
-
- if node.attributes:
- # We first sort by name, if present.
- node_string += node.getAttribute("Name")
-
- all_nodes = []
- for name, value in node.attributes.items():
- all_nodes.append((name, value))
-
- all_nodes.sort(CmpTuple())
- for name, value in all_nodes:
- node_string += name
- node_string += value
-
- return node_string
-
- return cmp(get_string(x), get_string(y))
-
-
-def PrettyPrintNode(node, indent=0):
- if node.nodeType == Node.TEXT_NODE:
- if node.data.strip():
- print("{}{}".format(" " * indent, node.data.strip()))
- return
-
- if node.childNodes:
- node.normalize()
- # Get the number of attributes
- attr_count = 0
- if node.attributes:
- attr_count = node.attributes.length
-
- # Print the main tag
- if attr_count == 0:
- print("{}<{}>".format(" " * indent, node.nodeName))
- else:
- print("{}<{}".format(" " * indent, node.nodeName))
-
- all_attributes = []
- for name, value in node.attributes.items():
- all_attributes.append((name, value))
- all_attributes.sort(CmpTuple())
- for name, value in all_attributes:
- print('{} {}="{}"'.format(" " * indent, name, value))
- print("%s>" % (" " * indent))
- if node.nodeValue:
- print("{} {}".format(" " * indent, node.nodeValue))
-
- for sub_node in node.childNodes:
- PrettyPrintNode(sub_node, indent=indent + 2)
- print("{}{}>".format(" " * indent, node.nodeName))
-
-
-def FlattenFilter(node):
- """Returns a list of all the node and sub nodes."""
- node_list = []
-
- if node.attributes and node.getAttribute("Name") == "_excluded_files":
- # We don't add the "_excluded_files" filter.
- return []
-
- for current in node.childNodes:
- if current.nodeName == "Filter":
- node_list.extend(FlattenFilter(current))
- else:
- node_list.append(current)
-
- return node_list
-
-
-def FixFilenames(filenames, current_directory):
- new_list = []
- for filename in filenames:
- if filename:
- for key, value in REPLACEMENTS.items():
- filename = filename.replace(key, value)
- os.chdir(current_directory)
- filename = filename.strip("\"' ")
- if filename.startswith("$"):
- new_list.append(filename)
- else:
- new_list.append(os.path.abspath(filename))
- return new_list
-
-
-def AbsoluteNode(node):
- """Makes all the properties we know about in this node absolute."""
- if node.attributes:
- for name, value in node.attributes.items():
- if name in [
- "InheritedPropertySheets",
- "RelativePath",
- "AdditionalIncludeDirectories",
- "IntermediateDirectory",
- "OutputDirectory",
- "AdditionalLibraryDirectories",
- ]:
- # We want to fix up these paths
- path_list = value.split(";")
- new_list = FixFilenames(path_list, os.path.dirname(ARGUMENTS[1]))
- node.setAttribute(name, ";".join(new_list))
- if not value:
- node.removeAttribute(name)
-
-
-def CleanupVcproj(node):
- """For each sub node, we call recursively this function."""
- for sub_node in node.childNodes:
- AbsoluteNode(sub_node)
- CleanupVcproj(sub_node)
-
- # Normalize the node, and remove all extraneous whitespaces.
- for sub_node in node.childNodes:
- if sub_node.nodeType == Node.TEXT_NODE:
- sub_node.data = sub_node.data.replace("\r", "")
- sub_node.data = sub_node.data.replace("\n", "")
- sub_node.data = sub_node.data.rstrip()
-
- # Fix all the semicolon separated attributes to be sorted, and we also
- # remove the dups.
- if node.attributes:
- for name, value in node.attributes.items():
- sorted_list = sorted(value.split(";"))
- unique_list = []
- for i in sorted_list:
- if not unique_list.count(i):
- unique_list.append(i)
- node.setAttribute(name, ";".join(unique_list))
- if not value:
- node.removeAttribute(name)
-
- if node.childNodes:
- node.normalize()
-
- # For each node, take a copy, and remove it from the list.
- node_array = []
- while node.childNodes and node.childNodes[0]:
- # Take a copy of the node and remove it from the list.
- current = node.childNodes[0]
- node.removeChild(current)
-
- # If the child is a filter, we want to append all its children
- # to this same list.
- if current.nodeName == "Filter":
- node_array.extend(FlattenFilter(current))
- else:
- node_array.append(current)
-
- # Sort the list.
- node_array.sort(CmpNode())
-
- # Insert the nodes in the correct order.
- for new_node in node_array:
- # But don't append empty tool node.
- if new_node.nodeName == "Tool":
- if new_node.attributes and new_node.attributes.length == 1:
- # This one was empty.
- continue
- if new_node.nodeName == "UserMacro":
- continue
- node.appendChild(new_node)
-
-
-def GetConfigurationNodes(vcproj):
- # TODO(nsylvain): Find a better way to navigate the xml.
- nodes = []
- for node in vcproj.childNodes:
- if node.nodeName == "Configurations":
- for sub_node in node.childNodes:
- if sub_node.nodeName == "Configuration":
- nodes.append(sub_node)
-
- return nodes
-
-
-def GetChildrenVsprops(filename):
- dom = parse(filename)
- if dom.documentElement.attributes:
- vsprops = dom.documentElement.getAttribute("InheritedPropertySheets")
- return FixFilenames(vsprops.split(";"), os.path.dirname(filename))
- return []
-
-
-def SeekToNode(node1, child2):
- # A text node does not have properties.
- if child2.nodeType == Node.TEXT_NODE:
- return None
-
- # Get the name of the current node.
- current_name = child2.getAttribute("Name")
- if not current_name:
- # There is no name. We don't know how to merge.
- return None
-
- # Look through all the nodes to find a match.
- for sub_node in node1.childNodes:
- if sub_node.nodeName == child2.nodeName:
- name = sub_node.getAttribute("Name")
- if name == current_name:
- return sub_node
-
- # No match. We give up.
- return None
-
-
-def MergeAttributes(node1, node2):
- # No attributes to merge?
- if not node2.attributes:
- return
-
- for name, value2 in node2.attributes.items():
- # Don't merge the 'Name' attribute.
- if name == "Name":
- continue
- value1 = node1.getAttribute(name)
- if value1:
- # The attribute exist in the main node. If it's equal, we leave it
- # untouched, otherwise we concatenate it.
- if value1 != value2:
- node1.setAttribute(name, ";".join([value1, value2]))
- else:
- # The attribute does not exist in the main node. We append this one.
- node1.setAttribute(name, value2)
-
- # If the attribute was a property sheet attributes, we remove it, since
- # they are useless.
- if name == "InheritedPropertySheets":
- node1.removeAttribute(name)
-
-
-def MergeProperties(node1, node2):
- MergeAttributes(node1, node2)
- for child2 in node2.childNodes:
- child1 = SeekToNode(node1, child2)
- if child1:
- MergeProperties(child1, child2)
- else:
- node1.appendChild(child2.cloneNode(True))
-
-
-def main(argv):
- """Main function of this vcproj prettifier."""
- global ARGUMENTS
- ARGUMENTS = argv
-
- # check if we have exactly 1 parameter.
- if len(argv) < 2:
- print(
- 'Usage: %s "c:\\path\\to\\vcproj.vcproj" [key1=value1] '
- "[key2=value2]" % argv[0]
- )
- return 1
-
- # Parse the keys
- for i in range(2, len(argv)):
- (key, value) = argv[i].split("=")
- REPLACEMENTS[key] = value
-
- # Open the vcproj and parse the xml.
- dom = parse(argv[1])
-
- # First thing we need to do is find the Configuration Node and merge them
- # with the vsprops they include.
- for configuration_node in GetConfigurationNodes(dom.documentElement):
- # Get the property sheets associated with this configuration.
- vsprops = configuration_node.getAttribute("InheritedPropertySheets")
-
- # Fix the filenames to be absolute.
- vsprops_list = FixFilenames(
- vsprops.strip().split(";"), os.path.dirname(argv[1])
- )
-
- # Extend the list of vsprops with all vsprops contained in the current
- # vsprops.
- for current_vsprops in vsprops_list:
- vsprops_list.extend(GetChildrenVsprops(current_vsprops))
-
- # Now that we have all the vsprops, we need to merge them.
- for current_vsprops in vsprops_list:
- MergeProperties(configuration_node, parse(current_vsprops).documentElement)
-
- # Now that everything is merged, we need to cleanup the xml.
- CleanupVcproj(dom.documentElement)
-
- # Finally, we use the prett xml function to print the vcproj back to the
- # user.
- # print dom.toprettyxml(newl="\n")
- PrettyPrintNode(dom.documentElement)
- return 0
-
-
-if __name__ == "__main__":
- sys.exit(main(sys.argv))
diff --git a/tools/gyp_node.py b/tools/gyp_node.py
deleted file mode 100755
index 2bcc912a4da..00000000000
--- a/tools/gyp_node.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env python
-from __future__ import print_function
-import os
-import sys
-
-script_dir = os.path.dirname(__file__)
-node_root = os.path.normpath(os.path.join(script_dir, os.pardir))
-
-sys.path.insert(0, os.path.join(node_root, 'tools', 'gyp', 'pylib'))
-import gyp
-
-# Add search path for `pymod_do_main` first to avoid depending on
-# load order of gyp files.
-sys.path.insert(0, os.path.join(node_root, 'tools', 'v8_gypfiles'))
-
-# Directory within which we want all generated files (including Makefiles)
-# to be written.
-output_dir = os.path.join(os.path.abspath(node_root), 'out')
-
-def run_gyp(args):
- # GYP bug.
- # On msvs it will crash if it gets an absolute path.
- # On Mac/make it will crash if it doesn't get an absolute path.
- a_path = node_root if sys.platform == 'win32' else os.path.abspath(node_root)
- args.append(os.path.join(a_path, 'node.gyp'))
- common_fn = os.path.join(a_path, 'common.gypi')
- options_fn = os.path.join(a_path, 'config.gypi')
-
- if os.path.exists(common_fn):
- args.extend(['-I', common_fn])
-
- if os.path.exists(options_fn):
- args.extend(['-I', options_fn])
-
- args.append('--depth=' + node_root)
-
- # There's a bug with windows which doesn't allow this feature.
- if sys.platform != 'win32' and 'ninja' not in args:
- # Tell gyp to write the Makefiles into output_dir
- args.extend(['--generator-output', output_dir])
-
- # Tell make to write its output into the same dir
- args.extend(['-Goutput_dir=' + output_dir])
-
- args.append('-Dcomponent=static_library')
- args.append('-Dlibrary=static_library')
-
- rc = gyp.main(args)
- if rc != 0:
- print('Error running GYP')
- sys.exit(rc)
-
-
-if __name__ == '__main__':
- run_gyp(sys.argv[1:])
diff --git a/tools/gypi_to_gn.py b/tools/gypi_to_gn.py
deleted file mode 100755
index 327cd38d7ba..00000000000
--- a/tools/gypi_to_gn.py
+++ /dev/null
@@ -1,334 +0,0 @@
-#!/usr/bin/env python3
-# Copyright 2014 The Chromium Authors. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Google LLC nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# Deleted from Chromium in https://crrev.com/097f64c631.
-
-"""Converts a given gypi file to a python scope and writes the result to stdout.
-USING THIS SCRIPT IN CHROMIUM
-Forking Python to run this script in the middle of GN is slow, especially on
-Windows, and it makes both the GYP and GN files harder to follow. You can't
-use "git grep" to find files in the GN build any more, and tracking everything
-in GYP down requires a level of indirection. Any calls will have to be removed
-and cleaned up once the GYP-to-GN transition is complete.
-As a result, we only use this script when the list of files is large and
-frequently-changing. In these cases, having one canonical list outweighs the
-downsides.
-As of this writing, the GN build is basically complete. It's likely that all
-large and frequently changing targets where this is appropriate use this
-mechanism already. And since we hope to turn down the GYP build soon, the time
-horizon is also relatively short. As a result, it is likely that no additional
-uses of this script should every be added to the build. During this later part
-of the transition period, we should be focusing more and more on the absolute
-readability of the GN build.
-HOW TO USE
-It is assumed that the file contains a toplevel dictionary, and this script
-will return that dictionary as a GN "scope" (see example below). This script
-does not know anything about GYP and it will not expand variables or execute
-conditions.
-It will strip conditions blocks.
-A variables block at the top level will be flattened so that the variables
-appear in the root dictionary. This way they can be returned to the GN code.
-Say your_file.gypi looked like this:
- {
- 'sources': [ 'a.cc', 'b.cc' ],
- 'defines': [ 'ENABLE_DOOM_MELON' ],
- }
-You would call it like this:
- gypi_values = exec_script("//build/gypi_to_gn.py",
- [ rebase_path("your_file.gypi") ],
- "scope",
- [ "your_file.gypi" ])
-Notes:
- - The rebase_path call converts the gypi file from being relative to the
- current build file to being system absolute for calling the script, which
- will have a different current directory than this file.
- - The "scope" parameter tells GN to interpret the result as a series of GN
- variable assignments.
- - The last file argument to exec_script tells GN that the given file is a
- dependency of the build so Ninja can automatically re-run GN if the file
- changes.
-Read the values into a target like this:
- component("mycomponent") {
- sources = gypi_values.sources
- defines = gypi_values.defines
- }
-Sometimes your .gypi file will include paths relative to a different
-directory than the current .gn file. In this case, you can rebase them to
-be relative to the current directory.
- sources = rebase_path(gypi_values.sources, ".",
- "//path/gypi/input/values/are/relative/to")
-This script will tolerate a 'variables' in the toplevel dictionary or not. If
-the toplevel dictionary just contains one item called 'variables', it will be
-collapsed away and the result will be the contents of that dictinoary. Some
-.gypi files are written with or without this, depending on how they expect to
-be embedded into a .gyp file.
-This script also has the ability to replace certain substrings in the input.
-Generally this is used to emulate GYP variable expansion. If you passed the
-argument "--replace=<(foo)=bar" then all instances of "<(foo)" in strings in
-the input will be replaced with "bar":
- gypi_values = exec_script("//build/gypi_to_gn.py",
- [ rebase_path("your_file.gypi"),
- "--replace=<(foo)=bar"],
- "scope",
- [ "your_file.gypi" ])
-"""
-
-from __future__ import absolute_import
-from __future__ import print_function
-from optparse import OptionParser
-import sys
-
-
-# This function is copied from build/gn_helpers.py in Chromium.
-def ToGNString(value, pretty=False):
- """Returns a stringified GN equivalent of a Python value.
-
- Args:
- value: The Python value to convert.
- pretty: Whether to pretty print. If true, then non-empty lists are rendered
- recursively with one item per line, with indents. Otherwise lists are
- rendered without new line.
- Returns:
- The stringified GN equivalent to |value|.
-
- Raises:
- ValueError: |value| cannot be printed to GN.
- """
-
- # Emits all output tokens without intervening whitespaces.
- def GenerateTokens(v, level):
- if isinstance(v, str):
- yield '"' + ''.join(TranslateToGnChars(v)) + '"'
-
- elif isinstance(v, bool):
- yield 'true' if v else 'false'
-
- elif isinstance(v, int):
- yield str(v)
-
- elif isinstance(v, list):
- yield '['
- for i, item in enumerate(v):
- if i > 0:
- yield ','
- for tok in GenerateTokens(item, level + 1):
- yield tok
- yield ']'
-
- elif isinstance(v, dict):
- if level > 0:
- yield '{'
- for key in sorted(v):
- if not isinstance(key, str):
- raise ValueError('Dictionary key is not a string.')
- if not key or key[0].isdigit() or not key.replace('_', '').isalnum():
- raise ValueError('Dictionary key is not a valid GN identifier.')
- yield key # No quotations.
- yield '='
- for tok in GenerateTokens(v[key], level + 1):
- yield tok
- if level > 0:
- yield '}'
-
- else: # Not supporting float: Add only when needed.
- raise ValueError('Unsupported type when printing to GN.')
-
- can_start = lambda tok: tok and tok not in ',}]='
- can_end = lambda tok: tok and tok not in ',{[='
-
- # Adds whitespaces, trying to keep everything (except dicts) in 1 line.
- def PlainGlue(gen):
- prev_tok = None
- for i, tok in enumerate(gen):
- if i > 0:
- if can_end(prev_tok) and can_start(tok):
- yield '\n' # New dict item.
- elif prev_tok == '[' and tok == ']':
- yield ' ' # Special case for [].
- elif tok != ',':
- yield ' '
- yield tok
- prev_tok = tok
-
- # Adds whitespaces so non-empty lists can span multiple lines, with indent.
- def PrettyGlue(gen):
- prev_tok = None
- level = 0
- for i, tok in enumerate(gen):
- if i > 0:
- if can_end(prev_tok) and can_start(tok):
- yield '\n' + ' ' * level # New dict item.
- elif tok == '=' or prev_tok in '=':
- yield ' ' # Separator before and after '=', on same line.
- if tok in ']}':
- level -= 1
- # Exclude '[]' and '{}' cases.
- if int(prev_tok == '[') + int(tok == ']') == 1 or \
- int(prev_tok == '{') + int(tok == '}') == 1:
- yield '\n' + ' ' * level
- yield tok
- if tok in '[{':
- level += 1
- if tok == ',':
- yield '\n' + ' ' * level
- prev_tok = tok
-
- token_gen = GenerateTokens(value, 0)
- ret = ''.join((PrettyGlue if pretty else PlainGlue)(token_gen))
- # Add terminating '\n' for dict |value| or multi-line output.
- if isinstance(value, dict) or '\n' in ret:
- return ret + '\n'
- return ret
-
-
-def TranslateToGnChars(s):
- for code in s.encode('utf-8'):
- if code in (34, 36, 92): # For '"', '$', or '\\'.
- yield '\\' + chr(code)
- elif 32 <= code < 127:
- yield chr(code)
- else:
- yield '$0x%02X' % code
-
-
-def LoadPythonDictionary(path):
- file_string = open(path).read()
- try:
- file_data = eval(file_string, {'__builtins__': None}, None)
- except SyntaxError as e:
- e.filename = path
- raise
- except Exception as e:
- raise Exception("Unexpected error while reading %s: %s" % (path, str(e)))
-
- assert isinstance(file_data, dict), "%s does not eval to a dictionary" % path
-
- # Flatten any variables to the top level.
- if 'variables' in file_data:
- file_data.update(file_data['variables'])
- del file_data['variables']
-
- # Strip all elements that this script can't process.
- elements_to_strip = [
- 'conditions',
- 'direct_dependent_settings',
- 'target_conditions',
- 'target_defaults',
- 'targets',
- 'includes',
- 'actions',
- ]
- for element in elements_to_strip:
- if element in file_data:
- del file_data[element]
-
- return file_data
-
-
-def ReplaceSubstrings(values, search_for, replace_with):
- """Recursively replaces substrings in a value.
- Replaces all substrings of the "search_for" with "replace_with" for all
- strings occurring in "values". This is done by recursively iterating into
- lists as well as the keys and values of dictionaries."""
- if isinstance(values, str):
- return values.replace(search_for, replace_with)
-
- if isinstance(values, list):
- result = []
- for v in values:
- # Remove the item from list for complete match.
- if v == search_for and replace_with == '':
- continue
- result.append(ReplaceSubstrings(v, search_for, replace_with))
- return result
-
- if isinstance(values, dict):
- # For dictionaries, do the search for both the key and values.
- result = {}
- for key, value in values.items():
- new_key = ReplaceSubstrings(key, search_for, replace_with)
- new_value = ReplaceSubstrings(value, search_for, replace_with)
- result[new_key] = new_value
- return result
-
- # Assume everything else is unchanged.
- return values
-
-
-def DeduplicateLists(values):
- """Recursively remove duplicate values in lists."""
- if isinstance(values, list):
- return sorted(list(set(values)))
-
- if isinstance(values, dict):
- for key in values:
- values[key] = DeduplicateLists(values[key])
- return values
-
-
-def main():
- parser = OptionParser()
- parser.add_option("-r", "--replace", action="append",
- help="Replaces substrings. If passed a=b, replaces all substrs a with b.")
- (options, args) = parser.parse_args()
-
- if len(args) != 1:
- raise Exception("Need one argument which is the .gypi file to read.")
-
- data = LoadPythonDictionary(args[0])
- if options.replace:
- # Do replacements for all specified patterns.
- for replace in options.replace:
- split = replace.split('=')
- # Allow "foo=" to replace with nothing.
- if len(split) == 1:
- split.append('')
- assert len(split) == 2, "Replacement must be of the form 'key=value'."
- data = ReplaceSubstrings(data, split[0], split[1])
-
- gn_dict = {}
- for key in data:
- gn_key = key.replace('-', '_')
- # Sometimes .gypi files use the GYP syntax with percents at the end of the
- # variable name (to indicate not to overwrite a previously-defined value):
- # 'foo%': 'bar',
- # Convert these to regular variables.
- if len(key) > 1 and key[len(key) - 1] == '%':
- gn_dict[gn_key[:-1]] = data[key]
- else:
- gn_dict[gn_key] = data[key]
-
- print(ToGNString(DeduplicateLists(gn_dict)))
-
-if __name__ == '__main__':
- try:
- main()
- except Exception as e:
- print(str(e))
- sys.exit(1)
diff --git a/tools/icu/README.md b/tools/icu/README.md
deleted file mode 100644
index 711f459696b..00000000000
--- a/tools/icu/README.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# Notes about the `tools/icu` subdirectory
-
-This directory contains tools and information about the
-[International Components for Unicode][ICU] (ICU) integration.
-Both V8 and Node.js use ICU to provide internationalization functionality.
-
-* `patches/` are one-off patches, actually entire source file replacements,
- organized by ICU version number.
-* `icu_small.json` controls the "small" (English only) ICU. It is input to
- `icutrim.py`
-* `icu-generic.gyp` is the build file used for most ICU builds within ICU.
-
-* `icu-system.gyp` is an alternate build file used when `--with-intl=system-icu`
- is invoked. It builds against the `pkg-config` located ICU.
-* `iculslocs.cc` is source for the `iculslocs` utility, invoked by `icutrim.py`
- as part of repackaging. Not used separately. See source for more details.
-* `no-op.cc` contains an empty function to convince gyp to use a C++ compiler.
-* `shrink-icu-src.py` is used during upgrade (see guide below).
-
-Note:
-
-> The files in this directory were written for the Node.js 0.12 effort.
-> The original intent was to merge the tools such as `icutrim.py` and `iculslocs.cc`
-> back into ICU. ICU has gained its own “data slicer” tool.
-> There is an issue open,
-> for replacing `icutrim.py` with the [ICU data slicer][].
-
-## See Also
-
-* [docs/guides/maintaining-icu.md](../../doc/contributing/maintaining/maintaining-icu.md)
- for information on maintaining ICU in Node.js
-
-* [docs/api/intl.md](../../doc/api/intl.md) for information on the
- internationalization-related APIs in Node.js
-
-* [The ICU Homepage][ICU]
-
-[ICU]: http://icu-project.org
-[ICU data slicer]: https://github.com/unicode-org/icu/blob/HEAD/docs/userguide/icu_data/buildtool.md
diff --git a/tools/icu/current_ver.dep b/tools/icu/current_ver.dep
deleted file mode 100644
index 3d923fec865..00000000000
--- a/tools/icu/current_ver.dep
+++ /dev/null
@@ -1,6 +0,0 @@
-[
- {
- "url": "https://github.com/unicode-org/icu/releases/download/release-78.3/icu4c-78.3-sources.tgz",
- "md5": "a7b736b570ef0e180c96a31715a00c78"
- }
-]
diff --git a/tools/icu/icu-generic.gyp b/tools/icu/icu-generic.gyp
deleted file mode 100644
index c4e8c6fbb9f..00000000000
--- a/tools/icu/icu-generic.gyp
+++ /dev/null
@@ -1,555 +0,0 @@
-# Copyright (c) IBM Corporation and Others. All Rights Reserved.
-# very loosely based on icu.gyp from Chromium:
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-
-{
- 'variables': {
- 'icu_src_derb': [
- '<(icu_path)/source/tools/genrb/derb.c',
- '<(icu_path)/source/tools/genrb/derb.cpp'
- ],
- },
- 'includes': [ '../../icu_config.gypi' ],
- 'targets': [
- {
- # a target for additional uconfig defines, target only
- 'target_name': 'icu_uconfig_target',
- 'type': 'none',
- 'toolsets': [ 'target' ],
- 'direct_dependent_settings': {
- 'defines': []
- },
- },
- {
- # a target to hold uconfig defines.
- # for now these are hard coded, but could be defined.
- 'target_name': 'icu_uconfig',
- 'type': 'none',
- 'toolsets': [ 'host', 'target' ],
- 'direct_dependent_settings': {
- 'defines': [
- 'UCONFIG_NO_SERVICE=1',
- 'U_ENABLE_DYLOAD=0',
- 'U_STATIC_IMPLEMENTATION=1',
- 'U_HAVE_STD_STRING=1',
- # TODO(srl295): reenable following pending
- # https://code.google.com/p/v8/issues/detail?id=3345
- # (saves some space)
- 'UCONFIG_NO_BREAK_ITERATION=0',
- ],
- }
- },
- {
- # a target to hold common settings.
- # make any target that is ICU implementation depend on this.
- 'target_name': 'icu_implementation',
- 'toolsets': [ 'host', 'target' ],
- 'type': 'none',
- 'direct_dependent_settings': {
- 'conditions': [
- [ 'os_posix == 1 and OS != "mac" and OS != "ios"', {
- 'cflags': [ '-Wno-deprecated-declarations', '-Wno-strict-aliasing' ],
- 'cflags_cc': [ '-frtti' ],
- 'cflags_cc!': [ '-fno-rtti' ],
- }],
- [ 'OS == "mac" or OS == "ios"', {
- 'xcode_settings': {'GCC_ENABLE_CPP_RTTI': 'YES' },
- }],
- [ 'OS == "win"', {
- 'msvs_settings': {
- 'VCCLCompilerTool': {'RuntimeTypeInfo': 'true'},
- }
- }],
- ],
- 'msvs_settings': {
- 'VCCLCompilerTool': {
- 'RuntimeTypeInfo': 'true',
- 'ExceptionHandling': '1',
- 'AdditionalOptions': [ '/source-charset:utf-8' ],
- },
- },
- 'configurations': {
- # TODO: why does this need to be redefined for Release and Debug?
- # Maybe this should be pushed into common.gypi with an "if v8 i18n"?
- 'Release': {
- 'msvs_settings': {
- 'VCCLCompilerTool': {
- 'RuntimeTypeInfo': 'true',
- 'ExceptionHandling': '1',
- },
- },
- },
- 'Debug': {
- 'msvs_settings': {
- 'VCCLCompilerTool': {
- 'RuntimeTypeInfo': 'true',
- 'ExceptionHandling': '1',
- },
- },
- },
- },
- 'defines': [
- 'U_ATTRIBUTE_DEPRECATED=',
- 'U_STATIC_IMPLEMENTATION=1',
- ],
- },
- },
- {
- 'target_name': 'icui18n',
- 'toolsets': [ 'target', 'host' ],
- 'conditions' : [
- ['_toolset=="target"', {
- 'type': '<(library)',
- 'sources': [
- '<@(icu_src_i18n)'
- ],
- 'include_dirs': [
- '<(icu_path)/source/i18n',
- ],
- 'defines': [
- 'U_I18N_IMPLEMENTATION=1',
- ],
- 'dependencies': [ 'icuucx', 'icu_implementation', 'icu_uconfig', 'icu_uconfig_target' ],
- 'direct_dependent_settings': {
- 'include_dirs': [
- '<(icu_path)/source/i18n',
- ],
- },
- 'export_dependent_settings': [ 'icuucx', 'icu_uconfig_target' ],
- }],
- ['_toolset=="host"', {
- 'type': 'none',
- 'dependencies': [ 'icutools#host' ],
- 'export_dependent_settings': [ 'icutools' ],
- }],
- ],
- },
- # This exports actual ICU data
- {
- 'target_name': 'icudata',
- 'type': '<(library)',
- 'toolsets': [ 'target' ],
- 'conditions': [
- [ 'OS == "win"', {
- 'conditions': [
- [ 'icu_small == "false"', { # and OS=win
- # full data - just build the full data file, then we are done.
- 'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.<(icu_asm_ext)' ],
- 'dependencies': [ 'genccode#host' ],
- 'conditions': [
- [ 'clang==1', {
- 'actions': [
- {
- 'action_name': 'icudata',
- 'msvs_quote_cmd': 0,
- 'inputs': [ '<(icu_data_in)' ],
- 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.<(icu_asm_ext)' ],
- # on Windows, we can go directly to .obj file (-o) option.
- # for Clang use "-c <(target_arch)" option
- 'action': [ '<(PRODUCT_DIR)/genccode<(EXECUTABLE_SUFFIX)',
- '<@(icu_asm_opts)', # -o
- '-c', '<(target_arch)',
- '-d', '<(SHARED_INTERMEDIATE_DIR)',
- '-n', 'icudata',
- '-e', 'icudt<(icu_ver_major)',
- '<@(_inputs)' ],
- },
- ],
- }, {
- 'actions': [
- {
- 'action_name': 'icudata',
- 'msvs_quote_cmd': 0,
- 'inputs': [ '<(icu_data_in)' ],
- 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.<(icu_asm_ext)' ],
- # on Windows, we can go directly to .obj file (-o) option.
- # for MSVC do not use "-c <(target_arch)" option
- 'action': [ '<(PRODUCT_DIR)/genccode<(EXECUTABLE_SUFFIX)',
- '<@(icu_asm_opts)', # -o
- '-d', '<(SHARED_INTERMEDIATE_DIR)',
- '-n', 'icudata',
- '-e', 'icudt<(icu_ver_major)',
- '<@(_inputs)' ],
- },
- ],
- }]
- ],
- }, { # icu_small == TRUE and OS == win
- # link against stub data primarily
- # then, use icupkg and genccode to rebuild data
- 'dependencies': [ 'icustubdata', 'genccode#host', 'icupkg#host', 'genrb#host', 'iculslocs#host' ],
- 'export_dependent_settings': [ 'icustubdata' ],
- 'actions': [
- {
- # trim down ICU
- 'action_name': 'icutrim',
- 'msvs_quote_cmd': 0,
- 'inputs': [ '<(icu_data_in)', 'icu_small.json' ],
- 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ],
- 'action': [ '<(python)',
- 'icutrim.py',
- '-P', '<(PRODUCT_DIR)/.', # '.' suffix is a workaround against GYP assumptions :(
- '-D', '<(icu_data_in)',
- '--delete-tmp',
- '-T', '<(SHARED_INTERMEDIATE_DIR)/icutmp',
- '-F', 'icu_small.json',
- '-O', 'icudt<(icu_ver_major)<(icu_endianness).dat',
- '-v',
- '-L', '<(icu_locales)'],
- },
- {
- # build final .dat -> .obj
- 'action_name': 'genccode',
- 'msvs_quote_cmd': 0,
- 'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ],
- 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.<(icu_asm_ext)' ],
- 'action': [ '<(PRODUCT_DIR)/genccode<(EXECUTABLE_SUFFIX)',
- '<@(icu_asm_opts)', # -o
- '-c', '<(target_arch)',
- '-d', '<(SHARED_INTERMEDIATE_DIR)/',
- '-n', 'icudata',
- '-e', 'icusmdt<(icu_ver_major)',
- '<@(_inputs)' ],
- },
- ],
- # This file contains the small ICU data.
- 'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.<(icu_asm_ext)' ],
- } ] ], #end of OS==win and icu_small == true
- }, { # OS != win
- 'conditions': [
- [ 'icu_small == "false"', {
- # full data - no trim needed
- 'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
- 'dependencies': [ 'genccode#host', 'icupkg#host', 'icu_implementation#host', 'icu_uconfig' ],
- 'include_dirs': [
- '<(icu_path)/source/common',
- ],
- 'actions': [
- {
- # Copy the .dat file, swapping endianness if needed.
- 'action_name': 'icupkg',
- 'inputs': [ '<(icu_data_in)' ],
- 'outputs':[ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness).dat' ],
- 'action': [ '<(PRODUCT_DIR)/icupkg<(EXECUTABLE_SUFFIX)',
- '-t<(icu_endianness)',
- '<@(_inputs)',
- '<@(_outputs)',
- ],
- },
- {
- # Rename without the endianness marker (icudt64l.dat -> icudt64.dat)
- 'action_name': 'copy',
- 'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness).dat' ],
- 'outputs':[ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major).dat' ],
- 'action': [ 'cp',
- '<@(_inputs)',
- '<@(_outputs)',
- ],
- },
- {
- # convert full ICU data file to .c, or .S, etc.
- 'action_name': 'icudata',
- 'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major).dat' ],
- 'outputs':[ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
- 'action': [ '<(PRODUCT_DIR)/genccode<(EXECUTABLE_SUFFIX)',
- '-e', 'icudt<(icu_ver_major)',
- '-d', '<(SHARED_INTERMEDIATE_DIR)',
- '<@(icu_asm_opts)',
- '-f', 'icudt<(icu_ver_major)_dat',
- '<@(_inputs)' ],
- },
- ], # end actions
- }, { # icu_small == true ( and OS != win )
- # link against stub data (as primary data)
- # then, use icupkg and genccode to rebuild small data
- 'dependencies': [ 'icustubdata', 'genccode#host', 'icupkg#host', 'genrb#host', 'iculslocs#host',
- 'icu_implementation', 'icu_uconfig' ],
- 'export_dependent_settings': [ 'icustubdata' ],
- 'actions': [
- {
- # Trim down ICU.
- # Note that icupkg is invoked automatically, swapping endianness if needed.
- 'action_name': 'icutrim',
- 'inputs': [ '<(icu_data_in)', 'icu_small.json' ],
- 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ],
- 'action': [ '<(python)',
- 'icutrim.py',
- '-P', '<(PRODUCT_DIR)',
- '-D', '<(icu_data_in)',
- '--delete-tmp',
- '-T', '<(SHARED_INTERMEDIATE_DIR)/icutmp',
- '-F', 'icu_small.json',
- '-O', 'icudt<(icu_ver_major)<(icu_endianness).dat',
- '-v',
- '-L', '<(icu_locales)'],
- }, {
- # rename to get the final entrypoint name right (icudt64l.dat -> icusmdt64.dat)
- 'action_name': 'rename',
- 'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ],
- 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icusmdt<(icu_ver_major).dat' ],
- 'action': [ 'cp',
- '<@(_inputs)',
- '<@(_outputs)',
- ],
- }, {
- # For icu-small, always use .c, don't try to use .S, etc.
- 'action_name': 'genccode',
- 'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icusmdt<(icu_ver_major).dat' ],
- 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icusmdt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
- 'action': [ '<(PRODUCT_DIR)/genccode<(EXECUTABLE_SUFFIX)',
- '<@(icu_asm_opts)',
- '-d', '<(SHARED_INTERMEDIATE_DIR)',
- '<@(_inputs)' ],
- },
- ],
- # This file contains the small ICU data
- 'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icusmdt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
- # for umachine.h
- 'include_dirs': [
- '<(icu_path)/source/common',
- ],
- }]], # end icu_small == true
- }]], # end OS != win
- }, # end icudata
- # icustubdata is a tiny (~1k) symbol with no ICU data in it.
- # tools must link against it as they are generating the full data.
- {
- 'target_name': 'icustubdata',
- 'type': '<(library)',
- 'toolsets': [ 'target' ],
- 'dependencies': [ 'icu_implementation' ],
- 'sources': [
- '<@(icu_src_stubdata)'
- ],
- 'include_dirs': [
- '<(icu_path)/source/common',
- ],
- },
- # this target is for v8 consumption.
- # it is icuuc + stubdata
- # it is only built for target
- {
- 'target_name': 'icuuc',
- 'type': 'none',
- 'toolsets': [ 'target', 'host' ],
- 'conditions' : [
- ['_toolset=="host"', {
- 'dependencies': [ 'icutools#host' ],
- 'export_dependent_settings': [ 'icutools' ],
- }],
- ['_toolset=="target"', {
- 'dependencies': [ 'icuucx', 'icudata' ],
- 'export_dependent_settings': [ 'icuucx', 'icudata' ],
- }],
- ],
- },
- # This is the 'real' icuuc.
- {
- 'target_name': 'icuucx',
- 'type': '<(library)',
- 'dependencies': [ 'icu_implementation', 'icu_uconfig', 'icu_uconfig_target' ],
- 'toolsets': [ 'target' ],
- 'sources': [
- '<@(icu_src_common)',
- ],
- ## if your compiler can dead-strip, this will
- ## make ZERO difference to binary size.
- ## Made ICU-specific for future-proofing.
- 'conditions': [
- [ 'OS == "solaris"', { 'defines': [
- '_XOPEN_SOURCE_EXTENDED=0',
- ]}],
- ],
- 'include_dirs': [
- '<(icu_path)/source/common',
- ],
- 'defines': [
- 'U_COMMON_IMPLEMENTATION=1',
- ],
- 'cflags_c': ['-std=c99'],
- 'export_dependent_settings': [ 'icu_uconfig', 'icu_uconfig_target' ],
- 'direct_dependent_settings': {
- 'include_dirs': [
- '<(icu_path)/source/common',
- ],
- 'conditions': [
- [ 'OS=="win"', {
- 'link_settings': {
- 'libraries': [ '-lAdvAPI32.lib', '-lUser32.lib' ],
- },
- }],
- ],
- },
- },
- # tools library. This builds all of ICU together.
- {
- 'target_name': 'icutools',
- 'type': '<(library)',
- 'toolsets': [ 'host' ],
- 'dependencies': [ 'icu_implementation', 'icu_uconfig' ],
- 'sources': [
- '<@(icu_src_tools)',
- '<@(icu_src_common)',
- '<@(icu_src_i18n)',
- '<@(icu_src_stubdata)',
- ],
- 'sources!': [
- '<(icu_path)/source/tools/toolutil/udbgutil.cpp',
- '<(icu_path)/source/tools/toolutil/udbgutil.h',
- '<(icu_path)/source/tools/toolutil/dbgutil.cpp',
- '<(icu_path)/source/tools/toolutil/dbgutil.h',
- ],
- 'include_dirs': [
- '<(icu_path)/source/common',
- '<(icu_path)/source/i18n',
- '<(icu_path)/source/tools/toolutil',
- ],
- 'defines': [
- 'U_COMMON_IMPLEMENTATION=1',
- 'U_I18N_IMPLEMENTATION=1',
- 'U_IO_IMPLEMENTATION=1',
- 'U_TOOLUTIL_IMPLEMENTATION=1',
- #'DEBUG=0', # http://bugs.icu-project.org/trac/ticket/10977
- ],
- 'cflags_c': ['-std=c99'],
- 'conditions': [
- ['OS == "solaris"', {
- 'defines': [ '_XOPEN_SOURCE_EXTENDED=0' ]
- }]
- ],
- 'direct_dependent_settings': {
- 'include_dirs': [
- '<(icu_path)/source/common',
- '<(icu_path)/source/i18n',
- '<(icu_path)/source/tools/toolutil',
- ],
- 'conditions': [
- [ 'OS=="win"', {
- 'link_settings': {
- 'libraries': [ '-lAdvAPI32.lib', '-lUser32.lib' ],
- },
- }],
- ],
- },
- 'export_dependent_settings': [ 'icu_uconfig' ],
- },
- # This tool is needed to rebuild .res files from .txt,
- # or to build index (res_index.txt) files for small-icu
- {
- 'target_name': 'genrb',
- 'type': 'executable',
- 'toolsets': [ 'host' ],
- 'dependencies': [ 'icutools', 'icu_implementation' ],
- 'sources': [
- '<@(icu_src_genrb)'
- ],
- # derb is a separate executable
- # (which is not currently built)
- 'sources!': [
- '<@(icu_src_derb)',
- 'no-op.cc',
- ],
- 'conditions': [
- # Avoid excessive LTO
- ['enable_lto=="true"', {
- 'ldflags': [ '-fno-lto' ],
- }],
- ['node_with_ltcg=="true" or enable_lto=="true" or enable_thin_lto=="true"', {
- 'msvs_settings': {
- 'VCCLCompilerTool': {
- 'AdditionalOptions': ['-fno-lto'],
- },
- 'VCLinkerTool': {
- 'AdditionalOptions': ['-fno-lto'],
- },
- },
- }],
- ],
- },
- # This tool is used to rebuild res_index.res manifests
- {
- 'target_name': 'iculslocs',
- 'toolsets': [ 'host' ],
- 'type': 'executable',
- 'dependencies': [ 'icutools' ],
- 'sources': [
- 'iculslocs.cc',
- 'no-op.cc',
- ],
- 'conditions': [
- # Avoid excessive LTO
- ['enable_lto=="true"', {
- 'ldflags': [ '-fno-lto' ],
- }],
- ['node_with_ltcg=="true" or enable_lto=="true" or enable_thin_lto=="true"', {
- 'msvs_settings': {
- 'VCCLCompilerTool': {
- 'AdditionalOptions': ['-fno-lto'],
- },
- 'VCLinkerTool': {
- 'AdditionalOptions': ['-fno-lto'],
- },
- },
- }],
- ],
- },
- # This tool is used to package, unpackage, repackage .dat files
- # and convert endianesses
- {
- 'target_name': 'icupkg',
- 'toolsets': [ 'host' ],
- 'type': 'executable',
- 'dependencies': [ 'icutools' ],
- 'sources': [
- '<@(icu_src_icupkg)',
- 'no-op.cc',
- ],
- 'conditions': [
- # Avoid excessive LTO
- ['enable_lto=="true"', {
- 'ldflags': [ '-fno-lto' ],
- }],
- ['node_with_ltcg=="true" or enable_lto=="true" or enable_thin_lto=="true"', {
- 'msvs_settings': {
- 'VCCLCompilerTool': {
- 'AdditionalOptions': ['-fno-lto'],
- },
- 'VCLinkerTool': {
- 'AdditionalOptions': ['-fno-lto'],
- },
- },
- }],
- ],
- },
- # this is used to convert .dat directly into .obj
- {
- 'target_name': 'genccode',
- 'toolsets': [ 'host' ],
- 'type': 'executable',
- 'dependencies': [ 'icutools' ],
- 'sources': [
- '<@(icu_src_genccode)',
- 'no-op.cc',
- ],
- 'conditions': [
- # Avoid excessive LTO
- ['enable_lto=="true"', {
- 'ldflags': [ '-fno-lto' ],
- }],
- ['node_with_ltcg=="true" or enable_lto=="true" or enable_thin_lto=="true"', {
- 'msvs_settings': {
- 'VCCLCompilerTool': {
- 'AdditionalOptions': ['-fno-lto'],
- },
- 'VCLinkerTool': {
- 'AdditionalOptions': ['-fno-lto'],
- },
- },
- }],
- ],
- },
- ],
-}
diff --git a/tools/icu/icu-system.gyp b/tools/icu/icu-system.gyp
deleted file mode 100644
index b3ca0e39b6c..00000000000
--- a/tools/icu/icu-system.gyp
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (c) 2014 IBM Corporation and Others. All Rights Reserved.
-
-# This variant is used for the '--with-intl=system-icu' option.
-# 'configure' has already set 'libs' and 'cflags' - so,
-# there's nothing to do in these targets.
-
-{
- 'targets': [
- {
- 'target_name': 'icuuc',
- 'type': 'none',
- 'toolsets': [ 'host', 'target' ],
- },
- {
- 'target_name': 'icui18n',
- 'type': 'none',
- 'toolsets': [ 'host', 'target' ],
- },
- ],
-}
diff --git a/tools/icu/icu_small.json b/tools/icu/icu_small.json
deleted file mode 100644
index 712998f2ade..00000000000
--- a/tools/icu/icu_small.json
+++ /dev/null
@@ -1,47 +0,0 @@
-{
- "copyright": "Copyright (c) 2014 IBM Corporation and Others. All Rights Reserved.",
- "comment": "icutrim.py config: Trim down ICU to just a certain locale set, needed for node.js use.",
- "variables": {
- "none": {
- "only": []
- },
- "locales": {
- "only": [
- "root",
- "en"
- ]
- },
- "leavealone": {
- }
- },
- "trees": {
- "ROOT": "locales",
- "brkitr": "none",
- "coll": "locales",
- "curr": "locales",
- "lang": "none",
- "rbnf": "none",
- "region": "none",
- "zone": "locales",
- "converters": "none",
- "stringprep": "locales",
- "translit": "locales",
- "brkfiles": "none",
- "brkdict": "none",
- "confusables": "none",
- "unit": "locales"
- },
- "remove": [
- "cnvalias.icu",
- "postalCodeData.res",
- "genderList.res",
- "brkitr/root.res",
- "unames.icu"
- ],
- "keep": [
- "pool.res",
- "supplementalData.res",
- "zoneinfo64.res",
- "likelySubtags.res"
- ]
-}
diff --git a/tools/icu/icu_versions.json b/tools/icu/icu_versions.json
deleted file mode 100644
index e635d9b841a..00000000000
--- a/tools/icu/icu_versions.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "minimum_icu": 73
-}
diff --git a/tools/icu/iculslocs.cc b/tools/icu/iculslocs.cc
deleted file mode 100644
index 85cf1f77c35..00000000000
--- a/tools/icu/iculslocs.cc
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
-**********************************************************************
-* Copyright (C) 2014, International Business Machines
-* Corporation and others. All Rights Reserved.
-**********************************************************************
-*
-* Created 2014-06-20 by Steven R. Loomis
-*
-* See: http://bugs.icu-project.org/trac/ticket/10922
-*
-*/
-
-/*
-WHAT IS THIS?
-
-Here's the problem: It's difficult to reconfigure ICU from the command
-line without using the full makefiles. You can do a lot, but not
-everything.
-
-Consider:
-
- $ icupkg -r 'ja*' icudt53l.dat
-
-Great, you've now removed the (main) Japanese data. But something's
-still wrong-- res_index (and thus, getAvailable* functions) still
-claim the locale is present.
-
-You are reading the source to a tool (using only public API C code)
-that can solve this problem. Use as follows:
-
- $ iculslocs -i . -N icudt53l -b res_index.txt
-
-.. Generates a NEW res_index.txt (by looking at the .dat file, and
-figuring out which locales are actually available. Has commented out
-the ones which are no longer available:
-
- ...
- it_SM {""}
-// ja {""}
-// ja_JP {""}
- jgo {""}
- ...
-
-Then you can build and in-place patch it with existing ICU tools:
- $ genrb res_index.txt
- $ icupkg -a res_index.res icudt53l.dat
-
-.. Now you have a patched icudt539.dat that not only doesn't have
-Japanese, it doesn't *claim* to have Japanese.
-
-*/
-
-#include
-#include "charstr.h" // ICU internal header
-#include
-#include
-#include
-#include
-
-const char* PROG = "iculslocs";
-const char* NAME = U_ICUDATA_NAME; // assume ICU data
-const char* TREE = "ROOT";
-int VERBOSE = 0;
-
-#define RES_INDEX "res_index"
-#define INSTALLEDLOCALES "InstalledLocales"
-
-icu::CharString packageName;
-const char* locale = RES_INDEX; // locale referring to our index
-
-void usage() {
- printf("Usage: %s [options]\n", PROG);
- printf(
- "This program lists and optionally regenerates the locale "
- "manifests\n"
- " in ICU 'res_index.res' files.\n");
- printf(
- " -i ICUDATA Set ICUDATA dir to ICUDATA.\n"
- " NOTE: this must be the first option given.\n");
- printf(" -h This Help\n");
- printf(" -v Verbose Mode on\n");
- printf(" -l List locales to stdout\n");
- printf(
- " if Verbose mode, then missing (unopenable)"
- "locales\n"
- " will be listed preceded by a '#'.\n");
- printf(
- " -b res_index.txt Write 'corrected' bundle "
- "to res_index.txt\n"
- " missing bundles will be "
- "OMITTED\n");
- printf(
- " -T TREE Choose tree TREE\n"
- " (TREE should be one of: \n"
- " ROOT, brkitr, coll, curr, lang, rbnf, region, zone)\n");
- // see ureslocs.h and elsewhere
- printf(
- " -N NAME Choose name NAME\n"
- " (default: '%s')\n",
- U_ICUDATA_NAME);
- printf(
- "\nNOTE: for best results, this tool ought to be "
- "linked against\n"
- "stubdata. i.e. '%s -l' SHOULD return an error with "
- " no data.\n",
- PROG);
-}
-
-#define ASSERT_SUCCESS(status, what) \
- if (U_FAILURE(*status)) { \
- printf("%s:%d: %s: ERROR: %s %s\n", \
- __FILE__, \
- __LINE__, \
- PROG, \
- u_errorName(*status), \
- what); \
- return 1; \
- }
-
-/**
- * @param status changed from reference to pointer to match node.js style
- */
-void calculatePackageName(UErrorCode* status) {
- packageName.clear();
- if (strcmp(NAME, "NONE")) {
- packageName.append(NAME, *status);
- if (strcmp(TREE, "ROOT")) {
- packageName.append(U_TREE_SEPARATOR_STRING, *status);
- packageName.append(TREE, *status);
- }
- }
- if (VERBOSE) {
- printf("packageName: %s\n", packageName.data());
- }
-}
-
-/**
- * Does the locale exist?
- * return zero for false, or nonzero if it was openable.
- * Assumes calculatePackageName was called.
- * @param exists set to TRUE if exists, FALSE otherwise.
- * Changed from reference to pointer to match node.js style
- * @returns 0 on "OK" (success or resource-missing),
- * 1 on "FAILURE" (unexpected error)
- */
-int localeExists(const char* loc, UBool* exists) {
- UErrorCode status = U_ZERO_ERROR;
- if (VERBOSE > 1) {
- printf("Trying to open %s:%s\n", packageName.data(), loc);
- }
- icu::LocalUResourceBundlePointer aResource(
- ures_openDirect(packageName.data(), loc, &status));
- *exists = false;
- if (U_SUCCESS(status)) {
- *exists = true;
- if (VERBOSE > 1) {
- printf("%s:%s existed!\n", packageName.data(), loc);
- }
- return 0;
- } else if (status == U_MISSING_RESOURCE_ERROR) {
- *exists = false;
- if (VERBOSE > 1) {
- printf("%s:%s did NOT exist (%s)!\n",
- packageName.data(),
- loc,
- u_errorName(status));
- }
- return 0; // "good" failure
- } else {
- // some other failure..
- printf("%s:%d: %s: ERROR %s opening %s for test.\n",
- __FILE__,
- __LINE__,
- u_errorName(status),
- packageName.data(),
- loc);
- return 1; // abort
- }
-}
-
-void printIndent(FILE* bf, int indent) {
- for (int i = 0; i < indent + 1; i++) {
- fprintf(bf, " ");
- }
-}
-
-/**
- * Dumps a table resource contents
- * if lev==0, skips INSTALLEDLOCALES
- * @returns 0 for OK, 1 for err
- */
-int dumpAllButInstalledLocales(int lev,
- icu::LocalUResourceBundlePointer* bund,
- FILE* bf,
- UErrorCode* status) {
- ures_resetIterator(bund->getAlias());
- icu::LocalUResourceBundlePointer t;
- while (U_SUCCESS(*status) && ures_hasNext(bund->getAlias())) {
- t.adoptInstead(ures_getNextResource(bund->getAlias(), t.orphan(), status));
- ASSERT_SUCCESS(status, "while processing table");
- const char* key = ures_getKey(t.getAlias());
- if (VERBOSE > 1) {
- printf("dump@%d: got key %s\n", lev, key);
- }
- if (lev == 0 && !strcmp(key, INSTALLEDLOCALES)) {
- if (VERBOSE > 1) {
- printf("dump: skipping '%s' as it must be evaluated.\n", key);
- }
- } else {
- printIndent(bf, lev);
- fprintf(bf, "%s", key);
- const UResType type = ures_getType(t.getAlias());
- switch (type) {
- case URES_STRING: {
- int32_t len = 0;
- const UChar* s = ures_getString(t.getAlias(), &len, status);
- ASSERT_SUCCESS(status, "getting string");
- fprintf(bf, ":string {\"");
- fwrite(s, len, 1, bf);
- fprintf(bf, "\"}");
- } break;
- case URES_TABLE: {
- fprintf(bf, ":table {\n");
- dumpAllButInstalledLocales(lev+1, &t, bf, status);
- printIndent(bf, lev);
- fprintf(bf, "}\n");
- } break;
- default: {
- printf("ERROR: unhandled type %d for key %s "
- "in dumpAllButInstalledLocales().\n",
- static_cast(type), key);
- return 1;
- } break;
- }
- fprintf(bf, "\n");
- }
- }
- return 0;
-}
-
-int list(const char* toBundle) {
- UErrorCode status = U_ZERO_ERROR;
-
- FILE* bf = nullptr;
-
- if (toBundle != nullptr) {
- if (VERBOSE) {
- printf("writing to bundle %s\n", toBundle);
- }
- bf = fopen(toBundle, "wb");
- if (bf == nullptr) {
- printf("ERROR: Could not open '%s' for writing.\n", toBundle);
- return 1;
- }
- fprintf(bf, "\xEF\xBB\xBF"); // write UTF-8 BOM
- fprintf(bf, "// -*- Coding: utf-8; -*-\n//\n");
- }
-
- // first, calculate the bundle name.
- calculatePackageName(&status);
- ASSERT_SUCCESS(&status, "calculating package name");
-
- if (VERBOSE) {
- printf("\"locale\": %s\n", locale);
- }
-
- icu::LocalUResourceBundlePointer bund(
- ures_openDirect(packageName.data(), locale, &status));
- ASSERT_SUCCESS(&status, "while opening the bundle");
- icu::LocalUResourceBundlePointer installedLocales(
- // NOLINTNEXTLINE (readability/null_usage)
- ures_getByKey(bund.getAlias(), INSTALLEDLOCALES, nullptr, &status));
- ASSERT_SUCCESS(&status, "while fetching installed locales");
-
- int32_t count = ures_getSize(installedLocales.getAlias());
- if (VERBOSE) {
- printf("Locales: %d\n", count);
- }
-
- if (bf != nullptr) {
- // write the HEADER
- fprintf(bf,
- "// NOTE: This file was generated during the build process.\n"
- "// Generator: tools/icu/iculslocs.cc\n"
- "// Input package-tree/item: %s/%s.res\n",
- packageName.data(),
- locale);
- fprintf(bf,
- "%s:table(nofallback) {\n"
- " // First, everything besides InstalledLocales:\n",
- locale);
- if (dumpAllButInstalledLocales(0, &bund, bf, &status)) {
- printf("Error dumping prolog for %s\n", toBundle);
- fclose(bf);
- return 1;
- }
- // in case an error was missed
- ASSERT_SUCCESS(&status, "while writing prolog");
-
- fprintf(bf,
- " %s:table { // %d locales in input %s.res\n",
- INSTALLEDLOCALES,
- count,
- locale);
- }
-
- // OK, now list them.
- icu::LocalUResourceBundlePointer subkey;
-
- int validCount = 0;
- for (int32_t i = 0; i < count; i++) {
- subkey.adoptInstead(ures_getByIndex(
- installedLocales.getAlias(), i, subkey.orphan(), &status));
- ASSERT_SUCCESS(&status, "while fetching an installed locale's name");
-
- const char* key = ures_getKey(subkey.getAlias());
- if (VERBOSE > 1) {
- printf("@%d: %s\n", i, key);
- }
- // now, see if the locale is installed..
-
- UBool exists;
- if (localeExists(key, &exists)) {
- if (bf != nullptr) fclose(bf);
- return 1; // get out.
- }
- if (exists) {
- validCount++;
- printf("%s\n", key);
- if (bf != nullptr) {
- fprintf(bf, " %s {\"\"}\n", key);
- }
- } else {
- if (bf != nullptr) {
- fprintf(bf, "// %s {\"\"}\n", key);
- }
- if (VERBOSE) {
- printf("#%s\n", key); // verbosity one - '' vs '#'
- }
- }
- }
-
- if (bf != nullptr) {
- fprintf(bf, " } // %d/%d valid\n", validCount, count);
- // write the HEADER
- fprintf(bf, "}\n");
- fclose(bf);
- }
-
- return 0;
-}
-
-int main(int argc, const char* argv[]) {
- PROG = argv[0];
- for (int i = 1; i < argc; i++) {
- const char* arg = argv[i];
- int argsLeft = argc - i - 1; /* how many remain? */
- if (!strcmp(arg, "-v")) {
- VERBOSE++;
- } else if (!strcmp(arg, "-i") && (argsLeft >= 1)) {
- if (i != 1) {
- printf("ERROR: -i must be the first argument given.\n");
- usage();
- return 1;
- }
- const char* dir = argv[++i];
- u_setDataDirectory(dir);
- if (VERBOSE) {
- printf("ICUDATA is now %s\n", dir);
- }
- } else if (!strcmp(arg, "-T") && (argsLeft >= 1)) {
- TREE = argv[++i];
- if (VERBOSE) {
- printf("TREE is now %s\n", TREE);
- }
- } else if (!strcmp(arg, "-N") && (argsLeft >= 1)) {
- NAME = argv[++i];
- if (VERBOSE) {
- printf("NAME is now %s\n", NAME);
- }
- } else if (!strcmp(arg, "-?") || !strcmp(arg, "-h")) {
- usage();
- return 0;
- } else if (!strcmp(arg, "-l")) {
- if (list(nullptr)) {
- return 1;
- }
- } else if (!strcmp(arg, "-b") && (argsLeft >= 1)) {
- if (list(argv[++i])) {
- return 1;
- }
- } else {
- printf("Unknown or malformed option: %s\n", arg);
- usage();
- return 1;
- }
- }
-}
-
-// Local Variables:
-// compile-command: "icurun iculslocs.cpp"
-// End:
diff --git a/tools/icu/icutrim.py b/tools/icu/icutrim.py
deleted file mode 100755
index 4441550df09..00000000000
--- a/tools/icu/icutrim.py
+++ /dev/null
@@ -1,355 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright (C) 2014 IBM Corporation and Others. All Rights Reserved.
-#
-# @author Steven R. Loomis
-#
-# This tool slims down an ICU data (.dat) file according to a config file.
-#
-# See: http://bugs.icu-project.org/trac/ticket/10922
-#
-# Usage:
-# Use "-h" to get help options.
-
-from __future__ import print_function
-
-import io
-import json
-import optparse
-import os
-import re
-import shutil
-import sys
-
-try:
- # for utf-8 on Python 2
- reload(sys)
- sys.setdefaultencoding("utf-8")
-except NameError:
- pass # Python 3 already defaults to utf-8
-
-try:
- basestring # Python 2
-except NameError:
- basestring = str # Python 3
-
-endian=sys.byteorder
-
-parser = optparse.OptionParser(usage="usage: mkdir tmp ; %prog -D ~/Downloads/icudt53l.dat -T tmp -F trim_en.json -O icudt53l.dat" )
-
-parser.add_option("-P","--tool-path",
- action="store",
- dest="toolpath",
- help="set the prefix directory for ICU tools")
-
-parser.add_option("-D","--input-file",
- action="store",
- dest="datfile",
- help="input data file (icudt__.dat)",
- ) # required
-
-parser.add_option("-F","--filter-file",
- action="store",
- dest="filterfile",
- help="filter file (JSON format)",
- ) # required
-
-parser.add_option("-T","--tmp-dir",
- action="store",
- dest="tmpdir",
- help="working directory.",
- ) # required
-
-parser.add_option("--delete-tmp",
- action="count",
- dest="deltmpdir",
- help="delete working directory.",
- default=0)
-
-parser.add_option("-O","--outfile",
- action="store",
- dest="outfile",
- help="outfile (NOT a full path)",
- ) # required
-
-parser.add_option("-v","--verbose",
- action="count",
- default=0)
-
-parser.add_option('-L',"--locales",
- action="store",
- dest="locales",
- help="sets the 'locales.only' variable",
- default=None)
-
-parser.add_option('-e', '--endian', action='store', dest='endian', help='endian, big, little or host, your default is "%s".' % endian, default=endian, metavar='endianness')
-
-(options, args) = parser.parse_args()
-
-optVars = vars(options)
-
-for opt in [ "datfile", "filterfile", "tmpdir", "outfile" ]:
- if optVars[opt] is None:
- print("Missing required option: %s" % opt)
- sys.exit(1)
-
-if options.verbose>0:
- print("Options: "+str(options))
-
-if (os.path.isdir(options.tmpdir) and options.deltmpdir):
- if options.verbose>1:
- print("Deleting tmp dir %s.." % (options.tmpdir))
- shutil.rmtree(options.tmpdir)
-
-if not (os.path.isdir(options.tmpdir)):
- os.mkdir(options.tmpdir)
-else:
- print("Please delete tmpdir %s before beginning." % options.tmpdir)
- sys.exit(1)
-
-if options.endian not in ("big","little","host"):
- print("Unknown endianness: %s" % options.endian)
- sys.exit(1)
-
-if options.endian == "host":
- options.endian = endian
-
-if not os.path.isdir(options.tmpdir):
- print("Error, tmpdir not a directory: %s" % (options.tmpdir))
- sys.exit(1)
-
-if not os.path.isfile(options.filterfile):
- print("Filterfile doesn't exist: %s" % (options.filterfile))
- sys.exit(1)
-
-if not os.path.isfile(options.datfile):
- print("Datfile doesn't exist: %s" % (options.datfile))
- sys.exit(1)
-
-if not options.datfile.endswith(".dat"):
- print("Datfile doesn't end with .dat: %s" % (options.datfile))
- sys.exit(1)
-
-outfile = os.path.join(options.tmpdir, options.outfile)
-
-if os.path.isfile(outfile):
- print("Error, output file does exist: %s" % (outfile))
- sys.exit(1)
-
-if not options.outfile.endswith(".dat"):
- print("Outfile doesn't end with .dat: %s" % (options.outfile))
- sys.exit(1)
-
-dataname=options.outfile[0:-4]
-
-
-## TODO: need to improve this. Quotes, etc.
-def runcmd(tool, cmd, doContinue=False):
- if(options.toolpath):
- cmd = os.path.join(options.toolpath, tool) + " " + cmd
- else:
- cmd = tool + " " + cmd
-
- if(options.verbose>4):
- print("# " + cmd)
-
- rc = os.system(cmd)
- if rc != 0 and not doContinue:
- print("FAILED: %s" % cmd)
- sys.exit(1)
- return rc
-
-## STEP 0 - read in json config
-with io.open(options.filterfile, encoding='utf-8') as fi:
- config = json.load(fi)
-
-if options.locales:
- config["variables"] = config.get("variables", {})
- config["variables"]["locales"] = config["variables"].get("locales", {})
- config["variables"]["locales"]["only"] = options.locales.split(',')
-
-if options.verbose > 6:
- print(config)
-
-if "comment" in config:
- print("%s: %s" % (options.filterfile, config["comment"]))
-
-## STEP 1 - copy the data file, swapping endianness
-## The first letter of endian_letter will be 'b' or 'l' for big or little
-endian_letter = options.endian[0]
-
-runcmd("icupkg", "-t%s %s %s""" % (endian_letter, options.datfile, outfile))
-
-## STEP 2 - get listing
-listfile = os.path.join(options.tmpdir,"icudata.lst")
-runcmd("icupkg", "-l %s > %s""" % (outfile, listfile))
-
-with open(listfile, 'rb') as fi:
- items = [line.strip() for line in fi.read().decode("utf-8").splitlines()]
-itemset = set(items)
-
-if options.verbose > 1:
- print("input file: %d items" % len(items))
-
-# list of all trees
-trees = {}
-RES_INDX = "res_index.res"
-remove = None
-# remove - always remove these
-if "remove" in config:
- remove = set(config["remove"])
-else:
- remove = set()
-
-# keep - always keep these
-if "keep" in config:
- keep = set(config["keep"])
-else:
- keep = set()
-
-def queueForRemoval(tree):
- global remove
- if tree not in config.get("trees", {}):
- return
- mytree = trees[tree]
- if options.verbose > 0:
- print("* %s: %d items" % (tree, len(mytree["locs"])))
- # do varible substitution for this tree here
- if isinstance(config["trees"][tree], basestring):
- treeStr = config["trees"][tree]
- if options.verbose > 5:
- print(" Substituting $%s for tree %s" % (treeStr, tree))
- if treeStr not in config.get("variables", {}):
- print(" ERROR: no variable: variables.%s for tree %s" % (treeStr, tree))
- sys.exit(1)
- config["trees"][tree] = config["variables"][treeStr]
- myconfig = config["trees"][tree]
- if options.verbose > 4:
- print(" Config: %s" % (myconfig))
- # Process this tree
- if(len(myconfig)==0 or len(mytree["locs"])==0):
- if(options.verbose>2):
- print(" No processing for %s - skipping" % (tree))
- else:
- only = None
- if "only" in myconfig:
- only = set(myconfig["only"])
- if (len(only)==0) and (mytree["treeprefix"] != ""):
- thePool = "%spool.res" % (mytree["treeprefix"])
- if (thePool in itemset):
- if(options.verbose>0):
- print("Removing %s because tree %s is empty." % (thePool, tree))
- remove.add(thePool)
- else:
- print("tree %s - no ONLY")
- for l in range(len(mytree["locs"])):
- loc = mytree["locs"][l]
- if (only is not None) and not loc in only:
- # REMOVE loc
- toRemove = "%s%s%s" % (mytree["treeprefix"], loc, mytree["extension"])
- if(options.verbose>6):
- print("Queueing for removal: %s" % toRemove)
- remove.add(toRemove)
-
-def addTreeByType(tree, mytree):
- if(options.verbose>1):
- print("(considering %s): %s" % (tree, mytree))
- trees[tree] = mytree
- mytree["locs"]=[]
- for i in range(len(items)):
- item = items[i]
- if item.startswith(mytree["treeprefix"]) and item.endswith(mytree["extension"]):
- mytree["locs"].append(item[len(mytree["treeprefix"]):-4])
- # now, process
- queueForRemoval(tree)
-
-addTreeByType("converters",{"treeprefix":"", "extension":".cnv"})
-addTreeByType("stringprep",{"treeprefix":"", "extension":".spp"})
-addTreeByType("translit",{"treeprefix":"translit/", "extension":".res"})
-addTreeByType("brkfiles",{"treeprefix":"brkitr/", "extension":".brk"})
-addTreeByType("brkdict",{"treeprefix":"brkitr/", "extension":"dict"})
-addTreeByType("confusables",{"treeprefix":"", "extension":".cfu"})
-
-for i in range(len(items)):
- item = items[i]
- if item.endswith(RES_INDX):
- treeprefix = item[0:item.rindex(RES_INDX)]
- tree = None
- if treeprefix == "":
- tree = "ROOT"
- else:
- tree = treeprefix[0:-1]
- if(options.verbose>6):
- print("procesing %s" % (tree))
- trees[tree] = { "extension": ".res", "treeprefix": treeprefix, "hasIndex": True }
- # read in the resource list for the tree
- treelistfile = os.path.join(options.tmpdir,"%s.lst" % tree)
- runcmd("iculslocs", "-i %s -N %s -T %s -l > %s" % (outfile, dataname, tree, treelistfile))
- with io.open(treelistfile, 'r', encoding='utf-8') as fi:
- treeitems = fi.readlines()
- trees[tree]["locs"] = [line.strip() for line in treeitems]
- if tree not in config.get("trees", {}):
- print(" Warning: filter file %s does not mention trees.%s - will be kept as-is" % (options.filterfile, tree))
- else:
- queueForRemoval(tree)
-
-def removeList(count=0):
- # don't allow "keep" items to creep in here.
- global remove
- remove = remove - keep
- if(count > 10):
- print("Giving up - %dth attempt at removal." % count)
- sys.exit(1)
- if(options.verbose>1):
- print("%d items to remove - try #%d" % (len(remove),count))
- if(len(remove)>0):
- oldcount = len(remove)
- hackerrfile=os.path.join(options.tmpdir, "REMOVE.err")
- removefile = os.path.join(options.tmpdir, "REMOVE.lst")
- with open(removefile, 'wb') as fi:
- fi.write('\n'.join(remove).encode("utf-8") + b'\n')
- rc = runcmd("icupkg","-r %s %s 2> %s" % (removefile,outfile,hackerrfile),True)
- if rc != 0:
- if(options.verbose>5):
- print("## Damage control, trying to parse stderr from icupkg..")
- fi = open(hackerrfile, 'rb')
- erritems = fi.readlines()
- fi.close()
- #Item zone/zh_Hant_TW.res depends on missing item zone/zh_Hant.res
- pat = re.compile(br"^Item ([^ ]+) depends on missing item ([^ ]+).*")
- for i in range(len(erritems)):
- line = erritems[i].strip()
- m = pat.match(line)
- if m:
- toDelete = m.group(1).decode("utf-8")
- if(options.verbose > 5):
- print("<< %s added to delete" % toDelete)
- remove.add(toDelete)
- else:
- print("ERROR: could not match errline: %s" % line)
- sys.exit(1)
- if(options.verbose > 5):
- print(" now %d items to remove" % len(remove))
- if(oldcount == len(remove)):
- print(" ERROR: could not add any mor eitems to remove. Fail.")
- sys.exit(1)
- removeList(count+1)
-
-# fire it up
-removeList(1)
-
-# now, fixup res_index, one at a time
-for tree, value in trees.items():
- # skip trees that don't have res_index
- if "hasIndex" not in value:
- continue
- treebunddir = options.tmpdir
- if(value["treeprefix"]):
- treebunddir = os.path.join(treebunddir, value["treeprefix"])
- if not (os.path.isdir(treebunddir)):
- os.mkdir(treebunddir)
- treebundres = os.path.join(treebunddir,RES_INDX)
- treebundtxt = "%s.txt" % (treebundres[0:-4])
- runcmd("iculslocs", "-i %s -N %s -T %s -b %s" % (outfile, dataname, tree, treebundtxt))
- runcmd("genrb","-d %s -s %s res_index.txt" % (treebunddir, treebunddir))
- runcmd("icupkg","-s %s -a %s%s %s" % (options.tmpdir, value["treeprefix"], RES_INDX, outfile))
diff --git a/tools/icu/no-op.cc b/tools/icu/no-op.cc
deleted file mode 100644
index 08d1599a264..00000000000
--- a/tools/icu/no-op.cc
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
-**********************************************************************
-* Copyright (C) 2014, International Business Machines
-* Corporation and others. All Rights Reserved.
-**********************************************************************
-*
-*/
-
-//
-// ICU needs the C++, not the C linker to be used, even if the main function
-// is in C.
-//
-// This is a dummy function just to get gyp to compile some internal
-// tools as C++.
-//
-// It should not appear in production node binaries.
-
-extern void icu_dummy_cxx() {}
diff --git a/tools/icu/patches/75/source/common/unicode/platform.h b/tools/icu/patches/75/source/common/unicode/platform.h
deleted file mode 100644
index 59176005f33..00000000000
--- a/tools/icu/patches/75/source/common/unicode/platform.h
+++ /dev/null
@@ -1,849 +0,0 @@
-// © 2016 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-/*
-******************************************************************************
-*
-* Copyright (C) 1997-2016, International Business Machines
-* Corporation and others. All Rights Reserved.
-*
-******************************************************************************
-*
-* FILE NAME : platform.h
-*
-* Date Name Description
-* 05/13/98 nos Creation (content moved here from ptypes.h).
-* 03/02/99 stephen Added AS400 support.
-* 03/30/99 stephen Added Linux support.
-* 04/13/99 stephen Reworked for autoconf.
-******************************************************************************
-*/
-
-#ifndef _PLATFORM_H
-#define _PLATFORM_H
-
-#include "unicode/uconfig.h"
-#include "unicode/uvernum.h"
-
-/**
- * \file
- * \brief Basic types for the platform.
- *
- * This file used to be generated by autoconf/configure.
- * Starting with ICU 49, platform.h is a normal source file,
- * to simplify cross-compiling and working with non-autoconf/make build systems.
- *
- * When a value in this file does not work on a platform, then please
- * try to derive it from the U_PLATFORM value
- * (for which we might need a new value constant in rare cases)
- * and/or from other macros that are predefined by the compiler
- * or defined in standard (POSIX or platform or compiler) headers.
- *
- * As a temporary workaround, you can add an explicit \#define for some macros
- * before it is first tested, or add an equivalent -D macro definition
- * to the compiler's command line.
- *
- * Note: Some compilers provide ways to show the predefined macros.
- * For example, with gcc you can compile an empty .c file and have the compiler
- * print the predefined macros with
- * \code
- * gcc -E -dM -x c /dev/null | sort
- * \endcode
- * (You can provide an actual empty .c file rather than /dev/null.
- * -x c++ is for C++.)
- */
-
-/**
- * Define some things so that they can be documented.
- * @internal
- */
-#ifdef U_IN_DOXYGEN
-/*
- * Problem: "platform.h:335: warning: documentation for unknown define U_HAVE_STD_STRING found." means that U_HAVE_STD_STRING is not documented.
- * Solution: #define any defines for non @internal API here, so that they are visible in the docs. If you just set PREDEFINED in Doxyfile.in, they won't be documented.
- */
-
-/* None for now. */
-#endif
-
-/**
- * \def U_PLATFORM
- * The U_PLATFORM macro defines the platform we're on.
- *
- * We used to define one different, value-less macro per platform.
- * That made it hard to know the set of relevant platforms and macros,
- * and hard to deal with variants of platforms.
- *
- * Starting with ICU 49, we define platforms as numeric macros,
- * with ranges of values for related platforms and their variants.
- * The U_PLATFORM macro is set to one of these values.
- *
- * Historical note from the Solaris Wikipedia article:
- * AT&T and Sun collaborated on a project to merge the most popular Unix variants
- * on the market at that time: BSD, System V, and Xenix.
- * This became Unix System V Release 4 (SVR4).
- *
- * @internal
- */
-
-/** Unknown platform. @internal */
-#define U_PF_UNKNOWN 0
-/** Windows @internal */
-#define U_PF_WINDOWS 1000
-/** MinGW. Windows, calls to Win32 API, but using GNU gcc and binutils. @internal */
-#define U_PF_MINGW 1800
-/**
- * Cygwin. Windows, calls to cygwin1.dll for Posix functions,
- * using MSVC or GNU gcc and binutils.
- * @internal
- */
-#define U_PF_CYGWIN 1900
-/* Reserve 2000 for U_PF_UNIX? */
-/** HP-UX is based on UNIX System V. @internal */
-#define U_PF_HPUX 2100
-/** Solaris is a Unix operating system based on SVR4. @internal */
-#define U_PF_SOLARIS 2600
-/** BSD is a UNIX operating system derivative. @internal */
-#define U_PF_BSD 3000
-/** AIX is based on UNIX System V Releases and 4.3 BSD. @internal */
-#define U_PF_AIX 3100
-/** IRIX is based on UNIX System V with BSD extensions. @internal */
-#define U_PF_IRIX 3200
-/**
- * Darwin is a POSIX-compliant operating system, composed of code developed by Apple,
- * as well as code derived from NeXTSTEP, BSD, and other projects,
- * built around the Mach kernel.
- * Darwin forms the core set of components upon which Mac OS X, Apple TV, and iOS are based.
- * (Original description modified from WikiPedia.)
- * @internal
- */
-#define U_PF_DARWIN 3500
-/** iPhone OS (iOS) is a derivative of Mac OS X. @internal */
-#define U_PF_IPHONE 3550
-/** QNX is a commercial Unix-like real-time operating system related to BSD. @internal */
-#define U_PF_QNX 3700
-/** Linux is a Unix-like operating system. @internal */
-#define U_PF_LINUX 4000
-/**
- * Native Client is pretty close to Linux.
- * See https://developer.chrome.com/native-client and
- * http://www.chromium.org/nativeclient
- * @internal
- */
-#define U_PF_BROWSER_NATIVE_CLIENT 4020
-/** Android is based on Linux. @internal */
-#define U_PF_ANDROID 4050
-/** Fuchsia is a POSIX-ish platform. @internal */
-#define U_PF_FUCHSIA 4100
-/* Maximum value for Linux-based platform is 4499 */
-/**
- * Emscripten is a C++ transpiler for the Web that can target asm.js or
- * WebAssembly. It provides some POSIX-compatible wrappers and stubs and
- * some Linux-like functionality, but is not fully compatible with
- * either.
- * @internal
- */
-#define U_PF_EMSCRIPTEN 5010
-/** z/OS is the successor to OS/390 which was the successor to MVS. @internal */
-#define U_PF_OS390 9000
-/** "IBM i" is the current name of what used to be i5/OS and earlier OS/400. @internal */
-#define U_PF_OS400 9400
-
-#ifdef U_PLATFORM
- /* Use the predefined value. */
-#elif defined(__MINGW32__)
-# define U_PLATFORM U_PF_MINGW
-#elif defined(__CYGWIN__)
-# define U_PLATFORM U_PF_CYGWIN
-#elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
-# define U_PLATFORM U_PF_WINDOWS
-#elif defined(__ANDROID__)
-# define U_PLATFORM U_PF_ANDROID
- /* Android wchar_t support depends on the API level. */
-# include
-#elif defined(__pnacl__) || defined(__native_client__)
-# define U_PLATFORM U_PF_BROWSER_NATIVE_CLIENT
-#elif defined(__Fuchsia__)
-# define U_PLATFORM U_PF_FUCHSIA
-#elif defined(linux) || defined(__linux__) || defined(__linux)
-# define U_PLATFORM U_PF_LINUX
-#elif defined(__APPLE__) && defined(__MACH__)
-# include
-# if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && (defined(TARGET_OS_MACCATALYST) && !TARGET_OS_MACCATALYST) /* variant of TARGET_OS_MAC */
-# define U_PLATFORM U_PF_IPHONE
-# else
-# define U_PLATFORM U_PF_DARWIN
-# endif
-#elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__)
-# if defined(__FreeBSD__)
-# include
-# endif
-# define U_PLATFORM U_PF_BSD
-#elif defined(sun) || defined(__sun)
- /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */
-# define U_PLATFORM U_PF_SOLARIS
-# if defined(__GNUC__)
- /* Solaris/GCC needs this header file to get the proper endianness. Normally, this
- * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h
- * is included which does not include this header file.
- */
-# include
-# endif
-#elif defined(_AIX) || defined(__TOS_AIX__)
-# define U_PLATFORM U_PF_AIX
-#elif defined(_hpux) || defined(hpux) || defined(__hpux)
-# define U_PLATFORM U_PF_HPUX
-#elif defined(sgi) || defined(__sgi)
-# define U_PLATFORM U_PF_IRIX
-#elif defined(__QNX__) || defined(__QNXNTO__)
-# define U_PLATFORM U_PF_QNX
-#elif defined(__TOS_MVS__)
-# define U_PLATFORM U_PF_OS390
-#elif defined(__OS400__) || defined(__TOS_OS400__)
-# define U_PLATFORM U_PF_OS400
-#elif defined(__EMSCRIPTEN__)
-# define U_PLATFORM U_PF_EMSCRIPTEN
-#else
-# define U_PLATFORM U_PF_UNKNOWN
-#endif
-
-/**
- * \def U_REAL_MSVC
- * Defined if the compiler is the real MSVC compiler (and not something like
- * Clang setting _MSC_VER in order to compile Windows code that requires it).
- * Otherwise undefined.
- * @internal
- */
-#if (defined(_MSC_VER) && !(defined(__clang__) && __clang__)) || defined(U_IN_DOXYGEN)
-# define U_REAL_MSVC
-#endif
-
-/**
- * \def CYGWINMSVC
- * Defined if this is Windows with Cygwin, but using MSVC rather than gcc.
- * Otherwise undefined.
- * @internal
- */
-/* Commented out because this is already set in mh-cygwin-msvc
-#if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER)
-# define CYGWINMSVC
-#endif
-*/
-#ifdef U_IN_DOXYGEN
-# define CYGWINMSVC
-#endif
-
-/**
- * \def U_PLATFORM_USES_ONLY_WIN32_API
- * Defines whether the platform uses only the Win32 API.
- * Set to 1 for Windows/MSVC, ClangCL and MinGW but not Cygwin.
- * @internal
- */
-#ifdef U_PLATFORM_USES_ONLY_WIN32_API
- /* Use the predefined value. */
-#elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC)
-# define U_PLATFORM_USES_ONLY_WIN32_API 1
-#else
- /* Cygwin implements POSIX. */
-# define U_PLATFORM_USES_ONLY_WIN32_API 0
-#endif
-
-/**
- * \def U_PLATFORM_HAS_WIN32_API
- * Defines whether the Win32 API is available on the platform.
- * Set to 1 for Windows/MSVC, ClangCL, MinGW and Cygwin.
- * @internal
- */
-#ifdef U_PLATFORM_HAS_WIN32_API
- /* Use the predefined value. */
-#elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
-# define U_PLATFORM_HAS_WIN32_API 1
-#else
-# define U_PLATFORM_HAS_WIN32_API 0
-#endif
-
-/**
- * \def U_PLATFORM_HAS_WINUWP_API
- * Defines whether target is intended for Universal Windows Platform API
- * Set to 1 for Windows10 Release Solution Configuration
- * @internal
- */
-#ifdef U_PLATFORM_HAS_WINUWP_API
- /* Use the predefined value. */
-#else
-# define U_PLATFORM_HAS_WINUWP_API 0
-#endif
-
-/**
- * \def U_PLATFORM_IMPLEMENTS_POSIX
- * Defines whether the platform implements (most of) the POSIX API.
- * Set to 1 for Cygwin and most other platforms.
- * @internal
- */
-#ifdef U_PLATFORM_IMPLEMENTS_POSIX
- /* Use the predefined value. */
-#elif U_PLATFORM_USES_ONLY_WIN32_API
-# define U_PLATFORM_IMPLEMENTS_POSIX 0
-#else
-# define U_PLATFORM_IMPLEMENTS_POSIX 1
-#endif
-
-/**
- * \def U_PLATFORM_IS_LINUX_BASED
- * Defines whether the platform is Linux or one of its derivatives.
- * @internal
- */
-#ifdef U_PLATFORM_IS_LINUX_BASED
- /* Use the predefined value. */
-#elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= 4499
-# define U_PLATFORM_IS_LINUX_BASED 1
-#else
-# define U_PLATFORM_IS_LINUX_BASED 0
-#endif
-
-/**
- * \def U_PLATFORM_IS_DARWIN_BASED
- * Defines whether the platform is Darwin or one of its derivatives.
- * @internal
- */
-#ifdef U_PLATFORM_IS_DARWIN_BASED
- /* Use the predefined value. */
-#elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE
-# define U_PLATFORM_IS_DARWIN_BASED 1
-#else
-# define U_PLATFORM_IS_DARWIN_BASED 0
-#endif
-
-/*===========================================================================*/
-/** @{ Compiler and environment features */
-/*===========================================================================*/
-
-/**
- * \def U_GCC_MAJOR_MINOR
- * Indicates whether the compiler is gcc (test for != 0),
- * and if so, contains its major (times 100) and minor version numbers.
- * If the compiler is not gcc, then U_GCC_MAJOR_MINOR == 0.
- *
- * For example, for testing for whether we have gcc, and whether it's 4.6 or higher,
- * use "#if U_GCC_MAJOR_MINOR >= 406".
- * @internal
- */
-#ifdef __GNUC__
-# define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__)
-#else
-# define U_GCC_MAJOR_MINOR 0
-#endif
-
-/**
- * \def U_IS_BIG_ENDIAN
- * Determines the endianness of the platform.
- * @internal
- */
-#ifdef U_IS_BIG_ENDIAN
- /* Use the predefined value. */
-#elif defined(BYTE_ORDER) && defined(BIG_ENDIAN)
-# define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
-#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
- /* gcc */
-# define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
-#elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
-# define U_IS_BIG_ENDIAN 1
-#elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN)
-# define U_IS_BIG_ENDIAN 0
-#elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__)
- /* These platforms do not appear to predefine any endianness macros. */
-# define U_IS_BIG_ENDIAN 1
-#elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0)
- /* HPPA do not appear to predefine any endianness macros. */
-# define U_IS_BIG_ENDIAN 1
-#elif defined(sparc) || defined(__sparc) || defined(__sparc__)
- /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */
-# define U_IS_BIG_ENDIAN 1
-#else
-# define U_IS_BIG_ENDIAN 0
-#endif
-
-/**
- * \def U_HAVE_PLACEMENT_NEW
- * Determines whether to override placement new and delete for STL.
- * @stable ICU 2.6
- */
-#ifdef U_HAVE_PLACEMENT_NEW
- /* Use the predefined value. */
-#elif defined(__BORLANDC__)
-# define U_HAVE_PLACEMENT_NEW 0
-#else
-# define U_HAVE_PLACEMENT_NEW 1
-#endif
-
-/**
- * \def U_HAVE_DEBUG_LOCATION_NEW
- * Define this to define the MFC debug version of the operator new.
- *
- * @stable ICU 3.4
- */
-#ifdef U_HAVE_DEBUG_LOCATION_NEW
- /* Use the predefined value. */
-#elif defined(_MSC_VER)
-# define U_HAVE_DEBUG_LOCATION_NEW 1
-#else
-# define U_HAVE_DEBUG_LOCATION_NEW 0
-#endif
-
-/* Compatibility with compilers other than clang: http://clang.llvm.org/docs/LanguageExtensions.html */
-#ifdef __has_attribute
-# define UPRV_HAS_ATTRIBUTE(x) __has_attribute(x)
-#else
-# define UPRV_HAS_ATTRIBUTE(x) 0
-#endif
-#ifdef __has_cpp_attribute
-# define UPRV_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
-#else
-# define UPRV_HAS_CPP_ATTRIBUTE(x) 0
-#endif
-#ifdef __has_declspec_attribute
-# define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) __has_declspec_attribute(x)
-#else
-# define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) 0
-#endif
-#ifdef __has_builtin
-# define UPRV_HAS_BUILTIN(x) __has_builtin(x)
-#else
-# define UPRV_HAS_BUILTIN(x) 0
-#endif
-#ifdef __has_feature
-# define UPRV_HAS_FEATURE(x) __has_feature(x)
-#else
-# define UPRV_HAS_FEATURE(x) 0
-#endif
-#ifdef __has_extension
-# define UPRV_HAS_EXTENSION(x) __has_extension(x)
-#else
-# define UPRV_HAS_EXTENSION(x) 0
-#endif
-#ifdef __has_warning
-# define UPRV_HAS_WARNING(x) __has_warning(x)
-#else
-# define UPRV_HAS_WARNING(x) 0
-#endif
-
-
-#if defined(__clang__)
-#define UPRV_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined")))
-#else
-#define UPRV_NO_SANITIZE_UNDEFINED
-#endif
-
-/**
- * \def U_MALLOC_ATTR
- * Attribute to mark functions as malloc-like
- * @internal
- */
-#if defined(__GNUC__) && __GNUC__>=3
-# define U_MALLOC_ATTR __attribute__ ((__malloc__))
-#else
-# define U_MALLOC_ATTR
-#endif
-
-/**
- * \def U_ALLOC_SIZE_ATTR
- * Attribute to specify the size of the allocated buffer for malloc-like functions
- * @internal
- */
-#if (defined(__GNUC__) && \
- (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \
- UPRV_HAS_ATTRIBUTE(alloc_size)
-# define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X)))
-# define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y)))
-#else
-# define U_ALLOC_SIZE_ATTR(X)
-# define U_ALLOC_SIZE_ATTR2(X,Y)
-#endif
-
-/**
- * \def U_CPLUSPLUS_VERSION
- * 0 if no C++; 1, 11, 14, ... if C++.
- * Support for specific features cannot always be determined by the C++ version alone.
- * @internal
- */
-#ifdef U_CPLUSPLUS_VERSION
-# if U_CPLUSPLUS_VERSION != 0 && !defined(__cplusplus)
-# undef U_CPLUSPLUS_VERSION
-# define U_CPLUSPLUS_VERSION 0
-# endif
- /* Otherwise use the predefined value. */
-#elif !defined(__cplusplus)
-# define U_CPLUSPLUS_VERSION 0
-#elif __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
-# define U_CPLUSPLUS_VERSION 17
-#elif __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
-# define U_CPLUSPLUS_VERSION 14
-#elif __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)
-# define U_CPLUSPLUS_VERSION 11
-#else
- // C++98 or C++03
-# define U_CPLUSPLUS_VERSION 1
-#endif
-
-/**
- * \def U_FALLTHROUGH
- * Annotate intentional fall-through between switch labels.
- * http://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough
- * @internal
- */
-#ifndef __cplusplus
- // Not for C.
-#elif defined(U_FALLTHROUGH)
- // Use the predefined value.
-#elif defined(__clang__)
- // Test for compiler vs. feature separately.
- // Other compilers might choke on the feature test.
-# if UPRV_HAS_CPP_ATTRIBUTE(clang::fallthrough) || \
- (UPRV_HAS_FEATURE(cxx_attributes) && \
- UPRV_HAS_WARNING("-Wimplicit-fallthrough"))
-# define U_FALLTHROUGH [[clang::fallthrough]]
-# endif
-#elif defined(__GNUC__) && (__GNUC__ >= 7)
-# define U_FALLTHROUGH __attribute__((fallthrough))
-#endif
-
-#ifndef U_FALLTHROUGH
-# define U_FALLTHROUGH
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/** @{ Character data types */
-/*===========================================================================*/
-
-/**
- * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform.
- * @stable ICU 2.0
- */
-#define U_ASCII_FAMILY 0
-
-/**
- * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform.
- * @stable ICU 2.0
- */
-#define U_EBCDIC_FAMILY 1
-
-/**
- * \def U_CHARSET_FAMILY
- *
- * These definitions allow to specify the encoding of text
- * in the char data type as defined by the platform and the compiler.
- * It is enough to determine the code point values of "invariant characters",
- * which are the ones shared by all encodings that are in use
- * on a given platform.
- *
- * Those "invariant characters" should be all the uppercase and lowercase
- * latin letters, the digits, the space, and "basic punctuation".
- * Also, '\\n', '\\r', '\\t' should be available.
- *
- * The list of "invariant characters" is:
- * \code
- * A-Z a-z 0-9 SPACE " % & ' ( ) * + , - . / : ; < = > ? _
- * \endcode
- *
- * (52 letters + 10 numbers + 20 punc/sym/space = 82 total)
- *
- * This matches the IBM Syntactic Character Set (CS 640).
- *
- * In other words, all the graphic characters in 7-bit ASCII should
- * be safely accessible except the following:
- *
- * \code
- * '\'
- * '['
- * ']'
- * '{'
- * '}'
- * '^'
- * '~'
- * '!'
- * '#'
- * '|'
- * '$'
- * '@'
- * '`'
- * \endcode
- * @stable ICU 2.0
- */
-#ifdef U_CHARSET_FAMILY
- /* Use the predefined value. */
-#elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB)
-# define U_CHARSET_FAMILY U_EBCDIC_FAMILY
-#elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__)
-# define U_CHARSET_FAMILY U_EBCDIC_FAMILY
-#else
-# define U_CHARSET_FAMILY U_ASCII_FAMILY
-#endif
-
-/**
- * \def U_CHARSET_IS_UTF8
- *
- * Hardcode the default charset to UTF-8.
- *
- * If this is set to 1, then
- * - ICU will assume that all non-invariant char*, StringPiece, std::string etc.
- * contain UTF-8 text, regardless of what the system API uses
- * - some ICU code will use fast functions like u_strFromUTF8()
- * rather than the more general and more heavy-weight conversion API (ucnv.h)
- * - ucnv_getDefaultName() always returns "UTF-8"
- * - ucnv_setDefaultName() is disabled and will not change the default charset
- * - static builds of ICU are smaller
- * - more functionality is available with the UCONFIG_NO_CONVERSION build-time
- * configuration option (see unicode/uconfig.h)
- * - the UCONFIG_NO_CONVERSION build option in uconfig.h is more usable
- *
- * @stable ICU 4.2
- * @see UCONFIG_NO_CONVERSION
- */
-#ifdef U_CHARSET_IS_UTF8
- /* Use the predefined value. */
-#elif U_PLATFORM_IS_LINUX_BASED || U_PLATFORM_IS_DARWIN_BASED || \
- U_PLATFORM == U_PF_EMSCRIPTEN
-# define U_CHARSET_IS_UTF8 1
-#else
-# define U_CHARSET_IS_UTF8 0
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/** @{ Information about wchar support */
-/*===========================================================================*/
-
-/**
- * \def U_HAVE_WCHAR_H
- * Indicates whether is available (1) or not (0). Set to 1 by default.
- *
- * @stable ICU 2.0
- */
-#ifdef U_HAVE_WCHAR_H
- /* Use the predefined value. */
-#elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9
- /*
- * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t.
- * The type and header existed, but the library functions did not work as expected.
- * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway.
- */
-# define U_HAVE_WCHAR_H 0
-#else
-# define U_HAVE_WCHAR_H 1
-#endif
-
-/**
- * \def U_SIZEOF_WCHAR_T
- * U_SIZEOF_WCHAR_T==sizeof(wchar_t)
- *
- * @stable ICU 2.0
- */
-#ifdef U_SIZEOF_WCHAR_T
- /* Use the predefined value. */
-#elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9)
- /*
- * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring.
- * Newer Mac OS X has size 4.
- */
-# define U_SIZEOF_WCHAR_T 1
-#elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN
-# define U_SIZEOF_WCHAR_T 2
-#elif U_PLATFORM == U_PF_AIX
- /*
- * AIX 6.1 information, section "Wide character data representation":
- * "... the wchar_t datatype is 32-bit in the 64-bit environment and
- * 16-bit in the 32-bit environment."
- * and
- * "All locales use Unicode for their wide character code values (process code),
- * except the IBM-eucTW codeset."
- */
-# ifdef __64BIT__
-# define U_SIZEOF_WCHAR_T 4
-# else
-# define U_SIZEOF_WCHAR_T 2
-# endif
-#elif U_PLATFORM == U_PF_OS390
- /*
- * z/OS V1R11 information center, section "LP64 | ILP32":
- * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes.
- * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes."
- */
-# ifdef _LP64
-# define U_SIZEOF_WCHAR_T 4
-# else
-# define U_SIZEOF_WCHAR_T 2
-# endif
-#elif U_PLATFORM == U_PF_OS400
-# if defined(__UTF32__)
- /*
- * LOCALETYPE(*LOCALEUTF) is specified.
- * Wide-character strings are in UTF-32,
- * narrow-character strings are in UTF-8.
- */
-# define U_SIZEOF_WCHAR_T 4
-# elif defined(__UCS2__)
- /*
- * LOCALETYPE(*LOCALEUCS2) is specified.
- * Wide-character strings are in UCS-2,
- * narrow-character strings are in EBCDIC.
- */
-# define U_SIZEOF_WCHAR_T 2
-# else
- /*
- * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified.
- * Wide-character strings are in 16-bit EBCDIC,
- * narrow-character strings are in EBCDIC.
- */
-# define U_SIZEOF_WCHAR_T 2
-# endif
-#else
-# define U_SIZEOF_WCHAR_T 4
-#endif
-
-#ifndef U_HAVE_WCSCPY
-#define U_HAVE_WCSCPY U_HAVE_WCHAR_H
-#endif
-
-/** @} */
-
-/**
- * \def U_HAVE_CHAR16_T
- * Defines whether the char16_t type is available for UTF-16
- * and u"abc" UTF-16 string literals are supported.
- * This is a new standard type and standard string literal syntax in C++11
- * but has been available in some compilers before.
- * @internal
- */
-#ifdef U_HAVE_CHAR16_T
- /* Use the predefined value. */
-#else
- /*
- * Notes:
- * C++11 and C11 require support for UTF-16 literals
- * Doesn't work on Mac C11 (see workaround in ptypes.h).
- */
-# if defined(__cplusplus) || !U_PLATFORM_IS_DARWIN_BASED
-# define U_HAVE_CHAR16_T 1
-# else
-# define U_HAVE_CHAR16_T 0
-# endif
-#endif
-
-/**
- * @{
- * \def U_DECLARE_UTF16
- * Do not use this macro because it is not defined on all platforms.
- * Use the UNICODE_STRING or U_STRING_DECL macros instead.
- * @internal
- */
-#ifdef U_DECLARE_UTF16
- /* Use the predefined value. */
-#elif U_HAVE_CHAR16_T \
- || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
- || (defined(__HP_aCC) && __HP_aCC >= 035000) \
- || (defined(__HP_cc) && __HP_cc >= 111106) \
- || (defined(U_IN_DOXYGEN))
-# define U_DECLARE_UTF16(string) u ## string
-#elif U_SIZEOF_WCHAR_T == 2 \
- && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__)))
-# define U_DECLARE_UTF16(string) L ## string
-#else
- /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/** @{ Symbol import-export control */
-/*===========================================================================*/
-
-#ifdef U_EXPORT
- /* Use the predefined value. */
-#elif defined(U_STATIC_IMPLEMENTATION)
-# define U_EXPORT
-#elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllexport__) && \
- UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllimport__))
-# define U_EXPORT __declspec(dllexport)
-#elif defined(__GNUC__)
-# define U_EXPORT __attribute__((visibility("default")))
-#elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
- || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
-# define U_EXPORT __global
-/*#elif defined(__HP_aCC) || defined(__HP_cc)
-# define U_EXPORT __declspec(dllexport)*/
-#else
-# define U_EXPORT
-#endif
-
-/* U_CALLCONV is related to U_EXPORT2 */
-#ifdef U_EXPORT2
- /* Use the predefined value. */
-#elif defined(_MSC_VER)
-# define U_EXPORT2 __cdecl
-#else
-# define U_EXPORT2
-#endif
-
-#ifdef U_IMPORT
- /* Use the predefined value. */
-#elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllexport__) && \
- UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllimport__))
- /* Windows needs to export/import data. */
-# define U_IMPORT __declspec(dllimport)
-#else
-# define U_IMPORT
-#endif
-
-/**
- * \def U_HIDDEN
- * This is used to mark internal structs declared within external classes,
- * to prevent the internal structs from having the same visibility as the
- * class within which they are declared.
- * @internal
- */
-#ifdef U_HIDDEN
- /* Use the predefined value. */
-#elif defined(__GNUC__)
-# define U_HIDDEN __attribute__((visibility("hidden")))
-#else
-# define U_HIDDEN
-#endif
-
-/**
- * \def U_CALLCONV
- * Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary
- * in callback function typedefs to make sure that the calling convention
- * is compatible.
- *
- * This is only used for non-ICU-API functions.
- * When a function is a public ICU API,
- * you must use the U_CAPI and U_EXPORT2 qualifiers.
- *
- * Please note, you need to use U_CALLCONV after the *.
- *
- * NO : "static const char U_CALLCONV *func( . . . )"
- * YES: "static const char* U_CALLCONV func( . . . )"
- *
- * @stable ICU 2.0
- */
-#if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
-# define U_CALLCONV __cdecl
-#else
-# define U_CALLCONV U_EXPORT2
-#endif
-
-/**
- * \def U_CALLCONV_FPTR
- * Similar to U_CALLCONV, but only used on function pointers.
- * @internal
- */
-#if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
-# define U_CALLCONV_FPTR U_CALLCONV
-#else
-# define U_CALLCONV_FPTR
-#endif
-/** @} */
-
-#endif // _PLATFORM_H
diff --git a/tools/icu/patches/75/source/tools/genccode/genccode.c b/tools/icu/patches/75/source/tools/genccode/genccode.c
deleted file mode 100644
index 0f243952a7d..00000000000
--- a/tools/icu/patches/75/source/tools/genccode/genccode.c
+++ /dev/null
@@ -1,226 +0,0 @@
-// © 2016 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-/*
- *******************************************************************************
- * Copyright (C) 1999-2016, International Business Machines
- * Corporation and others. All Rights Reserved.
- *******************************************************************************
- * file name: gennames.c
- * encoding: UTF-8
- * tab size: 8 (not used)
- * indentation:4
- *
- * created on: 1999nov01
- * created by: Markus W. Scherer
- *
- * This program reads a binary file and creates a C source code file
- * with a byte array that contains the data of the binary file.
- *
- * 12/09/1999 weiv Added multiple file handling
- */
-
-#include "unicode/utypes.h"
-
-#if U_PLATFORM_HAS_WIN32_API
-# define VC_EXTRALEAN
-# define WIN32_LEAN_AND_MEAN
-# define NOUSER
-# define NOSERVICE
-# define NOIME
-# define NOMCX
-#include
-#include
-#endif
-
-#if U_PLATFORM_IS_LINUX_BASED && U_HAVE_ELF_H
-# define U_ELF
-#endif
-
-#ifdef U_ELF
-# include
-# if defined(ELFCLASS64)
-# define U_ELF64
-# endif
- /* Old elf.h headers may not have EM_X86_64, or have EM_X8664 instead. */
-# ifndef EM_X86_64
-# define EM_X86_64 62
-# endif
-# define ICU_ENTRY_OFFSET 0
-#endif
-
-#include
-#include
-#include
-#include "unicode/putil.h"
-#include "cmemory.h"
-#include "cstring.h"
-#include "filestrm.h"
-#include "toolutil.h"
-#include "unicode/uclean.h"
-#include "uoptions.h"
-#include "pkg_genc.h"
-
-enum {
- kOptHelpH = 0,
- kOptHelpQuestionMark,
- kOptDestDir,
- kOptQuiet,
- kOptName,
- kOptEntryPoint,
-#ifdef CAN_GENERATE_OBJECTS
- kOptObject,
- kOptMatchArch,
- kOptCpuArch,
- kOptSkipDllExport,
-#endif
- kOptFilename,
- kOptAssembly
-};
-
-static UOption options[]={
-/*0*/UOPTION_HELP_H,
- UOPTION_HELP_QUESTION_MARK,
- UOPTION_DESTDIR,
- UOPTION_QUIET,
- UOPTION_DEF("name", 'n', UOPT_REQUIRES_ARG),
- UOPTION_DEF("entrypoint", 'e', UOPT_REQUIRES_ARG),
-#ifdef CAN_GENERATE_OBJECTS
-/*6*/UOPTION_DEF("object", 'o', UOPT_NO_ARG),
- UOPTION_DEF("match-arch", 'm', UOPT_REQUIRES_ARG),
- UOPTION_DEF("cpu-arch", 'c', UOPT_REQUIRES_ARG),
- UOPTION_DEF("skip-dll-export", '\0', UOPT_NO_ARG),
-#endif
- UOPTION_DEF("filename", 'f', UOPT_REQUIRES_ARG),
- UOPTION_DEF("assembly", 'a', UOPT_REQUIRES_ARG)
-};
-
-#define CALL_WRITECCODE 'c'
-#define CALL_WRITEASSEMBLY 'a'
-#define CALL_WRITEOBJECT 'o'
-extern int
-main(int argc, char* argv[]) {
- UBool verbose = true;
- char writeCode;
-
- U_MAIN_INIT_ARGS(argc, argv);
-
- options[kOptDestDir].value = ".";
-
- /* read command line options */
- argc=u_parseArgs(argc, argv, UPRV_LENGTHOF(options), options);
-
- /* error handling, printing usage message */
- if(argc<0) {
- fprintf(stderr,
- "error in command line argument \"%s\"\n",
- argv[-argc]);
- }
- if(argc<0 || options[kOptHelpH].doesOccur || options[kOptHelpQuestionMark].doesOccur) {
- fprintf(stderr,
- "usage: %s [-options] filename1 filename2 ...\n"
- "\tread each binary input file and \n"
- "\tcreate a .c file with a byte array that contains the input file's data\n"
- "options:\n"
- "\t-h or -? or --help this usage text\n"
- "\t-d or --destdir destination directory, followed by the path\n"
- "\t-q or --quiet do not display warnings and progress\n"
- "\t-n or --name symbol prefix, followed by the prefix\n"
- "\t-e or --entrypoint entry point name, followed by the name (_dat will be appended)\n"
- "\t-r or --revision Specify a version\n"
- , argv[0]);
-#ifdef CAN_GENERATE_OBJECTS
- fprintf(stderr,
- "\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"
- "\t-c or --cpu-arch Specify a CPU architecture for which to write a .obj file for ClangCL on Windows\n"
- "\t Valid values for this opton are x64, x86 and arm64.\n"
- "\t--skip-dll-export Don't export the ICU data entry point symbol (for use when statically linking)\n");
-#endif
- fprintf(stderr,
- "\t-f or --filename Specify an alternate base filename. (default: symbolname_typ)\n"
- "\t-a or --assembly Create assembly file. (possible values are: ");
-
- printAssemblyHeadersToStdErr();
- } else {
- const char *message, *filename;
- /* TODO: remove void (*writeCode)(const char *, const char *); */
-
- if(options[kOptAssembly].doesOccur) {
- message="generating assembly code for %s\n";
- writeCode = CALL_WRITEASSEMBLY;
- /* TODO: remove writeCode=&writeAssemblyCode; */
-
- if (!checkAssemblyHeaderName(options[kOptAssembly].value)) {
- fprintf(stderr,
- "Assembly type \"%s\" is unknown.\n", options[kOptAssembly].value);
- return -1;
- }
- }
-#ifdef CAN_GENERATE_OBJECTS
- else if(options[kOptObject].doesOccur) {
- message="generating object code for %s\n";
- writeCode = CALL_WRITEOBJECT;
- /* TODO: remove writeCode=&writeObjectCode; */
- }
-#endif
- else
- {
- message="generating C code for %s\n";
- writeCode = CALL_WRITECCODE;
- /* TODO: remove writeCode=&writeCCode; */
- }
- if (options[kOptQuiet].doesOccur) {
- verbose = false;
- }
- while(--argc) {
- filename=getLongPathname(argv[argc]);
- if (verbose) {
- fprintf(stdout, message, filename);
- }
-
- switch (writeCode) {
- case CALL_WRITECCODE:
- writeCCode(filename, options[kOptDestDir].value,
- options[kOptEntryPoint].doesOccur ? options[kOptEntryPoint].value : NULL,
- options[kOptName].doesOccur ? options[kOptName].value : NULL,
- options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL,
- NULL,
- 0);
- break;
- case CALL_WRITEASSEMBLY:
- writeAssemblyCode(filename, options[kOptDestDir].value,
- options[kOptEntryPoint].doesOccur ? options[kOptEntryPoint].value : NULL,
- options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL,
- NULL,
- 0);
- break;
-#ifdef CAN_GENERATE_OBJECTS
- case CALL_WRITEOBJECT:
- if(options[kOptCpuArch].doesOccur) {
- if (!checkCpuArchitecture(options[kOptCpuArch].value)) {
- fprintf(stderr,
- "CPU architecture \"%s\" is unknown.\n", options[kOptCpuArch].value);
- return -1;
- }
- }
- writeObjectCode(filename, options[kOptDestDir].value,
- options[kOptEntryPoint].doesOccur ? options[kOptEntryPoint].value : NULL,
- options[kOptMatchArch].doesOccur ? options[kOptMatchArch].value : NULL,
- options[kOptCpuArch].doesOccur ? options[kOptCpuArch].value : NULL,
- options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL,
- NULL,
- 0,
- !options[kOptSkipDllExport].doesOccur);
- break;
-#endif
- default:
- /* Should never occur. */
- break;
- }
- /* TODO: remove writeCode(filename, options[kOptDestDir].value); */
- }
- }
-
- return 0;
-}
diff --git a/tools/icu/patches/75/source/tools/genccode/pkg_genc.h b/tools/icu/patches/75/source/tools/genccode/pkg_genc.h
deleted file mode 100644
index 76474ec7df6..00000000000
--- a/tools/icu/patches/75/source/tools/genccode/pkg_genc.h
+++ /dev/null
@@ -1,111 +0,0 @@
-// © 2016 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-/******************************************************************************
- * Copyright (C) 2008-2011, International Business Machines
- * Corporation and others. All Rights Reserved.
- *******************************************************************************
- */
-
-#ifndef __PKG_GENC_H__
-#define __PKG_GENC_H__
-
-#include "unicode/utypes.h"
-#include "toolutil.h"
-
-#include "unicode/putil.h"
-#include "putilimp.h"
-
-/*** Platform #defines move here ***/
-#if U_PLATFORM_HAS_WIN32_API
-#ifdef __GNUC__
-#define WINDOWS_WITH_GNUC
-#else
-#define WINDOWS_WITH_MSVC
-#endif
-#endif
-
-
-#if !defined(WINDOWS_WITH_MSVC)
-#define BUILD_DATA_WITHOUT_ASSEMBLY
-#endif
-
-#ifndef U_DISABLE_OBJ_CODE /* testing */
-#if defined(WINDOWS_WITH_MSVC) || U_PLATFORM_IS_LINUX_BASED
-#define CAN_WRITE_OBJ_CODE
-#endif
-#if U_PLATFORM_HAS_WIN32_API || defined(U_ELF)
-#define CAN_GENERATE_OBJECTS
-#endif
-#endif
-
-#if U_PLATFORM == U_PF_CYGWIN || defined(CYGWINMSVC)
-#define USING_CYGWIN
-#endif
-
-/*
- * When building the data library without assembly,
- * some platforms use a single c code file for all of
- * the data to generate the final data library. This can
- * increase the performance of the pkdata tool.
- */
-#if U_PLATFORM == U_PF_OS400
-#define USE_SINGLE_CCODE_FILE
-#endif
-
-/* Need to fix the file seperator character when using MinGW. */
-#if defined(WINDOWS_WITH_GNUC) || defined(USING_CYGWIN)
-#define PKGDATA_FILE_SEP_STRING "/"
-#else
-#define PKGDATA_FILE_SEP_STRING U_FILE_SEP_STRING
-#endif
-
-#define LARGE_BUFFER_MAX_SIZE 2048
-#define SMALL_BUFFER_MAX_SIZE 512
-#define SMALL_BUFFER_FLAG_NAMES 32
-#define BUFFER_PADDING_SIZE 20
-
-/** End platform defines **/
-
-
-
-U_CAPI void U_EXPORT2
-printAssemblyHeadersToStdErr(void);
-
-U_CAPI UBool U_EXPORT2
-checkAssemblyHeaderName(const char* optAssembly);
-
-U_CAPI UBool U_EXPORT2
-checkCpuArchitecture(const char* optCpuArch);
-
-U_CAPI void U_EXPORT2
-writeCCode(
- const char *filename,
- const char *destdir,
- const char *optEntryPoint,
- const char *optName,
- const char *optFilename,
- char *outFilePath,
- size_t outFilePathCapacity);
-
-U_CAPI void U_EXPORT2
-writeAssemblyCode(
- const char *filename,
- const char *destdir,
- const char *optEntryPoint,
- const char *optFilename,
- char *outFilePath,
- size_t outFilePathCapacity);
-
-U_CAPI void U_EXPORT2
-writeObjectCode(
- const char *filename,
- const char *destdir,
- const char *optEntryPoint,
- const char *optMatchArch,
- const char *optCpuArch,
- const char *optFilename,
- char *outFilePath,
- size_t outFilePathCapacity,
- UBool optWinDllExport);
-
-#endif
diff --git a/tools/icu/patches/75/source/tools/pkgdata/pkgdata.cpp b/tools/icu/patches/75/source/tools/pkgdata/pkgdata.cpp
deleted file mode 100644
index 51452a51bb3..00000000000
--- a/tools/icu/patches/75/source/tools/pkgdata/pkgdata.cpp
+++ /dev/null
@@ -1,2292 +0,0 @@
-// © 2016 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-/******************************************************************************
- * Copyright (C) 2000-2016, International Business Machines
- * Corporation and others. All Rights Reserved.
- *******************************************************************************
- * file name: pkgdata.cpp
- * encoding: ANSI X3.4 (1968)
- * tab size: 8 (not used)
- * indentation:4
- *
- * created on: 2000may15
- * created by: Steven \u24C7 Loomis
- *
- * This program packages the ICU data into different forms
- * (DLL, common data, etc.)
- */
-
-// Defines _XOPEN_SOURCE for access to POSIX functions.
-// Must be before any other #includes.
-#include "uposixdefs.h"
-
-#include "unicode/utypes.h"
-
-#include "unicode/putil.h"
-#include "putilimp.h"
-
-#if U_HAVE_POPEN
-#if (U_PF_MINGW <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN) && defined(__STRICT_ANSI__)
-/* popen/pclose aren't defined in strict ANSI on Cygwin and MinGW */
-#undef __STRICT_ANSI__
-#endif
-#endif
-
-#include "cmemory.h"
-#include "cstring.h"
-#include "filestrm.h"
-#include "toolutil.h"
-#include "unicode/uclean.h"
-#include "unewdata.h"
-#include "uoptions.h"
-#include "package.h"
-#include "pkg_icu.h"
-#include "pkg_genc.h"
-#include "pkg_gencmn.h"
-#include "flagparser.h"
-#include "filetools.h"
-#include "charstr.h"
-#include "uassert.h"
-
-#if U_HAVE_POPEN
-# include
-#endif
-
-#include
-#include
-
-U_CDECL_BEGIN
-#include "pkgtypes.h"
-U_CDECL_END
-
-#if U_HAVE_POPEN
-U_NAMESPACE_BEGIN
-U_DEFINE_LOCAL_OPEN_POINTER(LocalPipeFilePointer, FILE, pclose);
-U_NAMESPACE_END
-#endif
-
-using icu::LocalMemory;
-
-static void loadLists(UPKGOptions *o, UErrorCode *status);
-
-static int32_t pkg_executeOptions(UPKGOptions *o);
-
-#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, UBool specialHandling=false);
-static int32_t pkg_installLibrary(const char *installDir, const char *dir, UBool noVersion);
-static int32_t pkg_installFileMode(const char *installDir, const char *srcDir, const char *fileListName);
-static int32_t pkg_installCommonMode(const char *installDir, const char *fileName);
-
-#ifdef BUILD_DATA_WITHOUT_ASSEMBLY
-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 = nullptr, UBool specialHandling=false);
-static int32_t pkg_archiveLibrary(const char *targetDir, const char *version, UBool reverseExt);
-static void createFileNames(UPKGOptions *o, const char mode, const char *version_major, const char *version, const char *libName, const UBool reverseExt, UBool noVersion);
-static int32_t initializePkgDataFlags(UPKGOptions *o);
-
-static int32_t pkg_getPkgDataPath(UBool verbose, UOption *option);
-static int runCommand(const char* command, UBool specialHandling=false);
-
-#define IN_COMMON_MODE(mode) (mode == 'a' || mode == 'c')
-#define IN_DLL_MODE(mode) (mode == 'd' || mode == 'l')
-#define IN_STATIC_MODE(mode) (mode == 's')
-#define IN_FILES_MODE(mode) (mode == 'f')
-
-enum {
- NAME,
- BLDOPT,
- MODE,
- HELP,
- HELP_QUESTION_MARK,
- VERBOSE,
- COPYRIGHT,
- COMMENT,
- DESTDIR,
- REBUILD,
- TEMPDIR,
- INSTALL,
- SOURCEDIR,
- ENTRYPOINT,
- REVISION,
- FORCE_PREFIX,
- LIBNAME,
- QUIET,
- WITHOUT_ASSEMBLY,
- PDS_BUILD,
- WIN_UWP_BUILD,
- WIN_DLL_ARCH,
- WIN_DYNAMICBASE
-};
-
-/* This sets the modes that are available */
-static struct {
- const char *name, *alt_name;
- const char *desc;
-} modes[] = {
- { "files", nullptr, "Uses raw data files (no effect). Installation copies all files to the target location." },
-#if U_PLATFORM_HAS_WIN32_API
- { "dll", "library", "Generates one common data file and one shared library, .dll"},
- { "common", "archive", "Generates just the common file, .dat"},
- { "static", "static", "Generates one statically linked library, " LIB_PREFIX "" UDATA_LIB_SUFFIX }
-#else
-#ifdef UDATA_SO_SUFFIX
- { "dll", "library", "Generates one shared library, " UDATA_SO_SUFFIX },
-#endif
- { "common", "archive", "Generates one common data file, .dat" },
- { "static", "static", "Generates one statically linked library, " LIB_PREFIX "" UDATA_LIB_SUFFIX }
-#endif
-};
-
-static UOption options[]={
- /*00*/ UOPTION_DEF( "name", 'p', UOPT_REQUIRES_ARG),
- /*01*/ UOPTION_DEF( "bldopt", 'O', UOPT_REQUIRES_ARG), /* on Win32 it is release or debug */
- /*02*/ UOPTION_DEF( "mode", 'm', UOPT_REQUIRES_ARG),
- /*03*/ UOPTION_HELP_H, /* -h */
- /*04*/ UOPTION_HELP_QUESTION_MARK, /* -? */
- /*05*/ UOPTION_VERBOSE, /* -v */
- /*06*/ UOPTION_COPYRIGHT, /* -c */
- /*07*/ UOPTION_DEF( "comment", 'C', UOPT_REQUIRES_ARG),
- /*08*/ UOPTION_DESTDIR, /* -d */
- /*11*/ UOPTION_DEF( "rebuild", 'F', UOPT_NO_ARG),
- /*12*/ UOPTION_DEF( "tempdir", 'T', UOPT_REQUIRES_ARG),
- /*13*/ UOPTION_DEF( "install", 'I', UOPT_REQUIRES_ARG),
- /*14*/ UOPTION_SOURCEDIR ,
- /*15*/ UOPTION_DEF( "entrypoint", 'e', UOPT_REQUIRES_ARG),
- /*16*/ UOPTION_DEF( "revision", 'r', UOPT_REQUIRES_ARG),
- /*17*/ UOPTION_DEF( "force-prefix", 'f', UOPT_NO_ARG),
- /*18*/ UOPTION_DEF( "libname", 'L', UOPT_REQUIRES_ARG),
- /*19*/ UOPTION_DEF( "quiet", 'q', UOPT_NO_ARG),
- /*20*/ UOPTION_DEF( "without-assembly", 'w', UOPT_NO_ARG),
- /*21*/ UOPTION_DEF("zos-pds-build", 'z', UOPT_NO_ARG),
- /*22*/ UOPTION_DEF("windows-uwp-build", 'u', UOPT_NO_ARG),
- /*23*/ UOPTION_DEF("windows-DLL-arch", 'a', UOPT_REQUIRES_ARG),
- /*24*/ UOPTION_DEF("windows-dynamicbase", 'b', UOPT_NO_ARG),
-};
-
-/* This enum and the following char array should be kept in sync. */
-enum {
- GENCCODE_ASSEMBLY_TYPE,
- SO_EXT,
- SOBJ_EXT,
- A_EXT,
- LIBPREFIX,
- LIB_EXT_ORDER,
- COMPILER,
- LIBFLAGS,
- GENLIB,
- LDICUDTFLAGS,
- LD_SONAME,
- RPATH_FLAGS,
- BIR_FLAGS,
- AR,
- ARFLAGS,
- RANLIB,
- INSTALL_CMD,
- PKGDATA_FLAGS_SIZE
-};
-static const char* FLAG_NAMES[PKGDATA_FLAGS_SIZE] = {
- "GENCCODE_ASSEMBLY_TYPE",
- "SO",
- "SOBJ",
- "A",
- "LIBPREFIX",
- "LIB_EXT_ORDER",
- "COMPILE",
- "LIBFLAGS",
- "GENLIB",
- "LDICUDTFLAGS",
- "LD_SONAME",
- "RPATH_FLAGS",
- "BIR_LDFLAGS",
- "AR",
- "ARFLAGS",
- "RANLIB",
- "INSTALL_CMD"
-};
-static char **pkgDataFlags = nullptr;
-
-enum {
- LIB_FILE,
- LIB_FILE_VERSION_MAJOR,
- LIB_FILE_VERSION,
- LIB_FILE_VERSION_TMP,
-#if U_PLATFORM == U_PF_CYGWIN
- LIB_FILE_CYGWIN,
- LIB_FILE_CYGWIN_VERSION,
-#elif U_PLATFORM == U_PF_MINGW
- LIB_FILE_MINGW,
-#elif U_PLATFORM == U_PF_OS390
- LIB_FILE_OS390BATCH_MAJOR,
- LIB_FILE_OS390BATCH_VERSION,
-#endif
- LIB_FILENAMES_SIZE
-};
-static char libFileNames[LIB_FILENAMES_SIZE][256];
-
-static UPKGOptions *pkg_checkFlag(UPKGOptions *o);
-
-const char options_help[][320]={
- "Set the data name",
-#ifdef U_MAKE_IS_NMAKE
- "The directory where the ICU is located (e.g. which contains the bin directory)",
-#else
- "Specify options for the builder.",
-#endif
- "Specify the mode of building (see below; default: common)",
- "This usage text",
- "This usage text",
- "Make the output verbose",
- "Use the standard ICU copyright",
- "Use a custom comment (instead of the copyright)",
- "Specify the destination directory for files",
- "Force rebuilding of all data",
- "Specify temporary dir (default: output dir)",
- "Install the data (specify target)",
- "Specify a custom source directory",
- "Specify a custom entrypoint name (default: short name)",
- "Specify a version when packaging in dll or static mode",
- "Add package to all file names if not present",
- "Library name to build (if different than package name)",
- "Quiet mode. (e.g. Do not output a readme file for static libraries)",
- "Build the data without assembly code",
- "Build PDS dataset (zOS build only)",
- "Build for Universal Windows Platform (Windows build only)",
- "Specify the DLL machine architecture for LINK.exe (Windows build only)",
- "Ignored. Enable DYNAMICBASE on the DLL. This is now the default. (Windows build only)",
-};
-
-const char *progname = "PKGDATA";
-
-int
-main(int argc, char* argv[]) {
- int result = 0;
- /* FileStream *out; */
- UPKGOptions o;
- CharList *tail;
- UBool needsHelp = false;
- UErrorCode status = U_ZERO_ERROR;
- /* char tmp[1024]; */
- uint32_t i;
- int32_t n;
-
- U_MAIN_INIT_ARGS(argc, argv);
-
- progname = argv[0];
-
- options[MODE].value = "common";
-
- /* read command line options */
- argc=u_parseArgs(argc, argv, UPRV_LENGTHOF(options), options);
-
- /* error handling, printing usage message */
- /* I've decided to simply print an error and quit. This tool has too
- many options to just display them all of the time. */
-
- if(options[HELP].doesOccur || options[HELP_QUESTION_MARK].doesOccur) {
- needsHelp = true;
- }
- else {
- if(!needsHelp && argc<0) {
- fprintf(stderr,
- "%s: error in command line argument \"%s\"\n",
- progname,
- argv[-argc]);
- fprintf(stderr, "Run '%s --help' for help.\n", progname);
- return 1;
- }
-
-
-#if !defined(WINDOWS_WITH_MSVC) || defined(USING_CYGWIN)
- if(!options[BLDOPT].doesOccur && uprv_strcmp(options[MODE].value, "common") != 0) {
- if (pkg_getPkgDataPath(options[VERBOSE].doesOccur, &options[BLDOPT]) != 0) {
- fprintf(stderr, " required parameter is missing: -O is required for static and shared builds.\n");
- fprintf(stderr, "Run '%s --help' for help.\n", progname);
- return 1;
- }
- }
-#else
- if(options[BLDOPT].doesOccur) {
- fprintf(stdout, "Warning: You are using the -O option which is not needed for MSVC build on Windows.\n");
- }
-#endif
-
- if(!options[NAME].doesOccur) /* -O we already have - don't report it. */
- {
- fprintf(stderr, " required parameter -p is missing \n");
- fprintf(stderr, "Run '%s --help' for help.\n", progname);
- return 1;
- }
-
- if(argc == 1) {
- fprintf(stderr,
- "No input files specified.\n"
- "Run '%s --help' for help.\n", progname);
- return 1;
- }
- } /* end !needsHelp */
-
- if(argc<0 || needsHelp ) {
- fprintf(stderr,
- "usage: %s [-options] [-] [packageFile] \n"
- "\tProduce packaged ICU data from the given list(s) of files.\n"
- "\t'-' by itself means to read from stdin.\n"
- "\tpackageFile is a text file containing the list of files to package.\n",
- progname);
-
- fprintf(stderr, "\n options:\n");
- for(i=0;i(strlen(command));
-
- if (len == 0) {
- return 0;
- }
-
- if (!specialHandling) {
-#if defined(USING_CYGWIN) || U_PLATFORM == U_PF_MINGW || U_PLATFORM == U_PF_OS400
- int32_t buff_len;
- if ((len + BUFFER_PADDING_SIZE) >= SMALL_BUFFER_MAX_SIZE) {
- cmd = (char *)uprv_malloc(len + BUFFER_PADDING_SIZE);
- buff_len = len + BUFFER_PADDING_SIZE;
- } else {
- cmd = cmdBuffer;
- buff_len = SMALL_BUFFER_MAX_SIZE;
- }
-#if defined(USING_CYGWIN) || U_PLATFORM == U_PF_MINGW
- snprintf(cmd, buff_len, "bash -c \"%s\"", command);
-
-#elif U_PLATFORM == U_PF_OS400
- snprintf(cmd, buff_len "QSH CMD('%s')", command);
-#endif
-#else
- goto normal_command_mode;
-#endif
- } else {
-#if !(defined(USING_CYGWIN) || U_PLATFORM == U_PF_MINGW || U_PLATFORM == U_PF_OS400)
-normal_command_mode:
-#endif
- cmd = (char *)command;
- }
-
- printf("pkgdata: %s\n", cmd);
- int result = system(cmd);
- if (result != 0) {
- fprintf(stderr, "-- return status = %d\n", result);
- result = 1; // system() result code is platform specific.
- }
-
- if (cmd != cmdBuffer && cmd != command) {
- uprv_free(cmd);
- }
-
- return result;
-}
-
-#define LN_CMD "ln -s"
-#define RM_CMD "rm -f"
-
-static int32_t pkg_executeOptions(UPKGOptions *o) {
- int32_t result = 0;
-
- const char mode = o->mode[0];
- char targetDir[SMALL_BUFFER_MAX_SIZE] = "";
- char tmpDir[SMALL_BUFFER_MAX_SIZE] = "";
- char datFileName[SMALL_BUFFER_MAX_SIZE] = "";
- char datFileNamePath[LARGE_BUFFER_MAX_SIZE] = "";
- char checkLibFile[LARGE_BUFFER_MAX_SIZE] = "";
-
- initializePkgDataFlags(o);
-
- if (IN_FILES_MODE(mode)) {
- /* Copy the raw data to the installation directory. */
- if (o->install != nullptr) {
- uprv_strcpy(targetDir, o->install);
- if (o->shortName != nullptr) {
- uprv_strcat(targetDir, PKGDATA_FILE_SEP_STRING);
- uprv_strcat(targetDir, o->shortName);
- }
-
- if(o->verbose) {
- fprintf(stdout, "# Install: Files mode, copying files to %s..\n", targetDir);
- }
- result = pkg_installFileMode(targetDir, o->srcDir, o->fileListFiles->str);
- }
- return result;
- } else /* if (IN_COMMON_MODE(mode) || IN_DLL_MODE(mode) || IN_STATIC_MODE(mode)) */ {
- UBool noVersion = false;
-
- uprv_strcpy(targetDir, o->targetDir);
- uprv_strcat(targetDir, PKGDATA_FILE_SEP_STRING);
-
- uprv_strcpy(tmpDir, o->tmpDir);
- uprv_strcat(tmpDir, PKGDATA_FILE_SEP_STRING);
-
- uprv_strcpy(datFileNamePath, tmpDir);
-
- uprv_strcpy(datFileName, o->shortName);
- uprv_strcat(datFileName, UDATA_CMN_SUFFIX);
-
- uprv_strcat(datFileNamePath, datFileName);
-
- if(o->verbose) {
- fprintf(stdout, "# Writing package file %s ..\n", datFileNamePath);
- }
- result = writePackageDatFile(datFileNamePath, o->comment, o->srcDir, o->fileListFiles->str, nullptr, U_CHARSET_FAMILY ? 'e' : U_IS_BIG_ENDIAN ? 'b' : 'l');
- if (result != 0) {
- fprintf(stderr,"Error writing package dat file.\n");
- return result;
- }
-
- if (IN_COMMON_MODE(mode)) {
- char targetFileNamePath[LARGE_BUFFER_MAX_SIZE] = "";
-
- uprv_strcpy(targetFileNamePath, targetDir);
- uprv_strcat(targetFileNamePath, datFileName);
-
- /* Move the dat file created to the target directory. */
- if (uprv_strcmp(datFileNamePath, targetFileNamePath) != 0) {
- if (T_FileStream_file_exists(targetFileNamePath)) {
- if ((result = remove(targetFileNamePath)) != 0) {
- fprintf(stderr, "Unable to remove old dat file: %s\n",
- targetFileNamePath);
- return result;
- }
- }
-
- result = rename(datFileNamePath, targetFileNamePath);
-
- if (o->verbose) {
- fprintf(stdout, "# Moving package file to %s ..\n",
- targetFileNamePath);
- }
- if (result != 0) {
- fprintf(
- stderr,
- "Unable to move dat file (%s) to target location (%s).\n",
- datFileNamePath, targetFileNamePath);
- return result;
- }
- }
-
- if (o->install != nullptr) {
- result = pkg_installCommonMode(o->install, targetFileNamePath);
- }
-
- return result;
- } else /* if (IN_STATIC_MODE(mode) || IN_DLL_MODE(mode)) */ {
- char gencFilePath[SMALL_BUFFER_MAX_SIZE] = "";
- char version_major[10] = "";
- UBool reverseExt = false;
-
-#if !defined(WINDOWS_WITH_MSVC) || defined(USING_CYGWIN)
- /* Get the version major number. */
- if (o->version != nullptr) {
- for (uint32_t i = 0;i < sizeof(version_major);i++) {
- if (o->version[i] == '.') {
- version_major[i] = 0;
- break;
- }
- version_major[i] = o->version[i];
- }
- } else {
- noVersion = true;
- if (IN_DLL_MODE(mode)) {
- fprintf(stdout, "Warning: Providing a revision number with the -r option is recommended when packaging data in the current mode.\n");
- }
- }
-
-#if U_PLATFORM != U_PF_OS400
- /* Certain platforms have different library extension ordering. (e.g. libicudata.##.so vs libicudata.so.##)
- * reverseExt is false if the suffix should be the version number.
- */
- if (pkgDataFlags[LIB_EXT_ORDER][uprv_strlen(pkgDataFlags[LIB_EXT_ORDER])-1] == pkgDataFlags[SO_EXT][uprv_strlen(pkgDataFlags[SO_EXT])-1]) {
- reverseExt = true;
- }
-#endif
- /* Using the base libName and version number, generate the library file names. */
- createFileNames(o, mode, version_major, o->version == nullptr ? "" : o->version, o->libName, reverseExt, noVersion);
-
- if ((o->version!=nullptr || IN_STATIC_MODE(mode)) && o->rebuild == false && o->pdsbuild == false) {
- /* Check to see if a previous built data library file exists and check if it is the latest. */
- snprintf(checkLibFile, sizeof(checkLibFile), "%s%s", targetDir, libFileNames[LIB_FILE_VERSION]);
- if (T_FileStream_file_exists(checkLibFile)) {
- if (isFileModTimeLater(checkLibFile, o->srcDir, true) && isFileModTimeLater(checkLibFile, o->options)) {
- if (o->install != nullptr) {
- if(o->verbose) {
- fprintf(stdout, "# Installing already-built library into %s\n", o->install);
- }
- result = pkg_installLibrary(o->install, targetDir, noVersion);
- } else {
- if(o->verbose) {
- printf("# Not rebuilding %s - up to date.\n", checkLibFile);
- }
- }
- return result;
- } else if (o->verbose && (o->install!=nullptr)) {
- fprintf(stdout, "# Not installing up-to-date library %s into %s\n", checkLibFile, o->install);
- }
- } else if(o->verbose && (o->install!=nullptr)) {
- fprintf(stdout, "# Not installing missing %s into %s\n", checkLibFile, o->install);
- }
- }
-
- if (pkg_checkFlag(o) == nullptr) {
- /* Error occurred. */
- return result;
- }
-#endif
-
- if (!o->withoutAssembly && pkgDataFlags[GENCCODE_ASSEMBLY_TYPE][0] != 0) {
- const char* genccodeAssembly = pkgDataFlags[GENCCODE_ASSEMBLY_TYPE];
-
- if(o->verbose) {
- fprintf(stdout, "# Generating assembly code %s of type %s ..\n", gencFilePath, genccodeAssembly);
- }
-
- /* Offset genccodeAssembly by 3 because "-a " */
- if (genccodeAssembly &&
- (uprv_strlen(genccodeAssembly)>3) &&
- checkAssemblyHeaderName(genccodeAssembly+3)) {
- writeAssemblyCode(
- datFileNamePath,
- o->tmpDir,
- o->entryName,
- nullptr,
- gencFilePath,
- sizeof(gencFilePath));
-
- result = pkg_createWithAssemblyCode(targetDir, mode, gencFilePath);
- if (result != 0) {
- fprintf(stderr, "Error generating assembly code for data.\n");
- return result;
- } else if (IN_STATIC_MODE(mode)) {
- if(o->install != nullptr) {
- if(o->verbose) {
- fprintf(stdout, "# Installing static library into %s\n", o->install);
- }
- result = pkg_installLibrary(o->install, targetDir, noVersion);
- }
- return result;
- }
- } else {
- fprintf(stderr,"Assembly type \"%s\" is unknown.\n", genccodeAssembly);
- return -1;
- }
- } else {
- if(o->verbose) {
- fprintf(stdout, "# Writing object code to %s ..\n", gencFilePath);
- }
- if (o->withoutAssembly) {
-#ifdef BUILD_DATA_WITHOUT_ASSEMBLY
- result = pkg_createWithoutAssemblyCode(o, targetDir, mode);
-#else
- /* This error should not occur. */
- fprintf(stderr, "Error- BUILD_DATA_WITHOUT_ASSEMBLY is not defined. Internal error.\n");
-#endif
- } else {
-#ifdef CAN_WRITE_OBJ_CODE
- /* Try to detect the arch type, use nullptr if unsuccessful */
- char optMatchArch[10] = { 0 };
- pkg_createOptMatchArch(optMatchArch);
- writeObjectCode(
- datFileNamePath,
- o->tmpDir,
- o->entryName,
- (optMatchArch[0] == 0 ? nullptr : optMatchArch),
- nullptr,
- nullptr,
- gencFilePath,
- sizeof(gencFilePath),
- true);
- pkg_destroyOptMatchArch(optMatchArch);
-#if U_PLATFORM_IS_LINUX_BASED
- result = pkg_generateLibraryFile(targetDir, mode, gencFilePath);
-#elif defined(WINDOWS_WITH_MSVC)
- result = pkg_createWindowsDLL(mode, gencFilePath, o);
-#endif
-#elif defined(BUILD_DATA_WITHOUT_ASSEMBLY)
- result = pkg_createWithoutAssemblyCode(o, targetDir, mode);
-#else
- fprintf(stderr, "Error- neither CAN_WRITE_OBJ_CODE nor BUILD_DATA_WITHOUT_ASSEMBLY are defined. Internal error.\n");
- return 1;
-#endif
- }
-
- if (result != 0) {
- fprintf(stderr, "Error generating package data.\n");
- return result;
- }
- }
-#if !U_PLATFORM_USES_ONLY_WIN32_API
- if(!IN_STATIC_MODE(mode)) {
- /* Certain platforms uses archive library. (e.g. AIX) */
- if(o->verbose) {
- fprintf(stdout, "# Creating data archive library file ..\n");
- }
- result = pkg_archiveLibrary(targetDir, o->version, reverseExt);
- if (result != 0) {
- fprintf(stderr, "Error creating data archive library file.\n");
- return result;
- }
-#if U_PLATFORM != U_PF_OS400
- if (!noVersion) {
- /* Create symbolic links for the final library file. */
-#if U_PLATFORM == U_PF_OS390
- result = pkg_createSymLinks(targetDir, o->pdsbuild);
-#else
- result = pkg_createSymLinks(targetDir, noVersion);
-#endif
- if (result != 0) {
- fprintf(stderr, "Error creating symbolic links of the data library file.\n");
- return result;
- }
- }
-#endif
- } /* !IN_STATIC_MODE */
-#endif
-
-#if !U_PLATFORM_USES_ONLY_WIN32_API
- /* Install the libraries if option was set. */
- if (o->install != nullptr) {
- if(o->verbose) {
- fprintf(stdout, "# Installing library file to %s ..\n", o->install);
- }
- result = pkg_installLibrary(o->install, targetDir, noVersion);
- if (result != 0) {
- fprintf(stderr, "Error installing the data library.\n");
- return result;
- }
- }
-#endif
- }
- }
- return result;
-}
-
-/* Initialize the pkgDataFlags with the option file given. */
-static int32_t initializePkgDataFlags(UPKGOptions *o) {
- UErrorCode status = U_ZERO_ERROR;
- int32_t result = 0;
- int32_t currentBufferSize = SMALL_BUFFER_MAX_SIZE;
- int32_t tmpResult = 0;
-
- /* Initialize pkgdataFlags */
- pkgDataFlags = (char**)uprv_malloc(sizeof(char*) * PKGDATA_FLAGS_SIZE);
-
- /* If we run out of space, allocate more */
-#if !defined(WINDOWS_WITH_MSVC) || defined(USING_CYGWIN)
- do {
-#endif
- if (pkgDataFlags != nullptr) {
- for (int32_t i = 0; i < PKGDATA_FLAGS_SIZE; i++) {
- pkgDataFlags[i] = (char*)uprv_malloc(sizeof(char) * currentBufferSize);
- if (pkgDataFlags[i] != nullptr) {
- pkgDataFlags[i][0] = 0;
- } else {
- fprintf(stderr,"Error allocating memory for pkgDataFlags.\n");
- /* If an error occurs, ensure that the rest of the array is nullptr */
- for (int32_t n = i + 1; n < PKGDATA_FLAGS_SIZE; n++) {
- pkgDataFlags[n] = nullptr;
- }
- return -1;
- }
- }
- } else {
- fprintf(stderr,"Error allocating memory for pkgDataFlags.\n");
- return -1;
- }
-
- if (o->options == nullptr) {
- return result;
- }
-
-#if !defined(WINDOWS_WITH_MSVC) || defined(USING_CYGWIN)
- /* Read in options file. */
- if(o->verbose) {
- fprintf(stdout, "# Reading options file %s\n", o->options);
- }
- status = U_ZERO_ERROR;
- tmpResult = parseFlagsFile(o->options, pkgDataFlags, currentBufferSize, FLAG_NAMES, (int32_t)PKGDATA_FLAGS_SIZE, &status);
- if (status == U_BUFFER_OVERFLOW_ERROR) {
- for (int32_t i = 0; i < PKGDATA_FLAGS_SIZE; i++) {
- if (pkgDataFlags[i]) {
- uprv_free(pkgDataFlags[i]);
- pkgDataFlags[i] = nullptr;
- }
- }
- currentBufferSize = tmpResult;
- } else if (U_FAILURE(status)) {
- fprintf(stderr,"Unable to open or read \"%s\" option file. status = %s\n", o->options, u_errorName(status));
- return -1;
- }
-#endif
- if(o->verbose) {
- fprintf(stdout, "# pkgDataFlags=\n");
- for(int32_t i=0;iverbose) {
- fprintf(stdout, "# libFileName[LIB_FILE] = %s\n", libFileNames[LIB_FILE]);
- }
-
-#if U_PLATFORM == U_PF_MINGW
- // Name the import library lib*.dll.a
- snprintf(libFileNames[LIB_FILE_MINGW], sizeof(libFileNames[LIB_FILE_MINGW]), "lib%s.dll.a", libName);
-#elif U_PLATFORM == U_PF_CYGWIN
- snprintf(libFileNames[LIB_FILE_CYGWIN], sizeof(libFileNames[LIB_FILE_CYGWIN]), "cyg%s%s%s",
- libName,
- FILE_EXTENSION_SEP,
- pkgDataFlags[SO_EXT]);
- snprintf(libFileNames[LIB_FILE_CYGWIN_VERSION], sizeof(libFileNames[LIB_FILE_CYGWIN_VERSION]), "cyg%s%s%s%s",
- libName,
- version_major,
- FILE_EXTENSION_SEP,
- pkgDataFlags[SO_EXT]);
-
- uprv_strcat(pkgDataFlags[SO_EXT], ".");
- uprv_strcat(pkgDataFlags[SO_EXT], pkgDataFlags[A_EXT]);
-#elif U_PLATFORM == U_PF_OS400 || defined(_AIX)
- snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s",
- libFileNames[LIB_FILE],
- FILE_EXTENSION_SEP,
- pkgDataFlags[SOBJ_EXT]);
-#elif U_PLATFORM == U_PF_OS390
- snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s%s%s",
- libFileNames[LIB_FILE],
- pkgDataFlags[LIB_EXT_ORDER][0] == '.' ? "." : "",
- reverseExt ? version : pkgDataFlags[SOBJ_EXT],
- FILE_EXTENSION_SEP,
- reverseExt ? pkgDataFlags[SOBJ_EXT] : version);
-
- snprintf(libFileNames[LIB_FILE_OS390BATCH_VERSION], sizeof(libFileNames[LIB_FILE_OS390BATCH_VERSION]), "%s%s.x",
- libFileNames[LIB_FILE],
- version);
- snprintf(libFileNames[LIB_FILE_OS390BATCH_MAJOR], sizeof(libFileNames[LIB_FILE_OS390BATCH_MAJOR]), "%s%s.x",
- libFileNames[LIB_FILE],
- version_major);
-#else
- if (noVersion && !reverseExt) {
- snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s",
- libFileNames[LIB_FILE],
- FILE_SUFFIX,
- pkgDataFlags[SOBJ_EXT]);
- } else {
- snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s%s%s",
- libFileNames[LIB_FILE],
- FILE_SUFFIX,
- reverseExt ? version : pkgDataFlags[SOBJ_EXT],
- FILE_EXTENSION_SEP,
- reverseExt ? pkgDataFlags[SOBJ_EXT] : version);
- }
-#endif
- if (noVersion && !reverseExt) {
- snprintf(libFileNames[LIB_FILE_VERSION_MAJOR], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s",
- libFileNames[LIB_FILE],
- FILE_SUFFIX,
- pkgDataFlags[SO_EXT]);
-
- snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s",
- libFileNames[LIB_FILE],
- FILE_SUFFIX,
- pkgDataFlags[SO_EXT]);
- } else {
- snprintf(libFileNames[LIB_FILE_VERSION_MAJOR], sizeof(libFileNames[LIB_FILE_VERSION_MAJOR]), "%s%s%s%s%s",
- libFileNames[LIB_FILE],
- FILE_SUFFIX,
- reverseExt ? version_major : pkgDataFlags[SO_EXT],
- FILE_EXTENSION_SEP,
- reverseExt ? pkgDataFlags[SO_EXT] : version_major);
-
- snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s%s%s",
- libFileNames[LIB_FILE],
- FILE_SUFFIX,
- reverseExt ? version : pkgDataFlags[SO_EXT],
- FILE_EXTENSION_SEP,
- reverseExt ? pkgDataFlags[SO_EXT] : version);
- }
-
- if(o->verbose) {
- fprintf(stdout, "# libFileName[LIB_FILE_VERSION] = %s\n", libFileNames[LIB_FILE_VERSION]);
- }
-
-#if U_PF_MINGW <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
- /* Cygwin and MinGW only deals with the version major number. */
- uprv_strcpy(libFileNames[LIB_FILE_VERSION_TMP], libFileNames[LIB_FILE_VERSION_MAJOR]);
-#endif
-
- if(IN_STATIC_MODE(mode)) {
- snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s.%s", libFileNames[LIB_FILE], pkgDataFlags[A_EXT]);
- libFileNames[LIB_FILE_VERSION_MAJOR][0]=0;
- if(o->verbose) {
- fprintf(stdout, "# libFileName[LIB_FILE_VERSION] = %s (static)\n", libFileNames[LIB_FILE_VERSION]);
- }
- }
-}
-
-/* Create the symbolic links for the final library file. */
-static int32_t pkg_createSymLinks(const char *targetDir, UBool specialHandling) {
- int32_t result = 0;
- char cmd[LARGE_BUFFER_MAX_SIZE];
- char name1[SMALL_BUFFER_MAX_SIZE]; /* symlink file name */
- char name2[SMALL_BUFFER_MAX_SIZE]; /* file name to symlink */
- const char* FILE_EXTENSION_SEP = uprv_strlen(pkgDataFlags[SO_EXT]) == 0 ? "" : ".";
-
-#if U_PLATFORM != U_PF_CYGWIN
- /* No symbolic link to make. */
- if (uprv_strlen(libFileNames[LIB_FILE_VERSION]) == 0 || uprv_strlen(libFileNames[LIB_FILE_VERSION_MAJOR]) == 0 ||
- uprv_strcmp(libFileNames[LIB_FILE_VERSION], libFileNames[LIB_FILE_VERSION_MAJOR]) == 0) {
- return result;
- }
-
- snprintf(cmd, sizeof(cmd), "cd %s && %s %s && %s %s %s",
- targetDir,
- RM_CMD,
- libFileNames[LIB_FILE_VERSION_MAJOR],
- LN_CMD,
- libFileNames[LIB_FILE_VERSION],
- libFileNames[LIB_FILE_VERSION_MAJOR]);
- result = runCommand(cmd);
- if (result != 0) {
- fprintf(stderr, "Error creating symbolic links. Failed command: %s\n", cmd);
- return result;
- }
-#endif
-
- if (specialHandling) {
-#if U_PLATFORM == U_PF_CYGWIN
- snprintf(name1, sizeof(name1), "%s", libFileNames[LIB_FILE_CYGWIN]);
- snprintf(name2, sizeof(name2), "%s", libFileNames[LIB_FILE_CYGWIN_VERSION]);
-#elif U_PLATFORM == U_PF_OS390
- /* Create the symbolic links for the import data */
- /* Use the cmd buffer to store path to import data file to check its existence */
- snprintf(cmd, sizeof(cmd), "%s/%s", targetDir, libFileNames[LIB_FILE_OS390BATCH_VERSION]);
- if (T_FileStream_file_exists(cmd)) {
- snprintf(cmd, sizeof(cmd), "cd %s && %s %s && %s %s %s",
- targetDir,
- RM_CMD,
- libFileNames[LIB_FILE_OS390BATCH_MAJOR],
- LN_CMD,
- libFileNames[LIB_FILE_OS390BATCH_VERSION],
- libFileNames[LIB_FILE_OS390BATCH_MAJOR]);
- result = runCommand(cmd);
- if (result != 0) {
- fprintf(stderr, "Error creating symbolic links. Failed command: %s\n", cmd);
- return result;
- }
-
- snprintf(cmd, sizeof(cmd), "cd %s && %s %s.x && %s %s %s.x",
- targetDir,
- RM_CMD,
- libFileNames[LIB_FILE],
- LN_CMD,
- libFileNames[LIB_FILE_OS390BATCH_VERSION],
- libFileNames[LIB_FILE]);
- result = runCommand(cmd);
- if (result != 0) {
- fprintf(stderr, "Error creating symbolic links. Failed command: %s\n", cmd);
- return result;
- }
- }
-
- /* Needs to be set here because special handling skips it */
- snprintf(name1, sizeof(name1), "%s%s%s", libFileNames[LIB_FILE], FILE_EXTENSION_SEP, pkgDataFlags[SO_EXT]);
- snprintf(name2, sizeof(name2), "%s", libFileNames[LIB_FILE_VERSION]);
-#else
- goto normal_symlink_mode;
-#endif
- } else {
-#if U_PLATFORM != U_PF_CYGWIN
-normal_symlink_mode:
-#endif
- snprintf(name1, sizeof(name1), "%s%s%s", libFileNames[LIB_FILE], FILE_EXTENSION_SEP, pkgDataFlags[SO_EXT]);
- snprintf(name2, sizeof(name2), "%s", libFileNames[LIB_FILE_VERSION]);
- }
-
- snprintf(cmd, sizeof(cmd), "cd %s && %s %s && %s %s %s",
- targetDir,
- RM_CMD,
- name1,
- LN_CMD,
- name2,
- name1);
-
- result = runCommand(cmd);
-
- return result;
-}
-
-static int32_t pkg_installLibrary(const char *installDir, const char *targetDir, UBool noVersion) {
- int32_t result = 0;
- char cmd[SMALL_BUFFER_MAX_SIZE];
-
- auto ret = snprintf(cmd,
- sizeof(cmd),
- "cd %s && %s %s %s%s%s",
- targetDir,
- pkgDataFlags[INSTALL_CMD],
- libFileNames[LIB_FILE_VERSION],
- installDir, PKGDATA_FILE_SEP_STRING, libFileNames[LIB_FILE_VERSION]);
- (void)ret;
- U_ASSERT(0 <= ret && ret < SMALL_BUFFER_MAX_SIZE);
-
- result = runCommand(cmd);
-
- if (result != 0) {
- fprintf(stderr, "Error installing library. Failed command: %s\n", cmd);
- return result;
- }
-
-#ifdef CYGWINMSVC
- snprintf(cmd, sizeof(cmd), "cd %s && %s %s.lib %s",
- targetDir,
- pkgDataFlags[INSTALL_CMD],
- libFileNames[LIB_FILE],
- installDir
- );
- result = runCommand(cmd);
-
- if (result != 0) {
- fprintf(stderr, "Error installing library. Failed command: %s\n", cmd);
- return result;
- }
-#elif U_PLATFORM == U_PF_CYGWIN
- snprintf(cmd, sizeof(cmd), "cd %s && %s %s %s",
- targetDir,
- pkgDataFlags[INSTALL_CMD],
- libFileNames[LIB_FILE_CYGWIN_VERSION],
- installDir
- );
- result = runCommand(cmd);
-
- if (result != 0) {
- fprintf(stderr, "Error installing library. Failed command: %s\n", cmd);
- return result;
- }
-
-#elif U_PLATFORM == U_PF_OS390
- if (T_FileStream_file_exists(libFileNames[LIB_FILE_OS390BATCH_VERSION])) {
- snprintf(cmd, sizeof(cmd), "%s %s %s",
- pkgDataFlags[INSTALL_CMD],
- libFileNames[LIB_FILE_OS390BATCH_VERSION],
- installDir
- );
- result = runCommand(cmd);
-
- if (result != 0) {
- fprintf(stderr, "Error installing library. Failed command: %s\n", cmd);
- return result;
- }
- }
-#endif
-
- if (noVersion) {
- return result;
- } else {
- return pkg_createSymLinks(installDir, true);
- }
-}
-
-static int32_t pkg_installCommonMode(const char *installDir, const char *fileName) {
- int32_t result = 0;
- char cmd[SMALL_BUFFER_MAX_SIZE] = "";
-
- if (!T_FileStream_file_exists(installDir)) {
- UErrorCode status = U_ZERO_ERROR;
-
- uprv_mkdir(installDir, &status);
- if (U_FAILURE(status)) {
- fprintf(stderr, "Error creating installation directory: %s\n", installDir);
- return -1;
- }
- }
-#ifndef U_WINDOWS_WITH_MSVC
- snprintf(cmd, sizeof(cmd), "%s %s %s", pkgDataFlags[INSTALL_CMD], fileName, installDir);
-#else
- snprintf(cmd, sizeof(cmd), "%s %s %s %s", WIN_INSTALL_CMD, fileName, installDir, WIN_INSTALL_CMD_FLAGS);
-#endif
-
- result = runCommand(cmd);
- if (result != 0) {
- fprintf(stderr, "Failed to install data file with command: %s\n", cmd);
- }
-
- return result;
-}
-
-#ifdef U_WINDOWS_MSVC
-/* Copy commands for installing the raw data files on Windows. */
-#define WIN_INSTALL_CMD "xcopy"
-#define WIN_INSTALL_CMD_FLAGS "/E /Y /K"
-#endif
-static int32_t pkg_installFileMode(const char *installDir, const char *srcDir, const char *fileListName) {
- int32_t result = 0;
- char cmd[SMALL_BUFFER_MAX_SIZE] = "";
-
- if (!T_FileStream_file_exists(installDir)) {
- UErrorCode status = U_ZERO_ERROR;
-
- uprv_mkdir(installDir, &status);
- if (U_FAILURE(status)) {
- fprintf(stderr, "Error creating installation directory: %s\n", installDir);
- return -1;
- }
- }
-#ifndef U_WINDOWS_WITH_MSVC
- char buffer[SMALL_BUFFER_MAX_SIZE] = "";
- int32_t bufferLength = 0;
-
- FileStream *f = T_FileStream_open(fileListName, "r");
- if (f != nullptr) {
- for(;;) {
- if (T_FileStream_readLine(f, buffer, SMALL_BUFFER_MAX_SIZE) != nullptr) {
- bufferLength = static_cast(uprv_strlen(buffer));
- /* Remove new line character. */
- if (bufferLength > 0) {
- buffer[bufferLength-1] = 0;
- }
-
- auto ret = snprintf(cmd,
- sizeof(cmd),
- "%s %s%s%s %s%s%s",
- pkgDataFlags[INSTALL_CMD],
- srcDir, PKGDATA_FILE_SEP_STRING, buffer,
- installDir, PKGDATA_FILE_SEP_STRING, buffer);
- (void)ret;
- U_ASSERT(0 <= ret && ret < SMALL_BUFFER_MAX_SIZE);
-
- result = runCommand(cmd);
- if (result != 0) {
- fprintf(stderr, "Failed to install data file with command: %s\n", cmd);
- break;
- }
- } else {
- if (!T_FileStream_eof(f)) {
- fprintf(stderr, "Failed to read line from file: %s\n", fileListName);
- result = -1;
- }
- break;
- }
- }
- T_FileStream_close(f);
- } else {
- result = -1;
- fprintf(stderr, "Unable to open list file: %s\n", fileListName);
- }
-#else
- snprintf(cmd, sizeof(cmd), "%s %s %s %s", WIN_INSTALL_CMD, srcDir, installDir, WIN_INSTALL_CMD_FLAGS);
- result = runCommand(cmd);
- if (result != 0) {
- fprintf(stderr, "Failed to install data file with command: %s\n", cmd);
- }
-#endif
-
- return result;
-}
-
-/* Archiving of the library file may be needed depending on the platform and options given.
- * If archiving is not needed, copy over the library file name.
- */
-static int32_t pkg_archiveLibrary(const char *targetDir, const char *version, UBool reverseExt) {
- int32_t result = 0;
- char cmd[LARGE_BUFFER_MAX_SIZE];
-
- /* If the shared object suffix and the final object suffix is different and the final object suffix and the
- * archive file suffix is the same, then the final library needs to be archived.
- */
- if (uprv_strcmp(pkgDataFlags[SOBJ_EXT], pkgDataFlags[SO_EXT]) != 0 && uprv_strcmp(pkgDataFlags[A_EXT], pkgDataFlags[SO_EXT]) == 0) {
- snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s.%s",
- libFileNames[LIB_FILE],
- pkgDataFlags[LIB_EXT_ORDER][0] == '.' ? "." : "",
- reverseExt ? version : pkgDataFlags[SO_EXT],
- reverseExt ? pkgDataFlags[SO_EXT] : version);
-
- snprintf(cmd, sizeof(cmd), "%s %s %s%s %s%s",
- pkgDataFlags[AR],
- pkgDataFlags[ARFLAGS],
- targetDir,
- libFileNames[LIB_FILE_VERSION],
- targetDir,
- libFileNames[LIB_FILE_VERSION_TMP]);
-
- result = runCommand(cmd);
- if (result != 0) {
- fprintf(stderr, "Error creating archive library. Failed command: %s\n", cmd);
- return result;
- }
-
- snprintf(cmd, sizeof(cmd), "%s %s%s",
- pkgDataFlags[RANLIB],
- targetDir,
- libFileNames[LIB_FILE_VERSION]);
-
- result = runCommand(cmd);
- if (result != 0) {
- fprintf(stderr, "Error creating archive library. Failed command: %s\n", cmd);
- return result;
- }
-
- /* Remove unneeded library file. */
- snprintf(cmd, sizeof(cmd), "%s %s%s",
- RM_CMD,
- targetDir,
- libFileNames[LIB_FILE_VERSION_TMP]);
-
- result = runCommand(cmd);
- if (result != 0) {
- fprintf(stderr, "Error creating archive library. Failed command: %s\n", cmd);
- return result;
- }
-
- } else {
- uprv_strcpy(libFileNames[LIB_FILE_VERSION], libFileNames[LIB_FILE_VERSION_TMP]);
- }
-
- return result;
-}
-
-/*
- * Using the compiler information from the configuration file set by -O option, generate the library file.
- * command may be given to allow for a larger buffer for cmd.
- */
-static int32_t pkg_generateLibraryFile(const char *targetDir, const char mode, const char *objectFile, char *command, UBool specialHandling) {
- int32_t result = 0;
- char *cmd = nullptr;
- UBool freeCmd = false;
- int32_t length = 0;
-
- (void)specialHandling; // Suppress unused variable compiler warnings on platforms where all usage
- // of this parameter is #ifdefed out.
-
- /* This is necessary because if packaging is done without assembly code, objectFile might be extremely large
- * containing many object files and so the calling function should supply a command buffer that is large
- * enough to handle this. Otherwise, use the default size.
- */
- if (command != nullptr) {
- cmd = command;
- }
-
- if (IN_STATIC_MODE(mode)) {
- if (cmd == nullptr) {
- length = static_cast(uprv_strlen(pkgDataFlags[AR]) + uprv_strlen(pkgDataFlags[ARFLAGS]) + uprv_strlen(targetDir) +
- uprv_strlen(libFileNames[LIB_FILE_VERSION]) + uprv_strlen(objectFile) + uprv_strlen(pkgDataFlags[RANLIB]) + BUFFER_PADDING_SIZE);
- if ((cmd = (char *)uprv_malloc(sizeof(char) * length)) == nullptr) {
- fprintf(stderr, "Unable to allocate memory for command.\n");
- return -1;
- }
- freeCmd = true;
- }
- sprintf(cmd, "%s %s %s%s %s",
- pkgDataFlags[AR],
- pkgDataFlags[ARFLAGS],
- targetDir,
- libFileNames[LIB_FILE_VERSION],
- objectFile);
-
- result = runCommand(cmd);
- if (result == 0) {
- sprintf(cmd, "%s %s%s",
- pkgDataFlags[RANLIB],
- targetDir,
- libFileNames[LIB_FILE_VERSION]);
-
- result = runCommand(cmd);
- }
- } else /* if (IN_DLL_MODE(mode)) */ {
- if (cmd == nullptr) {
- length = static_cast(uprv_strlen(pkgDataFlags[GENLIB]) + uprv_strlen(pkgDataFlags[LDICUDTFLAGS]) +
- ((uprv_strlen(targetDir) + uprv_strlen(libFileNames[LIB_FILE_VERSION_TMP])) * 2) +
- uprv_strlen(objectFile) + uprv_strlen(pkgDataFlags[LD_SONAME]) +
- uprv_strlen(pkgDataFlags[LD_SONAME][0] == 0 ? "" : libFileNames[LIB_FILE_VERSION_MAJOR]) +
- uprv_strlen(pkgDataFlags[RPATH_FLAGS]) + uprv_strlen(pkgDataFlags[BIR_FLAGS]) + BUFFER_PADDING_SIZE);
-#if U_PLATFORM == U_PF_CYGWIN
- length += static_cast(uprv_strlen(targetDir) + uprv_strlen(libFileNames[LIB_FILE_CYGWIN_VERSION]));
-#elif U_PLATFORM == U_PF_MINGW
- length += static_cast(uprv_strlen(targetDir) + uprv_strlen(libFileNames[LIB_FILE_MINGW]));
-#endif
- if ((cmd = (char *)uprv_malloc(sizeof(char) * length)) == nullptr) {
- fprintf(stderr, "Unable to allocate memory for command.\n");
- return -1;
- }
- freeCmd = true;
- }
-#if U_PLATFORM == U_PF_MINGW
- sprintf(cmd, "%s%s%s %s -o %s%s %s %s%s %s %s",
- pkgDataFlags[GENLIB],
- targetDir,
- libFileNames[LIB_FILE_MINGW],
- pkgDataFlags[LDICUDTFLAGS],
- targetDir,
- libFileNames[LIB_FILE_VERSION_TMP],
-#elif U_PLATFORM == U_PF_CYGWIN
- sprintf(cmd, "%s%s%s %s -o %s%s %s %s%s %s %s",
- pkgDataFlags[GENLIB],
- targetDir,
- libFileNames[LIB_FILE_VERSION_TMP],
- pkgDataFlags[LDICUDTFLAGS],
- targetDir,
- libFileNames[LIB_FILE_CYGWIN_VERSION],
-#elif U_PLATFORM == U_PF_AIX
- sprintf(cmd, "%s %s%s;%s %s -o %s%s %s %s%s %s %s",
- RM_CMD,
- targetDir,
- libFileNames[LIB_FILE_VERSION_TMP],
- pkgDataFlags[GENLIB],
- pkgDataFlags[LDICUDTFLAGS],
- targetDir,
- libFileNames[LIB_FILE_VERSION_TMP],
-#else
- sprintf(cmd, "%s %s -o %s%s %s %s%s %s %s",
- pkgDataFlags[GENLIB],
- pkgDataFlags[LDICUDTFLAGS],
- targetDir,
- libFileNames[LIB_FILE_VERSION_TMP],
-#endif
- objectFile,
- pkgDataFlags[LD_SONAME],
- pkgDataFlags[LD_SONAME][0] == 0 ? "" : libFileNames[LIB_FILE_VERSION_MAJOR],
- pkgDataFlags[RPATH_FLAGS],
- pkgDataFlags[BIR_FLAGS]);
-
- /* Generate the library file. */
- result = runCommand(cmd);
-
-#if U_PLATFORM == U_PF_OS390
- char *env_tmp;
- char PDS_LibName[512];
- char PDS_Name[512];
-
- PDS_Name[0] = 0;
- PDS_LibName[0] = 0;
- if (specialHandling && uprv_strcmp(libFileNames[LIB_FILE],"libicudata") == 0) {
- if (env_tmp = getenv("ICU_PDS_NAME")) {
- sprintf(PDS_Name, "%s%s",
- env_tmp,
- "DA");
- strcat(PDS_Name, getenv("ICU_PDS_NAME_SUFFIX"));
- } else if (env_tmp = getenv("PDS_NAME_PREFIX")) {
- sprintf(PDS_Name, "%s%s",
- env_tmp,
- U_ICU_VERSION_SHORT "DA");
- } else {
- sprintf(PDS_Name, "%s%s",
- "IXMI",
- U_ICU_VERSION_SHORT "DA");
- }
- } else if (!specialHandling && uprv_strcmp(libFileNames[LIB_FILE],"libicudata_stub") == 0) {
- if (env_tmp = getenv("ICU_PDS_NAME")) {
- sprintf(PDS_Name, "%s%s",
- env_tmp,
- "D1");
- strcat(PDS_Name, getenv("ICU_PDS_NAME_SUFFIX"));
- } else if (env_tmp = getenv("PDS_NAME_PREFIX")) {
- sprintf(PDS_Name, "%s%s",
- env_tmp,
- U_ICU_VERSION_SHORT "D1");
- } else {
- sprintf(PDS_Name, "%s%s",
- "IXMI",
- U_ICU_VERSION_SHORT "D1");
- }
- }
-
- if (PDS_Name[0]) {
- sprintf(PDS_LibName,"%s%s%s%s%s",
- "\"//'",
- getenv("LOADMOD"),
- "(",
- PDS_Name,
- ")'\"");
- sprintf(cmd, "%s %s -o %s %s %s%s %s %s",
- pkgDataFlags[GENLIB],
- pkgDataFlags[LDICUDTFLAGS],
- PDS_LibName,
- objectFile,
- pkgDataFlags[LD_SONAME],
- pkgDataFlags[LD_SONAME][0] == 0 ? "" : libFileNames[LIB_FILE_VERSION_MAJOR],
- pkgDataFlags[RPATH_FLAGS],
- pkgDataFlags[BIR_FLAGS]);
-
- result = runCommand(cmd);
- }
-#endif
- }
-
- if (result != 0) {
- fprintf(stderr, "Error generating library file. Failed command: %s\n", cmd);
- }
-
- if (freeCmd) {
- uprv_free(cmd);
- }
-
- return result;
-}
-
-static int32_t pkg_createWithAssemblyCode(const char *targetDir, const char mode, const char *gencFilePath) {
- char tempObjectFile[SMALL_BUFFER_MAX_SIZE] = "";
- int32_t result = 0;
- int32_t length = 0;
-
- /* Remove the ending .s and replace it with .o for the new object file. */
- uprv_strcpy(tempObjectFile, gencFilePath);
- tempObjectFile[uprv_strlen(tempObjectFile)-1] = 'o';
-
- length = static_cast(uprv_strlen(pkgDataFlags[COMPILER]) + uprv_strlen(pkgDataFlags[LIBFLAGS])
- + uprv_strlen(tempObjectFile) + uprv_strlen(gencFilePath) + BUFFER_PADDING_SIZE);
-
- LocalMemory cmd((char *)uprv_malloc(sizeof(char) * length));
- if (cmd.isNull()) {
- return -1;
- }
-
- /* Generate the object file. */
- snprintf(cmd.getAlias(), length, "%s %s -o %s %s",
- pkgDataFlags[COMPILER],
- pkgDataFlags[LIBFLAGS],
- tempObjectFile,
- gencFilePath);
-
- result = runCommand(cmd.getAlias());
-
- if (result != 0) {
- fprintf(stderr, "Error creating with assembly code. Failed command: %s\n", cmd.getAlias());
- return result;
- }
-
- return pkg_generateLibraryFile(targetDir, mode, tempObjectFile);
-}
-
-#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.
- * Note: Any update to the directory structure of the data needs to be reflected here.
- */
-enum {
- DATA_PREFIX_BRKITR,
- DATA_PREFIX_COLL,
- DATA_PREFIX_CURR,
- DATA_PREFIX_LANG,
- DATA_PREFIX_RBNF,
- DATA_PREFIX_REGION,
- DATA_PREFIX_TRANSLIT,
- DATA_PREFIX_ZONE,
- DATA_PREFIX_UNIT,
- DATA_PREFIX_LENGTH
-};
-
-const static char DATA_PREFIX[DATA_PREFIX_LENGTH][10] = {
- "brkitr",
- "coll",
- "curr",
- "lang",
- "rbnf",
- "region",
- "translit",
- "zone",
- "unit"
-};
-
-static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetDir, const char mode) {
- int32_t result = 0;
- CharList *list = o->filePaths;
- CharList *listNames = o->files;
- int32_t listSize = pkg_countCharList(list);
- char *buffer;
- char *cmd;
- char gencmnFile[SMALL_BUFFER_MAX_SIZE] = "";
- char tempObjectFile[SMALL_BUFFER_MAX_SIZE] = "";
-#ifdef USE_SINGLE_CCODE_FILE
- char icudtAll[SMALL_BUFFER_MAX_SIZE] = "";
- FileStream *icudtAllFile = nullptr;
-
- snprintf(icudtAll, sizeof(icudtAll), "%s%s%sall.c",
- o->tmpDir,
- PKGDATA_FILE_SEP_STRING,
- libFileNames[LIB_FILE]);
- /* Remove previous icudtall.c file. */
- if (T_FileStream_file_exists(icudtAll) && (result = remove(icudtAll)) != 0) {
- fprintf(stderr, "Unable to remove old icudtall file: %s\n", icudtAll);
- return result;
- }
-
- if((icudtAllFile = T_FileStream_open(icudtAll, "w"))==nullptr) {
- fprintf(stderr, "Unable to write to icudtall file: %s\n", icudtAll);
- return result;
- }
-#endif
-
- if (list == nullptr || listNames == nullptr) {
- /* list and listNames should never be nullptr since we are looping through the CharList with
- * the given size.
- */
- return -1;
- }
-
- if ((cmd = (char *)uprv_malloc((listSize + 2) * SMALL_BUFFER_MAX_SIZE)) == nullptr) {
- fprintf(stderr, "Unable to allocate memory for cmd.\n");
- return -1;
- } else if ((buffer = (char *)uprv_malloc((listSize + 1) * SMALL_BUFFER_MAX_SIZE)) == nullptr) {
- fprintf(stderr, "Unable to allocate memory for buffer.\n");
- uprv_free(cmd);
- return -1;
- }
-
- for (int32_t i = 0; i < (listSize + 1); i++) {
- const char *file ;
- const char *name;
-
- if (i == 0) {
- /* The first iteration calls the gencmn function and initializes the buffer. */
- createCommonDataFile(o->tmpDir, o->shortName, o->entryName, nullptr, o->srcDir, o->comment, o->fileListFiles->str, 0, true, o->verbose, gencmnFile);
- buffer[0] = 0;
-#ifdef USE_SINGLE_CCODE_FILE
- uprv_strcpy(tempObjectFile, gencmnFile);
- tempObjectFile[uprv_strlen(tempObjectFile) - 1] = 'o';
-
- sprintf(cmd, "%s %s -o %s %s",
- pkgDataFlags[COMPILER],
- pkgDataFlags[LIBFLAGS],
- tempObjectFile,
- gencmnFile);
-
- result = runCommand(cmd);
- if (result != 0) {
- break;
- }
-
- sprintf(buffer, "%s",tempObjectFile);
-#endif
- } else {
- char newName[SMALL_BUFFER_MAX_SIZE];
- char dataName[SMALL_BUFFER_MAX_SIZE];
- char dataDirName[SMALL_BUFFER_MAX_SIZE];
- const char *pSubstring;
- file = list->str;
- name = listNames->str;
-
- newName[0] = dataName[0] = 0;
- for (int32_t n = 0; n < DATA_PREFIX_LENGTH; n++) {
- dataDirName[0] = 0;
- sprintf(dataDirName, "%s%s", DATA_PREFIX[n], PKGDATA_FILE_SEP_STRING);
- /* If the name contains a prefix (indicating directory), alter the new name accordingly. */
- pSubstring = uprv_strstr(name, dataDirName);
- if (pSubstring != nullptr) {
- char newNameTmp[SMALL_BUFFER_MAX_SIZE] = "";
- const char *p = name + uprv_strlen(dataDirName);
- for (int32_t i = 0;;i++) {
- if (p[i] == '.') {
- newNameTmp[i] = '_';
- continue;
- }
- newNameTmp[i] = p[i];
- if (p[i] == 0) {
- break;
- }
- }
- auto ret = snprintf(newName,
- sizeof(newName),
- "%s_%s",
- DATA_PREFIX[n],
- newNameTmp);
- (void)ret;
- U_ASSERT(0 <= ret && ret < SMALL_BUFFER_MAX_SIZE);
- ret = snprintf(dataName,
- sizeof(dataName),
- "%s_%s",
- o->shortName,
- DATA_PREFIX[n]);
- (void)ret;
- U_ASSERT(0 <= ret && ret < SMALL_BUFFER_MAX_SIZE);
- }
- if (newName[0] != 0) {
- break;
- }
- }
-
- if(o->verbose) {
- printf("# Generating %s \n", gencmnFile);
- }
-
- writeCCode(
- file,
- o->tmpDir,
- nullptr,
- dataName[0] != 0 ? dataName : o->shortName,
- newName[0] != 0 ? newName : nullptr,
- gencmnFile,
- sizeof(gencmnFile));
-
-#ifdef USE_SINGLE_CCODE_FILE
- sprintf(cmd, "#include \"%s\"\n", gencmnFile);
- T_FileStream_writeLine(icudtAllFile, cmd);
- /* don't delete the file */
-#endif
- }
-
-#ifndef USE_SINGLE_CCODE_FILE
- uprv_strcpy(tempObjectFile, gencmnFile);
- tempObjectFile[uprv_strlen(tempObjectFile) - 1] = 'o';
-
- sprintf(cmd, "%s %s -o %s %s",
- pkgDataFlags[COMPILER],
- pkgDataFlags[LIBFLAGS],
- tempObjectFile,
- gencmnFile);
- result = runCommand(cmd);
- if (result != 0) {
- fprintf(stderr, "Error creating library without assembly code. Failed command: %s\n", cmd);
- break;
- }
-
- uprv_strcat(buffer, " ");
- uprv_strcat(buffer, tempObjectFile);
-
-#endif
-
- if (i > 0) {
- list = list->next;
- listNames = listNames->next;
- }
- }
-
-#ifdef USE_SINGLE_CCODE_FILE
- T_FileStream_close(icudtAllFile);
- uprv_strcpy(tempObjectFile, icudtAll);
- tempObjectFile[uprv_strlen(tempObjectFile) - 1] = 'o';
-
- sprintf(cmd, "%s %s -I. -o %s %s",
- pkgDataFlags[COMPILER],
- pkgDataFlags[LIBFLAGS],
- tempObjectFile,
- icudtAll);
-
- result = runCommand(cmd);
- if (result == 0) {
- uprv_strcat(buffer, " ");
- uprv_strcat(buffer, tempObjectFile);
- } else {
- fprintf(stderr, "Error creating library without assembly code. Failed command: %s\n", cmd);
- }
-#endif
-
- if (result == 0) {
- /* Generate the library file. */
-#if U_PLATFORM == U_PF_OS390
- result = pkg_generateLibraryFile(targetDir, mode, buffer, cmd, (o->pdsbuild && IN_DLL_MODE(mode)));
-#else
- result = pkg_generateLibraryFile(targetDir,mode, buffer, cmd);
-#endif
- }
-
- uprv_free(buffer);
- uprv_free(cmd);
-
- return result;
-}
-#endif
-
-#ifdef WINDOWS_WITH_MSVC
-#define LINK_CMD "link.exe /nologo /release /out:"
-#define LINK_FLAGS "/NXCOMPAT /DYNAMICBASE /DLL /NOENTRY /MANIFEST:NO /implib:"
-
-#define LINK_EXTRA_UWP_FLAGS "/APPCONTAINER "
-#define LINK_EXTRA_UWP_FLAGS_X86_ONLY "/SAFESEH "
-
-#define LINK_EXTRA_FLAGS_MACHINE "/MACHINE:"
-#define LIB_CMD "LIB.exe /nologo /out:"
-#define LIB_FILE "icudt.lib"
-#define LIB_EXT UDATA_LIB_SUFFIX
-#define DLL_EXT UDATA_SO_SUFFIX
-
-static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, UPKGOptions *o) {
- int32_t result = 0;
- char cmd[LARGE_BUFFER_MAX_SIZE];
- if (IN_STATIC_MODE(mode)) {
- char staticLibFilePath[SMALL_BUFFER_MAX_SIZE] = "";
-
-#ifdef CYGWINMSVC
- snprintf(staticLibFilePath, sizeof(staticLibFilePath), "%s%s%s%s%s",
- o->targetDir,
- PKGDATA_FILE_SEP_STRING,
- pkgDataFlags[LIBPREFIX],
- o->libName,
- LIB_EXT);
-#else
- snprintf(staticLibFilePath, sizeof(staticLibFilePath), "%s%s%s%s%s",
- o->targetDir,
- PKGDATA_FILE_SEP_STRING,
- (strstr(o->libName, "icudt") ? "s" : ""),
- o->libName,
- LIB_EXT);
-#endif
-
- snprintf(cmd, sizeof(cmd), "%s\"%s\" \"%s\"",
- LIB_CMD,
- staticLibFilePath,
- gencFilePath);
- } else if (IN_DLL_MODE(mode)) {
- char dllFilePath[SMALL_BUFFER_MAX_SIZE] = "";
- char libFilePath[SMALL_BUFFER_MAX_SIZE] = "";
- char resFilePath[SMALL_BUFFER_MAX_SIZE] = "";
- char tmpResFilePath[SMALL_BUFFER_MAX_SIZE] = "";
-
-#ifdef CYGWINMSVC
- uprv_strcpy(dllFilePath, o->targetDir);
-#else
- uprv_strcpy(dllFilePath, o->srcDir);
-#endif
- uprv_strcat(dllFilePath, PKGDATA_FILE_SEP_STRING);
- uprv_strcpy(libFilePath, dllFilePath);
-
-#ifdef CYGWINMSVC
- uprv_strcat(libFilePath, o->libName);
- uprv_strcat(libFilePath, ".lib");
-
- uprv_strcat(dllFilePath, o->libName);
- uprv_strcat(dllFilePath, o->version);
-#else
- if (strstr(o->libName, "icudt")) {
- uprv_strcat(libFilePath, LIB_FILE);
- } else {
- uprv_strcat(libFilePath, o->libName);
- uprv_strcat(libFilePath, ".lib");
- }
- uprv_strcat(dllFilePath, o->entryName);
-#endif
- uprv_strcat(dllFilePath, DLL_EXT);
-
- uprv_strcpy(tmpResFilePath, o->tmpDir);
- uprv_strcat(tmpResFilePath, PKGDATA_FILE_SEP_STRING);
- uprv_strcat(tmpResFilePath, ICUDATA_RES_FILE);
-
- if (T_FileStream_file_exists(tmpResFilePath)) {
- snprintf(resFilePath, sizeof(resFilePath), "\"%s\"", tmpResFilePath);
- }
-
- /* Check if dll file and lib file exists and that it is not newer than genc file. */
- if (!o->rebuild && (T_FileStream_file_exists(dllFilePath) && isFileModTimeLater(dllFilePath, gencFilePath)) &&
- (T_FileStream_file_exists(libFilePath) && isFileModTimeLater(libFilePath, gencFilePath))) {
- if(o->verbose) {
- printf("# Not rebuilding %s - up to date.\n", gencFilePath);
- }
- return 0;
- }
-
- char extraFlags[SMALL_BUFFER_MAX_SIZE] = "";
-#ifdef WINDOWS_WITH_MSVC
- if (options[WIN_UWP_BUILD].doesOccur) {
- uprv_strcat(extraFlags, LINK_EXTRA_UWP_FLAGS);
-
- if (options[WIN_DLL_ARCH].doesOccur) {
- if (uprv_strcmp(options[WIN_DLL_ARCH].value, "X86") == 0) {
- uprv_strcat(extraFlags, LINK_EXTRA_UWP_FLAGS_X86_ONLY);
- }
- }
- }
-
- if (options[WIN_DLL_ARCH].doesOccur) {
- uprv_strcat(extraFlags, LINK_EXTRA_FLAGS_MACHINE);
- uprv_strcat(extraFlags, options[WIN_DLL_ARCH].value);
- }
-
-#endif
- snprintf(cmd, sizeof(cmd), "%s\"%s\" %s %s\"%s\" \"%s\" %s",
- LINK_CMD,
- dllFilePath,
- extraFlags,
- LINK_FLAGS,
- libFilePath,
- gencFilePath,
- resFilePath
- );
- }
-
- result = runCommand(cmd, true);
- if (result != 0) {
- fprintf(stderr, "Error creating Windows DLL library. Failed command: %s\n", cmd);
- }
-
- return result;
-}
-#endif
-
-static UPKGOptions *pkg_checkFlag(UPKGOptions *o) {
-#if U_PLATFORM == U_PF_AIX
- /* AIX needs a map file. */
- char *flag = nullptr;
- int32_t length = 0;
- char tmpbuffer[SMALL_BUFFER_MAX_SIZE];
- const char MAP_FILE_EXT[] = ".map";
- FileStream *f = nullptr;
- char mapFile[SMALL_BUFFER_MAX_SIZE] = "";
- int32_t start = -1;
- uint32_t count = 0;
- const char rm_cmd[] = "rm -f all ;";
-
- flag = pkgDataFlags[GENLIB];
-
- /* This portion of the code removes 'rm -f all' in the GENLIB.
- * Only occurs in AIX.
- */
- if (uprv_strstr(flag, rm_cmd) != nullptr) {
- char *tmpGenlibFlagBuffer = nullptr;
- int32_t i, offset;
-
- length = static_cast(uprv_strlen(flag) + 1);
- tmpGenlibFlagBuffer = (char *)uprv_malloc(length);
- if (tmpGenlibFlagBuffer == nullptr) {
- /* Memory allocation error */
- fprintf(stderr,"Unable to allocate buffer of size: %d.\n", length);
- return nullptr;
- }
-
- uprv_strcpy(tmpGenlibFlagBuffer, flag);
-
- offset = static_cast(uprv_strlen(rm_cmd));
-
- for (i = 0; i < (length - offset); i++) {
- flag[i] = tmpGenlibFlagBuffer[offset + i];
- }
-
- /* Zero terminate the string */
- flag[i] = 0;
-
- uprv_free(tmpGenlibFlagBuffer);
- }
-
- flag = pkgDataFlags[BIR_FLAGS];
- length = static_cast(uprv_strlen(pkgDataFlags[BIR_FLAGS]));
-
- for (int32_t i = 0; i < length; i++) {
- if (flag[i] == MAP_FILE_EXT[count]) {
- if (count == 0) {
- start = i;
- }
- count++;
- } else {
- count = 0;
- }
-
- if (count == uprv_strlen(MAP_FILE_EXT)) {
- break;
- }
- }
-
- if (start >= 0) {
- int32_t index = 0;
- for (int32_t i = 0;;i++) {
- if (i == start) {
- for (int32_t n = 0;;n++) {
- if (o->shortName[n] == 0) {
- break;
- }
- tmpbuffer[index++] = o->shortName[n];
- }
- }
-
- tmpbuffer[index++] = flag[i];
-
- if (flag[i] == 0) {
- break;
- }
- }
-
- uprv_memset(flag, 0, length);
- uprv_strcpy(flag, tmpbuffer);
-
- uprv_strcpy(mapFile, o->shortName);
- uprv_strcat(mapFile, MAP_FILE_EXT);
-
- f = T_FileStream_open(mapFile, "w");
- if (f == nullptr) {
- fprintf(stderr,"Unable to create map file: %s.\n", mapFile);
- return nullptr;
- } else {
- snprintf(tmpbuffer, sizeof(tmpbuffer), "%s%s ", o->entryName, UDATA_CMN_INTERMEDIATE_SUFFIX);
-
- T_FileStream_writeLine(f, tmpbuffer);
-
- T_FileStream_close(f);
- }
- }
-#elif U_PLATFORM == U_PF_CYGWIN || U_PLATFORM == U_PF_MINGW
- /* Cygwin needs to change flag options. */
- char *flag = nullptr;
- int32_t length = 0;
-
- flag = pkgDataFlags[GENLIB];
- length = static_cast(uprv_strlen(pkgDataFlags[GENLIB]));
-
- int32_t position = length - 1;
-
- for(;position >= 0;position--) {
- if (flag[position] == '=') {
- position++;
- break;
- }
- }
-
- uprv_memset(flag + position, 0, length - position);
-#elif U_PLATFORM == U_PF_OS400
- /* OS/400 needs to fix the ld options (swap single quote with double quote) */
- char *flag = nullptr;
- int32_t length = 0;
-
- flag = pkgDataFlags[GENLIB];
- length = static_cast(uprv_strlen(pkgDataFlags[GENLIB]));
-
- int32_t position = length - 1;
-
- for(int32_t i = 0; i < length; i++) {
- if (flag[i] == '\'') {
- flag[i] = '\"';
- }
- }
-#endif
- // Don't really need a return value, just need to stop compiler warnings about
- // the unused parameter 'o' on platforms where it is not otherwise used.
- return o;
-}
-
-static void loadLists(UPKGOptions *o, UErrorCode *status)
-{
- CharList *l, *tail = nullptr, *tail2 = nullptr;
- FileStream *in;
- char line[16384];
- char *linePtr, *lineNext;
- const uint32_t lineMax = 16300;
- char *tmp;
- int32_t tmpLength = 0;
- char *s;
- int32_t ln=0; /* line number */
-
- for(l = o->fileListFiles; l; l = l->next) {
- if(o->verbose) {
- fprintf(stdout, "# pkgdata: Reading %s..\n", l->str);
- }
- /* TODO: stdin */
- in = T_FileStream_open(l->str, "r"); /* open files list */
-
- if(!in) {
- fprintf(stderr, "Error opening <%s>.\n", l->str);
- *status = U_FILE_ACCESS_ERROR;
- return;
- }
-
- while(T_FileStream_readLine(in, line, sizeof(line))!=nullptr) { /* for each line */
- ln++;
- if(uprv_strlen(line)>lineMax) {
- fprintf(stderr, "%s:%d - line too long (over %d chars)\n", l->str, (int)ln, (int)lineMax);
- exit(1);
- }
- /* remove spaces at the beginning */
- linePtr = line;
- /* On z/OS, disable call to isspace (#9996). Investigate using uprv_isspace instead (#9999) */
-#if U_PLATFORM != U_PF_OS390
- while(isspace(*linePtr)) {
- linePtr++;
- }
-#endif
- s=linePtr;
- /* remove trailing newline characters */
- while(*s!=0) {
- if(*s=='\r' || *s=='\n') {
- *s=0;
- break;
- }
- ++s;
- }
- if((*linePtr == 0) || (*linePtr == '#')) {
- continue; /* comment or empty line */
- }
-
- /* Now, process the line */
- lineNext = nullptr;
-
- while(linePtr && *linePtr) { /* process space-separated items */
- while(*linePtr == ' ') {
- linePtr++;
- }
- /* Find the next quote */
- if(linePtr[0] == '"')
- {
- lineNext = uprv_strchr(linePtr+1, '"');
- if(lineNext == nullptr) {
- fprintf(stderr, "%s:%d - missing trailing double quote (\")\n",
- l->str, (int)ln);
- exit(1);
- } else {
- lineNext++;
- if(*lineNext) {
- if(*lineNext != ' ') {
- fprintf(stderr, "%s:%d - malformed quoted line at position %d, expected ' ' got '%c'\n",
- l->str, (int)ln, (int)(lineNext-line), (*lineNext)?*lineNext:'0');
- exit(1);
- }
- *lineNext = 0;
- lineNext++;
- }
- }
- } else {
- lineNext = uprv_strchr(linePtr, ' ');
- if(lineNext) {
- *lineNext = 0; /* terminate at space */
- lineNext++;
- }
- }
-
- /* add the file */
- s = (char*)getLongPathname(linePtr);
-
- /* normal mode.. o->files is just the bare list without package names */
- o->files = pkg_appendToList(o->files, &tail, uprv_strdup(linePtr));
- if(uprv_pathIsAbsolute(s) || s[0] == '.') {
- fprintf(stderr, "pkgdata: Error: absolute path encountered. Old style paths are not supported. Use relative paths such as 'fur.res' or 'translit%cfur.res'.\n\tBad path: '%s'\n", U_FILE_SEP_CHAR, s);
- exit(U_ILLEGAL_ARGUMENT_ERROR);
- }
- /* The +5 is to add a little extra space for, among other things, PKGDATA_FILE_SEP_STRING */
- tmpLength = static_cast(uprv_strlen(o->srcDir) + uprv_strlen(s) + 5);
- if((tmp = (char *)uprv_malloc(tmpLength)) == nullptr) {
- fprintf(stderr, "pkgdata: Error: Unable to allocate tmp buffer size: %d\n", tmpLength);
- exit(U_MEMORY_ALLOCATION_ERROR);
- }
- uprv_strcpy(tmp, o->srcDir);
- uprv_strcat(tmp, o->srcDir[uprv_strlen(o->srcDir)-1] == U_FILE_SEP_CHAR ? "" : PKGDATA_FILE_SEP_STRING);
- uprv_strcat(tmp, s);
- o->filePaths = pkg_appendToList(o->filePaths, &tail2, tmp);
- linePtr = lineNext;
- } /* for each entry on line */
- } /* for each line */
- T_FileStream_close(in);
- } /* for each file list file */
-}
-
-/* Helper for pkg_getPkgDataPath() */
-#if U_HAVE_POPEN
-static UBool getPkgDataPath(const char *cmd, UBool verbose, char *buf, size_t items) {
- icu::CharString cmdBuf;
- UErrorCode status = U_ZERO_ERROR;
- icu::LocalPipeFilePointer p;
- size_t n;
-
- cmdBuf.append(cmd, status);
- if (verbose) {
- fprintf(stdout, "# Calling: %s\n", cmdBuf.data());
- }
- p.adoptInstead( popen(cmdBuf.data(), "r") );
-
- if (p.isNull() || (n = fread(buf, 1, items-1, p.getAlias())) <= 0) {
- fprintf(stderr, "%s: Error calling '%s'\n", progname, cmd);
- *buf = 0;
- return false;
- }
-
- return true;
-}
-#endif
-
-/* Get path to pkgdata.inc. Try pkg-config first, falling back to icu-config. */
-static int32_t pkg_getPkgDataPath(UBool verbose, UOption *option) {
-#if U_HAVE_POPEN
- static char buf[512] = "";
- UBool pkgconfigIsValid = true;
- const char *pkgconfigCmd = "pkg-config --variable=pkglibdir icu-uc";
- const char *icuconfigCmd = "icu-config --incpkgdatafile";
- const char *pkgdata = "pkgdata.inc";
-
- if (!getPkgDataPath(pkgconfigCmd, verbose, buf, UPRV_LENGTHOF(buf))) {
- if (!getPkgDataPath(icuconfigCmd, verbose, buf, UPRV_LENGTHOF(buf))) {
- fprintf(stderr, "%s: icu-config not found. Fix PATH or specify -O option\n", progname);
- return -1;
- }
-
- pkgconfigIsValid = false;
- }
-
- for (int32_t length = strlen(buf) - 1; length >= 0; length--) {
- if (buf[length] == '\n' || buf[length] == ' ') {
- buf[length] = 0;
- } else {
- break;
- }
- }
-
- if (!*buf) {
- fprintf(stderr, "%s: Unable to locate pkgdata.inc. Unable to parse the results of '%s'. Check paths or use the -O option to specify the path to pkgdata.inc.\n", progname, pkgconfigIsValid ? pkgconfigCmd : icuconfigCmd);
- return -1;
- }
-
- if (pkgconfigIsValid) {
- uprv_strcat(buf, U_FILE_SEP_STRING);
- uprv_strcat(buf, pkgdata);
- }
-
- buf[strlen(buf)] = 0;
-
- option->value = buf;
- option->doesOccur = true;
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-#ifdef CAN_WRITE_OBJ_CODE
- /* Create optMatchArch for genccode architecture detection */
-static void pkg_createOptMatchArch(char *optMatchArch) {
-#if !defined(WINDOWS_WITH_MSVC) || defined(USING_CYGWIN)
- const char* code = "void oma(){}";
- const char* source = "oma.c";
- const char* obj = "oma.obj";
- FileStream* stream = nullptr;
-
- stream = T_FileStream_open(source,"w");
- if (stream != nullptr) {
- T_FileStream_writeLine(stream, code);
- T_FileStream_close(stream);
-
- char cmd[LARGE_BUFFER_MAX_SIZE];
- snprintf(cmd, sizeof(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);
- }
-#endif
-}
-static void pkg_destroyOptMatchArch(char *optMatchArch) {
- if(T_FileStream_file_exists(optMatchArch) && !T_FileStream_remove(optMatchArch)){
- fprintf(stderr, "T_FileStream_remove failed to delete %s\n", optMatchArch);
- }
-}
-#endif
diff --git a/tools/icu/patches/75/source/tools/toolutil/pkg_genc.cpp b/tools/icu/patches/75/source/tools/toolutil/pkg_genc.cpp
deleted file mode 100644
index d51a52c8fff..00000000000
--- a/tools/icu/patches/75/source/tools/toolutil/pkg_genc.cpp
+++ /dev/null
@@ -1,1428 +0,0 @@
-// © 2016 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-/******************************************************************************
- * Copyright (C) 2009-2016, International Business Machines
- * Corporation and others. All Rights Reserved.
- *******************************************************************************
- */
-#include "unicode/utypes.h"
-
-#if U_PLATFORM_HAS_WIN32_API
-# define VC_EXTRALEAN
-# define WIN32_LEAN_AND_MEAN
-# define NOUSER
-# define NOSERVICE
-# define NOIME
-# define NOMCX
-#include
-#include
-# if defined(__clang__)
-# include
-# endif
-# ifdef __GNUC__
-# define WINDOWS_WITH_GNUC
-# endif
-#endif
-
-#if U_PLATFORM_IS_LINUX_BASED && U_HAVE_ELF_H
-# define U_ELF
-#endif
-
-#ifdef U_ELF
-# include
-# if defined(ELFCLASS64)
-# define U_ELF64
-# endif
- /* Old elf.h headers may not have EM_X86_64, or have EM_X8664 instead. */
-# ifndef EM_X86_64
-# define EM_X86_64 62
-# endif
-# define ICU_ENTRY_OFFSET 0
-#endif
-
-#include
-#include
-#include "unicode/putil.h"
-#include "cmemory.h"
-#include "cstring.h"
-#include "filestrm.h"
-#include "toolutil.h"
-#include "unicode/uclean.h"
-#include "uoptions.h"
-#include "pkg_genc.h"
-#include "filetools.h"
-#include "charstr.h"
-#include "unicode/errorcode.h"
-
-#define MAX_COLUMN ((uint32_t)(0xFFFFFFFFU))
-
-#define HEX_0X 0 /* 0x1234 */
-#define HEX_0H 1 /* 01234h */
-
-/* prototypes --------------------------------------------------------------- */
-static void
-getOutFilename(
- const char *inFilename,
- const char *destdir,
- char *outFilename,
- int32_t outFilenameCapacity,
- char *entryName,
- int32_t entryNameCapacity,
- const char *newSuffix,
- const char *optFilename);
-
-static uint32_t
-write8(FileStream *out, uint8_t byte, uint32_t column);
-
-static uint32_t
-write32(FileStream *out, uint32_t byte, uint32_t column);
-
-#if U_PLATFORM == U_PF_OS400
-static uint32_t
-write8str(FileStream *out, uint8_t byte, uint32_t column);
-#endif
-/* -------------------------------------------------------------------------- */
-
-/*
-Creating Template Files for New Platforms
-
-Let the cc compiler help you get started.
-Compile this program
- const unsigned int x[5] = {1, 2, 0xdeadbeef, 0xffffffff, 16};
-with the -S option to produce assembly output.
-
-For example, this will generate array.s:
-gcc -S array.c
-
-This will produce a .s file that may look like this:
-
- .file "array.c"
- .version "01.01"
-gcc2_compiled.:
- .globl x
- .section .rodata
- .align 4
- .type x,@object
- .size x,20
-x:
- .long 1
- .long 2
- .long -559038737
- .long -1
- .long 16
- .ident "GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-85)"
-
-which gives a starting point that will compile, and can be transformed
-to become the template, generally with some consulting of as docs and
-some experimentation.
-
-If you want ICU to automatically use this assembly, you should
-specify "GENCCODE_ASSEMBLY=-a name" in the specific config/mh-* file,
-where the name is the compiler or platform that you used in this
-assemblyHeader data structure.
-*/
-static const struct AssemblyType {
- const char *name;
- const char *header;
- const char *beginLine;
- const char *footer;
- int8_t hexType; /* HEX_0X or HEX_0h */
-} assemblyHeader[] = {
- /* For gcc assemblers, the meaning of .align changes depending on the */
- /* hardware, so we use .balign 16 which always means 16 bytes. */
- /* https://sourceware.org/binutils/docs/as/Pseudo-Ops.html */
- {"gcc",
- ".globl %s\n"
- "\t.section .note.GNU-stack,\"\",%%progbits\n"
- "#ifdef __CET__\n"
- "# include \n"
- "#endif\n"
- "\t.section .rodata\n"
- "\t.balign 16\n"
- "#ifdef U_HIDE_DATA_SYMBOL\n"
- "\t.hidden %s\n"
- "#endif\n"
- "\t.type %s,%%object\n"
- "%s:\n\n",
-
- ".long ",".size %s, .-%s\n",HEX_0X
- },
- {"gcc-darwin",
- /*"\t.section __TEXT,__text,regular,pure_instructions\n"
- "\t.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32\n"*/
- ".globl _%s\n"
- "#ifdef U_HIDE_DATA_SYMBOL\n"
- "\t.private_extern _%s\n"
- "#endif\n"
- "\t.data\n"
- "\t.const\n"
- "\t.balign 16\n"
- "_%s:\n\n",
-
- ".long ","",HEX_0X
- },
- /* macOS PPC should use `.p2align 4` instead `.balign 16` because is
- * unknown pseudo ops for such legacy system*/
- {"gcc-darwin-ppc",
- /*"\t.section __TEXT,__text,regular,pure_instructions\n"
- "\t.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32\n"*/
- ".globl _%s\n"
- "#ifdef U_HIDE_DATA_SYMBOL\n"
- "\t.private_extern _%s\n"
- "#endif\n"
- "\t.data\n"
- "\t.const\n"
- "\t.p2align 4\n"
- "_%s:\n\n",
-
- ".long ","",HEX_0X
- },
- {"gcc-cygwin",
- ".globl _%s\n"
- "\t.section .rodata\n"
- "\t.balign 16\n"
- "_%s:\n\n",
-
- ".long ","",HEX_0X
- },
- {"gcc-mingw64",
- ".globl %s\n"
- "\t.section .rodata\n"
- "\t.balign 16\n"
- "%s:\n\n",
-
- ".long ","",HEX_0X
- },
-/* 16 bytes alignment. */
-/* http://docs.oracle.com/cd/E19641-01/802-1947/802-1947.pdf */
- {"sun",
- "\t.section \".rodata\"\n"
- "\t.align 16\n"
- ".globl %s\n"
- "%s:\n",
-
- ".word ","",HEX_0X
- },
-/* 16 bytes alignment for sun-x86. */
-/* http://docs.oracle.com/cd/E19963-01/html/821-1608/eoiyg.html */
- {"sun-x86",
- "Drodata.rodata:\n"
- "\t.type Drodata.rodata,@object\n"
- "\t.size Drodata.rodata,0\n"
- "\t.globl %s\n"
- "\t.align 16\n"
- "%s:\n",
-
- ".4byte ","",HEX_0X
- },
-/* 1<<4 bit alignment for aix. */
-/* http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.aixassem%2Fdoc%2Falangref%2Fidalangref_csect_pseudoop.htm */
- {"xlc",
- ".globl %s{RO}\n"
- "\t.toc\n"
- "%s:\n"
- "\t.csect %s{RO}, 4\n",
-
- ".long ","",HEX_0X
- },
- {"aCC-ia64",
- "\t.file \"%s.s\"\n"
- "\t.type %s,@object\n"
- "\t.global %s\n"
- "\t.secalias .abe$0.rodata, \".rodata\"\n"
- "\t.section .abe$0.rodata = \"a\", \"progbits\"\n"
- "\t.align 16\n"
- "%s::\t",
-
- "data4 ","",HEX_0X
- },
- {"aCC-parisc",
- "\t.SPACE $TEXT$\n"
- "\t.SUBSPA $LIT$\n"
- "%s\n"
- "\t.EXPORT %s\n"
- "\t.ALIGN 16\n",
-
- ".WORD ","",HEX_0X
- },
-/* align 16 bytes */
-/* http://msdn.microsoft.com/en-us/library/dwa9fwef.aspx */
- {"nasm",
- "global %s\n"
-#if defined(_WIN32)
- "section .rdata align=16\n"
-#else
- "section .rodata align=16\n"
-#endif
- "%s:\n",
- " dd ","",HEX_0X
- },
- { "masm",
- "\tTITLE %s\n"
- "; generated by genccode\n"
- ".386\n"
- ".model flat\n"
- "\tPUBLIC _%s\n"
- "ICUDATA_%s\tSEGMENT READONLY PARA PUBLIC FLAT 'DATA'\n"
- "\tALIGN 16\n"
- "_%s\tLABEL DWORD\n",
- "\tDWORD ","\nICUDATA_%s\tENDS\n\tEND\n",HEX_0H
- },
- { "masm64",
- "\tTITLE %s\n"
- "; generated by genccode\n"
- "\tPUBLIC _%s\n"
- "ICUDATA_%s\tSEGMENT READONLY 'DATA'\n"
- "\tALIGN 16\n"
- "_%s\tLABEL DWORD\n",
- "\tDWORD ","\nICUDATA_%s\tENDS\n\tEND\n",HEX_0H
- }
-};
-
-static int32_t assemblyHeaderIndex = -1;
-static int32_t hexType = HEX_0X;
-
-U_CAPI UBool U_EXPORT2
-checkAssemblyHeaderName(const char* optAssembly) {
- int32_t idx;
- assemblyHeaderIndex = -1;
- for (idx = 0; idx < UPRV_LENGTHOF(assemblyHeader); idx++) {
- if (uprv_strcmp(optAssembly, assemblyHeader[idx].name) == 0) {
- assemblyHeaderIndex = idx;
- hexType = assemblyHeader[idx].hexType; /* set the hex type */
- return true;
- }
- }
-
- return false;
-}
-
-U_CAPI UBool U_EXPORT2
-checkCpuArchitecture(const char* optCpuArch) {
- return strcmp(optCpuArch, "x64") == 0 || strcmp(optCpuArch, "x86") == 0 || strcmp(optCpuArch, "arm64") == 0;
-}
-
-
-U_CAPI void U_EXPORT2
-printAssemblyHeadersToStdErr() {
- int32_t idx;
- fprintf(stderr, "%s", assemblyHeader[0].name);
- for (idx = 1; idx < UPRV_LENGTHOF(assemblyHeader); idx++) {
- fprintf(stderr, ", %s", assemblyHeader[idx].name);
- }
- fprintf(stderr,
- ")\n");
-}
-
-U_CAPI void U_EXPORT2
-writeAssemblyCode(
- const char *filename,
- const char *destdir,
- const char *optEntryPoint,
- const char *optFilename,
- char *outFilePath,
- size_t outFilePathCapacity) {
- uint32_t column = MAX_COLUMN;
- char entry[96];
- union {
- uint32_t uint32s[1024];
- char chars[4096];
- } buffer;
- FileStream *in, *out;
- size_t i, length, count;
-
- in=T_FileStream_open(filename, "rb");
- if(in==nullptr) {
- fprintf(stderr, "genccode: unable to open input file %s\n", filename);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- const char* newSuffix = nullptr;
-
- if (uprv_strcmp(assemblyHeader[assemblyHeaderIndex].name, "masm") == 0) {
- newSuffix = ".masm";
- }
- else if (uprv_strcmp(assemblyHeader[assemblyHeaderIndex].name, "nasm") == 0) {
- newSuffix = ".asm";
- } else {
- newSuffix = ".S";
- }
-
- getOutFilename(
- filename,
- destdir,
- buffer.chars,
- sizeof(buffer.chars),
- entry,
- sizeof(entry),
- newSuffix,
- optFilename);
- out=T_FileStream_open(buffer.chars, "w");
- if(out==nullptr) {
- fprintf(stderr, "genccode: unable to open output file %s\n", buffer.chars);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- if (outFilePath != nullptr) {
- if (uprv_strlen(buffer.chars) >= outFilePathCapacity) {
- fprintf(stderr, "genccode: filename too long\n");
- exit(U_ILLEGAL_ARGUMENT_ERROR);
- }
- uprv_strcpy(outFilePath, buffer.chars);
-#if defined (WINDOWS_WITH_GNUC) && U_PLATFORM != U_PF_CYGWIN
- /* Need to fix the file separator character when using MinGW. */
- swapFileSepChar(outFilePath, U_FILE_SEP_CHAR, '/');
-#endif
- }
-
- if(optEntryPoint != nullptr) {
- uprv_strcpy(entry, optEntryPoint);
- uprv_strcat(entry, "_dat");
- }
-
- /* turn dashes or dots in the entry name into underscores */
- length=uprv_strlen(entry);
- for(i=0; i= sizeof(buffer.chars)) {
- fprintf(stderr, "genccode: entry name too long (long filename?)\n");
- exit(U_ILLEGAL_ARGUMENT_ERROR);
- }
- T_FileStream_writeLine(out, buffer.chars);
- T_FileStream_writeLine(out, assemblyHeader[assemblyHeaderIndex].beginLine);
-
- for(;;) {
- memset(buffer.uint32s, 0, sizeof(buffer.uint32s));
- length=T_FileStream_read(in, buffer.uint32s, sizeof(buffer.uint32s));
- if(length==0) {
- break;
- }
- for(i=0; i<(length/sizeof(buffer.uint32s[0])); i++) {
- // TODO: What if the last read sees length not as a multiple of 4?
- column = write32(out, buffer.uint32s[i], column);
- }
- }
-
- T_FileStream_writeLine(out, "\n");
-
- count = snprintf(
- buffer.chars, sizeof(buffer.chars),
- assemblyHeader[assemblyHeaderIndex].footer,
- entry, entry, entry, entry,
- entry, entry, entry, entry);
- if (count >= sizeof(buffer.chars)) {
- fprintf(stderr, "genccode: entry name too long (long filename?)\n");
- exit(U_ILLEGAL_ARGUMENT_ERROR);
- }
- T_FileStream_writeLine(out, buffer.chars);
-
- if(T_FileStream_error(in)) {
- fprintf(stderr, "genccode: file read error while generating from file %s\n", filename);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- if(T_FileStream_error(out)) {
- fprintf(stderr, "genccode: file write error while generating from file %s\n", filename);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- T_FileStream_close(out);
- T_FileStream_close(in);
-}
-
-U_CAPI void U_EXPORT2
-writeCCode(
- const char *filename,
- const char *destdir,
- const char *optEntryPoint,
- const char *optName,
- const char *optFilename,
- char *outFilePath,
- size_t outFilePathCapacity) {
- uint32_t column = MAX_COLUMN;
- char buffer[4096], entry[96];
- FileStream *in, *out;
- size_t i, length, count;
-
- in=T_FileStream_open(filename, "rb");
- if(in==nullptr) {
- fprintf(stderr, "genccode: unable to open input file %s\n", filename);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- if(optName != nullptr) { /* prepend 'icudt28_' */
- // +2 includes the _ and the NUL
- if (uprv_strlen(optName) + 2 > sizeof(entry)) {
- fprintf(stderr, "genccode: entry name too long (long filename?)\n");
- exit(U_ILLEGAL_ARGUMENT_ERROR);
- }
- strcpy(entry, optName);
- strcat(entry, "_");
- } else {
- entry[0] = 0;
- }
-
- getOutFilename(
- filename,
- destdir,
- buffer,
- static_cast(sizeof(buffer)),
- entry + uprv_strlen(entry),
- static_cast(sizeof(entry) - uprv_strlen(entry)),
- ".c",
- optFilename);
-
- if (outFilePath != nullptr) {
- if (uprv_strlen(buffer) >= outFilePathCapacity) {
- fprintf(stderr, "genccode: filename too long\n");
- exit(U_ILLEGAL_ARGUMENT_ERROR);
- }
- uprv_strcpy(outFilePath, buffer);
-#if defined (WINDOWS_WITH_GNUC) && U_PLATFORM != U_PF_CYGWIN
- /* Need to fix the file separator character when using MinGW. */
- swapFileSepChar(outFilePath, U_FILE_SEP_CHAR, '/');
-#endif
- }
-
- out=T_FileStream_open(buffer, "w");
- if(out==nullptr) {
- fprintf(stderr, "genccode: unable to open output file %s\n", buffer);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- if(optEntryPoint != nullptr) {
- uprv_strcpy(entry, optEntryPoint);
- uprv_strcat(entry, "_dat");
- }
-
- /* turn dashes or dots in the entry name into underscores */
- length=uprv_strlen(entry);
- for(i=0; i= sizeof(buffer)) {
- fprintf(stderr, "genccode: entry name too long (long filename?)\n");
- exit(U_ILLEGAL_ARGUMENT_ERROR);
- }
- T_FileStream_writeLine(out, buffer);
-
- for(;;) {
- length=T_FileStream_read(in, buffer, sizeof(buffer));
- if(length==0) {
- break;
- }
- for(i=0; i= sizeof(buffer)) {
- fprintf(stderr, "genccode: entry name too long (long filename?)\n");
- exit(U_ILLEGAL_ARGUMENT_ERROR);
- }
- T_FileStream_writeLine(out, buffer);
-
- for(;;) {
- length=T_FileStream_read(in, buffer, sizeof(buffer));
- if(length==0) {
- break;
- }
- for(i=0; i= 0 ; i--)
-#endif
- {
- uint8_t value = ptrIdx[i];
- if (value || seenNonZero) {
- *(s++)=hexToStr[value>>4];
- *(s++)=hexToStr[value&0xF];
- seenNonZero = 1;
- }
- }
- if(hexType==HEX_0H) {
- *(s++)='h';
- }
- }
-
- *(s++)=0;
- T_FileStream_writeLine(out, bitFieldStr);
- return column;
-}
-
-static uint32_t
-write8(FileStream *out, uint8_t byte, uint32_t column) {
- char s[4];
- int i=0;
-
- /* convert the byte value to a string */
- if(byte>=100) {
- s[i++]=(char)('0'+byte/100);
- byte%=100;
- }
- if(i>0 || byte>=10) {
- s[i++]=(char)('0'+byte/10);
- byte%=10;
- }
- s[i++]=(char)('0'+byte);
- s[i]=0;
-
- /* write the value, possibly with comma and newline */
- if(column==MAX_COLUMN) {
- /* first byte */
- column=1;
- } else if(column<16) {
- T_FileStream_writeLine(out, ",");
- ++column;
- } else {
- T_FileStream_writeLine(out, ",\n");
- column=1;
- }
- T_FileStream_writeLine(out, s);
- return column;
-}
-
-#if U_PLATFORM == U_PF_OS400
-static uint32_t
-write8str(FileStream *out, uint8_t byte, uint32_t column) {
- char s[8];
-
- if (byte > 7)
- snprintf(s, sizeof(s), "\\x%X", byte);
- else
- snprintf(s, sizeof(s), "\\%X", byte);
-
- /* write the value, possibly with comma and newline */
- if(column==MAX_COLUMN) {
- /* first byte */
- column=1;
- T_FileStream_writeLine(out, "\"");
- } else if(column<24) {
- ++column;
- } else {
- T_FileStream_writeLine(out, "\"\n\"");
- column=1;
- }
- T_FileStream_writeLine(out, s);
- return column;
-}
-#endif
-
-static void
-getOutFilename(
- const char *inFilename,
- const char *destdir,
- char *outFilename,
- int32_t outFilenameCapacity,
- char *entryName,
- int32_t entryNameCapacity,
- const char *newSuffix,
- const char *optFilename) {
- const char *basename=findBasename(inFilename), *suffix=uprv_strrchr(basename, '.');
-
- icu::CharString outFilenameBuilder;
- icu::CharString entryNameBuilder;
- icu::ErrorCode status;
-
- /* copy path */
- if(destdir!=nullptr && *destdir!=0) {
- outFilenameBuilder.append(destdir, status);
- outFilenameBuilder.ensureEndsWithFileSeparator(status);
- } else {
- outFilenameBuilder.append(inFilename, static_cast