blob: 5a8d6545b18e535979f8380cc45ae2eea0fd813a (
plain)
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
|
module Main
( main
) where
import qualified Distribution.PackageDescription
as PackageDescription
import qualified Distribution.Simple as Simple
import qualified Distribution.Simple.LocalBuildInfo
as LocalBuildInfo
import qualified Distribution.Simple.Setup as Setup
import qualified Distribution.Simple.Utils as Utils
import System.Directory (getCurrentDirectory)
import System.FilePath ((</>))
main =
let h = Simple.simpleUserHooks
in Simple.defaultMainWithHooks
h
{ Simple.preConf =
\args flags
-- Cabal expects to find BoringSSL's libraries already built at the
-- time of configuration, so we must build BoringSSL completely
-- here.
-> do
boringsslBuild flags
Simple.preConf h args flags
, Simple.confHook =
\info flags -> do
buildinfo <- Simple.confHook h info flags
boringsslUpdateExtraLibDirs buildinfo
}
boringsslDir = "third_party" </> "boringssl"
boringsslLibDir = boringsslDir </> "lib"
boringsslBuild flags
-- Build BoringSSL.
= do
let buildDir = boringsslDir </> "build"
mkdir buildDir
cmd
[ "cmake"
, "-GNinja"
, "-DCMAKE_BUILD_TYPE=Release"
, "-B" ++ buildDir
, "-H" ++ boringsslDir </> "src"
]
cmd ["ninja", "-C", buildDir]
-- Rename BoringSSL's libraries so we don't accidentally grab OpenSSL.
mkdir boringsslLibDir
Utils.installOrdinaryFile
v
(buildDir </> "crypto" </> "libcrypto.a")
(boringsslLibDir </> "libbtls_crypto.a")
where
v = Setup.fromFlag (Setup.configVerbosity flags)
mkdir = Utils.createDirectoryIfMissingVerbose v True
cmd (bin:args) = Utils.rawSystemExit v bin args
boringsslUpdateExtraLibDirs buildinfo = do
let pkg = LocalBuildInfo.localPkgDescr buildinfo
Just lib = PackageDescription.library pkg
libBuild = PackageDescription.libBuildInfo lib
dirs = PackageDescription.extraLibDirs libBuild
root <- getCurrentDirectory
return
buildinfo
{ LocalBuildInfo.localPkgDescr =
pkg
{ PackageDescription.library =
Just $
lib
{ PackageDescription.libBuildInfo =
libBuild
{ PackageDescription.extraLibDirs =
(root </> boringsslLibDir) : dirs
}
}
}
}
|