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
8a2a6d92
Commit
8a2a6d92
authored
Dec 25, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make versionCode unconfigurable
parent
12aa6d86
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
45 deletions
+46
-45
build.gradle.kts
app/build.gradle.kts
+0
-1
build.py
build.py
+18
-18
BuildSource.kt
buildSrc/src/main/java/BuildSource.kt
+10
-11
config.prop.sample
config.prop.sample
+12
-14
gradle.properties
gradle.properties
+6
-1
No files found.
app/build.gradle.kts
View file @
8a2a6d92
...
@@ -22,7 +22,6 @@ android {
...
@@ -22,7 +22,6 @@ android {
multiDexEnabled
=
true
multiDexEnabled
=
true
versionName
=
Config
.
appVersion
versionName
=
Config
.
appVersion
versionCode
=
Config
.
appVersionCode
versionCode
=
Config
.
appVersionCode
buildConfigField
(
"int"
,
"LATEST_MAGISK"
,
Config
.
magiskVersionCode
.
toString
())
javaCompileOptions
.
annotationProcessorOptions
.
arguments
(
javaCompileOptions
.
annotationProcessorOptions
.
arguments
(
mapOf
(
"room.incremental"
to
"true"
)
mapOf
(
"room.incremental"
to
"true"
)
...
...
build.py
View file @
8a2a6d92
...
@@ -55,9 +55,6 @@ arch64 = ['arm64-v8a', 'x86_64']
...
@@ -55,9 +55,6 @@ arch64 = ['arm64-v8a', 'x86_64']
support_targets
=
[
'magisk'
,
'magiskinit'
,
'magiskboot'
,
'magiskpolicy'
,
'resetprop'
,
'busybox'
,
'test'
]
support_targets
=
[
'magisk'
,
'magiskinit'
,
'magiskboot'
,
'magiskpolicy'
,
'resetprop'
,
'busybox'
,
'test'
]
default_targets
=
[
'magisk'
,
'magiskinit'
,
'magiskboot'
,
'busybox'
]
default_targets
=
[
'magisk'
,
'magiskinit'
,
'magiskboot'
,
'busybox'
]
ndk_ver
=
'21d'
ndk_ver_full
=
'21.3.6528147'
ndk_root
=
op
.
join
(
os
.
environ
[
'ANDROID_SDK_ROOT'
],
'ndk'
)
ndk_root
=
op
.
join
(
os
.
environ
[
'ANDROID_SDK_ROOT'
],
'ndk'
)
ndk_path
=
op
.
join
(
ndk_root
,
'magisk'
)
ndk_path
=
op
.
join
(
ndk_root
,
'magisk'
)
ndk_build
=
op
.
join
(
ndk_path
,
'ndk-build'
)
ndk_build
=
op
.
join
(
ndk_path
,
'ndk-build'
)
...
@@ -141,23 +138,20 @@ def parse_props(file):
...
@@ -141,23 +138,20 @@ def parse_props(file):
def
load_config
(
args
):
def
load_config
(
args
):
commit_hash
=
cmd_out
([
'git'
,
'rev-parse'
,
'--short=8'
,
'refs/heads/master'
])
commit_hash
=
cmd_out
([
'git'
,
'rev-parse'
,
'--short=8'
,
'HEAD'
])
commit_count
=
cmd_out
([
'git'
,
'rev-list'
,
'--count'
,
'refs/heads/master'
])
#
Some d
efault values
#
D
efault values
config
[
'version'
]
=
commit_hash
config
[
'version'
]
=
commit_hash
config
[
'versionCode'
]
=
2147483647
config
[
'appVersion'
]
=
commit_hash
config
[
'appVersionCode'
]
=
commit_count
config
[
'outdir'
]
=
'out'
config
[
'outdir'
]
=
'out'
config
[
'prettyName'
]
=
'false'
config
[
'prettyName'
]
=
'false'
config
[
'keyStore'
]
=
'release-key.jks'
# Load prop file
# Load prop file
s
if
op
.
exists
(
args
.
config
):
if
op
.
exists
(
args
.
config
):
config
.
update
(
parse_props
(
args
.
config
))
config
.
update
(
parse_props
(
args
.
config
))
# Sanitize configs
for
key
,
value
in
parse_props
(
'gradle.properties'
)
.
items
():
if
key
.
startswith
(
'magisk.'
):
config
[
key
[
7
:]]
=
value
config
[
'prettyName'
]
=
config
[
'prettyName'
]
.
lower
()
==
'true'
config
[
'prettyName'
]
=
config
[
'prettyName'
]
.
lower
()
==
'true'
...
@@ -201,7 +195,7 @@ def clean_elf():
...
@@ -201,7 +195,7 @@ def clean_elf():
def
sign_zip
(
unsigned
,
output
,
release
):
def
sign_zip
(
unsigned
,
output
,
release
):
if
not
release
:
if
not
release
or
'keyStore'
not
in
config
:
mv
(
unsigned
,
output
)
mv
(
unsigned
,
output
)
return
return
...
@@ -289,7 +283,7 @@ def dump_bin_headers():
...
@@ -289,7 +283,7 @@ def dump_bin_headers():
def
build_binary
(
args
):
def
build_binary
(
args
):
# Verify NDK install
# Verify NDK install
props
=
parse_props
(
op
.
join
(
ndk_path
,
'source.properties'
))
props
=
parse_props
(
op
.
join
(
ndk_path
,
'source.properties'
))
if
props
[
'Pkg.Revision'
]
!=
ndk_ver_full
:
if
props
[
'Pkg.Revision'
]
!=
config
[
'fullNdkVersion'
]
:
error
(
'Incorrect NDK. Please install/upgrade NDK with "build.py ndk"'
)
error
(
'Incorrect NDK. Please install/upgrade NDK with "build.py ndk"'
)
if
args
.
target
:
if
args
.
target
:
...
@@ -301,12 +295,17 @@ def build_binary(args):
...
@@ -301,12 +295,17 @@ def build_binary(args):
header
(
'* Building binaries: '
+
' '
.
join
(
args
.
target
))
header
(
'* Building binaries: '
+
' '
.
join
(
args
.
target
))
update_flags
=
Tru
e
update_flags
=
Fals
e
flags
=
op
.
join
(
'native'
,
'jni'
,
'include'
,
'flags.hpp'
)
flags
=
op
.
join
(
'native'
,
'jni'
,
'include'
,
'flags.hpp'
)
flags_stat
=
os
.
stat
(
flags
)
if
op
.
exists
(
args
.
config
):
if
op
.
exists
(
args
.
config
):
config_stat
=
os
.
stat
(
args
.
config
)
if
os
.
stat
(
args
.
config
)
.
st_mtime_ns
>
flags_stat
.
st_mtime_ns
:
update_flags
=
config_stat
.
st_mtime_ns
>
os
.
stat
(
flags
)
.
st_mtime_ns
update_flags
=
True
last_commit
=
int
(
cmd_out
([
'git'
,
'log'
,
'-1'
,
r'--format=
%
at'
,
'HEAD'
]))
if
last_commit
>
flags_stat
.
st_mtime
:
update_flags
=
True
if
update_flags
:
if
update_flags
:
os
.
utime
(
flags
)
os
.
utime
(
flags
)
...
@@ -522,6 +521,7 @@ def cleanup(args):
...
@@ -522,6 +521,7 @@ def cleanup(args):
def
setup_ndk
(
args
):
def
setup_ndk
(
args
):
os_name
=
platform
.
system
()
.
lower
()
os_name
=
platform
.
system
()
.
lower
()
ndk_ver
=
config
[
'ndkVersion'
]
url
=
f
'https://dl.google.com/android/repository/android-ndk-r{ndk_ver}-{os_name}-x86_64.zip'
url
=
f
'https://dl.google.com/android/repository/android-ndk-r{ndk_ver}-{os_name}-x86_64.zip'
ndk_zip
=
url
.
split
(
'/'
)[
-
1
]
ndk_zip
=
url
.
split
(
'/'
)[
-
1
]
...
@@ -578,7 +578,7 @@ parser.add_argument('-r', '--release', action='store_true',
...
@@ -578,7 +578,7 @@ parser.add_argument('-r', '--release', action='store_true',
parser
.
add_argument
(
'-v'
,
'--verbose'
,
action
=
'store_true'
,
parser
.
add_argument
(
'-v'
,
'--verbose'
,
action
=
'store_true'
,
help
=
'verbose output'
)
help
=
'verbose output'
)
parser
.
add_argument
(
'-c'
,
'--config'
,
default
=
'config.prop'
,
parser
.
add_argument
(
'-c'
,
'--config'
,
default
=
'config.prop'
,
help
=
'
set
config file (default: config.prop)'
)
help
=
'
custom
config file (default: config.prop)'
)
subparsers
=
parser
.
add_subparsers
(
title
=
'actions'
)
subparsers
=
parser
.
add_subparsers
(
title
=
'actions'
)
all_parser
=
subparsers
.
add_parser
(
all_parser
=
subparsers
.
add_parser
(
...
...
buildSrc/src/main/java/BuildSource.kt
View file @
8a2a6d92
...
@@ -19,22 +19,21 @@ object Config {
...
@@ -19,22 +19,21 @@ object Config {
fun
contains
(
key
:
String
)
=
get
(
key
)
!=
null
fun
contains
(
key
:
String
)
=
get
(
key
)
!=
null
val
appVersion
:
String
get
()
=
get
(
"appVersion"
)
?:
commitHash
val
appVersion
:
String
get
()
=
get
(
"appVersion"
)
?:
commitHash
val
appVersionCode
:
Int
get
()
=
get
(
"appVersionCode"
)
?.
toInt
()
?:
commitCount
val
appVersionCode
:
Int
get
()
=
commitCount
val
magiskVersionCode
:
Int
get
()
=
get
(
"versionCode"
)
?.
toInt
()
?:
Int
.
MAX_VALUE
}
}
class
MagiskPlugin
:
Plugin
<
Project
>
{
class
MagiskPlugin
:
Plugin
<
Project
>
{
override
fun
apply
(
project
:
Project
)
{
override
fun
apply
(
project
:
Project
)
{
val
configPath
:
String
?
by
project
val
configPath
:
String
?
by
project
val
config
=
configPath
?.
let
{
File
(
it
)
}
?:
project
.
file
(
"config.prop"
)
configPath
?.
let
{
if
(
config
.
exists
())
val
config
=
File
(
it
)
config
.
inputStream
().
use
{
props
.
load
(
it
)
}
if
(
config
.
exists
())
config
.
inputStream
().
use
{
s
->
props
.
load
(
s
)
}
if
(!
Config
.
contains
(
"appVersion"
)
||
!
Config
.
contains
(
"appVersionCode"
))
{
val
repo
=
FileRepository
(
project
.
rootProject
.
file
(
".git"
))
val
refId
=
repo
.
refDatabase
.
exactRef
(
"refs/heads/master"
).
objectId
commitHash
=
repo
.
newObjectReader
().
abbreviate
(
refId
,
8
).
name
()
commitCount
=
Git
(
repo
).
log
().
add
(
refId
).
call
().
count
()
}
}
val
repo
=
FileRepository
(
project
.
rootProject
.
file
(
".git"
))
val
refId
=
repo
.
refDatabase
.
exactRef
(
"HEAD"
).
objectId
commitHash
=
repo
.
newObjectReader
().
abbreviate
(
refId
,
8
).
name
()
commitCount
=
Git
(
repo
).
log
().
add
(
refId
).
call
().
count
()
}
}
}
}
config.prop.sample
View file @
8a2a6d92
...
@@ -3,16 +3,14 @@
...
@@ -3,16 +3,14 @@
# Removing or leaving them blank will keep default values
# Removing or leaving them blank will keep default values
##########################################################
##########################################################
# The version name and version code of Magisk
# The version name of Magisk. Default: git HEAD short SHA1
version=
version=string
versionCode=
# The version name and version code of Magisk Manager
# The version name of Magisk Manager. Default: git HEAD short SHA1
appVersion=
appVersion=string
appVersionCode=
# Output path
# Output path
. Default: out
outdir=
outdir=
string
################################################################
################################################################
# Whether to use pretty names for zips
# Whether to use pretty names for zips
...
@@ -20,8 +18,8 @@ outdir=
...
@@ -20,8 +18,8 @@ outdir=
# Default names are magisk-${release/debug/uninstaller}.zip
# Default names are magisk-${release/debug/uninstaller}.zip
################################################################
################################################################
#
The value is either true or
false
#
Default:
false
prettyName=
prettyName=
bool
#####################################################
#####################################################
# Signing configs for signing zips and APKs
# Signing configs for signing zips and APKs
...
@@ -29,10 +27,10 @@ prettyName=
...
@@ -29,10 +27,10 @@ prettyName=
#####################################################
#####################################################
# Path to keystore file
# Path to keystore file
keyStore=
keyStore=
string
# Keystore password
# Keystore password
keyStorePass=
keyStorePass=
string
# The desired key alias in the keystore
# The desired key alias in the keystore
keyAlias=
keyAlias=
string
# Password of specified key alias
# Password of specified key alias
keyPass=
keyPass=
string
gradle.properties
View file @
8a2a6d92
...
@@ -21,7 +21,7 @@ org.gradle.parallel=true
...
@@ -21,7 +21,7 @@ org.gradle.parallel=true
# The developer environment is optimized for speed and feedback so we nearly always run Gradle jobs with the daemon.
# The developer environment is optimized for speed and feedback so we nearly always run Gradle jobs with the daemon.
org.gradle.daemon
=
true
org.gradle.daemon
=
true
#
AndroidX
#
Android
android.useAndroidX
=
true
android.useAndroidX
=
true
android.enableJetifier
=
false
android.enableJetifier
=
false
android.enableR8.fullMode
=
true
android.enableR8.fullMode
=
true
...
@@ -29,3 +29,8 @@ android.databinding.incremental=true
...
@@ -29,3 +29,8 @@ android.databinding.incremental=true
android.injected.testOnly
=
false
android.injected.testOnly
=
false
kapt.incremental.apt
=
true
kapt.incremental.apt
=
true
# Magisk
magisk.versionCode
=
21102
magisk.ndkVersion
=
21d
magisk.fullNdkVersion
=
21.3.6528147
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