Skip to content

提供launch 调试 #2

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build Plugin

on: push
#on:
# push:
# branches: [ "master" ]
# pull_request:
# branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

env:
CI: true
CI_BUILD_VERSION: 1.1.${{ github.run_number }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Build
run: |
chmod 777 gradlew
./gradlew buildPlugin

- name: Upload artifact
uses: actions/upload-artifact@v3.1.0
with:
name: v${{ env.CI_BUILD_VERSION }}
path: build/distributions/*.zip
94 changes: 0 additions & 94 deletions build.gradle

This file was deleted.

107 changes: 107 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* Copyright (c) 2017. tangzx(love.tangzx@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import de.undercouch.gradle.tasks.download.*

plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "1.7.20"
id("org.jetbrains.intellij") version "1.13.2"
id("de.undercouch.download").version("5.3.0")
}

repositories {
mavenCentral()
}

intellij {
pluginName.set("EmmyLua-AttachDebugger")
version.set("2023.1")
type.set("IC") // Target IDE Platform

plugins.set(listOf("com.tang:1.4.8-IDEA231"))
}

val emmyluaDebuggerVersion = "1.8.2"
val emmyluaDebuggerProjectUrl = "https://github.com/EmmyLua/EmmyLuaDebugger"

task("downloadDebugger", type = Download::class) {
src(arrayOf(
"${emmyluaDebuggerProjectUrl }/releases/download/${emmyluaDebuggerVersion}/win32-x86.zip",
"${emmyluaDebuggerProjectUrl }/releases/download/${emmyluaDebuggerVersion}/win32-x64.zip",
))

dest("temp")
}

task("unzipDebugger", type = Copy::class) {
dependsOn("downloadDebugger")
from(zipTree("temp/win32-x64.zip")) {
into("bin/win32-x64")
}
from(zipTree("temp/win32-x86.zip")) {
into("bin/win32-x86")
}
destinationDir = file("temp")
}

task("installDebugger", type = Copy::class) {
dependsOn("unzipDebugger")
from("temp/bin") {
into("bin")
}

destinationDir = file("src/main/resources/debugger")
}

tasks {
// Set the JVM compatibility versions
withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}

patchPluginXml {
sinceBuild.set("223")
untilBuild.set("242.*")
}

signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}

publishPlugin {
token.set(System.getenv("PUBLISH_TOKEN"))
}

buildPlugin {
dependsOn("installDebugger")
}

withType<org.jetbrains.intellij.tasks.PrepareSandboxTask> {
doLast {
copy {
from("src/main/resources/debugger/bin")
into("$destinationDir/${pluginName.get()}/debugger/bin")
}
}
}
}
26 changes: 0 additions & 26 deletions gradle.properties

This file was deleted.

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "EmmyLua-AttachDebugger"
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.tang.intellij.lua.debugger.emmyAttach

import com.intellij.execution.Executor
import com.intellij.execution.configurations.ConfigurationFactory
import com.intellij.execution.configurations.ConfigurationType
import com.intellij.execution.configurations.RunConfiguration
import com.intellij.execution.configurations.RunProfileState
import com.intellij.execution.runners.ExecutionEnvironment
import com.intellij.execution.runners.RunConfigurationWithSuppressedDefaultRunAction
import com.intellij.openapi.module.Module
import com.intellij.openapi.options.SettingsEditor
import com.intellij.openapi.options.SettingsEditorGroup
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.JDOMExternalizerUtil
import com.tang.intellij.lua.debugger.LuaCommandLineState
import com.tang.intellij.lua.debugger.LuaRunConfiguration
import com.tang.intellij.lua.lang.LuaIcons
import org.jdom.Element
import javax.swing.Icon
import com.tang.intellij.lua.debugger.LuaConfigurationFactory
import com.tang.intellij.lua.debugger.emmy.EmmyDebugTransportType

class EmmyAttachConfigurationType : ConfigurationType {
override fun getIcon(): Icon {
return LuaIcons.FILE
}

override fun getConfigurationTypeDescription(): String {
return "Emmy Attach Debugger"
}

override fun getId(): String {
return "lua.emmyAttach.debugger"
}

override fun getDisplayName(): String {
return "Emmy Attach Debugger"
}

override fun getConfigurationFactories(): Array<ConfigurationFactory> {
return arrayOf(EmmyAttachDebuggerConfigurationFactory(this))
}
}

enum class EmmyAttachMode(private val desc: String) {
Pid("Pid"),
ProcessName("ProcessName");

override fun toString(): String {
return desc;
}
}

class EmmyAttachDebuggerConfigurationFactory(val type: EmmyAttachConfigurationType) : LuaConfigurationFactory(type) {
override fun createTemplateConfiguration(project: Project): RunConfiguration {
return EmmyAttachDebugConfiguration(project, this)
}
}

class EmmyAttachDebugConfiguration(project: Project, factory: EmmyAttachDebuggerConfigurationFactory) :
LuaRunConfiguration(project, factory),
RunConfigurationWithSuppressedDefaultRunAction {
var attachMode = EmmyAttachMode.Pid;
var pid = "0"
var processName = ""
var encoding = "gbk"

override fun getConfigurationEditor(): SettingsEditor<out RunConfiguration> {
val group = SettingsEditorGroup<EmmyAttachDebugConfiguration>()
group.addEditor("emmy", EmmyAttachDebugSettingsPanel(project))
return group
}

override fun getState(executor: Executor, environment: ExecutionEnvironment): RunProfileState {
return LuaCommandLineState(environment)
}

override fun getValidModules(): Collection<Module> {
return emptyList()
}

override fun writeExternal(element: Element) {
super.writeExternal(element)
JDOMExternalizerUtil.writeField(element, "AttachMode", attachMode.ordinal.toString())
JDOMExternalizerUtil.writeField(element, "Pid", pid)
JDOMExternalizerUtil.writeField(element, "ProcessName", processName)
JDOMExternalizerUtil.writeField(element, "Encoding", encoding)
}

override fun readExternal(element: Element) {
super.readExternal(element)
JDOMExternalizerUtil.readField(element, "AttachMode")?.let { value ->
val i = value.toInt()
attachMode = EmmyAttachMode.values().find { it.ordinal == i } ?: EmmyAttachMode.Pid
}
JDOMExternalizerUtil.readField(element, "Pid")?.let {
pid = it
}
JDOMExternalizerUtil.readField(element, "ProcessName")?.let {
processName = it
}
JDOMExternalizerUtil.readField(element, "Encoding")?.let {
encoding = it
}
}
}
Loading