@@ -591,9 +591,6 @@ def self.register_plugin(klass)
591591 # Changes the typekit base directory
592592 def base_dir = ( path )
593593 @base_dir = path
594- if path
595- include_dirs << path
596- end
597594 end
598595
599596 INCLUDE_DIR_NAME = 'types'
@@ -803,7 +800,7 @@ def find_type(type, is_normalized = false)
803800 end
804801
805802 rescue Typelib ::NotFound => e
806- if ! pending_loads . empty ?
803+ if has_pending_loads ?
807804 perform_pending_loads
808805 retry
809806 end
@@ -1135,7 +1132,7 @@ def handle_local_load(file, relative_path_from: base_dir)
11351132 if elements . first != self . name
11361133 elements . unshift self . name
11371134 end
1138- link = File . join ( self . name , INCLUDE_DIR_NAME , *elements )
1135+ link = File . join ( *elements )
11391136 @local_loads_symlinks << [ file , link ]
11401137 link
11411138 end
@@ -1181,15 +1178,18 @@ def load(file, add = true, relative_path_from: base_dir, **user_options)
11811178 if File . file? ( file ) # Local file
11821179 file = File . expand_path ( file )
11831180 include_statement = handle_local_load ( file , relative_path_from : relative_path_from )
1181+ # Local loads are inserted in a normalized install path at
1182+ # loading and build time. They have no full path until then
1183+ full_path = nil
11841184 else # File from used libraries/task libraries
11851185 dir = include_dirs . find { |dir | File . file? ( File . join ( dir , file ) ) }
11861186 if !dir
11871187 raise LoadError , "cannot find #{ file } in #{ include_dirs . to_a . join ( ":" ) } "
11881188 end
11891189 loaded_files_dirs << dir
1190- file = File . join ( dir , file )
1190+ full_path = File . join ( dir , file )
11911191 include_path = include_dirs . map { |d | Pathname . new ( d ) }
1192- include_statement = resolve_full_include_path_to_relative ( file , include_path )
1192+ include_statement = resolve_full_include_path_to_relative ( full_path , include_path )
11931193 end
11941194
11951195 included_files << include_statement
@@ -1203,7 +1203,7 @@ def load(file, add = true, relative_path_from: base_dir, **user_options)
12031203 end
12041204
12051205 @pending_load_options = this_options
1206- pending_loads << file
1206+ pending_loads << [ full_path , include_statement ]
12071207 end
12081208
12091209 def filter_unsupported_types ( registry )
@@ -1430,9 +1430,9 @@ def resolve_toplevel_include_mapping(toplevel_files, options)
14301430 return preprocessed , owners
14311431 end
14321432
1433- def make_load_options ( pending_loads , user_options )
1433+ def make_load_options ( required_files , user_options )
14341434 user_options = user_options . dup
1435- options = { : opaques_ignore => true , : merge => false , : required_files => pending_loads . to_a }
1435+ options = { opaques_ignore : true , merge : false , required_files : required_files }
14361436 # GCCXML can't parse vectorized code, and the Typelib internal
14371437 # parser can't parse eigen at all. It is therefore safe to do it
14381438 # here
@@ -1475,30 +1475,32 @@ def has_pending_loads?
14751475 end
14761476
14771477 def perform_pending_loads
1478- return if pending_loads . empty?
1479- loads = pending_loads . dup
1480- pending_loads . clear
1478+ return if !has_pending_loads?
14811479
14821480 fake_include_dir = Dir . mktmpdir
14831481 @local_loads_symlinks . each do |target , link |
14841482 FileUtils . mkdir_p File . join ( fake_include_dir , File . dirname ( link ) )
14851483 FileUtils . cp target , File . join ( fake_include_dir , link )
14861484 end
14871485
1486+ pending_loads_to_relative = Hash . new
1487+ loads = pending_loads . map do |full_path , include_statement |
1488+ full_path ||= File . join ( fake_include_dir , include_statement )
1489+ pending_loads_to_relative [ full_path ] = include_statement
1490+ full_path
1491+ end
1492+ pending_loads . clear
1493+
14881494 add , user_options = *pending_load_options
14891495
14901496 file_registry = Typelib ::Registry . new
14911497 file_registry . merge opaque_registry
14921498
14931499 preprocess_options , options = make_load_options ( loads , user_options )
1500+ options [ :include ] << fake_include_dir
14941501 preprocessed , include_mappings = resolve_toplevel_include_mapping ( loads , preprocess_options )
14951502
14961503 include_paths = options [ :include ] . map { |p | Pathname . new ( p ) }
1497- pending_loads_to_relative = loads . inject ( Hash . new ) do |map , path |
1498- map [ path ] = resolve_full_include_path_to_relative ( path , include_paths )
1499- map
1500- end
1501-
15021504 include_mappings . each do |file , lines |
15031505 lines . map! { |inc | pending_loads_to_relative [ inc ] }
15041506 end
0 commit comments