1<!DOCTYPE html> 2<html> 3 <head> 4 <title>compile_trace_streamer</title> 5 <meta charset="utf-8" /> 6 <meta content="width=device-width, initial-scale=1.0" name="viewport" /> 7 8 <style> 9 code[class*='font-'], 10 pre[class*='font-'] { 11 text-align: left; 12 color: #333333; 13 background: none; 14 word-spacing: normal; 15 white-space: pre; 16 word-break: normal; 17 word-wrap: normal; 18 line-height: 1.5; 19 -moz-hyphens: none; 20 -ms-hyphens: none; 21 -o-tab-size: 8; 22 tab-size: 8; 23 -moz-tab-size: 8; 24 -webkit-hyphens: none; 25 hyphens: none; 26 font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; 27 } 28 29 pre[class*='font-'] { 30 border-radius: 3px; 31 background: #f5f5f5; 32 padding: 0.8em; 33 overflow: auto; 34 } 35 36 :not(pre) > code[class*='font-'] { 37 white-space: normal; 38 background: #f5f5f5; 39 padding: 0.2em; 40 border-radius: 0.3em; 41 } 42 43 .temporary.cdata { 44 color: #183690; 45 } 46 47 .temporary.comment, 48 .temporary.blockquote { 49 color: #969897; 50 } 51 52 .temporary.doctype, 53 .temporary.punctuation, 54 .temporary.variable, 55 .temporary.macro.property { 56 color: #333333; 57 } 58 59 .temporary.string, 60 .temporary.url, 61 .temporary.regex, 62 .temporary.attr-value { 63 color: #183690; 64 } 65 66 .temporary.operator, 67 .temporary.important, 68 .temporary.keyword, 69 .temporary.rule, 70 .temporary.builtin { 71 color: #a71d5c; 72 } 73 74 .temporary.atrule, 75 .temporary.constant, 76 .temporary.symbol, 77 .temporary.command, 78 .temporary.property, 79 .temporary.number, 80 .temporary.boolean, 81 .temporary.entity, 82 .temporary.code { 83 color: #0086b2; 84 } 85 86 .temporary.tag, 87 .temporary.selector, 88 .temporary.prolog { 89 color: #63a35e; 90 } 91 92 .temporary.entity { 93 cursor: help; 94 } 95 96 .temporary.title, 97 .temporary.title .temporary.punctuation { 98 font-weight: bold; 99 color: #1d3e89; 100 } 101 102 .temporary.list { 103 color: #ed6a48; 104 } 105 106 .temporary.function, 107 .temporary.namespace, 108 .temporary.pseudo-element, 109 .temporary.class, 110 .temporary.class-name, 111 .temporary.pseudo-class, 112 .temporary.id, 113 .temporary.url-reference .temporary.variable, 114 .temporary.attr-name { 115 color: #795da2; 116 } 117 118 .temporary.inserted { 119 color: #55a535; 120 background-color: #eaffee; 121 } 122 123 .temporary.bold { 124 font-weight: bold; 125 } 126 127 .temporary.deleted { 128 color: #bd2c08; 129 background-color: #ffecea; 130 } 131 132 .font-json .temporary.property { 133 color: #183690; 134 } 135 136 .temporary.italic { 137 font-style: italic; 138 } 139 140 .font-markup .temporary.tag .temporary.punctuation { 141 color: #333333; 142 } 143 144 .font-yaml .temporary.atrule { 145 color: #63a35a; 146 } 147 148 code.font-css, 149 .font-css .temporary.function { 150 color: #0086b8; 151 } 152 153 code.font-yaml { 154 color: #183690; 155 } 156 157 .font-ruby .temporary.function { 158 color: #333333; 159 } 160 161 .font-markdown .temporary.url { 162 color: #795da2; 163 } 164 165 .font-makefile .temporary.variable { 166 color: #183690; 167 } 168 169 .font-makefile .temporary.builtin { 170 color: #0086b3; 171 } 172 173 .font-makefile .temporary.symbol { 174 color: #795da2; 175 } 176 177 .font-bash .temporary.keyword { 178 color: #0086b3; 179 } 180 181 pre[data-wire] { 182 padding: 1em 0 1em 2em; 183 position: relative; 184 } 185 186 pre[data-wire] .line-highlight-wrapper { 187 background-color: transparent; 188 top: 2px; 189 left: 2px; 190 display: block; 191 width: 100%; 192 position: absolute; 193 } 194 195 pre[data-wire] .line-highlight { 196 position: absolute; 197 left: 2px; 198 right: 2px; 199 pointer-events: none; 200 margin-top: 3em; 201 background: hsla(25, 10%, 55%, 0.06); 202 background: linear-gradient(to right, hsla(25, 10%, 40%, 0.2) 80%, hsla(23, 24%, 52%, 0)); 203 line-height: inherit; 204 white-space: pre; 205 } 206 207 pre[data-wire] .line-highlight:before, 208 pre[data-wire] .line-highlight[data-end]:after { 209 content: attr(data-start); 210 position: absolute; 211 background-color: hsla(22, 25%, 54%, 0.5); 212 min-width: 2em; 213 padding: 0 0.6em; 214 top: 0.5em; 215 left: 0.4em; 216 color: hsl(22, 23%, 90%); 217 vertical-align: 0.3em; 218 border-radius: 10px; 219 text-shadow: none; 220 box-shadow: 0 2px white; 221 font: bold 60%/1.6 sans-serif; 222 text-align: center; 223 } 224 225 pre[data-wire] .line-highlight[data-end]:after { 226 bottom: 0.6em; 227 content: attr(data-end); 228 top: auto; 229 } 230 231 body { 232 font-size: 16px; 233 font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; 234 line-height: 1.6; 235 overflow: initial; 236 box-sizing: border-box; 237 word-wrap: break-word; 238 color: #333333; 239 background-color: #ffffff; 240 } 241 242 body > :first-child { 243 margin-top: 0; 244 } 245 246 body h1, 247 body h2, 248 body h3 { 249 margin-bottom: 16px; 250 color: #000000; 251 line-height: 1.2; 252 margin-top: 1em; 253 } 254 255 body h1 { 256 font-weight: 300; 257 font-size: 2.25em; 258 padding-bottom: 0.3em; 259 } 260 261 body h2 { 262 font-weight: 400; 263 font-size: 1.75em; 264 padding-bottom: 0.3em; 265 } 266 267 body h3 { 268 font-size: 1.5em; 269 font-weight: 500; 270 } 271 272 body h1, 273 body h2, 274 body h3 { 275 font-weight: 600; 276 } 277 278 body del { 279 color: #5c5c5c; 280 } 281 282 body strong { 283 color: #000000; 284 } 285 286 body a { 287 text-decoration: none; 288 color: #08c; 289 } 290 291 body a:not([href]) { 292 text-decoration: none; 293 color: inherit; 294 } 295 296 body a:hover { 297 color: #00a3f5; 298 text-decoration: none; 299 } 300 301 body img { 302 max-width: 100%; 303 } 304 305 body > ul, 306 body > ol { 307 margin-bottom: 16px; 308 } 309 310 body ul, 311 body ol { 312 padding-left: 2em; 313 } 314 315 body > p { 316 margin-top: 0; 317 word-wrap: break-word; 318 margin-bottom: 16px; 319 } 320 321 body ul.no-list, 322 body ol.no-list { 323 padding: 0; 324 list-style-type: none; 325 } 326 327 body li { 328 margin-bottom: 0; 329 } 330 331 body ul ul, 332 body ul ol, 333 body ol ol, 334 body ol ul { 335 margin-top: 0; 336 margin-bottom: 0; 337 } 338 339 body li.task-list-item { 340 list-style: none; 341 } 342 343 body li > p { 344 margin-top: 0; 345 margin-bottom: 0; 346 } 347 348 body .task-list-item-checkbox { 349 margin: 0 0.2em 0.25em -1.8em; 350 vertical-align: middle; 351 } 352 353 body blockquote { 354 margin: 16px 0; 355 font-size: inherit; 356 padding: 0 15px 0 0; 357 color: #5c5c5c; 358 background-color: #f0f0f0; 359 border-left: 4px solid #d6d6d6; 360 } 361 362 body .task-list-item-checkbox:hover { 363 cursor: pointer; 364 } 365 366 body blockquote > :first-child { 367 margin-top: 0; 368 } 369 370 body blockquote > :last-child { 371 margin-bottom: 0; 372 } 373 374 body hr { 375 background-color: #d6d6d6; 376 height: 6px; 377 border: 0 none; 378 margin: 32px 0 0 0; 379 } 380 381 body table th { 382 font-weight: bold; 383 color: #000000; 384 } 385 386 body table { 387 margin: 10px 0 15px 0; 388 border-collapse: collapse; 389 border-spacing: 0; 390 width: 100%; 391 display: block; 392 overflow: auto; 393 word-break: normal; 394 word-break: keep-all; 395 } 396 397 body table td, 398 body table th { 399 padding: 5px 14px 0 0; 400 border: 1px solid #d6d6d6; 401 } 402 403 body dl { 404 padding: 0; 405 } 406 407 body dl dd { 408 padding: 0 15px; 409 margin-bottom: 15px; 410 } 411 412 body dl dt { 413 margin-top: 16px; 414 padding: 0; 415 font-size: 1em; 416 font-weight: bold; 417 font-style: italic; 418 } 419 420 body code { 421 font-size: 0.85em !important; 422 font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; 423 padding: 0.2em 0 0 0; 424 color: #000000; 425 background-color: #f0f0f0; 426 border-radius: 3px; 427 } 428 429 body code::before, 430 body code::after { 431 letter-spacing: -0.2em; 432 content: '\00a0'; 433 } 434 435 body .highlight pre { 436 word-break: normal; 437 margin-bottom: 0; 438 } 439 440 body pre > code { 441 word-break: normal; 442 white-space: pre; 443 background: transparent; 444 border: 0; 445 padding: 0; 446 margin: 0; 447 font-size: 0.85em !important; 448 } 449 450 body .highlight { 451 margin-bottom: 15px; 452 } 453 454 body pre code, 455 body pre tt { 456 display: inline; 457 max-width: initial; 458 word-wrap: normal; 459 overflow: initial; 460 line-height: inherit; 461 background-color: transparent; 462 border: 0; 463 padding: 0; 464 margin: 0; 465 } 466 467 body .highlight pre, 468 body pre { 469 overflow: auto; 470 font-size: 0.85em !important; 471 line-height: 1.45; 472 border: #d6d6d6; 473 border-radius: 3px; 474 padding: 1em; 475 } 476 477 body pre code:before, 478 body pre tt:before, 479 body pre code:after, 480 body pre tt:after { 481 content: normal; 482 } 483 484 body p, 485 body blockquote, 486 body ul, 487 body ol, 488 body dl, 489 body pre { 490 margin-top: 0; 491 margin-bottom: 15px; 492 } 493 494 body kbd { 495 color: #000000; 496 border: 1px solid #d6d6d6; 497 border-bottom: 2px solid #c7c7c7; 498 padding: 2px 4px 0 0; 499 background-color: #f0f0f0; 500 border-radius: 3px; 501 } 502 503 @media print { 504 body { 505 background-color: #ffffff; 506 } 507 508 body pre { 509 page-break-inside: avoid; 510 } 511 512 body table { 513 display: table; 514 } 515 516 body h1, 517 body h2, 518 body h3 { 519 page-break-after: avoid; 520 color: #000000; 521 } 522 523 body blockquote { 524 color: #5c5c5c; 525 } 526 527 body pre, 528 body code { 529 white-space: pre; 530 word-wrap: break-word; 531 } 532 533 body img { 534 display: block; 535 max-width: 100%; 536 max-height: 100%; 537 } 538 } 539 540 .md-preview { 541 box-sizing: border-box; 542 width: 100%; 543 height: 100%; 544 } 545 546 .md-preview pre.line-numbers { 547 position: relative; 548 padding-left: 4em; 549 counter-reset: linenumber; 550 } 551 552 .md-preview .pagebreak, 553 .md-preview .newpage { 554 page-break-before: always; 555 } 556 557 .md-preview pre.line-numbers > code { 558 position: relative; 559 } 560 561 .md-preview pre.line-numbers .figure-numbers-rows > span { 562 pointer-events: none; 563 display: block; 564 counter-increment: linenumber; 565 } 566 567 .md-preview pre.line-numbers .figure-numbers-rows > span:before { 568 text-align: right; 569 content: counter(linenumber); 570 color: #999999; 571 display: block; 572 padding-right: 0.8em; 573 } 574 575 .md-preview pre.line-numbers .figure-numbers-rows { 576 position: absolute; 577 top: 1em; 578 left: 0; 579 width: 3em; 580 letter-spacing: -1px; 581 border-right: 1px solid #999999; 582 user-select: none; 583 -webkit-user-select: none; 584 -moz-user-select: none; 585 -ms-user-select: none; 586 pointer-events: none; 587 font-size: 100%; 588 } 589 590 .md-preview:not([for='preview']) .code-chunk .btn-group { 591 display: none; 592 } 593 594 .md-preview:not([for='preview']) .code-chunk .status { 595 display: none; 596 } 597 598 .md-preview:not([for='preview']) .code-chunk .output-div { 599 margin-bottom: 16px; 600 } 601 602 .scrollbar-type::-webkit-scrollbar { 603 width: 8px; 604 } 605 606 .scrollbar-type::-webkit-scrollbar-thumb { 607 border-radius: 6px; 608 background-clip: content-box; 609 background-color: rgba(150, 150, 150, 0.66); 610 border: 4px solid rgba(150, 150, 150, 0.66); 611 } 612 613 .scrollbar-type::-webkit-scrollbar-track { 614 border-radius: 10px; 615 background-color: transparent; 616 } 617 618 body[for='native-export']:not([data-display-mode]) .md-preview { 619 position: relative; 620 top: 0; 621 } 622 623 @media screen and (max-width: 450px) { 624 body[for='native-export']:not([data-display-mode]) .md-preview { 625 font-size: 14px !important; 626 padding: 1em; 627 } 628 } 629 630 @media print { 631 body[for='native-export']:not([data-display-mode]) #sidebarButton { 632 display: none; 633 } 634 } 635 636 @media screen and (min-width: 914px) { 637 body[for='native-export']:not([data-display-mode]) .md-preview { 638 padding: 2em calc(50% - 457px + 2em); 639 } 640 } 641 642 @media screen and (max-width: 914px) { 643 body[for='native-export']:not([data-display-mode]) .md-preview { 644 padding: 2em; 645 } 646 } 647 648 body[for='native-export']:not([data-display-mode]) #sidebarButton { 649 position: fixed; 650 bottom: 8px; 651 left: 8px; 652 font-size: 28px; 653 cursor: pointer; 654 color: inherit; 655 text-align: center; 656 opacity: 0.4; 657 z-index: 99; 658 width: 32px; 659 } 660 661 body[for='native-export']:not([data-display-mode])[sidebarToc] #sidebarButton { 662 opacity: 1; 663 } 664 665 body[for='native-export']:not([data-display-mode])[sidebarToc] .md-sidebar-toc { 666 position: fixed; 667 top: 0; 668 left: 0; 669 padding: 32px 0 48px 0; 670 width: 300px; 671 height: 100%; 672 font-size: 14px; 673 box-shadow: 0 0 4px rgba(150, 150, 150, 0.33); 674 box-sizing: border-box; 675 overflow: auto; 676 background-color: inherit; 677 } 678 679 body[for='native-export']:not([data-display-mode])[sidebarToc] .md-sidebar-toc::-webkit-scrollbar { 680 width: 8px; 681 } 682 683 body[for='native-export']:not([data-display-mode])[sidebarToc] .md-sidebar-toc::-webkit-scrollbar-track { 684 background-color: transparent; 685 border-radius: 10px; 686 } 687 688 body[for='native-export']:not([data-display-mode])[sidebarToc] .md-sidebar-toc::-webkit-scrollbar-thumb { 689 background-color: rgba(150, 150, 150, 0.66); 690 border-radius: 5px; 691 border: 4px solid rgba(150, 150, 150, 0.66); 692 background-clip: content-box; 693 } 694 695 body[for='native-export']:not([data-display-mode])[sidebarToc] .md-sidebar-toc a { 696 text-decoration: none; 697 } 698 699 body[for='native-export']:not([data-display-mode])[sidebarToc] .md-sidebar-toc li { 700 margin-bottom: 0.8em; 701 } 702 703 body[for='native-export']:not([data-display-mode])[sidebarToc] .md-sidebar-toc ul { 704 margin-top: 0.8em; 705 padding: 0 1.6em; 706 } 707 708 body[for='native-export']:not([data-display-mode])[sidebarToc] .md-sidebar-toc ul { 709 list-style-type: none; 710 } 711 712 body[for='native-export']:not([data-display-mode])[sidebarToc] .md-preview { 713 padding: 2em calc(50% - 457px - 150px); 714 margin: 0; 715 box-sizing: border-box; 716 left: 300px; 717 width: calc(100% - 300px); 718 } 719 720 @media screen and (max-width: 450px) { 721 body[for='native-export']:not([data-display-mode])[sidebarToc] .md-preview { 722 width: 100%; 723 } 724 } 725 726 @media screen and (max-width: 1274px) { 727 body[for='native-export']:not([data-display-mode])[sidebarToc] .md-preview { 728 padding: 2em; 729 } 730 } 731 732 body[for='native-export']:not([data-display-mode]):not([sidebarToc]) .md-preview { 733 transform: translateX(-50%); 734 left: 50%; 735 } 736 737 body[for='native-export']:not([data-display-mode]):not([sidebarToc]) .md-sidebar-toc { 738 display: none; 739 } 740 </style> 741 </head> 742 <body for="native-export" id="body"> 743 <div class="mume md-preview"> 744 <h1 class="mume-header fontColor">1.如何独立编译Trace_streamer</h1> 745 746 <p class="fontColor">尽管本工具(trace_streamer)是在ohos工具箱中的一员,但你依然可以独立编译此工具。</p> 747 <p class="fontColor">本工具可以编译linux, mac, windows, WebAssembly版本。</p> 748 <p class="fontColor">本工具默认编译方式是使用gn</p> 749 <ul class="fontColor"> 750 <li>编译方式</li> 751 </ul> 752 <pre class="font- light" data-info data-role="codeBlock"><code class="fontColor">third_party部分安装方式 753third_party相关控件下载链接:https://gitee.com/organizations/openharmony/projects 754在src路径下创建同级目录third_party。 755一、sqlite: 7561.打开上方链接,搜索sqlite。 7572.点击搜索结果进入下载界面,下载sqlite组件。 7583.把下载的文件解压后,文件夹命名为sqlite,并用代码路径中\prebuilts\buildsqlite\sqlite3build.gn文件替换sqlite目录中的BUILD.gn文件。 7594.把sqlite文件夹放入third_party目录中。 760二、protobuf: 7611.按上述下载方法,下载protobuf组件。 7622.把下载的文件解压后,文件夹命名为protobuf,并用代码路径中\prebuilts\buildprotobuf\protobufbuild.gn文件替换protobuf目录中的BUILD.gn文件。 7633.把protobuf文件夹放入third_party目录中。 764三、googletest: 7651.按上述下载方法,下载googletest相关组件。 7662.把下载的文件解压后,文件夹命名为googletest,并用代码路径中\prebuilts\buildgoogletest\googletestbuild.gn文件替换googletest目录中的BUILD.gn文件。 7673.把googletest文件夹放入third_party目录中。 7684.找到文件\googletest\include\gtest\internal\ gtest-port.h 把286行 #include <sstream> // NOLINT修改为 769#undef private 770#define private private 771#include <sstream> // NOLINT 772#undef private 773#define private public</code></pre> 774 775 <p class="fontColor">编译不同版本:linux, WebAssembly, mac</p> 776 <pre class="font- light" data-info data-role="codeBlock"><code class="fontColor">./build.sh linux/wasm/macx 777</code></pre> 778 779 <p class="fontColor">如果需要编译WebAssembly版本,您需要在prebuilts/目录下安装emsdk</p> 780 <pre 781 class="font- light" 782 data-info 783 data-role="codeBlock"><code class="fontColor">git clone https://github.com/juj/emsdk.git --depth=1 784cd emsdk 785git pull 786./emsdk update # this may not work, ignore it 787./emsdk install latest 788./emsdk activate latest 789安装之后,您需要将upstream目录复制到prebuilts/emsdk/emsdk,node复制到prebuilts/emsdk/node 790</code></pre> 791 <p class="fontColor">安装之后,目录结构当如:</p> 792 <pre class="font- light" data-info data-role="codeBlock"><code class="fontColor">prebuilts/emsdk 793├── prebuilts/emsdk/emsdk 794│ ├── prebuilts/emsdk/emsdk/bin 795│ ├── prebuilts/emsdk/emsdk/emscripten 796│ │ ├── prebuilts/emsdk/emsdk/emscripten/cache 797│ │ ├── prebuilts/emsdk/emsdk/emscripten/cmake 798│ │ ├── prebuilts/emsdk/emsdk/emscripten/docs 799│ │ ├── prebuilts/emsdk/emsdk/emscripten/media 800│ │ ├── prebuilts/emsdk/emsdk/emscripten/node_modules 801│ │ ├── prebuilts/emsdk/emsdk/emscripten/__pycache__ 802│ │ ├── prebuilts/emsdk/emsdk/emscripten/src 803│ │ ├── prebuilts/emsdk/emsdk/emscripten/system 804│ │ ├── prebuilts/emsdk/emsdk/emscripten/tests 805│ │ ├── prebuilts/emsdk/emsdk/emscripten/third_party 806│ │ └── prebuilts/emsdk/emsdk/emscripten/tools 807│ ├── prebuilts/emsdk/emsdk/include 808│ │ └── prebuilts/emsdk/emsdk/include/c++ 809│ └── prebuilts/emsdk/emsdk/lib 810│ └── prebuilts/emsdk/emsdk/lib/clang 811└── prebuilts/emsdk/node 812 └── prebuilts/emsdk/node/14.18.2_64bit 813 ├── prebuilts/emsdk/node/14.18.2_64bit/bin 814 ├── prebuilts/emsdk/node/14.18.2_64bit/include 815 ├── prebuilts/emsdk/node/14.18.2_64bit/lib 816 └── prebuilts/emsdk/node/14.18.2_64bit/share 817</code></pre> 818 <p class="fontColor">之后调用</p> 819 <pre 820 class="font- light" 821 data-info 822 data-role="codeBlock"><code class="fontColor">./build.sh wasm进行编译,您需要将sh脚本进行部分修改,因为这个脚本内置了一些库的下载和解析方式 823</code></pre> 824 </div> 825 <script type="text/javascript"> 826 window.onload = () => { 827 let isDark = window.location.search; 828 if (isDark.indexOf('?') != -1) { 829 isDark = isDark.substr(1, isDark.length - 1); 830 } 831 if (isDark == 'true') { 832 document.getElementById('body').setAttribute('style', 'background-color:#272C34;'); 833 let header = document.getElementsByClassName('fontColor'); 834 for (let i = 0; i < header.length; i++) { 835 header[i].style.color = '#fff'; 836 } 837 let lightBackGround = document.getElementsByClassName('light'); 838 for (let i = 0; i < lightBackGround.length; i++) { 839 lightBackGround[i].style.backgroundColor = '#32373F'; 840 } 841 } 842 }; 843 </script> 844 </body> 845</html> 846