diff options
author | 2025-01-07 12:36:05 +0800 | |
---|---|---|
committer | 2025-01-07 12:36:05 +0800 | |
commit | 4d88ef666eee1b6f191f6e85b00acf8d5a2d1899 (patch) | |
tree | 68391846bae84f9546b0d089c012afc336a6e6bd /code/projects/lcm_compile.html | |
parent | 11e64c5804b696f170b9d5d881befbabc4a4e85c (diff) | |
download | myweb-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/lcm_compile.html')
-rw-r--r-- | code/projects/lcm_compile.html | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/code/projects/lcm_compile.html b/code/projects/lcm_compile.html index d889b58..7aa390a 100644 --- a/code/projects/lcm_compile.html +++ b/code/projects/lcm_compile.html | |||
@@ -7,14 +7,15 @@ | |||
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>LCM 交叉编译</title> | 8 | <title>LCM 交叉编译</title> |
9 | <link rel="stylesheet" href="https://www.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://hl.qin-juan-ge-zhu.top/myset/myhighlight.js"></script> | ||
11 | <script type="text/javascript" src="https://www.qin-juan-ge-zhu.top/common/script4code.js"></script> | 10 | <script type="text/javascript" src="https://www.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">LCM 交叉编译</p> | 16 | <header id="title-block-header"> |
17 | <p class="title">LCM 交叉编译</p> | ||
18 | </header> | ||
18 | <!-- 编译集成lcm模块 --> | 19 | <!-- 编译集成lcm模块 --> |
19 | <h1 id="lcm-简介">LCM 简介</h1> | 20 | <h1 id="lcm-简介">LCM 简介</h1> |
20 | <p>LCM(Lightweight Communications and | 21 | <p>LCM(Lightweight Communications and |
@@ -28,13 +29,13 @@ | |||
28 | <li><a href="https://zhuanlan.zhihu.com/p/621943685">一篇博客</a></li> | 29 | <li><a href="https://zhuanlan.zhihu.com/p/621943685">一篇博客</a></li> |
29 | </ul> | 30 | </ul> |
30 | <h1 id="依赖项安装">依赖项安装</h1> | 31 | <h1 id="依赖项安装">依赖项安装</h1> |
31 | <pre><code>sudo apt update | 32 | <pre><code class="language-bash">sudo apt update |
32 | sudo apt upgrade | 33 | sudo apt upgrade |
33 | sudo apt install build-essential cmake libglib2.0-dev | 34 | sudo apt install build-essential cmake libglib2.0-dev |
34 | sudo apt install openjdk-8-jdk # lcm仅支持jdk8</code></pre> | 35 | sudo apt install openjdk-8-jdk # lcm仅支持jdk8</code></pre> |
35 | <h1 id="x86-的-lcm">x86 的 lcm</h1> | 36 | <h1 id="x86-的-lcm">x86 的 lcm</h1> |
36 | <p>如果我们仅仅需要 x86 架构的 lcm,执行下列命令即可:</p> | 37 | <p>如果我们仅仅需要 x86 架构的 lcm,执行下列命令即可:</p> |
37 | <pre><code>git clone https://github.com/lcm-proj/lcm | 38 | <pre><code class="language-bash">git clone https://github.com/lcm-proj/lcm |
38 | cd lcm | 39 | cd lcm |
39 | mkdir build && cd build | 40 | mkdir build && cd build |
40 | cmake .. | 41 | cmake .. |
@@ -48,14 +49,14 @@ sudo make install</code></pre> | |||
48 | <p>lcm-spy 是 LCM 配套的数据可视化工具。 可以通过 lcm-spy 监视 lcm 数据发送频率、数据量、数据结构,甚至实时画图。 如果安装了 JAVA,则 lcm-spy 会连同 LCM 一同被安装。 | 49 | <p>lcm-spy 是 LCM 配套的数据可视化工具。 可以通过 lcm-spy 监视 lcm 数据发送频率、数据量、数据结构,甚至实时画图。 如果安装了 JAVA,则 lcm-spy 会连同 LCM 一同被安装。 |
49 | </p> | 50 | </p> |
50 | <p>启动 lcm-spy:</p> | 51 | <p>启动 lcm-spy:</p> |
51 | <pre><code>export CLASSPATH=${your lcm-type class path} | 52 | <pre><code class="language-bash">export CLASSPATH=${your lcm-type class path} |
52 | lcm-spy</code></pre> | 53 | lcm-spy</code></pre> |
53 | <h1 id="交叉编译">交叉编译</h1> | 54 | <h1 id="交叉编译">交叉编译</h1> |
54 | <p>既然 lcm 用的是 cmake,何不交叉编译到 OHOS 里用呢?</p> | 55 | <p>既然 lcm 用的是 cmake,何不交叉编译到 OHOS 里用呢?</p> |
55 | <p>首先,我们可以设置一下 Native Development Kit(NDK)的路径:</p> | 56 | <p>首先,我们可以设置一下 Native Development Kit(NDK)的路径:</p> |
56 | <pre><code># 设置成自己的NDK工具目录 | 57 | <pre><code class="language-bash"># 设置成自己的NDK工具目录 |
57 | export OHOS_ROOT=~/app/native</code></pre> | 58 | export OHOS_ROOT=~/app/native</code></pre> |
58 | <pre><code>$OHOS_ROOT/build-tools/cmake/bin/cmake \ | 59 | <pre><code class="language-bash">$OHOS_ROOT/build-tools/cmake/bin/cmake \ |
59 | -DOHOS_STL=c++_shared \ | 60 | -DOHOS_STL=c++_shared \ |
60 | -DOHOS_ARCH=armv8-a \ | 61 | -DOHOS_ARCH=armv8-a \ |
61 | -DOHOS_PLATFORM=OHOS \ | 62 | -DOHOS_PLATFORM=OHOS \ |
@@ -66,7 +67,7 @@ export OHOS_ROOT=~/app/native</code></pre> | |||
66 | <p>解决方案自然是自己手动交叉编译<code>libglib2.0-dev</code>。</p> | 67 | <p>解决方案自然是自己手动交叉编译<code>libglib2.0-dev</code>。</p> |
67 | <h2 id="glib2.0-交叉编译">Glib2.0 交叉编译</h2> | 68 | <h2 id="glib2.0-交叉编译">Glib2.0 交叉编译</h2> |
68 | <p>从<a href="https://download.gnome.org/sources/glib/">官网</a>下载 glib-2.79.2 源码,解压后进入源码目录。</p> | 69 | <p>从<a href="https://download.gnome.org/sources/glib/">官网</a>下载 glib-2.79.2 源码,解压后进入源码目录。</p> |
69 | <pre><code>mkdir glib && cd glib | 70 | <pre><code class="language-bash">mkdir glib && cd glib |
70 | wget https://download.gnome.org/sources/glib/2.79/glib-2.79.2.tar.xz | 71 | wget https://download.gnome.org/sources/glib/2.79/glib-2.79.2.tar.xz |
71 | tar -xvf glib-2.79.2.tar.xz | 72 | tar -xvf glib-2.79.2.tar.xz |
72 | mkdir build</code></pre> | 73 | mkdir build</code></pre> |
@@ -78,7 +79,7 @@ mkdir build</code></pre> | |||
78 | <p>接着,参考博客<a | 79 | <p>接着,参考博客<a |
79 | href="https://t.csdnimg.cn/YfSJC">这篇博客</a>,撰写如下<kbd>meson_ohos.txt</kbd>(友情提醒,使用该文件时把<kbd>native</kbd>也就是 | 80 | href="https://t.csdnimg.cn/YfSJC">这篇博客</a>,撰写如下<kbd>meson_ohos.txt</kbd>(友情提醒,使用该文件时把<kbd>native</kbd>也就是 |
80 | NDK 的路径修改为自己的路径、源平台与目标平台按需修改):</p> | 81 | NDK 的路径修改为自己的路径、源平台与目标平台按需修改):</p> |
81 | <pre><code>[binaries] | 82 | <pre><code class="language-meson">[binaries] |
82 | c = '$OHOS_ROOT/llvm/bin/aarch64-unknown-linux-ohos-clang' | 83 | c = '$OHOS_ROOT/llvm/bin/aarch64-unknown-linux-ohos-clang' |
83 | cpp = '$OHOS_ROOT/llvm/bin/aarch64-unknown-linux-ohos-clang++' | 84 | cpp = '$OHOS_ROOT/llvm/bin/aarch64-unknown-linux-ohos-clang++' |
84 | ar = '$OHOS_ROOT/llvm/bin/llvm-ar' | 85 | ar = '$OHOS_ROOT/llvm/bin/llvm-ar' |
@@ -102,15 +103,16 @@ cpu_family = 'aarch64' | |||
102 | cpu = 'armv8a' | 103 | cpu = 'armv8a' |
103 | endian = 'little'</code></pre> | 104 | endian = 'little'</code></pre> |
104 | <p>将该文件放置在<kbd>glib-2.79.2</kbd>源码目录下,而后在<kbd>build</kbd>目录下执行以下命令:</p> | 105 | <p>将该文件放置在<kbd>glib-2.79.2</kbd>源码目录下,而后在<kbd>build</kbd>目录下执行以下命令:</p> |
105 | <pre><code>meson --cross-file=../glib-2.79.2/meson_ohos.txt .. | 106 | <pre><code class="language-bash">meson --cross-file=../glib-2.79.2/meson_ohos.txt .. |
106 | ninja</code></pre> | 107 | ninja</code></pre> |
107 | <p>编译完成,正确地安装 glib2 到交叉编译工具链中(???),之后我们回到 lcm 的源码目录,重新执行 cmake 命令:</p> | 108 | <p>编译完成,正确地安装 glib2 到交叉编译工具链中(???),之后我们回到 lcm 的源码目录,重新执行 cmake 命令:</p> |
108 | <pre><code>$OHOS_ROOT/build-tools/cmake/bin/cmake \ | 109 | <pre><code class="language-bash">$OHOS_ROOT/build-tools/cmake/bin/cmake \ |
109 | -DOHOS_STL=c++_shared \ | 110 | -DOHOS_STL=c++_shared \ |
110 | -DOHOS_ARCH=armv8-a \ | 111 | -DOHOS_ARCH=armv8-a \ |
111 | -DOHOS_PLATFORM=OHOS \ | 112 | -DOHOS_PLATFORM=OHOS \ |
112 | -DCMAKE_TOOLCHAIN_FILE=$(find $OHOS_ROOT -name "ohos.toolchain.cmake")</code></pre> | 113 | -DCMAKE_TOOLCHAIN_FILE=$(find $OHOS_ROOT -name "ohos.toolchain.cmake")</code></pre> |
113 | <p>这次,编译成功了。万岁!</p> | 114 | <p>这次,编译成功了。万岁!</p> |
115 | <p class="time">2024.4</p> | ||
114 | <script src="https://www.qin-juan-ge-zhu.top/common/js/comment.js"></script> | 116 | <script src="https://www.qin-juan-ge-zhu.top/common/js/comment.js"></script> |
115 | </div> | 117 | </div> |
116 | </div> | 118 | </div> |