google / nearby

šŸæļø A collection of projects focused on connectivity that enable building cross-device experiences.
https://developers.google.com/nearby
Apache License 2.0
763 stars 156 forks source link

Trouble building the fast pair library #3042

Open Thomas-Campion-Bose opened 1 week ago

Thomas-Campion-Bose commented 1 week ago

I am attempting to build the fastpair library on Windows, but am having issues with the bazel build system. There doesn't seem to be much documentation on how to build each of the packages. Some clarification would be greatly appreciated!

Thomas-Campion-Bose commented 1 week ago
tc1061336@USMA-26LSG24 MINGW64 /c/src/nearby/fastpair
$ bazel build :all
ERROR: no such package 'third_party/magic_enum': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - C:/src/nearby/third_party/magic_enum
ERROR: C:/src/nearby/fastpair/retroactive/BUILD:17:11: no such package 'third_party/magic_enum': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - C:/src/nearby/third_party/magic_enum and referenced by '//fastpair/retroactive:retroactive'
ERROR: Analysis of target '//fastpair:fast_pair_service' failed; build aborted: Analysis failed
INFO: Elapsed time: 3.887s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
FAILED:
    Fetching repository @@googletest~; starting
    Fetching repository @@abseil-cpp~; starting
    Fetching repository @@bazel_tools~cc_configure_extension~local_config_cc; starting
    Fetching repository @@rules_proto; starting
    Fetching repository @@boringssl~; starting
    Fetching C:/users/tc1061336/_bazel_tc1061336/tzb6rvzl/external/rules_proto; Extracting 5.3.0-21.7.tar.gz
    Fetching repository @@_main~_repo_rules~com_github_protobuf_matchers; starting
    Fetching repository @@_main~_repo_rules~com_google_nisaba; starting ... (9 fetches)

When attempting to build all the targets in fastpair package I get this output. I ran git submodule update --init --recursive in order to pull in all the third party deps. There is no reference to the magic_enum in any of the source other than the retroactive source, not in any of the third party dependencies/ git submodules etc.

Please advise on how to proceed. Thanks

Thomas-Campion-Bose commented 1 week ago

I attempted to build it on WSL Fedora. I received a different error but a similar issue, with reference to non-existing source.

āÆ bazelisk --migrate build :all
2024/11/18 10:19:57 Downloading https://releases.bazel.build/7.4.1/release/bazel-7.4.1-linux-x86_64...
Downloading: 56 MB out of 56 MB (100%)
Extracting Bazel installation...
Starting local Bazel server and connecting to it...

--- Running Bazel with all incompatible flags

