Ticket #48937: Portfile.4

File Portfile.4, 3.9 KB (added by Schamschula (Marius Schamschula), 7 years ago)

Added basel-complete bash

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    # The bash completion script
72    exec -ignorestderr -- sudo sh ${worksrcpath}/scripts/generate_bash_completion.sh \
73        --bazel=${worksrcpath}/output/${name} \
74        --output=${worksrcpath}/output/${name}-complete.bash
75}
76
77# Test Phase
78test {}
79
80# Destroot Phase
81destroot {
82    # Copy compiled binary
83    set bindir ${prefix}/bin
84    xinstall -d ${destroot}${bindir}
85    xinstall -m 755 -W ${worksrcpath}/output ${name} ${destroot}${bindir}
86    # Copy bash completion script
87    xinstall -m 755 -W ${worksrcpath}/output ${name}-complete.bash ${destroot}${bindir}
88}
89
90# Post-Destroot Phase
91post-destroot {
92    # Mark documentation, source, and example directories
93    set docdir ${prefix}/share/doc/${name}
94    set srcdir ${prefix}/src/${name}
95    set expdir ${prefix}/share/examples/${name}
96
97    # Copy documentation files
98    xinstall -d ${destroot}${docdir}
99    xinstall -m 644 -W ${worksrcpath} AUTHORS \
100                                      CHANGELOG.md \
101                                      CONTRIBUTING.md \
102                                      CONTRIBUTORS \
103                                      ISSUE_TEMPLATE.md \
104                                      LICENSE \
105                                      README.md \
106                       ${destroot}${docdir}
107
108    # Copy source files
109    xinstall -d ${destroot}${srcdir}
110    file copy -force {*}[glob ${worksrcpath}/src/*] ${destroot}${srcdir}
111
112    # Copy example files
113    xinstall -d ${destroot}${expdir}
114    file copy -force {*}[glob ${worksrcpath}/examples/*] ${destroot}${expdir}
115}
116
117notes "
118You can activate bash completion by adding the following line to your ~/.bash_profile:
119
120    source ${prefix}/bin/bazel-complete.bash
121
122See http://bazel.build/docs/getting-started.html to start a new project!
123"