Skip to content

Commit 74cb038

Browse files
[Infra] Remove DEFAULT_MODULES for harmony sdk publish
Use the `collect_module_config_list` method to fetch all modules to be released, replacing the original `DEFAULT_MODULES` logic. issue: #5312999715 AutoSubmit: true ExternalPullRequestID: 7048 ExternalGitURL: https://github.com/Kingatnuaa0528/lynx.git
1 parent d09b839 commit 74cb038

4 files changed

Lines changed: 50 additions & 36 deletions

File tree

explorer/harmony/script/build.py

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@
2323
'x86_64',
2424
]
2525

26-
DEFAULT_MODULES = [
27-
'lynx',
28-
'lynx_base',
29-
'lynx_devtool',
30-
'lynx_devtool_service',
31-
'lynx_log_service',
32-
'lynx_http_service',
33-
'lynx_image_service',
34-
]
35-
36-
3726
def add_node_home_env():
3827
if 'COMMANDLINE_TOOL_DIR' not in os.environ:
3928
print('COMMANDLINE_TOOL_DIR environment variable not found, ignore set NODE_HOME')
@@ -166,9 +155,29 @@ def collect_module_config_list(args):
166155
build_profile = json5.load(f)
167156

168157
module_config_list = build_profile['modules']
158+
publish_module_config_list = []
159+
for module_config in module_config_list:
160+
module_name = module_config.get('name')
161+
module_src_path = module_config.get('srcPath')
162+
if not module_name or not module_src_path:
163+
raise Exception(f'invalid module config: {module_config}')
164+
165+
module_json_path = os.path.join(
166+
HARMONY_DIR, module_src_path, 'src', 'main', 'module.json5')
167+
if not os.path.isfile(module_json_path):
168+
raise Exception(f'module.json5 not found: {module_json_path}')
169+
170+
with open(module_json_path, 'r') as f:
171+
module_json = json5.load(f)
172+
173+
module_info = module_json.get('module', {})
174+
module_type = module_info.get('type')
175+
if isinstance(module_type, str) and module_type.lower() == 'har':
176+
publish_module_config_list.append(module_config)
177+
169178
if args.verbose:
170-
print('module_config_list is' + str(module_config_list))
171-
return module_config_list
179+
print('module_config_list is' + str(publish_module_config_list))
180+
return publish_module_config_list
172181

173182

174183
def run_package_hap(args):
@@ -206,16 +215,6 @@ def main(argv):
206215
print(f'start build with args {args}')
207216
print(f'env info: {env_info}')
208217

209-
if args.modules:
210-
if len(args.modules) == 1 and args.modules[0].lower() == "default":
211-
if args.verbose:
212-
print("Using default module list as '--modules default' was specified.")
213-
modules = DEFAULT_MODULES
214-
else:
215-
modules = args.modules
216-
else:
217-
modules = []
218-
219218
if args.build_lynx_core:
220219
run_build_lynx_core(args.verbose, args.override_version if args.override_version else '0.0.1')
221220
run_copy_devtool_resources(args.verbose)
@@ -228,6 +227,20 @@ def main(argv):
228227
run_build_so(gn_out_dir, args)
229228
run_cp_so(gn_out_dir, args, abi)
230229

230+
if args.build_har:
231+
module_config_list = collect_module_config_list(args)
232+
default_modules = [module_config['name'] for module_config in module_config_list]
233+
234+
if args.modules:
235+
if len(args.modules) == 1 and args.modules[0].lower() == "default":
236+
if args.verbose:
237+
print("Using publishable module list as '--modules default' was specified.")
238+
modules = default_modules
239+
else:
240+
modules = args.modules
241+
else:
242+
modules = default_modules
243+
231244
if args.build_har and len(modules) > 0:
232245
commit_hash = os.popen('git rev-parse HEAD').read().strip()
233246
print('commit hash is ' + commit_hash)
@@ -248,14 +261,13 @@ def main(argv):
248261

