Skip to content

Commit

Permalink
Merge pull request #1 from jiangshengdev/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jiangshengdev authored Mar 4, 2024
2 parents 95d37df + 57b0373 commit 9accdca
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"bracketSpacing": false,
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
7 changes: 7 additions & 0 deletions docs/v8/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "Tutorial - V8",
"position": 4,
"link": {
"type": "generated-index"
}
}
50 changes: 50 additions & 0 deletions docs/v8/build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
sidebar_position: 1
---

# 从源代码构建 V8

为了在 macOS 上为 arm64 从零开始构建 V8,请按照以下步骤进行。

## 获取 V8 源代码

请跟随指南中的说明来 [获取 V8 源代码](./source-code)

## 安装构建依赖项

1. 对于 macOS:安装 Xcode 并接受其许可协议。(如果你之前已经单独安装了 Command Line Tools for Xcode,请先卸载它们。)

2. 确保你处于 V8 源代码目录中。如果你按照前一节的每个步骤操作了,那么你已经在正确的位置了。

3. 下载所有的构建依赖项:

```shell
gclient sync
```

## 构建 V8

1. 确保你处于 V8 源代码目录,并且当前位于 `main` 分支上。

```shell
cd ~/v8/v8
git checkout main
```

2. 拉取最新更改并安装所有新的构建依赖项:

```shell
git pull && gclient sync
```

3. 编译源代码:

```shell
tools/dev/gm.py arm64.release
```

或者,编译源代码并立即运行测试:

```shell
tools/dev/gm.py arm64.release.check
```
35 changes: 35 additions & 0 deletions docs/v8/get-depot-tools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
sidebar_position: 3
---

# 获取仓库工具

## 克隆 depot_tools 仓库

首先,创建一个目录并克隆 `depot_tools` 仓库到本地:

```shell
mkdir -p ~/chromium/tools
cd ~/chromium/tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
```

## 自动配置环境变量

然后,使用以下命令自动将 `depot_tools` 路径添加到你的 `~/.zshrc` 文件中,确保你可以在任何位置使用它的工具:

```shell
echo 'export PATH=~/chromium/tools/depot_tools:$PATH' >> ~/.zshrc
```

这条命令会在 `~/.zshrc` 文件的末尾追加 `export PATH` 命令,无需手动编辑文件。

## 应用更改

为了使更改生效,请重新加载 `~/.zshrc` 文件或重启终端:

```shell
source ~/.zshrc
```

或者,你可以简单地关闭并重新打开你的终端窗口。
55 changes: 55 additions & 0 deletions docs/v8/source-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
sidebar_position: 2
---

# 获取 V8 源代码

## 说明

1. 首先,在 macOS 上安装 Git 和 [depot_tools](./get-depot-tools)

2. 通过执行以下命令在终端中更新 depot_tools。

```shell
gclient
```

3. 省略

4. 现在,获取 V8 源代码,包括所有分支和依赖项:

```shell
mkdir ~/v8
cd ~/v8
fetch v8
cd v8
```

在那之后,这将导致你处于一个分离的 HEAD 状态。

你可以选择性地指定新分支应如何被跟踪:

```shell
git config branch.autosetupmerge always
git config branch.autosetuprebase always
```

或者,你也可以通过如下命令创建一个新的本地分支(推荐做法):

```shell
git new-branch fix-bug-1234
```

## 保持最新状态

使用 `git pull` 更新你当前的分支。请注意,如果你当前不在任何分支上,应使用 `git fetch` 而不是 `git pull` 来更新。

```shell
git pull
```

有时 V8 的依赖项会更新。你可以通过运行以下命令来同步这些更新:

```shell
gclient sync
```
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@docusaurus/module-type-aliases": "3.1.1",
"@docusaurus/tsconfig": "3.1.1",
"@docusaurus/types": "3.1.1",
"prettier": "3.2.5",
"typescript": "~5.2.2"
},
"browserslist": {
Expand Down

0 comments on commit 9accdca

Please sign in to comment.