Ticket #48937: Portfile.6

File Portfile.6, 4.6 KB (added by RootFunction, 7 years ago)

Updated to version 0.5.2 and fixed completion script issues

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.2
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  5269d2fce917d3324dcb75ca06fe12089a4e24a1 \
53                          sha256  2418c619bdd44257a170b85b9d2ecb75def29e751b725e27186468ada2e009ea
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 -- bash ${worksrcpath}/compile.sh
71
72    # Put executable in main working folder
73    xinstall -m 755 -W ${worksrcpath}/output ${name} ${worksrcpath}
74
75    # Build the bash completion script
76    exec -ignorestderr -- ${worksrcpath}/${name} build //scripts:${name}-complete.bash
77}
78
79# Test Phase
80test {}
81
82# Destroot Phase
83destroot {
84    # Copy compiled binary
85    set bindir ${prefix}/bin
86    xinstall -d ${destroot}${bindir}
87    xinstall -m 755 -W ${worksrcpath}/output ${name} ${destroot}${bindir}
88
89    # Copy bash and zsh completion scripts to designated area for on-demand usage
90    set bcompldir ${prefix}/share/bash-completion/completions/${name}
91    set zcompldir ${prefix}/share/zsh-completion/completions/${name}
92    xinstall -d ${destroot}${bcompldir}
93    xinstall -d ${destroot}${zcompldir}
94    xinstall -m 755 -W ${worksrcpath}/${name}-bin/scripts ${name}-complete.bash ${destroot}${bcompldir}
95    xinstall -m 755 -W ${worksrcpath}/scripts/zsh_completion _${name} ${destroot}${zcompldir}
96}
97
98# Post-Destroot Phase
99post-destroot {
100    # Mark documentation, source, and example directories
101    set docdir ${prefix}/share/doc/${name}
102    set srcdir ${prefix}/src/${name}
103    set expdir ${prefix}/share/examples/${name}
104
105    # Copy documentation files
106    xinstall -d ${destroot}${docdir}
107    xinstall -m 644 -W ${worksrcpath} AUTHORS \
108                                      CHANGELOG.md \
109                                      CONTRIBUTING.md \
110                                      CONTRIBUTORS \
111                                      ISSUE_TEMPLATE.md \
112                                      LICENSE \
113                                      README.md \
114                       ${destroot}${docdir}
115
116    # Copy source files
117    xinstall -d ${destroot}${srcdir}
118    file copy -force {*}[glob ${worksrcpath}/src/*] ${destroot}${srcdir}
119
120    # Copy example files
121    xinstall -d ${destroot}${expdir}
122    file copy -force {*}[glob ${worksrcpath}/examples/*] ${destroot}${expdir}
123}
124
125notes "
126You can activate bash completion by adding the following line to your ~/.bash_profile:
127    source ${prefix}/share/bash-completion/completions/${name}/${name}-complete.bash
128
129For zsh completion, follow instructions at https://bazel.build/versions/master/docs/install.html\
130and substitute ${prefix}/share/zsh-completion/completions/${name}/_${name} for scripts/zsh_completion/_bazel
131
132See http://bazel.build/docs/getting-started.html to start a new project!
133"