xref: /aosp_15_r20/external/libusb/Android.bp (revision 86b64dcb59b3a0b37502ecd56e119234366a6f7e)
1package {
2    default_applicable_licenses: ["external_libusb_license"],
3}
4
5// Added automatically by a large-scale-change that took the approach of
6// 'apply every license found to every target'. While this makes sure we respect
7// every license restriction, it may not be entirely correct.
8//
9// e.g. GPL in an MIT project might only apply to the contrib/ directory.
10//
11// Please consider splitting the single license below into multiple licenses,
12// taking care not to lose any license_kind information, and overriding the
13// default license using the 'licenses: [...]' property on targets as needed.
14//
15// For unused files, consider creating a 'fileGroup' with "//visibility:private"
16// to attach the license to, and including a comment whether the files may be
17// used in the current project.
18//
19// large-scale-change included anything that looked like it might be a license
20// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
21//
22// Please consider removing redundant or irrelevant files from 'license_text:'.
23// See: http://go/android-license-faq
24license {
25    name: "external_libusb_license",
26    visibility: [":__subpackages__"],
27    license_kinds: [
28        "SPDX-license-identifier-GPL",
29        "SPDX-license-identifier-LGPL",
30        "SPDX-license-identifier-LGPL-2.1",
31        "SPDX-license-identifier-LGPL-3.0",
32        "SPDX-license-identifier-MIT",
33    ],
34    license_text: [
35        "COPYING",
36        "NOTICE",
37    ],
38}
39
40cc_defaults {
41    name: "libusb_defaults",
42    host_supported: true,
43    vendor_available: true,
44
45    srcs: [
46        "libusb/core.c",
47        "libusb/descriptor.c",
48        "libusb/hotplug.c",
49        "libusb/io.c",
50        "libusb/sync.c",
51        "libusb/strerror.c",
52    ],
53
54    target: {
55        linux: {
56            srcs: [
57                "libusb/os/events_posix.c",
58                "libusb/os/linux_usbfs.c",
59                "libusb/os/threads_posix.c",
60                "libusb/os/linux_netlink.c",
61            ],
62        },
63
64        android: {
65            local_include_dirs: [
66                "android",
67            ],
68
69            cflags: ["-Werror"],
70        },
71
72        darwin: {
73            srcs: [
74                "libusb/os/events_posix.c",
75                "libusb/os/darwin_usb.c",
76                "libusb/os/threads_posix.c",
77            ],
78
79            local_include_dirs: [
80                "darwin",
81            ],
82
83            host_ldlibs: [
84                "-framework CoreFoundation",
85                "-framework IOKit",
86                "-framework Security",
87                "-lobjc",
88            ],
89
90            cflags: [
91                "-Wno-deprecated-declarations",
92                "-Wno-unguarded-availability",
93            ],
94        },
95
96        host_linux: {
97            local_include_dirs: [
98                "linux",
99            ],
100
101            cflags: ["-Werror"],
102        },
103
104        windows: {
105            srcs: [
106                "libusb/os/events_windows.c",
107                "libusb/os/threads_windows.c",
108                "libusb/os/windows_common.c",
109                "libusb/os/windows_usbdk.c",
110                "libusb/os/windows_winusb.c",
111            ],
112
113            local_include_dirs: [
114                "windows",
115            ],
116
117            cflags: [
118                "-Wno-error=pragma-pack",
119                "-Wno-error=missing-field-initializers",
120                "-Wno-error=ignored-attributes",
121            ],
122
123            enabled: true,
124        },
125    },
126
127    local_include_dirs: [
128        "libusb",
129        "libusb/os",
130    ],
131
132    cflags: [
133        "-Wall",
134        "-Wno-error=sign-compare",
135        "-Wno-error=switch",
136        "-Wno-error=unused-function",
137        "-Wno-unused-parameter",
138        "-DENABLE_LOGGING=1",
139    ],
140
141    shared_libs: ["liblog"],
142    export_include_dirs: ["include"],
143}
144
145cc_library {
146    name: "libusb",
147    defaults: ["libusb_defaults"],
148}
149
150// "libusb_plaform" should be depended upon only by programs running on Android
151// at OS level (e.g. Android platform services). The reason is that programs
152// using "libusb_platform" must have permission to access netlink sockets.
153cc_library {
154    name: "libusb_platform",
155    defaults: ["libusb_defaults"],
156    target: {
157        android: {
158            cflags: [
159                "-Werror",
160                "-DANDROID_OS", // ANDROID_OS flag signals that the program
161                // using libusb runs at Android OS level and allows netlink
162                // event monitoring. See libusb/os/linux_usbfs.h.
163            ],
164        },
165    },
166}
167