Skip to content

Commit

Permalink
Own target for brave/browser/ai_chat, brave/browser/skus, brave/brows… (
Browse files Browse the repository at this point in the history
#25681)

* Own target for brave/browser/ai_chat, brave/browser/skus, brave/browser/misc_metrics

* Add visibility setting and rename targets for misc_metrics

* Fix android
  • Loading branch information
yrliou authored Sep 21, 2024
1 parent cf10198 commit 1ac409f
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 76 deletions.
38 changes: 38 additions & 0 deletions browser/ai_chat/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,42 @@ import("//printing/buildflags/buildflags.gni")

assert(enable_ai_chat)

static_library("ai_chat") {
sources = [
"//brave/browser/ai_chat/ai_chat_service_factory.cc",
"//brave/browser/ai_chat/ai_chat_service_factory.h",
"//brave/browser/ai_chat/ai_chat_settings_helper.cc",
"//brave/browser/ai_chat/ai_chat_settings_helper.h",
"//brave/browser/ai_chat/ai_chat_utils.cc",
"//brave/browser/ai_chat/ai_chat_utils.h",
]

deps = [
"//brave/brave_domains",
"//brave/browser:browser_process",
"//brave/browser/misc_metrics",
"//brave/browser/skus",
"//brave/components/ai_chat/content/browser",
"//brave/components/ai_chat/core/browser",
"//brave/components/ai_chat/core/common",
"//brave/components/ai_chat/core/common/mojom",
"//brave/components/resources:strings_grit",
"//brave/net/base:utils",
"//chrome/browser:browser_process",
"//chrome/browser/profiles:profile",
"//chrome/common:channel_info",
"//components/keyed_service/content",
"//components/prefs",
"//components/user_prefs",
"//content/public/browser",
"//ui/base",
]

if (is_android) {
deps += [ "//brave/build/android:jni_headers" ]
}
}

source_set("unit_tests") {
testonly = true
sources = [ "ai_chat_throttle_unittest.cc" ]
Expand Down Expand Up @@ -44,6 +80,8 @@ source_set("browser_tests") {
]
deps = [
"//brave/app:generate_command_metadata",
"//brave/browser/ai_chat",
"//brave/browser/misc_metrics",
"//brave/components/ai_chat/content/browser",
"//brave/components/ai_chat/core/browser",
"//brave/components/ai_chat/core/browser:test_support",
Expand Down
21 changes: 0 additions & 21 deletions browser/ai_chat/sources.gni

This file was deleted.

72 changes: 72 additions & 0 deletions browser/misc_metrics/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,75 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.

import("//brave/components/ai_chat/core/common/buildflags/buildflags.gni")

source_set("misc_metrics") {
sources = [ "//brave/browser/misc_metrics/process_misc_metrics.h" ]

deps = [ "//brave/components/ai_chat/core/common/buildflags" ]
}

static_library("misc_metrics_impl") {
visibility = [
"//brave/browser/misc_metrics/*",
"//chrome/browser",
]

sources = [
"//brave/browser/misc_metrics/doh_metrics.cc",
"//brave/browser/misc_metrics/doh_metrics.h",
"//brave/browser/misc_metrics/page_metrics_tab_helper.cc",
"//brave/browser/misc_metrics/page_metrics_tab_helper.h",
"//brave/browser/misc_metrics/process_misc_metrics.cc",
"//brave/browser/misc_metrics/profile_misc_metrics_service.h",
"//brave/browser/misc_metrics/profile_misc_metrics_service_factory.h",
"//brave/browser/misc_metrics/uptime_monitor.h",
]

deps = [
"//brave/browser:browser_process",
"//brave/browser/misc_metrics",
"//brave/browser/profiles:util",
"//brave/components/ai_chat/core/common/buildflags",
"//brave/components/misc_metrics",
"//brave/components/p3a_utils",
"//brave/components/time_period_storage",
"//chrome/browser:browser_process",
"//chrome/browser/autofill",
"//chrome/browser/profiles:profiles",
"//chrome/browser/search_engines",
"//chrome/browser/ui",
"//chrome/common:constants",
"//components/keyed_service/content",
"//components/keyed_service/core",
"//components/prefs",
"//components/user_prefs",
"//content/public/browser",
]

if (!is_android) {
sources += [
"//brave/browser/misc_metrics/extension_metrics.cc",
"//brave/browser/misc_metrics/extension_metrics.h",
"//brave/browser/misc_metrics/theme_metrics.cc",
"//brave/browser/misc_metrics/theme_metrics.h",
"//brave/browser/misc_metrics/vertical_tab_metrics.cc",
"//brave/browser/misc_metrics/vertical_tab_metrics.h",
]
deps += [
"//brave/browser/themes",
"//chrome/browser/themes",
"//extensions/browser",
]
} else {
sources += [ "//brave/browser/misc_metrics/misc_android_metrics.h" ]
}

if (enable_ai_chat) {
deps += [ "//brave/components/ai_chat/core/browser" ]
}
}

source_set("unit_tests") {
testonly = true

Expand All @@ -16,6 +85,8 @@ source_set("unit_tests") {
"//base",
"//base/test:test_support",
"//brave/browser",
"//brave/browser/misc_metrics",
"//brave/browser/misc_metrics:misc_metrics_impl",
"//brave/components/misc_metrics",
"//chrome/browser",
"//chrome/browser/search_engines",
Expand Down Expand Up @@ -51,6 +122,7 @@ source_set("browser_tests") {
deps = [
"//base",
"//base/test:test_support",
"//brave/browser/misc_metrics:misc_metrics_impl",
"//chrome/browser/profiles:profile",
"//chrome/test:test_support",
"//components/prefs:test_support",
Expand Down
34 changes: 5 additions & 29 deletions browser/misc_metrics/sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,16 @@

import("//brave/components/ai_chat/core/common/buildflags/buildflags.gni")

# These files needs access to some files in chrome/browser target.
brave_browser_misc_metrics_sources = [
"//brave/browser/misc_metrics/doh_metrics.cc",
"//brave/browser/misc_metrics/doh_metrics.h",
"//brave/browser/misc_metrics/page_metrics_tab_helper.cc",
"//brave/browser/misc_metrics/page_metrics_tab_helper.h",
"//brave/browser/misc_metrics/process_misc_metrics.cc",
"//brave/browser/misc_metrics/process_misc_metrics.h",
"//brave/browser/misc_metrics/profile_misc_metrics_service.cc",
"//brave/browser/misc_metrics/profile_misc_metrics_service.h",
"//brave/browser/misc_metrics/profile_misc_metrics_service_factory.cc",
"//brave/browser/misc_metrics/profile_misc_metrics_service_factory.h",
"//brave/browser/misc_metrics/uptime_monitor.cc",
"//brave/browser/misc_metrics/uptime_monitor.h",
]

brave_browser_misc_metrics_deps = [
"//brave/browser:browser_process",
"//brave/browser/profiles:util",
"//brave/components/ai_chat/core/common/buildflags",
"//brave/components/misc_metrics",
"//chrome/browser:browser_process",
"//chrome/browser/profiles:profiles",
Expand All @@ -32,27 +23,12 @@ brave_browser_misc_metrics_deps = [
"//content/public/browser",
]

if (!is_android) {
brave_browser_misc_metrics_sources += [
"//brave/browser/misc_metrics/extension_metrics.cc",
"//brave/browser/misc_metrics/extension_metrics.h",
"//brave/browser/misc_metrics/theme_metrics.cc",
"//brave/browser/misc_metrics/theme_metrics.h",
"//brave/browser/misc_metrics/vertical_tab_metrics.cc",
"//brave/browser/misc_metrics/vertical_tab_metrics.h",
]
brave_browser_misc_metrics_deps += [ "//brave/browser/themes" ]
} else {
brave_browser_misc_metrics_sources += [
"//brave/browser/misc_metrics/misc_android_metrics.cc",
"//brave/browser/misc_metrics/misc_android_metrics.h",
]
}

if (enable_ai_chat) {
brave_browser_misc_metrics_deps +=
[ "//brave/components/ai_chat/core/browser" ]
}

brave_browser_misc_metrics_android_sources =
[ "//brave/browser/misc_metrics/misc_android_metrics_factory_android.cc" ]
brave_browser_misc_metrics_android_sources = [
"//brave/browser/misc_metrics/misc_android_metrics.cc",
"//brave/browser/misc_metrics/misc_android_metrics_factory_android.cc",
]
24 changes: 24 additions & 0 deletions browser/skus/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2024 The Brave Authors. All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.

static_library("skus") {
sources = [
"//brave/browser/skus/skus_service_factory.cc",
"//brave/browser/skus/skus_service_factory.h",
]

deps = [
"//base",
"//brave/components/skus/browser",
"//brave/components/skus/common",
"//brave/components/skus/common:mojom",
"//chrome/browser:browser_process",
"//chrome/browser/profiles:profile",
"//components/keyed_service/content",
"//components/pref_registry",
"//components/user_prefs",
"//content/public/browser",
]
}
18 changes: 0 additions & 18 deletions browser/skus/sources.gni

This file was deleted.

12 changes: 5 additions & 7 deletions browser/sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.

import("//brave/browser/ai_chat/android/sources.gni")
import("//brave/browser/ai_chat/sources.gni")
import("//brave/browser/autocomplete/sources.gni")
import("//brave/browser/brave_adaptive_captcha/sources.gni")
import("//brave/browser/brave_ads/sources.gni")
Expand Down Expand Up @@ -38,7 +37,6 @@ import("//brave/browser/playlist/sources.gni")
import("//brave/browser/renderer_context_menu/sources.gni")
import("//brave/browser/request_otr/sources.gni")
import("//brave/browser/search_engines/sources.gni")
import("//brave/browser/skus/sources.gni")
import("//brave/browser/speedreader/sources.gni")
import("//brave/browser/sync/sources.gni")
import("//brave/browser/themes/sources.gni")
Expand Down Expand Up @@ -127,8 +125,11 @@ brave_chrome_browser_deps = [
"//brave/browser/component_updater",
"//brave/browser/ethereum_remote_client/buildflags",
"//brave/browser/metrics/buildflags",
"//brave/browser/misc_metrics",
"//brave/browser/misc_metrics:misc_metrics_impl",
"//brave/browser/profiles",
"//brave/browser/search",
"//brave/browser/skus",
"//brave/browser/sync",
"//brave/browser/themes",
"//brave/browser/ui",
Expand Down Expand Up @@ -198,6 +199,7 @@ brave_chrome_browser_deps = [
"//brave/components/resources",
"//brave/components/skus/browser",
"//brave/components/skus/common",
"//brave/components/skus/common:mojom",
"//brave/components/speech_to_text",
"//brave/components/speech_to_text:buildflags",
"//brave/components/speedreader/common/buildflags",
Expand Down Expand Up @@ -331,15 +333,13 @@ if (enable_request_otr) {

if (enable_ai_chat) {
brave_chrome_browser_deps += [
"//brave/browser/ai_chat",
"//brave/components/ai_chat/content/browser",
"//brave/components/ai_chat/core/browser",
"//brave/components/ai_chat/core/common",
"//brave/components/ai_chat/core/common/mojom",
]

brave_chrome_browser_sources += brave_browser_ai_chat_sources
brave_chrome_browser_deps += brave_browser_ai_chat_deps

if (is_android) {
brave_chrome_browser_sources += brave_browser_ai_chat_android_sources
brave_chrome_browser_deps += brave_browser_ai_chat_android_deps
Expand Down Expand Up @@ -521,7 +521,6 @@ brave_chrome_browser_sources += brave_browser_playlist_sources
brave_chrome_browser_sources += brave_browser_renderer_context_menu_sources
brave_chrome_browser_sources += brave_browser_request_otr_sources
brave_chrome_browser_sources += brave_browser_search_engines_sources
brave_chrome_browser_sources += brave_browser_skus_sources
brave_chrome_browser_sources += brave_browser_speedreader_sources
brave_chrome_browser_sources += brave_browser_sync_sources
brave_chrome_browser_sources += brave_browser_themes_sources
Expand Down Expand Up @@ -559,7 +558,6 @@ brave_chrome_browser_deps += brave_browser_playlist_deps
brave_chrome_browser_deps += brave_browser_renderer_context_menu_deps
brave_chrome_browser_deps += brave_browser_request_otr_deps
brave_chrome_browser_deps += brave_browser_search_engines_deps
brave_chrome_browser_deps += brave_browser_skus_deps
brave_chrome_browser_deps += brave_browser_speedreader_deps
brave_chrome_browser_deps += brave_browser_sync_deps
brave_chrome_browser_deps += brave_browser_themes_deps
Expand Down
4 changes: 4 additions & 0 deletions browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ source_set("ui") {
]

deps = [
"//brave/browser/skus",
"//brave/components/brave_shields/core/browser",
"//brave/components/webcompat/core/common",
]
Expand Down Expand Up @@ -89,6 +90,8 @@ source_set("ui") {
"webui/ai_chat/ai_chat_ui_page_handler.h",
]

deps += [ "//brave/browser/ai_chat" ]

if (enable_print_preview) {
sources += [
"ai_chat/print_preview_extractor.cc",
Expand Down Expand Up @@ -723,6 +726,7 @@ source_set("ui") {
"//brave/browser:sparkle_buildflags",
"//brave/browser/brave_rewards:util",
"//brave/browser/ethereum_remote_client/buildflags",
"//brave/browser/misc_metrics",
"//brave/browser/profiles",
"//brave/browser/shell_integrations/buildflags",
"//brave/browser/themes",
Expand Down
5 changes: 4 additions & 1 deletion third_party/blink/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ component("renderer") {
"brave_font_whitelist.h",
]

deps = [ "//brave/components/brave_drm:brave_drm_blink" ]
deps = [
"//brave/components/brave_drm:brave_drm_blink",
"//brave/components/brave_shields/core/common:mojom",
]

defines = [ "BLINK_IMPLEMENTATION=1" ]

Expand Down

0 comments on commit 1ac409f

Please sign in to comment.