@@ -591,9 +591,6 @@ def self.register_plugin(klass)
591
591
# Changes the typekit base directory
592
592
def base_dir = ( path )
593
593
@base_dir = path
594
- if path
595
- include_dirs << path
596
- end
597
594
end
598
595
599
596
INCLUDE_DIR_NAME = 'types'
@@ -803,7 +800,7 @@ def find_type(type, is_normalized = false)
803
800
end
804
801
805
802
rescue Typelib ::NotFound => e
806
- if ! pending_loads . empty ?
803
+ if has_pending_loads ?
807
804
perform_pending_loads
808
805
retry
809
806
end
@@ -1135,7 +1132,7 @@ def handle_local_load(file, relative_path_from: base_dir)
1135
1132
if elements . first != self . name
1136
1133
elements . unshift self . name
1137
1134
end
1138
- link = File . join ( self . name , INCLUDE_DIR_NAME , *elements )
1135
+ link = File . join ( *elements )
1139
1136
@local_loads_symlinks << [ file , link ]
1140
1137
link
1141
1138
end
@@ -1181,15 +1178,18 @@ def load(file, add = true, relative_path_from: base_dir, **user_options)
1181
1178
if File . file? ( file ) # Local file
1182
1179
file = File . expand_path ( file )
1183
1180
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
1184
1184
else # File from used libraries/task libraries
1185
1185
dir = include_dirs . find { |dir | File . file? ( File . join ( dir , file ) ) }
1186
1186
if !dir
1187
1187
raise LoadError , "cannot find #{ file } in #{ include_dirs . to_a . join ( ":" ) } "
1188
1188
end
1189
1189
loaded_files_dirs << dir
1190
- file = File . join ( dir , file )
1190
+ full_path = File . join ( dir , file )
1191
1191
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 )
1193
1193
end
1194
1194
1195
1195
included_files << include_statement
@@ -1203,7 +1203,7 @@ def load(file, add = true, relative_path_from: base_dir, **user_options)
1203
1203
end
1204
1204
1205
1205
@pending_load_options = this_options
1206
- pending_loads << file
1206
+ pending_loads << [ full_path , include_statement ]
1207
1207
end
1208
1208
1209
1209
def filter_unsupported_types ( registry )
@@ -1430,9 +1430,9 @@ def resolve_toplevel_include_mapping(toplevel_files, options)
1430
1430
return preprocessed , owners
1431
1431
end
1432
1432
1433
- def make_load_options ( pending_loads , user_options )
1433
+ def make_load_options ( required_files , user_options )
1434
1434
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 }
1436
1436
# GCCXML can't parse vectorized code, and the Typelib internal
1437
1437
# parser can't parse eigen at all. It is therefore safe to do it
1438
1438
# here
@@ -1475,30 +1475,32 @@ def has_pending_loads?
1475
1475
end
1476
1476
1477
1477
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?
1481
1479
1482
1480
fake_include_dir = Dir . mktmpdir
1483
1481
@local_loads_symlinks . each do |target , link |
1484
1482
FileUtils . mkdir_p File . join ( fake_include_dir , File . dirname ( link ) )
1485
1483
FileUtils . cp target , File . join ( fake_include_dir , link )
1486
1484
end
1487
1485
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
+
1488
1494
add , user_options = *pending_load_options
1489
1495
1490
1496
file_registry = Typelib ::Registry . new
1491
1497
file_registry . merge opaque_registry
1492
1498
1493
1499
preprocess_options , options = make_load_options ( loads , user_options )
1500
+ options [ :include ] << fake_include_dir
1494
1501
preprocessed , include_mappings = resolve_toplevel_include_mapping ( loads , preprocess_options )
1495
1502
1496
1503
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
-
1502
1504
include_mappings . each do |file , lines |
1503
1505
lines . map! { |inc | pending_loads_to_relative [ inc ] }
1504
1506
end
0 commit comments