diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..09332f672e6198a3fe325c0d76c8d699cd5db0a7 --- /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 b5f66e46323457b17560493f95f56cc2968b73e8..14010748607864a4e273e567fc65417b92b4aa54 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 0000000000000000000000000000000000000000..ad5fba00adfb78124448dae15e5edd0d0ad51619 --- /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_port" ] + 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 4ead05d71f42e8573b2ebd108268626ca284d5df..bf8795cb069f8b1789bf8b5d4918ddb426f93174 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 = [ @@ -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,13 @@ function initLog() { function main() { log = initLog(); - if (!checkEnvironment()) { - return; + let argv = process.argv.slice(2)[0]; + if (!argv){ + if (!checkEnvironment()) { + return; + } + } else { + compileServer = false; } // clean outDir let outPath = path.normalize(path.join(__dirname, '/', outDir)); @@ -150,27 +159,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 0000000000000000000000000000000000000000..0a7ec14a5e6642b6e9bff5059a19d9600394a077 --- /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 0000000000000000000000000000000000000000..f03cb923876e7aed91f852793a19df3ebd7e6252 --- /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 ohos +mv $1/dist $2/dist +mkdir -p $2/dist/bin +mv $2/trace_streamer $2/dist/bin \ No newline at end of file diff --git a/trace_streamer/BUILD.gn b/trace_streamer/BUILD.gn index 839a23f8db58935cef8e9b4b095fb2a02026701a..a694033df690fef52cc8a52ba7ee91d564936840 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 3ca2bc372f4c2c1e899bcfb870f65f172b77b8e8..01dff9249e1d6ed8171e41a93d073c82ec94a44f 100644 --- a/trace_streamer/src/BUILD.gn +++ b/trace_streamer/src/BUILD.gn @@ -180,7 +180,8 @@ if (use_wasm) { } } else { if (!is_test && !is_fuzz) { - ohos_executable("trace_streamer") { + ohos_executable("trace_streamer_main") { + output_name = "trace_streamer" subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = []