126 |
# Remove extraneous warnings we don't care about |
# Remove extraneous warnings we don't care about |
127 |
# |
# |
128 |
proc prune_warnings { text } { |
proc prune_warnings { text } { |
129 |
global host_triplet; |
global host_triplet |
130 |
|
|
131 |
# remove the \r part of "\r\n" so we don't break all the patterns |
# remove the \r part of "\r\n" so we don't break all the patterns |
132 |
# we want to match. |
# we want to match. |
290 |
# |
# |
291 |
|
|
292 |
proc target_compile {source destfile type options} { |
proc target_compile {source destfile type options} { |
293 |
set target [target_info name]; |
set target [target_info name] |
294 |
if { [info proc ${target}_compile] != "" } { |
if { [info proc ${target}_compile] != "" } { |
295 |
return [${target}_compile $source $destfile $type $options]; |
return [${target}_compile $source $destfile $type $options] |
296 |
} else { |
} else { |
297 |
return [default_target_compile $source $destfile $type $options]; |
return [default_target_compile $source $destfile $type $options] |
298 |
} |
} |
299 |
} |
} |
300 |
|
|
320 |
} |
} |
321 |
|
|
322 |
if [info exists target_info(host,name)] { |
if [info exists target_info(host,name)] { |
323 |
set host [host_info name]; |
set host [host_info name] |
324 |
} else { |
} else { |
325 |
set host "unix"; |
set host "unix" |
326 |
} |
} |
327 |
|
|
328 |
foreach i $options { |
foreach i $options { |
331 |
if [board_info $dest exists cxxflags] { |
if [board_info $dest exists cxxflags] { |
332 |
append add_flags " [target_info cxxflags]" |
append add_flags " [target_info cxxflags]" |
333 |
} |
} |
334 |
append add_flags " [g++_include_flags]"; |
append add_flags " [g++_include_flags]" |
335 |
if [board_info $dest exists c++compiler] { |
if [board_info $dest exists c++compiler] { |
336 |
set compiler [target_info c++compiler]; |
set compiler [target_info c++compiler] |
337 |
} else { |
} else { |
338 |
set compiler [find_g++]; |
set compiler [find_g++] |
339 |
} |
} |
340 |
} |
} |
341 |
|
|
355 |
if [regexp "^dest=" $i] { |
if [regexp "^dest=" $i] { |
356 |
regsub "^dest=" $i "" tmp |
regsub "^dest=" $i "" tmp |
357 |
if [board_info $tmp exists name] { |
if [board_info $tmp exists name] { |
358 |
set dest [board_info $tmp name]; |
set dest [board_info $tmp name] |
359 |
} else { |
} else { |
360 |
set dest $tmp; |
set dest $tmp |
361 |
} |
} |
362 |
} |
} |
363 |
if [regexp "^compiler=" $i] { |
if [regexp "^compiler=" $i] { |
399 |
} |
} |
400 |
|
|
401 |
if [board_info $host exists cflags_for_target] { |
if [board_info $host exists cflags_for_target] { |
402 |
append add_flags " [board_info $host cflags_for_target]"; |
append add_flags " [board_info $host cflags_for_target]" |
403 |
} |
} |
404 |
|
|
405 |
global CC_FOR_TARGET |
global CC_FOR_TARGET |
425 |
} |
} |
426 |
|
|
427 |
if { $compiler == "" } { |
if { $compiler == "" } { |
428 |
set compiler [board_info $dest compiler]; |
set compiler [board_info $dest compiler] |
429 |
if { $compiler == "" } { |
if { $compiler == "" } { |
430 |
return "default_target_compile: No compiler to compile with"; |
return "default_target_compile: No compiler to compile with" |
431 |
} |
} |
432 |
} |
} |
433 |
|
|
463 |
append add_flags " [board_info $dest ldflags]" |
append add_flags " [board_info $dest ldflags]" |
464 |
} |
} |
465 |
if { $compiler_type == "c++" } { |
if { $compiler_type == "c++" } { |
466 |
append add_flags " [g++_link_flags]"; |
append add_flags " [g++_link_flags]" |
467 |
} |
} |
468 |
if [isnative] { |
if [isnative] { |
469 |
# This is a lose. |
# This is a lose. |
490 |
foreach i $options { |
foreach i $options { |
491 |
if { $i == "debug" } { |
if { $i == "debug" } { |
492 |
if [board_info $dest exists debug_flags] { |
if [board_info $dest exists debug_flags] { |
493 |
append add_flags " [board_info $dest debug_flags]"; |
append add_flags " [board_info $dest debug_flags]" |
494 |
} else { |
} else { |
495 |
append add_flags " -g" |
append add_flags " -g" |
496 |
} |
} |
498 |
} |
} |
499 |
|
|
500 |
if [info exists optimize] { |
if [info exists optimize] { |
501 |
append add_flags " $optimize"; |
append add_flags " $optimize" |
502 |
} |
} |
503 |
|
|
504 |
if { $type == "executable" } { |
if { $type == "executable" } { |
507 |
if [file exists $x] { |
if [file exists $x] { |
508 |
append source " $x" |
append source " $x" |
509 |
} else { |
} else { |
510 |
append add_flags " $x"; |
append add_flags " $x" |
511 |
} |
} |
512 |
} |
} |
513 |
|
|
527 |
} |
} |
528 |
|
|
529 |
# This must be added here. |
# This must be added here. |
530 |
append add_flags " $ldscript"; |
append add_flags " $ldscript" |
531 |
|
|
532 |
if [board_info $dest exists remote_link] { |
if [board_info $dest exists remote_link] { |
533 |
# Relink option. |
# Relink option. |
534 |
append add_flags " -Wl,-r" |
append add_flags " -Wl,-r" |
535 |
} |
} |
536 |
if [board_info $dest exists output_format] { |
if [board_info $dest exists output_format] { |
537 |
append add_flags " -Wl,-oformat,[board_info $dest output_format]"; |
append add_flags " -Wl,-oformat,[board_info $dest output_format]" |
538 |
} |
} |
539 |
} |
} |
540 |
|
|
541 |
if [board_info $dest exists multilib_flags] { |
if [board_info $dest exists multilib_flags] { |
542 |
append add_flags " [board_info $dest multilib_flags]"; |
append add_flags " [board_info $dest multilib_flags]" |
543 |
} |
} |
544 |
|
|
545 |
verbose "doing compile" |
verbose "doing compile" |
547 |
set sources "" |
set sources "" |
548 |
if [is_remote host] { |
if [is_remote host] { |
549 |
foreach x $source { |
foreach x $source { |
550 |
set file [remote_download host $x]; |
set file [remote_download host $x] |
551 |
if { $file == "" } { |
if { $file == "" } { |
552 |
warning "Unable to download $x to host." |
warning "Unable to download $x to host." |
553 |
return "Unable to download $x to host." |
return "Unable to download $x to host." |
554 |
} else { |
} else { |
555 |
append sources " $file"; |
append sources " $file" |
556 |
} |
} |
557 |
} |
} |
558 |
} else { |
} else { |
561 |
|
|
562 |
if [is_remote host] { |
if [is_remote host] { |
563 |
append add_flags " -o a.out" |
append add_flags " -o a.out" |
564 |
remote_file host delete a.out; |
remote_file host delete a.out |
565 |
} else { |
} else { |
566 |
if { $destfile != "" } { |
if { $destfile != "" } { |
567 |
append add_flags " -o $destfile"; |
append add_flags " -o $destfile" |
568 |
} |
} |
569 |
} |
} |
570 |
|
|
579 |
|
|
580 |
if [is_remote host] { |
if [is_remote host] { |
581 |
if [host_info exists use_at] { |
if [host_info exists use_at] { |
582 |
set fid [open "atfile" "w"]; |
set fid [open "atfile" "w"] |
583 |
puts $fid "$opts"; |
puts $fid "$opts" |
584 |
close $fid; |
close $fid |
585 |
set opts "@[remote_download host atfile]" |
set opts "@[remote_download host atfile]" |
586 |
remote_file build delete atfile |
remote_file build delete atfile |
587 |
} |
} |
591 |
|
|
592 |
if [info exists redirect] { |
if [info exists redirect] { |
593 |
verbose "Redirecting output to $redirect" 2 |
verbose "Redirecting output to $redirect" 2 |
594 |
set status [remote_exec host "$compiler $opts" "" "" $redirect]; |
set status [remote_exec host "$compiler $opts" "" "" $redirect] |
595 |
} else { |
} else { |
596 |
if [info exists timeout] { |
if [info exists timeout] { |
597 |
verbose "Setting timeout to $timeout" 2 |
verbose "Setting timeout to $timeout" 2 |
598 |
set status [remote_exec host "$compiler $opts" "" "" "" $timeout]; |
set status [remote_exec host "$compiler $opts" "" "" "" $timeout] |
599 |
} else { |
} else { |
600 |
set status [remote_exec host "$compiler $opts"]; |
set status [remote_exec host "$compiler $opts"] |
601 |
} |
} |
602 |
} |
} |
603 |
|
|
604 |
set compiler_flags $opts |
set compiler_flags $opts |
605 |
if [is_remote host] { |
if [is_remote host] { |
606 |
remote_upload host a.out $destfile; |
remote_upload host a.out $destfile |
607 |
remote_file host delete a.out; |
remote_file host delete a.out |
608 |
} |
} |
609 |
set comp_output [prune_warnings [lindex $status 1]]; |
set comp_output [prune_warnings [lindex $status 1]] |
610 |
regsub "^\[\r\n\]+" $comp_output "" comp_output; |
regsub "^\[\r\n\]+" $comp_output "" comp_output |
611 |
if { [lindex $status 0] != 0 } { |
if { [lindex $status 0] != 0 } { |
612 |
verbose -log "compiler exited with status [lindex $status 0]"; |
verbose -log "compiler exited with status [lindex $status 0]" |
613 |
} |
} |
614 |
if { [lindex $status 1] != "" } { |
if { [lindex $status 1] != "" } { |
615 |
verbose -log "output is:\n[lindex $status 1]" 2; |
verbose -log "output is:\n[lindex $status 1]" 2 |
616 |
} |
} |
617 |
if { [lindex $status 0] != 0 && "${comp_output}" == "" } { |
if { [lindex $status 0] != 0 && "${comp_output}" == "" } { |
618 |
set comp_output "exit status is [lindex $status 0]"; |
set comp_output "exit status is [lindex $status 0]" |
619 |
} |
} |
620 |
return ${comp_output}; |
return ${comp_output} |
621 |
} |
} |
622 |
|
|
623 |
proc reboot_target { } { |
proc reboot_target { } { |
624 |
set result [remote_reboot target] |
set result [remote_reboot target] |
625 |
puts "REBOOT_TARGET: \"$result\"" |
puts "REBOOT_TARGET: \"$result\"" |
626 |
return ${result}; |
return ${result} |
627 |
} |
} |
628 |
|
|
629 |
# |
# |
632 |
# assembler. |
# assembler. |
633 |
# |
# |
634 |
proc target_assemble { source destfile flags } { |
proc target_assemble { source destfile flags } { |
635 |
return [default_target_assemble $source $destfile $flags]; |
return [default_target_assemble $source $destfile $flags] |
636 |
} |
} |
637 |
|
|
638 |
proc default_target_assemble { source destfile flags } { |
proc default_target_assemble { source destfile flags } { |
640 |
global ASFLAGS_FOR_TARGET |
global ASFLAGS_FOR_TARGET |
641 |
|
|
642 |
if [info exists AS_FOR_TARGET] { |
if [info exists AS_FOR_TARGET] { |
643 |
set AS "$AS_FOR_TARGET"; |
set AS "$AS_FOR_TARGET" |
644 |
} else { |
} else { |
645 |
if ![board_info target exists assembler] { |
if ![board_info target exists assembler] { |
646 |
set AS [find_gas]; |
set AS [find_gas] |
647 |
} else { |
} else { |
648 |
set AS [board_info target assembler]; |
set AS [board_info target assembler] |
649 |
} |
} |
650 |
} |
} |
651 |
|
|
652 |
if [info exists ASFLAGS_FOR_TARGET] { |
if [info exists ASFLAGS_FOR_TARGET] { |
653 |
append flags " $ASFLAGS_FOR_TARGET"; |
append flags " $ASFLAGS_FOR_TARGET" |
654 |
} |
} |
655 |
|
|
656 |
if [is_remote host] { |
if [is_remote host] { |
657 |
set source [remote_download host $source]; |
set source [remote_download host $source] |
658 |
set dest "a.out" |
set dest "a.out" |
659 |
} else { |
} else { |
660 |
set dest $destfile |
set dest $destfile |
664 |
remote_upload host $dest $destfile |
remote_upload host $dest $destfile |
665 |
} |
} |
666 |
|
|
667 |
set comp_output [prune_warnings [lindex $status 1]]; |
set comp_output [prune_warnings [lindex $status 1]] |
668 |
if { [lindex $status 0] != 0 } { |
if { [lindex $status 0] != 0 } { |
669 |
verbose -log "assembler exited with status [lindex $status 0]"; |
verbose -log "assembler exited with status [lindex $status 0]" |
670 |
} |
} |
671 |
if { [lindex $status 1] != "" } { |
if { [lindex $status 1] != "" } { |
672 |
verbose -log "assembler output is:\n[lindex $status 1]" 2; |
verbose -log "assembler output is:\n[lindex $status 1]" 2 |
673 |
} |
} |
674 |
return ${comp_output}; |
return ${comp_output} |
675 |
} |
} |
676 |
|
|
677 |
# |
# |
680 |
# linker. |
# linker. |
681 |
# |
# |
682 |
proc target_link { objects destfile flags } { |
proc target_link { objects destfile flags } { |
683 |
return [default_link target "$objects" "$destfile" $flags]; |
return [default_link target "$objects" "$destfile" $flags] |
684 |
} |
} |
685 |
|
|
686 |
proc default_link { board objects destfile flags } { |
proc default_link { board objects destfile flags } { |
713 |
} |
} |
714 |
|
|
715 |
if [info exists LD_FOR_TARGET] { |
if [info exists LD_FOR_TARGET] { |
716 |
set LD "$LD_FOR_TARGET"; |
set LD "$LD_FOR_TARGET" |
717 |
} else { |
} else { |
718 |
if ![board_info target exists linker] { |
if ![board_info target exists linker] { |
719 |
set LD [find_ld]; |
set LD [find_ld] |
720 |
} else { |
} else { |
721 |
set LD [board_info target linker]; |
set LD [board_info target linker] |
722 |
} |
} |
723 |
} |
} |
724 |
|
|
725 |
if [info exists LDFLAGS_FOR_TARGET] { |
if [info exists LDFLAGS_FOR_TARGET] { |
726 |
append flags " $LDFLAGS_FOR_TARGET"; |
append flags " $LDFLAGS_FOR_TARGET" |
727 |
} |
} |
728 |
|
|
729 |
# `ldflags' consists of arguments to gcc (that are then |
# `ldflags' consists of arguments to gcc (that are then |
744 |
|
|
745 |
if [is_remote host] { |
if [is_remote host] { |
746 |
foreach x $objects { |
foreach x $objects { |
747 |
set nobjects "$nobjects [remote_download host $x]"; |
set nobjects "$nobjects [remote_download host $x]" |
748 |
} |
} |
749 |
set objects "$nobjects"; |
set objects "$nobjects" |
750 |
set dest "a.out"; |
set dest "a.out" |
751 |
} else { |
} else { |
752 |
set dest $destfile; |
set dest $destfile |
753 |
} |
} |
754 |
set status [remote_exec host "$LD $objects $flags -o $dest"] |
set status [remote_exec host "$LD $objects $flags -o $dest"] |
755 |
if [is_remote host] { |
if [is_remote host] { |
756 |
remote_upload host $dest $destfile; |
remote_upload host $dest $destfile |
757 |
} |
} |
758 |
|
|
759 |
set comp_output [prune_warnings [lindex $status 1]]; |
set comp_output [prune_warnings [lindex $status 1]] |
760 |
if { [lindex $status 0] != 0 } { |
if { [lindex $status 0] != 0 } { |
761 |
verbose -log "linker exited with status [lindex $status 0]"; |
verbose -log "linker exited with status [lindex $status 0]" |
762 |
} |
} |
763 |
if { [lindex $status 1] != "" } { |
if { [lindex $status 1] != "" } { |
764 |
verbose -log "linker output is:\n[lindex $status 1]" 2; |
verbose -log "linker output is:\n[lindex $status 1]" 2 |
765 |
} |
} |
766 |
return ${comp_output}; |
return ${comp_output} |
767 |
} |
} |