| 762 | # Helper function for set_compiler_dependencies. Used to force |
| 763 | # "depends_FOO" to act like "depends_FOO-append"; otherwise portfiles |
| 764 | # would overwrite the automatic compiler dependencies with their |
| 765 | # "depends_FOO" statements. |
| 766 | proc portconfigure::hijack_option {option} { |
| 767 | if {[exists $option]} { |
| 768 | return |
| 769 | } |
| 770 | interp alias {} $option {} handle_option-append $option |
| 771 | } |
| 772 | |
| 773 | # Automatically add the necessary dependency when setting the compiler. |
| 774 | proc portconfigure::set_compiler_dependencies {option action args} { |
| 775 | global option_defaults configure.compiler portconfigure::cc_should_eval \ |
| 776 | portconfigure::compiler_port portconfigure::compiler_name_map |
| 777 | |
| 778 | if {![info exists cc_should_eval]} { |
| 779 | set cc_should_eval yes |
| 780 | } |
| 781 | set cc_is_default [info exists option_defaults(configure.compiler)] |
| 782 | |
| 783 | switch $option { |
| 784 | configure.compiler { |
| 785 | if {$action eq "read" && !($cc_is_default && $cc_should_eval)} { |
| 786 | return |
| 787 | } |
| 788 | if {[info exists compiler_port]} { |
| 789 | depends_lib-delete port:$compiler_port |
| 790 | depends_build-delete port:$compiler_port |
| 791 | depends_skip_archcheck-delete port:$compiler_port |
| 792 | unset compiler_port |
| 793 | } |
| 794 | # The default value requires substitution before use. |
| 795 | set compiler [subst ${configure.compiler}] |
| 796 | if {![compiler_is_port $compiler]} { |
| 797 | return |
| 798 | } |
| 799 | set compiler_port $compiler_name_map($compiler) |
| 800 | if {[string match "macports-gcc-*" $compiler]} { |
| 801 | hijack_option depends_lib |
| 802 | depends_lib-append port:$compiler_port |
| 803 | } else { |
| 804 | hijack_option depends_build |
| 805 | depends_build-append port:$compiler_port |
| 806 | } |
| 807 | if {[arch_flag_supported $compiler]} { |
| 808 | hijack_option depends_skip_archcheck |
| 809 | depends_skip_archcheck-append $compiler_port |
| 810 | } |
| 811 | set cc_should_eval no |
| 812 | } |
| 813 | default { |
| 814 | if {$action eq "read" || !$cc_is_default} { |
| 815 | return |
| 816 | } |
| 817 | set cc_should_eval yes |
| 818 | # This is solely to trigger the variable trace. |
| 819 | expr {${configure.compiler}} |
| 820 | } |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | # Set traces on all values that might affect the compiler selection. |
| 825 | option_proc compiler.fallback portconfigure::set_compiler_dependencies |
| 826 | option_proc compiler.blacklist portconfigure::set_compiler_dependencies |
| 827 | option_proc compiler.whitelist portconfigure::set_compiler_dependencies |
| 828 | option_proc configure.compiler portconfigure::set_compiler_dependencies |
| 829 | |
| 830 | default configure.compiler {[portconfigure::configure_get_default_compiler]} |
| 831 | |
| 832 | |