Skip to content

Commit e45a6eb

Browse files
authored
new package: carbonyl-host-tools (#23073)
1 parent 68a2cbe commit e45a6eb

File tree

89 files changed

+17046
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+17046
-0
lines changed

scripts/big-pkgs.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
angle-android
22
bionic-host
3+
carbonyl-host-tools
34
clvk
45
dart
56
dotnet8.0

scripts/setup-ubuntu.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ PACKAGES+=" libwebp7 libwebp7:i386 libwebp-dev"
294294
PACKAGES+=" libwebpdemux2 libwebpdemux2:i386"
295295
PACKAGES+=" libwebpmux3 libwebpmux3:i386"
296296

297+
# Required by chromium-based packages
298+
PACKAGES+=" libfontconfig1"
299+
PACKAGES+=" libfontconfig1:i386"
300+
297301
# Required by wine-stable
298302
PACKAGES+=" libfreetype-dev:i386"
299303

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/src/browser/BUILD.gn
2+
+++ b/src/browser/BUILD.gn
3+
@@ -40,7 +40,7 @@
4+
if (is_mac) {
5+
target += "apple-darwin"
6+
} else if (is_linux) {
7+
- target += "unknown-linux-gnu"
8+
+ target += "linux-android"
9+
}
10+
11+
libs = ["carbonyl"]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--- a/chromium/src/carbonyl/src/browser/renderer.cc
2+
+++ b/chromium/src/carbonyl/src/browser/renderer.cc
3+
@@ -1,5 +1,6 @@
4+
#include "carbonyl/src/browser/renderer.h"
5+
6+
+#include <vector>
7+
#include <memory>
8+
#include <iostream>
9+
#include <stdio.h>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/src/browser/host_display_client.h
2+
+++ b/src/browser/host_display_client.h
3+
@@ -3,7 +3,7 @@
4+
5+
#include <memory>
6+
7+
-#include "base/callback.h"
8+
+#include "base/functional/callback.h"
9+
#include "base/memory/shared_memory_mapping.h"
10+
#include "carbonyl/src/browser/export.h"
11+
#include "components/viz/host/host_display_client.h"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
From 62d5b2d96bd8890d82ee5150fc4d0db76e68106d Mon Sep 17 00:00:00 2001
2+
From: Boyi C <fanthos@live.com>
3+
Date: Tue, 28 Mar 2023 12:23:33 +0800
4+
Subject: [PATCH] Update tty.rs to support putty
5+
6+
Add mode 1002 to tts, to make mouse works in Putty.
7+
---
8+
src/input/tty.rs | 2 +-
9+
1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+
diff --git a/src/input/tty.rs b/src/input/tty.rs
12+
index 5cf491b..38dd3f6 100644
13+
--- a/src/input/tty.rs
14+
+++ b/src/input/tty.rs
15+
@@ -65,7 +65,7 @@ enum TTY {
16+
File(File),
17+
}
18+
19+
-const SEQUENCES: [(u32, bool); 4] = [(1049, true), (1003, true), (1006, true), (25, false)];
20+
+const SEQUENCES: [(u32, bool); 5] = [(1049, true), (1002, true), (1003, true), (1006, true), (25, false)];
21+
22+
impl TTY {
23+
fn stdin() -> TTY {
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
2+
--- a/src/browser/bridge.rs
3+
+++ b/src/browser/bridge.rs
4+
@@ -44,6 +44,11 @@
5+
rect: CRect,
6+
color: CColor,
7+
}
8+
+#[repr(C)]
9+
+#[derive(Copy, Clone)]
10+
+pub struct InitArg {
11+
+ arg: *const c_char,
12+
+}
13+
14+
#[repr(C)]
15+
pub struct RendererBridge {
16+
@@ -103,8 +108,8 @@
17+
post_task: extern "C" fn(extern "C" fn(*mut c_void), *mut c_void),
18+
}
19+
20+
-fn main() -> io::Result<Option<i32>> {
21+
- let cmd = match CommandLineProgram::parse_or_run() {
22+
+fn main(args: Vec<String>) -> io::Result<Option<i32>> {
23+
+ let cmd = match CommandLineProgram::parse_or_run(args) {
24+
None => return Ok(Some(0)),
25+
Some(cmd) => cmd,
26+
};
27+
@@ -142,8 +147,22 @@
28+
}
29+
30+
#[no_mangle]
31+
-pub extern "C" fn carbonyl_bridge_main() {
32+
- if let Some(code) = main().unwrap() {
33+
+pub extern "C" fn carbonyl_bridge_main(
34+
+ args: *const InitArg,
35+
+ argc: size_t,
36+
+) {
37+
+ // Parse Vec<String> from params
38+
+ let args = unsafe { std::slice::from_raw_parts(args, argc) };
39+
+ let args = args.iter()
40+
+ .skip(1)
41+
+ .map(|arg| {
42+
+ let str = unsafe { CStr::from_ptr(arg.arg) };
43+
+
44+
+ str.to_str().unwrap().to_owned()
45+
+ })
46+
+ .collect::<Vec<String>>();
47+
+
48+
+ if let Some(code) = main(args).unwrap() {
49+
std::process::exit(code)
50+
}
51+
}
52+
--- a/src/cli/cli.rs
53+
+++ b/src/cli/cli.rs
54+
@@ -1,4 +1,5 @@
55+
use std::{env, ffi::OsStr};
56+
+use std::sync::OnceLock;
57+
58+
use super::CommandLineProgram;
59+
60+
@@ -35,7 +36,17 @@
61+
}
62+
}
63+
64+
+static INIT: OnceLock<Vec<String>> = OnceLock::new();
65+
+
66+
impl CommandLine {
67+
+ pub fn set_args(args: Vec<String>) {
68+
+ INIT.get_or_init(|| { args });
69+
+ }
70+
+
71+
+ pub fn get_args() -> Vec<String> {
72+
+ INIT.get_or_init(|| Vec::new()).to_vec()
73+
+ }
74+
+
75+
pub fn parse() -> CommandLine {
76+
let mut fps = 60.0;
77+
let mut zoom = 1.0;
78+
@@ -43,7 +54,7 @@
79+
let mut bitmap = false;
80+
let mut shell_mode = false;
81+
let mut program = CommandLineProgram::Main;
82+
- let args = env::args().skip(1).collect::<Vec<String>>();
83+
+ let args = Self::get_args();
84+
85+
for arg in &args {
86+
let split: Vec<&str> = arg.split("=").collect();
87+
--- a/src/cli/program.rs
88+
+++ b/src/cli/program.rs
89+
@@ -8,7 +8,8 @@
90+
}
91+
92+
impl CommandLineProgram {
93+
- pub fn parse_or_run() -> Option<CommandLine> {
94+
+ pub fn parse_or_run(args: Vec<String>) -> Option<CommandLine> {
95+
+ CommandLine::set_args(args);
96+
let cmd = CommandLine::parse();
97+
98+
match cmd.program {
99+
--- a/src/browser/renderer.h
100+
+++ b/src/browser/renderer.h
101+
@@ -47,7 +47,7 @@
102+
103+
class CARBONYL_RENDERER_EXPORT Renderer {
104+
public:
105+
- static void Main();
106+
+ static void Main(int argc, const char** argv);
107+
static Renderer* GetCurrent();
108+
109+
gfx::Size GetSize();
110+
--- a/src/browser/renderer.cc
111+
+++ b/src/browser/renderer.cc
112+
@@ -34,8 +34,14 @@
113+
carbonyl_renderer_rect rect;
114+
carbonyl_renderer_color color;
115+
};
116+
+struct carbonyl_init_arg {
117+
+ const char *arg;
118+
+};
119+
120+
-void carbonyl_bridge_main();
121+
+void carbonyl_bridge_main(
122+
+ const struct carbonyl_init_arg* args,
123+
+ size_t argc
124+
+);
125+
bool carbonyl_bridge_bitmap_mode();
126+
float carbonyl_bridge_get_dpi();
127+
128+
@@ -71,8 +77,15 @@
129+
130+
Renderer::Renderer(struct carbonyl_renderer* ptr): ptr_(ptr) {}
131+
132+
-void Renderer::Main() {
133+
- carbonyl_bridge_main();
134+
+void Renderer::Main(int argc, const char** argv) {
135+
+ if (argc < 0) {
136+
+ argc = 0;
137+
+ }
138+
+ struct carbonyl_init_arg args[argc];
139+
+ for (int i = 0; i < argc; ++i) {
140+
+ args[i].arg = argv[i];
141+
+ }
142+
+ carbonyl_bridge_main(args, (size_t) argc);
143+
144+
Bridge::Configure(
145+
carbonyl_bridge_get_dpi(),
146+
--- a/chromium/src/headless/app/headless_shell_main.cc
147+
+++ b/chromium/src/headless/app/headless_shell_main.cc
148+
@@ -17,7 +17,7 @@
149+
#include "carbonyl/src/browser/renderer.h"
150+
151+
int main(int argc, const char** argv) {
152+
- carbonyl::Renderer::Main();
153+
+ carbonyl::Renderer::Main(argc, argv);
154+
155+
content::ContentMainParams params(nullptr);
156+
#if BUILDFLAG(IS_WIN)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--- a/chromium/patches/chromium/0002-Add-Carbonyl-service.patch
2+
+++ b/chromium/patches/chromium/0002-Add-Carbonyl-service.patch
3+
@@ -590,7 +590,7 @@
4+
+ base64.c_str(),
5+
+ PrimaryFont()->
6+
+ PlatformData().
7+
-+ CreateSkFont(false, &font_description_)
8+
++ CreateSkFont(&font_description_)
9+
+ );
10+
+
11+
+ if (node_id != cc::kInvalidNodeId) {
12+
@@ -622,7 +622,7 @@
13+
+ base64.c_str(),
14+
+ PrimaryFont()->
15+
+ PlatformData().
16+
-+ CreateSkFont(false, &font_description_)
17+
++ CreateSkFont(&font_description_)
18+
+ );
19+
+
20+
+ if (node_id != cc::kInvalidNodeId) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--- a/chromium/patches/chromium/0004-Setup-browser-default-settings.patch
2+
+++ b/chromium/patches/chromium/0004-Setup-browser-default-settings.patch
3+
@@ -10,9 +10,9 @@
4+
5+
diff --git a/headless/public/headless_browser.cc b/headless/public/headless_browser.cc
6+
index b6c70ecb0fc23..c836a082d2e68 100644
7+
---- a/headless/public/headless_browser.cc
8+
-+++ b/headless/public/headless_browser.cc
9+
-@@ -22,14 +22,14 @@ namespace headless {
10+
+--- a/headless/lib/browser/headless_browser_impl.cc
11+
++++ b/headless/lib/browser/headless_browser_impl.cc
12+
+@@ -25,7 +25,7 @@
13+
14+
namespace {
15+
// Product name for building the default user agent string.
16+
@@ -21,14 +21,15 @@
17+
constexpr gfx::Size kDefaultWindowSize(800, 600);
18+
19+
constexpr gfx::FontRenderParams::Hinting kDefaultFontRenderHinting =
20+
- gfx::FontRenderParams::Hinting::HINTING_FULL;
21+
+@@ -122,7 +122,7 @@
22+
23+
- std::string GetProductNameAndVersion() {
24+
+ /// static
25+
+ std::string HeadlessBrowser::GetProductNameAndVersion() {
26+
- return std::string(kHeadlessProductName) + "/" + PRODUCT_VERSION;
27+
+ return std::string(kHeadlessProductName) + "/" + PRODUCT_VERSION + " (Carbonyl)";
28+
}
29+
- } // namespace
30+
31+
+ HeadlessBrowserImpl::HeadlessBrowserImpl(
32+
diff --git a/headless/public/headless_browser.h b/headless/public/headless_browser.h
33+
index 48efaa7d57ca2..afc0236147519 100644
34+
--- a/headless/public/headless_browser.h
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
--- a/chromium/patches/chromium/0009-Bridge-browser-into-Carbonyl-library.patch
2+
+++ b/chromium/patches/chromium/0009-Bridge-browser-into-Carbonyl-library.patch
3+
@@ -18,14 +18,14 @@
4+
+++ b/headless/app/headless_shell.cc
5+
@@ -4,6 +4,8 @@
6+
7+
- #include "headless/app/headless_shell.h"
8+
+ #include "headless/public/headless_shell.h"
9+
10+
+#include "carbonyl/src/browser/bridge.h"
11+
+
12+
#include <memory>
13+
14+
#include "base/base_switches.h"
15+
-@@ -90,6 +92,8 @@ void HeadlessShell::OnBrowserStart(HeadlessBrowser* browser) {
16+
+@@ -103,6 +105,8 @@
17+
HeadlessBrowserContext::Builder context_builder =
18+
browser_->CreateBrowserContextBuilder();
19+
20+
@@ -34,15 +34,13 @@
21+
// Retrieve the locale set by InitApplicationLocale() in
22+
// headless_content_main_delegate.cc in a way that is free of side-effects.
23+
context_builder.SetAcceptLanguage(base::i18n::GetConfiguredLocale());
24+
-@@ -113,39 +117,14 @@ void HeadlessShell::OnBrowserStart(HeadlessBrowser* browser) {
25+
-
26+
- GURL target_url = ConvertArgumentToURL(args.front());
27+
+@@ -133,35 +137,12 @@
28+
+ HeadlessWebContents::Builder builder(
29+
+ browser_context->CreateWebContentsBuilder());
30+
31+
- // If driven by a debugger just open the target page and
32+
- // leave expecting the debugger will do what they need.
33+
-- if (IsRemoteDebuggingEnabled()) {
34+
-- HeadlessWebContents::Builder builder(
35+
-- browser_context_->CreateWebContentsBuilder());
36+
+- if (devtools_enabled) {
37+
- HeadlessWebContents* web_contents =
38+
- builder.SetInitialURL(target_url).Build();
39+
- if (!web_contents) {
40+
@@ -56,8 +54,6 @@
41+
- // execute the commands against the target page.
42+
-#if defined(HEADLESS_ENABLE_COMMANDS)
43+
- GURL handler_url = HeadlessCommandHandler::GetHandlerUrl();
44+
- HeadlessWebContents::Builder builder(
45+
- browser_context_->CreateWebContentsBuilder());
46+
HeadlessWebContents* web_contents =
47+
- builder.SetInitialURL(handler_url).Build();
48+
+ builder.SetInitialURL(target_url).Build();
49+
@@ -71,7 +67,7 @@
50+
- HeadlessCommandHandler::ProcessCommands(
51+
- HeadlessWebContentsImpl::From(web_contents)->web_contents(),
52+
- std::move(target_url),
53+
-- base::BindOnce(&HeadlessShell::ShutdownSoon, weak_factory_.GetWeakPtr()));
54+
+- base::BindOnce(&HeadlessShell::ShutdownSoon, base::Unretained(this)));
55+
-#endif
56+
}
57+
58+
@@ -90,9 +86,9 @@
59+
int main(int argc, const char** argv) {
60+
+ carbonyl_shell_main();
61+
+
62+
+ content::ContentMainParams params(nullptr);
63+
#if BUILDFLAG(IS_WIN)
64+
sandbox::SandboxInterfaceInfo sandbox_info = {nullptr};
65+
- content::InitializeSandboxInfo(&sandbox_info);
66+
diff --git a/headless/lib/browser/headless_browser_impl.cc b/headless/lib/browser/headless_browser_impl.cc
67+
index 1a1223108be6d..fd45d215479ab 100644
68+
--- a/headless/lib/browser/headless_browser_impl.cc
69+
@@ -550,7 +546,7 @@
70+
71+
#include "base/memory/weak_ptr.h"
72+
#include "base/task/single_thread_task_runner.h"
73+
-@@ -121,9 +122,24 @@ class HEADLESS_EXPORT HeadlessBrowserImpl : public HeadlessBrowser,
74+
+@@ -121,7 +122,22 @@
75+
policy::PolicyService* GetPolicyService();
76+
#endif
77+
78+
@@ -566,9 +562,7 @@
79+
+ void OnMouseDownInput(unsigned int x, unsigned int y);
80+
+ void OnMouseMoveInput(unsigned int x, unsigned int y);
81+
+
82+
- bool did_shutdown() const { return did_shutdown_; }
83+
-
84+
- protected:
85+
+ private:
86+
+ // TODO: use base::TaskRunner
87+
+ std::thread input_thread_;
88+
+

0 commit comments

Comments
 (0)