bazel build :all --incompatible_allow_tags_propagation --incompatible_always_check_depset_elements --incompatible_always_include_files_in_data --incompatible_auto_exec_groups --incompatible_check_sharding_support --incompatible_check_testonly_for_output_files --incompatible_check_visibility_for_toolchains --incompatible_config_setting_private_default_visibility --incompatible_default_to_explicit_init_py --incompatible_depset_for_java_output_source_jars --incompatible_depset_for_libraries_to_link_getter --incompatible_disable_native_android_rules --incompatible_disable_native_apple_binary_rule --incompatible_disable_native_repo_rules --incompatible_disable_non_executable_java_binary --incompatible_disable_objc_library_transition --incompatible_disable_starlark_host_transitions --incompatible_disable_target_provider_fields --incompatible_disallow_empty_glob --incompatible_disallow_legacy_py_provider --incompatible_disallow_sdk_frameworks_attributes --incompatible_disallow_struct_provider_syntax --incompatible_disallow_symlink_file_to_dir --incompatible_disallow_unsound_directory_outputs --incompatible_do_not_split_linking_cmdline --incompatible_dont_enable_host_nonhost_crosstool_features --incompatible_dont_use_javasourceinfoprovider --incompatible_enable_android_toolchain_resolution --incompatible_enable_apple_toolchain_resolution --incompatible_enable_deprecated_label_apis --incompatible_enable_proto_toolchain_resolution --incompatible_enforce_config_setting_visibility --incompatible_exclusive_test_sandboxed --incompatible_existing_rules_immutable_view --incompatible_fail_on_unknown_attributes --incompatible_fix_package_group_reporoot_syntax --incompatible_java_common_parameters --incompatible_legacy_local_fallback --incompatible_make_thinlto_command_lines_standalone --incompatible_merge_fixed_and_default_shell_env --incompatible_merge_genfiles_directory --incompatible_modify_execution_info_additive --incompatible_new_actions_api --incompatible_no_attr_license --incompatible_no_implicit_file_export --incompatible_no_implicit_watch_label --incompatible_no_rule_outputs_param --incompatible_objc_alwayslink_by_default --incompatible_objc_provider_remove_linking_info --incompatible_package_group_has_public_syntax --incompatible_py2_outputs_are_suffixed --incompatible_py3_is_default --incompatible_python_disable_py2 --incompatible_python_disallow_native_rules --incompatible_remote_build_event_upload_respect_no_cache --incompatible_remote_dangling_symlinks --incompatible_remote_downloader_send_all_headers --incompatible_remote_output_paths_relative_to_input_root --incompatible_remote_results_ignore_disk --incompatible_remote_symlinks --incompatible_remote_use_new_exit_code_for_lost_inputs --incompatible_remove_legacy_whole_archive --incompatible_require_ctx_in_configure_features --incompatible_require_linker_input_cc_api --incompatible_run_shell_command_string --incompatible_sandbox_hermetic_tmp --incompatible_stop_exporting_language_modules --incompatible_strict_action_env --incompatible_struct_has_no_methods --incompatible_top_level_aspects_require_providers --incompatible_unambiguous_label_stringification --incompatible_use_cc_configure_from_rules_cc --incompatible_use_host_features --incompatible_use_plus_in_repo_names --incompatible_use_python_toolchains --incompatible_validate_top_level_header_inclusions --incompatible_visibility_private_attributes_at_definition
WARNING: Option 'incompatible_disable_native_apple_binary_rule' is deprecated
WARNING: Option 'incompatible_remote_build_event_upload_respect_no_cache' is deprecated: --incompatible_remote_build_event_upload_respect_no_cache has been deprecated in favor of --remote_build_event_upload=minimal.
WARNING: For repository 'platforms', the root module requires module version platforms@0.0.8, but got platforms@0.0.9 in the resolved dependency graph.
WARNING: For repository 'bazel_skylib', the root module requires module version bazel_skylib@1.5.0, but got bazel_skylib@1.6.1 in the resolved dependency graph.
WARNING: For repository 'com_google_googletest', the root module requires module version googletest@1.14.0, but got googletest@1.14.0.bcr.1 in the resolved dependency graph.
ERROR: Traceback (most recent call last):
        File "/virtual_builtins_bzl/common/cc/cc_binary.bzl", line 926, column 17, in <toplevel>
Error in rule: in call to rule(), parameter 'outputs' is deprecated and will be removed soon. It may be temporarily re-enabled by setting --incompatible_no_rule_outputs_param=false
ERROR: Error computing the main repository mapping: Internal error while loading Starlark builtins for @@bazel_tools//tools/build_defs/repo:local.bzl: Failed to load builtins sources: at /virtual_builtins_bzl/exports.bzl:25:5: at /virtual_builtins_bzl/common/exports.bzl:17:6: initialization of module 'common/cc/cc_binary.bzl' (internal) failed
Computing main repo mapping:

--- Running Bazel with no incompatible flags

bazel build :all
ERROR: no such package 'buildenv/target': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - /home/thcampion/nearby/buildenv/target
ERROR: /home/thcampion/nearby/fastpair/BUILD:82:11: no such package 'buildenv/target': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - /home/thcampion/nearby/buildenv/target and referenced by '//fastpair:fast_pair_events'
ERROR: Analysis of target '//fastpair:fast_pair_events' failed; build aborted: Analysis failed
INFO: Elapsed time: 3.597s, Critical Path: 0.02s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
FAILED:
    Fetching repository @@abseil-cpp~; starting
    Fetching repository @@bazel_tools~cc_configure_extension~local_config_cc; starting
    Fetching repository @@googletest~; starting
Failure: Command failed, even without incompatible flags.
Thomas-Campion-Bose commented 1 week ago

I am able to build the connections library for Linux however, by following the README.

āÆ CC=clang CXX=clang++ bazelisk build -s --check_visibility=false //connections:core  --spawn_strategy=standalone --verbose_failures
INFO: Analyzed target //connections:core (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //connections:core up-to-date:
  bazel-bin/connections/libcore.a
  bazel-bin/connections/libcore.so
INFO: Elapsed time: 0.196s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
Thomas-Campion-Bose commented 1 week ago

I made more progress by removing some referenced but un-resolvable source in the BUILD files, the diff is below. Still isn't building, stuck on GenProto command failure.

