From 4ebb7c59dcda9e59923652728fb2050bda0b8e5d Mon Sep 17 00:00:00 2001 From: Bart Louwers Date: Sat, 13 May 2023 17:19:36 +0200 Subject: [PATCH] Add formatting for Bazel files (#1137) --- .pre-commit-config.yaml | 7 ++ BUILD.bazel | 11 ++-- WORKSPACE | 2 +- bazel/flags.bzl | 2 +- platform/ios/BUILD.bazel | 121 ++++++++++++++++++---------------- platform/ios/bazel/macros.bzl | 24 +++---- 6 files changed, 93 insertions(+), 74 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 28a74b902..bbe669d6e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,3 +5,10 @@ repos: - id: clang-format files: '.*\.(hpp|cpp|h)' exclude: '(vendor/.*|platform/(ios|darwin)/.*|test/ios/.*|render-test/ios/.*|benchmark/ios/.*)' +- repo: https://github.com/keith/pre-commit-buildifier + rev: 6.1.0 + hooks: + - id: buildifier +ci: + # sometimes fails https://github.com/keith/pre-commit-buildifier/issues/13 + skip: [buildifier] diff --git a/BUILD.bazel b/BUILD.bazel index 4304c42d6..eab0cfba0 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -47,12 +47,15 @@ cc_library( genrule( name = "git_hash", - local = True, outs = ["hash"], - visibility = ["//visibility:public"], cmd = """ git rev-parse HEAD > $@ - """ + """, + local = True, + visibility = ["//visibility:public"], ) -exports_files(["LICENSE.md"], visibility = ["//visibility:public"]) +exports_files( + ["LICENSE.md"], + visibility = ["//visibility:public"], +) diff --git a/WORKSPACE b/WORKSPACE index 9ee85cd4b..aee010ba2 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -47,4 +47,4 @@ load( "xcodeproj_rules_dependencies", ) -xcodeproj_rules_dependencies() \ No newline at end of file +xcodeproj_rules_dependencies() diff --git a/bazel/flags.bzl b/bazel/flags.bzl index 677739c7e..c04c14667 100644 --- a/bazel/flags.bzl +++ b/bazel/flags.bzl @@ -27,7 +27,7 @@ CPP_FLAGS = WARNING_FLAGS + [ "-fexceptions", "-fno-rtti", "-ftemplate-depth=1024", - "-std=c++17" + "-std=c++17", ] """ Compilation flags related to the Maplibre codebase. Relevant for all .cpp .mm and .m code diff --git a/platform/ios/BUILD.bazel b/platform/ios/BUILD.bazel index ae1333b98..6d490b2a4 100644 --- a/platform/ios/BUILD.bazel +++ b/platform/ios/BUILD.bazel @@ -115,7 +115,7 @@ info_plist( info_plist( name = "info_static_plist", out = "Info-static.plist", - base_info_plist = "platform/ios/framework/Info-static.plist" + base_info_plist = "platform/ios/framework/Info-static.plist", ) apple_xcframework( @@ -154,6 +154,7 @@ ios_framework( # sdk for the static target which includes the resources. objc_library( name = "sdk", + hdrs = _PUBLIC_HEADERS, data = ["resources"], sdk_dylibs = [ "libz", @@ -170,7 +171,6 @@ objc_library( "objc-sdk", "objcpp-sdk", ], - hdrs = _PUBLIC_HEADERS ) # sdk for the dynamic target. Lacking the resources bundle since for dynamic @@ -386,107 +386,113 @@ objc_library( objc_library( name = "iosapp", srcs = [ - "platform/ios/app/MBXAppDelegate.m", - "platform/ios/app/MBXState.m", - "platform/ios/app/MBXCustomLocationViewController.m", - "platform/ios/app/MBXSnapshotsViewController.m", - "platform/ios/app/MBXFrameTimeGraphView.m", - "platform/ios/app/main.m", - "platform/ios/app/MBXCustomCalloutView.m", - "platform/ios/app/MBXViewController.m", - "platform/ios/app/MBXUserLocationAnnotationView.m", - "platform/ios/app/MBXAnnotationView.m", - "platform/ios/app/MBXOfflinePacksTableViewController.m", - "platform/ios/app/MBXEmbeddedMapViewController.m", - "platform/ios/app/MBXOrnamentsViewController.m", - "platform/ios/app/MBXStateManager.m", - "platform/darwin/app/LimeGreenStyleLayer.m", "platform/darwin/app/LimeGreenStyleLayer.h", + "platform/darwin/app/LimeGreenStyleLayer.m", + "platform/ios/app/MBXAnnotationView.m", + "platform/ios/app/MBXAppDelegate.m", "platform/ios/app/MBXCustomCalloutView.h", + "platform/ios/app/MBXCustomCalloutView.m", + "platform/ios/app/MBXCustomLocationViewController.m", + "platform/ios/app/MBXEmbeddedMapViewController.m", + "platform/ios/app/MBXFrameTimeGraphView.m", + "platform/ios/app/MBXOfflinePacksTableViewController.m", + "platform/ios/app/MBXOrnamentsViewController.m", + "platform/ios/app/MBXSnapshotsViewController.m", + "platform/ios/app/MBXState.m", + "platform/ios/app/MBXStateManager.m", + "platform/ios/app/MBXUserLocationAnnotationView.m", + "platform/ios/app/MBXViewController.m", + "platform/ios/app/main.m", ], hdrs = [ - "platform/ios/app/MBXAppDelegate.h", - "platform/ios/app/MBXState.h", - "platform/ios/app/MBXCustomLocationViewController.h", - "platform/ios/app/MBXSnapshotsViewController.h", - "platform/ios/app/MBXFrameTimeGraphView.h", - "platform/ios/app/MBXViewController.h", - "platform/ios/app/MBXUserLocationAnnotationView.h", "platform/ios/app/MBXAnnotationView.h", - "platform/ios/app/MBXOfflinePacksTableViewController.h", + "platform/ios/app/MBXAppDelegate.h", + "platform/ios/app/MBXCustomLocationViewController.h", "platform/ios/app/MBXEmbeddedMapViewController.h", + "platform/ios/app/MBXFrameTimeGraphView.h", + "platform/ios/app/MBXOfflinePacksTableViewController.h", "platform/ios/app/MBXOrnamentsViewController.h", + "platform/ios/app/MBXSnapshotsViewController.h", + "platform/ios/app/MBXState.h", "platform/ios/app/MBXStateManager.h", - "platform/ios/app/MLNMapView_Experimental.h" + "platform/ios/app/MBXUserLocationAnnotationView.h", + "platform/ios/app/MBXViewController.h", + "platform/ios/app/MLNMapView_Experimental.h", ], includes = [ "platform/darwin/app", + "platform/darwin/src", "platform/ios/src", - "platform/darwin/src" ], sdk_frameworks = [ - "GLKit" # needed for LimeGreenStyleLayer + "GLKit", # needed for LimeGreenStyleLayer ], deps = [ - "sdk-headers" + "sdk-headers", ], ) _IOS_APPLICATION_RESOURCES = [ - "platform/ios/app/numeric_filter_style.json", - "platform/ios/app/missing_icon.json", - "platform/ios/app/points.geojson", - "platform/ios/app/polyline.geojson", - "platform/ios/app/Settings.bundle", - "platform/ios/app/Main.storyboard", - "platform/ios/app/threestates.geojson", - "platform/ios/app/LaunchScreen.storyboard", - "platform/ios/app/simple_route.json", - "platform/ios/app/fill_filter_style.json", - "platform/ios/app/Assets.xcassets", - "platform/darwin/test/amsterdam.geojson" - ] + glob([ - "platform/ios/app/*.lproj/**", - ]) + "platform/ios/app/numeric_filter_style.json", + "platform/ios/app/missing_icon.json", + "platform/ios/app/points.geojson", + "platform/ios/app/polyline.geojson", + "platform/ios/app/Settings.bundle", + "platform/ios/app/Main.storyboard", + "platform/ios/app/threestates.geojson", + "platform/ios/app/LaunchScreen.storyboard", + "platform/ios/app/simple_route.json", + "platform/ios/app/fill_filter_style.json", + "platform/ios/app/Assets.xcassets", + "platform/darwin/test/amsterdam.geojson", +] + glob([ + "platform/ios/app/*.lproj/**", +]) ios_application( name = "App", bundle_id = "com.maplibre.app", - families = ["iphone", "ipad"], + families = [ + "iphone", + "ipad", + ], infoplists = ["platform/ios/app/Info.plist"], minimum_os_version = "12.0", + resources = _IOS_APPLICATION_RESOURCES, visibility = ["//visibility:public"], deps = [ - "sdk", "iosapp", + "sdk", ], - resources = _IOS_APPLICATION_RESOURCES ) ios_application( name = "AppDynamicLib", bundle_id = "com.maplibre.app", - families = ["iphone", "ipad"], + families = [ + "iphone", + "ipad", + ], + frameworks = [ + "MapLibre.link", + ], infoplists = ["platform/ios/app/Info.plist"], minimum_os_version = "12.0", + resources = _IOS_APPLICATION_RESOURCES, visibility = ["//visibility:public"], deps = [ "iosapp", ], - frameworks = [ - "MapLibre.link" - ], - resources = _IOS_APPLICATION_RESOURCES ) # Outputs a file with the size of MapLibre as a dynamic library in bytes genrule( name = "size", srcs = [ - "AppDynamicLib" + "AppDynamicLib", ], outs = [ - "size-out" + "size-out", ], cmd = """ unzip $(location AppDynamicLib) @@ -496,10 +502,13 @@ genrule( xcodeproj( name = "xcodeproj", + minimum_xcode_version = "14", project_name = "MapLibre", tags = ["manual"], top_level_targets = [ - top_level_target("App", target_environments = ["simulator"]), + top_level_target( + "App", + target_environments = ["simulator"], + ), ], - minimum_xcode_version = "14" ) diff --git a/platform/ios/bazel/macros.bzl b/platform/ios/bazel/macros.bzl index b1406a664..4ee50978d 100644 --- a/platform/ios/bazel/macros.bzl +++ b/platform/ios/bazel/macros.bzl @@ -1,14 +1,14 @@ def info_plist(name, base_info_plist, out, **kwargs): - native.genrule( - name = name, - srcs = [ - base_info_plist, - "//:git_hash" - ], - outs = [ - out - ], - cmd = """ + native.genrule( + name = name, + srcs = [ + base_info_plist, + "//:git_hash", + ], + outs = [ + out, + ], + cmd = """ cp $(location {}) $@ plutil -replace MLNCommitHash -string $$(cat $(location //:git_hash)) $@ @@ -16,5 +16,5 @@ def info_plist(name, base_info_plist, out, **kwargs): sem_version=0.0.0 plutil -replace MLNSemanticVersionString -string $$sem_version $@ """.format(base_info_plist), - **kwargs -) \ No newline at end of file + **kwargs + )