forked from Concordium/concordium-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup.hs
41 lines (34 loc) · 1.84 KB
/
Setup.hs
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
import Distribution.PackageDescription
import Distribution.Simple
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Setup
import Distribution.Simple.Utils
import Distribution.System
import System.Directory
import System.Environment
import Data.Maybe
makeRust :: Args -> ConfigFlags -> IO HookedBuildInfo
makeRust args flags = do
let verbosity = fromFlag $ configVerbosity flags
rawSystemExit verbosity "mkdir" ["-p", "./smart-contracts/lib"]
-- This way of determining the platform is not ideal.
notice verbosity "Calling 'cargo build'"
rawSystemExit verbosity "cargo"
["build", "--release", "--manifest-path", "./smart-contracts/wasm-chain-integration/Cargo.toml"]
case buildOS of
Windows -> do
notice verbosity "Copying wasm_chain_integration library"
rawSystemExit verbosity "cp" ["-u", "./smart-contracts/wasm-chain-integration/target/release/wasm_chain_integration.dll", "./smart-contracts/lib/"]
rawSystemExit verbosity "cp" ["-u", "./smart-contracts/wasm-chain-integration/target/release/libwasm_chain_integration.a", "./smart-contracts/lib/"]
_ -> do
rawSystemExit verbosity "ln" ["-s", "-f", "../wasm-chain-integration/target/release/libwasm_chain_integration.a", "./smart-contracts/lib/"]
case buildOS of
OSX ->
rawSystemExit verbosity "ln" ["-s", "-f", "../wasm-chain-integration/target/release/libwasm_chain_integration.dylib", "./smart-contracts/lib/libwasm_chain_integration.dylib"]
_ ->
rawSystemExit verbosity "ln" ["-s", "-f", "../wasm-chain-integration/target/release/libwasm_chain_integration.so", "./smart-contracts/lib/libwasm_chain_integration.so"]
return emptyHookedBuildInfo
main = defaultMainWithHooks simpleUserHooks
{
preConf = makeRust
}