forked from sifive/wake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.wake
86 lines (82 loc) · 3.3 KB
/
build.wake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Copyright 2019 SiFive, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You should have received a copy of LICENSE.Apache2 along with
# this software. If not, you may obtain a copy at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Useful build variants (arguments to all)
global def default = Pair "native-cpp11-release" "native-c99-release"
global def debug = Pair "native-cpp11-debug" "native-c99-debug"
# Build all wake targets
def targets = buildWake, buildFuse, buildFuseDaemon, buildShim, buildPreload, buildPrelib, Nil
def allOut variant = map (_ variant) targets
global def all variant =
allOut variant
| findSomeFn getPathError
| getOrPass "BUILT"
# Install wake into a target location
global def install dest =
def datfiles = sources "{here}/share" `.*`
def binfiles = allOut default
def releaseBin exe = installAs "{dest}/{replace `\.[^.]*$` '' exe.getPathName}" exe
def datinstall = map (installIn dest) datfiles
def bininstall = map releaseBin binfiles
def readme = installIn "{dest}/share/doc/wake" (source "README.md")
def install = readme, bininstall ++ datinstall
install
| findSomeFn getPathError
| getOrPass "INSTALLED"
# Create a release tarball
global def tarball Unit = match (buildAs Unit) (buildOn Unit)
(Fail f) _ = Fail f
_ (Fail f) = Fail f
(Pass release) (Pass time) =
# Create debian + RedHat package files
def pkgfiles =
def setVersion file =
def in = source "{file}.in"
def script = "%
set -e
sed "s/@VERSION@/%{release}/g" "%{in.getPathName}" > "%{file}.tmp"
mv "%{file}.tmp" "%{file}"
%"
shellJob script (in, Nil) | getJobOutput
map setVersion ("debian/changelog", "wake.spec", Nil)
# Identify those sources files to include in the tarball
def srcs =
sources "." `([^.][^/]*/)*[^.][^/]*` # ignore .foo/ files srcs
| filter (! matches `(debian/|wake.spec).*` _.getPathName) # omit packaging files
# Create a manifest which describes the release and source files
def manifest = write "manifest.wake" (
def pub =
map (_.getPathName.format) srcs
| foldr (_, ",\n ", _) Nil
| cat
"# Generated by 'wake tarball Unit':\n",
"publish releaseAs = '{release}', Nil\n",
"publish releaseOn = '{time}', Nil\n",
"publish source =\n {pub}Nil\n",
Nil
).cat
# Execute tar to create a tarball of manifest + sources
def tarball =
def cmd =
def gnutar = which "gnutar"
def tar = if gnutar ==* "gnutar" then which "tar" else gnutar
def files = map getPathName (manifest, srcs) | sortBy (_<*_)
tar, "--mtime={time}", "--transform=s@^@wake-{release}/@",
"--owner=0", "--group=0", "--numeric-owner", "-cJf",
"wake_{release}.tar.xz", files
job cmd (manifest, srcs)
| getJobOutput
(tarball, pkgfiles)
| findSomeFn getPathError
| getOrPass "TARBALL"