summaryrefslogtreecommitdiffstats
path: root/code/projects/ohos_compile.html
diff options
context:
space:
mode:
authorWe-unite <3205135446@qq.com>2025-01-07 12:36:05 +0800
committerWe-unite <3205135446@qq.com>2025-01-07 12:36:05 +0800
commit4d88ef666eee1b6f191f6e85b00acf8d5a2d1899 (patch)
tree68391846bae84f9546b0d089c012afc336a6e6bd /code/projects/ohos_compile.html
parent11e64c5804b696f170b9d5d881befbabc4a4e85c (diff)
downloadmyweb-new_highlightjs.tar.gz
myweb-new_highlightjs.zip
highlight don't use auto-detect but given languagenew_highlightjs
In this commit, lot's of things is changed. Hope they all runs currectly. Now highlight.js is supporting more and more proguam languages, but the auto detection always go wrong, even for common languages like c, bash, python, makefile. Use Given Language ------------------ As you know, I always write markdown and convert to html by pandoc. In the old, "```cpp" in markdown will be deleted first to keep the embeded code clean and not highlighted, then I can use highlight.js. But this causes that html document doesn't know the language. This time, md2html.sh is changed: pandoc use "--no-highlight" argument to keep code clean, and it will output like this: ```html <pre class="cpp"><code>...</code></pre> ``` Although there may be other tags between `<code></code>`, it's clear that `<pre class="xxx"><code>` is nested tightly, except some space characters or \n. Then, sed deal with the whole doc(not line by line), replace `<pre class="xxx"><code>` with `<pre><code class="language-xxx">`. That's it! Math Formula ------------ Math formular is also a problem during convertion by pandoc. In the old it's dealed menually. Now pandoc use "--mathjax=none", then formula is no longer showed by pandoc, but only `<span class="math xxx">\( formula \)</span>`. And the math tool I used will deal with it. Mermaid picture ---------------- pandoc doesn't support convert mermaid in markdown to html picture. Let's have a warning!
Diffstat (limited to 'code/projects/ohos_compile.html')
-rw-r--r--code/projects/ohos_compile.html60
1 files changed, 30 insertions, 30 deletions
diff --git a/code/projects/ohos_compile.html b/code/projects/ohos_compile.html
index fd52643..c9d240d 100644
--- a/code/projects/ohos_compile.html
+++ b/code/projects/ohos_compile.html
@@ -5,16 +5,17 @@
5 <meta charset="utf-8" /> 5 <meta charset="utf-8" />
6 <meta name="generator" content="pandoc" /> 6 <meta name="generator" content="pandoc" />
7 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> 7 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
8 <title>OHOS全量编译记录</title> 8 <title>OHOS 全量编译记录</title>
9 <link rel="stylesheet" href="https://test.qin-juan-ge-zhu.top/common/CSS/pandoc.css"> 9 <link rel="stylesheet" href="https://www.qin-juan-ge-zhu.top/common/CSS/pandoc.css">
10 <script type="text/javascript" src="https://test.qin-juan-ge-zhu.top/common/js/myhighlight.js"></script> 10 <script type="text/javascript" src="https://www.qin-juan-ge-zhu.top/common/script4code.js"></script>
11 <script type="text/javascript" src="https://test.qin-juan-ge-zhu.top/common/script4code.js"></script>
12</head> 11</head>
13 12
14<body> 13<body>
15 <div class="pandoc"> 14 <div class="pandoc">
16 <div class="main"> 15 <div class="main">
17 <p class="title">OHOS 全量编译记录</p> 16 <header id="title-block-header">
17 <p class="title">OHOS 全量编译记录</p>
18 </header>
18 <!-- 鸿蒙开发环境搭建 --> 19 <!-- 鸿蒙开发环境搭建 -->
19 <blockquote> 20 <blockquote>
20 <p>本次编译环境搭建参考了以下博客:</p> 21 <p>本次编译环境搭建参考了以下博客:</p>
@@ -36,8 +37,7 @@
36 <h2 id="硬件环境">硬件环境</h2> 37 <h2 id="硬件环境">硬件环境</h2>
37 <p>编译过程使用的是 38 <p>编译过程使用的是
38 <code>Ubuntu</code>,经测试,<code>Ubuntu 22.04 LTS</code>/<code>Ubuntu 20.04 LTS</code>/<code>Ubuntu 18.04 LTS</code> 39 <code>Ubuntu</code>,经测试,<code>Ubuntu 22.04 LTS</code>/<code>Ubuntu 20.04 LTS</code>/<code>Ubuntu 18.04 LTS</code>
39 均可用。 40 均可用。</p>
40 </p>
41 <p>网上的大多数博客里没有对编译的硬件限制作出说明,现根据我们的情况,给出一个大概的范围:</p> 41 <p>网上的大多数博客里没有对编译的硬件限制作出说明,现根据我们的情况,给出一个大概的范围:</p>
42 <ul> 42 <ul>
43 <li><strong>内存必须在 10G 以上</strong>,我使用的是 13G,编译成功(8G 时编译失败了,下文会说明)</li> 43 <li><strong>内存必须在 10G 以上</strong>,我使用的是 13G,编译成功(8G 时编译失败了,下文会说明)</li>
@@ -53,7 +53,7 @@
53 <p>这里我用的是 VMWare+Ubuntu22.04 虚拟机。</p> 53 <p>这里我用的是 VMWare+Ubuntu22.04 虚拟机。</p>
54 <h2 id="软件包依赖">软件包依赖</h2> 54 <h2 id="软件包依赖">软件包依赖</h2>
55 <p>安装依赖在博客中都有讲,但<strong>少了一部分依赖项</strong>,我因而将所有必要的依赖项整理到一个脚本里了:</p> 55 <p>安装依赖在博客中都有讲,但<strong>少了一部分依赖项</strong>,我因而将所有必要的依赖项整理到一个脚本里了:</p>
56 <pre><code>#!/bin/bash 56 <pre><code class="language-bash">#!/bin/bash
57set -e # 一旦出错立刻停止执行,不会执行后续指令 57set -e # 一旦出错立刻停止执行,不会执行后续指令
58 58
59# 更新软件源 59# 更新软件源
@@ -87,7 +87,7 @@ fi</code></pre>
87 <h1 id="配置-git">配置 git</h1> 87 <h1 id="配置-git">配置 git</h1>
88 <h2 id="git-基础设置">git 基础设置</h2> 88 <h2 id="git-基础设置">git 基础设置</h2>
89 <p>在上边我们已经下载了本次所需要的<code>git</code>与<code>git-lfs</code>,接下来我们需要对<code>git</code>进行基础设置。</p> 89 <p>在上边我们已经下载了本次所需要的<code>git</code>与<code>git-lfs</code>,接下来我们需要对<code>git</code>进行基础设置。</p>
90 <pre><code># 设置用户名与密码,新用户必做 90 <pre><code class="language-bash"># 设置用户名与密码,新用户必做
91# 这里的用户名与密码只是一个写在git提交记录中的标识,可以与gitee/github账号无关 91# 这里的用户名与密码只是一个写在git提交记录中的标识,可以与gitee/github账号无关
92git config --global user.name &quot;yourname&quot; 92git config --global user.name &quot;yourname&quot;
93git config --global user.email &quot;your-email-address&quot; 93git config --global user.email &quot;your-email-address&quot;
@@ -99,7 +99,7 @@ git config --global core.editor vim</code></pre>
99 <p>由于 OpenHarmony 的源码托管在 gitee 上,所以我们需要在 gitee 上注册一个帐户。注册的方法在此不复赘述。</p> 99 <p>由于 OpenHarmony 的源码托管在 gitee 上,所以我们需要在 gitee 上注册一个帐户。注册的方法在此不复赘述。</p>
100 <p>本次编译过程中,我们并不需要提交代码,因而可以仅通过 http 方式从 gitee 下载源码——如果是这样的话,<strong>就不需要进行 git 与 gitee 100 <p>本次编译过程中,我们并不需要提交代码,因而可以仅通过 http 方式从 gitee 下载源码——如果是这样的话,<strong>就不需要进行 git 与 gitee
101 关联</strong>;如果想要提交代码,那么需要将本地的 git 与 gitee 账号关联起来,具体操作如下:</p> 101 关联</strong>;如果想要提交代码,那么需要将本地的 git 与 gitee 账号关联起来,具体操作如下:</p>
102 <pre><code># 在本地执行 102 <pre><code class="language-bash"># 在本地执行
103ssh-keygen -t rsa -C &quot;your-email-address&quot;</code></pre> 103ssh-keygen -t rsa -C &quot;your-email-address&quot;</code></pre>
104 <p>命令执行后,每次需要输入都直接回车,<strong>连续有三个回车</strong>,执行就会结束,ssh 104 <p>命令执行后,每次需要输入都直接回车,<strong>连续有三个回车</strong>,执行就会结束,ssh
105 密钥对的公钥和私钥分别保存在<code>~/.ssh/id_rsa.pub</code>和<code>~/.ssh/id_rsa</code>中。</p> 105 密钥对的公钥和私钥分别保存在<code>~/.ssh/id_rsa.pub</code>和<code>~/.ssh/id_rsa</code>中。</p>
@@ -107,7 +107,7 @@ ssh-keygen -t rsa -C &quot;your-email-address&quot;</code></pre>
107 <p>此时,我们就可以通过 ssh 的方式与 gitee 进行交互、也可以免密提交代码了。</p> 107 <p>此时,我们就可以通过 ssh 的方式与 gitee 进行交互、也可以免密提交代码了。</p>
108 <h1 id="系统源码编译">系统源码编译</h1> 108 <h1 id="系统源码编译">系统源码编译</h1>
109 <h2 id="配置-repo-工具">配置 repo 工具</h2> 109 <h2 id="配置-repo-工具">配置 repo 工具</h2>
110 <pre><code>curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 &gt; ~/repo 110 <pre><code class="language-bash">curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 &gt; ~/repo
111chmod a+x ~/repo 111chmod a+x ~/repo
112sudo mv ~/repo /usr/local/bin/repo 112sudo mv ~/repo /usr/local/bin/repo
113sudo chown root:root /usr/local/bin/repo 113sudo chown root:root /usr/local/bin/repo
@@ -121,7 +121,7 @@ pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests</co
121 的区别,如<code>OpenHarmony-v4.0-Release</code>和<code>OpenHarmony-4.0-Release</code>。二者的区别主要在于,不带 v 121 的区别,如<code>OpenHarmony-v4.0-Release</code>和<code>OpenHarmony-4.0-Release</code>。二者的区别主要在于,不带 v
122 的是官方维护的稳定版,也会更新代码,厂商的补丁一般只针对带 v 的使用。</p> 122 的是官方维护的稳定版,也会更新代码,厂商的补丁一般只针对带 v 的使用。</p>
123 <p>通过 repo + https/ssh 下载:</p> 123 <p>通过 repo + https/ssh 下载:</p>
124 <pre><code># 如果需要的是特定分支,-b后边改成对应分支名 124 <pre><code class="language-bash"># 如果需要的是特定分支,-b后边改成对应分支名
125# repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify 125# repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify
126# 如果是tag,-b后的参数比较复杂,要在网页上提前确定好需要的tag名字, 126# 如果是tag,-b后的参数比较复杂,要在网页上提前确定好需要的tag名字,
127# 如下载的是tag为OpenHarmony-v3.2-Release的版本,命令如下: 127# 如下载的是tag为OpenHarmony-v3.2-Release的版本,命令如下:
@@ -133,11 +133,11 @@ repo sync -c
133repo forall -c &#39;git lfs pull&#39;</code></pre> 133repo forall -c &#39;git lfs pull&#39;</code></pre>
134 <h2 id="补丁与编译">补丁与编译</h2> 134 <h2 id="补丁与编译">补丁与编译</h2>
135 <p>首先,打上厂商的补丁。下载对应版本补丁后,将补丁文件放到源码根目录下,执行:</p> 135 <p>首先,打上厂商的补丁。下载对应版本补丁后,将补丁文件放到源码根目录下,执行:</p>
136 <pre><code>unzip purple_pi_oh_patch.zip 136 <pre><code class="language-bash">unzip purple_pi_oh_patch.zip
137cd purple_pi_oh_patch 137cd purple_pi_oh_patch
138./ido_patch.sh</code></pre> 138./ido_patch.sh</code></pre>
139 <p>看到<code>patch complete</code>字样,说明补丁成功。接下来进行 prebuilts 和编译:</p> 139 <p>看到<code>patch complete</code>字样,说明补丁成功。接下来进行 prebuilts 和编译:</p>
140 <pre><code># 先在源码根目录下执行脚本,安装编译器及二进制工具 140 <pre><code class="language-bash"># 先在源码根目录下执行脚本,安装编译器及二进制工具
141bash build/prebuilts_download.sh 141bash build/prebuilts_download.sh
142 142
143# 编译 143# 编译
@@ -181,22 +181,22 @@ sudo ./build.sh --product-name purple_pi_oh --ccache --no-prebuilt-sdk --target-
181 <li>右键该分区,查看挂载到什么位置了。一般是挂载到<code>/</code>与<code>/var/snap/firefox/common/host-hunspell</code></li> 181 <li>右键该分区,查看挂载到什么位置了。一般是挂载到<code>/</code>与<code>/var/snap/firefox/common/host-hunspell</code></li>
182 <li>执行以下命令:</li> 182 <li>执行以下命令:</li>
183 </ul> 183 </ul>
184 <pre><code># 对于这个设备挂载到的每一个分区,都执行以下命令,以此类推 184 <pre><code class="language-bash"># 对于这个设备挂载到的每一个分区,都执行以下命令,以此类推
185sudo mount -o remount -rw / 185sudo mount -o remount -rw /
186sudo mount -o remount -rw /var/snap/firefox/common/host-hunspell</code></pre> 186sudo mount -o remount -rw /var/snap/firefox/common/host-hunspell</code></pre>
187 <p>而后在 gparted 中点击<code>gparted-&gt;刷新设备</code>,即可进行分区扩展。</p> 187 <p>而后在 gparted 中点击<code>gparted-&gt;刷新设备</code>,即可进行分区扩展。</p>
188 <h2 id="ninja-编译报错-code-4000">Ninja 编译报错 <code>Code 4000</code></h2> 188 <h2 id="ninja-编译报错-code-4000">Ninja 编译报错 <code>Code 4000</code></h2>
189 <p>编译 rk3568 过程中可能会出现以下报错:</p> 189 <p>编译 rk3568 过程中可能会出现以下报错:</p>
190 <pre><code>[OHOS ERROR] Code: 4000 190 <pre><code class="language-plaintext">[OHOS ERROR] Code: 4000
191[OHOS ERROR] Reason: ninja phase failed</code></pre> 191[OHOS ERROR] Reason: ninja phase failed</code></pre>
192 <p>详细的报错信息已经丢失,将就着看吧。反正别的办法都不好使的时候试试这个。</p> 192 <p>详细的报错信息已经丢失,将就着看吧。反正别的办法都不好使的时候试试这个。</p>
193 <p>此时执行以下内容即可:</p> 193 <p>此时执行以下内容即可:</p>
194 <pre><code>rm -rf out 194 <pre><code class="language-bash">rm -rf out
195sed -i &#39;s/CONFIG_DEBUG_INFO_BTF=y/# CONFIG_DEBUG_INFO_BTF=y/g&#39; kernel/linux/config/linux-5.10/rk3568/arch/arm64_defconfig</code></pre> 195sed -i &#39;s/CONFIG_DEBUG_INFO_BTF=y/# CONFIG_DEBUG_INFO_BTF=y/g&#39; kernel/linux/config/linux-5.10/rk3568/arch/arm64_defconfig</code></pre>
196 <p>而后重新编译。</p> 196 <p>而后重新编译。</p>
197 <h2 id="另一个code-4000">另一个<code>Code 4000</code></h2> 197 <h2 id="另一个code-4000">另一个<code>Code 4000</code></h2>
198 <p>编译时报错如下:</p> 198 <p>编译时报错如下:</p>
199 <pre><code>ninja: build stopped: subcommand failed. 199 <pre><code class="language-plaintext">ninja: build stopped: subcommand failed.
200[OHOS ERROR] Traceback (most recent call last): 200[OHOS ERROR] Traceback (most recent call last):
201[OHOS ERROR] File &quot;/home/player/Desktop/ohos/src/build/hb/services/ninja.py&quot;, line 49, in _execute_ninja_cmd 201[OHOS ERROR] File &quot;/home/player/Desktop/ohos/src/build/hb/services/ninja.py&quot;, line 49, in _execute_ninja_cmd
202[OHOS ERROR] SystemUtil.exec_command( 202[OHOS ERROR] SystemUtil.exec_command(
@@ -250,13 +250,13 @@ sed -i &#39;s/CONFIG_DEBUG_INFO_BTF=y/# CONFIG_DEBUG_INFO_BTF=y/g&#39; kernel/li
250 <p>这是一个很奇怪的报错,我们尚未找到真正的原因所在,只知道如何暂时地绕过去。</p> 250 <p>这是一个很奇怪的报错,我们尚未找到真正的原因所在,只知道如何暂时地绕过去。</p>
251 <h3 id="问题描述与复现">问题描述与复现</h3> 251 <h3 id="问题描述与复现">问题描述与复现</h3>
252 <p>问题复现方法为在编译过程中,执行以下命令:</p> 252 <p>问题复现方法为在编译过程中,执行以下命令:</p>
253 <pre><code>./build.sh --product-name rk3568 --ccache</code></pre> 253 <pre><code class="language-bash">./build.sh --product-name rk3568 --ccache</code></pre>
254 <p>该命令是指导书中写的编译命令,但执行时候会出错;<strong>与上文所述的经确认无误的编译命令不同在于没加<code>sudo</code></strong>。</p> 254 <p>该命令是指导书中写的编译命令,但执行时候会出错;<strong>与上文所述的经确认无误的编译命令不同在于没加<code>sudo</code></strong>。</p>
255 <p>如果按照指导书的命令来,不出意外编译将会报错: <img src="https://www.qin-juan-ge-zhu.top/images/code/ohos_gn_fail_1.png" /> <img 255 <p>如果按照指导书的命令来,不出意外编译将会报错: <img src="https://www.qin-juan-ge-zhu.top/images/code/ohos_compile_gn_fail_1.png" /> <img
256 src="https://www.qin-juan-ge-zhu.top/images/code/ohos_gn_fail_2.png" /></p> 256 src="https://www.qin-juan-ge-zhu.top/images/code/ohos_compile_gn_fail_2.png" /></p>
257 <p><strong>以下是该问题的具体描述:</strong></p> 257 <p><strong>以下是该问题的具体描述:</strong></p>
258 <p><code>build.log</code>如下:</p> 258 <p><code>build.log</code>如下:</p>
259 <pre><code>Set cache size limit to 100.0 GB 259 <pre><code class="language-plaintext">Set cache size limit to 100.0 GB
260[OHOS INFO] loader args:[&#39;platforms_config_file=&quot;/home/axiomer/桌面/out/preloader/ohos-sdk/platforms.build&quot;&#39;, &#39;subsystem_config_file=&quot;/home/axiomer/桌面/out/preloader/ohos-sdk/subsystem_config.json&quot;&#39;, &#39;example_subsystem_file=&quot;&quot;&#39;, &#39;exclusion_modules_config_file=&quot;/home/axiomer/桌面/out/preloader/ohos-sdk/exclusion_modules.json&quot;&#39;, &#39;source_root_dir=&quot;/home/axiomer/桌面/&quot;&#39;, &#39;gn_root_out_dir=&quot;out/sdk&quot;&#39;, &#39;build_platform_name=phone&#39;, &#39;build_xts=False&#39;, &#39;load_test_config=False&#39;, &#39;target_os=ohos&#39;, &#39;target_cpu=arm64&#39;, &#39;os_level=standard&#39;, &quot;ignore_api_check=[&#39;xts&#39;, &#39;common&#39;, &#39;testfwk&#39;]&quot;, &#39;scalable_build=False&#39;, &#39;skip_partlist_check=False&#39;] 260[OHOS INFO] loader args:[&#39;platforms_config_file=&quot;/home/axiomer/桌面/out/preloader/ohos-sdk/platforms.build&quot;&#39;, &#39;subsystem_config_file=&quot;/home/axiomer/桌面/out/preloader/ohos-sdk/subsystem_config.json&quot;&#39;, &#39;example_subsystem_file=&quot;&quot;&#39;, &#39;exclusion_modules_config_file=&quot;/home/axiomer/桌面/out/preloader/ohos-sdk/exclusion_modules.json&quot;&#39;, &#39;source_root_dir=&quot;/home/axiomer/桌面/&quot;&#39;, &#39;gn_root_out_dir=&quot;out/sdk&quot;&#39;, &#39;build_platform_name=phone&#39;, &#39;build_xts=False&#39;, &#39;load_test_config=False&#39;, &#39;target_os=ohos&#39;, &#39;target_cpu=arm64&#39;, &#39;os_level=standard&#39;, &quot;ignore_api_check=[&#39;xts&#39;, &#39;common&#39;, &#39;testfwk&#39;]&quot;, &#39;scalable_build=False&#39;, &#39;skip_partlist_check=False&#39;]
261[OHOS INFO] Excuting gn command: /home/axiomer/桌面/prebuilts/build-tools/linux-x86/bin/gn gen --args=&quot;product_name=\&quot;ohos-sdk\&quot; product_path=\&quot;/home/axiomer/桌面/productdefine/common/products\&quot; product_config_path=\&quot;/home/axiomer/桌面/productdefine/common/products\&quot; device_name=\&quot;sdk\&quot; device_path=\&quot;/home/axiomer/桌面/device/board/ohos/sdk\&quot; device_company=\&quot;ohos\&quot; device_config_path=\&quot;/home/axiomer/桌面/device/board/ohos/sdk\&quot; target_cpu=\&quot;arm64\&quot; is_standard_system=true ohos_build_compiler_specified=\&quot;\&quot; ohos_build_time=1707374188101 ohos_build_datetime=\&quot;2024-02-08 22:36:28\&quot; build_ohos_sdk=true build_ohos_ndk=true ohos_build_enable_ccache=true ohos_build_type=\&quot;debug\&quot; device_type=\&quot;default\&quot; build_variant=\&quot;root\&quot; use_thin_lto=false ndk_platform=\&quot;linux\&quot; sdk_for_hap_build=true skip_generate_module_list_file=true enable_lto_O0=true archive_ndk=false enable_ndk_doxygen=false use_cfi=false sdk_check_flag=false sdk_platform=\&quot;linux\&quot; root_perf_main=\&quot;main\&quot; runtime_mode=\&quot;release\&quot;&quot; --args=product_name=&quot;ohos-sdk&quot; product_path=&quot;/home/axiomer/桌面/productdefine/common/products&quot; product_config_path=&quot;/home/axiomer/桌面/productdefine/common/products&quot; device_name=&quot;sdk&quot; device_path=&quot;/home/axiomer/桌面/device/board/ohos/sdk&quot; device_company=&quot;ohos&quot; device_config_path=&quot;/home/axiomer/桌面/device/board/ohos/sdk&quot; target_cpu=&quot;arm64&quot; is_standard_system=true ohos_build_compiler_specified=&quot;&quot; ohos_build_time=1707374188101 ohos_build_datetime=&quot;2024-02-08 22:36:28&quot; build_ohos_sdk=true build_ohos_ndk=true ohos_build_enable_ccache=true ohos_build_type=&quot;debug&quot; device_type=&quot;default&quot; build_variant=&quot;root&quot; use_thin_lto=false ndk_platform=&quot;linux&quot; sdk_for_hap_build=true skip_generate_module_list_file=true enable_lto_O0=true archive_ndk=false enable_ndk_doxygen=false use_cfi=false sdk_check_flag=false sdk_platform=&quot;linux&quot; root_perf_main=&quot;main&quot; runtime_mode=&quot;release&quot; /home/axiomer/桌面/out/sdk 261[OHOS INFO] Excuting gn command: /home/axiomer/桌面/prebuilts/build-tools/linux-x86/bin/gn gen --args=&quot;product_name=\&quot;ohos-sdk\&quot; product_path=\&quot;/home/axiomer/桌面/productdefine/common/products\&quot; product_config_path=\&quot;/home/axiomer/桌面/productdefine/common/products\&quot; device_name=\&quot;sdk\&quot; device_path=\&quot;/home/axiomer/桌面/device/board/ohos/sdk\&quot; device_company=\&quot;ohos\&quot; device_config_path=\&quot;/home/axiomer/桌面/device/board/ohos/sdk\&quot; target_cpu=\&quot;arm64\&quot; is_standard_system=true ohos_build_compiler_specified=\&quot;\&quot; ohos_build_time=1707374188101 ohos_build_datetime=\&quot;2024-02-08 22:36:28\&quot; build_ohos_sdk=true build_ohos_ndk=true ohos_build_enable_ccache=true ohos_build_type=\&quot;debug\&quot; device_type=\&quot;default\&quot; build_variant=\&quot;root\&quot; use_thin_lto=false ndk_platform=\&quot;linux\&quot; sdk_for_hap_build=true skip_generate_module_list_file=true enable_lto_O0=true archive_ndk=false enable_ndk_doxygen=false use_cfi=false sdk_check_flag=false sdk_platform=\&quot;linux\&quot; root_perf_main=\&quot;main\&quot; runtime_mode=\&quot;release\&quot;&quot; --args=product_name=&quot;ohos-sdk&quot; product_path=&quot;/home/axiomer/桌面/productdefine/common/products&quot; product_config_path=&quot;/home/axiomer/桌面/productdefine/common/products&quot; device_name=&quot;sdk&quot; device_path=&quot;/home/axiomer/桌面/device/board/ohos/sdk&quot; device_company=&quot;ohos&quot; device_config_path=&quot;/home/axiomer/桌面/device/board/ohos/sdk&quot; target_cpu=&quot;arm64&quot; is_standard_system=true ohos_build_compiler_specified=&quot;&quot; ohos_build_time=1707374188101 ohos_build_datetime=&quot;2024-02-08 22:36:28&quot; build_ohos_sdk=true build_ohos_ndk=true ohos_build_enable_ccache=true ohos_build_type=&quot;debug&quot; device_type=&quot;default&quot; build_variant=&quot;root&quot; use_thin_lto=false ndk_platform=&quot;linux&quot; sdk_for_hap_build=true skip_generate_module_list_file=true enable_lto_O0=true archive_ndk=false enable_ndk_doxygen=false use_cfi=false sdk_check_flag=false sdk_platform=&quot;linux&quot; root_perf_main=&quot;main&quot; runtime_mode=&quot;release&quot; /home/axiomer/桌面/out/sdk
262ERROR at //build/config/BUILDCONFIG.gn:92:15: Could not read file. 262ERROR at //build/config/BUILDCONFIG.gn:92:15: Could not read file.
@@ -296,7 +296,7 @@ current_toolchain=
296 <p>在此,我进行了许多尝试,但都无一例外失败了;以下是我的尝试点,或许会有帮助:</p> 296 <p>在此,我进行了许多尝试,但都无一例外失败了;以下是我的尝试点,或许会有帮助:</p>
297 <ul> 297 <ul>
298 <li>根据<a href="">一个相似提问</a>,对相关依赖进行安装,失败了: <img 298 <li>根据<a href="">一个相似提问</a>,对相关依赖进行安装,失败了: <img
299 src="https://www.qin-juan-ge-zhu.top/images/code/ohos_gn_fail_dependencies.png" /></li> 299 src="https://www.qin-juan-ge-zhu.top/images/code/ohos_compile_gn_fail_dependencies.png" /></li>
300 <li>根据报错信息,在编译命令中添加<code>--no-prebuilt-sdk</code>选项对 ohos-sdk 的构建进行跳过,依然失败</li> 300 <li>根据报错信息,在编译命令中添加<code>--no-prebuilt-sdk</code>选项对 ohos-sdk 的构建进行跳过,依然失败</li>
301 </ul> 301 </ul>
302 <p>尝试未果 T^T</p> 302 <p>尝试未果 T^T</p>
@@ -304,7 +304,7 @@ current_toolchain=
304 <p>报错信息如下所示:</p> 304 <p>报错信息如下所示:</p>
305 <p>在上述报错信息中提到<code>Permission denied</code>,即权限不够;于是尝试添加<code>sudo</code>,居然跑通了!!!!</p> 305 <p>在上述报错信息中提到<code>Permission denied</code>,即权限不够;于是尝试添加<code>sudo</code>,居然跑通了!!!!</p>
306 <p>在指导书的编译指令<code>./build.sh --product-name rk3568 --ccache</code>前添加权限设置<code>sudo</code>,即指令更改为:</p> 306 <p>在指导书的编译指令<code>./build.sh --product-name rk3568 --ccache</code>前添加权限设置<code>sudo</code>,即指令更改为:</p>
307 <pre><code>sudo ./build.sh --product-name rk3568 --ccache</code></pre> 307 <pre><code class="language-bash">sudo ./build.sh --product-name rk3568 --ccache</code></pre>
308 <p>不知道为什么,编译过程中始终没有向我提出权限要求,但是不加<code>sudo</code>开权限就是跑不通,很奇怪 @ _ <span class="citation" 308 <p>不知道为什么,编译过程中始终没有向我提出权限要求,但是不加<code>sudo</code>开权限就是跑不通,很奇怪 @ _ <span class="citation"
309 data-cites="也许是">@也许是</span> OHOS 内敛不好意思申请权限呢……</p> 309 data-cites="也许是">@也许是</span> OHOS 内敛不好意思申请权限呢……</p>
310 <h2 id="另一个奇怪的报错failed-load-btf-from-vmlinux-unknown-error--22"> 310 <h2 id="另一个奇怪的报错failed-load-btf-from-vmlinux-unknown-error--22">
@@ -312,7 +312,7 @@ current_toolchain=
312 <p>关于这个报错,当时的错误日志、运行日志、聊天截图均已丢失,但时日不久,记忆还算清楚,加上这个报错困扰了我好些天,因而必须记录。</p> 312 <p>关于这个报错,当时的错误日志、运行日志、聊天截图均已丢失,但时日不久,记忆还算清楚,加上这个报错困扰了我好些天,因而必须记录。</p>
313 <h3 id="问题简要描述">问题简要描述</h3> 313 <h3 id="问题简要描述">问题简要描述</h3>
314 <p>正常按照<code>sudo ./build.sh --product-name rk3568 --ccache</code>编译时,报错,主要报错信息如下:</p> 314 <p>正常按照<code>sudo ./build.sh --product-name rk3568 --ccache</code>编译时,报错,主要报错信息如下:</p>
315 <pre><code>die__process_unit: DW_TAG_label (0xa) @ &lt;0x3adc&gt; not handled! 315 <pre><code class="language-plaintext">die__process_unit: DW_TAG_label (0xa) @ &lt;0x3adc&gt; not handled!
316die__process_unit: DW_TAG_label (0xa) @ &lt;0x3bdc&gt; not handled! 316die__process_unit: DW_TAG_label (0xa) @ &lt;0x3bdc&gt; not handled!
317die__process_unit: DW_TAG_label (0xa) @ &lt;0x3bef&gt; not handled! 317die__process_unit: DW_TAG_label (0xa) @ &lt;0x3bef&gt; not handled!
318die__process_unit: DW_TAG_label (0xa) @ &lt;0x3ce5&gt; not handled! 318die__process_unit: DW_TAG_label (0xa) @ &lt;0x3ce5&gt; not handled!
@@ -333,7 +333,7 @@ make[1]: *** [arch/arm64/Makefile:208: rk3568-toybrick-x0-linux.img]错误2
333make[1]: 离开目录&quot;/home/player/harmony/out/kernel/OBJ/linux-5.10&quot; 333make[1]: 离开目录&quot;/home/player/harmony/out/kernel/OBJ/linux-5.10&quot;
334make: *** [Makefile:192:__sub-make]错误 2</code></pre> 334make: *** [Makefile:192:__sub-make]错误 2</code></pre>
335 <p>可以看到,报错的关键点在于<code>FAILED: load BTF from vmlinux: Unknown error -22</code>这里。查看 Makefile 对应报错位置:</p> 335 <p>可以看到,报错的关键点在于<code>FAILED: load BTF from vmlinux: Unknown error -22</code>这里。查看 Makefile 对应报错位置:</p>
336 <pre><code>vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE 336 <pre><code class="language-makefile">vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
337 +$(call if_changed,link-vmlinux) 337 +$(call if_changed,link-vmlinux)
338 338
339targets := vmlinux</code></pre> 339targets := vmlinux</code></pre>
@@ -362,7 +362,7 @@ targets := vmlinux</code></pre>
362 时候推荐的最大虚拟机内存)是能编译完成的,编译时长 6h。最终解决。</p> 362 时候推荐的最大虚拟机内存)是能编译完成的,编译时长 6h。最终解决。</p>
363 <h1 id="ohos-的-ndk">ohos 的 NDK</h1> 363 <h1 id="ohos-的-ndk">ohos 的 NDK</h1>
364 <p>NDK 编译方式比较简单,在源码根目录下执行如下命令:</p> 364 <p>NDK 编译方式比较简单,在源码根目录下执行如下命令:</p>
365 <pre><code># 安装依赖 365 <pre><code class="language-bash"># 安装依赖
366./build/build_scripts/env_setup.sh 366./build/build_scripts/env_setup.sh
367 367
368# 执行完上述命令后记得执行source ~/.bashrc或者重启终端 368# 执行完上述命令后记得执行source ~/.bashrc或者重启终端
@@ -377,7 +377,7 @@ sudo apt-get install libxcursor-dev libxrandr-dev libxinerama-dev
377 <p>注意,NDK 包提供的交叉编译工具是 cmake 和 ninja,编译器是 clang 和 clang++,并没有我们熟悉的 gcc/g++和 make。除此之外,NDK 377 <p>注意,NDK 包提供的交叉编译工具是 cmake 和 ninja,编译器是 clang 和 clang++,并没有我们熟悉的 gcc/g++和 make。除此之外,NDK
378 还未我们提供编译所需的全套服务,如编译工具链配置文件<code>ohos.toolchain.cmake</code>、头文件、库文件等。快说,谢谢 ohos~</p> 378 还未我们提供编译所需的全套服务,如编译工具链配置文件<code>ohos.toolchain.cmake</code>、头文件、库文件等。快说,谢谢 ohos~</p>
379 <p>为了更方便地使用 NDK,鄙人不才,写了两个脚本,分别用于 cmake 编译和单文件编译:</p> 379 <p>为了更方便地使用 NDK,鄙人不才,写了两个脚本,分别用于 cmake 编译和单文件编译:</p>
380 <pre><code>#!/bin/bash 380 <pre><code class="language-bash">#!/bin/bash
381 381
382####################################################################### 382#######################################################################
383# File Name : compile.sh 383# File Name : compile.sh
@@ -418,7 +418,7 @@ cmake -B build -D OHOS_STL=c++_$link -D OHOS_ARCH=$arch \
418 -D OHOS_PLATFORM=OHOS \ 418 -D OHOS_PLATFORM=OHOS \
419 -D CMAKE_TOOLCHAIN_FILE=$(find $native_path -name ohos.toolchain.cmake) 419 -D CMAKE_TOOLCHAIN_FILE=$(find $native_path -name ohos.toolchain.cmake)
420cmake --build build</code></pre> 420cmake --build build</code></pre>
421 <pre><code>#!/bin/bash 421 <pre><code class="language-bash">#!/bin/bash
422 422
423####################################################################### 423#######################################################################
424# File Name : compile-tiny.sh 424# File Name : compile-tiny.sh
@@ -492,7 +492,7 @@ $compiler -o $targetFile $file -Wall \
492 </ul> 492 </ul>
493 <p>不说了,抓紧攒点钱开学升级电脑配置要紧……磁盘快炸了……</p> 493 <p>不说了,抓紧攒点钱开学升级电脑配置要紧……磁盘快炸了……</p>
494 <p class="time">2024.2.12,甲辰年正月初三<br>2024.4.24改<br>2024.11.19改</p> 494 <p class="time">2024.2.12,甲辰年正月初三<br>2024.4.24改<br>2024.11.19改</p>
495 <script src="https://test.qin-juan-ge-zhu.top/common/js/comment.js"></script> 495 <script src="https://www.qin-juan-ge-zhu.top/common/js/comment.js"></script>
496 </div> 496 </div>
497 </div> 497 </div>
498</body> 498</body>