Adding libyaml submodule and getting it building. (#6319)
The yaml_util.* files are here to ensure the cmake/bazel configuration is
correct and don't yet do anything meaningful.
diff --git a/build_tools/bazel/workspace.bzl b/build_tools/bazel/workspace.bzl
index 076c3a3..49ed2d6 100644
--- a/build_tools/bazel/workspace.bzl
+++ b/build_tools/bazel/workspace.bzl
@@ -35,6 +35,13 @@
path = paths.join(iree_path, "third_party/flatcc"),
)
+ maybe(
+ native.new_local_repository,
+ name = "com_github_yaml_libyaml",
+ build_file = iree_repo_alias + "//:build_tools/third_party/libyaml/BUILD.overlay",
+ path = paths.join(iree_path, "third_party/libyaml"),
+ )
+
# TODO(scotttodd): TensorFlow is squatting on the vulkan_headers repo name, so
# we use a temporary one until resolved. Theirs is set to an outdated version.
maybe(
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
index d6413f9..00063a2 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
@@ -55,6 +55,7 @@
"@com_google_benchmark//:benchmark": ["benchmark"],
"@com_github_dvidelabs_flatcc//:flatcc": ["flatcc"],
"@com_github_dvidelabs_flatcc//:runtime": ["flatcc::runtime"],
+ "@com_github_yaml_libyaml//:yaml": ["yaml"],
"@com_google_googletest//:gtest": ["gmock", "gtest"],
"@spirv_cross//:spirv_cross_lib": ["spirv-cross-msl"],
"@cpuinfo": ["cpuinfo"],
diff --git a/build_tools/third_party/libyaml/BUILD.overlay b/build_tools/third_party/libyaml/BUILD.overlay
new file mode 100644
index 0000000..ca7ede9
--- /dev/null
+++ b/build_tools/third_party/libyaml/BUILD.overlay
@@ -0,0 +1,38 @@
+# Copyright 2021 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+package(default_visibility = ["//visibility:public"])
+
+cc_library(
+ name = "yaml",
+ srcs = [
+ "src/api.c",
+ "src/dumper.c",
+ "src/emitter.c",
+ "src/loader.c",
+ "src/parser.c",
+ "src/reader.c",
+ "src/scanner.c",
+ "src/writer.c",
+ "src/yaml_private.h",
+ ],
+ hdrs = [
+ "include/yaml.h",
+ ],
+ copts = [
+ "-D_CRT_SECURE_NO_WARNINGS",
+ "-DYAML_DECLARE_STATIC",
+ '-DYAML_VERSION_STRING=\\"0.2.5\\"',
+ "-DYAML_VERSION_MAJOR=0",
+ "-DYAML_VERSION_MINOR=2",
+ "-DYAML_VERSION_PATCH=5",
+ "-Iexternal/com_github_yaml_libyaml/include/",
+ ],
+ includes = [
+ "include/",
+ ],
+ strip_include_prefix = "include",
+)
diff --git a/build_tools/third_party/libyaml/CMakeLists.txt b/build_tools/third_party/libyaml/CMakeLists.txt
new file mode 100644
index 0000000..d060fe6
--- /dev/null
+++ b/build_tools/third_party/libyaml/CMakeLists.txt
@@ -0,0 +1,44 @@
+# Copyright 2021 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+set(LIBYAML_ROOT "${IREE_ROOT_DIR}/third_party/libyaml/")
+
+external_cc_library(
+ PACKAGE
+ yaml
+ NAME
+ yaml
+ ROOT
+ ${LIBYAML_ROOT}
+ INCLUDES
+ "${FLATCC_ROOT}/include"
+ SRCS
+ "src/api.c"
+ "src/dumper.c"
+ "src/emitter.c"
+ "src/loader.c"
+ "src/parser.c"
+ "src/reader.c"
+ "src/scanner.c"
+ "src/writer.c"
+ "src/yaml_private.h"
+ HDRS
+ "include/yaml.h"
+ COPTS
+ "-D_CRT_SECURE_NO_WARNINGS"
+ "-DYAML_DECLARE_STATIC"
+ "-DYAML_VERSION_STRING=\"0.2.5\""
+ "-DYAML_VERSION_MAJOR=0"
+ "-DYAML_VERSION_MINOR=2"
+ "-DYAML_VERSION_PATCH=5"
+ INCLUDES
+ "${LIBYAML_ROOT}/include"
+ PUBLIC
+)
+
+if(MSVC)
+ target_compile_options(yaml_yaml PRIVATE /wd4996)
+endif()