forked from cronos-labs/play-cpp-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
172 lines (144 loc) · 6.26 KB
/
Makefile
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Compile with g++: make CXX=g++
# Compile with clang++: make CXX=clang++
# Compile with default compiler: make
UNAME := $(shell uname)
GCC_CXXFLAGS =
CLANG_CXXFLAGS = -stdlib=libc++
DEFAULT_CXXFLAGS =
ifeq ($(CXX),g++)
CXXFLAGS += $(GCC_CXXFLAGS)
else ifneq (,$(findstring clang,$(CXX)))
CXXFLAGS += $(CLANG_CXXFLAGS)
else
CXXFLAGS += $(DEFAULT_CXXFLAGS)
endif
# Comment out to set your ndk version
# r23, for unreal 4.27 and 5.0
# NDK_VERSION=23.0.7599858
# r25, for unreal 5.1
# NDK_VERSION=25.1.8937393
#
# or set NDK_VERSION on command line
# NDK_VERSION=23.0.7599858 make armv7-linux-androideabi
# NDK_VERSION=23.0.7599858 make aarch64-linux-android
# NDK_VERSION=23.0.7599858 make i686-linux-android
# NDK_VERSION=23.0.7599858 make x86_64-linux-android
# The ndk requirement for unreal, please check
# https://docs.unrealengine.com/4.27/en-US/SharingAndReleasing/Mobile/Android/AndroidSDKRequirements/
# https://docs.unrealengine.com/5.0/en-US/android-development-requirements-for-unreal-engine/
ifeq ($(UNAME), Darwin)
# Please install NDK via Android Studio
NDK_HOME=$(HOME)/Library/Android/sdk/ndk/$(NDK_VERSION)
TOOLCHAIN=$(NDK_HOME)/toolchains/llvm/prebuilt/darwin-x86_64
endif
ifeq ($(UNAME), Linux)
# Change NDK_HOME if necessary
NDK_HOME=/usr/local/lib/android/sdk/ndk/$(NDK_VERSION)
TOOLCHAIN=$(NDK_HOME)/toolchains/llvm/prebuilt/linux-x86_64
endif
# Set this to your minSdkVersion.
API=26
all: build_cpp
clone:
git submodule update --init --recursive
build_play-cpp-sdk: clone
ifeq ($(shell uname -m), x86_64)
ifeq ($(UNAME), Darwin)
cargo install cargo-lipo
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
MACOSX_DEPLOYMENT_TARGET=10.15 CXX=$(CXX) CXXFLAGS=$(CXXFLAGS) cargo build --package play-cpp-sdk --release --target aarch64-apple-darwin
MACOSX_DEPLOYMENT_TARGET=10.15 CXX=$(CXX) CXXFLAGS=$(CXXFLAGS) cargo build --package play-cpp-sdk --release
lipo -create -output ./target/release/libplay_cpp_sdk_universal.a ./target/release/libplay_cpp_sdk.a ./target/aarch64-apple-darwin/release/libplay_cpp_sdk.a
lipo -create -output ./target/aarch64-apple-darwin/release/libplay_cpp_sdk_universal.a ./target/release/libplay_cpp_sdk.a ./target/aarch64-apple-darwin/release/libplay_cpp_sdk.a
endif
ifeq ($(UNAME), Linux)
CXX=$(CXX) CXXFLAGS=$(CXXFLAGS) cargo build --package play-cpp-sdk --release
endif
else
ifeq ($(shell uname -m), arm64)
ifeq ($(UNAME), Darwin)
cargo install cargo-lipo
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
MACOSX_DEPLOYMENT_TARGET=10.15 CXX=$(CXX) CXXFLAGS=$(CXXFLAGS) cargo build --package play-cpp-sdk --release
MACOSX_DEPLOYMENT_TARGET=10.15 CXX=$(CXX) CXXFLAGS=$(CXXFLAGS) cargo build --package play-cpp-sdk --release --target x86_64-apple-darwin
lipo -create -output ./target/release/libplay_cpp_sdk_universal.a ./target/release/libplay_cpp_sdk.a ./target/x86_64-apple-darwin/release/libplay_cpp_sdk.a
lipo -create -output ./target/x86_64-apple-darwin/release/libplay_cpp_sdk_universal.a ./target/release/libplay_cpp_sdk.a ./target/x86_64-apple-darwin/release/libplay_cpp_sdk.a
endif
else
CXX=$(CXX) CXXFLAGS=$(CXXFLAGS) cargo build --package play-cpp-sdk --release
endif
endif
build_extra-cpp-bindings:
CXX=$(CXX) CXXFLAGS=$(CXXFLAGS) cargo build --package extra-cpp-bindings --release
build_cpp: build_play-cpp-sdk
MACOSX_DEPLOYMENT_TARGET=10.15 && cd demo && make build
armv7-linux-androideabi: TARGET=armv7-linux-androideabi
armv7-linux-androideabi: android_armv7
cd demo && TARGET=$(TARGET) make android_build
aarch64-linux-android: TARGET=aarch64-linux-android
aarch64-linux-android: android_aarch64
cd demo && TARGET=$(TARGET) make android_build
i686-linux-android: TARGET=i686-linux-android
i686-linux-android: android_i686
cd demo && TARGET=$(TARGET) make android_build
x86_64-linux-android: TARGET=x86_64-linux-android
x86_64-linux-android: android_x86_64
cd demo && TARGET=$(TARGET) make android_build
aarch64-apple-ios: TARGET=aarch64-apple-ios
aarch64-apple-ios: ios_aarch64
cd demo && TARGET=$(TARGET) make ios_build
android_armv7:
rustup target add $(TARGET)
TARGET_CC=$(TOOLCHAIN)/bin/armv7a-linux-androideabi$(API)-clang \
CXX=$(TOOLCHAIN)/bin/armv7a-linux-androideabi$(API)-clang++ \
TARGET_AR=$(TOOLCHAIN)/bin/llvm-ar \
CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$(TOOLCHAIN)/bin/armv7a-linux-androideabi$(API)-clang \
cargo build --target=$(TARGET) --package play-cpp-sdk --release
android_aarch64:
rustup target add $(TARGET)
TARGET_CC=$(TOOLCHAIN)/bin/$(TARGET)$(API)-clang \
CXX=$(TOOLCHAIN)/bin/$(TARGET)$(API)-clang++ \
TARGET_AR=$(TOOLCHAIN)/bin/llvm-ar \
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$(TOOLCHAIN)/bin/$(TARGET)$(API)-clang \
cargo build --target=$(TARGET) --package play-cpp-sdk --release
android_i686:
rustup target add $(TARGET)
TARGET_CC=$(TOOLCHAIN)/bin/$(TARGET)$(API)-clang \
CXX=$(TOOLCHAIN)/bin/$(TARGET)$(API)-clang++ \
TARGET_AR=$(TOOLCHAIN)/bin/llvm-ar \
CARGO_TARGET_I686_LINUX_ANDROID_LINKER=$(TOOLCHAIN)/bin/$(TARGET)$(API)-clang \
cargo build --target=$(TARGET) --package play-cpp-sdk --release
android_x86_64:
rustup target add $(TARGET)
TARGET_CC=$(TOOLCHAIN)/bin/$(TARGET)$(API)-clang \
CXX=$(TOOLCHAIN)/bin/$(TARGET)$(API)-clang++ \
TARGET_AR=$(TOOLCHAIN)/bin/llvm-ar \
CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=$(TOOLCHAIN)/bin/$(TARGET)$(API)-clang \
cargo build --target=$(TARGET) --package play-cpp-sdk --release
ios_aarch64:
rustup target add $(TARGET)
cargo build --target=$(TARGET) --package play-cpp-sdk --release
cpp: build_cpp
# 1. In order to use crypto pay api, you need to Generate Keys in
# https://merchant.crypto.com/developers/api_keys first
#
# 2. Copy the `Publishable Key` or `Secret Key` as `PAY_API_KEY`'s value in `.env`
# cd demo && git submodule update --init --recursive && make build
cd demo && make run
cpp-ci-tests: build_cpp
./integration_test.sh
webhook:
# 1. Install ngrok for crypto pay api testing: https://ngrok.com/download
#
# 2. Run `ngrok http 4567` in a seperate terminal first, then add the `payload url` into
# https://merchant.crypto.com/developers/webhooks
#
# 3. Find the `SIGNATURE SECRET` in merchant dashboard, and copy it as
# `PAY_WEBHOOK_SIGNATURE_SECRET`'s value in `.env`
cd demo && . ./.env && npm install && node server.js
install:
. ./install.sh
uninstall:
rm -rf install