From 5e365ecb600bd83e025435b1a454be7858b1027a Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Thu, 25 Feb 2021 21:52:59 +0100 Subject: [PATCH 1/9] Add CI coverage --- .bazelci/presubmit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 355cd59c22..e351b30c0c 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -37,6 +37,7 @@ tasks: rbe_ubuntu1604: test_targets: - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245 + - "..." - "//test/..." - "@examples//..." - "-//test/conflicting_deps:conflicting_deps_test" @@ -53,6 +54,7 @@ tasks: - "--enable_runfiles" # this is not enabled by default on windows and is necessary for the cargo build scripts windows_targets: &windows_targets - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245 + - "..." - "@examples//..." - "-@examples//ffi/rust_calling_c:matrix_dylib_test" - "-@examples//ffi/rust_calling_c:matrix_dynamically_linked" From c91c23414eedc590e0e90e2f0a0737021cc46226 Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Thu, 25 Feb 2021 21:59:03 +0100 Subject: [PATCH 2/9] Disable bindgen on windows --- .bazelci/presubmit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index e351b30c0c..aab21c3dd3 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -55,6 +55,7 @@ tasks: windows_targets: &windows_targets - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245 - "..." + - "-//bindgen/..." - "@examples//..." - "-@examples//ffi/rust_calling_c:matrix_dylib_test" - "-@examples//ffi/rust_calling_c:matrix_dynamically_linked" From dbb09e1aefb8edcbe6046ba945c54850b6c99186 Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Thu, 25 Feb 2021 22:26:02 +0100 Subject: [PATCH 3/9] Fix a test --- test/BUILD | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/BUILD b/test/BUILD index fb5c838cba..f2a76d5eb1 100644 --- a/test/BUILD +++ b/test/BUILD @@ -9,9 +9,17 @@ rule_test( rule = "@examples//hello_lib:hello_lib", ) +config_setting( + name = "is_windows", + constraint_values = ["@platforms//os:windows"], +) + rule_test( name = "hello_world_rule_test", - generates = ["hello_world"], + generates = select({ + ":is_windows": ["hello_world.exe"], + "//conditions:default": ["hello_world"], + }), rule = "@examples//hello_world:hello_world", ) From a684790ed67ca3987e4350f2cc2b6fd10aa11d3a Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Thu, 25 Feb 2021 22:36:32 +0100 Subject: [PATCH 4/9] Fix more tests --- .bazelci/presubmit.yml | 1 + test/unit/cc_info/cc_info_test.bzl | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index aab21c3dd3..63c9cfc2ee 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -56,6 +56,7 @@ tasks: - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245 - "..." - "-//bindgen/..." + - "-//test/load_arbitrary_tool/..." - "@examples//..." - "-@examples//ffi/rust_calling_c:matrix_dylib_test" - "-@examples//ffi/rust_calling_c:matrix_dynamically_linked" diff --git a/test/unit/cc_info/cc_info_test.bzl b/test/unit/cc_info/cc_info_test.bzl index 23674769df..c645f15197 100644 --- a/test/unit/cc_info/cc_info_test.bzl +++ b/test/unit/cc_info/cc_info_test.bzl @@ -3,6 +3,9 @@ load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") load("//rust:defs.bzl", "rust_binary", "rust_library", "rust_proc_macro", "rust_shared_library", "rust_static_library") +def _is_dylib_on_windows(ctx): + return ctx.target_platform_has_constraint(ctx.attr._windows[platform_common.ConstraintValueInfo]) + def _assert_cc_info_has_library_to_link(env, tut, type): asserts.true(env, CcInfo in tut, "rust_library should provide CcInfo") cc_info = tut[CcInfo] @@ -20,7 +23,10 @@ def _assert_cc_info_has_library_to_link(env, tut, type): if type == "cdylib": asserts.true(env, library_to_link.dynamic_library != None) asserts.equals(env, None, library_to_link.interface_library) - asserts.true(env, library_to_link.resolved_symlink_dynamic_library != None) + if _is_dylib_on_windows(env.ctx): + asserts.true(env, library_to_link.resolved_symlink_dynamic_library == None) + else: + asserts.true(env, library_to_link.resolved_symlink_dynamic_library != None) asserts.equals(env, None, library_to_link.resolved_symlink_interface_library) asserts.equals(env, None, library_to_link.static_library) asserts.equals(env, None, library_to_link.pic_static_library) @@ -66,7 +72,9 @@ def _staticlib_provides_cc_info_test_impl(ctx): rlib_provides_cc_info_test = analysistest.make(_rlib_provides_cc_info_test_impl) bin_does_not_provide_cc_info_test = analysistest.make(_bin_does_not_provide_cc_info_test_impl) staticlib_provides_cc_info_test = analysistest.make(_staticlib_provides_cc_info_test_impl) -cdylib_provides_cc_info_test = analysistest.make(_cdylib_provides_cc_info_test_impl) +cdylib_provides_cc_info_test = analysistest.make(_cdylib_provides_cc_info_test_impl, attrs = { + "_windows": attr.label(default = Label("@platforms//os:windows")), +}) proc_macro_does_not_provide_cc_info_test = analysistest.make(_proc_macro_does_not_provide_cc_info_test_impl) def _cc_info_test(): From 98c4b8db993d4f91b084d049b2e85136e8103f98 Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Thu, 25 Feb 2021 22:40:02 +0100 Subject: [PATCH 5/9] Disable test/test_env/ --- .bazelci/presubmit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 63c9cfc2ee..6ec3bd2c63 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -57,6 +57,7 @@ tasks: - "..." - "-//bindgen/..." - "-//test/load_arbitrary_tool/..." + - "-//test/test_env/..." - "@examples//..." - "-@examples//ffi/rust_calling_c:matrix_dylib_test" - "-@examples//ffi/rust_calling_c:matrix_dynamically_linked" From 6a2858c2f79f9def893482778d4243d3621adc37 Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Thu, 25 Feb 2021 22:51:07 +0100 Subject: [PATCH 6/9] Disable rust analyzer --- .bazelci/presubmit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 6ec3bd2c63..cfbc84294b 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -58,6 +58,7 @@ tasks: - "-//bindgen/..." - "-//test/load_arbitrary_tool/..." - "-//test/test_env/..." + - "-//tools/rust_analyzer/..." - "@examples//..." - "-@examples//ffi/rust_calling_c:matrix_dylib_test" - "-@examples//ffi/rust_calling_c:matrix_dynamically_linked" From 70d5bf0e983ce2901cbe40b1e06eeff86754b835 Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Thu, 25 Feb 2021 22:55:56 +0100 Subject: [PATCH 7/9] Disable test/proto --- .bazelci/presubmit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index cfbc84294b..5fae00c214 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -58,6 +58,7 @@ tasks: - "-//bindgen/..." - "-//test/load_arbitrary_tool/..." - "-//test/test_env/..." + - "-//test/proto/..." - "-//tools/rust_analyzer/..." - "@examples//..." - "-@examples//ffi/rust_calling_c:matrix_dylib_test" From b426d70e77e0839b003493a1a61521012397881e Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Thu, 25 Feb 2021 22:59:28 +0100 Subject: [PATCH 8/9] Disable //tools/runfiles --- .bazelci/presubmit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 5fae00c214..b5a1ed1aad 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -60,6 +60,7 @@ tasks: - "-//test/test_env/..." - "-//test/proto/..." - "-//tools/rust_analyzer/..." + - "-//tools/runfiles/..." - "@examples//..." - "-@examples//ffi/rust_calling_c:matrix_dylib_test" - "-@examples//ffi/rust_calling_c:matrix_dynamically_linked" From 9c5828a054f5b90bcd85196e7057141b550080ff Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Thu, 25 Feb 2021 23:03:12 +0100 Subject: [PATCH 9/9] Disable //test/rustfmt --- .bazelci/presubmit.yml | 1 + test/BUILD | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index b5a1ed1aad..18ebd70c84 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -61,6 +61,7 @@ tasks: - "-//test/proto/..." - "-//tools/rust_analyzer/..." - "-//tools/runfiles/..." + - "-//test/rustfmt/..." - "@examples//..." - "-@examples//ffi/rust_calling_c:matrix_dylib_test" - "-@examples//ffi/rust_calling_c:matrix_dynamically_linked" diff --git a/test/BUILD b/test/BUILD index f2a76d5eb1..be389ad7d4 100644 --- a/test/BUILD +++ b/test/BUILD @@ -9,15 +9,10 @@ rule_test( rule = "@examples//hello_lib:hello_lib", ) -config_setting( - name = "is_windows", - constraint_values = ["@platforms//os:windows"], -) - rule_test( name = "hello_world_rule_test", generates = select({ - ":is_windows": ["hello_world.exe"], + "//rust/platform:windows": ["hello_world.exe"], "//conditions:default": ["hello_world"], }), rule = "@examples//hello_world:hello_world",