Ticket #48937: Portfile.3

File Portfile.3, 3.4 KB (added by Schamschula (Marius Schamschula), 7 years ago)
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2
3# Global Keywords
4PortSystem                1.0
5PortGroup                 github 1.0
6
7github.setup              bazelbuild bazel 0.5.1
8github.tarball_from       releases
9categories                devel
10maintainers               tfmnet.com:mohamed.issa \
11                          openmaintainer
12description               A tool for automating builds and tests.
13long_description          ${description}
14platforms                 darwin
15license                   Apache-2
16
17# Pre-Fetch Phase
18pre-fetch {
19    # Make sure the Java compiler exists
20    set cmdnm "javac"
21    set param [auto_execok $cmdnm]
22    if {$param == ""} {
23        error "The Java compiler was not detected on this machine. \
24               Please ensure JDK 8 or newer is properly installed."
25    }
26
27    # Get the Java compiler version and then extract the major + minor parts
28    set ver [exec -ignorestderr -- $cmdnm -version 2>@1]
29    set count [scan $ver "%s %d.%d." cmdnm mjver mnver]
30    if {$count != 3} {
31        error "The Java compiler version data could not be parsed."
32    }
33
34    # Check for major version incompatbility
35    if {$mjver < 1} {
36        error "The installed JDK is too old, please upgrade to JDK 8 or newer."
37    }
38
39    # Check for minor version incompatbility
40    if {$mjver == 1} {
41        if {$mnver < 8} {
42            error "The installed JDK is too old, please upgrade to JDK 8 or newer."
43        }
44    }
45}
46
47# Fetch Phase
48distname                  ${distname}-dist
49dist_subdir               ${name}
50
51# Checksum Phase
52checksums                 rmd160  e0b5b8bd17df2557219561ece7c0020f330ebfe4 \
53                          sha256  85e6a18b111afeea2e475fe991db2a441ec3824211d659bee7b0012c36be9a40
54
55# Extract Phase
56use_zip                   yes
57extract.mkdir             yes
58
59# Patch Phase
60patch {}
61
62# Configure Phase
63use_configure             no
64
65# Build Phase
66build {
67    # The Bazel compilation script erroneously writes to the standard
68    # error stream, so we'll just ignore it. If the build fails, then there
69    # won't be a binary to copy and the destroot phase will fail.
70    exec -ignorestderr -- sudo sh ${worksrcpath}/compile.sh
71}
72
73# Test Phase
74test {}
75
76# Destroot Phase
77destroot {
78    # Copy compiled binary
79    set bindir ${prefix}/bin
80    xinstall -d ${destroot}${bindir}
81    xinstall -m 755 -W ${worksrcpath}/output ${name} ${destroot}${bindir}
82}
83
84# Post-Destroot Phase
85post-destroot {
86    # Mark documentation, source, and example directories
87    set docdir ${prefix}/share/doc/${name}
88    set srcdir ${prefix}/src/${name}
89    set expdir ${prefix}/share/examples/${name}
90
91    # Copy documentation files
92    xinstall -d ${destroot}${docdir}
93    xinstall -m 644 -W ${worksrcpath} AUTHORS \
94                                      CHANGELOG.md \
95                                      CONTRIBUTING.md \
96                                      CONTRIBUTORS \
97                                      ISSUE_TEMPLATE.md \
98                                      LICENSE \
99                                      README.md \
100                       ${destroot}${docdir}
101
102    # Copy source files
103    xinstall -d ${destroot}${srcdir}
104    file copy -force {*}[glob ${worksrcpath}/src/*] ${destroot}${srcdir}
105
106    # Copy example files
107    xinstall -d ${destroot}${expdir}
108    file copy -force {*}[glob ${worksrcpath}/examples/*] ${destroot}${expdir}
109}