nix: use jsbundle derivation for iOS as well
For some unknown to me reason we are using a different Yarn call to Shadow-cljs to generate the JSBundle for iOS builds, while the one created by the Android derivation shoudl be exactly the same. I'm changing the target to just be `make jsbundle` while keeping aliases referencing old naming, and moving things around in `nix` folder to reflect the fact that the derivation is no longer Android-specific. Also, crucially, I've changed the `import` in `index.js` to use the `./result/index.js` path, since that's what Nix creates. I'm not sure if this clashes with any developer workflow that takes place locally, so I'd appreciate some testing from developers. Depends on: https://github.com/status-im/status-jenkins-lib/pull/67 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
6858884c83
commit
58d20967ae
32
Makefile
32
Makefile
|
@ -218,23 +218,18 @@ release-android: keystore build-android ##@build Build signed Android APK
|
||||||
|
|
||||||
release-ios: export TARGET := ios
|
release-ios: export TARGET := ios
|
||||||
release-ios: export BUILD_ENV ?= prod
|
release-ios: export BUILD_ENV ?= prod
|
||||||
release-ios: watchman-clean ##@build Build release for iOS release
|
release-ios: watchman-clean ios-clean jsbundle ##@build Build release for iOS release
|
||||||
@git clean -dxf -f target/ios && \
|
xcodebuild \
|
||||||
$(MAKE) jsbundle-ios && \
|
-scheme StatusIm \
|
||||||
xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration Release -destination 'generic/platform=iOS' -UseModernBuildSystem=N clean archive
|
-configuration Release \
|
||||||
|
-workspace ios/StatusIm.xcworkspace \
|
||||||
|
-destination 'generic/platform=iOS' \
|
||||||
|
-UseModernBuildSystem=N clean archive
|
||||||
|
|
||||||
jsbundle-android: SHELL := /bin/sh
|
jsbundle: SHELL := /bin/sh
|
||||||
jsbundle-android: export TARGET := android
|
jsbundle: export BUILD_ENV ?= prod
|
||||||
jsbundle-android: export BUILD_ENV ?= prod
|
jsbundle: ##@build Build JavaScript and Clojurescript bundle for iOS and Android
|
||||||
jsbundle-android: ##@jsbundle Compile JavaScript and Clojurescript into app directory
|
nix/scripts/build.sh targets.mobile.jsbundle
|
||||||
# Call nix-build to build the 'targets.mobile.android.jsbundle' attribute and copy the.js files to the project root
|
|
||||||
nix/scripts/build.sh targets.mobile.android.jsbundle && \
|
|
||||||
mv result/*.js ./
|
|
||||||
|
|
||||||
jsbundle-ios: export TARGET := ios
|
|
||||||
jsbundle-ios: export BUILD_ENV ?= prod
|
|
||||||
jsbundle-ios: ##@jsbundle Compile JavaScript and Clojure into index.ios.js
|
|
||||||
yarn shadow-cljs release mobile
|
|
||||||
|
|
||||||
#--------------
|
#--------------
|
||||||
# status-go lib
|
# status-go lib
|
||||||
|
@ -365,6 +360,7 @@ component-test: ##@test Run component tests once in NodeJS
|
||||||
yarn shadow-cljs compile component-test && \
|
yarn shadow-cljs compile component-test && \
|
||||||
jest --config=test/jest/jest.config.js
|
jest --config=test/jest/jest.config.js
|
||||||
|
|
||||||
|
#--------------
|
||||||
# Other
|
# Other
|
||||||
#--------------
|
#--------------
|
||||||
|
|
||||||
|
@ -373,6 +369,10 @@ geth-connect: ##@other Connect to Geth on the device
|
||||||
adb forward tcp:8545 tcp:8545 && \
|
adb forward tcp:8545 tcp:8545 && \
|
||||||
build/bin/geth attach http://localhost:8545
|
build/bin/geth attach http://localhost:8545
|
||||||
|
|
||||||
|
ios-clean: SHELL := /bin/sh
|
||||||
|
ios-clean: ##@prepare Clean iOS build artifacts
|
||||||
|
git clean -dxf -f target/ios
|
||||||
|
|
||||||
android-clean: export TARGET := gradle
|
android-clean: export TARGET := gradle
|
||||||
android-clean: ##@prepare Clean Gradle state
|
android-clean: ##@prepare Clean Gradle state
|
||||||
git clean -dxf -f ./android/app/build; \
|
git clean -dxf -f ./android/app/build; \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
library 'status-jenkins-lib@v1.7.6'
|
library 'status-jenkins-lib@v1.7.7'
|
||||||
|
|
||||||
/* Options section can't access functions in objects. */
|
/* Options section can't access functions in objects. */
|
||||||
def isPRBuild = utils.isPRBuild()
|
def isPRBuild = utils.isPRBuild()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
library 'status-jenkins-lib@v1.7.6'
|
library 'status-jenkins-lib@v1.7.7'
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent { label 'linux' }
|
agent { label 'linux' }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
library 'status-jenkins-lib@v1.7.6'
|
library 'status-jenkins-lib@v1.7.7'
|
||||||
|
|
||||||
/* Options section can't access functions in objects. */
|
/* Options section can't access functions in objects. */
|
||||||
def isPRBuild = utils.isPRBuild()
|
def isPRBuild = utils.isPRBuild()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
library 'status-jenkins-lib@v1.7.6'
|
library 'status-jenkins-lib@v1.7.7'
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent { label params.AGENT_LABEL }
|
agent { label params.AGENT_LABEL }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
library 'status-jenkins-lib@v1.7.6'
|
library 'status-jenkins-lib@v1.7.7'
|
||||||
|
|
||||||
/* Options section can't access functions in objects. */
|
/* Options section can't access functions in objects. */
|
||||||
def isPRBuild = utils.isPRBuild()
|
def isPRBuild = utils.isPRBuild()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
library 'status-jenkins-lib@v1.7.6'
|
library 'status-jenkins-lib@v1.7.7'
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
library 'status-jenkins-lib@v1.7.6'
|
library 'status-jenkins-lib@v1.7.7'
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
library 'status-jenkins-lib@v1.7.6'
|
library 'status-jenkins-lib@v1.7.7'
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
library 'status-jenkins-lib@v1.7.6'
|
library 'status-jenkins-lib@v1.7.7'
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent { label 'macos' }
|
agent { label 'macos' }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
library 'status-jenkins-lib@v1.7.6'
|
library 'status-jenkins-lib@v1.7.7'
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent { label 'linux' }
|
agent { label 'linux' }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
library 'status-jenkins-lib@v1.7.6'
|
library 'status-jenkins-lib@v1.7.7'
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent {
|
agent {
|
||||||
|
|
2
index.js
2
index.js
|
@ -1,2 +1,2 @@
|
||||||
import "node-libs-react-native/globals";
|
import "node-libs-react-native/globals";
|
||||||
import "./app/index.js";
|
import "./result/index.js";
|
||||||
|
|
|
@ -55,12 +55,12 @@ The [`nix/scripts/shell.sh`](./scripts/shell.sh) script is essentially a wrapper
|
||||||
|
|
||||||
# Building
|
# Building
|
||||||
|
|
||||||
We will use the `make jsbundle-android` target as an example of a derivation you can build using Nix:
|
We will use the `make jsbundle` target as an example of a derivation you can build using Nix:
|
||||||
|
|
||||||
1. `make jsbundle-android` is called by developer
|
1. `make jsbundle` is called by developer
|
||||||
2. `make` calls `nix/scripts/build.sh targets.mobile.android.jsbundle`
|
2. `make` calls `nix/scripts/build.sh targets.mobile.jsbundle`
|
||||||
3. [`build.sh`](/nix/scripts/build.sh) calls `nix-build --attr targets.mobile.android.jsbundle` with extra arguments
|
3. [`build.sh`](/nix/scripts/build.sh) calls `nix-build --attr targets.mobile.jsbundle` with extra arguments
|
||||||
4. `nix-build` builds the derivation from [`nix/mobile/android/jsbundle/default.nix`](/nix/mobile/android/jsbundle/default.nix)
|
4. `nix-build` builds the derivation from [`nix/mobile/jsbundle/default.nix`](/nix/mobile/jsbundle/default.nix)
|
||||||
|
|
||||||
The same can be done for other targets like `targets.mobile.android.release`.
|
The same can be done for other targets like `targets.mobile.android.release`.
|
||||||
Except in that case extra arguments are required which is why the [`scripts/release-android.sh`](/scripts/release-android.sh) is used in the `make release-android` target.
|
Except in that case extra arguments are required which is why the [`scripts/release-android.sh`](/scripts/release-android.sh) is used in the `make release-android` target.
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
{ pkgs, deps, callPackage, mkShell
|
{ pkgs, deps, callPackage, mkShell
|
||||||
, status-go, androidPkgs, androidShell }:
|
, jsbundle, status-go, androidPkgs, androidShell }:
|
||||||
|
|
||||||
let
|
rec {
|
||||||
# Import a jsbundle compiled out of clojure codebase
|
release = callPackage ./release.nix {
|
||||||
jsbundle = callPackage ./jsbundle { };
|
inherit jsbundle status-go;
|
||||||
|
};
|
||||||
release = callPackage ./release.nix { inherit jsbundle status-go; };
|
|
||||||
in {
|
|
||||||
# TARGETS
|
|
||||||
inherit release jsbundle;
|
|
||||||
|
|
||||||
shell = mkShell {
|
shell = mkShell {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
|
|
|
@ -46,7 +46,7 @@ in stdenv.mkDerivation rec {
|
||||||
root = path;
|
root = path;
|
||||||
include = [
|
include = [
|
||||||
"package.json" "yarn.lock" "metro.config.js" "babel.config.js"
|
"package.json" "yarn.lock" "metro.config.js" "babel.config.js"
|
||||||
"resources/.*" "translations/.*" "src/js/.*"
|
"resources/.*" "translations/.*" "src/js/.*" "index.js"
|
||||||
"modules/react-native-status/android.*" "android/.*"
|
"modules/react-native-status/android.*" "android/.*"
|
||||||
envFileName "VERSION" "status-go-version.json" "react-native.config.js"
|
envFileName "VERSION" "status-go-version.json" "react-native.config.js"
|
||||||
];
|
];
|
||||||
|
@ -94,8 +94,10 @@ in stdenv.mkDerivation rec {
|
||||||
# Export all vars from .env file
|
# Export all vars from .env file
|
||||||
export $(cut -d= -f1 .env)
|
export $(cut -d= -f1 .env)
|
||||||
|
|
||||||
# Copy index.js and app/ input files
|
# Symlink React Native entrypoint.
|
||||||
cp -ra --no-preserve=ownership ${builtJsBundle}/* ./
|
cp -Lr ${builtJsBundle} ./result
|
||||||
|
pwd
|
||||||
|
find -L result
|
||||||
|
|
||||||
# Copy android/ directory
|
# Copy android/ directory
|
||||||
mkdir -p ./android/build
|
mkdir -p ./android/build
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
let
|
let
|
||||||
fastlane = callPackage ./fastlane { };
|
fastlane = callPackage ./fastlane { };
|
||||||
|
|
||||||
|
jsbundle = callPackage ./jsbundle { };
|
||||||
|
|
||||||
android = callPackage ./android {
|
android = callPackage ./android {
|
||||||
|
inherit jsbundle;
|
||||||
status-go = status-go.mobile.android;
|
status-go = status-go.mobile.android;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26,5 +29,5 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
# TARGETS
|
# TARGETS
|
||||||
inherit android ios fastlane;
|
inherit android ios fastlane jsbundle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
{ secretsFile ? "" }:
|
{ secretsFile ? "" }:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "status-mobile-build-jsbundle-android";
|
name = "status-mobile-jsbundle";
|
||||||
src =
|
src =
|
||||||
let path = ./../../../..;
|
let path = ./../../..;
|
||||||
# We use builtins.path so that we can name the resulting derivation,
|
# We use builtins.path so that we can name the resulting derivation,
|
||||||
# otherwise the name would be taken from the checkout directory,
|
# otherwise the name would be taken from the checkout directory,
|
||||||
# which is outside of our control inherit path;
|
# which is outside of our control inherit path;
|
||||||
|
@ -25,7 +25,7 @@ stdenv.mkDerivation {
|
||||||
ignoreVCS = false;
|
ignoreVCS = false;
|
||||||
include = [
|
include = [
|
||||||
"VERSION" "BUILD_NUMBER" "scripts/version/.*"
|
"VERSION" "BUILD_NUMBER" "scripts/version/.*"
|
||||||
"src/.*" "shadow-cljs.edn" "index.js"
|
"src/.*" "shadow-cljs.edn"
|
||||||
# I want to avoid including the whole .git directory
|
# I want to avoid including the whole .git directory
|
||||||
".git/HEAD" ".git/objects" ".git/refs/heads/.*"
|
".git/HEAD" ".git/objects" ".git/refs/heads/.*"
|
||||||
# shadow-cljs expects these for deps resolution
|
# shadow-cljs expects these for deps resolution
|
||||||
|
@ -77,6 +77,6 @@ stdenv.mkDerivation {
|
||||||
'';
|
'';
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cp -r index.js app $out/
|
cp -r result/* $out/
|
||||||
'';
|
'';
|
||||||
}
|
}
|
|
@ -37,7 +37,8 @@
|
||||||
:builds
|
:builds
|
||||||
{:mobile
|
{:mobile
|
||||||
{:target :react-native
|
{:target :react-native
|
||||||
:output-dir "app"
|
;; To match the folder created by Nix build of JSBundle.
|
||||||
|
:output-dir "result"
|
||||||
:init-fn status-im2.core/init
|
:init-fn status-im2.core/init
|
||||||
;; When false, the Shadow-CLJS watcher won't automatically refresh
|
;; When false, the Shadow-CLJS watcher won't automatically refresh
|
||||||
;; the target files (a.k.a hot reload). When false, you can manually
|
;; the target files (a.k.a hot reload). When false, you can manually
|
||||||
|
|
Loading…
Reference in New Issue