Browse Source

Create Nix package for building status-go

tags/0.12.0-mobile
Pedro Pombeiro 4 months ago
parent
commit
65e6e80349
No account linked to committer's email address
53 changed files with 474 additions and 341 deletions
  1. 0
    1
      .dockerignore
  2. 3
    3
      .gitignore
  3. 5
    12
      Makefile
  4. 1
    0
      STATUS_GO_OWNER
  5. 1
    0
      STATUS_GO_SHA256
  6. 1
    1
      STATUS_GO_VERSION
  7. 2
    2
      android/app/jni/Application.mk
  8. 1
    2
      android/build.gradle
  9. 3
    3
      ci/Jenkinsfile.android
  10. 1
    1
      ci/Jenkinsfile.ios
  11. 2
    2
      ci/Jenkinsfile.linux
  12. 1
    1
      ci/Jenkinsfile.macos
  13. 1
    1
      ci/Jenkinsfile.nix.linux
  14. 2
    2
      ci/Jenkinsfile.windows
  15. 3
    1
      ci/docker/nix/Dockerfile
  16. 3
    1
      ci/docker/nix/Makefile
  17. 8
    4
      ci/ios.groovy
  18. 40
    9
      default.nix
  19. 1
    1
      deployment/windows/nsis/setup.nsi
  20. 10
    5
      fastlane/Fastfile
  21. 3
    2
      modules/react-native-desktop-notification/desktop/CMakeLists.txt
  22. 1
    15
      modules/react-native-status/android/build.gradle
  23. 53
    31
      modules/react-native-status/desktop/CMakeLists.txt
  24. 0
    4
      nix/desktop/default.nix
  25. 0
    0
      nix/desktop/linux/appimagekit/default.nix
  26. 0
    0
      nix/desktop/linux/appimagekit/nix.patch
  27. 0
    0
      nix/desktop/linux/base-image/default.nix
  28. 0
    3
      nix/desktop/linux/default.nix
  29. 0
    0
      nix/desktop/linux/linuxdeployqt/default.nix
  30. 0
    0
      nix/desktop/linux/linuxdeployqt/linuxdeployqt.patch
  31. 0
    0
      nix/desktop/macos/base-image/default.nix
  32. 0
    0
      nix/desktop/macos/default.nix
  33. 0
    0
      nix/desktop/windows/base-image/default.nix
  34. 17
    0
      nix/desktop/windows/default.nix
  35. 0
    0
      nix/global-node-packages/README.md
  36. 0
    0
      nix/global-node-packages/generate-nix.sh
  37. 0
    0
      nix/global-node-packages/output/default.nix
  38. 0
    0
      nix/global-node-packages/output/node-env.nix
  39. 0
    0
      nix/global-node-packages/output/node-packages.nix
  40. 36
    0
      nix/mobile/default.nix
  41. 0
    0
      nix/nix.conf
  42. 123
    0
      nix/status-go/default.nix
  43. 70
    0
      nix/status-go/gomobile/default.nix
  44. 12
    0
      nix/status-go/gomobile/ignore-nullability-error-on-ios.patch
  45. 20
    0
      nix/status-go/gomobile/ndk-search-path.patch
  46. 15
    0
      nix/status-go/gomobile/resolve-nix-android-sdk.patch
  47. 0
    90
      scripts/bundle-status-go.sh
  48. 9
    5
      scripts/lib/setup/installers.sh
  49. 0
    12
      scripts/lib/setup/nix/desktop/windows/default.nix
  50. 0
    40
      scripts/lib/setup/nix/mobile/android-ndk/default.nix
  51. 0
    29
      scripts/lib/setup/nix/mobile/default.nix
  52. 14
    52
      scripts/prepare-for-platform.sh
  53. 12
    6
      scripts/update-status-go.sh

+ 0
- 1
.dockerignore View File

@@ -86,7 +86,6 @@ doo-index.html

# Status
Statusgo.framework
status-go-local.aar
status-dev-cli

#ios

+ 3
- 3
.gitignore View File

@@ -35,6 +35,9 @@ project.xcworkspace
# Atom
.tags*

# VS Code
.vscode/ipch/

# node.js
#
node_modules/
@@ -94,9 +97,6 @@ doo-index.html

# Status
Statusgo.framework
status-go-local.aar
status-dev-cli
status-go-*.zip

#ios
ios/Pods

+ 5
- 12
Makefile View File

@@ -26,13 +26,16 @@ HELP_FUN = \
print "\n"; \
}

__toolversion = $(shell $(GIT_ROOT)/scripts/toolversion $(1))
export NIX_CONF_DIR = $(PWD)/nix

# Main targets

clean: ##@prepare Remove all output folders
git clean -dxf -f

clean-nix: ##@prepare Remove complete nix setup
sudo rm -rf /nix ~/.cache/nix

setup: ##@prepare Install all the requirements for status-react
@./scripts/setup

@@ -47,11 +50,9 @@ ifndef IN_NIX_SHELL
echo "Configuring Nix shell..."; \
if ! command -v "nix" >/dev/null 2>&1; then \
. ~/.nix-profile/etc/profile.d/nix.sh; \
NIX_CONF_DIR=$(PWD)/scripts/lib/setup/nix \
nix-shell; \
else \
NIX_CONF_DIR=$(PWD)/scripts/lib/setup/nix \
nix-shell; \
nix-shell; \
fi \
else \
echo "Please run 'make setup' first"; \
@@ -93,21 +94,13 @@ prod-build: _ensure-in-nix-shell
lein prod-build

prod-build-android: _ensure-in-nix-shell
rm ./modules/react-native-status/android/libs/status-im/status-go/local/status-go-local.aar 2> /dev/null || true
scripts/prepare-for-platform.sh android
lein prod-build-android

prod-build-ios: _ensure-in-nix-shell
rm -r ./modules/react-native-status/ios/RCTStatus/Statusgo.framework/ 2> /dev/null || true
scripts/prepare-for-platform.sh ios
lein prod-build-ios

full-prod-build: _ensure-in-nix-shell ##@build build prod for both Android and iOS
./scripts/bundle-status-go.sh ios android
$(MAKE) prod-build
rm -r ./modules/react-native-status/ios/RCTStatus/Statusgo.framework/ 2> /dev/null || true
rm ./modules/react-native-status/android/libs/status-im/status-go/local/status-go-local.aar 2> /dev/null

prod-build-desktop: _ensure-in-nix-shell
git clean -qdxf -f ./index.desktop.js desktop/
scripts/prepare-for-platform.sh desktop

+ 1
- 0
STATUS_GO_OWNER View File

@@ -0,0 +1 @@
status-im

+ 1
- 0
STATUS_GO_SHA256 View File

@@ -0,0 +1 @@
1iixi6f6r3rqb671x3xzki8cibrbhrr312sh32vd13np9hcdwf0w

+ 1
- 1
STATUS_GO_VERSION View File

@@ -1 +1 @@
0.23.0-beta.10
v0.23.0-beta.10

+ 2
- 2
android/app/jni/Application.mk View File

@@ -1,4 +1,4 @@
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
APP_PLATFORM := android-18
APP_STL := gnustl_static
NDK_TOOLCHAIN_VERSION=4.9
APP_STL := c++_static
NDK_TOOLCHAIN_VERSION=clang

+ 1
- 2
android/build.gradle View File

@@ -46,9 +46,8 @@ allprojects {
google()
jcenter()
maven { url "$rootDir/../node_modules/react-native/android" }
maven { url "$rootDir/../modules/react-native-status/android/libs" }
// for geth, function, and status-go
flatDir { dirs "libs", "${rootDir}/app/libs" }
flatDir { dirs "libs", "${System.env.STATUS_GO_LIBDIR}/android" }
maven { url "https://jitpack.io" }
}
}

