浏览代码

Meta: Add gn build rules for Ladybird

Andrew Kaster 2 年之前
父节点
当前提交
16b83cd8fb

+ 2 - 0
Meta/gn/secondary/BUILD.gn

@@ -2,8 +2,10 @@ import("//Meta/gn/build/toolchain/compiler.gni")
 
 group("default") {
   deps = [
+    "//Ladybird:ladybird",
     "//Meta/Lagom/Tools/CodeGenerators/IPCCompiler",
     "//Tests",
+    "//Userland/Libraries/LibWeb",
     "//Userland/Utilities:js",
   ]
   testonly = true

+ 123 - 0
Meta/gn/secondary/Ladybird/BUILD.gn

@@ -0,0 +1,123 @@
+import("//Ladybird/compile_qt_resource_file.gni")
+import("//Ladybird/link_qt.gni")
+import("//Ladybird/moc_qt_objects.gni")
+
+moc_qt_objects("generate_moc") {
+  sources = [
+    "BrowserWindow.h",
+    "ConsoleWidget.h",
+    "InspectorWidget.h",
+    "LocationEdit.h",
+    "ModelTranslator.h",
+    "SettingsDialog.h",
+    "Tab.h",
+    "WebContentView.h",
+  ]
+}
+
+compile_qt_resource_file("compile_resource_file") {
+  sources = [ "ladybird.qrc" ]
+}
+
+link_qt("ladybird_qt_components") {
+  qt_components = [
+    "Core",
+    "Gui",
+    "Widgets",
+    "Network",
+    "Svg",
+  ]
+}
+
+config("ladybird_config") {
+  include_dirs = [
+    "//Userland/Applications",
+    "//Userland",
+  ]
+  defines = [ "AK_DONT_REPLACE_STD" ]
+}
+
+executable("ladybird") {
+  configs += [
+    ":ladybird_config",
+    ":ladybird_qt_components",
+  ]
+  data_deps = [
+    ":headless-browser",
+    "SQLServer",
+    "WebContent",
+    "WebDriver",
+  ]
+  deps = [
+    ":compile_resource_file",
+    ":generate_moc",
+    "//AK",
+    "//Userland/Libraries/LibCore",
+    "//Userland/Libraries/LibFileSystem",
+    "//Userland/Libraries/LibGUI",
+    "//Userland/Libraries/LibGfx",
+    "//Userland/Libraries/LibIPC",
+    "//Userland/Libraries/LibJS",
+    "//Userland/Libraries/LibMain",
+    "//Userland/Libraries/LibSQL",
+    "//Userland/Libraries/LibWeb",
+    "//Userland/Libraries/LibWebView",
+  ]
+  sources = [
+    "//Userland/Applications/Browser/CookieJar.cpp",
+    "//Userland/Applications/Browser/Database.cpp",
+    "//Userland/Applications/Browser/History.cpp",
+    "BrowserWindow.cpp",
+    "ConsoleWidget.cpp",
+    "EventLoopImplementationQt.cpp",
+    "HelperProcess.cpp",
+    "InspectorWidget.cpp",
+    "LocationEdit.cpp",
+    "ModelTranslator.cpp",
+    "Settings.cpp",
+    "SettingsDialog.cpp",
+    "Tab.cpp",
+    "Utilities.cpp",
+    "WebContentView.cpp",
+    "main.cpp",
+  ]
+  sources += get_target_outputs(":generate_moc") +
+             get_target_outputs(":compile_resource_file")
+  if (current_os == "android") {
+    sources += [ "AndroidPlatform.cpp" ]
+  }
+}
+
+link_qt("headless_browser_qt") {
+  qt_components = [ "Core" ]
+}
+
+executable("headless-browser") {
+  include_dirs = [ "//Userland/Services" ]
+  configs += [
+    ":ladybird_config",
+    ":headless_browser_qt",
+  ]
+  deps = [
+    "//Userland/Libraries/LibCore",
+    "//Userland/Libraries/LibCrypto",
+    "//Userland/Libraries/LibDiff",
+    "//Userland/Libraries/LibFileSystem",
+    "//Userland/Libraries/LibGemini",
+    "//Userland/Libraries/LibGfx",
+    "//Userland/Libraries/LibHTTP",
+    "//Userland/Libraries/LibIPC",
+    "//Userland/Libraries/LibJS",
+    "//Userland/Libraries/LibMain",
+    "//Userland/Libraries/LibTLS",
+    "//Userland/Libraries/LibWeb",
+    "//Userland/Libraries/LibWebSocket",
+    "//Userland/Libraries/LibWebView",
+  ]
+  sources = [
+    "//Userland/Services/WebContent/WebDriverConnection.cpp",
+    "//Userland/Utilities/headless-browser.cpp",
+    "HelperProcess.cpp",
+    "Utilities.cpp",
+  ]
+}

+ 33 - 0
Meta/gn/secondary/Ladybird/SQLServer/BUILD.gn

@@ -0,0 +1,33 @@
+import("//Ladybird/link_qt.gni")
+
+link_qt("SQLServer_qt") {
+  qt_components = [
+    "Core",
+    "Gui",
+    "Network",
+  ]
+}
+
+executable("SQLServer") {
+  configs += [
+    "//Ladybird:ladybird_config",
+    ":SQLServer_qt",
+  ]
+  include_dirs = [
+    "//Userland/Libraries",
+    "//Userland/Services",
+  ]
+  deps = [
+    "//AK",
+    "//Userland/Libraries/LibCore",
+    "//Userland/Libraries/LibIPC",
+    "//Userland/Libraries/LibMain",
+    "//Userland/Libraries/LibSQL",
+  ]
+  sources = [
+    "//Userland/Services/SQLServer/ConnectionFromClient.cpp",
+    "//Userland/Services/SQLServer/DatabaseConnection.cpp",
+    "//Userland/Services/SQLServer/SQLStatement.cpp",
+    "main.cpp",
+  ]
+}

+ 70 - 0
Meta/gn/secondary/Ladybird/WebContent/BUILD.gn

@@ -0,0 +1,70 @@
+import("//Ladybird/link_qt.gni")
+import("//Ladybird/moc_qt_objects.gni")
+
+moc_qt_objects("generate_moc") {
+  sources = [
+    "//Ladybird/AudioCodecPluginLadybird.h",
+    "//Ladybird/AudioThread.h",
+    "//Ladybird/RequestManagerQt.h",
+  ]
+}
+
+link_qt("WebContent_qt") {
+  qt_components = [
+    "Core",
+    "Gui",
+    "Network",
+    "Multimedia",
+  ]
+}
+
+executable("WebContent") {
+  configs += [
+    "//Ladybird:ladybird_config",
+    ":WebContent_qt",
+  ]
+  include_dirs = [
+    "//Userland/Services",
+    "//Ladybird",
+  ]
+  deps = [
+    ":generate_moc",
+    "//AK",
+    "//Userland/Libraries/LibCore",
+    "//Userland/Libraries/LibFileSystem",
+    "//Userland/Libraries/LibGfx",
+    "//Userland/Libraries/LibIPC",
+    "//Userland/Libraries/LibJS",
+    "//Userland/Libraries/LibMain",
+    "//Userland/Libraries/LibWeb",
+    "//Userland/Libraries/LibWebSocket",
+    "//Userland/Libraries/LibWebView:WebContentClientEndpoint",
+    "//Userland/Libraries/LibWebView:WebContentServerEndpoint",
+    "//Userland/Libraries/LibWebView:WebDriverClientEndpoint",
+    "//Userland/Libraries/LibWebView:WebDriverServerEndpoint",
+  ]
+  sources = [
+    "../AudioCodecPluginLadybird.cpp",
+    "../AudioThread.cpp",
+    "../EventLoopImplementationQt.cpp",
+    "../FontPluginQt.cpp",
+    "../ImageCodecPluginLadybird.cpp",
+    "../RequestManagerQt.cpp",
+    "../Utilities.cpp",
+    "../WebSocketClientManagerLadybird.cpp",
+    "../WebSocketImplQt.cpp",
+    "../WebSocketLadybird.cpp",
+    "//Userland/Services/WebContent/ConnectionFromClient.cpp",
+    "//Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.cpp",
+    "//Userland/Services/WebContent/PageHost.cpp",
+    "//Userland/Services/WebContent/WebContentConsoleClient.cpp",
+    "//Userland/Services/WebContent/WebDriverConnection.cpp",
+    "main.cpp",
+  ]
+  sources += get_target_outputs(":generate_moc")
+
+  if (current_os == "mac") {
+    sources += [ "MacOSSetup.mm" ]
+    frameworks = [ "AppKit.framework" ]
+  }
+}

+ 41 - 0
Meta/gn/secondary/Ladybird/WebDriver/BUILD.gn

@@ -0,0 +1,41 @@
+import("//Ladybird/link_qt.gni")
+
+link_qt("WebDriver_qt") {
+  qt_components = [
+    "Core",
+    "Network",
+  ]
+}
+
+executable("WebDriver") {
+  configs += [
+    "//Ladybird:ladybird_config",
+    ":WebDriver_qt",
+  ]
+  include_dirs = [
+    "//Userland/Services",
+    "//Ladybird",
+  ]
+  data_deps = [ "//Ladybird:headless-browser" ]
+  deps = [
+    "//AK",
+    "//Userland/Libraries/LibCore",
+    "//Userland/Libraries/LibFileSystem",
+    "//Userland/Libraries/LibGfx",
+    "//Userland/Libraries/LibIPC",
+    "//Userland/Libraries/LibJS",
+    "//Userland/Libraries/LibMain",
+    "//Userland/Libraries/LibWeb",
+    "//Userland/Libraries/LibWebSocket",
+    "//Userland/Libraries/LibWebView:WebDriverClientEndpoint",
+    "//Userland/Libraries/LibWebView:WebDriverServerEndpoint",
+  ]
+  sources = [
+    "../HelperProcess.cpp",
+    "../Utilities.cpp",
+    "//Userland/Services/WebDriver/Client.cpp",
+    "//Userland/Services/WebDriver/Session.cpp",
+    "//Userland/Services/WebDriver/WebContentConnection.cpp",
+    "main.cpp",
+  ]
+}

+ 24 - 0
Meta/gn/secondary/Ladybird/compile_qt_resource_file.gni

@@ -0,0 +1,24 @@
+import("qt_install_prefix.gni")
+
+template("compile_qt_resource_file") {
+  action_foreach(target_name) {
+    forward_variables_from(invoker, [ "sources" ])
+
+    script = "//Meta/gn/secondary/Ladybird/invoke_process_with_args.py"
+
+    outputs = [ "$target_gen_dir/rcc_{{source_name_part}}.cpp" ]
+    depfile = "$target_gen_dir/rcc_{{source_name_part}}.cpp.d"
+    args = [
+      qt_install_libexec + "rcc",
+      "-g",
+      "cpp",
+      "-d",
+      rebase_path(target_gen_dir, root_build_dir) +
+          "/rcc_{{source_name_part}}.cpp.d",
+      "-o",
+      rebase_path(target_gen_dir, root_build_dir) +
+          "/rcc_{{source_name_part}}.cpp",
+      "{{source}}",
+    ]
+  }
+}

+ 6 - 0
Meta/gn/secondary/Ladybird/invoke_process_with_args.py

@@ -0,0 +1,6 @@
+#!/usr/bin/env python3
+
+import subprocess
+import sys
+
+sys.exit(subprocess.call(sys.argv[1:]))

+ 25 - 0
Meta/gn/secondary/Ladybird/link_qt.gni

@@ -0,0 +1,25 @@
+import("qt_install_prefix.gni")
+
+template("link_qt") {
+  assert(defined(invoker.qt_components),
+         "Must define qt_component on $target_name")
+
+  config(target_name) {
+    include_dirs = [ qt_install_headers ]
+    if (current_os == "mac") {
+      frameworks = []
+      framework_dirs = [ qt_install_frameworks ]
+      foreach(component, invoker.qt_components) {
+        include_dirs += [ qt_install_headers + "Qt" + component ]
+        frameworks += [ "Qt" + component + ".framework" ]
+      }
+    } else {
+      libs = []
+      lib_dirs = [ qt_install_lib ]
+      foreach(component, invoker.qt_components) {
+        include_dirs += [ qt_install_headers + "Qt" + component ]
+        libs += [ "Qt6" + component ]
+      }
+    }
+  }
+}

+ 18 - 0
Meta/gn/secondary/Ladybird/moc_qt_objects.gni

@@ -0,0 +1,18 @@
+import("qt_install_prefix.gni")
+
+template("moc_qt_objects") {
+  action_foreach(target_name) {
+    forward_variables_from(invoker, [ "sources" ])
+
+    script = "//Meta/gn/secondary/Ladybird/invoke_process_with_args.py"
+
+    outputs = [ "$target_gen_dir/moc_{{source_name_part}}.cpp" ]
+    args = [
+      qt_install_libexec + "moc",
+      "{{source}}",
+      "-o",
+      rebase_path(target_gen_dir, root_build_dir) +
+          "/moc_{{source_name_part}}.cpp",
+    ]
+  }
+}

+ 26 - 0
Meta/gn/secondary/Ladybird/qt_install_prefix.gni

@@ -0,0 +1,26 @@
+declare_args() {
+  # Location of Qt6 binaries/libraries/frameworks.
+  # Likely /opt/homebrew on macOS and /usr or /usr/local on Linux
+  # FIXME: We could get these by parsing `qmake -query` or `pkg-config`
+  if (host_os == "mac") {
+    qt_install_prefix = "/opt/homebrew/"
+  } else {
+    qt_install_prefix = "/usr/"
+  }
+}
+
+declare_args() {
+  # Location of Qt6 headers, normally set based on $qt_install_prefix
+  qt_install_headers = qt_install_prefix + "include/"
+  if (current_os == "mac") {
+    # Location of Qt6 frameworks, normally set based on $qt_install_prefix
+    qt_install_frameworks = qt_install_prefix + "Frameworks/"
+  } else {
+    # Location of Qt6 libraries, normally set based on $qt_install_prefix
+    qt_install_lib = qt_install_prefix + "lib"
+  }
+
+  # Location of Qt6 helper programs, normally set based on $qt_install_prefix
+  # Programs such as moc and rcc are expected to be in this location.
+  qt_install_libexec = qt_install_prefix + "share/qt/libexec/"
+}

+ 13 - 0
Meta/gn/secondary/Userland/Libraries/LibDiff/BUILD.gn

@@ -0,0 +1,13 @@
+shared_library("LibDiff") {
+  include_dirs = [ "//Userland/Libraries" ]
+  sources = [
+    "Format.cpp",
+    "Generator.cpp",
+    "Hunks.cpp",
+  ]
+  deps = [
+    "//AK",
+    "//Userland/Libraries/LibCore",
+  ]
+  output_name = "diff"
+}