-
-
Notifications
You must be signed in to change notification settings - Fork 135
Bazel build on windows and linux #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hugooole
wants to merge
15
commits into
jeremy-rifkin:main
Choose a base branch
from
hugooole:zhiguo/bazel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4c79312
update
zhiguo-rbs db09137
update
hugooole ccb9f9c
update
hugooole 492f806
support windows
hugooole 7900553
update
hugooole 9d23a04
update
hugooole 42d2ecf
update ci
hugooole 71686d7
dynamic link on windows
hugooole 1a43cfe
update
hugooole e04602e
fix flag bugs on windows
hugooole 34b0ea9
test on macos
hugooole 68e10a2
format BUILD file
hugooole 1527943
add apple_support
hugooole 28096ec
update
hugooole 6be3065
update
hugooole File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| cmake-build-debug |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| test --strip=never | ||
| test --test_output=all | ||
| test --copt=-g | ||
| test --spawn_strategy=local | ||
| test --compilation_mode=dbg | ||
| build --strip=never | ||
| build --spawn_strategy=local | ||
| build --compilation_mode=dbg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 8.4.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,7 @@ bazel-*/ | |
| cmake-build-*/ | ||
|
|
||
| test/jank/data | ||
|
|
||
| # bazel out | ||
| bazel-* | ||
| MODULE.bazel.lock | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,104 @@ | ||
| load("@rules_cc//cc:defs.bzl", "cc_library") | ||
|
|
||
| COMMON_FLAGS = [ | ||
| "--std=c++11", | ||
| "-fPIC", | ||
| "-Wall", | ||
| "-Wextra", | ||
| "-Werror=return-type", | ||
| "-Wundef", | ||
| "-g", | ||
| "-O0", | ||
| "-gdwarf-4", | ||
| "-fPIC", | ||
| ] | ||
|
|
||
| GCC_FLAGS = COMMON_FLAGS + [ | ||
| "-Wuseless-cast", | ||
| "-Wmaybe-uninitialized", | ||
| "-fdiagnostics-color=always", | ||
| ] | ||
|
|
||
| CLANG_FLAGS = COMMON_FLAGS + ["-fcolor-diagnostics"] | ||
|
|
||
| cc_library( | ||
| name = "cpptrace", | ||
| srcs = glob([ | ||
| "src/**/*.hpp", | ||
| "src/**/*.cpp", | ||
| ]), | ||
| local_defines = [ | ||
| "CPPTRACE_GET_SYMBOLS_WITH_LIBDWARF", | ||
| "CPPTRACE_DEMANGLE_WITH_CXXABI", | ||
| "CPPTRACE_UNWIND_WITH_LIBUNWIND" | ||
| ], | ||
| hdrs = glob([ | ||
| "include/cpptrace/*.hpp", | ||
| "include/ctrace/*.h", | ||
| ]), | ||
| copts = select( | ||
| { | ||
| "@rules_cc//cc/compiler:msvc-cl": [ | ||
| "/W4", | ||
| "/permissive-", | ||
| "/FS", | ||
| ], | ||
| "@rules_cc//cc/compiler:gcc": [ | ||
| "-Wall", | ||
| "-Wextra", | ||
| "-Werror=return-type", | ||
| "-Wundef", | ||
| "-Wuninitialized", | ||
| "-fPIC", | ||
| "-std=c++11", | ||
| ], | ||
| "@rules_cc//cc/compiler:clang": CLANG_FLAGS, | ||
| "//conditions:default": COMMON_FLAGS, | ||
| }, | ||
| ), | ||
| defines = ["CPPTRACE_STATIC_DEFINE"], | ||
| includes = [ | ||
| "include", | ||
| "src" | ||
| ], | ||
| deps = [ | ||
| "@libdwarf//:libdwarf", | ||
| "@libunwind//:libunwind" | ||
| ], | ||
| copts = [ | ||
| "-Wall", | ||
| "-Wextra", | ||
| "-Werror=return-type", | ||
| "-Wundef", | ||
| "-Wuninitialized", | ||
| "-fPIC", | ||
| "-std=c++11" | ||
| "src", | ||
| ], | ||
| linkopts = select({ | ||
| "@platforms//os:windows": ["dbghelp.lib"], | ||
| "//conditions:default": [], | ||
| }), | ||
| linkstatic = select({ | ||
| "@platforms//os:windows": False, | ||
| "//conditions:default": True, | ||
| }), | ||
| local_defines = select({ | ||
| "@platforms//os:windows": [ | ||
| "CPPTRACE_DEMANGLE_WITH_WINAPI", | ||
| "CPPTRACE_GET_SYMBOLS_WITH_DBGHELP", | ||
| "CPPTRACE_UNWIND_WITH_DBGHELP", | ||
| ], | ||
| "@platforms//os:linux": [ | ||
| "CPPTRACE_HAS_DL_FIND_OBJECT", | ||
| "CPPTRACE_DEMANGLE_WITH_CXXABI", | ||
| "CPPTRACE_UNWIND_WITH_LIBUNWIND", | ||
| "CPPTRACE_GET_SYMBOLS_WITH_LIBDWARF", | ||
| ], | ||
| "@platforms//os:macos": [ | ||
| "CPPTRACE_HAS_MACH_VM", | ||
| "CPPTRACE_DEMANGLE_WITH_CXXABI", | ||
| "CPPTRACE_GET_SYMBOLS_WITH_LIBDWARF", | ||
| "CPPTRACE_UNWIND_WITH_EXECINFO", | ||
| ], | ||
| "//conditions:default": ["NOMINMAX"], | ||
| }) + select({ | ||
| "@rules_cc//cc/compiler:msvc-cl": [], | ||
| "//conditions:default": [ | ||
| "HAS_ATTRIBUTE_PACKED", | ||
| "CPPTRACE_HAS_CXX_EXCEPTION_TYPE", | ||
| ], | ||
| }), | ||
| visibility = ["//visibility:public"], | ||
| deps = select({ | ||
| "@platforms//os:linux": [ | ||
| "@libdwarf", | ||
| "@libunwind", | ||
| ], | ||
| "@platforms//os:macos": [ | ||
| "@libdwarf", | ||
| ], | ||
| "//conditions:default": [], | ||
| }), | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,104 +1,16 @@ | ||
| """cpptrace""" | ||
|
|
||
| module( | ||
| name = "cpptrace", | ||
| ) | ||
|
|
||
| bazel_dep(name = "googletest", version = "1.14.0") | ||
| bazel_dep(name = "bazel_skylib", version = "1.7.1") | ||
| bazel_dep(name = "rules_foreign_cc", version = "0.11.1") | ||
| bazel_dep(name = "zstd", version = "1.5.6") | ||
| bazel_dep(name = "zlib", version = "1.3.1") | ||
| bazel_dep(name = "xz", version = "5.4.5.bcr.2") | ||
| bazel_dep(name = "toolchains_llvm", version = "1.1.2") | ||
|
|
||
| # Configure and register the toolchain. | ||
| llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True) | ||
|
|
||
| llvm.toolchain( | ||
| llvm_versions = { | ||
| "": "18.1.8", | ||
| }, | ||
| sha256 = { | ||
| "": "54ec30358afcc9fb8aa74307db3046f5187f9fb89fb37064cdde906e062ebf36", | ||
| }, | ||
| strip_prefix = { | ||
| "": "clang+llvm-18.1.8-x86_64-linux-gnu-ubuntu-18.04", | ||
| }, | ||
| urls = { | ||
| "": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/clang+llvm-18.1.8-x86_64-linux-gnu-ubuntu-18.04.tar.xz"], | ||
| }, | ||
| ) | ||
|
|
||
| use_repo(llvm, "llvm_toolchain") | ||
|
|
||
| register_toolchains("@llvm_toolchain//:all", dev_dependency = True) | ||
|
|
||
| http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
|
||
| http_archive( | ||
| name = "libdwarf", | ||
| build_file_content = | ||
| """ | ||
| package(default_visibility = ["//visibility:public"]) | ||
| load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") | ||
|
|
||
| filegroup( | ||
| name = "sources", | ||
| srcs = glob(["**/*"]), | ||
| ) | ||
| cmake( | ||
| name = "libdwarf", | ||
| build_args = ["-j12"], | ||
| lib_source = ":sources", | ||
| out_static_libs = ["libdwarf.a"], | ||
| copts = ["-Wall", "-Werror"], | ||
| deps = [ | ||
| "@zstd", | ||
| "@zlib" | ||
| ] | ||
| ) | ||
| """, | ||
| sha256 = "4ab8ae7b4b7aa42453725054b348f4fdb2460d5ba644199a1305311c718ff416", | ||
| strip_prefix = "libdwarf-code-0.10.1", | ||
| url = "https://github.com/davea42/libdwarf-code/archive/refs/tags/v0.10.1.tar.gz", | ||
| ) | ||
|
|
||
|
|
||
|
|
||
| http_archive( | ||
| name = "libunwind", | ||
| build_file_content = | ||
| """ | ||
| package(default_visibility = ["//visibility:public"]) | ||
| load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make") | ||
|
|
||
| filegroup( | ||
| name = "sources", | ||
| srcs = glob(["**/*"]), | ||
| ) | ||
| configure_make( | ||
| name = "libunwind", | ||
| args = ["-j12"], | ||
| autoreconf = True, | ||
| configure_in_place = True, | ||
| autoreconf_options = [ | ||
| "-i", | ||
| ], | ||
| lib_source = ":sources", | ||
| out_static_libs = [ | ||
| "libunwind.a", | ||
| "libunwind-coredump.a", | ||
| "libunwind-ptrace.a", | ||
| "libunwind-x86_64.a", | ||
| "libunwind-generic.a", | ||
| "libunwind-setjmp.a" | ||
| ], | ||
| deps = [ | ||
| "@xz//:lzma" | ||
| ] | ||
| ) | ||
| """, | ||
| sha256 = "38833b7b1582db7d76485a62a213706c9252b3dab7380069fea5824e823d8e41", | ||
| strip_prefix = "libunwind-1.8.1", | ||
| url = "https://github.com/libunwind/libunwind/archive/refs/tags/v1.8.1.tar.gz", | ||
| ) | ||
|
|
||
| version = "1.0.4", | ||
| compatibility_level = 1, | ||
| bazel_compatibility = [">=8.0.0"], | ||
| ) | ||
|
|
||
| bazel_dep(name = "apple_support", version = "1.24.3", repo_name = "build_bazel_apple_support") | ||
| bazel_dep(name = "rules_cc", version = "0.2.8") | ||
| bazel_dep(name = "libdwarf", version = "2.2.0") | ||
| bazel_dep(name = "libunwind", version = "1.8.1") | ||
| bazel_dep(name = "platforms", version = "1.0.0") | ||
| bazel_dep(name = "bazel_skylib", version = "1.8.2") | ||
| bazel_dep(name = "googletest", version = "1.17.0.bcr.1", dev_dependency = True) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an option that needs to be specified by anyone using the static cpptrace build, it shouldn't be set by cpptrace itself for cpptrace's sources.