Skip to content
Permalink
Browse files

godot: clean up variant setting code

  • Loading branch information
cjones051073 committed May 17, 2020
1 parent e3b47b4 commit 6d243211b919532b78f35e2dfa63e410bf8d5a6f
Showing with 25 additions and 50 deletions.
  1. +25 −50 games/godot/Portfile
@@ -67,77 +67,52 @@ livecheck.regex Godot <em>(\\d+\\.\\d+(?:\\.\\d+)*)</em>
### The following code was adapted from the portfiles
### of ports such as openvdb and openimageio

set clang_suffixes {5 6 7 8 9}
# Get major version from version string
proc get_major {version} { return [lindex [split ${version} .] 0] }

set clang_versions {5.0 6.0 7.0 8.0 9.0}
set clang_variants {}
foreach v ${clang_versions} { lappend clang_variants clang[get_major ${v}] }

# this default version should stay synchronized with
# the default macports_clang option in the SConstruct
# file that is part of the Godot source code
# the default macports_clang option in the SConstruct
# file that is part of the Godot source code
set sconstruct_default_mp_clang 5

set clang_ports {}
foreach s ${clang_suffixes} {
lappend clang_ports clang${s}
}

# error: invalid value 'gnu++14' in '-std=gnu++14'
# On older OSX versions use (latest) clang variant by default
if { ${os.major} <= 13 } {
set has_clang_variant no
foreach s ${clang_suffixes} {
if { [variant_isset clang${s}] } {
foreach v ${clang_versions} {
if { [variant_isset clang[get_major ${v}] ] } {
set has_clang_variant yes
}
}
if { !${has_clang_variant} } {
# Use most recent clang by default
default_variants-append +clang[lindex ${clang_suffixes} end]
default_variants-append +clang[get_major [lindex ${clang_versions} end] ]
}
}

foreach s ${clang_suffixes} {
global use_xcode sconstruct_default_mp_clang
set p clang${s}
if {${s} < 10} {
set v ${s}.0
} else {
set v ${s}
}
set i [lsearch -exact ${clang_ports} ${p}]
set c [lreplace ${clang_ports} ${i} ${i}]
variant ${p} conflicts {*}${c} description "Build using the MacPorts Clang ${v} compiler" {}
if { [variant_isset ${p}] } {

set selected_clang_v ${v}
set selected_clang_s ${s}
set selected_clang_p ${p}

# Configure the variants
foreach clang_ver ${clang_versions} {

set clang_ver_major [get_major ${clang_ver}]

set i [lsearch -exact ${clang_variants} clang${clang_ver_major}]
set c [lreplace ${clang_variants} ${i} ${i}]

variant clang${clang_ver_major} conflicts {*}${c} description {Build using MacPorts Clang ${clang_ver}} {}
if { [variant_isset clang${clang_ver_major}] } {
set selected_clang_v ${clang_ver}
depends_build-append port:clang-${selected_clang_v}

compiler.whitelist macports-clang-${selected_clang_v}

build.args-append macports_clang=${selected_clang_v}
post-configure {
if {${selected_clang_s} != ${sconstruct_default_mp_clang}} {
if { [get_major ${selected_clang_v}] != ${sconstruct_default_mp_clang}} {
reinplace s|${sconstruct_default_mp_clang}\.0|${selected_clang_v}|g \
${worksrcpath}/SConstruct
}

# References:
# * https://trac.macports.org/ticket/58770
# * https://trac.macports.org/ticket/58779#comment:28
ui_warn "
****
**** Installing port ${name} with variant +${selected_clang_p} uses
**** MacPorts Clang instead of Xcode Clang. It also
**** circumvents the Xcode toolchain, which means that
**** if you attempt to perform a build using trace mode
**** (port -t install ${name} +${selected_clang_p}), the build will
**** fail!
****
**** If you are not using trace mode, you can safely
**** ignore this message.
****
"
}

build.args-append macports_clang=${selected_clang_v}
}
}

0 comments on commit 6d24321

Please sign in to comment.
You can’t perform that action at this time.