blob: 2f7ae150fff21486282ba05cdfaee4349e93ab39 [file] [log] [blame]
# Copyright 2015 The Chromium Authors. All rights reserved.
# 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/features.gni")
import("//build/config/ui.gni")
import("//media/media_options.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",
]
java_files = [
"java/src/org/chromium/media/midi/MidiDeviceAndroid.java",
"java/src/org/chromium/media/midi/MidiInputPortAndroid.java",
"java/src/org/chromium/media/midi/MidiManagerAndroid.java",
"java/src/org/chromium/media/midi/MidiOutputPortAndroid.java",
"java/src/org/chromium/media/midi/UsbMidiDeviceAndroid.java",
"java/src/org/chromium/media/midi/UsbMidiDeviceFactoryAndroid.java",
]
}
generate_jni("midi_jni_headers") {
sources = [
"java/src/org/chromium/media/midi/MidiDeviceAndroid.java",
"java/src/org/chromium/media/midi/MidiInputPortAndroid.java",
"java/src/org/chromium/media/midi/MidiManagerAndroid.java",
"java/src/org/chromium/media/midi/MidiOutputPortAndroid.java",
"java/src/org/chromium/media/midi/UsbMidiDeviceAndroid.java",
"java/src/org/chromium/media/midi/UsbMidiDeviceFactoryAndroid.java",
]
jni_package = "media/midi"
}
}
component("midi") {
sources = [
"midi_export.h",
"midi_manager.cc",
"midi_manager.h",
"midi_manager_mac.cc",
"midi_manager_mac.h",
"midi_manager_win.cc",
"midi_manager_win.h",
"midi_message_queue.cc",
"midi_message_queue.h",
"midi_message_util.cc",
"midi_message_util.h",
"midi_port_info.cc",
"midi_port_info.h",
"midi_scheduler.cc",
"midi_scheduler.h",
"midi_switches.cc",
"midi_switches.h",
]
configs += [ ":midi_config" ]
defines = [ "MIDI_IMPLEMENTATION" ]
deps = [
"//base",
]
libs = []
if (is_android) {
# TODO(yhirano): Consider having "android" subdirectory.
sources += [
"midi_device_android.cc",
"midi_device_android.h",
"midi_jni_registrar.cc",
"midi_jni_registrar.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_mac) {
libs += [
"CoreAudio.framework",
"CoreFoundation.framework",
"CoreMIDI.framework",
]
}
if (is_win) {
deps += [ "//device/usb" ]
}
if (use_alsa && use_udev) {
deps += [
"//crypto",
"//crypto:platform",
]
libs += [ "asound" ]
sources += [
"midi_manager_alsa.cc",
"midi_manager_alsa.h",
]
}
if (use_udev) {
deps += [ "//device/udev_linux" ]
}
}
test("midi_unittests") {
sources = [
"midi_manager_unittest.cc",
"midi_manager_usb_unittest.cc",
"midi_message_queue_unittest.cc",
"midi_message_util_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",
"//base/test/:run_all_unittests",
"//base/test/:test_support",
"//testing/gtest",
]
if (is_android) {
deps += [ ":midi_java" ]
} else {
sources += usb_midi_sources
}
if (is_mac) {
sources += [ "midi_manager_mac_unittest.cc" ]
}
if (use_alsa && use_udev) {
sources += [ "midi_manager_alsa_unittest.cc" ]
}
if (use_x11) {
deps += [ "//tools/xdisplaycheck" ]
}
}