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:
Jakub Sokołowski 2023-05-16 18:42:56 +02:00
parent 6858884c83
commit 58d20967ae
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
19 changed files with 53 additions and 51 deletions

View File

@ -218,23 +218,18 @@ release-android: keystore build-android ##@build Build signed Android APK
release-ios: export TARGET := ios
release-ios: export BUILD_ENV ?= prod
release-ios: watchman-clean ##@build Build release for iOS release
@git clean -dxf -f target/ios && \
$(MAKE) jsbundle-ios && \
xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration Release -destination 'generic/platform=iOS' -UseModernBuildSystem=N clean archive
release-ios: watchman-clean ios-clean jsbundle ##@build Build release for iOS release
xcodebuild \
-scheme StatusIm \
-configuration Release \
-workspace ios/StatusIm.xcworkspace \
-destination 'generic/platform=iOS' \
-UseModernBuildSystem=N clean archive
jsbundle-android: SHELL := /bin/sh
jsbundle-android: export TARGET := android
jsbundle-android: export BUILD_ENV ?= prod
jsbundle-android: ##@jsbundle Compile JavaScript and Clojurescript into app directory
# 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
jsbundle: SHELL := /bin/sh
jsbundle: export BUILD_ENV ?= prod
jsbundle: ##@build Build JavaScript and Clojurescript bundle for iOS and Android
nix/scripts/build.sh targets.mobile.jsbundle
#--------------
# status-go lib
@ -365,6 +360,7 @@ component-test: ##@test Run component tests once in NodeJS
yarn shadow-cljs compile component-test && \
jest --config=test/jest/jest.config.js
#--------------
# Other
#--------------
@ -373,6 +369,10 @@ geth-connect: ##@other Connect to Geth on the device
adb forward tcp:8545 tcp: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: ##@prepare Clean Gradle state
git clean -dxf -f ./android/app/build; \

View File

@ -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. */
def isPRBuild = utils.isPRBuild()

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.7.6'
library 'status-jenkins-lib@v1.7.7'
pipeline {
agent { label 'linux' }

View File

@ -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. */
def isPRBuild = utils.isPRBuild()

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.7.6'
library 'status-jenkins-lib@v1.7.7'
pipeline {
agent { label params.AGENT_LABEL }

View File

@ -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. */
def isPRBuild = utils.isPRBuild()

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.7.6'
library 'status-jenkins-lib@v1.7.7'
pipeline {

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.7.6'
library 'status-jenkins-lib@v1.7.7'
pipeline {

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.7.6'
library 'status-jenkins-lib@v1.7.7'
pipeline {

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.7.6'
library 'status-jenkins-lib@v1.7.7'
pipeline {
agent { label 'macos' }

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.7.6'
library 'status-jenkins-lib@v1.7.7'
pipeline {
agent { label 'linux' }

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.7.6'
library 'status-jenkins-lib@v1.7.7'
pipeline {
agent {

View File

@ -1,2 +1,2 @@
import "node-libs-react-native/globals";
import "./app/index.js";
import "./result/index.js";

View File

@ -55,12 +55,12 @@ The [`nix/scripts/shell.sh`](./scripts/shell.sh) script is essentially a wrapper
# 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
2. `make` calls `nix/scripts/build.sh targets.mobile.android.jsbundle`
3. [`build.sh`](/nix/scripts/build.sh) calls `nix-build --attr targets.mobile.android.jsbundle` with extra arguments
4. `nix-build` builds the derivation from [`nix/mobile/android/jsbundle/default.nix`](/nix/mobile/android/jsbundle/default.nix)
1. `make jsbundle` is called by developer
2. `make` calls `nix/scripts/build.sh targets.mobile.jsbundle`
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/jsbundle/default.nix`](/nix/mobile/jsbundle/default.nix)
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.

View File

@ -1,14 +1,10 @@
{ pkgs, deps, callPackage, mkShell
, status-go, androidPkgs, androidShell }:
, jsbundle, status-go, androidPkgs, androidShell }:
let
# Import a jsbundle compiled out of clojure codebase
jsbundle = callPackage ./jsbundle { };
release = callPackage ./release.nix { inherit jsbundle status-go; };
in {
# TARGETS
inherit release jsbundle;
rec {
release = callPackage ./release.nix {
inherit jsbundle status-go;
};
shell = mkShell {
buildInputs = with pkgs; [

View File

@ -46,7 +46,7 @@ in stdenv.mkDerivation rec {
root = path;
include = [
"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/.*"
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 $(cut -d= -f1 .env)
# Copy index.js and app/ input files
cp -ra --no-preserve=ownership ${builtJsBundle}/* ./
# Symlink React Native entrypoint.
cp -Lr ${builtJsBundle} ./result
pwd
find -L result
# Copy android/ directory
mkdir -p ./android/build

View File

@ -3,7 +3,10 @@
let
fastlane = callPackage ./fastlane { };
jsbundle = callPackage ./jsbundle { };
android = callPackage ./android {
inherit jsbundle;
status-go = status-go.mobile.android;
};
@ -26,5 +29,5 @@ in {
};
# TARGETS
inherit android ios fastlane;
inherit android ios fastlane jsbundle;
}

View File

@ -8,9 +8,9 @@
{ secretsFile ? "" }:
stdenv.mkDerivation {
name = "status-mobile-build-jsbundle-android";
name = "status-mobile-jsbundle";
src =
let path = ./../../../..;
let path = ./../../..;
# We use builtins.path so that we can name the resulting derivation,
# otherwise the name would be taken from the checkout directory,
# which is outside of our control inherit path;
@ -25,7 +25,7 @@ stdenv.mkDerivation {
ignoreVCS = false;
include = [
"VERSION" "BUILD_NUMBER" "scripts/version/.*"
"src/.*" "shadow-cljs.edn" "index.js"
"src/.*" "shadow-cljs.edn"
# I want to avoid including the whole .git directory
".git/HEAD" ".git/objects" ".git/refs/heads/.*"
# shadow-cljs expects these for deps resolution
@ -77,6 +77,6 @@ stdenv.mkDerivation {
'';
installPhase = ''
mkdir -p $out
cp -r index.js app $out/
cp -r result/* $out/
'';
}

View File

@ -37,7 +37,8 @@
:builds
{:mobile
{: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
;; When false, the Shadow-CLJS watcher won't automatically refresh
;; the target files (a.k.a hot reload). When false, you can manually