āÆ git diff */BUILD
diff --git a/fastpair/common/BUILD b/fastpair/common/BUILD
index ab62e395..0fdba705 100644
--- a/fastpair/common/BUILD
+++ b/fastpair/common/BUILD
@@ -48,7 +48,6 @@ cc_library(
         "//fastpair/proto:fastpair_cc_proto",
         "//internal/crypto_cros",
         "//internal/platform:types",
-        "//internal/preferences",
         "@com_google_absl//absl/base:core_headers",
         "@com_google_absl//absl/container:flat_hash_map",
         "@com_google_absl//absl/status",
āÆ git diff *BUILD
diff --git a/fastpair/BUILD b/fastpair/BUILD
index 7f5f5799..7f6685ed 100644
--- a/fastpair/BUILD
+++ b/fastpair/BUILD
@@ -22,7 +22,6 @@ cc_library(
     name = "fast_pair_controller",
     srcs = ["fast_pair_controller.cc"],
     hdrs = ["fast_pair_controller.h"],
-    compatible_with = ["//buildenv/target:non_prod"],
     visibility = ["//:__subpackages__"],
     deps = [
         "//fastpair/common",
@@ -59,7 +58,6 @@ cc_test(
 cc_library(
     name = "fast_pair_seeker",
     hdrs = ["fast_pair_seeker.h"],
-    compatible_with = ["//buildenv/target:non_prod"],
     visibility = ["//:__subpackages__"],
     deps = [
         "//fastpair/common",

Failing build output:
ERROR: /home/thcampion/nearby/fastpair/proto/BUILD:20:14: Generating proto_library //fastpair/proto:fastpair_proto failed: (Exit 1): protoc failed: error executing GenProto command (from target //fastpair/proto:fastpair_proto) 
  (cd /home/thcampion/.cache/bazel/_bazel_thcampion/5fb4aaefadf94cc2ad26c9cad49b73af/execroot/_main && \
  exec env - \
    BAZEL_CXXOPTS='-std=c++20' \
    PATH='/home/thcampion/.cache/bazelisk/downloads/sha256/c97f02133adce63f0c28678ac1f21d65fa8255c80429b588aeeba8a1fac6202b/bin:/home/thcampion/.nix-profile/bin:/home/thcampion/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/home/thcampion/.vscode-server/bin/e8653663e8840adaf45af01eab5c627a5af81807/bin/remote-cli:/home/thcampion/.nix-profile/bin:/home/thcampion/.local/bin:/home/thcampion/bin:/home/thcampion/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/WindowsApps/22955VineelSai.FedoraWSL_40.0.0.0_x64__qz230bc1wsk9j:/mnt/c/Program Files/CyberSafe/bin:/mnt/c/Program Files (x86)/CyberSafe/bin:/mnt/c/local/Python:/mnt/c/local/Python/Scripts:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH:/mnt/c/Program Files/dotnet:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/qtil/llvm14/bin:/mnt/c/Program Files/usbipd-win:/mnt/c/local/platform-tools:/mnt/c/Program Files (x86)/Qualcomm/QUTS/bin:/mnt/c/local:/mnt/c/Program Files/Git/mingw64/libexec/git-core:/mnt/c/Program Files/Git/usr/bin:/mnt/c/git-sdk-64:/mnt/c/Users/tc1061336/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/tc1061336/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/tc1061336/AppData/Local/Programs/Git/cmd:/mnt/c/src/SpitfireTools:/home/thcampion/go/bin:/home/thcampion/.local/lib/python3.12/site-packages:/mnt/c/Program\ Files\ \(x86\)/QTIL/BlueSuite\ 3.3.18:/home/thcampion/go/bin:/home/thcampion/.local/lib/python3.12/site-packages:/mnt/c/Program\ Files\ \(x86\)/QTIL/BlueSuite\ 3.3.18' \
  bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/protobuf~/protoc '--cpp_out=bazel-out/k8-fastbuild/bin' -I. fastpair/proto/cache.proto fastpair/proto/data.proto fastpair/proto/enum.proto fastpair/proto/fast_pair_string.proto fastpair/proto/fastpair_rpcs.proto)
# Configuration: 26311207faea7ee1150dc887e7071e1e86ca4352006707e41ff20ed454572059
# Execution platform: @@platforms//host:host
third_party/nearby/fastpair/proto/enum.proto: File not found.
fastpair/proto/cache.proto:19:1: Import "third_party/nearby/fastpair/proto/enum.proto" was not found or had errors.
fastpair/proto/cache.proto:76:12: "FastPairFeature" is not defined.
Target //fastpair:fast_pair_seeker failed to build
ERROR: /home/thcampion/nearby/fastpair/common/BUILD:17:11 Compiling fastpair/common/pair_failure.cc failed: (Exit 1): protoc failed: error executing GenProto command (from target //fastpair/proto:fastpair_proto) 
  (cd /home/thcampion/.cache/bazel/_bazel_thcampion/5fb4aaefadf94cc2ad26c9cad49b73af/execroot/_main && \
  exec env - \
    BAZEL_CXXOPTS='-std=c++20' \
    PATH='/home/thcampion/.cache/bazelisk/downloads/sha256/c97f02133adce63f0c28678ac1f21d65fa8255c80429b588aeeba8a1fac6202b/bin:/home/thcampion/.nix-profile/bin:/home/thcampion/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/home/thcampion/.vscode-server/bin/e8653663e8840adaf45af01eab5c627a5af81807/bin/remote-cli:/home/thcampion/.nix-profile/bin:/home/thcampion/.local/bin:/home/thcampion/bin:/home/thcampion/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/WindowsApps/22955VineelSai.FedoraWSL_40.0.0.0_x64__qz230bc1wsk9j:/mnt/c/Program Files/CyberSafe/bin:/mnt/c/Program Files (x86)/CyberSafe/bin:/mnt/c/local/Python:/mnt/c/local/Python/Scripts:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH:/mnt/c/Program Files/dotnet:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/qtil/llvm14/bin:/mnt/c/Program Files/usbipd-win:/mnt/c/local/platform-tools:/mnt/c/Program Files (x86)/Qualcomm/QUTS/bin:/mnt/c/local:/mnt/c/Program Files/Git/mingw64/libexec/git-core:/mnt/c/Program Files/Git/usr/bin:/mnt/c/git-sdk-64:/mnt/c/Users/tc1061336/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/tc1061336/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/tc1061336/AppData/Local/Programs/Git/cmd:/mnt/c/src/SpitfireTools:/home/thcampion/go/bin:/home/thcampion/.local/lib/python3.12/site-packages:/mnt/c/Program\ Files\ \(x86\)/QTIL/BlueSuite\ 3.3.18:/home/thcampion/go/bin:/home/thcampion/.local/lib/python3.12/site-packages:/mnt/c/Program\ Files\ \(x86\)/QTIL/BlueSuite\ 3.3.18' \
  bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/protobuf~/protoc '--cpp_out=bazel-out/k8-fastbuild/bin' -I. fastpair/proto/cache.proto fastpair/proto/data.proto fastpair/proto/enum.proto fastpair/proto/fast_pair_string.proto fastpair/proto/fastpair_rpcs.proto)
# Configuration: 26311207faea7ee1150dc887e7071e1e86ca4352006707e41ff20ed454572059
# Execution platform: @@platforms//host:host
bourdakos1 commented 1 week ago

Hi @Thomas-Campion-Bose, it looks like the imports in the fastpair proto files arenā€™t correct. Try removing ā€œthird_party/nearbyā€ from the beginning of the imports.

Unfortunately, we donā€™t have any GitHub actions for testing the fastpair build, so the GitHub code is prone to breaking. If you are able to get this building successfully, let me know and I can make the necessary changes and add a test to keep this package more stable in the future :)

Thomas-Campion-Bose commented 1 week ago

Hi @bourdakos1, I appreciate the prompt response. I think a few libraries/tests within fast pair are broken. I have documented a list of targets below that require non-trivial fixes (i.e. removal of auth manager, but continued usage). I have attached the output from the failing builds along with the current diff I have on my local branch.

  1. fast_pair_service/test, makes reference to authentication manager and account managers that seem to have been removed from the source.
  2. fast_pair_controller, lots of little issues, also an issue with the logging macros in absl referencing undefined macros. May need a whole logging overhaul
  3. fast_pair_seeker, builds after fixing

diff_output.txt fast_pair_controller.txt fast_service_controller.txt

Thomas-Campion-Bose commented 1 week ago

Link to my fork: https://github.com/Thomas-Campion-Bose/nearby.git Branch: fastpair-broken-build

bourdakos1 commented 1 week ago

Thanks! This is all very helpful :) Iā€™ll work on getting these changes upstreamed

Thomas-Campion-Bose commented 1 week ago

Is there anyway you could point me to a commit that is working for the fastpair package? Trying to evaluate how useful it would be for automated fastpair validation.

bourdakos1 commented 1 week ago

Iā€™m not entirely sure if the fastpair code exported to GitHub has ever been buildable, so trying old commits might not provide much value. Iā€™m working towards getting all of the open sourced packages in this repo to a buildable state, but we arenā€™t fully there yet.

Thomas-Campion-Bose commented 1 week ago

Okay good to know. So is this code used internally to any success? I am just trying to evaluate if contributing to this effort would bear any fruit any reasonable time frame. Also are there any other google supported frameworks for validating an OEM fast pair provider implementation other than the Validator app?

bourdakos1 commented 6 days ago

It might not be worth your time. We are considering removing the package, since we don't have anyone committed to maintaining the external copy.