+ 3
- 3
ci/Jenkinsfile.android View File

@@ -2,7 +2,7 @@ pipeline {
agent {
docker {
label 'linux'
image 'statusteam/nix:jenkins-1.0.0-158e62e1'
image 'statusteam/nix:jenkins-1.0.0-150d5721'
args (
"-v /home/jenkins/tmp:/var/tmp:rw "+
"-v /home/jenkins/status-im.keystore:/tmp/status-im.keystore:ro"
@@ -13,7 +13,7 @@ pipeline {
options {
timestamps()
/* Prevent Jenkins jobs from running forever */
timeout(time: 35, unit: 'MINUTES')
timeout(time: 45, unit: 'MINUTES')
/* Limit builds retained */
buildDiscarder(logRotator(
numToKeepStr: '10',
@@ -41,7 +41,7 @@ pipeline {
/* since we are mounting it we need to specify location */
STATUS_RELEASE_STORE_FILE = '/tmp/status-im.keystore'
/* bundle cache is sensitive to being used by different ruby versions */
BUNDLE_PATH = "/tmp/bundle"
BUNDLE_PATH = "/var/tmp/bundle-${EXECUTOR_NUMBER}"
/* We use EXECUTOR_NUMBER to avoid multiple instances clashing */
LEIN_HOME = "/var/tmp/lein-${EXECUTOR_NUMBER}"
YARN_CACHE_FOLDER = "/var/tmp/yarn-${EXECUTOR_NUMBER}"

+ 1
- 1
ci/Jenkinsfile.ios View File

@@ -27,7 +27,7 @@ pipeline {
LANG = 'en_US.UTF-8'
LANGUAGE = 'en_US.UTF-8'
LC_ALL = 'en_US.UTF-8'
NIX_CONF_DIR = "${env.WORKSPACE}/scripts/lib/setup/nix"
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
FASTLANE_DISABLE_COLORS=1
REALM_DISABLE_ANALYTICS=1
BUNDLE_PATH = "${HOME}/.bundle"

+ 2
- 2
ci/Jenkinsfile.linux View File

@@ -2,7 +2,7 @@ pipeline {
agent {
docker {
label 'linux'
image 'statusteam/nix:jenkins-1.0.0-158e62e1'
image 'statusteam/nix:jenkins-1.0.0-150d5721'
args (
"-v /tmp/Android/Sdk:/home/jenkins/.status/Android/Sdk:rw "+
"-v /var/tmp/lein:/var/tmp/lein:rw "+
@@ -43,7 +43,7 @@ pipeline {
NPM_CONFIG_CACHE = '/var/tmp/npm'
CI_ENVIRONMENT = 'jenkins'
LEIN_HOME = '/var/tmp/lein'
NIX_CONF_DIR = "${env.WORKSPACE}/scripts/lib/setup/nix"
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
VERBOSE_LEVEL = '3'
}


+ 1
- 1
ci/Jenkinsfile.macos View File

@@ -27,7 +27,7 @@ pipeline {
LANG = 'en_US.UTF-8'
LANGUAGE = 'en_US.UTF-8'
LC_ALL = 'en_US.UTF-8'
NIX_CONF_DIR = "${env.WORKSPACE}/scripts/lib/setup/nix"
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
VERBOSE_LEVEL = '3'
}


+ 1
- 1
ci/Jenkinsfile.nix.linux View File

@@ -3,7 +3,7 @@ pipeline {
/* the -u is necessary for acces to /nix */
docker {
label 'linux'
image 'statusteam/nix:jenkins-1.0.0-158e62e1'
image 'statusteam/nix:jenkins-1.0.0-150d5721'
}
}


+ 2
- 2
ci/Jenkinsfile.windows View File

@@ -2,7 +2,7 @@ pipeline {
agent {
docker {
label 'linux-new'
image 'statusteam/nix:jenkins-1.0.0-158e62e1'
image 'statusteam/nix:jenkins-1.0.0-150d5721'
args (
"-v /var/tmp/lein:/var/tmp/lein:rw "+
"-v /var/tmp/npm:/var/tmp/npm:rw "
@@ -42,7 +42,7 @@ pipeline {
LC_ALL = 'en_US.UTF-8'
NPM_CONFIG_CACHE = '/var/tmp/npm'
LEIN_HOME = '/var/tmp/lein'
NIX_CONF_DIR = "${env.WORKSPACE}/scripts/lib/setup/nix"
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
TARGET_SYSTEM_NAME = 'Windows'
CONAN_PRINT_RUN_COMMANDS = '1'
CONAN_SYSREQUIRES_MODE = 'disabled'

+ 3
- 1
ci/docker/nix/Dockerfile View File

@@ -82,10 +82,12 @@ RUN mkdir -p /home/jenkins/.status/Android/Sdk
COPY --from=android_sdk /usr/lib/android-sdk /home/jenkins/.status/Android/Sdk
RUN chmod o+w /home/jenkins/.status/Android/Sdk

ARG GIT_COMMIT

RUN export USER=jenkins \
&& /tmp/nix-install.sh \
&& . ~/.nix-profile/etc/profile.d/nix.sh \
&& nix-shell https://github.com/status-im/status-react/tarball/develop --run 'echo'
&& nix-build --no-out-link https://github.com/status-im/status-react/tarball/${GIT_COMMIT}

# hack to avoid calling login
ENV USER=jenkins

+ 3
- 1
ci/docker/nix/Makefile View File

@@ -1,6 +1,7 @@
__toolversion = $(shell $(GIT_ROOT)/scripts/toolversion $(1))

GIT_COMMIT = $(shell git rev-parse --short HEAD)
GIT_COMMIT_FULL = $(shell git rev-parse HEAD)
GIT_ROOT = $(shell git rev-parse --show-toplevel)

ANDROID_SDK_VERSION = $(call __toolversion, android-sdk)
@@ -19,7 +20,7 @@ NIX_SHA = 0039df605d2324f721f0c99ab76fc58fa60f791d84b30196eed805e8e65b1e51
NIX_URL = https://nixos.org/releases/nix/nix-$(NIX_VERSION)/install

# WARNING: Remember to change the tag when updating the image
DEPS_HASH = $(shell $(GIT_ROOT)/scripts/gen-deps-hash.sh -b $(NIX_SHA) \
DEPS_HASH = $(shell $(GIT_ROOT)/scripts/gen-deps-hash.sh -b $(NIX_SHA) -b $(GIT_COMMIT_FULL) \
-d android-sdk \
-d android-sdk-platform \
-d android-sdk-build-tools \
@@ -39,6 +40,7 @@ build: $(NIX_INSTALL) $(ANDROID_SDK_ARCHIVE)
--build-arg="SDK_BUILD_TOOLS_VERSION=$(SDK_BUILD_TOOLS_VERSION)" \
--build-arg="SDK_PLATFORM_VERSION=$(SDK_PLATFORM_VERSION)" \
--build-arg="DEPS_HASH=$(DEPS_HASH)" \
--build-arg="GIT_COMMIT=$(GIT_COMMIT_FULL)" \
-t $(IMAGE_NAME) .

$(NIX_INSTALL):

+ 8
- 4
ci/ios.groovy View File

@@ -1,7 +1,9 @@
utils = load('ci/utils.groovy')

def plutil(name, value) {
utils.nix_sh "plutil -replace ${name} -string ${value} ios/StatusIm/Info.plist"
return """
plutil -replace ${name} -string ${value} ios/StatusIm/Info.plist;
"""
}

def bundle(type) {
@@ -16,9 +18,11 @@ def bundle(type) {
default: target = 'nightly';
}
/* configure build metadata */
plutil('CFBundleShortVersionString', utils.getVersion('mobile_files'))
plutil('CFBundleVersion', utils.genBuildNumber())
plutil('CFBundleBuildUrl', currentBuild.absoluteUrl)
utils.nix_sh(
plutil('CFBundleShortVersionString', utils.getVersion('mobile_files')) +
plutil('CFBundleVersion', utils.genBuildNumber()) +
plutil('CFBundleBuildUrl', currentBuild.absoluteUrl)
)
/* the dir might not exist */
sh 'mkdir -p status-e2e'
/* build the actual app */

+ 40
- 9
default.nix View File

@@ -2,9 +2,9 @@
{ pkgs ? import ((import <nixpkgs> { }).fetchFromGitHub {
owner = "status-im";
repo = "nixpkgs";
rev = "15623aac6e8cbfa24d4268195bc8eda7303ea2ff";
sha256 = "0crjmspk65rbpkl3kqcj7433355i9fy530lhc48g2cz75xjk4sxh";
}) { config = { }; },
rev = "db492b61572251c2866f6b5e6e94e9d70e7d3021";
sha256 = "188r7gbcrxi20nj6xh9bmdf3lbjwb94v9s0wpacl7q39g1fca66h";
}) { config = { android_sdk.accept_license = true; }; },
target-os ? "" }:

with pkgs;
@@ -22,18 +22,41 @@ with pkgs;
}.${target-os} or false;
# TODO: Try to use stdenv for iOS. The problem is with building iOS as the build is trying to pass parameters to Apple's ld that are meant for GNU's ld (e.g. -dynamiclib)
_stdenv = if target-os == "ios" || target-os == "" then stdenvNoCC else stdenv;
statusDesktop = callPackage ./scripts/lib/setup/nix/desktop { inherit target-os; stdenv = _stdenv; };
statusMobile = callPackage ./scripts/lib/setup/nix/mobile { inherit target-os; stdenv = _stdenv; };
nodeInputs = import ./scripts/lib/setup/nix/global-node-packages/output {
statusDesktop = callPackage ./nix/desktop { inherit target-os; stdenv = _stdenv; };
statusMobile = callPackage ./nix/mobile { inherit target-os status-go; androidPkgs = androidComposition; stdenv = _stdenv; };
status-go = callPackage ./nix/status-go { inherit (xcodeenv) composeXcodeWrapper; inherit xcodewrapperArgs; androidPkgs = androidComposition; };
nodeInputs = import ./nix/global-node-packages/output {
# The remaining dependencies come from Nixpkgs
inherit pkgs;
inherit nodejs;
inherit pkgs nodejs;
};
nodePkgs = [
nodejs
python27 # for e.g. gyp
yarn
] ++ (map (x: nodeInputs."${x}") (builtins.attrNames nodeInputs));
xcodewrapperArgs = {
version = "10.1";
};
xcodeWrapper = xcodeenv.composeXcodeWrapper xcodewrapperArgs;
androidComposition = androidenv.composeAndroidPackages {
toolsVersion = "26.1.1";
platformToolsVersion = "28.0.2";
buildToolsVersions = [ "28.0.3" ];
includeEmulator = false;
platformVersions = [ "26" "27" ];
includeSources = false;
includeDocs = false;
includeSystemImages = false;
systemImageTypes = [ "default" ];
abiVersions = [ "armeabi-v7a" ];
lldbVersions = [ "2.0.2558144" ];
cmakeVersions = [ "3.6.4111459" ];
includeNDK = true;
ndkVersion = "19.2.5345600";
useGoogleAPIs = false;
useGoogleTVAddOns = false;
includeExtras = [ "extras;android;m2repository" "extras;google;m2repository" ];
};

in _stdenv.mkDerivation rec {
name = "env";
@@ -52,6 +75,8 @@ with pkgs;
watchman
unzip
wget

status-go
] ++ nodePkgs
++ lib.optional isDarwin cocoapods
++ lib.optional targetDesktop statusDesktop.buildInputs
@@ -60,6 +85,12 @@ with pkgs;
''
set -e
'' +
status-go.shellHook +
''
export STATUS_GO_INCLUDEDIR=${status-go}/include
export STATUS_GO_LIBDIR=${status-go}/lib
export STATUS_GO_BINDIR=${status-go.bin}/bin
'' +
lib.optionalString targetDesktop statusDesktop.shellHook +
lib.optionalString targetMobile statusMobile.shellHook +
''
@@ -68,5 +99,5 @@ with pkgs;
fi
set +e
'';
hardeningDisable = statusDesktop.hardeningDisable;
hardeningDisable = status-go.hardeningDisable;
}

+ 1
- 1
deployment/windows/nsis/setup.nsi View File

@@ -627,7 +627,7 @@ Section "Status Desktop" SecMain
File "${top_srcdir}\.env"
File "${top_srcdir}\node_modules\node-notifier\vendor\snoreToast\SnoreToast.exe"
File /r "${top_srcdir}\desktop\bin\"
File /r "${base_image_dir}"
File /r "${base_image_dir}\"

SetOutPath "$INSTDIR\notifier"
File "${top_srcdir}\node_modules\node-notifier\vendor\notifu\*.exe"

+ 10
- 5
fastlane/Fastfile View File

@@ -103,7 +103,10 @@ def build_ios_adhoc(readonly)
export_method: "ad-hoc",
# Temporary fix for Xcode 10.1
xcargs: "-UseModernBuildSystem=N",
output_directory: "status-adhoc"
output_directory: "status-adhoc",
export_options: {
"UseModernBuildSystem": "N"
}
)
end

@@ -130,7 +133,8 @@ def build_ios_e2e
destination: "generic/platform=iOS Simulator",
# 2. fixing compilations issues as stated in https://stackoverflow.com/a/20505258
# it looks like i386 isn't supported by React Native
xcargs: "ARCHS=\"x86_64\" ONLY_ACTIVE_ARCH=NO",
# UseModernBuildSystem: Temporary fix for Xcode 10.1
xcargs: "ARCHS=\"x86_64\" ONLY_ACTIVE_ARCH=NO -UseModernBuildSystem=N",
# 3. directory where to up StatusIm.app
derived_data_path: "status-e2e",
output_name: "StatusIm.app",
@@ -139,12 +143,13 @@ def build_ios_e2e
scheme: "StatusIm",
workspace: "ios/StatusIm.xcworkspace",
configuration: "Release",
# Temporary fix for Xcode 10.1
xcargs: "-UseModernBuildSystem=N",
# Simulator apps can't be archived...
skip_archive: true,
# ...and we don't need an .ipa file for them, because we use .app directly
skip_package_ipa: true
skip_package_ipa: true,
export_options: {
"UseModernBuildSystem": "N"
}
)

zip(

+ 3
- 2
modules/react-native-desktop-notification/desktop/CMakeLists.txt View File

@@ -18,8 +18,8 @@ if (WIN32)
-DBUILD_freedesktop_backend=OFF -DBUILD_snarl=OFF -DBUILD_growl=OFF -DBUILD_trayicon=OFF -DBUILD_pushover_backend=OFF)
endif()

set(SN_LIBPATHSUFFIX /${CMAKE_LIBRARY_ARCHITECTURE})
if (UNIX AND NOT APPLE)
set(SN_LIBPATHSUFFIX /${CMAKE_LIBRARY_ARCHITECTURE})
set(SnoreNotifyFreedesktop_STATIC_LIB ${SN_PREFIX}/lib${SN_LIBPATHSUFFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}snore_backend_freedesktop${CMAKE_STATIC_LIBRARY_SUFFIX})

set(SnoreNotify_LIBS ${SnoreNotifyFreedesktop_STATIC_LIB})
@@ -40,7 +40,8 @@ set(SnoreNotify_STATIC_LIB ${SN_PREFIX}/lib${SN_LIBPATHSUFFIX}/${CMAKE_STATIC_LI
set(SnoreNotifyBackend_STATIC_LIB ${SN_PREFIX}/lib${SN_LIBPATHSUFFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}snore_backend_snore${CMAKE_STATIC_LIBRARY_SUFFIX})
set(SnoreNotifyBackendSettings_STATIC_LIB ${SN_PREFIX}/lib${SN_LIBPATHSUFFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}snore_settings_backend_snore${CMAKE_STATIC_LIBRARY_SUFFIX})
set(SnoreNotifySettings_STATIC_LIB ${SN_PREFIX}/lib${SN_LIBPATHSUFFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}snoresettings-qt5${CMAKE_STATIC_LIBRARY_SUFFIX})
set(SnoreNotify_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${SN_PREFIX} -DSNORE_STATIC=ON -DBUILD_daemon=OFF -DBUILD_settings=OFF
set(SnoreNotify_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${SN_PREFIX} -DCMAKE_INSTALL_LIBDIR=lib${SN_LIBPATHSUFFIX}
-DSNORE_STATIC=ON -DBUILD_daemon=OFF -DBUILD_settings=OFF
-DBUILD_snoresend=OFF ${SnoreNotify_CMAKE_ARGS})
set(SnoreNotify_CMAKE_ARGS ${SnoreNotify_CMAKE_ARGS}
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"

+ 1
- 15
modules/react-native-status/android/build.gradle View File

@@ -20,19 +20,5 @@ dependencies {
implementation 'com.facebook.react:react-native:+' // from node_modules
compile 'com.github.status-im:function:0.0.1'

// WARNING: If you change this, make sure the GitHub release of the .aar exists.
// WARNING: status-go is downloaded in Makefile and has a hardcoded version too.
String statusGoVersion = getStatusGoVersion()
final String statusGoGroup = 'status-im', statusGoName = 'status-go'

// Check if the local status-go jar exists, and compile against that if it does
final String localStatusLibOutputDir = "${rootDir}/../modules/react-native-status/android/libs", localVersion = 'local'
final File localFile = new File("${localStatusLibOutputDir}/${statusGoGroup}/${statusGoName}/${localVersion}/${statusGoName}-${localVersion}.aar")
if ( localFile.exists() ) {
// Use the local version
logger.warn("Using local build of Android status-go library ${localFile.absolutePath}.")
statusGoVersion = localVersion
}

implementation(group: statusGoGroup, name: statusGoName, version: statusGoVersion, ext: 'aar')
implementation(group: 'status-im', name: 'status-go', version: getStatusGoVersion(), ext: 'aar')
}

+ 53
- 31
modules/react-native-status/desktop/CMakeLists.txt View File

@@ -1,7 +1,6 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
find_package(Go REQUIRED)

set(REACT_NATIVE_DESKTOP_EXTERNAL_MODULES_TYPE_NAMES ${REACT_NATIVE_DESKTOP_EXTERNAL_MODULES_TYPE_NAMES}
\"RCTStatus\" PARENT_SCOPE)
@@ -9,37 +8,60 @@ set(REACT_NATIVE_DESKTOP_EXTERNAL_MODULES_TYPE_NAMES ${REACT_NATIVE_DESKTOP_EXTE
set(REACT_NATIVE_DESKTOP_EXTERNAL_MODULES_SRC ${REACT_NATIVE_DESKTOP_EXTERNAL_MODULES_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/rctstatus.cpp PARENT_SCOPE)

include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
if (WIN32)
#
# Right now we only build status-go from source for Windows, since that needs to be cross-compiled with the toolchain in Conan
#
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)

if (CUSTOM_STATUSGO_BUILD_DIR_PATH)
set(StatusGo_ROOT ${CUSTOM_STATUSGO_BUILD_DIR_PATH})
else()
set(StatusGo_ROOT "${CMAKE_CURRENT_BINARY_DIR}/StatusGo")
endif()
set(StatusGo_PREFIX "${StatusGo_ROOT}/src/github.com/status-im")
set(StatusGo_SOURCE_DIR "${StatusGo_PREFIX}/status-go")
set(StatusGo_INCLUDE_DIR "${StatusGo_SOURCE_DIR}/build/bin")
set(StatusGo_STATIC_LIB
"${StatusGo_SOURCE_DIR}/build/bin/${CMAKE_STATIC_LIBRARY_PREFIX}status${CMAKE_STATIC_LIBRARY_SUFFIX}")

include_directories(${StatusGo_INCLUDE_DIR})

set(CONFIGURE_SCRIPT build-status-go.sh)

file(STRINGS "../../../STATUS_GO_VERSION" STATUS_GO_VERSION)

ExternalProject_Add(StatusGo_ep
PREFIX ${StatusGo_PREFIX}
SOURCE_DIR ${StatusGo_SOURCE_DIR}
URL https://status-go.ams3.digitaloceanspaces.com/status-go-desktop-${STATUS_GO_VERSION}.zip
https://github.com/status-im/status-go/archive/${STATUS_GO_VERSION}.zip
BUILD_BYPRODUCTS ${StatusGo_STATIC_LIB}
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIGURE_SCRIPT} ${CMAKE_SYSTEM_NAME} ${GO_ROOT_PATH} ${StatusGo_ROOT} ${StatusGo_SOURCE_DIR} ${CMAKE_C_COMPILER} ${CMAKE_CXX_COMPILER}
BUILD_COMMAND ""
INSTALL_COMMAND ""
)

set(REACT_NATIVE_DESKTOP_EXTERNAL_PROJECT_DEPS ${REACT_NATIVE_DESKTOP_EXTERNAL_PROJECT_DEPS} StatusGo_ep PARENT_SCOPE)
find_package(Go REQUIRED)

file(STRINGS "../../../STATUS_GO_OWNER" STATUS_GO_OWNER)
file(STRINGS "../../../STATUS_GO_VERSION" STATUS_GO_VERSION)

if (CUSTOM_STATUSGO_BUILD_DIR_PATH)
set(StatusGo_ROOT ${CUSTOM_STATUSGO_BUILD_DIR_PATH})
else()
set(StatusGo_ROOT "${CMAKE_CURRENT_BINARY_DIR}/StatusGo")
endif()
set(StatusGo_PREFIX "${StatusGo_ROOT}/src/github.com/${STATUS_GO_OWNER}")
set(StatusGo_SOURCE_DIR "${StatusGo_PREFIX}/status-go")
set(StatusGo_INCLUDE_DIR "${StatusGo_SOURCE_DIR}/build/bin")
set(StatusGo_STATIC_LIB
"${StatusGo_SOURCE_DIR}/build/bin/${CMAKE_STATIC_LIBRARY_PREFIX}status${CMAKE_STATIC_LIBRARY_SUFFIX}")

include_directories(${StatusGo_INCLUDE_DIR})

set(CONFIGURE_SCRIPT build-status-go.sh)

ExternalProject_Add(StatusGo_ep
PREFIX ${StatusGo_PREFIX}
SOURCE_DIR ${StatusGo_SOURCE_DIR}
URL https://status-go.ams3.digitaloceanspaces.com/status-go-desktop-${STATUS_GO_VERSION}.zip
https://github.com/${STATUS_GO_OWNER}/status-go/archive/${STATUS_GO_VERSION}.zip
BUILD_BYPRODUCTS ${StatusGo_STATIC_LIB}
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIGURE_SCRIPT} ${CMAKE_SYSTEM_NAME} ${GO_ROOT_PATH} ${StatusGo_ROOT} ${StatusGo_SOURCE_DIR} ${CMAKE_C_COMPILER} ${CMAKE_CXX_COMPILER}
BUILD_COMMAND ""
INSTALL_COMMAND ""
)

set(REACT_NATIVE_DESKTOP_EXTERNAL_PROJECT_DEPS ${REACT_NATIVE_DESKTOP_EXTERNAL_PROJECT_DEPS} StatusGo_ep PARENT_SCOPE)
else (WIN32)
# For Linux and Darwin just use the Nix build of status-go
set(StatusGo_INCLUDE_DIR $ENV{STATUS_GO_INCLUDEDIR})
if (APPLE)
set(StatusGo_PLATFORM "x86_64-darwin")
else()
set(StatusGo_PLATFORM "x86_64-linux")
endif()
set(StatusGo_STATIC_LIB
"$ENV{STATUS_GO_LIBDIR}/${StatusGo_PLATFORM}/${CMAKE_STATIC_LIBRARY_PREFIX}status${CMAKE_STATIC_LIBRARY_SUFFIX}")

include_directories(${StatusGo_INCLUDE_DIR})

message(STATUS "StatusGo_STATIC_LIB=${StatusGo_STATIC_LIB}")
message(STATUS "StatusGo_INCLUDE_DIR=${StatusGo_INCLUDE_DIR}")
endif (WIN32)

if (APPLE)
set(STATUSGO_DEPS_LIBS "-framework Foundation"

scripts/lib/setup/nix/desktop/default.nix → nix/desktop/default.nix View File

@@ -26,7 +26,6 @@ in
cmake
extra-cmake-modules
file
go
] ++ lib.optional targetLinux linuxPlatform.buildInputs
++ lib.optional targetDarwin darwinPlatform.buildInputs
++ lib.optional (! targetWindows) qt5.full
@@ -37,7 +36,4 @@ in
export QT_PATH="${qt5.full}"
export PATH="${stdenv.lib.makeBinPath [ qt5.full ]}:$PATH"
'');

# Fixes Cgo related build failures (see https://github.com/NixOS/nixpkgs/issues/25959 )
hardeningDisable = linuxPlatform.hardeningDisable;
}

scripts/lib/setup/nix/desktop/linux/appimagekit/default.nix → nix/desktop/linux/appimagekit/default.nix View File


scripts/lib/setup/nix/desktop/linux/appimagekit/nix.patch → nix/desktop/linux/appimagekit/nix.patch View File


scripts/lib/setup/nix/desktop/linux/base-image/default.nix → nix/desktop/linux/base-image/default.nix View File


scripts/lib/setup/nix/desktop/linux/default.nix → nix/desktop/linux/default.nix View File

@@ -11,7 +11,4 @@ let
in
{
buildInputs = [ appimagekit linuxdeployqt patchelf baseImage ];

# Fixes Cgo related build failures (see https://github.com/NixOS/nixpkgs/issues/25959 )
hardeningDisable = [ "fortify" ];
}

scripts/lib/setup/nix/desktop/linux/linuxdeployqt/default.nix → nix/desktop/linux/linuxdeployqt/default.nix View File


scripts/lib/setup/nix/desktop/linux/linuxdeployqt/linuxdeployqt.patch → nix/desktop/linux/linuxdeployqt/linuxdeployqt.patch View File


scripts/lib/setup/nix/desktop/macos/base-image/default.nix → nix/desktop/macos/base-image/default.nix View File


scripts/lib/setup/nix/desktop/macos/default.nix → nix/desktop/macos/default.nix View File


scripts/lib/setup/nix/desktop/windows/base-image/default.nix → nix/desktop/windows/base-image/default.nix View File


+ 17
- 0
nix/desktop/windows/default.nix View File

@@ -0,0 +1,17 @@
{ stdenv, pkgs }:

with pkgs;
with stdenv;

let
baseImage = callPackage ./base-image { };

in
{
buildInputs = lib.optional isLinux [
conan
nsis
baseImage
go # Needed for Windows build only
];
}

scripts/lib/setup/nix/global-node-packages/README.md → nix/global-node-packages/README.md View File


scripts/lib/setup/nix/global-node-packages/generate-nix.sh → nix/global-node-packages/generate-nix.sh View File


scripts/lib/setup/nix/global-node-packages/output/default.nix → nix/global-node-packages/output/default.nix View File


scripts/lib/setup/nix/global-node-packages/output/node-env.nix → nix/global-node-packages/output/node-env.nix View File


scripts/lib/setup/nix/global-node-packages/output/node-packages.nix → nix/global-node-packages/output/node-packages.nix View File


+ 36
- 0
nix/mobile/default.nix View File

@@ -0,0 +1,36 @@
{ stdenv, pkgs, target-os ? "", status-go, androidPkgs }:

with pkgs;
with stdenv;

let
targetAndroid = {
"android" = true;
"" = true;
}.${target-os} or false;
targetIOS = {
"ios" = true;
"" = true;
}.${target-os} or false;

in
{
buildInputs =
[ bundler ruby ] ++ ## bundler/ruby used for fastlane
lib.optional targetAndroid [
openjdk
];
shellHook =
lib.optionalString targetIOS ''
export RCTSTATUS_FILEPATH=${status-go}/lib/ios/Statusgo.framework
'' +
lib.optionalString targetAndroid ''
export JAVA_HOME="${openjdk}"
export ANDROID_HOME=~/.status/Android/Sdk
export ANDROID_SDK_ROOT="$ANDROID_HOME"
export ANDROID_NDK_ROOT="${androidPkgs.ndk-bundle}/libexec/android-sdk/ndk-bundle"
export ANDROID_NDK_HOME="$ANDROID_NDK_ROOT"
export ANDROID_NDK="$ANDROID_NDK_ROOT"
export PATH="$ANDROID_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools:$PATH"
'';
}

scripts/lib/setup/nix/nix.conf → nix/nix.conf View File


+ 123
- 0
nix/status-go/default.nix View File

@@ -0,0 +1,123 @@
{ stdenv, buildGoPackage, go, pkgs, fetchFromGitHub, openjdk, androidPkgs, composeXcodeWrapper, xcodewrapperArgs ? {} }:

with stdenv;

let
gomobile = pkgs.callPackage ./gomobile { inherit (androidPkgs) platform-tools; inherit composeXcodeWrapper xcodewrapperArgs; };
version = lib.fileContents ../../STATUS_GO_VERSION; # TODO: Simplify this path search with lib.locateDominatingFile
owner = lib.fileContents ../../STATUS_GO_OWNER;
repo = "status-go";
goPackagePath = "github.com/${owner}/${repo}";
rev = version;
sha256 = lib.fileContents ../../STATUS_GO_SHA256;
mobileTarget = if isDarwin then "ios" else "android";
mobileOutputFileName = if isDarwin then "Statusgo.framework" else "status-go-${version}.aar";
desktopOutputFileName = "libstatus.a";
destopSystem = hostPlatform.system;
removeReferences = [ go ];
removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}'';
goBuildFlags = "-v";
goBuildLdFlags = "-ldflags=-s";
xcodeWrapper = composeXcodeWrapper xcodewrapperArgs;

in buildGoPackage rec {
inherit goPackagePath version rev;
name = "${repo}-${version}";

src = pkgs.fetchFromGitHub { inherit rev owner repo sha256; };

nativeBuildInputs = [ gomobile openjdk ]
++ lib.optional isDarwin xcodeWrapper;

# Fixes Cgo related build failures (see https://github.com/NixOS/nixpkgs/issues/25959 )
hardeningDisable = [ "fortify" ];

# gomobile doesn't seem to be able to pass -ldflags with multiple values correctly to go build, so we just patch files here
patchPhase = ''
date=$(date -u '+%Y-%m-%d.%H:%M:%S')

substituteInPlace cmd/statusd/main.go --replace \
"buildStamp = \"N/A\"" \
"buildStamp = \"$date\""
substituteInPlace params/version.go --replace \
"var Version string" \
"var Version string = \"${version}\""
substituteInPlace params/version.go --replace \
"var GitCommit string" \
"var GitCommit string = \"${rev}\""
substituteInPlace vendor/github.com/ethereum/go-ethereum/metrics/metrics.go --replace \
"var EnabledStr = \"false\"" \
"var EnabledStr = \"true\""
'';

# we print out the version so that we fail fast in case there's any problem running xcrun, instead of failing at the end of the build
preConfigure = lib.optionalString isDarwin ''
xcrun xcodebuild -version
'';

buildPhase = ''
runHook preBuild

runHook renameImports

pushd "$NIX_BUILD_TOP/go/src/${goPackagePath}" >/dev/null

echo
echo "Building desktop library"
echo
#GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build ${goBuildFlags} -buildmode=c-archive -o $out/${desktopOutputFileName} ./lib
go build -o $out/${desktopOutputFileName} ${goBuildFlags} -buildmode=c-archive ${goBuildLdFlags} ./lib

# Build command-line tools
for name in ./cmd/*; do
echo
echo "Building $name"
echo
go install ${goBuildFlags} $name
done

popd >/dev/null

# Build mobile libraries
# TODO: Manage to pass -s -w to -ldflags. Seems to only accept a single flag
echo
echo "Building mobile library"
echo
ANDROID_HOME=${androidPkgs.androidsdk}/libexec/android-sdk \
ANDROID_NDK_HOME="${androidPkgs.ndk-bundle}/libexec/android-sdk/ndk-bundle" \
GOPATH=${gomobile.dev}:$GOPATH \
PATH=${lib.makeBinPath [ gomobile.bin openjdk ]}:$PATH \
gomobile bind ${goBuildFlags} -target=${mobileTarget} -iosversion=8.0 \
-o ${mobileOutputFileName} \
${goBuildLdFlags} \
${goPackagePath}/mobile

runHook postBuild
'';

postInstall = ''
mkdir -p $bin
cp -r "$NIX_BUILD_TOP/go/bin/" $bin

mkdir -p $out/lib/${mobileTarget}
mv ${mobileOutputFileName} $out/lib/${mobileTarget}/

mkdir -p $out/lib/${destopSystem} $out/include
mv $out/${desktopOutputFileName} $out/lib/${destopSystem}
mv $out/libstatus.h $out/include
'';

# remove hardcoded paths to go package in /nix/store, otherwise Nix will fail the build
preFixup = ''
find $out -type f -exec ${removeExpr removeReferences} '{}' + || true
'';

outputs = [ "out" "bin" ];

meta = {
description = "The Status module that consumes go-ethereum.";
license = lib.licenses.mpl20;
maintainers = with lib.maintainers; [ pombeirp ];
platforms = with lib.platforms; linux ++ darwin;
};
}

+ 70
- 0
nix/status-go/gomobile/default.nix View File

@@ -0,0 +1,70 @@
{ stdenv, pkgs, buildGoPackage, fetchgit,
glibc, ncurses5, zlib, makeWrapper, patchelf,
platform-tools, composeXcodeWrapper, xcodewrapperArgs ? {}
}:

with stdenv;

let
xcodeWrapper = composeXcodeWrapper xcodewrapperArgs;

in buildGoPackage rec {
name = "gomobile-${version}";
version = "20190319-${lib.strings.substring 0 7 rev}";
rev = "167ebed0ec6dd457a6b24a4f61db913f0af11f70";
sha256 = "0lspdhikhnhbwv8v0q6fs3a0pd9sjnhkpg8z03m2dc5h6f84m38w";

goPackagePath = "golang.org/x/mobile";
subPackages = [ "bind" "cmd/gobind" "cmd/gomobile" ];

buildInputs = [ makeWrapper ]
++ lib.optional isDarwin xcodeWrapper;

# we print out the version so that we fail fast in case there's any problem running xcrun, instead of failing at the end of the build
preConfigure = lib.optionalString isDarwin ''
PATH=${lib.makeBinPath [ xcodeWrapper ]}:$PATH xcrun xcodebuild -version
'';

patches = [ ./ndk-search-path.patch ./resolve-nix-android-sdk.patch ]
++ lib.optional isDarwin [ ./ignore-nullability-error-on-ios.patch ];

postPatch = ''
substituteInPlace cmd/gomobile/install.go --replace "\`adb\`" "\`${platform-tools}/bin/adb\`"

echo "Creating $dev"
mkdir -p $dev/src/$goPackagePath
echo "Copying from $src"
cp -a $src/. $dev/src/$goPackagePath
'';

postInstall = ''
mkdir -p $out $bin/lib

ln -s ${ncurses5}/lib/libncursesw.so.5 $bin/lib/libtinfo.so.5
'' + lib.optionalString isDarwin ''
wrapProgram $bin/bin/gomobile \
--prefix "PATH" : "${lib.makeBinPath [ xcodeWrapper ]}" \
--prefix "LD_LIBRARY_PATH" : "${lib.makeLibraryPath [ ncurses5 zlib ]}:$bin/lib"
'' + lib.optionalString (!isDarwin) ''
wrapProgram $bin/bin/gomobile \
--prefix "LD_LIBRARY_PATH" : "${lib.makeLibraryPath [ ncurses5 zlib ]}:$bin/lib"
'' + ''
$bin/bin/gomobile init
'';

src = fetchgit {
inherit rev sha256;
url = "https://go.googlesource.com/mobile";
};

outputs = [ "bin" "dev" "out" ];

meta = {
description = "A tool for building and running mobile apps written in Go.";
longDescription = "Gomobile is a tool for building and running mobile apps written in Go.";
homepage = https://go.googlesource.com/mobile;
license = lib.licenses.bsdOriginal;
maintainers = with lib.maintainers; [ sheenobu pombeirp ];
platforms = with lib.platforms; linux ++ darwin;
};
}

+ 12
- 0
nix/status-go/gomobile/ignore-nullability-error-on-ios.patch View File

@@ -0,0 +1,12 @@
diff --git a/cmd/gomobile/env.go b/cmd/gomobile/env.go
index dbf9c8c..538cf35 100644
--- a/cmd/gomobile/env.go
+++ b/cmd/gomobile/env.go
@@ -138,6 +138,7 @@ func envInit() (err error) {
panic(fmt.Errorf("unknown GOARCH: %q", arch))
}
cflags += " -fembed-bitcode"
+ cflags += " -Wno-nullability-completeness"
if err != nil {
return err
}

+ 20
- 0
nix/status-go/gomobile/ndk-search-path.patch View File

@@ -0,0 +1,20 @@
diff --git a/cmd/gomobile/env.go b/cmd/gomobile/env.go
index dbf9c8c..a1c835a 100644
--- a/cmd/gomobile/env.go
+++ b/cmd/gomobile/env.go
@@ -165,10 +165,13 @@ func ndkRoot() (string, error) {
if androidHome == "" {
return "", errors.New("The Android SDK was not found. Please set ANDROID_HOME to the root of the Android SDK.")
}
- ndkRoot := filepath.Join(androidHome, "ndk-bundle")
+ ndkRoot := os.Getenv("ANDROID_NDK_HOME")
+ if ndkRoot == "" {
+ ndkRoot = filepath.Join(androidHome, "ndk-bundle")
+ }
_, err := os.Stat(ndkRoot)
if err != nil {
- return "", fmt.Errorf("The NDK was not found in $ANDROID_HOME/ndk-bundle (%q). Install the NDK with `sdkmanager 'ndk-bundle'`", ndkRoot)
+ return "", fmt.Errorf("The NDK was not found in $ANDROID_HOME/ndk-bundle (%q) nor in ANDROID_NDK_HOME. Install the NDK with `sdkmanager 'ndk-bundle'`", ndkRoot)
}
return ndkRoot, nil
}

+ 15
- 0
nix/status-go/gomobile/resolve-nix-android-sdk.patch View File

@@ -0,0 +1,15 @@
diff --git a/cmd/gomobile/bind_androidapp.go b/cmd/gomobile/bind_androidapp.go
index 3b01adc..76216fa 100644
--- a/cmd/gomobile/bind_androidapp.go
+++ b/cmd/gomobile/bind_androidapp.go
@@ -372,6 +372,10 @@ func androidAPIPath() (string, error) {
var apiVer int
for _, fi := range fis {
name := fi.Name()
+ // Resolve symlinked directories (this is how the Nix Android SDK package is built)
+ if fi2, err := os.Stat(filepath.Join(sdkDir.Name(), name)); err == nil {
+ fi = fi2
+ }
if !fi.IsDir() || !strings.HasPrefix(name, "android-") {
continue
}

+ 0
- 90
scripts/bundle-status-go.sh View File

@@ -1,90 +0,0 @@
#!/usr/bin/env sh

if [ -z $STATUS_GO_HOME ] ; then
echo "Please define STATUS_GO_HOME"
exit 1
fi
if [ -z $STATUS_REACT_HOME ] ; then
echo "Please define STATUS_REACT_HOME"
exit 1
fi
if [ $# -eq 0 ]; then
echo "Please specify platforms to bundle as discrete arguments (ios, android)"
exit 1
fi

set -euf

# Ensure we start with a clean state, so as to e.g., not reuse old native status-go bindings
if [ -z $DONT_CLEAN ] ; then
make clean
fi

for platform in "$@"; do
case $platform in
ios | android)
echo "Bundling $platform platform"

cd $STATUS_GO_HOME
;;
*)
echo "Undefined platform $platform"
exit 1
esac

case $platform in
ios)
# Build status-go artifact for iOS:
make statusgo-ios-simulator

# You should see iOS framework cross compilation done. This builds the following artifact:
#
# > (cd status-go && find . -iname "Statusgo.framework")
# ./build/bin/statusgo-ios-9.3-framework/Statusgo.framework
#
# You can get this by running:
# scripts/prepare-for-platform.sh {ios|android}
#
# Locally you can see it here:
# > (cd status-react && find . -iname "Statusgo.framework")
# ./modules/react-native-status/ios/RCTStatus/Statusgo.framework
# ./modules/react-native-status/ios/RCTStatus/Statusgo.framework/Statusgo.framework
#
# Instead we are going to manually overwrite it.

# For Xcode to pick up the new version, remove the whole framework first:
rm -r $STATUS_REACT_HOME/modules/react-native-status/ios/RCTStatus/Statusgo.framework/ || true

# Then copy over framework:
cp -R $STATUS_GO_HOME/build/bin/statusgo-ios-9.3-framework/Statusgo.framework $STATUS_REACT_HOME/modules/react-native-status/ios/RCTStatus/Statusgo.framework

# In Xcode, clean and build. If you have any scripts to do this, make sure that
# you don't accidentally run the mvn step to undo your manual install.
#

# It might also be a good idea to print something custom so you can easily tell
# the difference between an old and new version of status-go.

cd -

echo "[Done]"
echo "[You can now build in Xcode]"
;;
android)
# Build status-go artifact for Android:
make statusgo-android

target=$STATUS_REACT_HOME/modules/react-native-status/android/libs/status-im/status-go/local
[ -d $target ] || mkdir -p $target
# Copy over framework:
cp -R $STATUS_GO_HOME/build/bin/statusgo.aar $target/status-go-local.aar

# It might also be a good idea to print something custom so you can easily tell
# the difference between an old and new version of status-go.

cd -

echo "[Done]"
;;
esac
done

+ 9
- 5
scripts/lib/setup/installers.sh View File

@@ -23,14 +23,18 @@ function install_nix() {
echo "if [ -e ${HOME}/.nix-profile/etc/profile.d/nix.sh ]; then . ${HOME}/.nix-profile/etc/profile.d/nix.sh; fi # added by make setup Status script" >> ~/.bashrc
fi

local buildFlags=''
[ -n "$CI_ENVIRONMENT" ] && buildFlags='-v'
. ${HOME}/.nix-profile/etc/profile.d/nix.sh && \
NIX_CONF_DIR=$(cd "${BASH_SOURCE%/*}" && pwd)/nix \
nix-build --no-out-link -A env.all ${GIT_ROOT}/default.nix
nix build --no-link ${buildFlags} -f ${GIT_ROOT}/default.nix

echo -e "${YELLOW}**********************************************************************************************************"
echo "The Nix package manager was successfully installed. Please run \`make shell\` to initialize the Nix environment."
echo "If this doesn't work, you might have to sign out and back in, in order for the environment to be reloaded."
echo -e "**********************************************************************************************************${NC}"
if [ $? -eq 0 ]; then
echo -e "${YELLOW}**********************************************************************************************************"
echo "The Nix package manager was successfully installed. Please run \`make shell\` to initialize the Nix environment."
echo "If this doesn't work, you might have to sign out and back in, in order for the environment to be reloaded."
echo -e "**********************************************************************************************************${NC}"
fi
else
echo "Please see https://nixos.org/nix/manual/#chap-installation"
fi

+ 0
- 12
scripts/lib/setup/nix/desktop/windows/default.nix View File

@@ -1,12 +0,0 @@
{ stdenv, pkgs }:

with pkgs;
with stdenv;

let
baseImage = callPackage ./base-image { };

in
{
buildInputs = lib.optional isLinux [ conan nsis baseImage ];
}

+ 0
- 40
scripts/lib/setup/nix/mobile/android-ndk/default.nix View File

@@ -1,40 +0,0 @@
###
### TODO: This Nix expression is a poor-man's package that just wraps the Android NDK download
### Since the executables' dependencies don't point to /nix/store, it isn't a pure package
### so it won't work e.g. on NixOS
###
{ stdenv, fetchzip }:

let
ndk-version = "r17c";
archives = {
macosx = fetchzip {
url = "https://dl.google.com/android/repository/android-ndk-${ndk-version}-darwin-x86_64.zip";
sha256 = "0299m2l8jp773r9y1l9jbyy4xw2mvsz8gqv5b409gwclq8apip1w";
};
linux = fetchzip {
url = "https://dl.google.com/android/repository/android-ndk-${ndk-version}-linux-x86_64.zip";
sha256 = "02q1hy423syl868jdyaxjm44hn59cmni5019r811vinagvq3m7qi";
};
};

in stdenv.mkDerivation rec {
name = "android-ndk";
version = ndk-version;

src = if stdenv.isLinux then archives.linux else archives.macosx;

phases = [ "unpackPhase" "installPhase" ];
installPhase = ''
mkdir $out
cp -rv . $out
'';

meta = {
description = "The Android NDK is a toolset that lets you implement parts of your app in native code, using languages such as C and C++. For certain types of apps, this can help you reuse code libraries written in those languages.";
homepage = https://developer.android.com/ndk;
license = stdenv.lib.licenses.asl20;
maintainers = [ stdenv.lib.maintainers.pombeirp ];
platforms = stdenv.lib.platforms.unix;
};
}

+ 0
- 29
scripts/lib/setup/nix/mobile/default.nix View File

@@ -1,29 +0,0 @@
{ stdenv, pkgs, target-os ? "" }:

with pkgs;
with stdenv;

let
android-ndk = callPackage ./android-ndk { };
targetAndroid = {
"android" = true;
"" = true;
}.${target-os} or false;

in
{
buildInputs = [ bundler ruby ] ++ ## bundler/ruby used for fastlane
lib.optional targetAndroid [
android-ndk
openjdk
];
shellHook = lib.optionalString targetAndroid ''
export JAVA_HOME="${openjdk}"
export ANDROID_HOME=~/.status/Android/Sdk
export ANDROID_SDK_ROOT="$ANDROID_HOME"
export ANDROID_NDK_ROOT="${android-ndk}"
export ANDROID_NDK_HOME="${android-ndk}"
export ANDROID_NDK="${android-ndk}"
export PATH="$ANDROID_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools:$PATH"
'';
}

+ 14
- 52
scripts/prepare-for-platform.sh View File

@@ -11,15 +11,7 @@ NC='\033[0m'
PLATFORM=""
PLATFORM_FOLDER=""

DO_SPACE_URL=https://status-go.ams3.digitaloceanspaces.com
GITHUB_URL=https://github.com/status-im/status-go/releases
STATUS_GO_VER="$(cat STATUS_GO_VERSION)"

ANDROID_LIBS_DIR="$GIT_ROOT/android/app/libs"
STATUS_GO_DRO_ARCH="${ANDROID_LIBS_DIR}/status-go-${STATUS_GO_VER}.aar"

RCTSTATUS_DIR="$GIT_ROOT/modules/react-native-status/ios/RCTStatus"
STATUS_GO_IOS_ARCH="${RCTSTATUS_DIR}/status-go-ios-${STATUS_GO_VER}.zip"

#if no arguments passed, inform user about possible ones

@@ -62,47 +54,6 @@ fi

yarn install --frozen-lockfile

if [ "$PLATFORM" == 'mobile' ]; then
if [ "$1" == 'android' ]; then
outputPath=$STATUS_GO_DRO_ARCH
ext='.aar'
else
outputPath=$STATUS_GO_IOS_ARCH
ext='.zip'
fi

statusGoSentinelFile="$(dirname $outputPath)/.download.log"
if [ -f "$statusGoSentinelFile" ] && [ "$(cat $statusGoSentinelFile)" == "$STATUS_GO_VER" ]; then
echo "status-go artifact already downloaded!"
else
echo "Downloading status-go artifact from DigitalOcean Bucket to $outputPath"

set +e
mkdir -p $(dirname $outputPath)
curl --fail --silent --location \
"${DO_SPACE_URL}/status-go-$1-${STATUS_GO_VER}${ext}" \
--output "$outputPath"
set -e
if [ $? -ne 0 ]; then
echo "Failed to download from DigitalOcean Bucket, checking GitHub..."
set +e
curl --fail --silent --location \
"${GITHUB_URL}/download/${STATUS_GO_VER}/status-go-$1.zip" \
--output "$outputPath"
set -e
if [ $? -ne 0 ]; then
echo "Failed to download from GitHub!"
echo "Please check the contents of your STATUS_GO_VERSION are correct."
echo "Verify the version has been uploaded:"
echo " * ${DO_SPACE_URL}/index.html"
echo " * $GITHUB_URL"
exit 1
fi
fi
echo "$STATUS_GO_VER" > $statusGoSentinelFile
fi
fi

case $1 in
android)
set -e
@@ -111,10 +62,21 @@ case $1 in
fi
;;
ios)
if [ ! -d "$RCTSTATUS_DIR/Statusgo.framework" ]; then
unzip -q -o "$STATUS_GO_IOS_ARCH" -d "$RCTSTATUS_DIR" && rm $STATUS_GO_IOS_ARCH
targetBasename='Statusgo.framework'
# Compare target folder with source to see if copying is required
if [ -d "$RCTSTATUS_DIR/$targetBasename" ] && \
diff -q --no-dereference --recursive $RCTSTATUS_DIR/$targetBasename/ $RCTSTATUS_FILEPATH/ > /dev/null; then
echo "$RCTSTATUS_DIR/$targetBasename already in place"
else
sourceBasename="$(basename $RCTSTATUS_FILEPATH)"
echo "Copying $sourceBasename from Nix store to $RCTSTATUS_DIR"
rm -rf "$RCTSTATUS_DIR/$targetBasename/"
cp -a $RCTSTATUS_FILEPATH $RCTSTATUS_DIR && chmod -R 755 "$RCTSTATUS_DIR/$targetBasename"
if [ "$sourceBasename" != "$targetBasename" ]; then
mv "$RCTSTATUS_DIR/$sourceBasename" "$RCTSTATUS_DIR/$targetBasename"
fi
if [ "$(uname)" == 'Darwin' ]; then
# TODO: remove this patch when we upgrade to RN 0.57+
# TODO: remove this patch when we upgrade to a RN version that plays well with the modern build system
git apply --check $GIT_ROOT/ios/patches/ios-legacy-build-system.patch 2> /dev/null && \
git apply $GIT_ROOT/ios/patches/ios-legacy-build-system.patch || \
echo "Patch already applied"

+ 12
- 6
scripts/update-status-go.sh View File

@@ -2,6 +2,8 @@

set -eof pipefail

GIT_ROOT=$(git rev-parse --show-toplevel)

usage() {
printf "%s is a tool for upgrading status-go to a given version.\n" "$(basename "$0")"
printf "The given version must be uploaded to Artifactory first.\n\n"
@@ -11,10 +13,6 @@ usage() {
printf " %s develop-g12345678\n" "$(basename "$0")"
}

sedi () {
sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i "" "$@"
}

if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
usage
exit 1
@@ -25,7 +23,15 @@ if [ $# -eq 0 ]; then
exit 1
fi

STATUSGO_OWNER="$(cat ${GIT_ROOT}/STATUS_GO_OWNER)"
STATUSGO_VERSION="v${1#"v"}"
if [ "$STATUSGO_OWNER" == 'status-im' ] && [ "$STATUSGO_VERSION" != "$1" ]; then
echo "status-go release branches should include the v prefix!"
echo "Please create a new branch called $STATUSGO_VERSION"
exit 1
fi
STATUSGO_VERSION=$1
STATUSGO_VERSION=${STATUSGO_VERSION#"v"}
STATUSGO_SHA256=$(nix-prefetch-url --unpack https://github.com/${STATUSGO_OWNER}/status-go/archive/${STATUSGO_VERSION}.zip)

echo $STATUSGO_VERSION > STATUS_GO_VERSION
echo $STATUSGO_VERSION > ${GIT_ROOT}/STATUS_GO_VERSION
echo $STATUSGO_SHA256 > ${GIT_ROOT}/STATUS_GO_SHA256

Loading…
Cancel
Save