249262
module_paths = {}
250263
for module in modules:
251-
module_config_list = collect_module_config_list(args)
252264
for module_config in module_config_list:
253265
if module_config['name'] == module:
254266
module_path = module_config['srcPath']
255267
module_paths[module] = module_path
256268
break
257269
else:
258-
raise Exception(f'module {module} not found in build-profile.json5')
270+
raise Exception(f'module {module} not found in build-profile.json5 or not type har')
259271
module_full_path = os.path.join(HARMONY_DIR, module_path)
260272
patch_lynx_version(publish_version, commit_hash, module_full_path)
261273
run_package_har(module, module_full_path, args.verbose)

explorer/harmony/script/generate_changelog.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import sys
1010
from subprocess import check_call
1111

12-
from build import DEFAULT_MODULES, LYNX_DIR, collect_module_config_list
12+
from build import LYNX_DIR, collect_module_config_list
1313

1414
PLATFORM_HARMONY_DIR = os.path.normpath(os.path.join(LYNX_DIR, 'platform', 'harmony'))
1515

@@ -31,22 +31,23 @@ def main():
3131
args = parser.parse_args()
3232

3333
print(f'args.modules: {args.modules}')
34+
module_config_list = collect_module_config_list(args)
35+
default_modules = [module_config['name'] for module_config in module_config_list]
3436
if args.modules:
3537
if len(args.modules) == 1 and args.modules[0].lower() == "default":
36-
modules = DEFAULT_MODULES
38+
modules = default_modules
3739
else:
3840
modules = args.modules
3941
else:
40-
modules = []
42+
modules = default_modules
4143

4244
for module in modules:
43-
module_config_list = collect_module_config_list(args)
4445
for module_config in module_config_list:
4546
if module_config['name'] == module:
4647
module_path = module_config['srcPath']
4748
break
4849
else:
49-
raise Exception(f'module {module} not found in build-profile.json5')
50+
raise Exception(f'module {module} not found in build-profile.json5 or not type har')
5051
print(f'module {module} path: {module_path}')
5152
module_full_path = os.path.join(PLATFORM_HARMONY_DIR, module_path)
5253
generate_changelog(module_full_path, args.version, args.base_commit)

explorer/harmony/script/publish.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import sys
1010
from subprocess import check_call
1111

12-
from build import DEFAULT_MODULES, LYNX_DIR, collect_module_config_list
12+
from build import LYNX_DIR, collect_module_config_list
1313

1414
PLATFORM_HARMONY_DIR = os.path.normpath(os.path.join(LYNX_DIR, 'platform', 'harmony'))
1515

@@ -34,22 +34,23 @@ def main():
3434

3535
args = parser.parse_args()
3636

37+
module_config_list = collect_module_config_list(args)
38+
default_modules = [module_config['name'] for module_config in module_config_list]
3739
if args.modules:
3840
if len(args.modules) == 1 and args.modules[0].lower() == "default":
39-
modules = DEFAULT_MODULES
41+
modules = default_modules
4042
else:
4143
modules = args.modules
4244
else:
43-
modules = []
45+
modules = default_modules
4446

4547
for module in modules:
46-
module_config_list = collect_module_config_list(args)
4748
for module_config in module_config_list:
4849
if module_config['name'] == module:
4950
module_path = module_config['srcPath']
5051
break
5152
else:
52-
raise Exception(f'module {module} not found in build-profile.json5')
53+
raise Exception(f'module {module} not found in build-profile.json5 or not type har')
5354
print(f'module {module} path: {module_path}')
5455
module_full_path = os.path.join(PLATFORM_HARMONY_DIR, module_path)
5556
publish(module_full_path, module)

platform/harmony/lynx_xelement/svg/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Lynx XElement SVG provide `<svg>` on harmony.
1010
## Installation
1111

1212
```bash
13-
ohpm install @lynx/xelement-svg
13+
ohpm install @lynx/xelement_svg
1414
```
1515

1616
## How to use

0 commit comments

Comments
 (0)