git ssb

1+

Daan Patchwork / manyverse



Commit 3d8fa3d5b0f328e521aab2c74cb44c5154a133bc

ux: [and] make APK size 4MB smaller

Andre Staltz committed on 10/26/2020, 10:36:54 AM
Parent: a39b6fb4146143b7f26d95bf2c161bf7b923cc74

Files changed

src/backend/package-lock.jsonchanged
tools/backend/remove-unused-files.shdeleted
tools/backend/post-remove-unused-files.shadded
tools/backend/pre-remove-unused-files.shadded
tools/build-backend.jschanged
src/backend/package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 243490 bytes
New file size: 243618 bytes
tools/backend/remove-unused-files.shView
@@ -1,32 +1,0 @@
1-#!/bin/bash
2-
3-# Any copyright is dedicated to the Public Domain.
4-# http://creativecommons.org/publicdomain/zero/1.0/
5-
6-set -eEu -o pipefail
7-shopt -s extdebug
8-IFS=$'\n\t'
9-trap 'onFailure $?' ERR
10-
11-function onFailure() {
12- echo "Unhandled script error $1 at ${BASH_SOURCE[0]}:${BASH_LINENO[0]}" >&2
13- exit 1
14-}
15-
16-# make a list of things to delete then delete them
17-# `-exec rm -rf {} \;` confuses find because the recursion can no longer find a step (depth-first traversal (-d) would also work)
18-# GNU find and modern BSD/macOS find have a `-delete` operator
19-find ./nodejs-assets/nodejs-project/node_modules \
20- -type d \
21- \( \
22- -name "darwin-x64" \
23- -o -name "win32-ia32" \
24- -o -name "win32-x64" \
25- \) \
26- -print0 | xargs -0 rm -rf # delete everything in the list
27-find ./nodejs-assets/nodejs-project/node_modules \
28- -type f \
29- \( \
30- -name "electron-napi.node" \
31- \) \
32- -print0 | xargs -0 rm -rf # delete everything in the list
tools/backend/post-remove-unused-files.shView
@@ -1,0 +1,40 @@
1+#!/bin/bash
2+
3+# Any copyright is dedicated to the Public Domain.
4+# http://creativecommons.org/publicdomain/zero/1.0/
5+
6+set -eEu -o pipefail
7+shopt -s extdebug
8+IFS=$'\n\t'
9+trap 'onFailure $?' ERR
10+
11+function onFailure() {
12+ echo "Unhandled script error $1 at ${BASH_SOURCE[0]}:${BASH_LINENO[0]}" >&2
13+ exit 1
14+}
15+
16+declare -a archs=(
17+ "armeabi-v7a"
18+ "arm64-v8a"
19+ # "x86"
20+ # "x86_64"
21+)
22+
23+for arch in "${archs[@]}"
24+do
25+ pushd ./android/build/nodejs-native-assets/nodejs-native-assets-$arch
26+
27+ # Remove obj.target directories
28+ find . \
29+ -type d \
30+ -name "obj.target" \
31+ -print0 | xargs -0 rm -rf
32+
33+ # Update dir.list file
34+ sed -i '/obj\.target/d' dir.list
35+
36+ # Update file.list file
37+ sed -i '/obj\.target/d' file.list
38+
39+ popd
40+done
tools/backend/pre-remove-unused-files.shView
@@ -1,0 +1,39 @@
1+#!/bin/bash
2+
3+# Any copyright is dedicated to the Public Domain.
4+# http://creativecommons.org/publicdomain/zero/1.0/
5+
6+set -eEu -o pipefail
7+shopt -s extdebug
8+IFS=$'\n\t'
9+trap 'onFailure $?' ERR
10+
11+function onFailure() {
12+ echo "Unhandled script error $1 at ${BASH_SOURCE[0]}:${BASH_LINENO[0]}" >&2
13+ exit 1
14+}
15+
16+pushd ./nodejs-assets/nodejs-project/node_modules
17+
18+# Remove leveldown because it's replaced by leveldown-nodejs-mobile
19+rm -rf leveldown
20+
21+# Remove directories that have these names
22+find . \
23+ -type d \
24+ \( \
25+ -name "obj.target" \
26+ -o \
27+ -name "prebuilds" \
28+ \) \
29+ -print0 | xargs -0 rm -rf
30+
31+# Remove files that have these names
32+find . \
33+ -type f \
34+ \( \
35+ -name "electron-napi.node" \
36+ \) \
37+ -print0 | xargs -0 rm -rf
38+
39+popd
tools/build-backend.jsView
@@ -39,9 +39,9 @@
3939 console.log(stdout);
4040 }
4141 }
4242
43-(async function() {
43+(async function () {
4444 await runAndReport('Compile TypeScript', exec('npm run lib'));
4545
4646 if (targetPlatform === 'desktop') {
4747 await runAndReport(
@@ -88,10 +88,10 @@
8888 }
8989
9090 if (targetPlatform === 'android' || targetPlatform === 'ios') {
9191 await runAndReport(
92- 'Remove unused files meant for macOS or Windows or Electron',
93- exec('./tools/backend/remove-unused-files.sh'),
92+ 'Pre-remove files not necessary for Android nor iOS',
93+ exec('./tools/backend/pre-remove-unused-files.sh'),
9494 );
9595 }
9696
9797 if (targetPlatform === 'android') {
@@ -102,8 +102,15 @@
102102 }),
103103 );
104104 }
105105
106+ if (targetPlatform === 'android') {
107+ await runAndReport(
108+ 'Post-remove files not necessary for Android',
109+ exec('./tools/backend/post-remove-unused-files.sh'),
110+ );
111+ }
112+
106113 if (targetPlatform === 'desktop') {
107114 await runAndReport(
108115 'Bundle and minify backend JS into one file',
109116 exec('./tools/backend/noderify-desktop.sh'),

Built with git-ssb-web