Ticket #56351: Portfile.diff

File Portfile.diff, 3.0 KB (added by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), 6 years ago)
  • Portfile

    diff -urb ./Portfile /Users/macports/MacPorts/mports/lang/rust/Portfile
    old new  
    22
    33PortSystem          1.0
    44PortGroup           muniversal 1.0
     5PortGroup           active_variants 1.1
    56
    67name                rust
    78version             1.25.0
     
    2425
    2526homepage            https://www.rust-lang.org/
    2627
     28set ruststd_version 1.24.0
     29set rustc_version   1.24.0
     30set cargo_version   0.25.0
     31set llvm_version    6.0
     32
    2733# can use cmake or cmake-devel; default to cmake.
    2834depends_build       path:bin/cmake:cmake \
    2935                    bin:python2.7:python27
    3036
    31 depends_lib         port:llvm-6.0
     37depends_lib         port:llvm-${llvm_version}
    3238
    3339master_sites        https://static.rust-lang.org/dist
    3440
     
    3642
    3743patchfiles          patch-src-librustc-llvm-lib.diff
    3844
    39 set ruststd_version 1.24.0
    40 set rustc_version   1.24.0
    41 set cargo_version   0.25.0
    42 
    4345if {![variant_isset universal]} {
    4446    if {${build_arch} eq "i386"} {
    4547        set architectures i686
     
    118120                    --default-linker=${configure.cc} \
    119121                    --disable-codegen-tests \
    120122                    --disable-docs \
    121                     --llvm-root=${prefix}/libexec/llvm-6.0 \
    122123                    --release-channel=stable
    123124
     125if {[variant_isset universal]} {
     126    # LLVM is or will need to be universal
     127    set copy_llvm 1
     128} else {
     129    if {![catch {set result [active_variants llvm-${llvm_version} "universal" ""]}] && $result} {
     130        # LLVM was installed with universal variant
     131        set copy_llvm 1
     132    } else {
     133        set copy_llvm 0
     134    }
     135}
     136
     137if {!${copy_llvm}} {
     138    # LLVM is NOT universal, so use installed version
     139    configure.args-append \
     140        --llvm-root=${prefix}/libexec/llvm-${llvm_version}
     141} else {
     142    # copy LLVM and thin static libraries
     143    # see https://trac.macports.org/ticket/56351
     144    # see https://github.com/rust-lang/rust/issues/50220
     145    if {[variant_isset universal]} {
     146        set archs ${universal_archs}
     147        foreach arch ${universal_archs} {
     148            lappend merger_configure_args(${arch}) \
     149                --llvm-root=${workpath}/llvm-${llvm_version}-${arch}
     150        }
     151    } else {
     152        set archs ${build_arch}
     153        configure.args-append \
     154            --llvm-root=${workpath}/llvm-${llvm_version}-${build_arch}
     155    }
     156
     157    post-extract {
     158        foreach arch ${archs} {
     159            system -W ${workpath} "cp -R ${prefix}/libexec/llvm-${llvm_version} ${workpath}/llvm-${llvm_version}-${arch}"
     160            fs-traverse f ${workpath}/llvm-${llvm_version}-${arch} {
     161                if {[file isfile $f] && [file type $f]!="link" && [file extension $f]==".a"} {
     162                    catch {system "lipo -thin ${arch} ${f} -o ${f}"}
     163                }
     164            }
     165        }
     166    }
     167}
     168
    124169if {![variant_isset universal]} {
    125170    if {${build_arch} eq "i386"} {
    126171        set arch_name i686