summaryrefslogtreecommitdiff
path: root/impls/monero.rs/scripts/build_monero_c.sh
blob: ca9fba4058bb3f0293d6c579f79af0a2795fca08 (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
#!/bin/bash

set -x -e

# See https://github.com/MrCyjaneK/monero_c for the most up-to-date build docs,
# this is an example and a starting point for building monero_c for use in Rust
# but it should be automated either using CMake or Cargo (preferred).

# Detect architecture.
ARCH=$(uname -m)
OS=$(uname -s)

case $ARCH-$OS in
    x86_64-Linux)
        TARGET_ARCH="x86_64-linux-gnu"
        ;;
    i686-Linux)
        TARGET_ARCH="i686-linux-gnu"
        ;;
    aarch64-Linux)
        TARGET_ARCH="aarch64-linux-gnu"
        ;;
    x86_64-Android)
        TARGET_ARCH="x86_64-linux-android"
        ;;
    i686-Android)
        TARGET_ARCH="i686-linux-android"
        ;;
    aarch64-Android)
        TARGET_ARCH="aarch64-linux-android"
        ;;
    armv7l-Android)
        TARGET_ARCH="arm-linux-androideabi"
        ;;
    i686-Windows)
        TARGET_ARCH="i686-w64-mingw32"
        ;;
    x86_64-Windows)
        TARGET_ARCH="x86_64-w64-mingw32"
        ;;
    x86_64-Darwin)
        TARGET_ARCH="host-apple-darwin"
        ;;
    arm64-Darwin)
        TARGET_ARCH="host-apple-ios"
        ;;
    *)
        echo "Unsupported architecture: $ARCH on OS: $OS"
        exit 1
        ;;
esac


unxz -f release/monero/${TARGET_ARCH}_libwallet2_api_c.so.xz
#unxz -f release/wownero/${TARGET_ARCH}_libwallet2_api_c.so.xz

# Navigate back to /scripts.
cd ..

# Copy the built .so file to a generic name.
SO_FILE="monero_c/release/monero/${TARGET_ARCH}_libwallet2_api_c.so"
if [[ -f "$SO_FILE" ]]; then
    cp "$SO_FILE" "../lib/libwallet2_api_c.so"
    echo "Copied $SO_FILE to libwallet2_api_c.so"
else
    echo "Error: $SO_FILE not found."
    exit 1
fi