487 | | *.la - |
| 487 | *.la { |
| 488 | set known_file "yes" |
| 489 | set la1_channel [open ${dir1}/${fl}] |
| 490 | set la2_channel [open ${dir2}/${fl}] |
| 491 | set la1_data [read $la1_channel] |
| 492 | set la2_data [read $la2_channel] |
| 493 | close $la1_channel |
| 494 | close $la2_channel |
| 495 | set la1_lines [split $la1_data \n] |
| 496 | set la2_lines [split $la2_data \n] |
| 497 | if {[llength la1_lines] == [llength la2_lines]} { |
| 498 | set lam_channel [open ${dir}/${fl} w] |
| 499 | foreach la1_line $la1_lines la2_line $la2_lines { |
| 500 | if {$la1_line == $la2_line} { |
| 501 | puts $lam_channel $la1_line |
| 502 | } else { |
| 503 | if {[regexp -nocase {(.*?)='(.*)'} $la1_line la1_fmatch la1_key la1_value] && [regexp -nocase {(.*?)='(.*)'} $la2_line la1_fmatch la2_key la2_value] && ${la1_key} == ${la2_key}} { |
| 504 | if {${la1_key} == "dependency_libs"} { |
| 505 | set merged_value ${la1_value} |
| 506 | foreach value2 ${la2_value} { |
| 507 | if {[lsearch -exact ${merged_value} ${value2}] < 0} { |
| 508 | set merged_value "${merged_value} ${value2}" |
| 509 | } |
| 510 | } |
| 511 | puts $lam_channel "${la1_key}='${merged_value}'" |
| 512 | } else { |
| 513 | close ${lam_channel} |
| 514 | return -code error "${prefixDir}/${fl} differs in ${base1} and ${base2} and cannot be merged (cannot merge key ${la1_key})\nline1: ${la1_line}\nline2: ${la2_line}" |
| 515 | } |
| 516 | } else { |
| 517 | close ${lam_channel} |
| 518 | return -code error "${prefixDir}/${fl} differs in ${base1} and ${base2} and cannot be merged (mismatching keys)\nline1: ${la1_line}\nline2: ${la2_line}" |
| 519 | } |
| 520 | } |
| 521 | } |
| 522 | close ${lam_channel} |
| 523 | } else { |
| 524 | return -code error "${prefixDir}/${fl} differs in ${base1} and ${base2} and cannot be merged (different number of lines)" |
| 525 | } |
| 526 | } |