mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-02 15:16:03 +00:00
[Bazel] Update README with examples
Reviewed By: chandlerc Differential Revision: https://reviews.llvm.org/D105245
This commit is contained in:
parent
627733b5f0
commit
9cc1ddd393
2
utils/bazel/.gitignore
vendored
2
utils/bazel/.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
# Bazel artifacts
|
||||
/bazel-*
|
||||
**/bazel-*
|
||||
|
||||
# Per-user bazelrc files
|
||||
user.bazelrc
|
||||
|
@ -75,56 +75,5 @@ configuration you'd like to use that isn't supported, please send a patch.
|
||||
|
||||
# Usage
|
||||
|
||||
To use in dependent projects using Bazel, you can import LLVM (e.g. as a
|
||||
submodule or using `http_archive`) and then use the provided configuration rule.
|
||||
|
||||
FIXME: This needs to be updated to a commit that exists once such a commit
|
||||
exists.
|
||||
FIXME: It shouldn't be necessary to configure `http_archive` twice for the same
|
||||
archive (though caching means this isn't too expensive).
|
||||
|
||||
```starlark
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
|
||||
|
||||
LLVM_COMMIT = "0a1f0ee78122fc0642e8a1a18e1b2bc89c813387"
|
||||
|
||||
LLVM_SHA256 = "4f59737ccfdad2cfb4587d796ce97c1eb5433de7ea0f57f248554b83e92d81d2"
|
||||
|
||||
http_archive(
|
||||
name = "llvm-project-raw",
|
||||
build_file_content = "#empty",
|
||||
sha256 = LLVM_SHA256,
|
||||
strip_prefix = "llvm-project-" + LLVM_COMMIT,
|
||||
urls = ["https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT)],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "llvm-bazel",
|
||||
sha256 = LLVM_SHA256,
|
||||
strip_prefix = "llvm-project-{}/utils/bazel".format(LLVM_COMMIT),
|
||||
urls = ["https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT)],
|
||||
)
|
||||
|
||||
load("@llvm-bazel//:configure.bzl", "llvm_configure")
|
||||
|
||||
llvm_configure(
|
||||
name = "llvm-project",
|
||||
src_path = ".",
|
||||
src_workspace = "@llvm-project-raw//:WORKSPACE",
|
||||
)
|
||||
|
||||
load("@llvm-bazel//:terminfo.bzl", "llvm_terminfo_system")
|
||||
|
||||
maybe(
|
||||
llvm_terminfo_system,
|
||||
name = "llvm_terminfo",
|
||||
)
|
||||
|
||||
load("@llvm-bazel//:zlib.bzl", "llvm_zlib_system")
|
||||
|
||||
maybe(
|
||||
llvm_zlib_system,
|
||||
name = "llvm_zlib",
|
||||
)
|
||||
```
|
||||
To use in dependent projects using Bazel, you can import LLVM and then use the
|
||||
provided configuration rule. See example usage in the `examples/` directory.
|
||||
|
48
utils/bazel/examples/http_archive/WORKSPACE
Normal file
48
utils/bazel/examples/http_archive/WORKSPACE
Normal file
@ -0,0 +1,48 @@
|
||||
# This file is 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
|
||||
|
||||
"""An example WORKSPACE for configuring LLVM using http_archive."""
|
||||
|
||||
workspace(name = "http_archive_example")
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
# Replace with the LLVM commit you want to use.
|
||||
LLVM_COMMIT = "09ac97ce350316b95b8cddb796d52f71b6f68296"
|
||||
|
||||
# The easiest way to calculate this for a new commit is to set it to empty and
|
||||
# then run a bazel build and it will report the digest necessary to cache the
|
||||
# archive and make the build reproducible.
|
||||
LLVM_SHA256 = "2fb1aa06d12f8db349a27426cb0ced062987c5c2a75143c69f4284929e2750ff"
|
||||
|
||||
# FIXME: It shouldn't be necessary to use http_archive twice here. Caching
|
||||
# should mean that this isn't too expensive though.
|
||||
|
||||
http_archive(
|
||||
name = "llvm-project-raw",
|
||||
build_file_content = "#empty",
|
||||
sha256 = LLVM_SHA256,
|
||||
strip_prefix = "llvm-project-" + LLVM_COMMIT,
|
||||
urls = ["https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT)],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "llvm-bazel",
|
||||
sha256 = LLVM_SHA256,
|
||||
strip_prefix = "llvm-project-{}/utils/bazel".format(LLVM_COMMIT),
|
||||
urls = ["https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT)],
|
||||
)
|
||||
|
||||
load("@llvm-bazel//:configure.bzl", "llvm_configure", "llvm_disable_optional_support_deps")
|
||||
|
||||
llvm_configure(
|
||||
name = "llvm-project",
|
||||
src_path = ".",
|
||||
src_workspace = "@llvm-project-raw//:WORKSPACE",
|
||||
)
|
||||
|
||||
# Disables optional dependencies for Support like zlib and terminfo. You may
|
||||
# instead want to configure them using the macros in the corresponding bzl
|
||||
# files.
|
||||
llvm_disable_optional_support_deps()
|
26
utils/bazel/examples/submodule/WORKSPACE
Normal file
26
utils/bazel/examples/submodule/WORKSPACE
Normal file
@ -0,0 +1,26 @@
|
||||
# This file is 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
|
||||
|
||||
"""An example WORKSPACE for configuring LLVM using a git submodule."""
|
||||
|
||||
workspace(name = "submodule_example")
|
||||
|
||||
# Or wherever your submodule is located.
|
||||
SUBMODULE_PATH = "third_party/llvm-project"
|
||||
|
||||
local_repository(
|
||||
name = "llvm-bazel",
|
||||
path = SUBMODULE_PATH + "/utils/bazel",
|
||||
)
|
||||
|
||||
llvm_configure(
|
||||
name = "llvm-project",
|
||||
src_path = SUBMODULE_PATH,
|
||||
src_workspace = "@submodule_example//:WORKSPACE",
|
||||
)
|
||||
|
||||
# Disables optional dependencies for Support like zlib and terminfo. You may
|
||||
# instead want to configure them using the macros in the corresponding bzl
|
||||
# files.
|
||||
llvm_disable_optional_support_deps()
|
Loading…
x
Reference in New Issue
Block a user