blob: 9e2ac184c9428049aa218a2999a044b8af7184f3 [file] [log] [blame]
# Copyright 2015 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/android/config.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//media/media_options.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")
if (is_android) {
# For generate_jni().
import("//build/config/android/rules.gni")
}
# Common configuration for targets in the media/midi directory.
config("midi_config") {
if (use_alsa && use_udev) {
defines = [
"USE_ALSA",
"USE_UDEV",
]
}
visibility = [ ":*" ]
}
# USB MIDI specific source files that are used in Android port, and unit tests.
# These can't easily be a source set because "midi" is a component and the
# component export flags must always be the same.
usb_midi_sources = [
"midi_manager_usb.cc",
"midi_manager_usb.h",
"usb_midi_descriptor_parser.cc",
"usb_midi_descriptor_parser.h",
"usb_midi_device.h",
"usb_midi_export.h",
"usb_midi_input_stream.cc",
"usb_midi_input_stream.h",
"usb_midi_jack.h",
"usb_midi_output_stream.cc",
"usb_midi_output_stream.h",
]
# Android specific Java source files that are used to generate jni header files.
if (is_android) {
android_library("midi_java") {
deps = [
"//base:base_java",
"//base:jni_java",
"//build/android:build_java",
"//third_party/androidx:androidx_annotation_annotation_java",
]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
sources = [
"java/src/org/chromium/midi/MidiDeviceAndroid.java",
"java/src/org/chromium/midi/MidiInputPortAndroid.java",
"java/src/org/chromium/midi/MidiManagerAndroid.java",
"java/src/org/chromium/midi/MidiOutputPortAndroid.java",
"java/src/org/chromium/midi/UsbMidiDeviceAndroid.java",
"java/src/org/chromium/midi/UsbMidiDeviceFactoryAndroid.java",
]
}
generate_jni("midi_jni_headers") {
sources = [
"java/src/org/chromium/midi/MidiDeviceAndroid.java",
"java/src/org/chromium/midi/MidiInputPortAndroid.java",
"java/src/org/chromium/midi/MidiManagerAndroid.java",
"java/src/org/chromium/midi/MidiOutputPortAndroid.java",
"java/src/org/chromium/midi/UsbMidiDeviceAndroid.java",
"java/src/org/chromium/midi/UsbMidiDeviceFactoryAndroid.java",
]
}
}
component("midi") {
sources = [
"message_util.cc",
"message_util.h",
"midi_export.h",
"midi_manager.cc",
"midi_manager.h",
"midi_message_queue.cc",
"midi_message_queue.h",
"midi_service.cc",
"midi_service.h",
"midi_switches.cc",
"midi_switches.h",
"task_service.cc",
"task_service.h",
]
configs += [ ":midi_config" ]
defines = [ "MIDI_IMPLEMENTATION" ]
deps = [
":mojo",
"//base",
]
libs = []
if (is_android) {
# TODO(yhirano): Consider having "android" subdirectory.
sources += [
"midi_device_android.cc",
"midi_device_android.h",
"midi_input_port_android.cc",
"midi_input_port_android.h",
"midi_manager_android.cc",
"midi_manager_android.h",
"midi_output_port_android.cc",
"midi_output_port_android.h",
"usb_midi_device_android.cc",
"usb_midi_device_android.h",
"usb_midi_device_factory_android.cc",
"usb_midi_device_factory_android.h",
] + usb_midi_sources
# Since the USB sources are part of the component.
defines += [ "EXPORT_USB_MIDI" ]
deps += [
":midi_jni_headers",
"//base:i18n",
]
}
if (is_apple) {
sources += [
"midi_manager_mac.cc",
"midi_manager_mac.h",
]
frameworks = [
"CoreAudio.framework",
"CoreFoundation.framework",
"CoreMIDI.framework",
]
}
if (is_win) {
deps += [ "//services/device/public/cpp/usb" ]
sources += [
"midi_manager_win.cc",
"midi_manager_win.h",
"midi_manager_winrt.cc",
"midi_manager_winrt.h",
]
libs += [ "setupapi.lib" ]
# This library is included in base in static builds.
if (is_component_build) {
libs += [ "cfgmgr32.lib" ]
}
}
if (use_alsa && use_udev) {
deps += [ "//crypto" ]
libs += [ "asound" ]
sources += [
"midi_manager_alsa.cc",
"midi_manager_alsa.h",
]
}
if (use_udev) {
deps += [ "//device/udev_linux" ]
}
}
mojom("mojo") {
sources = [ "midi_service.mojom" ]
deps = [ "//mojo/public/mojom/base" ]
}
test("midi_unittests") {
use_xvfb = use_xvfb_in_this_config
sources = [
"message_util_unittest.cc",
"midi_manager_unittest.cc",
"midi_manager_usb_unittest.cc",
"midi_message_queue_unittest.cc",
"task_service_unittest.cc",
"usb_midi_descriptor_parser_unittest.cc",
"usb_midi_input_stream_unittest.cc",
"usb_midi_output_stream_unittest.cc",
]
configs += [ ":midi_config" ]
deps = [
":midi",
":mojo",
"//base/test/:run_all_unittests",
"//base/test/:test_support",
"//testing/gtest",
]
if (is_android) {
deps += [ ":midi_java" ]
} else {
sources += usb_midi_sources
}
if (is_apple) {
sources += [ "midi_manager_mac_unittest.cc" ]
frameworks = [ "CoreMIDI.framework" ]
}
if (use_alsa && use_udev) {
sources += [ "midi_manager_alsa_unittest.cc" ]
}
# On LaCrOS, tests use ash-chrome as a window manager, thus the dependency.
# On other platforms, this target should not require the Chrome to run.
if (!is_chromeos_lacros) {
assert_no_deps = [ "//chrome" ]
}
}
fuzzer_test("midi_webmidi_data_validator_fuzzer") {
sources = [ "midi_webmidi_data_validator_fuzzer.cc" ]
seed_corpus = "fuzz/corpus"
deps = [ ":midi" ]
}
fuzzer_test("midi_message_queue_fuzzer") {
sources = [ "midi_message_queue_fuzzer.cc" ]
seed_corpus = "fuzz/corpus"
deps = [ ":midi" ]
}
fuzzer_test("usb_midi_descriptor_parser_fuzzer") {
sources = [ "usb_midi_descriptor_parser_fuzzer.cc" ] + usb_midi_sources
seed_corpus = "fuzz/usb_midi_descriptor_corpus"
deps = [
":midi",
":mojo",
"//base",
]
}