Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
c19b7818
Commit
c19b7818
authored
Aug 20, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Read props directly in Gradle
parent
c0b750a0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
72 deletions
+43
-72
build.gradle
app/build.gradle
+15
-2
build.py
build.py
+23
-69
config.prop.sample
config.prop.sample
+5
-1
No files found.
app/build.gradle
View file @
c19b7818
apply
plugin:
'com.android.application'
apply
plugin:
'com.android.application'
def
configProps
=
new
Properties
()
configProps
.
load
(
new
FileInputStream
(
rootProject
.
file
(
'config.prop'
)))
android
{
android
{
compileSdkVersion
rootProject
.
ext
.
compileSdkVersion
compileSdkVersion
rootProject
.
ext
.
compileSdkVersion
buildToolsVersion
rootProject
.
ext
.
buildToolsVersion
buildToolsVersion
rootProject
.
ext
.
buildToolsVersion
...
@@ -10,11 +13,21 @@ android {
...
@@ -10,11 +13,21 @@ android {
targetSdkVersion
rootProject
.
ext
.
compileSdkVersion
targetSdkVersion
rootProject
.
ext
.
compileSdkVersion
}
}
signingConfigs
{
config
{
storeFile
rootProject
.
file
(
'release-key.jks'
)
storePassword
configProps
[
'keyStorePass'
]
keyAlias
configProps
[
'keyAlias'
]
keyPassword
configProps
[
'keyPass'
]
}
}
buildTypes
{
buildTypes
{
release
{
release
{
minifyEnabled
true
minifyEnabled
true
shrinkResources
true
shrinkResources
true
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
signingConfig
signingConfigs
.
config
}
}
}
}
...
@@ -22,8 +35,8 @@ android {
...
@@ -22,8 +35,8 @@ android {
productFlavors
{
productFlavors
{
full
{
full
{
version
Code
134
version
Name
configProps
[
'appVersion'
]
version
Name
"5.8.3"
version
Code
configProps
[
'appVersionCode'
]
as
Integer
javaCompileOptions
{
javaCompileOptions
{
annotationProcessorOptions
{
annotationProcessorOptions
{
argument
(
'butterknife.debuggable'
,
'false'
)
argument
(
'butterknife.debuggable'
,
'false'
)
...
...
build.py
View file @
c19b7818
...
@@ -123,29 +123,6 @@ def sign_zip(unsigned, output, release):
...
@@ -123,29 +123,6 @@ def sign_zip(unsigned, output, release):
if
proc
.
returncode
!=
0
:
if
proc
.
returncode
!=
0
:
error
(
'Signing zip failed!'
)
error
(
'Signing zip failed!'
)
def
sign_apk
(
source
,
target
):
# Find the latest build tools
build_tool
=
os
.
path
.
join
(
os
.
environ
[
'ANDROID_HOME'
],
'build-tools'
,
sorted
(
os
.
listdir
(
os
.
path
.
join
(
os
.
environ
[
'ANDROID_HOME'
],
'build-tools'
)))[
-
1
])
proc
=
execv
([
os
.
path
.
join
(
build_tool
,
'zipalign'
),
'-vpf'
,
'4'
,
source
,
target
],
subprocess
.
DEVNULL
)
if
proc
.
returncode
!=
0
:
error
(
'Zipalign Magisk Manager failed!'
)
# Find apksigner.jar
apksigner
=
''
for
root
,
dirs
,
files
in
os
.
walk
(
build_tool
):
if
'apksigner.jar'
in
files
:
apksigner
=
os
.
path
.
join
(
root
,
'apksigner.jar'
)
break
if
not
apksigner
:
error
(
'Cannot find apksigner.jar in Android SDK build tools'
)
proc
=
execv
([
'java'
,
'-jar'
,
apksigner
,
'sign'
,
'--ks'
,
keystore
,
'--ks-pass'
,
'pass:'
+
config
[
'keyStorePass'
],
'--ks-key-alias'
,
config
[
'keyAlias'
],
'--key-pass'
,
'pass:'
+
config
[
'keyPass'
],
target
])
if
proc
.
returncode
!=
0
:
error
(
'Release sign Magisk Manager failed!'
)
def
binary_dump
(
src
,
out
,
var_name
):
def
binary_dump
(
src
,
out
,
var_name
):
out
.
write
(
'const static unsigned char {}[] = {{'
.
format
(
var_name
))
out
.
write
(
'const static unsigned char {}[] = {{'
.
format
(
var_name
))
for
i
,
c
in
enumerate
(
xz
(
src
.
read
())):
for
i
,
c
in
enumerate
(
xz
(
src
.
read
())):
...
@@ -244,60 +221,37 @@ def build_binary(args):
...
@@ -244,60 +221,37 @@ def build_binary(args):
error
(
'Build binaries failed!'
)
error
(
'Build binaries failed!'
)
collect_binary
()
collect_binary
()
def
build_apk
(
args
):
def
build_apk
(
args
,
flavor
):
header
(
'* Building
Magisk Manager'
)
header
(
'* Building
{} Magisk Manager'
.
format
(
flavor
)
)
source
=
os
.
path
.
join
(
'scripts'
,
'util_functions.sh'
)
buildType
=
'Release'
if
args
.
release
else
'Debug'
target
=
os
.
path
.
join
(
'app'
,
'src'
,
'full'
,
'res'
,
'raw'
,
'util_functions.sh'
)
cp
(
source
,
target
)
if
args
.
release
:
proc
=
execv
([
gradlew
,
'app:assemble'
+
flavor
+
buildType
])
proc
=
execv
([
gradlew
,
'app:assembleFullRelease'
])
if
proc
.
returncode
!=
0
:
if
proc
.
returncode
!=
0
:
error
(
'Build Magisk Manager failed!'
)
error
(
'Build Magisk Manager failed!'
)
source
=
os
.
path
.
join
(
'app'
,
'build'
,
'outputs'
,
'apk'
,
'full'
,
'release'
,
'app-full-release-unsigned.apk'
)
target
=
os
.
path
.
join
(
config
[
'outdir'
],
'app-release.apk'
)
sign_apk
(
source
,
target
)
rm
(
source
)
else
:
proc
=
execv
([
gradlew
,
'app:assembleFullDebug'
])
if
proc
.
returncode
!=
0
:
error
(
'Build Magisk Manager failed!'
)
source
=
os
.
path
.
join
(
'app'
,
'build'
,
'outputs'
,
'apk'
,
'full'
,
'debug'
,
'app-full-debug.apk'
)
flavor
=
flavor
.
lower
(
)
target
=
os
.
path
.
join
(
config
[
'outdir'
],
'app-debug.apk'
)
buildType
=
buildType
.
lower
(
)
mv
(
source
,
target
)
apk
=
'app-{}-{}.apk'
.
format
(
flavor
,
buildType
)
source
=
os
.
path
.
join
(
'app'
,
'build'
,
'outputs'
,
'apk'
,
flavor
,
buildType
,
apk
)
target
=
os
.
path
.
join
(
config
[
'outdir'
],
apk
)
mv
(
source
,
target
)
header
(
'Output: '
+
target
)
header
(
'Output: '
+
target
)
return
target
def
build_stub
(
args
):
def
build_app
(
args
):
header
(
'* Building stub Magisk Manager'
)
source
=
os
.
path
.
join
(
'scripts'
,
'util_functions.sh'
)
target
=
os
.
path
.
join
(
'app'
,
'src'
,
'full'
,
'res'
,
'raw'
,
'util_functions.sh'
)
if
args
.
release
:
cp
(
source
,
target
)
proc
=
execv
([
gradlew
,
'app:assembleStubRelease'
])
build_apk
(
args
,
'Full'
)
if
proc
.
returncode
!=
0
:
error
(
'Build stub Magisk Manager failed!'
)
source
=
os
.
path
.
join
(
'app'
,
'build'
,
'outputs'
,
'apk'
,
'stub'
,
'release'
,
'app-stub-release-unsigned.apk'
)
target
=
os
.
path
.
join
(
config
[
'outdir'
],
'stub-release.apk'
)
sign_apk
(
source
,
target
)
rm
(
source
)
else
:
proc
=
execv
([
gradlew
,
'app:assembleStubDebug'
])
if
proc
.
returncode
!=
0
:
error
(
'Build stub Magisk Manager failed!'
)
source
=
os
.
path
.
join
(
'app'
,
'build'
,
'outputs'
,
'apk'
,
'stub'
,
'debug'
,
'app-stub-debug.apk'
)
target
=
os
.
path
.
join
(
config
[
'outdir'
],
'stub-debug.apk'
)
mv
(
source
,
target
)
header
(
'Output: '
+
target
)
def
build_stub
(
args
):
stub
=
build_apk
(
args
,
'Stub'
)
# Dump the stub APK to header
# Dump the stub APK to header
mkdir
(
os
.
path
.
join
(
'native'
,
'out'
))
mkdir
(
os
.
path
.
join
(
'native'
,
'out'
))
with
open
(
os
.
path
.
join
(
'native'
,
'out'
,
'binaries.h'
),
'w'
)
as
out
:
with
open
(
os
.
path
.
join
(
'native'
,
'out'
,
'binaries.h'
),
'w'
)
as
out
:
with
open
(
target
,
'rb'
)
as
src
:
with
open
(
stub
,
'rb'
)
as
src
:
binary_dump
(
src
,
out
,
'manager_xz'
);
binary_dump
(
src
,
out
,
'manager_xz'
);
def
build_snet
(
args
):
def
build_snet
(
args
):
...
@@ -437,7 +391,7 @@ def cleanup(args):
...
@@ -437,7 +391,7 @@ def cleanup(args):
def
build_all
(
args
):
def
build_all
(
args
):
vars
(
args
)[
'target'
]
=
[]
vars
(
args
)[
'target'
]
=
[]
build_stub
(
args
)
build_stub
(
args
)
build_apk
(
args
)
build_apk
(
args
,
'Full'
)
build_binary
(
args
)
build_binary
(
args
)
zip_main
(
args
)
zip_main
(
args
)
zip_uninstaller
(
args
)
zip_uninstaller
(
args
)
...
@@ -481,7 +435,7 @@ binary_parser.add_argument('target', nargs='*', help='Support: magisk, magiskini
...
@@ -481,7 +435,7 @@ binary_parser.add_argument('target', nargs='*', help='Support: magisk, magiskini
binary_parser
.
set_defaults
(
func
=
build_binary
)
binary_parser
.
set_defaults
(
func
=
build_binary
)
apk_parser
=
subparsers
.
add_parser
(
'apk'
,
help
=
'build Magisk Manager APK'
)
apk_parser
=
subparsers
.
add_parser
(
'apk'
,
help
=
'build Magisk Manager APK'
)
apk_parser
.
set_defaults
(
func
=
build_ap
k
)
apk_parser
.
set_defaults
(
func
=
build_ap
p
)
stub_parser
=
subparsers
.
add_parser
(
'stub'
,
help
=
'build stub Magisk Manager APK'
)
stub_parser
=
subparsers
.
add_parser
(
'stub'
,
help
=
'build stub Magisk Manager APK'
)
stub_parser
.
set_defaults
(
func
=
build_stub
)
stub_parser
.
set_defaults
(
func
=
build_stub
)
...
...
config.prop.sample
View file @
c19b7818
# The version
string
and version code of Magisk
# The version
name
and version code of Magisk
version=
version=
versionCode=
versionCode=
# The version name and version code of Magisk Manager
appVersion=
appVersionCode=
outdir=out
outdir=out
# Whether use pretty names for zips, e.g. Magisk-v${version}.zip, Magisk-uninstaller-${date}.zip
# Whether use pretty names for zips, e.g. Magisk-v${version}.zip, Magisk-uninstaller-${date}.zip
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment