From d57d414489b2a167aec13e97144c46990c4d4d48 Mon Sep 17 00:00:00 2001 From: zhaojunxia Date: Fri, 21 Oct 2022 16:15:45 +0800 Subject: [PATCH] fix: modify win command Signed-off-by: zhaojunxia --- .../com/sk/gn/action/SelectOutDirAction.java | 23 +++++++- .../src/com/sk/gn/dialog/GenDialogPane.java | 55 +++++++++++++++---- .../resources/META-INF/plugin.xml | 14 +---- 3 files changed, 64 insertions(+), 28 deletions(-) diff --git a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/SelectOutDirAction.java b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/SelectOutDirAction.java index d7bb23f7..e4719062 100644 --- a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/SelectOutDirAction.java +++ b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/SelectOutDirAction.java @@ -30,12 +30,23 @@ import java.io.File; * @since 2022-09-21 */ public class SelectOutDirAction implements ActionListener { + private static final String SYS_NAME = System.getProperties().getProperty("os.name").toUpperCase(); + private final JButton button; private final JTextField textField; + /** + * 构造函数 + * + * @param button 按钮 + * @param textField 输入框 + */ public SelectOutDirAction(JButton button, JTextField textField) { this.button = button; this.textField = textField; + if (SYS_NAME.contains("WIN")) { + textField.setText("out\\rk3568"); + } } @Override @@ -47,15 +58,21 @@ public class SelectOutDirAction implements ActionListener { int returnVal = fcDlg.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { String filepath = fcDlg.getSelectedFile().getPath(); + String fieldShowPath; if (filepath.contains(File.separator)) { String path = filepath.substring(0, filepath.lastIndexOf(File.separator)); if (path.contains(File.separator)) { - textField.setText(filepath.substring(path.lastIndexOf(File.separator) + 1)); + fieldShowPath = filepath.substring(path.lastIndexOf(File.separator) + 1); } else { - textField.setText(filepath.substring(filepath.lastIndexOf(File.separator) + 1)); + fieldShowPath = filepath.substring(filepath.lastIndexOf(File.separator) + 1); } } else { - textField.setText(filepath); + fieldShowPath = filepath; + } + if (SYS_NAME.contains("WIN")) { + textField.setText(fieldShowPath.replaceAll("/", "\"")); + } else { + textField.setText(fieldShowPath); } } } diff --git a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.java b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.java index 9cbbccbc..ca0b4690 100644 --- a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.java +++ b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.java @@ -244,6 +244,7 @@ public class GenDialogPane extends JDialog { */ public boolean runFun() { createCopyResMakeFile(); + createCopyResMakeRawFile(); createCopyResToolChainFile(); GenNotification.notifyMessage(this.project, "", "正在生成", NotificationType.INFORMATION); String command; @@ -297,13 +298,16 @@ public class GenDialogPane extends JDialog { if (!TextUtils.isEmpty(compileTextField.getText().trim())) { command += " -a " + "\"" + compileOptions + "\""; } + if (SYS_NAME.contains("WIN")) { + return command.replaceAll("\\\\", "/"); + } return command; } private void createCopyResMakeFile() { String makeFilePath = "cmds/res/linux/bin/make"; if (SYS_NAME.contains("WIN")) { - makeFilePath = "cmds/res/win64/bin/gnumake.exe"; + makeFilePath = "cmds/res/win/bin/gnumake.exe"; } String tmpDirFile = System.getProperty("java.io.tmpdir") + "/res/linux/bin/"; File file = new File(tmpDirFile); @@ -312,19 +316,44 @@ public class GenDialogPane extends JDialog { } String tmp = SYS_NAME.contains("WIN") ? file.getPath() + "/gnumake.exe" : file.getPath() + "/make"; writeTmpFile(tmp, makeFilePath, project); - try { - executable(tmp); - } catch (IOException | InterruptedException e) { - GenNotification.notifyMessage(this.project, e.getMessage(), "Can not Find File:" + makeFilePath, + if (SYS_NAME.contains("LINUX") || SYS_NAME.contains("MAC OS")) { + try { + executable(tmp); + } catch (IOException | InterruptedException e) { + GenNotification.notifyMessage(this.project, e.getMessage(), "Can not Find File:" + makeFilePath, NotificationType.ERROR); - LOG.error(e); + LOG.error(e); + } + } + } + + private void createCopyResMakeRawFile() { + String makeFilePath = "cmds/res/linux/bin/make_raw"; + if (SYS_NAME.contains("WIN")) { + makeFilePath = "cmds/res/win/bin/make_raw.exe"; + } + String tmpDirFile = System.getProperty("java.io.tmpdir") + "/res/linux/bin/"; + File file = new File(tmpDirFile); + if (file.mkdirs()) { + LOG.info("create dir success"); + } + String tmp = SYS_NAME.contains("WIN") ? file.getPath() + "/make_raw.exe" : file.getPath() + "/make_raw"; + writeTmpFile(tmp, makeFilePath, project); + if (SYS_NAME.contains("LINUX") || SYS_NAME.contains("MAC OS")) { + try { + executable(tmp); + } catch (IOException | InterruptedException e) { + GenNotification.notifyMessage(this.project, e.getMessage(), "Can not Find File:" + makeFilePath, + NotificationType.ERROR); + LOG.error(e); + } } } private void createCopyResToolChainFile() { String toolchainFileDir = "cmds/res/linux/ohos.toolchain.cmake"; if (SYS_NAME.contains("WIN")) { - toolchainFileDir = "cmds/res/win64/ohos.toolchain.cmake"; + toolchainFileDir = "cmds/res/win/ohos.toolchain.cmake"; } String tmpDirFile = System.getProperty("java.io.tmpdir") + "/res/linux/"; File file = new File(tmpDirFile); @@ -333,12 +362,14 @@ public class GenDialogPane extends JDialog { } String tmp = file.getPath() + "/ohos.toolchain.cmake"; writeTmpFile(tmp, toolchainFileDir, project); - try { - executable(tmp); - } catch (IOException | InterruptedException e) { - GenNotification.notifyMessage(this.project, e.getMessage(), "Can not Find File:" + toolchainFileDir, + if (SYS_NAME.contains("LINUX") || SYS_NAME.contains("MAC OS")) { + try { + executable(tmp); + } catch (IOException | InterruptedException e) { + GenNotification.notifyMessage(this.project, e.getMessage(), "Can not Find File:" + toolchainFileDir, NotificationType.ERROR); - LOG.error(e); + LOG.error(e); + } } } diff --git a/napi_IntelliJ_plugin/resources/META-INF/plugin.xml b/napi_IntelliJ_plugin/resources/META-INF/plugin.xml index 031258e0..fd0902a0 100644 --- a/napi_IntelliJ_plugin/resources/META-INF/plugin.xml +++ b/napi_IntelliJ_plugin/resources/META-INF/plugin.xml @@ -2,22 +2,13 @@ com.sk.ng Napi Generator 1.0 - YourCompany + 深圳开鸿数字产业发展有限公司 Introduction

    One-click generation of NAPI framework code, business code framework, GN file, etc. according to the ts (typescript) interface file in the user-specified path.

    When developing the interface between JS applications and NAPI, the developers of the underlying framework do not need to pay attention to the upper-level application conversion logic such as Nodejs syntax, data type conversion between C++ and JS, and only focus on the underlying business logic. Professional people do professional things. Thus, the development efficiency can be greatly improved

-

Sources on Gitee

- - - - - - - - ]]>
@@ -26,11 +17,8 @@ ]]> - - com.intellij.modules.platform -- Gitee