66require "rake/application"
77require "rubygems/requirement"
88require "tilt"
9- require "yaml"
109
1110require_relative "#{ $lib} /validate"
1211require_relative "#{ $lib} /arch_def"
@@ -53,7 +52,7 @@ def gen_params_schema
5352 @implemented_extensions . each do |ext |
5453 ext_name = ext [ "name" ]
5554 gen_ext_path = @gen_dir / "arch" / "ext" / "#{ ext_name } .yaml"
56- ext_yaml = YAML . safe_load gen_ext_path . read
55+ ext_yaml = YamlLoader . load gen_ext_path . to_s
5756 unless ext_yaml [ ext_name ] [ "params" ] . nil?
5857 ext_yaml [ ext_name ] [ "params" ] . each do |param_name , param_data |
5958 schema [ "properties" ] [ "params" ] [ "required" ] << param_name
@@ -92,7 +91,7 @@ def initialize(config_name)
9291 raise "Validation failed" if @cfg_impl_ext . nil?
9392
9493 cfg_opts_path = @cfg_dir / "cfg.yaml"
95- @cfg_opts = YAML . load_file ( cfg_opts_path )
94+ @cfg_opts = YamlLoader . load ( cfg_opts_path )
9695 raise "Validation failed" if @cfg_opts . nil?
9796 raise "Validation failed: bad type" unless [ "partially configured" , "fully configured" ] . include? ( @cfg_opts [ "type" ] )
9897
@@ -147,7 +146,7 @@ def params_extra_validation
147146 @implemented_extensions . each do |ext |
148147 ext_name = ext [ "name" ]
149148 gen_ext_path = @gen_dir / "arch" / "ext" / "#{ ext_name } .yaml"
150- ext_yaml = YAML . safe_load gen_ext_path . read
149+ ext_yaml = YamlLoader . load gen_ext_path . read
151150 unless ext_yaml [ ext_name ] [ "params" ] . nil?
152151 ext_yaml [ ext_name ] [ "params" ] . each do |param_name , param_data |
153152 next unless param_data . key? ( "extra_validation" )
@@ -275,63 +274,63 @@ def implemented_extensions
275274 #
276275 def gen_arch_def
277276 csr_hash = Dir . glob ( @gen_dir / "arch" / "csr" / "**" / "*.yaml" ) . map do |f |
278- csr_obj = YAML . load_file ( f )
277+ csr_obj = YamlLoader . load ( f )
279278 csr_name = csr_obj . keys [ 0 ]
280279 [ csr_name , csr_obj [ csr_name ] ]
281280 end . to_h
282281 inst_hash = Dir . glob ( @gen_dir / "arch" / "inst" / "**" / "*.yaml" ) . map do |f |
283- inst_obj = YAML . load_file ( f )
282+ inst_obj = YamlLoader . load ( f )
284283 inst_name = inst_obj . keys [ 0 ]
285284 [ inst_name , inst_obj [ inst_name ] ]
286285 end . to_h
287286 ext_hash = Dir . glob ( @gen_dir / "arch" / "ext" / "**" / "*.yaml" ) . map do |f |
288- ext_obj = YAML . load_file ( f )
287+ ext_obj = YamlLoader . load ( f )
289288 ext_name = ext_obj . keys [ 0 ]
290289 [ ext_name , ext_obj [ ext_name ] ]
291290 end . to_h
292291 profile_family_hash = Dir . glob ( $root / "arch" / "profile_family" / "**" / "*.yaml" ) . map do |f |
293- profile_obj = YAML . load_file ( f )
292+ profile_obj = YamlLoader . load ( f )
294293 profile_name = profile_obj . keys [ 0 ]
295294 profile_obj [ profile_name ] [ "name" ] = profile_name
296295 profile_obj [ profile_name ] [ "__source" ] = f
297296 [ profile_name , profile_obj [ profile_name ] ]
298297 end . to_h
299298 profile_hash = Dir . glob ( $root / "arch" / "profile" / "**" / "*.yaml" ) . map do |f |
300- profile_obj = YAML . load_file ( f )
299+ profile_obj = YamlLoader . load ( f )
301300 profile_name = profile_obj . keys [ 0 ]
302301 profile_obj [ profile_name ] [ "name" ] = profile_name
303302 profile_obj [ profile_name ] [ "__source" ] = f
304303 [ profile_name , profile_obj [ profile_name ] ]
305304 end . to_h
306305 manual_hash = { }
307306 Dir . glob ( $root / "arch" / "manual" / "**" / "contents.yaml" ) . map do |f |
308- manual_version = YAML . load_file ( f )
307+ manual_version = YamlLoader . load ( f )
309308 manual_id = manual_version [ "manual" ]
310309 unless manual_hash . key? ( manual_id )
311310 manual_info_files = Dir . glob ( $root / "arch" / "manual" / "**" / "#{ manual_id } .yaml" )
312311 raise "Could not find manual info '#{ manual_id } '.yaml, needed by #{ f } " if manual_info_files . empty?
313312 raise "Found multiple manual infos '#{ manual_id } '.yaml, needed by #{ f } " if manual_info_files . size > 1
314313
315314 manual_info_file = manual_info_files . first
316- manual_hash [ manual_id ] = YAML . load_file ( manual_info_file )
315+ manual_hash [ manual_id ] = YamlLoader . load ( manual_info_file )
317316 manual_hash [ manual_id ] [ "__source" ] = manual_info_file
318317 # TODO: schema validation
319318 end
320319
321320 manual_hash [ manual_id ] [ "versions" ] ||= [ ]
322- manual_hash [ manual_id ] [ "versions" ] << YAML . load_file ( f )
321+ manual_hash [ manual_id ] [ "versions" ] << YamlLoader . load ( f )
323322 # TODO: schema validation
324323 manual_hash [ manual_id ] [ "versions" ] . last [ "__source" ] = f
325324 end
326325 crd_family_hash = Dir . glob ( $root / "arch" / "crd_family" / "**" / "*.yaml" ) . map do |f |
327- family_obj = YAML . load_file ( f , permitted_classes : [ Date ] )
326+ family_obj = YamlLoader . load ( f , permitted_classes : [ Date ] )
328327 family_name = family_obj . keys [ 0 ]
329328 family_obj [ family_name ] [ "name" ] = family_name
330329 family_obj [ family_name ] [ "__source" ] = f
331330 [ family_name , family_obj [ family_name ] ]
332331 end . to_h
333332 crd_hash = Dir . glob ( $root / "arch" / "crd" / "**" / "*.yaml" ) . map do |f |
334- crd_obj = YAML . load_file ( f , permitted_classes : [ Date ] )
333+ crd_obj = YamlLoader . load ( f , permitted_classes : [ Date ] )
335334 crd_name = crd_obj . keys [ 0 ]
336335 crd_obj [ crd_name ] [ "name" ] = crd_name
337336 crd_obj [ crd_name ] [ "__source" ] = f
@@ -590,7 +589,7 @@ def gen_rendered_arch_def(type, name, extra_env = {})
590589 raise e
591590 end
592591
593- def_obj = YAML . safe_load ( rendered_def )
592+ def_obj = YamlLoader . load ( rendered_def )
594593
595594 raise "#{ type } name ('#{ name } ') must match key in defintion ('#{ def_obj . keys [ 0 ] } ')" if name . to_s != def_obj . keys [ 0 ]
596595
@@ -626,7 +625,7 @@ def gen_rendered_arch_overlay_def(type, name, extra_env = {})
626625 extra_env &.each { |k , v | current_env . define_singleton_method ( k ) { v } }
627626 rendered_def = Tilt [ "erb" ] . new ( source_path , trim : "-" ) . render ( current_env )
628627
629- def_obj = YAML . safe_load ( rendered_def )
628+ def_obj = YamlLoader . load ( rendered_def )
630629
631630 raise "#{ type } name (#{ name } ) must match key in defintion (#{ def_obj . keys [ 0 ] } )" if name . to_s != def_obj . keys [ 0 ]
632631
@@ -672,8 +671,8 @@ def gen_merged_def(type, arch_path, overlay_path)
672671 FileUtils . cp overlay_path , merged_path
673672 else
674673 # arch and overlay, do the merge
675- arch_obj = YAML . load_file ( arch_path )
676- overlay_obj = YAML . load_file ( overlay_path )
674+ arch_obj = YamlLoader . load ( arch_path )
675+ overlay_obj = YamlLoader . load ( overlay_path )
677676
678677 merge ( arch_obj , overlay_obj )
679678 merged_path . write YAML . dump ( arch_obj )
@@ -722,7 +721,7 @@ def maybe_add_csr(csr_name, extra_env = {})
722721 end
723722
724723 # get the csr data (not including the name key), which is redundant at this point
725- csr_data = YAML . load_file ( merged_path ) [ csr_name ]
724+ csr_data = YamlLoader . load ( merged_path ) [ csr_name ]
726725 csr_data [ "name" ] = csr_name
727726 csr_data [ "fields" ] . each { |n , f | f [ "name" ] = n }
728727 csr_data [ "__source" ] = og_path . to_s
@@ -805,7 +804,7 @@ def maybe_add_ext(ext_name)
805804
806805 merged_path = gen_merged_def ( :ext , arch_path , arch_overlay_path )
807806
808- yaml_contents = YAML . load_file ( merged_path )
807+ yaml_contents = YamlLoader . load ( merged_path )
809808 raise "In #{ merged_path } , key does not match file name" unless yaml_contents . key? ( ext_name )
810809
811810 ext_obj = yaml_contents [ ext_name ]
@@ -884,7 +883,7 @@ def exception_codes
884883
885884 @exception_codes = { }
886885 Dir . glob ( @gen_dir / "arch" / "ext" / "*.yaml" ) do |ext_path |
887- ext_obj = YAML . load_file ( ext_path )
886+ ext_obj = YamlLoader . load ( ext_path )
888887 ext_obj = ext_obj [ ext_obj . keys [ 0 ] ]
889888 if ext_obj . key? ( "exception_codes" )
890889 ext_obj [ "exception_codes" ] . each do |exception_code |
@@ -905,7 +904,7 @@ def interrupt_codes
905904
906905 @interrupt_codes = { }
907906 Dir . glob ( @gen_dir / "arch" / "ext" / "*.yaml" ) do |ext_path |
908- ext_obj = YAML . load_file ( ext_path )
907+ ext_obj = YamlLoader . load ( ext_path )
909908 ext_obj = ext_obj [ ext_obj . keys [ 0 ] ]
910909 if ext_obj . key? ( "interrupt_codes" )
911910 ext_obj [ "interrupt_codes" ] . each do |interrupt_code |
@@ -967,7 +966,7 @@ def maybe_add_inst(inst_name, extra_env = {})
967966 end
968967
969968 # get the inst data (not including the name key), which is redundant at this point
970- inst_data = YAML . load_file ( merged_path )
969+ inst_data = YamlLoader . load ( merged_path )
971970 raise "The first and only key of #{ arch_path } must be '#{ inst_name } " unless inst_data . key? ( inst_name )
972971 inst_data = inst_data [ inst_name ]
973972
0 commit comments