From 1ab3fdb3ea69a7fb7bc65d48e55d5c77072f8b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Tue, 12 Nov 2019 16:34:11 +0800 Subject: [PATCH] add project home build field for debugger --- Android/doric/build.gradle | 6 ++++++ Android/doric/src/main/java/pub/doric/dev/DevPanel.java | 3 ++- doric-cli/scripts/server.js | 7 ++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Android/doric/build.gradle b/Android/doric/build.gradle index 8ca243ce..24523a49 100644 --- a/Android/doric/build.gradle +++ b/Android/doric/build.gradle @@ -1,5 +1,7 @@ apply plugin: 'com.android.library' +def projectHome = project.rootDir.getParent() + "/demo" + android { compileSdkVersion 29 buildToolsVersion '29.0.2' @@ -20,6 +22,10 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' consumerProguardFiles 'proguard-rules.pro' } + + debug { + buildConfigField "String", "PROJECT_HOME", "\"${projectHome}\"" + } } } diff --git a/Android/doric/src/main/java/pub/doric/dev/DevPanel.java b/Android/doric/src/main/java/pub/doric/dev/DevPanel.java index 68148286..1a0efc44 100644 --- a/Android/doric/src/main/java/pub/doric/dev/DevPanel.java +++ b/Android/doric/src/main/java/pub/doric/dev/DevPanel.java @@ -23,6 +23,7 @@ import org.greenrobot.eventbus.ThreadMode; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Consumer; +import pub.doric.BuildConfig; import pub.doric.Doric; import pub.doric.DoricContext; import pub.doric.DoricContextManager; @@ -30,7 +31,6 @@ import pub.doric.IDoricDriver; import pub.doric.R; import pub.doric.dev.event.EOFEvent; import pub.doric.dev.event.OpenEvent; -import pub.doric.utils.DoricUtils; public class DevPanel extends BottomSheetDialogFragment { @@ -85,6 +85,7 @@ public class DevPanel extends BottomSheetDialogFragment { for (DoricContext doricContext : DoricContextManager.aliveContexts()) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("contextId", doricContext.getContextId()); + jsonObject.addProperty("projectHome", BuildConfig.PROJECT_HOME); Doric.sendDevCommand(IDoricDriver.Command.DEBUG, jsonObject); } } diff --git a/doric-cli/scripts/server.js b/doric-cli/scripts/server.js index cb07865f..e93bf683 100644 --- a/doric-cli/scripts/server.js +++ b/doric-cli/scripts/server.js @@ -7,9 +7,10 @@ const createServer = () => { console.log('text', result) let resultObject = JSON.parse(result) switch(resultObject.cmd) { - case 'debug': - let contextId = resultObject.contextId - + case 'DEBUG': + let contextId = resultObject.data.contextId + let projectHome = resultObject.data.projectHome + console.log(projectHome) break } })