• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# TensorFlow Lite for Objective-C
2
3package(default_visibility = ["//visibility:private"])
4
5licenses(["notice"])  # Apache 2.0
6
7load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
8
9SOURCES = glob([
10    "sources/*.h",
11    "sources/*.m",
12    "sources/*.mm",
13])
14
15API_HEADERS = glob([
16    "apis/*.h",
17])
18
19MINIMUM_OS_VERSION = "9.0"
20
21# Compiler flags for building regular non-test libraries.
22RELEASE_COPTS = [
23    # Enables language-specific warnings for Objective-C, Objective-C++, C, and C++.
24    "-Wall",
25    # Warns if functions, variables, and types marked with the deprecated attribute are being used.
26    "-Wdeprecated-declarations",
27    # Warns for errors in documentation.
28    "-Wdocumentation",
29    # Turns all warnings into errors.
30    "-Werror",
31    # Enables extra warning flags that are not enabled by -Wall.
32    "-Wextra",
33    # Warns if a global function is defined without a previous prototype declaration.
34    "-Wmissing-prototypes",
35    # From -Wextra. Disables warning when signed value is converted to unsigned value during comparison.
36    "-Wno-sign-compare",
37    # From -Wextra. Disables warning for unused parameters, which are common in delegate methods and block callbacks.
38    "-Wno-unused-parameter",
39    # Warns if a global or local variable or type declaration shadows another variable, parameter, type, class member, or instance variable.
40    "-Wshadow",
41    # Warns if a function is declared or defined without specifying the argument types. For a block with no args, use (void) instead of ().
42    "-Wstrict-prototypes",
43    # Warns if an @selector() expression is encountered with a method name that hasn't been defined yet.
44    "-Wundeclared-selector",
45    # Turn off warnings for headers not part of TensorFlow Lite Objective-C API.
46    "--system-header-prefix=tensorflow/lite/experimental/c/",
47]
48
49# Compiler flags for building test libraries.
50TEST_COPTS = RELEASE_COPTS + [
51    # From -Wall. Disables warning when passing nil to a callee that requires a non-null argument.
52    "-Wno-nonnull",
53    # Disables warning when a global or local variable or type declaration shadows another.
54    "-Wno-shadow",
55]
56
57# Default tags for filtering targets. Targets in this file are restricted to Apple platforms.
58DEFAULT_TAGS = [
59    "apple",
60]
61
62objc_library(
63    name = "TensorFlowLite",
64    srcs = SOURCES,
65    hdrs = API_HEADERS,
66    copts = RELEASE_COPTS,
67    tags = DEFAULT_TAGS,
68    deps = [
69        "//tensorflow/lite/experimental/c:c_api",
70    ],
71    alwayslink = 1,
72)
73
74ios_unit_test(
75    name = "TensorFlowLiteTests",
76    size = "small",
77    minimum_os_version = MINIMUM_OS_VERSION,
78    tags = DEFAULT_TAGS + [
79        # These sanitizer tests are not supported by iOS build toolchain (b/74292221).
80        # Disabled these for iOS test targets.
81        "noasan",
82        "notsan",
83        "nomsan",
84    ],
85    deps = [
86        ":TestsLib",
87    ],
88)
89
90objc_library(
91    name = "TestsLib",
92    testonly = 1,
93    srcs = glob([
94        "tests/*.m",
95    ]),
96    hdrs = glob([
97        "apis/*.h",
98        "sources/*.h",
99        "tests/*.h",
100    ]),
101    copts = TEST_COPTS,
102    data = [
103        "//tensorflow/lite:testdata/add.bin",
104        "//tensorflow/lite:testdata/add_quantized.bin",
105    ],
106    tags = DEFAULT_TAGS,
107    deps = [
108        ":TensorFlowLite",
109    ],
110)
111