1
0
mirror of https://github.com/raspberrypi/pico-sdk.git synced 2025-08-07 17:02:52 +03:00

[Bazel] Fix bazel build, add presubmit (#1973)

* [Bazel] Fix bazel build, add presubmit

* Fixes a missing dep in the Bazel build breaking the host build.
* Automagically finds all board headers.
* Improves presubmit script polish for GH Action readiness.
* Adds a GitHub action workflow for the Bazel build.
* Disable failing checks
* Disables Windows, as there's a mix of real build errors and
  overly-ambitious checks that don't work on Windows.
* Disables extra checks temporarily since it's currently failing.
This commit is contained in:
armandomontanez
2024-10-12 15:41:43 -07:00
committed by GitHub
parent 03a82f3d2f
commit 07d6dc1315
8 changed files with 151 additions and 120 deletions

View File

@@ -14,12 +14,15 @@
from dataclasses import dataclass
import glob
import logging
import os
import re
import sys
from typing import Dict
from bazel_common import SDK_ROOT
from bazel_common import SDK_ROOT, setup_logging
_LOG = logging.getLogger(__file__)
CMAKE_FILE_TYPES = (
"**/CMakeLists.txt",
@@ -182,17 +185,17 @@ def OptionsAreEqual(bazel_option, cmake_option):
if bazel_option is None:
if cmake_option.name in CMAKE_ONLY_ALLOWLIST:
return True
print(f" {cmake_option.name} does not exist in Bazel")
_LOG.warning(f" {cmake_option.name} does not exist in Bazel")
return False
elif cmake_option is None:
if bazel_option.name in BAZEL_ONLY_ALLOWLIST:
return True
print(f" {bazel_option.name} does not exist in CMake")
_LOG.warning(f" {bazel_option.name} does not exist in CMake")
return False
elif not bazel_option.matches(cmake_option):
print(" Bazel and CMAKE definitions do not match:")
print(f" [CMAKE] {bazel_option}")
print(f" [BAZEL] {cmake_option}")
_LOG.error(" Bazel and CMAKE definitions do not match:")
_LOG.error(f" [CMAKE] {bazel_option}")
_LOG.error(f" [BAZEL] {cmake_option}")
return False
return True
@@ -224,22 +227,23 @@ def compare_build_systems():
for f in glob.glob(os.path.join(SDK_ROOT, p), recursive=True)
]
print("[1/2] Checking build system configuration flags...")
_LOG.info("[1/2] Checking build system configuration flags...")
build_options_ok = CompareOptions(
"PICO_BAZEL_CONFIG", bazel_files, "PICO_CMAKE_CONFIG", cmake_files
)
print("[2/2] Checking build system defines...")
_LOG.info("[2/2] Checking build system defines...")
build_defines_ok = CompareOptions(
"PICO_BUILD_DEFINE", bazel_files, "PICO_BUILD_DEFINE", cmake_files
)
if build_options_ok and build_defines_ok:
print("OK")
_LOG.info("OK")
return 0
return 1
if __name__ == "__main__":
setup_logging()
sys.exit(compare_build_systems())