• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16const fs = require('fs');
17const path = require('path');
18
19const currentDirectory = process.cwd();
20let workSpace = currentDirectory;
21for (let i = 0; i < 4; i++) {
22  workSpace = path.dirname(workSpace);
23}
24
25const jsonFilePath = path.join(__dirname, 'demo/localtest/build_decl_config_template.json');
26const outJsonFilePath = path.join(__dirname, 'demo/localtest/build_decl_config.json');
27
28try {
29  const data = fs.readFileSync(jsonFilePath, 'utf8');
30  const jsonData = JSON.parse(data);
31
32  if (jsonData.buildSdkPath) {
33      jsonData.buildSdkPath = jsonData.buildSdkPath.replace(/workspace/g, workSpace);
34  }
35
36  if (jsonData.plugins.interop_plugin) {
37    jsonData.plugins.interop_plugin = jsonData.plugins.interop_plugin.replace(/workspace/g, workSpace);
38  }
39
40  if (jsonData.declgenV1OutPath) {
41    jsonData.declgenV1OutPath = jsonData.declgenV1OutPath.replace(/workspace/g, workSpace);
42  }
43
44  if (jsonData.declgenBridgeCodePath) {
45    jsonData.declgenBridgeCodePath = jsonData.declgenBridgeCodePath.replace(/workspace/g, workSpace);
46  }
47
48  fs.writeFileSync(outJsonFilePath, JSON.stringify(jsonData, null, 2), 'utf8');
49} catch (error) {
50  console.error('writeFile error:', error);
51}
52