From ec04c7a0c376e9a8a609407ff4e9a2bc77007421 Mon Sep 17 00:00:00 2001 From: jichuan Date: Thu, 13 Jul 2023 22:12:07 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=E6=94=AF=E6=8C=81=E4=B8=BB=E7=BA=BF?= =?UTF-8?q?=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- BUILD.gn | 15 ++++++++ bundle.json | 2 +- ide/BUILD.gn | 22 +++++++++++ ide/build.js | 101 ++++++++++++++++++++++++++++----------------------- ide/build.py | 22 +++++++++++ ide/build.sh | 25 +++++++++++++ 6 files changed, 140 insertions(+), 47 deletions(-) create mode 100644 BUILD.gn create mode 100644 ide/BUILD.gn create mode 100755 ide/build.py create mode 100755 ide/build.sh diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 000000000..09332f672 --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright (C) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +group("trace_streamer") { + deps = [ "ide:ts_build_sh" ] +} diff --git a/bundle.json b/bundle.json index b5f66e463..140107486 100755 --- a/bundle.json +++ b/bundle.json @@ -32,7 +32,7 @@ }, "build": { "sub_component": [ - "//developtools/smartperf_host/trace_streamer:trace_streamer" + "//developtools/smartperf_host:trace_streamer" ] } } diff --git a/ide/BUILD.gn b/ide/BUILD.gn new file mode 100644 index 000000000..619bf5ab3 --- /dev/null +++ b/ide/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (C) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +action("ts_build_sh") { + deps = [ "../trace_streamer:trace_streamer" ] + script = get_path_info("./build.sh", "abspath") + outputs = [ "$root_out_dir/developtools/smartperf_host/dist" ] + args = [ + rebase_path("."), + rebase_path("$root_out_dir/developtools/smartperf_host"), + ] +} diff --git a/ide/build.js b/ide/build.js index 4ead05d71..b0b6e2500 100644 --- a/ide/build.js +++ b/ide/build.js @@ -66,31 +66,35 @@ function cpFile(from, to) { } function checkEnvironment() { - let goVersion = childProcess.execSync('go version', { - encoding: 'utf-8', - }); - log.info('go is', goVersion); - let nodeVersion = childProcess.execSync('node -v', { - encoding: 'utf-8', - }); - log.info('node version is', nodeVersion); - let tscVersion = childProcess.execSync('tsc -v', { - encoding: 'utf-8', - }); - log.info('tsc version is', tscVersion); - if (goVersion == '' || nodeVersion == '' || tscVersion == '') { - return false; - } - let traceStreamer = path.normalize(path.join(__dirname, '/bin')); - if (!checkDirExist(traceStreamer + '/trace_streamer_builtin.js')) { - log.error(traceStreamer + '/trace_streamer_builtin.js' + ' Must exist'); - return false; - } - if (!checkDirExist(traceStreamer + '/trace_streamer_builtin.wasm')) { - log.error(traceStreamer + '/trace_streamer_builtin.wasm' + ' Must exist'); - return false; + if (process.argv.slice(2)[0]) { + return true; + } else { + let goVersion = childProcess.execSync('go version', { + encoding: 'utf-8', + }); + log.info('go is', goVersion); + let nodeVersion = childProcess.execSync('node -v', { + encoding: 'utf-8', + }); + log.info('node version is', nodeVersion); + let tscVersion = childProcess.execSync('tsc -v', { + encoding: 'utf-8', + }); + log.info('tsc version is', tscVersion); + if (goVersion == '' || nodeVersion == '' || tscVersion == '') { + return false; + } + let traceStreamer = path.normalize(path.join(__dirname, '/bin')); + if (!checkDirExist(traceStreamer + '/trace_streamer_builtin.js')) { + log.error(traceStreamer + '/trace_streamer_builtin.js' + ' Must exist'); + return false; + } + if (!checkDirExist(traceStreamer + '/trace_streamer_builtin.wasm')) { + log.error(traceStreamer + '/trace_streamer_builtin.wasm' + ' Must exist'); + return false; + } + return true; } - return true; } function initLog() { @@ -107,8 +111,11 @@ function initLog() { function main() { log = initLog(); - if (!checkEnvironment()) { - return; + let argv = process.argv.slice(2)[0]; + if (!argv){ + if (!checkEnvironment()) { + return; + } } // clean outDir let outPath = path.normalize(path.join(__dirname, '/', outDir)); @@ -150,27 +157,29 @@ function main() { let thirdDistFile = path.join(__dirname, outDir, value.distFilePath); cpFile(thirdFile, thirdDistFile); }); - let traceStreamer = path.normalize(path.join(__dirname, '/bin')); - if (checkDirExist(traceStreamer)) { - let dest = path.normalize(path.join(__dirname, outDir, '/bin')); - copyDirectory(traceStreamer, dest); - // to mv traceStream Wasm and js - cpFile( - traceStreamer + '/trace_streamer_builtin.js', - rootPath + outDir + '/trace/database/trace_streamer_builtin.js' - ); - cpFile( - traceStreamer + '/trace_streamer_builtin.wasm', - rootPath + outDir + '/trace/database/trace_streamer_builtin.wasm' - ); - if (sdkWams.length > 0) { - sdkWams.forEach((fileName) => { - cpFile(traceStreamer + '/' + fileName, rootPath + outDir + '/trace/database/' + fileName); - }); + if (!argv) { + let traceStreamer = path.normalize(path.join(__dirname, '/bin')); + if (checkDirExist(traceStreamer)) { + let dest = path.normalize(path.join(__dirname, outDir, '/bin')); + copyDirectory(traceStreamer, dest); + // to mv traceStream Wasm and js + cpFile( + traceStreamer + '/trace_streamer_builtin.js', + rootPath + outDir + '/trace/database/trace_streamer_builtin.js' + ); + cpFile( + traceStreamer + '/trace_streamer_builtin.wasm', + rootPath + outDir + '/trace/database/trace_streamer_builtin.wasm' + ); + if (sdkWams.length > 0) { + sdkWams.forEach((fileName) => { + cpFile(traceStreamer + '/' + fileName, rootPath + outDir + '/trace/database/' + fileName); + }); + } + } else { + log.error('traceStreamer dir is not Exits'); + return; } - } else { - log.error('traceStreamer dir is not Exits'); - return; } // compile server if (compileServer) { diff --git a/ide/build.py b/ide/build.py new file mode 100755 index 000000000..0a7ec14a5 --- /dev/null +++ b/ide/build.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import subprocess +import sys + +print("1 =", sys.argv[1]) +print("build.py start!") +subprocess.run(["npm", "install"]) +subprocess.run(["npm", "run", "compile"]) \ No newline at end of file diff --git a/ide/build.sh b/ide/build.sh new file mode 100755 index 000000000..97a780a35 --- /dev/null +++ b/ide/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e +echo "----------------smartperf_ide--------------------" +echo "1=$1" +echo "2=$2" +SOURCE="${BASH_SOURCE[0]}" +cd $(dirname ${SOURCE}) +npm install +npm run compile +mv $1/dist $2/dist +mkdir -p $2/dist/bin +mv $2/trace_streamer $2/dist/bin \ No newline at end of file -- Gitee From f03808b3bf42a0fa4ef15c400dfe5fd37f3ed7ed Mon Sep 17 00:00:00 2001 From: jichuan Date: Thu, 13 Jul 2023 22:17:38 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20build.sh=E7=BC=96=E8=AF=91=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- ide/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ide/build.sh b/ide/build.sh index 97a780a35..f03cb9238 100755 --- a/ide/build.sh +++ b/ide/build.sh @@ -19,7 +19,7 @@ echo "2=$2" SOURCE="${BASH_SOURCE[0]}" cd $(dirname ${SOURCE}) npm install -npm run compile +npm run compile ohos mv $1/dist $2/dist mkdir -p $2/dist/bin mv $2/trace_streamer $2/dist/bin \ No newline at end of file -- Gitee From 8c722f4242ba5e3ad02ca6627e90e16829431dee Mon Sep 17 00:00:00 2001 From: jichuan Date: Thu, 13 Jul 2023 22:29:31 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20build.sh=E7=BC=96=E8=AF=91=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- ide/build.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ide/build.js b/ide/build.js index b0b6e2500..bf8795cb0 100644 --- a/ide/build.js +++ b/ide/build.js @@ -19,7 +19,7 @@ const childProcess = require('child_process'); const os = require('os'); const log4js = require('log4js'); -const compileServer = true; +let compileServer = true; const outDir = 'dist'; const sdkWams = [ @@ -116,6 +116,8 @@ function main() { if (!checkEnvironment()) { return; } + } else { + compileServer = false; } // clean outDir let outPath = path.normalize(path.join(__dirname, '/', outDir)); -- Gitee From 850611d6f2d110b5c485d92caab1bf4090197370 Mon Sep 17 00:00:00 2001 From: jichuan Date: Thu, 13 Jul 2023 23:41:16 +0800 Subject: [PATCH 4/5] fix: gn Signed-off-by: jichuan --- ide/BUILD.gn | 2 +- trace_streamer/BUILD.gn | 4 ++-- trace_streamer/src/BUILD.gn | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ide/BUILD.gn b/ide/BUILD.gn index 619bf5ab3..ad5fba00a 100644 --- a/ide/BUILD.gn +++ b/ide/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. action("ts_build_sh") { - deps = [ "../trace_streamer:trace_streamer" ] + deps = [ "../trace_streamer:trace_streamer_port" ] script = get_path_info("./build.sh", "abspath") outputs = [ "$root_out_dir/developtools/smartperf_host/dist" ] args = [ diff --git a/trace_streamer/BUILD.gn b/trace_streamer/BUILD.gn index 839a23f8d..a694033df 100644 --- a/trace_streamer/BUILD.gn +++ b/trace_streamer/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import("build/ts.gni") -group("trace_streamer") { +group("trace_streamer_port") { if (is_test) { deps = [ "test:unittest" ] testonly = true @@ -33,6 +33,6 @@ group("trace_streamer") { } else if (use_wasm) { deps = [ "src:trace_streamer_builtin" ] } else { - deps = [ "src:trace_streamer" ] + deps = [ "src:trace_streamer_main" ] } } diff --git a/trace_streamer/src/BUILD.gn b/trace_streamer/src/BUILD.gn index 3ca2bc372..da24e83ba 100644 --- a/trace_streamer/src/BUILD.gn +++ b/trace_streamer/src/BUILD.gn @@ -180,7 +180,7 @@ if (use_wasm) { } } else { if (!is_test && !is_fuzz) { - ohos_executable("trace_streamer") { + ohos_executable("trace_streamer_main") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [] -- Gitee From 2e37d2fe3855dd42808d93f98c158aba4ec5d596 Mon Sep 17 00:00:00 2001 From: jichuan Date: Fri, 14 Jul 2023 09:07:07 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E6=8C=87trace=5Fstreamerer=5Fmain?= =?UTF-8?q?=E7=9A=84output=5Fname=E4=B8=BAtrace=5Fstreamer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- trace_streamer/src/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/trace_streamer/src/BUILD.gn b/trace_streamer/src/BUILD.gn index da24e83ba..01dff9249 100644 --- a/trace_streamer/src/BUILD.gn +++ b/trace_streamer/src/BUILD.gn @@ -181,6 +181,7 @@ if (use_wasm) { } else { if (!is_test && !is_fuzz) { ohos_executable("trace_streamer_main") { + output_name = "trace_streamer" subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [] -- Gitee