Skip to content

Commit 2965ddd

Browse files
committed
Modernize the build system
This is based on our react-native-zano repo, rather than the old airbitz-core repo.
1 parent e8c348a commit 2965ddd

44 files changed

Lines changed: 491 additions & 1452 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Build output:
2-
/android/.cxx/
32
/android/*.jar
43
/android/build/
4+
/android/src/main/jniLibs/
5+
/ios/RNFastCrypto.xcframework/
56
/lib/
7+
/tmp/
68

79
# Package managers:
810
node_modules/

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,25 @@ const result: Uint8Array = await crypto.scrypt(data, salt, 16384, 8, 1, 32)
2020
console.log(result)
2121
```
2222

23-
## Build libsecp256k1 from scratch (optional)
23+
## Developing
2424

25-
The build process requires several pieces of software to be installed on the
26-
host system:
25+
This library relies on native C++ code from other repos. To integrate this code, you must run the following script before publishing this library to NPM:
2726

28-
* autoconf
29-
* automake
30-
* git
31-
* libtool
27+
```sh
28+
npm run build-native
29+
```
30+
31+
This script does the following tasks:
3232

33-
To install these on the Mac, please use [Homebrew](http://brew.sh/):
33+
- Download third-party source code (libsecp256k1).
34+
- Compile shared libraries for Android.
35+
- Compile an iOS universal static library and put it into an XCFramework.
3436

35-
brew install autoconf automake git libtool
37+
The `build-native` script is also the place to make edits when upgrading any of the third-party dependencies.
3638

37-
If you are building for iOS, you also need a working installation
38-
of the XCode command-line tools. In addition, Macs with Apple Silicon
39-
will also need to do `softwareupdate --install-rosetta`.
39+
For this to work, you need:
4040

41-
Finally, run `./build-secp256k1.sh`
41+
- A recent Android SDK, installed at `$ANDROID_HOME`
42+
- Xcode command-line tools
43+
- `cmake`, provided by `brew install cmake`
44+
- `llvm-objcopy`, provided by `brew install llvm`

android/build.gradle

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.6.0'
8+
classpath 'com.android.tools.build:gradle:7.3.1'
99
}
1010
}
1111

@@ -15,38 +15,19 @@ def safeExtGet(prop, fallback) {
1515
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
1616
}
1717

18-
def DEFAULT_COMPILE_SDK_VERSION = 28
19-
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.2'
20-
def DEFAULT_MIN_SDK_VERSION = 19
21-
def DEFAULT_TARGET_SDK_VERSION = 27
22-
2318
android {
24-
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
25-
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
19+
namespace = "co.airbitz.fastcrypto"
20+
compileSdk = safeExtGet('compileSdkVersion', 28)
21+
ndkVersion = safeExtGet('ndkVersion', '28.0.12674087')
2622

2723
defaultConfig {
28-
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
29-
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
30-
versionCode 1
31-
versionName '1.0'
24+
minSdk = safeExtGet('minSdkVersion', 19)
25+
targetSdk = safeExtGet('targetSdkVersion', 27)
26+
versionCode = 1
27+
versionName = '1.0'
3228
}
3329
lintOptions {
34-
abortOnError false
35-
}
36-
externalNativeBuild {
37-
cmake {
38-
path "src/main/cpp/CMakeLists.txt"
39-
}
40-
}
41-
42-
// Older vesions of the Android Gradle plugin need us to manually add
43-
// the static libraries to the APK:
44-
if (com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION < '4.0') {
45-
sourceSets {
46-
main {
47-
jniLibs.srcDirs 'jni/libs/'
48-
}
49-
}
30+
abortOnError = false
5031
}
5132
}
5233

0 commit comments

Comments
 (0)