Commit 60b3b8dd authored by topjohnwu's avatar topjohnwu

Better incremental builds

parent 41446ec9
...@@ -170,8 +170,7 @@ def build_binary(args): ...@@ -170,8 +170,7 @@ def build_binary(args):
header('* Building binaries: ' + ' '.join(args.target)) header('* Building binaries: ' + ' '.join(args.target))
# Force update logging.h timestamp to trigger recompilation for the flags to make a difference os.utime(os.path.join('native', 'jni', 'include', 'flags.h'))
os.utime(os.path.join('native', 'jni', 'utils', 'include', 'logging.h'))
# Basic flags # Basic flags
base_flags = 'MAGISK_VERSION=\"{}\" MAGISK_VER_CODE={} MAGISK_DEBUG={}'.format(config['version'], config['versionCode'], base_flags = 'MAGISK_VERSION=\"{}\" MAGISK_VER_CODE={} MAGISK_DEBUG={}'.format(config['version'], config['versionCode'],
......
...@@ -14,8 +14,8 @@ android { ...@@ -14,8 +14,8 @@ android {
externalNativeBuild { externalNativeBuild {
ndkBuild { ndkBuild {
// Pass arguments to ndk-build. // Pass arguments to ndk-build.
arguments('B_MAGISK=1', 'B_INIT=1', 'B_BOOT=1', 'B_BXZ=1', 'MAGISK_VERSION=debug', arguments('B_MAGISK=1', 'B_INIT=1', 'B_BOOT=1', 'B_BXZ=1',
'MAGISK_VER_CODE=99999', 'MAGISK_DEBUG=-DMAGISK_DEBUG') 'MAGISK_DEBUG=-DMAGISK_DEBUG')
} }
} }
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "daemon.h" #include "daemon.h"
#include "resetprop.h" #include "resetprop.h"
#include "selinux.h" #include "selinux.h"
#include "flags.h"
static char buf[PATH_MAX], buf2[PATH_MAX]; static char buf[PATH_MAX], buf2[PATH_MAX];
static struct vector module_list; static struct vector module_list;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "daemon.h" #include "daemon.h"
#include "resetprop.h" #include "resetprop.h"
#include "selinux.h" #include "selinux.h"
#include "flags.h"
int setup_done = 0; int setup_done = 0;
int seperate_vendor = 0; int seperate_vendor = 0;
...@@ -69,7 +70,7 @@ static void *request_handler(void *args) { ...@@ -69,7 +70,7 @@ static void *request_handler(void *args) {
su_daemon_receiver(client, &credential); su_daemon_receiver(client, &credential);
break; break;
case CHECK_VERSION: case CHECK_VERSION:
write_string(client, MAGISK_VER_STR); write_string(client, xstr(MAGISK_VERSION) ":MAGISK");
close(client); close(client);
break; break;
case CHECK_VERSION_CODE: case CHECK_VERSION_CODE:
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "magisk.h" #include "magisk.h"
#include "utils.h" #include "utils.h"
#include "daemon.h" #include "daemon.h"
#include "flags.h"
static int loggable = 0; static int loggable = 0;
static struct vector log_cmd, clear_cmd; static struct vector log_cmd, clear_cmd;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "magisk.h" #include "magisk.h"
#include "daemon.h" #include "daemon.h"
#include "selinux.h" #include "selinux.h"
#include "flags.h"
char *argv0; char *argv0;
...@@ -66,7 +67,7 @@ int magisk_main(int argc, char *argv[]) { ...@@ -66,7 +67,7 @@ int magisk_main(int argc, char *argv[]) {
if (argc < 2) if (argc < 2)
usage(); usage();
if (strcmp(argv[1], "-c") == 0) { if (strcmp(argv[1], "-c") == 0) {
printf("%s (%d)\n", MAGISK_VER_STR, MAGISK_VER_CODE); printf("%s (%d)\n", xstr(MAGISK_VERSION) ":MAGISK", MAGISK_VER_CODE);
return 0; return 0;
} else if (strcmp(argv[1], "-v") == 0) { } else if (strcmp(argv[1], "-v") == 0) {
int fd = connect_daemon(); int fd = connect_daemon();
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "utils.h" #include "utils.h"
#include "daemon.h" #include "daemon.h"
#include "magisk.h" #include "magisk.h"
#include "flags.h"
#define DEFAULT_DT_DIR "/proc/device-tree/firmware/android" #define DEFAULT_DT_DIR "/proc/device-tree/firmware/android"
......
#pragma once
/* Include this header anywhere you access MAGISK_DEBUG, MAGISK_VERSION, MAGISK_VER_CODE.
*
* This file is only for more precise incremental builds. We can make sure code that uses
* external flags are re-compiled by updating the timestamp of this file
* */
#ifndef MAGISK_VERSION
#define MAGISK_VERSION 99.99
#endif
#ifndef MAGISK_VER_CODE
#define MAGISK_VER_CODE 99999
#endif
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "logging.h" #include "logging.h"
#define MAGISK_VER_STR xstr(MAGISK_VERSION) ":MAGISK"
#define MAIN_SOCKET "d30138f2310a9fb9c54a3e0c21f58591" #define MAIN_SOCKET "d30138f2310a9fb9c54a3e0c21f58591"
#define LOG_SOCKET "5864cd77f2f8c59b3882e2d35dbf51e4" #define LOG_SOCKET "5864cd77f2f8c59b3882e2d35dbf51e4"
#define JAVA_PACKAGE_NAME "com.topjohnwu.magisk" #define JAVA_PACKAGE_NAME "com.topjohnwu.magisk"
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "daemon.h" #include "daemon.h"
#include "utils.h" #include "utils.h"
#include "magiskhide.h" #include "magiskhide.h"
#include "flags.h"
static int sockfd = -1; static int sockfd = -1;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "utils.h" #include "utils.h"
#include "su.h" #include "su.h"
#include "selinux.h" #include "selinux.h"
#include "flags.h"
struct su_context *su_ctx; struct su_context *su_ctx;
...@@ -182,7 +183,7 @@ int su_daemon_main(int argc, char **argv) { ...@@ -182,7 +183,7 @@ int su_daemon_main(int argc, char **argv) {
printf("%d\n", MAGISK_VER_CODE); printf("%d\n", MAGISK_VER_CODE);
exit2(EXIT_SUCCESS); exit2(EXIT_SUCCESS);
case 'v': case 'v':
printf("%s\n", MAGISKSU_VER_STR); printf("%s\n", xstr(MAGISK_VERSION) ":MAGISKSU (topjohnwu)");
exit2(EXIT_SUCCESS); exit2(EXIT_SUCCESS);
case 'z': case 'z':
// Do nothing, placed here for legacy support :) // Do nothing, placed here for legacy support :)
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "db.h" #include "db.h"
#include "list.h" #include "list.h"
#define MAGISKSU_VER_STR xstr(MAGISK_VERSION) ":MAGISKSU (topjohnwu)"
#define DEFAULT_SHELL "/system/bin/sh" #define DEFAULT_SHELL "/system/bin/sh"
struct su_info { struct su_info {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "magisk.h" #include "magisk.h"
#include "utils.h" #include "utils.h"
#include "img.h" #include "img.h"
#include "flags.h"
#define round_size(a) ((((a) / 32) + 2) * 32) #define round_size(a) ((((a) / 32) + 2) * 32)
#define SOURCE_TMP "/dev/.img_src" #define SOURCE_TMP "/dev/.img_src"
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "logging.h" #include "logging.h"
#include "utils.h" #include "utils.h"
#include "resetprop.h" #include "resetprop.h"
#include "flags.h"
unsigned get_shell_uid() { unsigned get_shell_uid() {
struct passwd* ppwd = getpwnam("shell"); struct passwd* ppwd = getpwnam("shell");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment