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-
3726def 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
174183def 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 )
0 commit comments