├── .classpath ├── .github └── workflows │ ├── build_pull_requests.yml │ └── publish.yml ├── .gitignore ├── .project ├── .settings ├── org.eclipse.core.resources.prefs ├── org.eclipse.jdt.core.prefs └── org.eclipse.m2e.core.prefs ├── LICENSE ├── README.md ├── features └── org.zephyrproject.ide.eclipse-feature │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.m2e.core.prefs │ ├── build.properties │ ├── feature.xml │ └── pom.xml ├── maven ├── .project ├── parent │ ├── .project │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ └── org.eclipse.m2e.core.prefs │ └── pom.xml └── repository │ ├── .gitignore │ ├── .project │ ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.m2e.core.prefs │ ├── category.xml │ └── pom.xml ├── plugins ├── org.zephyrproject.ide.eclipse.core.java11 │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ │ ├── org.eclipse.jdt.core.prefs │ │ └── org.eclipse.jdt.ui.prefs │ ├── META-INF │ │ └── MANIFEST.MF │ ├── build.properties │ ├── pom.xml │ └── src │ │ └── org │ │ └── zephyrproject │ │ └── ide │ │ └── eclipse │ │ └── core │ │ └── internal │ │ └── launch │ │ └── java11 │ │ ├── ZephyrLaunchHelpers.java │ │ └── ZephyrRuntimeProcess.java ├── org.zephyrproject.ide.eclipse.core.linux │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ │ ├── org.eclipse.jdt.core.prefs │ │ └── org.eclipse.jdt.ui.prefs │ ├── META-INF │ │ └── MANIFEST.MF │ ├── build.properties │ ├── pom.xml │ └── src │ │ └── org │ │ └── zephyrproject │ │ └── ide │ │ └── eclipse │ │ └── core │ │ └── internal │ │ └── launch │ │ └── linux │ │ ├── ZephyrLaunchHelpers.java │ │ └── ZephyrRuntimeProcess.java ├── org.zephyrproject.ide.eclipse.core.macosx │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ │ ├── org.eclipse.jdt.core.prefs │ │ └── org.eclipse.jdt.ui.prefs │ ├── META-INF │ │ └── MANIFEST.MF │ ├── build.properties │ ├── pom.xml │ └── src │ │ └── org │ │ └── zephyrproject │ │ └── ide │ │ └── eclipse │ │ └── core │ │ └── internal │ │ └── launch │ │ └── macosx │ │ ├── ZephyrLaunchHelpers.java │ │ └── ZephyrRuntimeProcess.java ├── org.zephyrproject.ide.eclipse.core.win32 │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ │ ├── org.eclipse.jdt.core.prefs │ │ └── org.eclipse.jdt.ui.prefs │ ├── META-INF │ │ └── MANIFEST.MF │ ├── build.properties │ ├── pom.xml │ └── src │ │ └── org │ │ └── zephyrproject │ │ └── ide │ │ └── eclipse │ │ └── core │ │ └── internal │ │ └── launch │ │ └── win32 │ │ ├── ZephyrLaunchHelpers.java │ │ └── ZephyrRuntimeProcess.java ├── org.zephyrproject.ide.eclipse.core │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ ├── org.eclipse.jdt.core.prefs │ │ ├── org.eclipse.jdt.ui.prefs │ │ ├── org.eclipse.m2e.core.prefs │ │ └── org.eclipse.pde.core.prefs │ ├── META-INF │ │ └── MANIFEST.MF │ ├── build.properties │ ├── plugin.properties │ ├── plugin.xml │ ├── pom.xml │ ├── src │ │ └── org │ │ │ └── zephyrproject │ │ │ └── ide │ │ │ └── eclipse │ │ │ └── core │ │ │ ├── ZephyrApplicationBuilder.java │ │ │ ├── ZephyrApplicationNature.java │ │ │ ├── ZephyrApplicationNewProjectGenerator.java │ │ │ ├── ZephyrPlugin.java │ │ │ ├── ZephyrStrings.java │ │ │ ├── build │ │ │ ├── CMakeConstants.java │ │ │ ├── ZephyrApplicationBuildConfiguration.java │ │ │ ├── ZephyrApplicationBuildConfigurationProvider.java │ │ │ └── toolchain │ │ │ │ ├── ZephyrApplicationToolChainProvider.java │ │ │ │ ├── ZephyrGCCToolChain.java │ │ │ │ ├── ZephyrGenericToolChain.java │ │ │ │ └── ZephyrToolChainConstants.java │ │ │ ├── debug │ │ │ └── jtagdevice │ │ │ │ ├── ARCnSimDevice.java │ │ │ │ ├── Nios2Device.java │ │ │ │ ├── OpenIPCDevice.java │ │ │ │ ├── QEMUDevice.java │ │ │ │ └── XtOCDDevice.java │ │ │ ├── internal │ │ │ ├── ZephyrHelpers.java │ │ │ ├── ZephyrPaths.java │ │ │ └── build │ │ │ │ ├── CMakeCache.java │ │ │ │ ├── CompileCommand.java │ │ │ │ ├── MakefileProgressMonitor.java │ │ │ │ ├── NinjaProgressMonitor.java │ │ │ │ └── ZephyrScannerInfoCache.java │ │ │ ├── launch │ │ │ ├── IZephyrLaunchHelper.java │ │ │ ├── ZephyrAbstractRunLaunchConfigDelegate.java │ │ │ ├── ZephyrApplicationEmulatorDebugLaunchConfigDelegate.java │ │ │ ├── ZephyrApplicationEmulatorRunLaunchConfigDelegate.java │ │ │ ├── ZephyrApplicationHardwareDebugLaunchConfigDelegate.java │ │ │ ├── ZephyrApplicationHardwareRunLaunchConfigDelegate.java │ │ │ ├── ZephyrLaunchConstants.java │ │ │ └── ZephyrProcessFactory.java │ │ │ ├── launchbar │ │ │ ├── ZephyrApplicationLaunchConfigurationProvider.java │ │ │ ├── ZephyrApplicationLaunchDescriptorType.java │ │ │ └── ZephyrApplicationLaunchTargetProvider.java │ │ │ └── preferences │ │ │ ├── ZephyrPreferenceConstants.java │ │ │ ├── ZephyrPreferenceInitializer.java │ │ │ └── ZephyrProjectPreferences.java │ └── templates │ │ └── ZephyrApplication │ │ ├── CMakeLists.txt │ │ ├── prj.conf │ │ ├── src │ │ └── main.c │ │ └── template.xml └── org.zephyrproject.ide.eclipse.ui │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.jdt.ui.prefs │ ├── org.eclipse.m2e.core.prefs │ └── org.eclipse.pde.core.prefs │ ├── META-INF │ └── MANIFEST.MF │ ├── about.ini │ ├── about.properties │ ├── build.properties │ ├── icons │ ├── wizard.png │ ├── zephyr-kite-logo-txt.png │ ├── zephyr-kite-logo.png │ ├── zephyr-kite-logo_16x16.png │ ├── zephyr-kite-logo_32x32.png │ ├── zephyr-kite-logo_48x48.png │ └── zephyr-project-icon.png │ ├── plugin.properties │ ├── plugin.xml │ ├── pom.xml │ └── src │ └── org │ └── zephyrproject │ └── ide │ └── eclipse │ └── ui │ ├── ZephyrUIPlugin.java │ ├── internal │ ├── debug │ │ └── JTagDeviceDesc.java │ └── launch │ │ └── tabs │ │ └── CommonDebugLaunchDebuggerTab.java │ ├── launch │ ├── ZephyrApplicationEmulatorDebugLaunchConfigurationTabGroup.java │ ├── ZephyrApplicationEmulatorRunLaunchConfigurationTabGroup.java │ ├── ZephyrApplicationHardwareDebugLaunchConfigurationTabGroup.java │ ├── ZephyrApplicationHardwareRunLaunchConfigurationTabGroup.java │ └── tabs │ │ ├── CommonDebugLaunchStartupTab.java │ │ ├── EmulatorDebugLaunchDebuggerTab.java │ │ ├── EmulatorDebugLaunchMainTab.java │ │ ├── EmulatorRunLaunchMainTab.java │ │ ├── HardwareDebugLaunchDebuggerTab.java │ │ ├── HardwareDebugLaunchMainTab.java │ │ └── HardwareRunLaunchMainTab.java │ ├── launchbar │ ├── ZephyrApplicationLaunchBarConfigurationLabelProvider.java │ └── ZephyrApplicationLaunchBarTargetLabelProvider.java │ ├── preferences │ ├── ZephyrPreferenceToolchainPage.java │ ├── ZephyrPreferenceTopPage.java │ └── internal │ │ └── ZephyrBaseLocationDirectoryFieldEditor.java │ ├── property │ ├── ZephyrApplicationToolchainPropertyPage.java │ └── ZephyrApplicationTopPropertyPage.java │ └── wizards │ ├── ZephyrApplicationEmptyProjectWizard.java │ ├── ZephyrApplicationNewProjectWizard.java │ └── internal │ ├── ZephyrApplicationAbstractProjectWizard.java │ ├── ZephyrApplicationBoardWizardPage.java │ ├── ZephyrApplicationMainWizardPage.java │ └── ZephyrApplicationToolchainWizardPage.java └── pom.xml /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /.github/workflows/build_pull_requests.yml: -------------------------------------------------------------------------------- 1 | name: Build PR with Maven 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | master 7 | 8 | jobs: 9 | build: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Checkout commits 15 | uses: actions/checkout@v2 16 | 17 | - name: Set up JDK 11 18 | uses: actions/setup-java@v1 19 | with: 20 | java-version: 11 21 | 22 | - name: Build with Maven 23 | run: mvn -B package --file pom.xml 24 | 25 | - name: Upload build artifacts 26 | uses: actions/upload-artifact@v1 27 | with: 28 | name: zephyr_eclipse_p2_repo 29 | path: maven/repository/target/repository 30 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Build PR with Maven 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | 8 | jobs: 9 | build: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Configure AWS Credentials 15 | uses: aws-actions/configure-aws-credentials@v1 16 | with: 17 | aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} 18 | aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 19 | aws-region: us-east-1 20 | 21 | - name: Checkout commits 22 | uses: actions/checkout@v2 23 | 24 | - name: Set up JDK 11 25 | uses: actions/setup-java@v1 26 | with: 27 | java-version: 11 28 | 29 | - name: Build with Maven 30 | run: mvn -B package --file pom.xml 31 | 32 | - name: Upload build artifacts 33 | uses: actions/upload-artifact@v1 34 | with: 35 | name: zephyr_eclipse_p2_repo 36 | path: maven/repository/target/repository 37 | 38 | - name: Upload to AWS S3 39 | run: | 40 | echo "publish latest docs" 41 | aws s3 sync --quiet maven/repository/target/repository s3://builds.zephyrproject.org/eclipse-plugin --delete 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | zephyr-eclipse 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 8 | org.eclipse.jdt.core.compiler.source=1.8 9 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Eclipse Plug-in for Zephyr Project 2 | 3 | ## Overview 4 | 5 | This contains a set of Eclipse plug-ins which extends Eclipse CDT to support 6 | application development on Zephyr RTOS, including building and target hardware 7 | debugging. 8 | 9 | ## How to Install 10 | 11 | #### Prerequisites 12 | 13 | The minimum requirements for running the plugins are: 14 | 15 | * Java SE 8 Update 212 or later 16 | * Eclipse 2019-12 (4.14.0) with CDT 9.10.0 17 | 18 | Also, please make sure the development host is setup to build Zephyr 19 | application by following the [Getting Started](https://docs.zephyrproject.org/latest/getting_started/index.html) 20 | guide. 21 | 22 | #### Installing the Plugin 23 | 24 | The plugin can be installed via update sites in Eclipse. 25 | 26 | 1. Go to `Help` in the menu bar, and select `Install New Software`. 27 | 2. Click the `Add` button to add a new update site: 28 | * Name: `zephyr-eclipse` 29 | * URL: https://builds.zephyrproject.org/eclipse-plugin/ 30 | 3. Select the newly added update site. 31 | 4. Select `Zephyr Project` and `Zephyr Project Development Support` and 32 | click `Next`. 33 | 5. Follow the instructions on the wizards to install the plugin. 34 | 6. Restart Eclipse when asked to do so. 35 | 36 | #### Updating the Plugin 37 | 38 | Go to `Help` in the menu bar, and select `Check for Updates`. 39 | 40 | ## How to Use 41 | 42 | #### Create a New Project for Zephyr Application 43 | 44 | Project creation is similar to creating other project type under Eclipse. 45 | This will create a `Hello World` project. 46 | 47 | 1. Go to `File`, `New` and `Project...` 48 | 2. In the dialog, select `Zephyr Application` under `Zephyr Project`. 49 | 3. Click `Next` 50 | 4. Type in the name for the project. 51 | 5. Under `Zephyr Base Path (ZEPHYR_BASE)`, put in (or browse to) the path 52 | to the Zephyr tree. 53 | 6. Click `Next` 54 | 7. Select the toolchain variant to be used with this project. Depending on 55 | the selection, different set of options will need to be set. These options 56 | are the same one as described in the 57 | [Getting Started - Set Up a Toolchain](https://docs.zephyrproject.org/latest/getting_started/index.html#set-up-a-toolchain). 58 | 8. Click `Next` 59 | 9. Type in the board name of the targat hardware. 60 | * Or click on the check box and select one below. 61 | 10. Click `Finish` 62 | 11. A new project is created under Eclipse. 63 | 12. It is recommended to use the `C/C++` perspective. 64 | 1. Go to `Window`, `Perspective`, `Open Perspective`, and `Other...`. 65 | 2. Select `C/C++` and click `Ok`. 66 | 67 | #### Building the Project 68 | 69 | * Right click on the project name under `Project Explorer` and select 70 | `Build Project`. 71 | 72 | #### Run Emulator 73 | 74 | 1. Right click on the project name under `Project Explorer` and select 75 | `Run As`, and `Run Configurations...`. 76 | 2. Right click on `Zephyr Emulator Target`, and `New`. 77 | * Or, select a previously created configuration. 78 | 3. In the newly created configuration, make sure the project is the correct 79 | one. 80 | 4. Click `Run` 81 | 5. The `Console` view will contain the output of the emulator. 82 | 6. Click the red square `Terminate` to stop the emulator. 83 | 84 | #### Flash to Hardware 85 | 86 | 1. Right click on the project name under `Project Explorer` and select 87 | `Run As`, and `Run Configurations...`. 88 | 2. Right click on `Zephyr Hardware Target`, and `New`. 89 | * Or, select a previously created configuration. 90 | 3. In the newly created configuration, make sure the project is the correct 91 | one. 92 | 4. Click `Run` 93 | 5. The `Console` view will contain the output of the flashing process. 94 | 95 | #### Debugging on Emulator 96 | 97 | 1. Right click on the project name under `Project Explorer` and select 98 | `Debug As`, and `Debug Configurations...`. 99 | 2. Right click on `Zephyr Emulator Target`, and `New`. 100 | * Or, select a previously created configuration. 101 | 3. In the newly created configuration, make sure the project is the correct 102 | one, and the `C/C++ Application` points to the correct ELF file. 103 | 4. In the `Debugger` tab: 104 | * The `GDB Command` should be pre-populated with the GDB project 105 | discovered by CMake. If not, select the correct GDB program corresponding 106 | to the target. 107 | * Port number is pre-populated according to the target type. 108 | Change if it is not correct. 109 | 5. Click `Debug` and the debug session should start. 110 | 6. Follow Eclipse's debugging workflow to debug the application. 111 | 112 | #### Debugging on Hardware 113 | 114 | 1. Right click on the project name under `Project Explorer` and select 115 | `Debug As`, and `Debug Configurations...`. 116 | 2. Right click on `Zephyr Hardware Target`, and `New`. 117 | * Or, select a previously created configuration. 118 | 3. In the newly created configuration, make sure the project is the correct 119 | one, and the `C/C++ Application` points to the correct ELF file. 120 | 4. In the `Main` tab, default is to also flash the image to the target. 121 | This can be skipped with the appropriate option. 122 | 5. In the `Debugger` tab: 123 | * The `GDB Command` should be pre-populated with the GDB project 124 | discovered by CMake. If not, select the correct GDB program corresponding 125 | to the target. 126 | * Port number is pre-populated according to the target type. 127 | Change if it is not correct. 128 | 6. Click `Debug` and the debug session should start. 129 | 7. Follow Eclipse's debugging workflow to debug the application. 130 | 131 | ## How to Build 132 | 133 | #### Prerequisites 134 | 135 | The minimum requirements for building the plugins are: 136 | 137 | * Java SE 11.0.3 138 | * Maven 3.3.9 or later (except 3.6.1) 139 | 140 | #### Running Maven 141 | 142 | ```bash 143 | $ mvn clean package 144 | ``` 145 | 146 | The resulting p2 repository is at `maven/repository/target/repository`. 147 | 148 | ## OpenOCD and Thread awareness 149 | 150 | The OpenOCD in the Zephyr SDK can export information on threads for GDB. 151 | To utilize this capability, `CONFIG_OPENOCD_SUPPORT` must be enabled in 152 | the project configuration file to export information on threads. 153 | Also, the board's openocd configuration file must have the following line: 154 | 155 | ``` 156 | $_TARGETNAME configure -rtos auto 157 | ``` 158 | 159 | This line tells OpenOCD to search for exported information on threads. 160 | 161 | With the correct configuration mentioned above, information on available 162 | threads will be displayed in Eclipse's debug perspective. 163 | 164 | ## Troubleshooting 165 | 166 | * Eclipse is not responding after clicking Finish at project creation. 167 | 168 | > Due to the Zephyr source tree being linked within the project, 169 | > it may take some time for Eclipse to traverse the whole tree. 170 | > For example, after running sanity check, the output folder contains 171 | > a large amount of files for Eclipse to traverse. 172 | -------------------------------------------------------------------------------- /features/org.zephyrproject.ide.eclipse-feature/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /features/org.zephyrproject.ide.eclipse-feature/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /features/org.zephyrproject.ide.eclipse-feature/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.zephyrproject.ide.eclipse-feature 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.FeatureBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.m2e.core.maven2Nature 27 | org.eclipse.pde.FeatureNature 28 | 29 | 30 | -------------------------------------------------------------------------------- /features/org.zephyrproject.ide.eclipse-feature/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /features/org.zephyrproject.ide.eclipse-feature/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 8 | org.eclipse.jdt.core.compiler.source=1.8 9 | -------------------------------------------------------------------------------- /features/org.zephyrproject.ide.eclipse-feature/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /features/org.zephyrproject.ide.eclipse-feature/build.properties: -------------------------------------------------------------------------------- 1 | bin.includes = feature.xml 2 | -------------------------------------------------------------------------------- /features/org.zephyrproject.ide.eclipse-feature/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | 7 | org.zephyrproject 8 | org.zephyrproject.ide.eclipse.parent 9 | 0.2.99-SNAPSHOT 10 | ../../maven/parent 11 | 12 | 13 | org.zephyrproject.ide.eclipse 14 | eclipse-feature 15 | 16 | Zephyr Project Eclipse Plugin 17 | https://www.zephyrproject.org/ 18 | 19 | 20 | Zephyr Project 21 | https://www.zephyrproject.org/ 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /maven/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.zephyrproject.ide.eclipse.parent 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /maven/parent/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.zephyrproject.ide.eclipse.parent 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /maven/parent/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /maven/parent/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /maven/parent/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | 7 | 3.3.0 8 | 9 | 10 | org.zephyrproject 11 | org.zephyrproject.ide.eclipse.parent 12 | 0.2.99-SNAPSHOT 13 | pom 14 | 15 | Zephyr Project Eclipse Plugin parent 16 | https://www.zephyrproject.org/ 17 | 18 | 19 | Zephyr Project 20 | https://www.zephyrproject.org/ 21 | 22 | 23 | 24 | 1.4.0 25 | UTF-8 26 | yyyyMMddHHmm 27 | 28 | 29 | 30 | 31 | eclipse-release 32 | p2 33 | http://download.eclipse.org/releases/2019-12 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.eclipse.tycho 41 | tycho-maven-plugin 42 | ${tycho.version} 43 | true 44 | 45 | 46 | 47 | org.eclipse.tycho 48 | target-platform-configuration 49 | ${tycho.version} 50 | 51 | p2 52 | consider 53 | 54 | 55 | 56 | linux 57 | gtk 58 | x86_64 59 | 60 | 61 | win32 62 | win32 63 | x86_64 64 | 65 | 66 | macosx 67 | cocoa 68 | x86_64 69 | 70 | 71 | 72 | 73 | 74 | 75 | org.eclipse.tycho 76 | tycho-versions-plugin 77 | 1.4.0 78 | 79 | 80 | 81 | org.eclipse.tycho.extras 82 | tycho-source-feature-plugin 83 | ${tycho.version} 84 | 85 | 86 | source-feature 87 | package 88 | 89 | source-feature 90 | 91 | 92 | 93 | 94 | 95 | 96 | org.eclipse.tycho 97 | tycho-source-plugin 98 | ${tycho.version} 99 | 100 | 101 | plugin-source 102 | 103 | plugin-source 104 | 105 | 106 | 107 | 108 | 109 | 110 | org.eclipse.tycho 111 | tycho-p2-plugin 112 | ${tycho.version} 113 | 114 | 115 | attached-p2-metadata 116 | package 117 | 118 | p2-metadata 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | org.eclipse.tycho 131 | tycho-compiler-plugin 132 | ${tycho.version} 133 | 134 | UTF-8 135 | true 136 | 137 | 138 | 139 | 140 | org.eclipse.tycho 141 | tycho-p2-repository-plugin 142 | ${tycho.version} 143 | 144 | false 145 | false 146 | 147 | 148 | 149 | 150 | org.eclipse.tycho 151 | tycho-p2-publisher-plugin 152 | ${tycho.version} 153 | 154 | true 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /maven/repository/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /maven/repository/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.zephyrproject.ide.eclipse.repository 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /maven/repository/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /maven/repository/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /maven/repository/category.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /maven/repository/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | 7 | org.zephyrproject 8 | org.zephyrproject.ide.eclipse.parent 9 | 0.2.99-SNAPSHOT 10 | ../parent 11 | 12 | 13 | org.zephyrproject.ide.eclipse.repository 14 | eclipse-repository 15 | 16 | Zephyr Project Eclipse Plugin Repository 17 | https://www.zephyrproject.org/ 18 | 19 | 20 | Zephyr Project 21 | https://www.zephyrproject.org/ 22 | 23 | 24 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.java11/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.java11/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /target/ 3 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.java11/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.zephyrproject.ide.eclipse.core.java11 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.pde.PluginNature 26 | org.eclipse.jdt.core.javanature 27 | 28 | 29 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.java11/.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | cleanup.add_default_serial_version_id=true 2 | cleanup.add_generated_serial_version_id=false 3 | cleanup.add_missing_annotations=true 4 | cleanup.add_missing_deprecated_annotations=true 5 | cleanup.add_missing_methods=false 6 | cleanup.add_missing_nls_tags=false 7 | cleanup.add_missing_override_annotations=true 8 | cleanup.add_missing_override_annotations_interface_methods=true 9 | cleanup.add_serial_version_id=false 10 | cleanup.always_use_blocks=true 11 | cleanup.always_use_parentheses_in_expressions=true 12 | cleanup.always_use_this_for_non_static_field_access=false 13 | cleanup.always_use_this_for_non_static_method_access=false 14 | cleanup.convert_functional_interfaces=false 15 | cleanup.convert_to_enhanced_for_loop=false 16 | cleanup.correct_indentation=true 17 | cleanup.format_source_code=false 18 | cleanup.format_source_code_changes_only=false 19 | cleanup.insert_inferred_type_arguments=false 20 | cleanup.make_local_variable_final=true 21 | cleanup.make_parameters_final=false 22 | cleanup.make_private_fields_final=true 23 | cleanup.make_type_abstract_if_missing_method=false 24 | cleanup.make_variable_declarations_final=false 25 | cleanup.never_use_blocks=false 26 | cleanup.never_use_parentheses_in_expressions=false 27 | cleanup.organize_imports=false 28 | cleanup.qualify_static_field_accesses_with_declaring_class=false 29 | cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true 30 | cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true 31 | cleanup.qualify_static_member_accesses_with_declaring_class=true 32 | cleanup.qualify_static_method_accesses_with_declaring_class=false 33 | cleanup.remove_private_constructors=true 34 | cleanup.remove_redundant_type_arguments=false 35 | cleanup.remove_trailing_whitespaces=true 36 | cleanup.remove_trailing_whitespaces_all=true 37 | cleanup.remove_trailing_whitespaces_ignore_empty=false 38 | cleanup.remove_unnecessary_casts=true 39 | cleanup.remove_unnecessary_nls_tags=true 40 | cleanup.remove_unused_imports=true 41 | cleanup.remove_unused_local_variables=false 42 | cleanup.remove_unused_private_fields=true 43 | cleanup.remove_unused_private_members=false 44 | cleanup.remove_unused_private_methods=true 45 | cleanup.remove_unused_private_types=true 46 | cleanup.sort_members=false 47 | cleanup.sort_members_all=false 48 | cleanup.use_anonymous_class_creation=false 49 | cleanup.use_blocks=true 50 | cleanup.use_blocks_only_for_return_and_throw=false 51 | cleanup.use_lambda=true 52 | cleanup.use_parentheses_in_expressions=false 53 | cleanup.use_this_for_non_static_field_access=false 54 | cleanup.use_this_for_non_static_field_access_only_if_necessary=true 55 | cleanup.use_this_for_non_static_method_access=false 56 | cleanup.use_this_for_non_static_method_access_only_if_necessary=true 57 | cleanup_profile=_Zephyr 58 | cleanup_settings_version=2 59 | eclipse.preferences.version=1 60 | formatter_profile=_Zephyr 61 | formatter_settings_version=12 62 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.java11/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Zephyr Project Development Support - Core - Java11 4 | Bundle-SymbolicName: org.zephyrproject.ide.eclipse.core.java11;singleton:=true 5 | Bundle-Version: 0.2.99.qualifier 6 | Fragment-Host: org.zephyrproject.ide.eclipse.core;bundle-version="0.2.99" 7 | Bundle-RequiredExecutionEnvironment: JavaSE-11 8 | Export-Package: org.zephyrproject.ide.eclipse.core.internal.launch.java11 9 | Bundle-Vendor: Zephyr Project 10 | Automatic-Module-Name: org.zephyrproject.ide.eclipse.core.java11 11 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.java11/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = target/classes/ 3 | bin.includes = META-INF/,\ 4 | . 5 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.java11/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | 7 | org.zephyrproject 8 | org.zephyrproject.ide.eclipse.parent 9 | 0.2.99-SNAPSHOT 10 | ../../maven/parent 11 | 12 | 13 | Zephyr Project Eclipse Plugin - Core - Java11 14 | https://www.zephyrproject.org/ 15 | 16 | 17 | Zephyr Project 18 | https://www.zephyrproject.org/ 19 | 20 | 21 | org.zephyrproject.ide.eclipse.core.java11 22 | eclipse-plugin 23 | 24 | 25 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.java11/src/org/zephyrproject/ide/eclipse/core/internal/launch/java11/ZephyrLaunchHelpers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal.launch.java11; 8 | 9 | import java.io.File; 10 | import java.io.IOException; 11 | import java.nio.file.Files; 12 | import java.nio.file.Path; 13 | import java.nio.file.Paths; 14 | import java.util.ArrayList; 15 | 16 | import org.eclipse.core.resources.IProject; 17 | import org.eclipse.core.runtime.CoreException; 18 | import org.eclipse.core.runtime.Platform; 19 | import org.eclipse.debug.core.DebugPlugin; 20 | import org.eclipse.debug.core.ILaunch; 21 | import org.zephyrproject.ide.eclipse.core.build.ZephyrApplicationBuildConfiguration; 22 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 23 | import org.zephyrproject.ide.eclipse.core.launch.IZephyrLaunchHelper; 24 | 25 | public final class ZephyrLaunchHelpers implements IZephyrLaunchHelper { 26 | 27 | public ZephyrLaunchHelpers() { 28 | } 29 | 30 | private static String findCommand(String command) { 31 | if (Platform.getOS().equals(Platform.OS_WIN32)) { 32 | if (!command.toString().endsWith(".exe") //$NON-NLS-1$ 33 | && !command.toString().endsWith(".bat")) { //$NON-NLS-1$ 34 | command = command.trim() + ".exe"; //$NON-NLS-1$ 35 | } 36 | } 37 | 38 | /* Look for it in the path environment var */ 39 | String path = System.getenv("PATH"); //$NON-NLS-1$ 40 | for (String entry : path.split(File.pathSeparator)) { 41 | Path entryPath = Paths.get(entry); 42 | Path cmdPath = entryPath.resolve(command); 43 | if (Files.isExecutable(cmdPath)) { 44 | return cmdPath.toString(); 45 | } 46 | } 47 | 48 | return null; 49 | } 50 | 51 | public Process doMakefile(IProject project, 52 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 53 | String makeProgram, String mode) throws CoreException, IOException { 54 | String[] command = { 55 | makeProgram, 56 | mode 57 | }; 58 | 59 | ProcessBuilder builder = new ProcessBuilder(command) 60 | .directory(appBuildCfg.getBuildDirectory().toFile()); 61 | builder.environment().putAll( 62 | ZephyrHelpers.Launch.getBuildEnvironmentMap(appBuildCfg)); 63 | Process process = builder.start(); 64 | DebugPlugin.newProcess(launch, process, 65 | ZephyrHelpers.getBoardName(project)); 66 | 67 | return process; 68 | } 69 | 70 | public Process doNinja(IProject project, 71 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 72 | String makeProgram, String mode) throws CoreException, IOException { 73 | String[] command = { 74 | makeProgram, 75 | mode 76 | }; 77 | 78 | ProcessBuilder builder = new ProcessBuilder(command) 79 | .directory(appBuildCfg.getBuildDirectory().toFile()); 80 | builder.environment().putAll( 81 | ZephyrHelpers.Launch.getBuildEnvironmentMap(appBuildCfg)); 82 | Process process = builder.start(); 83 | DebugPlugin.newProcess(launch, process, 84 | ZephyrHelpers.getBoardName(project)); 85 | 86 | return process; 87 | } 88 | 89 | public Process runWest(IProject project, 90 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 91 | String action, String args) throws CoreException, IOException { 92 | String westPath = ZephyrHelpers.getWestPath(project); 93 | 94 | /* 95 | * Path to West may not have been cached by CMake. 96 | * So this try to find West here. 97 | */ 98 | if ((westPath == null) || (westPath.trim().isEmpty())) { 99 | westPath = findCommand("west"); //$NON-NLS-1$ 100 | } 101 | 102 | if ((westPath == null) || (westPath.trim().isEmpty())) { 103 | throw new CoreException(ZephyrHelpers.errorStatus( 104 | "Project is not correctly configured.", //$NON-NLS-1$ 105 | new RuntimeException("Cannot get path for West."))); //$NON-NLS-1$ 106 | } 107 | 108 | ArrayList cmds = new ArrayList(); 109 | 110 | if (westPath.indexOf(';') == -1) { 111 | cmds.add(westPath); 112 | } else { 113 | String[] westPathBits = westPath.split(";"); 114 | for (String s : westPathBits) { 115 | cmds.add(s); 116 | } 117 | } 118 | 119 | cmds.add(action); 120 | if (args != null) { 121 | cmds.addAll(ZephyrHelpers.parseWestArguments(args)); 122 | } 123 | 124 | String[] command = cmds.toArray(new String[0]); 125 | 126 | ProcessBuilder builder = new ProcessBuilder(command) 127 | .directory(appBuildCfg.getBuildDirectory().toFile()); 128 | builder.environment().putAll( 129 | ZephyrHelpers.Launch.getBuildEnvironmentMap(appBuildCfg)); 130 | Process process = builder.start(); 131 | DebugPlugin.newProcess(launch, process, 132 | ZephyrHelpers.getBoardName(project)); 133 | 134 | return process; 135 | } 136 | 137 | } 138 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.java11/src/org/zephyrproject/ide/eclipse/core/internal/launch/java11/ZephyrRuntimeProcess.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal.launch.java11; 8 | 9 | import java.util.Map; 10 | import java.util.stream.Stream; 11 | 12 | import org.eclipse.debug.core.DebugException; 13 | import org.eclipse.debug.core.ILaunch; 14 | import org.eclipse.debug.core.model.RuntimeProcess; 15 | 16 | public class ZephyrRuntimeProcess extends RuntimeProcess { 17 | 18 | public ZephyrRuntimeProcess(ILaunch launch, Process process, String name, 19 | Map attributes) { 20 | super(launch, process, name, attributes); 21 | } 22 | 23 | @Override 24 | public void terminate() throws DebugException { 25 | if (!isTerminated()) { 26 | Process process = getSystemProcess(); 27 | 28 | try { 29 | /* Stop all descendants */ 30 | Stream handles = process.descendants(); 31 | handles.forEach(ProcessHandle::destroy); 32 | } catch (Exception e) { 33 | } 34 | } 35 | 36 | super.terminate(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.linux/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.linux/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /target/ 3 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.linux/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.zephyrproject.ide.eclipse.core.linux 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.pde.PluginNature 26 | org.eclipse.jdt.core.javanature 27 | 28 | 29 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.linux/.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | cleanup.add_default_serial_version_id=true 2 | cleanup.add_generated_serial_version_id=false 3 | cleanup.add_missing_annotations=true 4 | cleanup.add_missing_deprecated_annotations=true 5 | cleanup.add_missing_methods=false 6 | cleanup.add_missing_nls_tags=false 7 | cleanup.add_missing_override_annotations=true 8 | cleanup.add_missing_override_annotations_interface_methods=true 9 | cleanup.add_serial_version_id=false 10 | cleanup.always_use_blocks=true 11 | cleanup.always_use_parentheses_in_expressions=true 12 | cleanup.always_use_this_for_non_static_field_access=false 13 | cleanup.always_use_this_for_non_static_method_access=false 14 | cleanup.convert_functional_interfaces=false 15 | cleanup.convert_to_enhanced_for_loop=false 16 | cleanup.correct_indentation=true 17 | cleanup.format_source_code=false 18 | cleanup.format_source_code_changes_only=false 19 | cleanup.insert_inferred_type_arguments=false 20 | cleanup.make_local_variable_final=true 21 | cleanup.make_parameters_final=false 22 | cleanup.make_private_fields_final=true 23 | cleanup.make_type_abstract_if_missing_method=false 24 | cleanup.make_variable_declarations_final=false 25 | cleanup.never_use_blocks=false 26 | cleanup.never_use_parentheses_in_expressions=false 27 | cleanup.organize_imports=false 28 | cleanup.qualify_static_field_accesses_with_declaring_class=false 29 | cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true 30 | cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true 31 | cleanup.qualify_static_member_accesses_with_declaring_class=true 32 | cleanup.qualify_static_method_accesses_with_declaring_class=false 33 | cleanup.remove_private_constructors=true 34 | cleanup.remove_redundant_type_arguments=false 35 | cleanup.remove_trailing_whitespaces=true 36 | cleanup.remove_trailing_whitespaces_all=true 37 | cleanup.remove_trailing_whitespaces_ignore_empty=false 38 | cleanup.remove_unnecessary_casts=true 39 | cleanup.remove_unnecessary_nls_tags=true 40 | cleanup.remove_unused_imports=true 41 | cleanup.remove_unused_local_variables=false 42 | cleanup.remove_unused_private_fields=true 43 | cleanup.remove_unused_private_members=false 44 | cleanup.remove_unused_private_methods=true 45 | cleanup.remove_unused_private_types=true 46 | cleanup.sort_members=false 47 | cleanup.sort_members_all=false 48 | cleanup.use_anonymous_class_creation=false 49 | cleanup.use_blocks=true 50 | cleanup.use_blocks_only_for_return_and_throw=false 51 | cleanup.use_lambda=true 52 | cleanup.use_parentheses_in_expressions=false 53 | cleanup.use_this_for_non_static_field_access=false 54 | cleanup.use_this_for_non_static_field_access_only_if_necessary=true 55 | cleanup.use_this_for_non_static_method_access=false 56 | cleanup.use_this_for_non_static_method_access_only_if_necessary=true 57 | cleanup_profile=_Zephyr 58 | cleanup_settings_version=2 59 | eclipse.preferences.version=1 60 | formatter_profile=_Zephyr 61 | formatter_settings_version=12 62 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.linux/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Zephyr Project Development Support - Core - Linux 4 | Bundle-SymbolicName: org.zephyrproject.ide.eclipse.core.linux;singleton:=true 5 | Bundle-Version: 0.2.99.qualifier 6 | Fragment-Host: org.zephyrproject.ide.eclipse.core;bundle-version="0.2.99" 7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 8 | Eclipse-PlatformFilter: (osgi.os=linux) 9 | Export-Package: org.zephyrproject.ide.eclipse.core.internal.launch.linux 10 | Bundle-Vendor: Zephyr Project 11 | Automatic-Module-Name: org.zephyrproject.ide.eclipse.core.linux 12 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.linux/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = target/classes/ 3 | bin.includes = META-INF/,\ 4 | . 5 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.linux/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | 7 | org.zephyrproject 8 | org.zephyrproject.ide.eclipse.parent 9 | 0.2.99-SNAPSHOT 10 | ../../maven/parent 11 | 12 | 13 | Zephyr Project Eclipse Plugin - Core - Linux 14 | https://www.zephyrproject.org/ 15 | 16 | 17 | Zephyr Project 18 | https://www.zephyrproject.org/ 19 | 20 | 21 | org.zephyrproject.ide.eclipse.core.linux 22 | eclipse-plugin 23 | 24 | 25 | 26 | 27 | org.eclipse.tycho 28 | target-platform-configuration 29 | ${tycho.version} 30 | 31 | p2 32 | consider 33 | 34 | 35 | 36 | linux 37 | gtk 38 | x86_64 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.linux/src/org/zephyrproject/ide/eclipse/core/internal/launch/linux/ZephyrLaunchHelpers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal.launch.linux; 8 | 9 | import java.io.File; 10 | import java.io.IOException; 11 | import java.nio.file.Files; 12 | import java.nio.file.Path; 13 | import java.nio.file.Paths; 14 | import java.util.ArrayList; 15 | 16 | import org.eclipse.core.resources.IProject; 17 | import org.eclipse.core.runtime.CoreException; 18 | import org.eclipse.debug.core.DebugPlugin; 19 | import org.eclipse.debug.core.ILaunch; 20 | import org.zephyrproject.ide.eclipse.core.build.ZephyrApplicationBuildConfiguration; 21 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 22 | import org.zephyrproject.ide.eclipse.core.launch.IZephyrLaunchHelper; 23 | 24 | public final class ZephyrLaunchHelpers implements IZephyrLaunchHelper { 25 | 26 | public ZephyrLaunchHelpers() { 27 | } 28 | 29 | private static String findCommand(String command) { 30 | /* Look for it in the path environment var */ 31 | String path = System.getenv("PATH"); //$NON-NLS-1$ 32 | for (String entry : path.split(File.pathSeparator)) { 33 | Path entryPath = Paths.get(entry); 34 | Path cmdPath = entryPath.resolve(command); 35 | if (Files.isExecutable(cmdPath)) { 36 | return cmdPath.toString(); 37 | } 38 | } 39 | 40 | return null; 41 | } 42 | 43 | public Process doMakefile(IProject project, 44 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 45 | String makeProgram, String mode) throws CoreException, IOException { 46 | String[] command = { 47 | makeProgram, 48 | mode 49 | }; 50 | 51 | ProcessBuilder builder = new ProcessBuilder(command) 52 | .directory(appBuildCfg.getBuildDirectory().toFile()); 53 | builder.environment().putAll( 54 | ZephyrHelpers.Launch.getBuildEnvironmentMap(appBuildCfg)); 55 | Process process = builder.start(); 56 | DebugPlugin.newProcess(launch, process, 57 | ZephyrHelpers.getBoardName(project)); 58 | 59 | return process; 60 | } 61 | 62 | public Process doNinja(IProject project, 63 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 64 | String makeProgram, String mode) throws CoreException, IOException { 65 | String[] command = { 66 | makeProgram, 67 | mode 68 | }; 69 | 70 | ProcessBuilder builder = new ProcessBuilder(command) 71 | .directory(appBuildCfg.getBuildDirectory().toFile()); 72 | builder.environment().putAll( 73 | ZephyrHelpers.Launch.getBuildEnvironmentMap(appBuildCfg)); 74 | Process process = builder.start(); 75 | DebugPlugin.newProcess(launch, process, 76 | ZephyrHelpers.getBoardName(project)); 77 | 78 | return process; 79 | } 80 | 81 | public Process runWest(IProject project, 82 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 83 | String action, String args) throws CoreException, IOException { 84 | String westPath = ZephyrHelpers.getWestPath(project); 85 | 86 | /* 87 | * Path to West may not have been cached by CMake. 88 | * So this try to find West here. 89 | */ 90 | if ((westPath == null) || (westPath.trim().isEmpty())) { 91 | westPath = findCommand("west"); //$NON-NLS-1$ 92 | } 93 | 94 | if ((westPath == null) || (westPath.trim().isEmpty())) { 95 | throw new CoreException(ZephyrHelpers.errorStatus( 96 | "Project is not correctly configured.", //$NON-NLS-1$ 97 | new RuntimeException("Cannot get path for West."))); //$NON-NLS-1$ 98 | } 99 | 100 | ArrayList cmds = new ArrayList(); 101 | 102 | if (westPath.indexOf(';') == -1) { 103 | cmds.add(westPath); 104 | } else { 105 | String[] westPathBits = westPath.split(";"); 106 | for (String s : westPathBits) { 107 | cmds.add(s); 108 | } 109 | } 110 | 111 | cmds.add(action); 112 | if (args != null) { 113 | cmds.add(args); 114 | } 115 | 116 | String[] command = cmds.toArray(new String[0]); 117 | 118 | ProcessBuilder builder = new ProcessBuilder(command) 119 | .directory(appBuildCfg.getBuildDirectory().toFile()); 120 | builder.environment().putAll( 121 | ZephyrHelpers.Launch.getBuildEnvironmentMap(appBuildCfg)); 122 | Process process = builder.start(); 123 | DebugPlugin.newProcess(launch, process, 124 | ZephyrHelpers.getBoardName(project)); 125 | 126 | return process; 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.linux/src/org/zephyrproject/ide/eclipse/core/internal/launch/linux/ZephyrRuntimeProcess.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal.launch.linux; 8 | 9 | import java.io.BufferedReader; 10 | import java.io.InputStreamReader; 11 | import java.lang.reflect.Field; 12 | import java.util.ArrayList; 13 | import java.util.HashSet; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | import org.eclipse.debug.core.DebugException; 18 | import org.eclipse.debug.core.ILaunch; 19 | import org.eclipse.debug.core.model.RuntimeProcess; 20 | 21 | public class ZephyrRuntimeProcess extends RuntimeProcess { 22 | 23 | public ZephyrRuntimeProcess(ILaunch launch, Process process, String name, 24 | Map attributes) { 25 | super(launch, process, name, attributes); 26 | } 27 | 28 | @Override 29 | public void terminate() throws DebugException { 30 | Process process = getSystemProcess(); 31 | 32 | if (!isTerminated() 33 | && (process.getClass().getName().equals("java.lang.UNIXProcess") 34 | || process.getClass().getName() 35 | .equals("java.lang.ProcessImpl"))) { 36 | /* For Linux and macOS */ 37 | try { 38 | /* Grab the PID from root of process tree */ 39 | Field fPid = process.getClass().getDeclaredField("pid"); 40 | fPid.setAccessible(true); 41 | int pid = fPid.getInt(process); 42 | fPid.setAccessible(false); 43 | 44 | /* Find all leaf nodes in the process tree */ 45 | HashSet leafPids = new HashSet(); 46 | findAllLeafProcesses(pid, leafPids); 47 | 48 | /* Terminate the leaf node processes */ 49 | ArrayList cmd = new ArrayList(); 50 | cmd.add("kill"); //$NON-NLS-1$ 51 | cmd.add("-s TERM"); // $NON-NLS-1$ 52 | for (Integer p : leafPids) { 53 | cmd.add(p.toString()); 54 | } 55 | 56 | ProcessBuilder pb = 57 | new ProcessBuilder(cmd.toArray(new String[0])); 58 | pb.start().waitFor(); 59 | 60 | } catch (Exception e) { 61 | } 62 | } 63 | 64 | super.terminate(); 65 | } 66 | 67 | private void findAllLeafProcesses(Integer pid, HashSet pids) { 68 | 69 | if (pids == null) { 70 | return; 71 | } 72 | 73 | if (pid <= 1) { 74 | return; 75 | } 76 | 77 | String[] command = { 78 | "pgrep", //$NON-NLS-1$ 79 | "-P", //$NON-NLS-1$ , 80 | pid.toString() 81 | }; 82 | 83 | ProcessBuilder pb = new ProcessBuilder(command); 84 | Process process; 85 | try { 86 | process = pb.start(); 87 | int exitval = process.waitFor(); 88 | boolean noChild = false; 89 | 90 | if (exitval == 0) { 91 | /* pgrep succeeded, parse for children PIDs */ 92 | BufferedReader reader = new BufferedReader( 93 | new InputStreamReader(process.getInputStream())); 94 | String line; 95 | List children = new ArrayList<>(); 96 | while ((line = reader.readLine()) != null) { 97 | children.add(line); 98 | } 99 | reader.close(); 100 | 101 | if (children.isEmpty()) { 102 | /* If nothing is returned, assume no children */ 103 | noChild = true; 104 | } else { 105 | /* Go through each PIDs and find their children */ 106 | for (String child : children) { 107 | try { 108 | Integer cPid = Integer.valueOf(child); 109 | findAllLeafProcesses(cPid, pids); 110 | } catch (NumberFormatException e) { 111 | } 112 | } 113 | } 114 | } 115 | 116 | if ((exitval != 0) || noChild) { 117 | /* No more children, so this is a leaf node */ 118 | pids.add(pid); 119 | } 120 | } catch (Exception e) { 121 | } 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.macosx/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.macosx/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /target/ 3 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.macosx/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.zephyrproject.ide.eclipse.core.macosx 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.pde.PluginNature 26 | org.eclipse.jdt.core.javanature 27 | 28 | 29 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.macosx/.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | cleanup.add_default_serial_version_id=true 2 | cleanup.add_generated_serial_version_id=false 3 | cleanup.add_missing_annotations=true 4 | cleanup.add_missing_deprecated_annotations=true 5 | cleanup.add_missing_methods=false 6 | cleanup.add_missing_nls_tags=false 7 | cleanup.add_missing_override_annotations=true 8 | cleanup.add_missing_override_annotations_interface_methods=true 9 | cleanup.add_serial_version_id=false 10 | cleanup.always_use_blocks=true 11 | cleanup.always_use_parentheses_in_expressions=true 12 | cleanup.always_use_this_for_non_static_field_access=false 13 | cleanup.always_use_this_for_non_static_method_access=false 14 | cleanup.convert_functional_interfaces=false 15 | cleanup.convert_to_enhanced_for_loop=false 16 | cleanup.correct_indentation=true 17 | cleanup.format_source_code=false 18 | cleanup.format_source_code_changes_only=false 19 | cleanup.insert_inferred_type_arguments=false 20 | cleanup.make_local_variable_final=true 21 | cleanup.make_parameters_final=false 22 | cleanup.make_private_fields_final=true 23 | cleanup.make_type_abstract_if_missing_method=false 24 | cleanup.make_variable_declarations_final=false 25 | cleanup.never_use_blocks=false 26 | cleanup.never_use_parentheses_in_expressions=false 27 | cleanup.organize_imports=false 28 | cleanup.qualify_static_field_accesses_with_declaring_class=false 29 | cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true 30 | cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true 31 | cleanup.qualify_static_member_accesses_with_declaring_class=true 32 | cleanup.qualify_static_method_accesses_with_declaring_class=false 33 | cleanup.remove_private_constructors=true 34 | cleanup.remove_redundant_type_arguments=false 35 | cleanup.remove_trailing_whitespaces=true 36 | cleanup.remove_trailing_whitespaces_all=true 37 | cleanup.remove_trailing_whitespaces_ignore_empty=false 38 | cleanup.remove_unnecessary_casts=true 39 | cleanup.remove_unnecessary_nls_tags=true 40 | cleanup.remove_unused_imports=true 41 | cleanup.remove_unused_local_variables=false 42 | cleanup.remove_unused_private_fields=true 43 | cleanup.remove_unused_private_members=false 44 | cleanup.remove_unused_private_methods=true 45 | cleanup.remove_unused_private_types=true 46 | cleanup.sort_members=false 47 | cleanup.sort_members_all=false 48 | cleanup.use_anonymous_class_creation=false 49 | cleanup.use_blocks=true 50 | cleanup.use_blocks_only_for_return_and_throw=false 51 | cleanup.use_lambda=true 52 | cleanup.use_parentheses_in_expressions=false 53 | cleanup.use_this_for_non_static_field_access=false 54 | cleanup.use_this_for_non_static_field_access_only_if_necessary=true 55 | cleanup.use_this_for_non_static_method_access=false 56 | cleanup.use_this_for_non_static_method_access_only_if_necessary=true 57 | cleanup_profile=_Zephyr 58 | cleanup_settings_version=2 59 | eclipse.preferences.version=1 60 | formatter_profile=_Zephyr 61 | formatter_settings_version=12 62 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.macosx/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Zephyr Project Development Support - Core - MacOSX 4 | Bundle-SymbolicName: org.zephyrproject.ide.eclipse.core.macosx;singleton:=true 5 | Bundle-Version: 0.2.99.qualifier 6 | Fragment-Host: org.zephyrproject.ide.eclipse.core;bundle-version="0.2.99" 7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 8 | Eclipse-PlatformFilter: (osgi.os=macosx) 9 | Export-Package: org.zephyrproject.ide.eclipse.core.internal.launch.macosx 10 | Bundle-Vendor: Zephyr Project 11 | Automatic-Module-Name: org.zephyrproject.ide.eclipse.core.macosx 12 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.macosx/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = target/classes/ 3 | bin.includes = META-INF/,\ 4 | . 5 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.macosx/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | 7 | org.zephyrproject 8 | org.zephyrproject.ide.eclipse.parent 9 | 0.2.99-SNAPSHOT 10 | ../../maven/parent 11 | 12 | 13 | Zephyr Project Eclipse Plugin - Core - MacOS 14 | https://www.zephyrproject.org/ 15 | 16 | 17 | Zephyr Project 18 | https://www.zephyrproject.org/ 19 | 20 | 21 | org.zephyrproject.ide.eclipse.core.macosx 22 | eclipse-plugin 23 | 24 | 25 | 26 | 27 | org.eclipse.tycho 28 | target-platform-configuration 29 | ${tycho.version} 30 | 31 | p2 32 | consider 33 | 34 | 35 | 36 | macosx 37 | cocoa 38 | x86_64 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.macosx/src/org/zephyrproject/ide/eclipse/core/internal/launch/macosx/ZephyrLaunchHelpers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal.launch.macosx; 8 | 9 | import java.io.File; 10 | import java.io.IOException; 11 | import java.nio.file.Files; 12 | import java.nio.file.Path; 13 | import java.nio.file.Paths; 14 | import java.util.ArrayList; 15 | 16 | import org.eclipse.core.resources.IProject; 17 | import org.eclipse.core.runtime.CoreException; 18 | import org.eclipse.debug.core.DebugPlugin; 19 | import org.eclipse.debug.core.ILaunch; 20 | import org.zephyrproject.ide.eclipse.core.build.ZephyrApplicationBuildConfiguration; 21 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 22 | import org.zephyrproject.ide.eclipse.core.launch.IZephyrLaunchHelper; 23 | 24 | public final class ZephyrLaunchHelpers implements IZephyrLaunchHelper { 25 | 26 | public ZephyrLaunchHelpers() { 27 | } 28 | 29 | private static String findCommand(String command) { 30 | /* Look for it in the path environment var */ 31 | String path = System.getenv("PATH"); //$NON-NLS-1$ 32 | for (String entry : path.split(File.pathSeparator)) { 33 | Path entryPath = Paths.get(entry); 34 | Path cmdPath = entryPath.resolve(command); 35 | if (Files.isExecutable(cmdPath)) { 36 | return cmdPath.toString(); 37 | } 38 | } 39 | 40 | return null; 41 | } 42 | 43 | public Process doMakefile(IProject project, 44 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 45 | String makeProgram, String mode) throws CoreException, IOException { 46 | String[] command = { 47 | makeProgram, 48 | mode 49 | }; 50 | 51 | ProcessBuilder builder = new ProcessBuilder(command) 52 | .directory(appBuildCfg.getBuildDirectory().toFile()); 53 | builder.environment().putAll( 54 | ZephyrHelpers.Launch.getBuildEnvironmentMap(appBuildCfg)); 55 | Process process = builder.start(); 56 | DebugPlugin.newProcess(launch, process, 57 | ZephyrHelpers.getBoardName(project)); 58 | 59 | return process; 60 | } 61 | 62 | public Process doNinja(IProject project, 63 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 64 | String makeProgram, String mode) throws CoreException, IOException { 65 | String[] command = { 66 | makeProgram, 67 | mode 68 | }; 69 | 70 | ProcessBuilder builder = new ProcessBuilder(command) 71 | .directory(appBuildCfg.getBuildDirectory().toFile()); 72 | builder.environment().putAll( 73 | ZephyrHelpers.Launch.getBuildEnvironmentMap(appBuildCfg)); 74 | Process process = builder.start(); 75 | DebugPlugin.newProcess(launch, process, 76 | ZephyrHelpers.getBoardName(project)); 77 | 78 | return process; 79 | } 80 | 81 | public Process runWest(IProject project, 82 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 83 | String action, String args) throws CoreException, IOException { 84 | String westPath = ZephyrHelpers.getWestPath(project); 85 | 86 | /* 87 | * Path to West may not have been cached by CMake. 88 | * So this try to find West here. 89 | */ 90 | if ((westPath == null) || (westPath.trim().isEmpty())) { 91 | westPath = findCommand("west"); //$NON-NLS-1$ 92 | } 93 | 94 | if ((westPath == null) || (westPath.trim().isEmpty())) { 95 | throw new CoreException(ZephyrHelpers.errorStatus( 96 | "Project is not correctly configured.", //$NON-NLS-1$ 97 | new RuntimeException("Cannot get path for West."))); //$NON-NLS-1$ 98 | } 99 | 100 | ArrayList cmds = new ArrayList(); 101 | 102 | if (westPath.indexOf(';') == -1) { 103 | cmds.add(westPath); 104 | } else { 105 | String[] westPathBits = westPath.split(";"); 106 | for (String s : westPathBits) { 107 | cmds.add(s); 108 | } 109 | } 110 | 111 | cmds.add(action); 112 | if (args != null) { 113 | cmds.add(args); 114 | } 115 | 116 | String[] command = cmds.toArray(new String[0]); 117 | 118 | ProcessBuilder builder = new ProcessBuilder(command) 119 | .directory(appBuildCfg.getBuildDirectory().toFile()); 120 | builder.environment().putAll( 121 | ZephyrHelpers.Launch.getBuildEnvironmentMap(appBuildCfg)); 122 | Process process = builder.start(); 123 | DebugPlugin.newProcess(launch, process, 124 | ZephyrHelpers.getBoardName(project)); 125 | 126 | return process; 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.macosx/src/org/zephyrproject/ide/eclipse/core/internal/launch/macosx/ZephyrRuntimeProcess.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal.launch.macosx; 8 | 9 | import java.io.BufferedReader; 10 | import java.io.InputStreamReader; 11 | import java.lang.reflect.Field; 12 | import java.util.ArrayList; 13 | import java.util.HashSet; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | import org.eclipse.debug.core.DebugException; 18 | import org.eclipse.debug.core.ILaunch; 19 | import org.eclipse.debug.core.model.RuntimeProcess; 20 | 21 | public class ZephyrRuntimeProcess extends RuntimeProcess { 22 | 23 | public ZephyrRuntimeProcess(ILaunch launch, Process process, String name, 24 | Map attributes) { 25 | super(launch, process, name, attributes); 26 | } 27 | 28 | @Override 29 | public void terminate() throws DebugException { 30 | Process process = getSystemProcess(); 31 | 32 | if (!isTerminated() 33 | && (process.getClass().getName().equals("java.lang.UNIXProcess") 34 | || process.getClass().getName() 35 | .equals("java.lang.ProcessImpl"))) { 36 | /* For Linux and macOS */ 37 | try { 38 | /* Grab the PID from root of process tree */ 39 | Field fPid = process.getClass().getDeclaredField("pid"); 40 | fPid.setAccessible(true); 41 | int pid = fPid.getInt(process); 42 | fPid.setAccessible(false); 43 | 44 | /* Find all leaf nodes in the process tree */ 45 | HashSet leafPids = new HashSet(); 46 | findAllLeafProcesses(pid, leafPids); 47 | 48 | /* Terminate the leaf node processes */ 49 | ArrayList cmd = new ArrayList(); 50 | cmd.add("kill"); //$NON-NLS-1$ 51 | cmd.add("-s TERM"); // $NON-NLS-1$ 52 | for (Integer p : leafPids) { 53 | cmd.add(p.toString()); 54 | } 55 | 56 | ProcessBuilder pb = 57 | new ProcessBuilder(cmd.toArray(new String[0])); 58 | pb.start().waitFor(); 59 | 60 | } catch (Exception e) { 61 | } 62 | } 63 | 64 | super.terminate(); 65 | } 66 | 67 | private void findAllLeafProcesses(Integer pid, HashSet pids) { 68 | 69 | if (pids == null) { 70 | return; 71 | } 72 | 73 | if (pid <= 1) { 74 | return; 75 | } 76 | 77 | String[] command = { 78 | "pgrep", //$NON-NLS-1$ 79 | "-P", //$NON-NLS-1$ , 80 | pid.toString() 81 | }; 82 | 83 | ProcessBuilder pb = new ProcessBuilder(command); 84 | Process process; 85 | try { 86 | process = pb.start(); 87 | int exitval = process.waitFor(); 88 | boolean noChild = false; 89 | 90 | if (exitval == 0) { 91 | /* pgrep succeeded, parse for children PIDs */ 92 | BufferedReader reader = new BufferedReader( 93 | new InputStreamReader(process.getInputStream())); 94 | String line; 95 | List children = new ArrayList<>(); 96 | while ((line = reader.readLine()) != null) { 97 | children.add(line); 98 | } 99 | reader.close(); 100 | 101 | if (children.isEmpty()) { 102 | /* If nothing is returned, assume no children */ 103 | noChild = true; 104 | } else { 105 | /* Go through each PIDs and find their children */ 106 | for (String child : children) { 107 | try { 108 | Integer cPid = Integer.valueOf(child); 109 | findAllLeafProcesses(cPid, pids); 110 | } catch (NumberFormatException e) { 111 | } 112 | } 113 | } 114 | } 115 | 116 | if ((exitval != 0) || noChild) { 117 | /* No more children, so this is a leaf node */ 118 | pids.add(pid); 119 | } 120 | } catch (Exception e) { 121 | } 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.win32/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.win32/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /target/ 3 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.win32/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.zephyrproject.ide.eclipse.core.win32 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.pde.PluginNature 26 | org.eclipse.jdt.core.javanature 27 | 28 | 29 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.win32/.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | cleanup.add_default_serial_version_id=true 2 | cleanup.add_generated_serial_version_id=false 3 | cleanup.add_missing_annotations=true 4 | cleanup.add_missing_deprecated_annotations=true 5 | cleanup.add_missing_methods=false 6 | cleanup.add_missing_nls_tags=false 7 | cleanup.add_missing_override_annotations=true 8 | cleanup.add_missing_override_annotations_interface_methods=true 9 | cleanup.add_serial_version_id=false 10 | cleanup.always_use_blocks=true 11 | cleanup.always_use_parentheses_in_expressions=true 12 | cleanup.always_use_this_for_non_static_field_access=false 13 | cleanup.always_use_this_for_non_static_method_access=false 14 | cleanup.convert_functional_interfaces=false 15 | cleanup.convert_to_enhanced_for_loop=false 16 | cleanup.correct_indentation=true 17 | cleanup.format_source_code=false 18 | cleanup.format_source_code_changes_only=false 19 | cleanup.insert_inferred_type_arguments=false 20 | cleanup.make_local_variable_final=true 21 | cleanup.make_parameters_final=false 22 | cleanup.make_private_fields_final=true 23 | cleanup.make_type_abstract_if_missing_method=false 24 | cleanup.make_variable_declarations_final=false 25 | cleanup.never_use_blocks=false 26 | cleanup.never_use_parentheses_in_expressions=false 27 | cleanup.organize_imports=false 28 | cleanup.qualify_static_field_accesses_with_declaring_class=false 29 | cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true 30 | cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true 31 | cleanup.qualify_static_member_accesses_with_declaring_class=true 32 | cleanup.qualify_static_method_accesses_with_declaring_class=false 33 | cleanup.remove_private_constructors=true 34 | cleanup.remove_redundant_type_arguments=false 35 | cleanup.remove_trailing_whitespaces=true 36 | cleanup.remove_trailing_whitespaces_all=true 37 | cleanup.remove_trailing_whitespaces_ignore_empty=false 38 | cleanup.remove_unnecessary_casts=true 39 | cleanup.remove_unnecessary_nls_tags=true 40 | cleanup.remove_unused_imports=true 41 | cleanup.remove_unused_local_variables=false 42 | cleanup.remove_unused_private_fields=true 43 | cleanup.remove_unused_private_members=false 44 | cleanup.remove_unused_private_methods=true 45 | cleanup.remove_unused_private_types=true 46 | cleanup.sort_members=false 47 | cleanup.sort_members_all=false 48 | cleanup.use_anonymous_class_creation=false 49 | cleanup.use_blocks=true 50 | cleanup.use_blocks_only_for_return_and_throw=false 51 | cleanup.use_lambda=true 52 | cleanup.use_parentheses_in_expressions=false 53 | cleanup.use_this_for_non_static_field_access=false 54 | cleanup.use_this_for_non_static_field_access_only_if_necessary=true 55 | cleanup.use_this_for_non_static_method_access=false 56 | cleanup.use_this_for_non_static_method_access_only_if_necessary=true 57 | cleanup_profile=_Zephyr 58 | cleanup_settings_version=2 59 | eclipse.preferences.version=1 60 | formatter_profile=_Zephyr 61 | formatter_settings_version=12 62 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.win32/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Zephyr Project Development Support - Core - Windows 4 | Bundle-SymbolicName: org.zephyrproject.ide.eclipse.core.win32;singleton:=true 5 | Bundle-Version: 0.2.99.qualifier 6 | Fragment-Host: org.zephyrproject.ide.eclipse.core;bundle-version="0.2.99" 7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 8 | Eclipse-PlatformFilter: (osgi.os=win32) 9 | Export-Package: org.zephyrproject.ide.eclipse.core.internal.launch.win32 10 | Bundle-Vendor: Zephyr Project 11 | Automatic-Module-Name: org.zephyrproject.ide.eclipse.core.win32 12 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.win32/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = target/classes/ 3 | bin.includes = META-INF/,\ 4 | . 5 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.win32/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | 7 | org.zephyrproject 8 | org.zephyrproject.ide.eclipse.parent 9 | 0.2.99-SNAPSHOT 10 | ../../maven/parent 11 | 12 | 13 | Zephyr Project Eclipse Plugin - Core - Windows 14 | https://www.zephyrproject.org/ 15 | 16 | 17 | Zephyr Project 18 | https://www.zephyrproject.org/ 19 | 20 | 21 | org.zephyrproject.ide.eclipse.core.win32 22 | eclipse-plugin 23 | 24 | 25 | 26 | 27 | org.eclipse.tycho 28 | target-platform-configuration 29 | ${tycho.version} 30 | 31 | p2 32 | consider 33 | 34 | 35 | 36 | win32 37 | win32 38 | x86_64 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.win32/src/org/zephyrproject/ide/eclipse/core/internal/launch/win32/ZephyrLaunchHelpers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal.launch.win32; 8 | 9 | import java.io.BufferedWriter; 10 | import java.io.File; 11 | import java.io.FileWriter; 12 | import java.io.IOException; 13 | import java.nio.file.Files; 14 | import java.nio.file.Path; 15 | import java.nio.file.Paths; 16 | 17 | import org.eclipse.core.resources.IProject; 18 | import org.eclipse.core.runtime.CoreException; 19 | import org.eclipse.debug.core.DebugPlugin; 20 | import org.eclipse.debug.core.ILaunch; 21 | import org.zephyrproject.ide.eclipse.core.build.ZephyrApplicationBuildConfiguration; 22 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 23 | import org.zephyrproject.ide.eclipse.core.launch.IZephyrLaunchHelper; 24 | 25 | public final class ZephyrLaunchHelpers implements IZephyrLaunchHelper { 26 | 27 | private static final String BAT_FILE_PREFIX = ".zephyr-eclipse-"; //$NON-NLS-1$ 28 | private static final String BAT_FILE_SUFFIX = ".bat"; //$NON-NLS-1$ 29 | 30 | public ZephyrLaunchHelpers() { 31 | } 32 | 33 | private static String findCommand(String command) { 34 | if (!command.toString().endsWith(".exe") //$NON-NLS-1$ 35 | && !command.toString().endsWith(".bat")) { //$NON-NLS-1$ 36 | command = command.trim() + ".exe"; //$NON-NLS-1$ 37 | } 38 | 39 | /* Look for it in the path environment var */ 40 | String path = System.getenv("PATH"); //$NON-NLS-1$ 41 | for (String entry : path.split(File.pathSeparator)) { 42 | Path entryPath = Paths.get(entry); 43 | Path cmdPath = entryPath.resolve(command); 44 | if (Files.isExecutable(cmdPath)) { 45 | return cmdPath.toString(); 46 | } 47 | } 48 | 49 | return null; 50 | } 51 | 52 | private static Path createBatchFile( 53 | ZephyrApplicationBuildConfiguration appBuildCfg, String cmd) 54 | throws CoreException, IOException { 55 | Path buildDir = appBuildCfg.getBuildDirectory(); 56 | 57 | Path tmpFile = Files.createTempFile(buildDir, BAT_FILE_PREFIX, 58 | BAT_FILE_SUFFIX); 59 | tmpFile.toFile().deleteOnExit(); 60 | 61 | try (BufferedWriter writer = 62 | new BufferedWriter(new FileWriter(tmpFile.toFile()))) { 63 | 64 | writer.write("@echo off"); //$NON-NLS-1$ 65 | writer.newLine(); 66 | 67 | writer.write(String.format("CALL %s", cmd)); //$NON-NLS-1$ 68 | writer.newLine(); 69 | 70 | writer.write("pause"); //$NON-NLS-1$ 71 | writer.newLine(); 72 | 73 | writer.write("exit"); //$NON-NLS-1$ 74 | writer.newLine(); 75 | 76 | writer.flush(); 77 | } 78 | 79 | return tmpFile; 80 | } 81 | 82 | private static Process runCmd(IProject project, 83 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 84 | String cmd) throws CoreException, IOException { 85 | Path batFile = createBatchFile(appBuildCfg, cmd); 86 | 87 | cmd = String.format("cmd.exe /c start \"%s\" /WAIT %s", 88 | ZephyrRuntimeProcess.WINDOWTITLE, 89 | batFile.toAbsolutePath().toString()); 90 | 91 | Process process = Runtime.getRuntime().exec(cmd, 92 | ZephyrHelpers.Launch.getBuildEnvironmentArray(appBuildCfg), 93 | appBuildCfg.getBuildDirectory().toFile()); 94 | DebugPlugin.newProcess(launch, process, 95 | ZephyrHelpers.getBoardName(project)); 96 | 97 | return process; 98 | } 99 | 100 | public Process doMakefile(IProject project, 101 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 102 | String makeProgram, String mode) throws CoreException, IOException { 103 | String cmd = String.format("%s %s", makeProgram, mode); 104 | return runCmd(project, appBuildCfg, launch, cmd); 105 | } 106 | 107 | public Process doNinja(IProject project, 108 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 109 | String makeProgram, String mode) throws CoreException, IOException { 110 | String cmd = String.format("%s %s", makeProgram, mode); 111 | return runCmd(project, appBuildCfg, launch, cmd); 112 | } 113 | 114 | public Process runWest(IProject project, 115 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 116 | String action, String args) throws CoreException, IOException { 117 | String westPath = ZephyrHelpers.getWestPath(project); 118 | 119 | /* 120 | * Path to West may not have been cached by CMake. 121 | * So this try to find West here. 122 | */ 123 | if ((westPath == null) || (westPath.trim().isEmpty())) { 124 | westPath = findCommand("west"); //$NON-NLS-1$ 125 | } 126 | 127 | if ((westPath == null) || (westPath.trim().isEmpty())) { 128 | throw new CoreException(ZephyrHelpers.errorStatus( 129 | "Project is not correctly configured.", //$NON-NLS-1$ 130 | new RuntimeException("Cannot get path for West."))); //$NON-NLS-1$ 131 | } 132 | 133 | if (args == null) { 134 | String cmd = String.format("%s %s", westPath, action); 135 | return runCmd(project, appBuildCfg, launch, cmd); 136 | } else { 137 | String cmd = String.format("%s %s %s", westPath, action, args); 138 | return runCmd(project, appBuildCfg, launch, cmd); 139 | } 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core.win32/src/org/zephyrproject/ide/eclipse/core/internal/launch/win32/ZephyrRuntimeProcess.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal.launch.win32; 8 | 9 | import java.util.Map; 10 | 11 | import org.eclipse.debug.core.DebugException; 12 | import org.eclipse.debug.core.ILaunch; 13 | import org.eclipse.debug.core.model.RuntimeProcess; 14 | 15 | public class ZephyrRuntimeProcess extends RuntimeProcess { 16 | 17 | public static final String WINDOWTITLE = "zephyr-eclipse"; //$NON-NLS-1$ 18 | 19 | public ZephyrRuntimeProcess(ILaunch launch, Process process, String name, 20 | Map attributes) { 21 | super(launch, process, name, attributes); 22 | } 23 | 24 | @Override 25 | public void terminate() throws DebugException { 26 | Process process = getSystemProcess(); 27 | 28 | if (!isTerminated() && (process.getClass().getName() 29 | .equals("java.lang.Win32Process") 30 | || process.getClass().getName() 31 | .equals("java.lang.ProcessImpl"))) { 32 | String killCmd = String.format( 33 | "taskkill /T /F /FI \"WINDOWTITLE eq %s*\"", WINDOWTITLE); 34 | 35 | try { 36 | Process killp = Runtime.getRuntime().exec(killCmd); 37 | int exitval = killp.waitFor(); 38 | if (exitval != 0) { 39 | 40 | } 41 | } catch (Exception e) { 42 | 43 | } 44 | } 45 | 46 | super.terminate(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /target/ 3 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.zephyrproject.ide.eclipse.core 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.m2e.core.maven2Nature 31 | org.eclipse.pde.PluginNature 32 | org.eclipse.jdt.core.javanature 33 | 34 | 35 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | cleanup.add_default_serial_version_id=true 2 | cleanup.add_generated_serial_version_id=false 3 | cleanup.add_missing_annotations=true 4 | cleanup.add_missing_deprecated_annotations=true 5 | cleanup.add_missing_methods=false 6 | cleanup.add_missing_nls_tags=false 7 | cleanup.add_missing_override_annotations=true 8 | cleanup.add_missing_override_annotations_interface_methods=true 9 | cleanup.add_serial_version_id=false 10 | cleanup.always_use_blocks=true 11 | cleanup.always_use_parentheses_in_expressions=true 12 | cleanup.always_use_this_for_non_static_field_access=false 13 | cleanup.always_use_this_for_non_static_method_access=false 14 | cleanup.convert_functional_interfaces=false 15 | cleanup.convert_to_enhanced_for_loop=false 16 | cleanup.correct_indentation=true 17 | cleanup.format_source_code=false 18 | cleanup.format_source_code_changes_only=false 19 | cleanup.insert_inferred_type_arguments=false 20 | cleanup.make_local_variable_final=true 21 | cleanup.make_parameters_final=false 22 | cleanup.make_private_fields_final=true 23 | cleanup.make_type_abstract_if_missing_method=false 24 | cleanup.make_variable_declarations_final=false 25 | cleanup.never_use_blocks=false 26 | cleanup.never_use_parentheses_in_expressions=false 27 | cleanup.organize_imports=false 28 | cleanup.qualify_static_field_accesses_with_declaring_class=false 29 | cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true 30 | cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true 31 | cleanup.qualify_static_member_accesses_with_declaring_class=true 32 | cleanup.qualify_static_method_accesses_with_declaring_class=false 33 | cleanup.remove_private_constructors=true 34 | cleanup.remove_redundant_type_arguments=false 35 | cleanup.remove_trailing_whitespaces=true 36 | cleanup.remove_trailing_whitespaces_all=true 37 | cleanup.remove_trailing_whitespaces_ignore_empty=false 38 | cleanup.remove_unnecessary_casts=true 39 | cleanup.remove_unnecessary_nls_tags=true 40 | cleanup.remove_unused_imports=true 41 | cleanup.remove_unused_local_variables=false 42 | cleanup.remove_unused_private_fields=true 43 | cleanup.remove_unused_private_members=false 44 | cleanup.remove_unused_private_methods=true 45 | cleanup.remove_unused_private_types=true 46 | cleanup.sort_members=false 47 | cleanup.sort_members_all=false 48 | cleanup.use_anonymous_class_creation=false 49 | cleanup.use_blocks=true 50 | cleanup.use_blocks_only_for_return_and_throw=false 51 | cleanup.use_lambda=true 52 | cleanup.use_parentheses_in_expressions=false 53 | cleanup.use_this_for_non_static_field_access=false 54 | cleanup.use_this_for_non_static_field_access_only_if_necessary=true 55 | cleanup.use_this_for_non_static_method_access=false 56 | cleanup.use_this_for_non_static_method_access_only_if_necessary=true 57 | cleanup_profile=_Zephyr 58 | cleanup_settings_version=2 59 | eclipse.preferences.version=1 60 | formatter_profile=_Zephyr 61 | formatter_settings_version=12 62 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/.settings/org.eclipse.pde.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | resolve.requirebundle=false 3 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Zephyr Project Development Support - Core 4 | Bundle-SymbolicName: org.zephyrproject.ide.eclipse.core;singleton:=true 5 | Bundle-Version: 0.2.99.qualifier 6 | Bundle-Activator: org.zephyrproject.ide.eclipse.core.ZephyrPlugin 7 | Bundle-Vendor: Zephyr Project 8 | Require-Bundle: com.google.gson, 9 | org.eclipse.core.runtime;bundle-version="3.17.0", 10 | org.eclipse.core.resources;bundle-version="3.13.600", 11 | org.eclipse.cdt.build.gcc.core;bundle-version="1.0.200", 12 | org.eclipse.cdt.core;bundle-version="6.10.0", 13 | org.eclipse.cdt.debug.core;bundle-version="8.4.0", 14 | org.eclipse.cdt.debug.gdbjtag;bundle-version="7.0.100", 15 | org.eclipse.cdt.debug.gdbjtag.core;bundle-version="9.4.0", 16 | org.eclipse.cdt.dsf;bundle-version="2.8.200", 17 | org.eclipse.cdt.dsf.gdb;bundle-version="5.8.0", 18 | org.eclipse.cdt.launch;bundle-version="9.3.100", 19 | org.eclipse.debug.core;bundle-version="3.14.100", 20 | org.eclipse.tools.templates.freemarker;bundle-version="1.1.2", 21 | org.eclipse.launchbar.core;bundle-version="2.3.0", 22 | org.eclipse.platform;bundle-version="4.14.0", 23 | org.eclipse.ui;bundle-version="3.115.0" 24 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 25 | Automatic-Module-Name: org.zephyrproject.ide.eclipse.core 26 | Bundle-ActivationPolicy: lazy 27 | Export-Package: org.zephyrproject.ide.eclipse.core, 28 | org.zephyrproject.ide.eclipse.core.build, 29 | org.zephyrproject.ide.eclipse.core.build.toolchain, 30 | org.zephyrproject.ide.eclipse.core.internal, 31 | org.zephyrproject.ide.eclipse.core.internal.build, 32 | org.zephyrproject.ide.eclipse.core.launch, 33 | org.zephyrproject.ide.eclipse.core.launchbar, 34 | org.zephyrproject.ide.eclipse.core.preferences 35 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = target/classes/ 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | plugin.xml,\ 6 | templates/ 7 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/plugin.properties: -------------------------------------------------------------------------------- 1 | bundle.name = Zephyr Project Eclipse Plugin 2 | bundle.vendor = Zephyr Project 3 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | 7 | org.zephyrproject 8 | org.zephyrproject.ide.eclipse.parent 9 | 0.2.99-SNAPSHOT 10 | ../../maven/parent 11 | 12 | 13 | Zephyr Project Eclipse Plugin - Core 14 | https://www.zephyrproject.org/ 15 | 16 | 17 | Zephyr Project 18 | https://www.zephyrproject.org/ 19 | 20 | 21 | org.zephyrproject.ide.eclipse.core 22 | eclipse-plugin 23 | 24 | 25 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/ZephyrApplicationBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core; 8 | 9 | import java.util.Map; 10 | 11 | import org.eclipse.cdt.core.CCorePlugin; 12 | import org.eclipse.cdt.core.build.ICBuildConfiguration; 13 | import org.eclipse.cdt.core.resources.IConsole; 14 | import org.eclipse.core.resources.IFile; 15 | import org.eclipse.core.resources.IProject; 16 | import org.eclipse.core.resources.IResource; 17 | import org.eclipse.core.resources.IResourceDelta; 18 | import org.eclipse.core.resources.IncrementalProjectBuilder; 19 | import org.eclipse.core.runtime.CoreException; 20 | import org.eclipse.core.runtime.IProgressMonitor; 21 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 22 | 23 | public class ZephyrApplicationBuilder extends IncrementalProjectBuilder { 24 | 25 | public static final String BUILDER_ID = 26 | ZephyrPlugin.PLUGIN_ID + ".zephyrApplicationBuilder"; //$NON-NLS-1$ 27 | 28 | /** 29 | * Adjust build kind if needed. 30 | * 31 | * This looks at the resource delta to determine whether a new kind value 32 | * is needed to be passed to the builder. For example, if CMakeLists.txt 33 | * has changed, a {@code FULL_BUILD} is needed to regenerate cmake files. 34 | * 35 | * @param oldKind Current kind value. 36 | * @param delta Resource delta. 37 | * @return New kind value to be passed to the builder. 38 | */ 39 | private int adjustKind(int oldKind, IResourceDelta delta) { 40 | if (delta == null) { 41 | return FULL_BUILD; 42 | } 43 | 44 | int newKind = oldKind; 45 | IResourceDelta[] children = delta.getAffectedChildren( 46 | IResourceDelta.CHANGED | IResourceDelta.CONTENT); 47 | 48 | for (IResourceDelta oneDelta : children) { 49 | IResource res = oneDelta.getResource(); 50 | if (res instanceof IFile) { 51 | IFile file = (IFile) res; 52 | 53 | /* If CMakeLists.txt has changed, force a full build */ 54 | if (file.getName().equals("CMakeLists.txt")) { //$NON-NLS-1$ 55 | newKind = FULL_BUILD; 56 | } 57 | 58 | /* If prj.conf has changed, force a full build */ 59 | if (file.getName().equals("prj.conf")) { //$NON-NLS-1$ 60 | newKind = FULL_BUILD; 61 | } 62 | } 63 | } 64 | 65 | return newKind; 66 | } 67 | 68 | @Override 69 | protected IProject[] build(int kind, Map args, 70 | IProgressMonitor monitor) throws CoreException { 71 | IResourceDelta delta = getDelta(getProject()); 72 | int buildType = adjustKind(kind, delta); 73 | IProject project = getProject(); 74 | 75 | /* Setup console */ 76 | IConsole console = CCorePlugin.getDefault().getConsole(); 77 | console.start(project); 78 | 79 | /* Grab a build configuration from the provider */ 80 | ICBuildConfiguration appBuildCfg = 81 | ZephyrHelpers.Build.getZephyrBuildConfiguration(project); 82 | 83 | /* Invoke application build */ 84 | appBuildCfg.build(buildType, args, console, monitor); 85 | 86 | return new IProject[] { 87 | project 88 | }; 89 | } 90 | 91 | @Override 92 | protected void clean(IProgressMonitor monitor) throws CoreException { 93 | IProject project = getProject(); 94 | 95 | /* Setup console */ 96 | IConsole console = CCorePlugin.getDefault().getConsole(); 97 | console.start(project); 98 | 99 | /* Grab a build configuration from the provider */ 100 | ICBuildConfiguration appBuildCfg = 101 | ZephyrHelpers.Build.getZephyrBuildConfiguration(project); 102 | 103 | /* Invoke application clean */ 104 | appBuildCfg.clean(console, monitor); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/ZephyrApplicationNature.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core; 8 | 9 | import org.eclipse.core.resources.IProject; 10 | import org.eclipse.core.resources.IProjectDescription; 11 | import org.eclipse.core.resources.IProjectNature; 12 | import org.eclipse.core.runtime.CoreException; 13 | 14 | public class ZephyrApplicationNature implements IProjectNature { 15 | 16 | /** 17 | * ID of this project nature 18 | */ 19 | public static final String NATURE_ID = 20 | ZephyrPlugin.PLUGIN_ID + ".zephyrApplicationNature"; //$NON-NLS-1$ 21 | 22 | private IProject project; 23 | 24 | @Override 25 | public void configure() throws CoreException { 26 | } 27 | 28 | @Override 29 | public void deconfigure() throws CoreException { 30 | } 31 | 32 | @Override 33 | public IProject getProject() { 34 | return project; 35 | } 36 | 37 | @Override 38 | public void setProject(IProject project) { 39 | this.project = project; 40 | } 41 | 42 | public static boolean hasNature(IProject project) throws CoreException { 43 | IProjectDescription projDesc = project.getDescription(); 44 | for (String id : projDesc.getNatureIds()) { 45 | if (id.equals(NATURE_ID)) { 46 | return true; 47 | } 48 | } 49 | return false; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/ZephyrPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core; 8 | 9 | import org.eclipse.ui.plugin.AbstractUIPlugin; 10 | import org.osgi.framework.BundleContext; 11 | import org.osgi.framework.ServiceReference; 12 | 13 | /** 14 | * The activator class controls the plug-in life cycle 15 | */ 16 | public class ZephyrPlugin extends AbstractUIPlugin { 17 | 18 | public static final String PLUGIN_STEM = "org.zephyrproject.ide.eclipse"; //$NON-NLS-1$ 19 | 20 | // The plug-in ID 21 | public static final String PLUGIN_ID = PLUGIN_STEM + ".core"; //$NON-NLS-1$ 22 | 23 | // The shared instance 24 | private static ZephyrPlugin plugin; 25 | 26 | /** 27 | * The constructor 28 | */ 29 | public ZephyrPlugin() { 30 | } 31 | 32 | /* 33 | * (non-Javadoc) 34 | * 35 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework. 36 | * BundleContext) 37 | */ 38 | @Override 39 | public void start(BundleContext context) throws Exception { 40 | super.start(context); 41 | plugin = this; 42 | } 43 | 44 | /* 45 | * (non-Javadoc) 46 | * 47 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework. 48 | * BundleContext) 49 | */ 50 | @Override 51 | public void stop(BundleContext context) throws Exception { 52 | plugin = null; 53 | super.stop(context); 54 | } 55 | 56 | /** 57 | * Returns the shared instance 58 | * 59 | * @return the shared instance 60 | */ 61 | public static ZephyrPlugin getDefault() { 62 | return plugin; 63 | } 64 | 65 | public static String getId() { 66 | return plugin.getBundle().getSymbolicName(); 67 | } 68 | 69 | public static T getService(Class service) { 70 | BundleContext context = plugin.getBundle().getBundleContext(); 71 | ServiceReference ref = context.getServiceReference(service); 72 | return ref != null ? context.getService(ref) : null; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/ZephyrStrings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core; 8 | 9 | /** 10 | * Contains strings used within the plugin. 11 | */ 12 | public class ZephyrStrings { 13 | 14 | public static final String EMPTY_STRING = ""; //$NON-NLS-1$ 15 | 16 | public static final String ONE_EMPTY_SPACE = " "; //$NON-NLS-1$ 17 | 18 | public static final String PATH = "Path"; 19 | 20 | public static final String TOOLCHAIN = "Toolchain"; 21 | 22 | public static final String BROWSE_BTN_TEXT = "Browse"; 23 | 24 | public static final String ZEPHYR_APPLICATION = "Zephyr Application"; 25 | 26 | public static final String ZEPHYR_APPLICATION_PROJECT = 27 | ZEPHYR_APPLICATION + " Project"; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/build/CMakeConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.build; 8 | 9 | public final class CMakeConstants { 10 | 11 | public static final String CMAKE_GENERATOR = "CMAKE_GENERATOR"; //$NON-NLS-1$ 12 | public static final String CMAKE_GENERATOR_DESC = "CMake Generator"; //$NON-NLS-1$ 13 | public static final String CMAKE_GENERATOR_MAKEFILE = "Unix Makefiles"; //$NON-NLS-1$ 14 | public static final String CMAKE_GENERATOR_NINJA = "Ninja"; //$NON-NLS-1$ 15 | 16 | public static final String[] CMAKE_GENERATOR_LIST_UNIX = { 17 | CMAKE_GENERATOR_NINJA, 18 | CMAKE_GENERATOR_MAKEFILE 19 | }; 20 | 21 | public static final String[] CMAKE_GENERATOR_LIST_WINDOWS = { 22 | CMAKE_GENERATOR_NINJA, 23 | CMAKE_GENERATOR_MAKEFILE 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/build/ZephyrApplicationBuildConfigurationProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 QNX Software Systems and others. 3 | * Copyright (c) 2019 Intel Corporation 4 | * 5 | * SPDX-License-Identifier: EPL-2.0 6 | */ 7 | 8 | package org.zephyrproject.ide.eclipse.core.build; 9 | 10 | import org.eclipse.cdt.core.build.ICBuildConfiguration; 11 | import org.eclipse.cdt.core.build.ICBuildConfigurationProvider; 12 | import org.eclipse.cdt.core.build.IToolChain; 13 | import org.eclipse.cdt.core.build.IToolChainManager; 14 | import org.eclipse.core.resources.IBuildConfiguration; 15 | import org.eclipse.core.runtime.CoreException; 16 | import org.zephyrproject.ide.eclipse.core.ZephyrPlugin; 17 | import org.zephyrproject.ide.eclipse.core.build.toolchain.ZephyrGCCToolChain; 18 | import org.zephyrproject.ide.eclipse.core.build.toolchain.ZephyrGenericToolChain; 19 | import org.zephyrproject.ide.eclipse.core.build.toolchain.ZephyrToolChainConstants.CrossCompileToolChain; 20 | import org.zephyrproject.ide.eclipse.core.build.toolchain.ZephyrToolChainConstants.CrosstoolsToolChain; 21 | import org.zephyrproject.ide.eclipse.core.build.toolchain.ZephyrToolChainConstants.GnuArmEmbToolChain; 22 | import org.zephyrproject.ide.eclipse.core.build.toolchain.ZephyrToolChainConstants.ZephyrSdkToolChain; 23 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 24 | 25 | /** 26 | * Build configuration provider for Zephyr Application 27 | * 28 | * Originally from 29 | * org.eclipse.cdt.cmake.core.internal.CMakeBuildConfigurationProvider. 30 | */ 31 | public class ZephyrApplicationBuildConfigurationProvider 32 | implements ICBuildConfigurationProvider { 33 | 34 | public static final String ID = ZephyrPlugin.PLUGIN_ID 35 | + ".build.zephyrApplicationBuildConfigProvider"; //$NON-NLS-1$ 36 | 37 | private IToolChainManager toolChainManager = 38 | ZephyrPlugin.getService(IToolChainManager.class); 39 | 40 | /* 41 | * (non-Javadoc) 42 | * 43 | * @see org.eclipse.cdt.core.build.ICBuildConfigurationProvider#getId() 44 | */ 45 | @Override 46 | public String getId() { 47 | return ID; 48 | } 49 | 50 | /* 51 | * (non-Javadoc) 52 | * 53 | * @see org.eclipse.cdt.core.build.ICBuildConfigurationProvider# 54 | * getCBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration, 55 | * java.lang.String) 56 | */ 57 | @Override 58 | public synchronized ICBuildConfiguration getCBuildConfiguration( 59 | IBuildConfiguration config, String name) throws CoreException { 60 | 61 | /* 62 | * Do not provide a build configuration if being asked for 63 | * a default one, since our builder is always looking for 64 | * Zephyr build configurations. 65 | */ 66 | if (config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) { 67 | return null; 68 | } 69 | 70 | try { 71 | ICBuildConfiguration cBuildCfg = null; 72 | 73 | /* Figure out the toolchain */ 74 | IToolChain toolChain = this.getToolChain(config); 75 | 76 | if (toolChain == null) { 77 | return null; 78 | } 79 | 80 | ZephyrGCCToolChain zToolChain = (ZephyrGCCToolChain) toolChain; 81 | 82 | zToolChain.updateCMakeVarsFromProjectPerfStore(config.getProject()); 83 | 84 | /* Create new build configuration */ 85 | if (config.getName().startsWith( 86 | ZephyrApplicationBuildConfiguration.CONFIG_NAME)) { 87 | cBuildCfg = new ZephyrApplicationBuildConfiguration(config, 88 | config.getName(), toolChain); 89 | } else { 90 | return null; 91 | } 92 | 93 | return cBuildCfg; 94 | } catch (CoreException e) { 95 | e.printStackTrace(); 96 | return null; 97 | } 98 | } 99 | 100 | /** 101 | * Get a toolchain ID from a build configuration name. 102 | * 103 | * @param config 104 | * @return 105 | * @throws CoreException 106 | */ 107 | private IToolChain getToolChain(IBuildConfiguration config) 108 | throws CoreException { 109 | String configName = config.getName(); 110 | String tcVariant = 111 | ZephyrHelpers.getToolChainVariant(config.getProject()); 112 | 113 | StringBuilder tcId = new StringBuilder(); 114 | if (tcVariant == null) { 115 | tcId.append(ZephyrGenericToolChain.TOOLCHAIN_ID); 116 | } else if (tcVariant.equals(ZephyrSdkToolChain.VARIANT)) { 117 | tcId.append(ZephyrGCCToolChain.TOOLCHAIN_ID); 118 | } else if (tcVariant.equals(CrosstoolsToolChain.VARIANT)) { 119 | tcId.append(ZephyrGCCToolChain.TOOLCHAIN_ID); 120 | } else if (tcVariant.equals(GnuArmEmbToolChain.VARIANT)) { 121 | tcId.append(ZephyrGCCToolChain.TOOLCHAIN_ID); 122 | } else if (tcVariant.equals(CrossCompileToolChain.VARIANT)) { 123 | tcId.append(ZephyrGenericToolChain.TOOLCHAIN_ID); 124 | } else { 125 | tcId.append(ZephyrGenericToolChain.TOOLCHAIN_ID); 126 | } 127 | 128 | String[] elem = configName.split("#", 2); //$NON-NLS-1$ 129 | if (elem.length == 2) { 130 | tcId.append("#"); //$NON-NLS-1$ 131 | tcId.append(elem[1]); 132 | } 133 | 134 | String tcIdStr = tcId.toString(); 135 | 136 | IToolChain toolChain = toolChainManager 137 | .getToolChain(ZephyrGCCToolChain.TYPE_ID, tcIdStr); 138 | 139 | if (toolChain != null) { 140 | return toolChain; 141 | } 142 | 143 | toolChain = new ZephyrGCCToolChain(tcIdStr); 144 | toolChainManager.addToolChain(toolChain); 145 | 146 | return toolChain; 147 | } 148 | 149 | } 150 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/build/toolchain/ZephyrApplicationToolChainProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.build.toolchain; 8 | 9 | import org.eclipse.cdt.core.build.IToolChain; 10 | import org.eclipse.cdt.core.build.IToolChainManager; 11 | import org.eclipse.cdt.core.build.IToolChainProvider; 12 | import org.eclipse.core.runtime.CoreException; 13 | import org.zephyrproject.ide.eclipse.core.ZephyrPlugin; 14 | 15 | /** 16 | * Toolchain provider for Zephyr Application. 17 | * 18 | * This creates IToolChain objects necessary for building Zephyr Applications. 19 | */ 20 | public class ZephyrApplicationToolChainProvider implements IToolChainProvider { 21 | 22 | public static final String ID = ZephyrPlugin.PLUGIN_ID 23 | + ".build.zephyrApplicationToolChainProvider"; //$NON-NLS-1$ 24 | 25 | private IToolChainManager toolChainManager = 26 | ZephyrPlugin.getService(IToolChainManager.class); 27 | 28 | @Override 29 | public String getId() { 30 | return ID; 31 | } 32 | 33 | @Override 34 | public void init(IToolChainManager manager) throws CoreException { 35 | IToolChain tc = new ZephyrGenericToolChain(); 36 | toolChainManager.addToolChain(tc); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/build/toolchain/ZephyrGenericToolChain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.build.toolchain; 8 | 9 | import java.nio.file.Path; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | import org.eclipse.cdt.core.CCorePlugin; 14 | import org.eclipse.cdt.core.build.IToolChain; 15 | import org.eclipse.cdt.core.build.IToolChainManager; 16 | import org.eclipse.cdt.core.build.IToolChainProvider; 17 | import org.eclipse.cdt.core.envvar.IEnvironmentVariable; 18 | import org.eclipse.core.runtime.CoreException; 19 | import org.eclipse.core.runtime.Platform; 20 | import org.eclipse.core.runtime.PlatformObject; 21 | import org.zephyrproject.ide.eclipse.core.ZephyrPlugin; 22 | 23 | /** 24 | * A Generic Zephyr toolchain which only provides bare minimum. 25 | */ 26 | public class ZephyrGenericToolChain extends PlatformObject 27 | implements IToolChain { 28 | 29 | public static final String TOOLCHAIN_OS = "zephyr"; //$NON-NLS-1$ 30 | 31 | public static final String TYPE_ID = 32 | ZephyrPlugin.PLUGIN_STEM + ".toolchain"; //$NON-NLS-1$ 33 | 34 | public static final String TOOLCHAIN_ID = "zephyr.toolchain.generic"; //$NON-NLS-1$ 35 | 36 | private final IToolChainProvider provider; 37 | private final IEnvironmentVariable[] envVars; 38 | private final Map properties = new HashMap<>(); 39 | 40 | public ZephyrGenericToolChain() { 41 | super(); 42 | 43 | IToolChainProvider tcP = null; 44 | try { 45 | IToolChainManager toolChainManager = 46 | ZephyrPlugin.getService(IToolChainManager.class); 47 | tcP = toolChainManager 48 | .getProvider(ZephyrApplicationToolChainProvider.ID); 49 | } catch (CoreException e) { 50 | } 51 | 52 | this.provider = tcP; 53 | this.envVars = new IEnvironmentVariable[0]; 54 | } 55 | 56 | @Override 57 | public IToolChainProvider getProvider() { 58 | return provider; 59 | } 60 | 61 | @Override 62 | public String getTypeId() { 63 | return TYPE_ID; 64 | } 65 | 66 | @Override 67 | public String getId() { 68 | return TOOLCHAIN_ID; 69 | } 70 | 71 | @Override 72 | public String getVersion() { 73 | return ""; 74 | } 75 | 76 | @Override 77 | public String getName() { 78 | return TOOLCHAIN_ID; 79 | } 80 | 81 | @Override 82 | public String getProperty(String key) { 83 | String value = properties.get(key); 84 | if (value != null) { 85 | return value; 86 | } 87 | 88 | switch (key) { 89 | case ATTR_OS: 90 | return Platform.getOS(); 91 | case ATTR_ARCH: 92 | if (Platform.getOS().equals(getProperty(ATTR_OS))) { 93 | return Platform.getOSArch(); 94 | } 95 | } 96 | 97 | return null; 98 | } 99 | 100 | @Override 101 | public void setProperty(String key, String value) { 102 | properties.put(key, value); 103 | } 104 | 105 | @Override 106 | public IEnvironmentVariable[] getVariables() { 107 | return envVars; 108 | } 109 | 110 | @Override 111 | public IEnvironmentVariable getVariable(String name) { 112 | return null; 113 | } 114 | 115 | @Override 116 | public String[] getErrorParserIds() { 117 | return new String[] { 118 | "org.eclipse.cdt.core.CWDLocator" //$NON-NLS-1$ 119 | }; 120 | } 121 | 122 | @Override 123 | public String getBinaryParserId() { 124 | return CCorePlugin.PLUGIN_ID + ".ELF"; //$NON-NLS-1$ 125 | } 126 | 127 | @Override 128 | public Path getCommandPath(Path command) { 129 | return null; 130 | } 131 | 132 | @Override 133 | public String[] getCompileCommands() { 134 | return null; 135 | } 136 | 137 | } 138 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/build/toolchain/ZephyrToolChainConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.build.toolchain; 8 | 9 | import org.zephyrproject.ide.eclipse.core.ZephyrStrings; 10 | 11 | /** 12 | * Toolchain related constants. 13 | */ 14 | public final class ZephyrToolChainConstants { 15 | 16 | public static final String ZEPHYR_TOOLCHAIN_VARIANT = 17 | "ZEPHYR_TOOLCHAIN_VARIANT"; //$NON-NLS-1$ 18 | 19 | public static class ZephyrSdkToolChain { 20 | 21 | public static final String VARIANT = "zephyr"; //$NON-NLS-1$ 22 | 23 | public static final String DESCRIPTION = "Zephyr SDK"; 24 | 25 | public static final String ENV_DESC = 26 | String.join(ZephyrStrings.ONE_EMPTY_SPACE, DESCRIPTION, // $NON-NLS-1$ 27 | "Install", ZephyrStrings.PATH); //$NON-NLS-1$ 28 | 29 | public static final String ENV = "ZEPHYR_SDK_INSTALL_DIR"; //$NON-NLS-1$ 30 | 31 | } 32 | 33 | public static class CrosstoolsToolChain { 34 | 35 | public static final String VARIANT = "xtools"; //$NON-NLS-1$ 36 | 37 | public static final String DESCRIPTION = "Crosstool-NG"; 38 | 39 | public static final String ENV_DESC = 40 | String.join(ZephyrStrings.ONE_EMPTY_SPACE, DESCRIPTION, 41 | ZephyrStrings.TOOLCHAIN, ZephyrStrings.PATH); 42 | 43 | public static final String ENV = "XTOOLS_TOOLCHAIN_PATH"; //$NON-NLS-1$ 44 | 45 | } 46 | 47 | public static class GnuArmEmbToolChain { 48 | 49 | public static final String VARIANT = "gnuarmemb"; //$NON-NLS-1$ 50 | 51 | public static final String DESCRIPTION = "GNU ARM Embedded Toolchain"; 52 | 53 | public static final String ENV_DESC = String.join( 54 | ZephyrStrings.ONE_EMPTY_SPACE, DESCRIPTION, ZephyrStrings.PATH); 55 | 56 | public static final String ENV = "GNUARMEMB_TOOLCHAIN_PATH"; //$NON-NLS-1$ 57 | 58 | } 59 | 60 | public static class CrossCompileToolChain { 61 | 62 | public static final String VARIANT = "cross-compile"; //$NON-NLS-1$ 63 | 64 | public static final String DESCRIPTION = "Cross Compile"; 65 | 66 | public static final String ENV_DESC = String 67 | .join(ZephyrStrings.ONE_EMPTY_SPACE, DESCRIPTION, "Prefix"); 68 | 69 | public static final String ENV = "CROSS_COMPILE"; //$NON-NLS-1$ 70 | 71 | } 72 | 73 | public static class CustomToolChain { 74 | 75 | public static final String VARIANT = "Custom CMake Toolchain"; //$NON-NLS-1$ 76 | 77 | public static final String DESCRIPTION = "Custom CMake Toolchain"; 78 | 79 | public static final String ENV_DESC = String.join( 80 | ZephyrStrings.ONE_EMPTY_SPACE, DESCRIPTION, ZephyrStrings.PATH); 81 | 82 | public static final String ENV = "TOOLCHAIN_ROOT"; //$NON-NLS-1$ 83 | 84 | } 85 | 86 | public static final String[] ZEPHYR_TOOLCHAIN_DESC_LIST = { 87 | ZephyrSdkToolChain.DESCRIPTION, 88 | CrosstoolsToolChain.DESCRIPTION, 89 | GnuArmEmbToolChain.DESCRIPTION, 90 | CrossCompileToolChain.DESCRIPTION, 91 | CustomToolChain.DESCRIPTION 92 | }; 93 | 94 | } 95 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/debug/jtagdevice/ARCnSimDevice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2012 QNX Software Systems and others. 3 | * Copyright (c) 2020 Intel Corporation 4 | * 5 | * SPDX-License-Identifier: EPL-2.0 6 | */ 7 | 8 | /* 9 | * Originally from org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GenericDevice 10 | */ 11 | 12 | package org.zephyrproject.ide.eclipse.core.debug.jtagdevice; 13 | 14 | import java.util.Collection; 15 | 16 | import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.DefaultGDBJtagConnectionImpl; 17 | 18 | public class ARCnSimDevice extends DefaultGDBJtagConnectionImpl { 19 | 20 | @Override 21 | public void doDelay(int delay, Collection commands) { 22 | } 23 | 24 | @Override 25 | public void doHalt(Collection commands) { 26 | } 27 | 28 | @Override 29 | public void doReset(Collection commands) { 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/debug/jtagdevice/Nios2Device.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2012 QNX Software Systems and others. 3 | * Copyright (c) 2020 Intel Corporation 4 | * 5 | * SPDX-License-Identifier: EPL-2.0 6 | */ 7 | 8 | /* 9 | * Originally from org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GenericDevice 10 | */ 11 | 12 | package org.zephyrproject.ide.eclipse.core.debug.jtagdevice; 13 | 14 | import java.util.Collection; 15 | 16 | import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.DefaultGDBJtagConnectionImpl; 17 | 18 | public class Nios2Device extends DefaultGDBJtagConnectionImpl { 19 | 20 | @Override 21 | public void doDelay(int delay, Collection commands) { 22 | } 23 | 24 | @Override 25 | public void doHalt(Collection commands) { 26 | } 27 | 28 | @Override 29 | public void doReset(Collection commands) { 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/debug/jtagdevice/OpenIPCDevice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2012 QNX Software Systems and others. 3 | * Copyright (c) 2020 Intel Corporation 4 | * 5 | * SPDX-License-Identifier: EPL-2.0 6 | */ 7 | 8 | /* 9 | * Originally from org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GenericDevice 10 | */ 11 | 12 | package org.zephyrproject.ide.eclipse.core.debug.jtagdevice; 13 | 14 | import java.util.Collection; 15 | 16 | import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.DefaultGDBJtagConnectionImpl; 17 | 18 | public class OpenIPCDevice extends DefaultGDBJtagConnectionImpl { 19 | 20 | @Override 21 | public void doDelay(int delay, Collection commands) { 22 | addCmd(commands, "monitor sleep " + String.valueOf(delay * 1000)); //$NON-NLS-1$ 23 | } 24 | 25 | @Override 26 | public void doResetAndHalt(Collection commands) { 27 | addCmd(commands, "monitor reset halt"); //$NON-NLS-1$ 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/debug/jtagdevice/QEMUDevice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2012 QNX Software Systems and others. 3 | * Copyright (c) 2020 Intel Corporation 4 | * 5 | * SPDX-License-Identifier: EPL-2.0 6 | */ 7 | 8 | /* 9 | * Originally from org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GenericDevice 10 | */ 11 | 12 | package org.zephyrproject.ide.eclipse.core.debug.jtagdevice; 13 | 14 | import java.util.Collection; 15 | 16 | import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.DefaultGDBJtagConnectionImpl; 17 | 18 | public class QEMUDevice extends DefaultGDBJtagConnectionImpl { 19 | 20 | @Override 21 | public void doDelay(int delay, Collection commands) { 22 | } 23 | 24 | @Override 25 | public void doHalt(Collection commands) { 26 | } 27 | 28 | @Override 29 | public void doReset(Collection commands) { 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/debug/jtagdevice/XtOCDDevice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2012 QNX Software Systems and others. 3 | * Copyright (c) 2020 Intel Corporation 4 | * 5 | * SPDX-License-Identifier: EPL-2.0 6 | */ 7 | 8 | /* 9 | * Originally from org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GenericDevice 10 | */ 11 | 12 | package org.zephyrproject.ide.eclipse.core.debug.jtagdevice; 13 | 14 | import java.util.Collection; 15 | 16 | import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.DefaultGDBJtagConnectionImpl; 17 | 18 | public class XtOCDDevice extends DefaultGDBJtagConnectionImpl { 19 | 20 | @Override 21 | public void doDelay(int delay, Collection commands) { 22 | } 23 | 24 | @Override 25 | public void doHalt(Collection commands) { 26 | } 27 | 28 | @Override 29 | public void doReset(Collection commands) { 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/internal/ZephyrPaths.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal; 8 | 9 | import org.eclipse.core.runtime.IPath; 10 | import org.eclipse.core.runtime.Path; 11 | 12 | public class ZephyrPaths { 13 | 14 | public static IPath[] generateZephyrBaseExclusionList() { 15 | 16 | return new Path[] { 17 | /* 18 | * Files in these directories are not source code. 19 | */ 20 | new Path(".git/**"), //$NON-NLS-1$ 21 | new Path(".github/**"), //$NON-NLS-1$ 22 | new Path(".known-issues/**"), //$NON-NLS-1$ 23 | new Path("cmake/**"), //$NON-NLS-1$ 24 | new Path("doc/**"), //$NON-NLS-1$ 25 | new Path("scripts/**"), //$NON-NLS-1$ 26 | 27 | /* 28 | * Default build and sanity check directories are ignored. 29 | */ 30 | new Path("**/build/**"), //$NON-NLS-1$ 31 | new Path("sanity-out/**"), //$NON-NLS-1$ 32 | 33 | /* 34 | * samples/** and tests/** are excluded because code here is 35 | * almost never called in applications. 36 | */ 37 | new Path("samples/**"), //$NON-NLS-1$ 38 | new Path("tests/**"), //$NON-NLS-1$ 39 | 40 | /* 41 | * Ignore non-code files. 42 | */ 43 | new Path("CODEOWNERS"), //$NON-NLS-1$ 44 | new Path("CODE_OF_CONDUCT.md"), //$NON-NLS-1$ 45 | new Path("LICENSE"), //$NON-NLS-1$ 46 | new Path("VERSION"), //$NON-NLS-1$ 47 | new Path("dts/**"), //$NON-NLS-1$ 48 | new Path("share/**"), //$NON-NLS-1$ 49 | new Path("**/*_defconfig"), //$NON-NLS-1$ 50 | new Path("**/CMakeLists.txt"), //$NON-NLS-1$ 51 | new Path("**/Kconfig*"), //$NON-NLS-1$ 52 | new Path("**/Makefile"), // $NON-NLS 53 | new Path("**/README*"), // $NON-NLS 54 | new Path("**/*.cmake"), //$NON-NLS-1$ 55 | new Path("**/*.cmd"), //$NON-NLS-1$ 56 | new Path("**/*.dts"), //$NON-NLS-1$ 57 | new Path("**/*.dtsi"), //$NON-NLS-1$ 58 | new Path("**/*.h.in"), //$NON-NLS-1$ 59 | new Path("**/*.ld"), //$NON-NLS-1$ 60 | new Path("**/*.py"), //$NON-NLS-1$ 61 | new Path("**/*.pyc"), //$NON-NLS-1$ 62 | new Path("**/*.rst"), //$NON-NLS-1$ 63 | new Path("**/*.sh"), //$NON-NLS-1$ 64 | new Path("**/*.txt"), //$NON-NLS-1$ 65 | new Path("**/*.yml"), //$NON-NLS-1$ 66 | new Path("**/*.yaml"), //$NON-NLS-1$ 67 | }; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/internal/build/CMakeCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal.build; 8 | 9 | import java.io.BufferedReader; 10 | import java.io.File; 11 | import java.io.FileReader; 12 | import java.io.IOException; 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | 16 | import org.eclipse.core.resources.IProject; 17 | 18 | /** 19 | * Store Variables in CMakeCache.txt 20 | */ 21 | public class CMakeCache { 22 | 23 | public static final String CMAKE_CXX_COMPILER = "CMAKE_CXX_COMPILER"; //$NON-NLS-1$ 24 | 25 | public static final String CMAKE_C_COMPILER = "CMAKE_C_COMPILER"; //$NON-NLS-1$ 26 | 27 | public static final String CMAKE_MAKE_PROGRAM = "CMAKE_MAKE_PROGRAM"; //$NON-NLS-1$ 28 | 29 | public static final String CMAKE_GDB = "CMAKE_GDB"; //$NON-NLS-1$ 30 | 31 | public static final String WEST = "WEST"; //$NON-NLS-1$ 32 | 33 | public static final String ZEPHYR_BOARD_DEBUG_RUNNER = 34 | "ZEPHYR_BOARD_DEBUG_RUNNER"; //$NON-NLS-1$ 35 | 36 | private IProject project; 37 | 38 | private Map variables; 39 | 40 | public CMakeCache(IProject project) throws IOException { 41 | this.project = project; 42 | this.variables = new HashMap<>(); 43 | } 44 | 45 | /** 46 | * @return The project associated with this cache 47 | */ 48 | public IProject getProject() { 49 | return project; 50 | } 51 | 52 | /** 53 | * @param name Name of CMake cached variable 54 | * @return The raw variable value or {@code null} if variable does not exist 55 | */ 56 | public String getRawValue(String name) { 57 | return variables.get(name); 58 | } 59 | 60 | private String getTypedValue(String type, String name) { 61 | String str = variables.get(name); 62 | if (str == null) { 63 | return null; 64 | } else if (!str.startsWith(type)) { 65 | return null; 66 | } else { 67 | return str.substring(type.length()); 68 | } 69 | } 70 | 71 | /** 72 | * @param name Name of cached variable with type STRING 73 | * @return The STRING value or {@code null} if variable does not exist or 74 | * not of type STRING 75 | */ 76 | public String getString(String name) { 77 | return getTypedValue("STRING=", name); //$NON-NLS-1$ 78 | } 79 | 80 | /** 81 | * @param name Name of cached variable with type FILEPATH 82 | * @return The FILEPATH value or {@code null} if variable does not exist or 83 | * not of type FILEPATH 84 | */ 85 | public String getFilePath(String name) { 86 | String val = getTypedValue("FILEPATH=", name); //$NON-NLS-1$ 87 | 88 | if ((val != null) && (val.indexOf("-NOTFOUND") != -1)) { 89 | return null; 90 | } 91 | 92 | return val; 93 | } 94 | 95 | /** 96 | * @param name Name of cached variable with type INTERNAL 97 | * @return The INTERNAL value or {@code null} if variable does not exist or 98 | * not of type INTERNAL 99 | */ 100 | public String getInternal(String name) { 101 | return getTypedValue("INTERNAL=", name); //$NON-NLS-1$ 102 | } 103 | 104 | /** 105 | * @return Path to C compiler as discovered by CMake 106 | */ 107 | public String getCCompiler() { 108 | /* CMAKE_C_COMPILER can appear as FILEPATH or STRING */ 109 | String c_compiler = getFilePath(CMAKE_C_COMPILER); 110 | 111 | if (c_compiler == null) { 112 | c_compiler = getString(CMAKE_C_COMPILER); 113 | } 114 | 115 | return c_compiler; 116 | } 117 | 118 | /** 119 | * @return Path to C++ compiler as discovered by CMake 120 | */ 121 | public String getCXXCompiler() { 122 | /* CMAKE_CXX_COMPILER can appear as FILEPATH or STRING */ 123 | String cxx_compiler = getFilePath(CMAKE_CXX_COMPILER); 124 | 125 | if (cxx_compiler == null) { 126 | cxx_compiler = getString(CMAKE_CXX_COMPILER); 127 | } 128 | 129 | return cxx_compiler; 130 | } 131 | 132 | /** 133 | * @return Path to Make program as discovered by CMake 134 | */ 135 | public String getMakeProgram() { 136 | return getFilePath(CMAKE_MAKE_PROGRAM); 137 | } 138 | 139 | /** 140 | * @return Path to GDB as discovered by CMake 141 | */ 142 | public String getGdb() { 143 | return getFilePath(CMAKE_GDB); 144 | } 145 | 146 | /** 147 | * @return Path to West as discovered by CMake 148 | */ 149 | public String getWest() { 150 | /* WEST can appear as FILEPATH or INTERNAL. */ 151 | 152 | String val = getFilePath(WEST); 153 | 154 | if (val == null) { 155 | val = getInternal(WEST); 156 | } 157 | 158 | return val; 159 | } 160 | 161 | /** 162 | * @return Debug Runner 163 | */ 164 | public String getDebugRunner() { 165 | return getString(ZEPHYR_BOARD_DEBUG_RUNNER); 166 | } 167 | 168 | /** 169 | * @param f File to CMakeCache.txt 170 | * @return true if there is any variables read, false otherwise 171 | * @throws IOException 172 | */ 173 | public boolean parseFile(File f) throws IOException { 174 | try (BufferedReader reader = new BufferedReader(new FileReader(f))) { 175 | 176 | /* Clear the mappings before reading new ones */ 177 | variables.clear(); 178 | 179 | String line; 180 | while ((line = reader.readLine()) != null) { 181 | String l = line.trim(); 182 | if (l.startsWith("#") || l.startsWith("/") || l.isEmpty()) { //$NON-NLS-1$ //$NON-NLS-2$ 183 | continue; 184 | } 185 | 186 | String[] pair = l.split(":", 2); 187 | if (pair.length == 2) { 188 | variables.put(pair[0], pair[1]); 189 | } 190 | } 191 | 192 | reader.close(); 193 | 194 | return !variables.isEmpty(); 195 | } 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/internal/build/CompileCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 QNX Software Systems and others. 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal.build; 8 | 9 | public class CompileCommand { 10 | 11 | private String directory; 12 | private String command; 13 | private String file; 14 | 15 | public String getDirectory() { 16 | return directory; 17 | } 18 | 19 | public String getCommand() { 20 | return command; 21 | } 22 | 23 | public String getFile() { 24 | return file; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/internal/build/MakefileProgressMonitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal.build; 8 | 9 | import java.util.regex.Matcher; 10 | import java.util.regex.Pattern; 11 | 12 | import org.eclipse.cdt.core.IConsoleParser; 13 | import org.eclipse.core.runtime.IProgressMonitor; 14 | 15 | /** 16 | * Simple console parser to update progress due to build output 17 | */ 18 | public class MakefileProgressMonitor implements IConsoleParser { 19 | 20 | private IProgressMonitor monitor; 21 | 22 | private int lastPercentage; 23 | 24 | private Pattern linePattern; 25 | 26 | public MakefileProgressMonitor(IProgressMonitor m) { 27 | this.monitor = m; 28 | this.lastPercentage = 0; 29 | this.linePattern = Pattern.compile("\\[[ ]?([0-9]+)%\\] (.+)"); 30 | } 31 | 32 | @Override 33 | public boolean processLine(String line) { 34 | if (!line.startsWith("[")) { 35 | return false; 36 | } 37 | 38 | Matcher matcher = linePattern.matcher(line); 39 | if (matcher.matches()) { 40 | String percentage = matcher.group(1); 41 | String msg = matcher.group(2); 42 | 43 | try { 44 | int p = Integer.valueOf(percentage); 45 | if (p != lastPercentage) { 46 | monitor.worked(p - lastPercentage); 47 | lastPercentage = p; 48 | } 49 | } catch (NumberFormatException nfe) { 50 | 51 | } 52 | 53 | monitor.subTask(msg); 54 | 55 | return true; 56 | } 57 | 58 | return false; 59 | } 60 | 61 | @Override 62 | public void shutdown() { 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/internal/build/NinjaProgressMonitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal.build; 8 | 9 | import java.util.regex.Matcher; 10 | import java.util.regex.Pattern; 11 | 12 | import org.eclipse.cdt.core.IConsoleParser; 13 | import org.eclipse.core.runtime.IProgressMonitor; 14 | 15 | /** 16 | * Simple console parser to update progress due to build output 17 | */ 18 | public class NinjaProgressMonitor implements IConsoleParser { 19 | 20 | private IProgressMonitor monitor; 21 | 22 | private int lastPercentage; 23 | 24 | private Pattern linePattern; 25 | 26 | public NinjaProgressMonitor(IProgressMonitor m) { 27 | this.monitor = m; 28 | this.lastPercentage = 0; 29 | this.linePattern = Pattern.compile("\\[([0-9]+)/([0-9]+)\\] (.+)"); 30 | } 31 | 32 | @Override 33 | public boolean processLine(String line) { 34 | if (!line.startsWith("[")) { 35 | return false; 36 | } 37 | 38 | Matcher matcher = linePattern.matcher(line); 39 | if (matcher.matches()) { 40 | String sCurStep = matcher.group(1); 41 | String sAllSteps = matcher.group(2); 42 | String msg = matcher.group(3); 43 | 44 | try { 45 | int curStep = Integer.valueOf(sCurStep); 46 | int allSteps = Integer.valueOf(sAllSteps); 47 | 48 | int percentage = (curStep * 100) / allSteps; 49 | 50 | if (percentage != lastPercentage) { 51 | monitor.worked(percentage - lastPercentage); 52 | lastPercentage = percentage; 53 | } 54 | } catch (NumberFormatException nfe) { 55 | } 56 | 57 | monitor.subTask(msg); 58 | 59 | return true; 60 | } 61 | 62 | return false; 63 | } 64 | 65 | @Override 66 | public void shutdown() { 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/internal/build/ZephyrScannerInfoCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.internal.build; 8 | 9 | import java.io.File; 10 | import java.io.FileReader; 11 | import java.io.FileWriter; 12 | import java.io.IOException; 13 | import java.lang.reflect.Type; 14 | import java.util.Map; 15 | import java.util.TreeMap; 16 | 17 | import org.eclipse.cdt.core.parser.ExtendedScannerInfo; 18 | import org.eclipse.cdt.core.parser.IExtendedScannerInfo; 19 | import org.eclipse.core.resources.IBuildConfiguration; 20 | import org.eclipse.core.resources.IFile; 21 | import org.eclipse.core.resources.IResource; 22 | import org.eclipse.core.runtime.IPath; 23 | import org.zephyrproject.ide.eclipse.core.ZephyrPlugin; 24 | 25 | import com.google.gson.Gson; 26 | import com.google.gson.reflect.TypeToken; 27 | 28 | /** 29 | * Scanner Information Caching class 30 | */ 31 | public class ZephyrScannerInfoCache { 32 | 33 | private static final String SCANNER_INFO_CACHE = "scannerInfoCache"; 34 | 35 | private Map cacheMap; 36 | 37 | private Map defaultCacheMap; 38 | 39 | private IBuildConfiguration config; 40 | 41 | public ZephyrScannerInfoCache(IBuildConfiguration config) { 42 | this.cacheMap = new TreeMap<>(); 43 | this.defaultCacheMap = new TreeMap<>(); 44 | this.config = config; 45 | 46 | getScannerInfoCachePath().toFile().mkdirs(); 47 | readCache(); 48 | } 49 | 50 | /** 51 | * @return Path to store the scanner info cache files. 52 | */ 53 | private IPath getScannerInfoCachePath() { 54 | return config.getProject().getWorkingLocation(ZephyrPlugin.PLUGIN_ID) 55 | .append(SCANNER_INFO_CACHE); 56 | } 57 | 58 | /** 59 | * Read the cache files from storage. 60 | */ 61 | private void readCache() { 62 | File cacheFile = getScannerInfoCachePath().append("cacheMap").toFile(); //$NON-NLS-1$ 63 | 64 | if (cacheFile.exists()) { 65 | try (FileReader reader = new FileReader(cacheFile)) { 66 | Gson gson = new Gson(); 67 | synchronized (this) { 68 | Type mapType = 69 | new TypeToken>() { 70 | }.getType(); 71 | cacheMap = gson.fromJson(reader, mapType); 72 | } 73 | } catch (Exception e) { 74 | e.printStackTrace(); 75 | } 76 | } 77 | 78 | cacheFile = 79 | getScannerInfoCachePath().append("defaultCacheMap").toFile(); //$NON-NLS-1$ 80 | 81 | if (cacheFile.exists()) { 82 | try (FileReader reader = new FileReader(cacheFile)) { 83 | Gson gson = new Gson(); 84 | synchronized (this) { 85 | Type mapType = 86 | new TypeToken>() { 87 | }.getType(); 88 | defaultCacheMap = gson.fromJson(reader, mapType); 89 | } 90 | } catch (Exception e) { 91 | e.printStackTrace(); 92 | } 93 | } 94 | } 95 | 96 | /** 97 | * Write the cached info object into storage. 98 | */ 99 | public void writeCache() { 100 | File cacheFile = getScannerInfoCachePath().append("cacheMap").toFile(); //$NON-NLS-1$ 101 | 102 | try (FileWriter writer = new FileWriter(cacheFile)) { 103 | Gson gson = new Gson(); 104 | synchronized (this) { 105 | gson.toJson(cacheMap, writer); 106 | } 107 | } catch (IOException ioe) { 108 | ioe.printStackTrace(); 109 | } 110 | 111 | cacheFile = 112 | getScannerInfoCachePath().append("defaultCacheMap").toFile(); //$NON-NLS-1$ 113 | 114 | try (FileWriter writer = new FileWriter(cacheFile)) { 115 | Gson gson = new Gson(); 116 | synchronized (this) { 117 | gson.toJson(defaultCacheMap, writer); 118 | } 119 | } catch (IOException ioe) { 120 | ioe.printStackTrace(); 121 | } 122 | } 123 | 124 | /** 125 | * Retrieve a scanner info object associated with a file. 126 | * 127 | * @param resource Resource object to the file. 128 | * @return IExtendedScannerInfo object if file is cached, null otherwise. 129 | */ 130 | public IExtendedScannerInfo getScannerInfo(IResource resource) { 131 | if ((resource != null) && (resource instanceof IFile)) { 132 | Integer hash = resource.getLocation().toOSString().hashCode(); 133 | IExtendedScannerInfo info; 134 | synchronized (this) { 135 | info = cacheMap.get(hash); 136 | } 137 | 138 | return info; 139 | } 140 | return null; 141 | } 142 | 143 | /** 144 | * Put a scanner info object associated with a file into cache. 145 | * 146 | * @param resource Resource object to the file. 147 | * @param info Scanner info object associated with the file. 148 | */ 149 | public void setScannerInfo(IResource resource, IExtendedScannerInfo info) { 150 | if ((resource != null) && (info != null) && (resource instanceof IFile) 151 | && (info instanceof ExtendedScannerInfo)) { 152 | Integer hash = resource.getLocation().toOSString().hashCode(); 153 | ExtendedScannerInfo esi = (ExtendedScannerInfo) info; 154 | synchronized (this) { 155 | cacheMap.put(hash, esi); 156 | } 157 | } 158 | } 159 | 160 | /** 161 | * Retrieve a generic scanner info object using the file extension of 162 | * the resource. 163 | * 164 | * @param resource Resource object to the file. 165 | * @return IExtendedScannerInfo object if file is cached, null otherwise. 166 | */ 167 | public IExtendedScannerInfo getDefaultScannerInfo(IResource resource) { 168 | if ((resource != null) && (resource instanceof IFile)) { 169 | String ext = resource.getLocation().getFileExtension(); 170 | IExtendedScannerInfo info = null; 171 | 172 | if (ext != null) { 173 | /* If there is an extension... */ 174 | synchronized (this) { 175 | info = defaultCacheMap.get(ext.toLowerCase()); 176 | } 177 | } 178 | 179 | if (info == null) { 180 | /* The ".c" scanner is the default one. */ 181 | synchronized (this) { 182 | info = defaultCacheMap.get("c"); //$NON-NLS-1$ 183 | } 184 | } 185 | 186 | return info; 187 | } 188 | 189 | return null; 190 | } 191 | 192 | /** 193 | * Put a generic scanner info object into cache. 194 | * 195 | * @param resource Resource object to the file. 196 | * @param info Scanner info object associated with the file extension. 197 | */ 198 | public void setDefaultScannerInfo(IResource resource, 199 | IExtendedScannerInfo info) { 200 | if ((resource != null) && (info != null) && (resource instanceof IFile) 201 | && (info instanceof ExtendedScannerInfo)) { 202 | 203 | String ext = resource.getLocation().getFileExtension(); 204 | ExtendedScannerInfo esi = (ExtendedScannerInfo) info; 205 | if (ext != null) { 206 | /* If there is an extension... */ 207 | synchronized (this) { 208 | defaultCacheMap.put(ext.toLowerCase(), esi); 209 | } 210 | } 211 | } 212 | } 213 | } 214 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/launch/IZephyrLaunchHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.launch; 8 | 9 | import java.io.IOException; 10 | 11 | import org.eclipse.core.resources.IProject; 12 | import org.eclipse.core.runtime.CoreException; 13 | import org.eclipse.debug.core.ILaunch; 14 | import org.zephyrproject.ide.eclipse.core.build.ZephyrApplicationBuildConfiguration; 15 | 16 | public interface IZephyrLaunchHelper { 17 | 18 | Process doMakefile(IProject project, 19 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 20 | String makeProgram, String mode) throws CoreException, IOException; 21 | 22 | Process doNinja(IProject project, 23 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 24 | String makeProgram, String mode) throws CoreException, IOException; 25 | 26 | Process runWest(IProject project, 27 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 28 | String action, String args) throws CoreException, IOException; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/launch/ZephyrAbstractRunLaunchConfigDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.launch; 8 | 9 | import org.eclipse.cdt.core.build.ICBuildConfiguration; 10 | import org.eclipse.cdt.debug.core.launch.CoreBuildLaunchConfigDelegate; 11 | import org.eclipse.core.resources.IProject; 12 | import org.eclipse.core.runtime.CoreException; 13 | import org.eclipse.core.runtime.IProgressMonitor; 14 | import org.eclipse.debug.core.ILaunch; 15 | import org.eclipse.debug.core.ILaunchConfiguration; 16 | import org.eclipse.launchbar.core.target.ILaunchTarget; 17 | import org.zephyrproject.ide.eclipse.core.build.ZephyrApplicationBuildConfiguration; 18 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 19 | 20 | public abstract class ZephyrAbstractRunLaunchConfigDelegate 21 | extends CoreBuildLaunchConfigDelegate { 22 | 23 | @Override 24 | protected ZephyrApplicationBuildConfiguration getBuildConfiguration( 25 | IProject project, String mode, ILaunchTarget target, 26 | IProgressMonitor monitor) throws CoreException { 27 | return ZephyrHelpers.Launch.getZephyrBuildConfiguration(project, mode, 28 | target, monitor); 29 | } 30 | 31 | @Override 32 | protected ICBuildConfiguration getBuildConfiguration( 33 | ILaunchConfiguration configuration, String mode, 34 | ILaunchTarget target, IProgressMonitor monitor) 35 | throws CoreException { 36 | return this.getBuildConfiguration(getProject(configuration), mode, 37 | target, monitor); 38 | } 39 | 40 | protected void doMakefile(IProject project, 41 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 42 | String makeProgram, String mode) throws CoreException { 43 | ZephyrHelpers.Launch.doMakefile(project, appBuildCfg, launch, 44 | makeProgram, mode); 45 | } 46 | 47 | protected void doNinja(IProject project, 48 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 49 | String makeProgram, String mode) throws CoreException { 50 | ZephyrHelpers.Launch.doNinja(project, appBuildCfg, launch, makeProgram, 51 | mode); 52 | } 53 | 54 | protected void runWest(IProject project, 55 | ZephyrApplicationBuildConfiguration appBuildCfg, ILaunch launch, 56 | String action, String args) throws CoreException { 57 | ZephyrHelpers.Launch.runWest(project, appBuildCfg, launch, action, 58 | args); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/launch/ZephyrApplicationEmulatorDebugLaunchConfigDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.launch; 8 | 9 | import org.eclipse.cdt.debug.gdbjtag.core.GDBJtagDSFLaunchConfigurationDelegate; 10 | import org.eclipse.core.resources.IProject; 11 | import org.eclipse.core.runtime.CoreException; 12 | import org.eclipse.core.runtime.IProgressMonitor; 13 | import org.eclipse.debug.core.ILaunch; 14 | import org.eclipse.debug.core.ILaunchConfiguration; 15 | import org.eclipse.debug.core.ILaunchManager; 16 | import org.eclipse.launchbar.core.target.ILaunchTarget; 17 | import org.eclipse.launchbar.core.target.launch.ITargetedLaunch; 18 | import org.zephyrproject.ide.eclipse.core.build.ZephyrApplicationBuildConfiguration; 19 | import org.zephyrproject.ide.eclipse.core.build.toolchain.ZephyrGCCToolChain; 20 | import org.zephyrproject.ide.eclipse.core.ZephyrStrings; 21 | import org.zephyrproject.ide.eclipse.core.build.CMakeConstants; 22 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 23 | 24 | public class ZephyrApplicationEmulatorDebugLaunchConfigDelegate 25 | extends GDBJtagDSFLaunchConfigurationDelegate { 26 | 27 | private static final String CMD_DEBUGSERVER = "debugserver"; //$NON-NLS-1$ 28 | 29 | @Override 30 | public void launch(ILaunchConfiguration configuration, String mode, 31 | ILaunch launch, IProgressMonitor monitor) throws CoreException { 32 | if (ILaunchManager.DEBUG_MODE.equals(mode)) { 33 | /* Need to launch the debugserver */ 34 | launchDebugServer(configuration, mode, launch, monitor); 35 | 36 | super.launch(configuration, mode, launch, monitor); 37 | } else { 38 | throw new CoreException(ZephyrHelpers.errorStatus( 39 | "Project is not correctly configured.", //$NON-NLS-1$ 40 | new RuntimeException( 41 | String.format("Unknown mode: %s", mode)))); // $NON-NLS-1$ 42 | } 43 | } 44 | 45 | private void launchDebugServer(ILaunchConfiguration configuration, 46 | String mode, ILaunch launch, IProgressMonitor monitor) 47 | throws CoreException { 48 | IProject project = configuration.getMappedResources()[0].getProject(); 49 | ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget(); 50 | 51 | ZephyrApplicationBuildConfiguration appBuildCfg = ZephyrHelpers.Launch 52 | .getZephyrBuildConfiguration(project, mode, target, monitor); 53 | ZephyrGCCToolChain toolChain = 54 | (ZephyrGCCToolChain) appBuildCfg.getToolChain(); 55 | 56 | String cmakeGenerator = ZephyrHelpers.getCMakeGenerator(project); 57 | String makeProgram = toolChain.getMakeProgram(); 58 | if (makeProgram == null) { 59 | throw new CoreException(ZephyrHelpers.errorStatus( 60 | "Project is not correctly configured.", //$NON-NLS-1$ 61 | new RuntimeException("Cannot get CMake generator used."))); //$NON-NLS-1$ 62 | } 63 | 64 | /* Figure out whether to do run, flash or custom command */ 65 | String commandSelection = configuration.getAttribute( 66 | ZephyrLaunchConstants.ATTR_DBGSERVER_CMD_SEL, 67 | ZephyrLaunchConstants.DBGSERVER_CMD_SEL_NONE); 68 | String cmdTarget = null; 69 | if (commandSelection 70 | .equals(ZephyrLaunchConstants.DBGSERVER_CMD_SEL_BUILDSYS)) { 71 | cmdTarget = CMD_DEBUGSERVER; 72 | 73 | if (cmakeGenerator 74 | .equals(CMakeConstants.CMAKE_GENERATOR_MAKEFILE)) { 75 | ZephyrHelpers.Launch.doMakefile(project, appBuildCfg, launch, 76 | makeProgram, cmdTarget); 77 | } else if (cmakeGenerator 78 | .equals(CMakeConstants.CMAKE_GENERATOR_NINJA)) { 79 | ZephyrHelpers.Launch.doNinja(project, appBuildCfg, launch, 80 | makeProgram, cmdTarget); 81 | } else { 82 | throw new CoreException(ZephyrHelpers.errorStatus( 83 | "Project is not correctly configured.", //$NON-NLS-1$ 84 | new RuntimeException("Unknown CMake Generator."))); //$NON-NLS-1$ 85 | } 86 | } else if (commandSelection 87 | .equals(ZephyrLaunchConstants.DBGSERVER_CMD_SEL_WEST)) { 88 | String args = configuration.getAttribute( 89 | ZephyrLaunchConstants.ATTR_DBGSERVER_CMD_WEST_ARGS, 90 | ZephyrStrings.EMPTY_STRING); 91 | 92 | args = "-t debugserver " + args; //$NON-NLS-1$ 93 | args = args.trim(); 94 | 95 | ZephyrHelpers.Launch.runWest(project, appBuildCfg, launch, 96 | "build", args); //$NON-NLS-1$ 97 | } else if (commandSelection 98 | .equals(ZephyrLaunchConstants.DBGSERVER_CMD_SEL_NONE)) { 99 | /* Instructed not to launch debugserver */ 100 | } else { 101 | throw new CoreException(ZephyrHelpers.errorStatus( 102 | "Project is not correctly configured.", //$NON-NLS-1$ 103 | new RuntimeException("Unknown Command to Run"))); //$NON-NLS-1$ 104 | } 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/launch/ZephyrApplicationEmulatorRunLaunchConfigDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.launch; 8 | 9 | import org.eclipse.core.resources.IProject; 10 | import org.eclipse.core.runtime.CoreException; 11 | import org.eclipse.core.runtime.IProgressMonitor; 12 | import org.eclipse.debug.core.ILaunch; 13 | import org.eclipse.debug.core.ILaunchConfiguration; 14 | import org.eclipse.debug.core.ILaunchManager; 15 | import org.eclipse.launchbar.core.target.ILaunchTarget; 16 | import org.eclipse.launchbar.core.target.launch.ITargetedLaunch; 17 | import org.zephyrproject.ide.eclipse.core.ZephyrStrings; 18 | import org.zephyrproject.ide.eclipse.core.build.ZephyrApplicationBuildConfiguration; 19 | import org.zephyrproject.ide.eclipse.core.build.toolchain.ZephyrGCCToolChain; 20 | import org.zephyrproject.ide.eclipse.core.build.CMakeConstants; 21 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 22 | 23 | public class ZephyrApplicationEmulatorRunLaunchConfigDelegate 24 | extends ZephyrAbstractRunLaunchConfigDelegate { 25 | 26 | private static final String CMD_RUN = "run"; //$NON-NLS-1$ 27 | 28 | @Override 29 | public void launch(ILaunchConfiguration configuration, String mode, 30 | ILaunch launch, IProgressMonitor monitor) throws CoreException { 31 | if (ILaunchManager.RUN_MODE.equals(mode)) { 32 | run(configuration, mode, launch, monitor); 33 | } else { 34 | throw new CoreException(ZephyrHelpers.errorStatus( 35 | "Project is not correctly configured.", //$NON-NLS-1$ 36 | new RuntimeException( 37 | String.format("Unknown mode: %s", mode)))); // $NON-NLS-1$ 38 | } 39 | } 40 | 41 | private void run(ILaunchConfiguration configuration, String mode, 42 | ILaunch launch, IProgressMonitor monitor) throws CoreException { 43 | IProject project = getProject(configuration); 44 | ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget(); 45 | 46 | ZephyrApplicationBuildConfiguration appBuildCfg = 47 | getBuildConfiguration(project, mode, target, monitor); 48 | ZephyrGCCToolChain toolChain = 49 | (ZephyrGCCToolChain) appBuildCfg.getToolChain(); 50 | 51 | String cmakeGenerator = ZephyrHelpers.getCMakeGenerator(project); 52 | String makeProgram = toolChain.getMakeProgram(); 53 | if (makeProgram == null) { 54 | throw new CoreException(ZephyrHelpers.errorStatus( 55 | "Project is not correctly configured.", //$NON-NLS-1$ 56 | new RuntimeException("Cannot get CMake generator used."))); //$NON-NLS-1$ 57 | } 58 | 59 | /* Figure out whether to do run, flash or custom command */ 60 | String commandSelection = configuration.getAttribute( 61 | ZephyrLaunchConstants.ATTR_EMULATOR_RUN_CMD_SEL, 62 | ZephyrStrings.EMPTY_STRING); 63 | String cmdToRun = null; 64 | if (commandSelection 65 | .equals(ZephyrLaunchConstants.EMULATOR_RUN_CMD_SEL_BUILDSYS)) { 66 | cmdToRun = CMD_RUN; 67 | 68 | if (cmakeGenerator 69 | .equals(CMakeConstants.CMAKE_GENERATOR_MAKEFILE)) { 70 | doMakefile(project, appBuildCfg, launch, makeProgram, cmdToRun); 71 | } else if (cmakeGenerator 72 | .equals(CMakeConstants.CMAKE_GENERATOR_NINJA)) { 73 | doNinja(project, appBuildCfg, launch, makeProgram, cmdToRun); 74 | } else { 75 | throw new CoreException(ZephyrHelpers.errorStatus( 76 | "Project is not correctly configured.", //$NON-NLS-1$ 77 | new RuntimeException("Unknown CMake Generator."))); //$NON-NLS-1$ 78 | } 79 | } else if (commandSelection 80 | .equals(ZephyrLaunchConstants.EMULATOR_RUN_CMD_SEL_WEST)) { 81 | String args = configuration.getAttribute( 82 | ZephyrLaunchConstants.ATTR_RUN_CMD_WEST_ARGS, 83 | ZephyrStrings.EMPTY_STRING); 84 | 85 | args = "-t run " + args; //$NON-NLS-1$ 86 | args = args.trim(); 87 | 88 | runWest(project, appBuildCfg, launch, "build", args); //$NON-NLS-1$ 89 | } else { 90 | throw new CoreException(ZephyrHelpers.errorStatus( 91 | "Project is not correctly configured.", //$NON-NLS-1$ 92 | new RuntimeException("Unknown Command to Run"))); //$NON-NLS-1$ 93 | } 94 | 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/launch/ZephyrApplicationHardwareRunLaunchConfigDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.launch; 8 | 9 | import org.eclipse.core.resources.IProject; 10 | import org.eclipse.core.runtime.CoreException; 11 | import org.eclipse.core.runtime.IProgressMonitor; 12 | import org.eclipse.debug.core.ILaunch; 13 | import org.eclipse.debug.core.ILaunchConfiguration; 14 | import org.eclipse.debug.core.ILaunchManager; 15 | import org.eclipse.launchbar.core.target.ILaunchTarget; 16 | import org.eclipse.launchbar.core.target.launch.ITargetedLaunch; 17 | import org.zephyrproject.ide.eclipse.core.ZephyrStrings; 18 | import org.zephyrproject.ide.eclipse.core.build.ZephyrApplicationBuildConfiguration; 19 | import org.zephyrproject.ide.eclipse.core.build.toolchain.ZephyrGCCToolChain; 20 | import org.zephyrproject.ide.eclipse.core.build.CMakeConstants; 21 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 22 | 23 | public class ZephyrApplicationHardwareRunLaunchConfigDelegate 24 | extends ZephyrAbstractRunLaunchConfigDelegate { 25 | 26 | private static final String CMD_FLASH = "flash"; //$NON-NLS-1$ 27 | 28 | @Override 29 | public void launch(ILaunchConfiguration configuration, String mode, 30 | ILaunch launch, IProgressMonitor monitor) throws CoreException { 31 | if (ILaunchManager.RUN_MODE.equals(mode)) { 32 | run(configuration, mode, launch, monitor); 33 | } else { 34 | throw new CoreException(ZephyrHelpers.errorStatus( 35 | "Project is not correctly configured.", //$NON-NLS-1$ 36 | new RuntimeException( 37 | String.format("Unknown mode: %s", mode)))); // $NON-NLS-1$ 38 | } 39 | } 40 | 41 | private void run(ILaunchConfiguration configuration, String mode, 42 | ILaunch launch, IProgressMonitor monitor) throws CoreException { 43 | IProject project = getProject(configuration); 44 | ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget(); 45 | 46 | ZephyrApplicationBuildConfiguration appBuildCfg = 47 | getBuildConfiguration(project, mode, target, monitor); 48 | ZephyrGCCToolChain toolChain = 49 | (ZephyrGCCToolChain) appBuildCfg.getToolChain(); 50 | 51 | String cmakeGenerator = ZephyrHelpers.getCMakeGenerator(project); 52 | String makeProgram = toolChain.getMakeProgram(); 53 | if (makeProgram == null) { 54 | throw new CoreException(ZephyrHelpers.errorStatus( 55 | "Project is not correctly configured.", //$NON-NLS-1$ 56 | new RuntimeException("Cannot get CMake generator used."))); //$NON-NLS-1$ 57 | } 58 | 59 | /* Figure out whether to do run, flash or custom command */ 60 | String commandSelection = configuration.getAttribute( 61 | ZephyrLaunchConstants.ATTR_FLASH_CMD_SEL, 62 | ZephyrStrings.EMPTY_STRING); 63 | String cmdToRun = null; 64 | if (commandSelection 65 | .equals(ZephyrLaunchConstants.FLASH_CMD_SEL_BUILDSYS)) { 66 | cmdToRun = CMD_FLASH; 67 | 68 | if (cmakeGenerator 69 | .equals(CMakeConstants.CMAKE_GENERATOR_MAKEFILE)) { 70 | doMakefile(project, appBuildCfg, launch, makeProgram, cmdToRun); 71 | } else if (cmakeGenerator 72 | .equals(CMakeConstants.CMAKE_GENERATOR_NINJA)) { 73 | doNinja(project, appBuildCfg, launch, makeProgram, cmdToRun); 74 | } else { 75 | throw new CoreException(ZephyrHelpers.errorStatus( 76 | "Project is not correctly configured.", //$NON-NLS-1$ 77 | new RuntimeException("Unknown CMake Generator."))); //$NON-NLS-1$ 78 | } 79 | } else if (commandSelection 80 | .equals(ZephyrLaunchConstants.FLASH_CMD_SEL_WEST)) { 81 | String args = configuration.getAttribute( 82 | ZephyrLaunchConstants.ATTR_FLASH_CMD_WEST_ARGS, 83 | ZephyrStrings.EMPTY_STRING); 84 | if (args.trim().isEmpty()) { 85 | args = null; 86 | } 87 | 88 | runWest(project, appBuildCfg, launch, CMD_FLASH, args); 89 | } else { 90 | throw new CoreException(ZephyrHelpers.errorStatus( 91 | "Project is not correctly configured.", //$NON-NLS-1$ 92 | new RuntimeException("Unknown Command to Run"))); //$NON-NLS-1$ 93 | } 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/launch/ZephyrLaunchConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.launch; 8 | 9 | import org.zephyrproject.ide.eclipse.core.ZephyrPlugin; 10 | 11 | /** 12 | * Contains launch related constants. 13 | */ 14 | public final class ZephyrLaunchConstants { 15 | 16 | public static final String LAUNCH_ID = 17 | ZephyrPlugin.PLUGIN_ID + ".ui.launch"; //$NON-NLS-1$ 18 | 19 | public static final String ATTR_EMULATOR_RUN_CMD_SEL = 20 | LAUNCH_ID + ".EMULATOR_RUN_CMD_SEL"; //$NON-NLS-1$ 21 | 22 | public static final String EMULATOR_RUN_CMD_SEL_NONE = 23 | "EMULATOR_RUN_CMD_SEL_NONE"; //$NON-NLS-1$ 24 | 25 | public static final String EMULATOR_RUN_CMD_SEL_BUILDSYS = 26 | "EMULATOR_RUN_CMD_SEL_BUILDSYS"; //$NON-NLS-1$ 27 | 28 | public static final String EMULATOR_RUN_CMD_SEL_WEST = 29 | "EMULATOR_RUN_CMD_SEL_WEST"; //$NON-NLS-1$ 30 | 31 | public static final String ATTR_RUN_CMD_WEST_ARGS = 32 | LAUNCH_ID + ".RUN_CMD_WEST_ARGS"; //$NON-NLS-1$ 33 | 34 | public static final String ATTR_FLASH_CMD_SEL = 35 | LAUNCH_ID + ".FLASH_CMD_SEL"; //$NON-NLS-1$ 36 | 37 | public static final String FLASH_CMD_SEL_NONE = "FLASH_CMD_SEL_NONE"; //$NON-NLS-1$ 38 | 39 | public static final String FLASH_CMD_SEL_BUILDSYS = 40 | "FLASH_CMD_SEL_BUILDSYS"; //$NON-NLS-1$ 41 | 42 | public static final String FLASH_CMD_SEL_WEST = "FLASH_CMD_SEL_WEST"; //$NON-NLS-1$ 43 | 44 | public static final String ATTR_FLASH_CMD_WEST_ARGS = 45 | LAUNCH_ID + ".FLASH_CMD_WEST_ARGS"; //$NON-NLS-1$ 46 | 47 | public static final String ATTR_DBGSERVER_CMD_SEL = 48 | LAUNCH_ID + ".DBGSERVER_CMD_SEL"; //$NON-NLS-1$ 49 | 50 | public static final String DBGSERVER_CMD_SEL_NONE = 51 | "DBGSERVER_CMD_SEL_NONE"; //$NON-NLS-1$ 52 | 53 | public static final String DBGSERVER_CMD_SEL_BUILDSYS = 54 | "DBGSERVER_CMD_SEL_BUILDSYS"; //$NON-NLS-1$ 55 | 56 | public static final String DBGSERVER_CMD_SEL_WEST = 57 | "DBGSERVER_CMD_SEL_WEST"; //$NON-NLS-1$ 58 | 59 | public static final String ATTR_DBGSERVER_CMD_WEST_ARGS = 60 | LAUNCH_ID + ".DBGSERVER_CMD_WEST_ARGS"; //$NON-NLS-1$ 61 | 62 | public static final String LAUNCH_TARGET_EMULATOR_RUN_NAME = "Emulator"; // $NON-NLS-1 63 | 64 | public static final String LAUNCH_TARGET_HARDWARE_RUN_NAME = "Hardware"; // $NON-NLS-1 65 | 66 | public static final String LAUNCH_TARGET_EMULATOR_RUN_TYPE_ID = 67 | ZephyrPlugin.PLUGIN_ID + ".launchTargetType.emulator.run"; //$NON-NLS-1$ 68 | 69 | public static final String LAUNCH_TARGET_HARDWARE_RUN_TYPE_ID = 70 | ZephyrPlugin.PLUGIN_ID + ".launchTargetType.hardware.run"; //$NON-NLS-1$ 71 | 72 | public static final String LAUNCH_TARGET_OS = "zephyr"; //$NON-NLS-1$ 73 | 74 | public static final String LAUNCH_TARGET_ARCH = "zephyr"; //$NON-NLS-1$ 75 | } 76 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/launch/ZephyrProcessFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.launch; 8 | 9 | import java.lang.reflect.Constructor; 10 | import java.lang.reflect.InvocationTargetException; 11 | import java.util.Map; 12 | 13 | import org.eclipse.cdt.dsf.gdb.IGdbDebugConstants; 14 | import org.eclipse.cdt.dsf.gdb.launching.GDBProcess; 15 | import org.eclipse.cdt.dsf.gdb.launching.InferiorRuntimeProcess; 16 | import org.eclipse.core.runtime.Platform; 17 | import org.eclipse.debug.core.ILaunch; 18 | import org.eclipse.debug.core.IProcessFactory; 19 | import org.eclipse.debug.core.model.IProcess; 20 | import org.eclipse.debug.core.model.RuntimeProcess; 21 | import org.zephyrproject.ide.eclipse.core.ZephyrPlugin; 22 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 23 | 24 | public class ZephyrProcessFactory implements IProcessFactory { 25 | 26 | public static final String ID = ZephyrPlugin.PLUGIN_ID + ".processFactory"; //$NON-NLS-1$ 27 | 28 | private static Constructor getRuntimeProcessConstructor() { 29 | Constructor runtime = null; 30 | Class runtimeClass = null; 31 | String className; 32 | 33 | Double jvmSpecVer = Double 34 | .parseDouble(System.getProperty("java.specification.version")); 35 | if (jvmSpecVer >= 11) { 36 | className = String.format( 37 | "%s.internal.launch.java11.ZephyrRuntimeProcess", //$NON-NLS-1$ 38 | ZephyrPlugin.PLUGIN_ID); 39 | } else { 40 | className = 41 | String.format("%s.internal.launch.%s.ZephyrRuntimeProcess", //$NON-NLS-1$ 42 | ZephyrPlugin.PLUGIN_ID, Platform.getOS()); 43 | } 44 | 45 | try { 46 | ClassLoader loader = ZephyrHelpers.class.getClassLoader(); 47 | runtimeClass = loader.loadClass(className); 48 | } catch (ClassNotFoundException cnfe) { 49 | runtimeClass = null; 50 | } 51 | 52 | if (runtimeClass != null) { 53 | try { 54 | /* Grab the constructor */ 55 | Class args[] = new Class[4]; 56 | args[0] = ILaunch.class; 57 | args[1] = Process.class; 58 | args[2] = String.class; 59 | args[3] = Map.class; 60 | 61 | runtime = runtimeClass.getConstructor(args); 62 | } catch (NoSuchMethodException | SecurityException e) { 63 | runtime = null; 64 | } 65 | } 66 | 67 | return runtime; 68 | } 69 | 70 | @Override 71 | public IProcess newProcess(ILaunch launch, Process process, String label, 72 | Map attributes) { 73 | if (attributes != null) { 74 | if (IGdbDebugConstants.GDB_PROCESS_CREATION_VALUE.equals(attributes 75 | .get(IGdbDebugConstants.PROCESS_TYPE_CREATION_ATTR))) { 76 | return new GDBProcess(launch, process, label, attributes); 77 | } 78 | 79 | if (IGdbDebugConstants.INFERIOR_PROCESS_CREATION_VALUE 80 | .equals(attributes.get( 81 | IGdbDebugConstants.PROCESS_TYPE_CREATION_ATTR))) { 82 | return new InferiorRuntimeProcess(launch, process, label, 83 | attributes); 84 | } 85 | } 86 | 87 | Constructor runtime = getRuntimeProcessConstructor(); 88 | IProcess iproc = null; 89 | if (runtime != null) { 90 | try { 91 | iproc = (IProcess) runtime.newInstance(launch, process, label, 92 | attributes); 93 | } catch (InstantiationException | IllegalAccessException 94 | | IllegalArgumentException | InvocationTargetException e) { 95 | iproc = null; 96 | } 97 | } 98 | 99 | if (iproc == null) { 100 | iproc = new RuntimeProcess(launch, process, label, attributes); 101 | } 102 | 103 | return iproc; 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/launchbar/ZephyrApplicationLaunchConfigurationProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.launchbar; 8 | 9 | import org.eclipse.core.resources.IProject; 10 | import org.eclipse.core.resources.IResource; 11 | import org.eclipse.core.runtime.CoreException; 12 | import org.eclipse.debug.core.DebugPlugin; 13 | import org.eclipse.debug.core.ILaunchConfiguration; 14 | import org.eclipse.debug.core.ILaunchConfigurationType; 15 | import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 16 | import org.eclipse.debug.core.ILaunchManager; 17 | import org.eclipse.launchbar.core.ILaunchDescriptor; 18 | import org.eclipse.launchbar.core.ProjectPerTargetLaunchConfigProvider; 19 | import org.eclipse.launchbar.core.target.ILaunchTarget; 20 | import org.eclipse.launchbar.core.target.ILaunchTargetManager; 21 | import org.zephyrproject.ide.eclipse.core.launch.ZephyrLaunchConstants; 22 | import org.zephyrproject.ide.eclipse.core.launch.ZephyrProcessFactory; 23 | 24 | public class ZephyrApplicationLaunchConfigurationProvider 25 | extends ProjectPerTargetLaunchConfigProvider { 26 | 27 | @Override 28 | protected ILaunchConfiguration createLaunchConfiguration( 29 | ILaunchDescriptor descriptor, ILaunchTarget target) 30 | throws CoreException { 31 | ILaunchManager launchManager = 32 | DebugPlugin.getDefault().getLaunchManager(); 33 | String name = launchManager 34 | .generateLaunchConfigurationName(descriptor.getName()); 35 | ILaunchConfigurationType type = 36 | getLaunchConfigurationType(descriptor, target); 37 | ILaunchConfigurationWorkingCopy workingCopy = 38 | type.newInstance(null, name); 39 | 40 | populateLaunchConfiguration(descriptor, target, workingCopy); 41 | 42 | return workingCopy.doSave(); 43 | } 44 | 45 | @Override 46 | public ILaunchConfigurationType getLaunchConfigurationType( 47 | ILaunchDescriptor descriptor, ILaunchTarget target) 48 | throws CoreException { 49 | return DebugPlugin.getDefault().getLaunchManager() 50 | .getLaunchConfigurationType(target.getTypeId()); 51 | } 52 | 53 | @Override 54 | public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) 55 | throws CoreException { 56 | if (ZephyrLaunchConstants.LAUNCH_TARGET_EMULATOR_RUN_TYPE_ID 57 | .equals(target.getTypeId())) { 58 | return true; 59 | } else if (ZephyrLaunchConstants.LAUNCH_TARGET_HARDWARE_RUN_TYPE_ID 60 | .equals(target.getTypeId())) { 61 | return true; 62 | } 63 | 64 | return false; 65 | } 66 | 67 | @Override 68 | protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, 69 | ILaunchTarget target, ILaunchConfigurationWorkingCopy workingCopy) 70 | throws CoreException { 71 | super.populateLaunchConfiguration(descriptor, target, workingCopy); 72 | 73 | /* Set the project and the connection */ 74 | IProject project = descriptor.getAdapter(IProject.class); 75 | workingCopy.setMappedResources(new IResource[] { 76 | project 77 | }); 78 | 79 | /* Use our own process factory */ 80 | workingCopy.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, 81 | ZephyrProcessFactory.ID); 82 | 83 | if (target.getTypeId().equals( 84 | ZephyrLaunchConstants.LAUNCH_TARGET_EMULATOR_RUN_TYPE_ID)) { 85 | workingCopy.setAttribute( 86 | ZephyrLaunchConstants.ATTR_EMULATOR_RUN_CMD_SEL, 87 | ZephyrLaunchConstants.EMULATOR_RUN_CMD_SEL_BUILDSYS); 88 | } else if (target.getTypeId().equals( 89 | ZephyrLaunchConstants.LAUNCH_TARGET_HARDWARE_RUN_TYPE_ID)) { 90 | workingCopy.setAttribute(ZephyrLaunchConstants.ATTR_FLASH_CMD_SEL, 91 | ZephyrLaunchConstants.FLASH_CMD_SEL_BUILDSYS); 92 | } 93 | } 94 | 95 | @Override 96 | protected ILaunchTarget getLaunchTarget(ILaunchConfiguration configuration) 97 | throws CoreException { 98 | @SuppressWarnings("restriction") 99 | ILaunchTargetManager manager = 100 | org.eclipse.launchbar.core.internal.Activator 101 | .getLaunchTargetManager(); 102 | 103 | ILaunchTarget target = manager.getDefaultLaunchTarget(configuration); 104 | if (target != null) { 105 | return target; 106 | } 107 | 108 | String type = configuration.getType().getIdentifier(); 109 | 110 | if (type.equals( 111 | ZephyrLaunchConstants.LAUNCH_TARGET_EMULATOR_RUN_TYPE_ID)) { 112 | target = manager.getLaunchTarget( 113 | ZephyrLaunchConstants.LAUNCH_TARGET_EMULATOR_RUN_TYPE_ID, 114 | ZephyrLaunchConstants.LAUNCH_TARGET_EMULATOR_RUN_NAME); 115 | } else if (type.equals( 116 | ZephyrLaunchConstants.LAUNCH_TARGET_HARDWARE_RUN_TYPE_ID)) { 117 | target = manager.getLaunchTarget( 118 | ZephyrLaunchConstants.LAUNCH_TARGET_HARDWARE_RUN_TYPE_ID, 119 | ZephyrLaunchConstants.LAUNCH_TARGET_HARDWARE_RUN_NAME); 120 | } 121 | 122 | return target; 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/launchbar/ZephyrApplicationLaunchDescriptorType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.launchbar; 8 | 9 | import org.eclipse.core.resources.IProject; 10 | import org.eclipse.core.runtime.CoreException; 11 | import org.eclipse.launchbar.core.ILaunchDescriptor; 12 | import org.eclipse.launchbar.core.ILaunchDescriptorType; 13 | import org.eclipse.launchbar.core.ProjectLaunchDescriptor; 14 | import org.zephyrproject.ide.eclipse.core.ZephyrApplicationNature; 15 | 16 | public class ZephyrApplicationLaunchDescriptorType 17 | implements ILaunchDescriptorType { 18 | 19 | @Override 20 | public ILaunchDescriptor getDescriptor(Object launchObject) 21 | throws CoreException { 22 | if (launchObject instanceof IProject 23 | && ZephyrApplicationNature.hasNature((IProject) launchObject)) { 24 | return new ProjectLaunchDescriptor(this, (IProject) launchObject); 25 | } 26 | 27 | return null; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/launchbar/ZephyrApplicationLaunchTargetProvider.java: -------------------------------------------------------------------------------- 1 | package org.zephyrproject.ide.eclipse.core.launchbar; 2 | 3 | import org.eclipse.launchbar.core.target.ILaunchTarget; 4 | import org.eclipse.launchbar.core.target.ILaunchTargetManager; 5 | import org.eclipse.launchbar.core.target.ILaunchTargetProvider; 6 | import org.eclipse.launchbar.core.target.ILaunchTargetWorkingCopy; 7 | import org.eclipse.launchbar.core.target.TargetStatus; 8 | import org.zephyrproject.ide.eclipse.core.launch.ZephyrLaunchConstants; 9 | 10 | public class ZephyrApplicationLaunchTargetProvider 11 | implements ILaunchTargetProvider { 12 | 13 | @Override 14 | public void init(ILaunchTargetManager targetManager) { 15 | if (targetManager.getLaunchTarget( 16 | ZephyrLaunchConstants.LAUNCH_TARGET_EMULATOR_RUN_TYPE_ID, 17 | ZephyrLaunchConstants.LAUNCH_TARGET_EMULATOR_RUN_NAME) == null) { 18 | ILaunchTarget target = targetManager.addLaunchTarget( 19 | ZephyrLaunchConstants.LAUNCH_TARGET_EMULATOR_RUN_TYPE_ID, 20 | ZephyrLaunchConstants.LAUNCH_TARGET_EMULATOR_RUN_NAME); 21 | ILaunchTargetWorkingCopy wc = target.getWorkingCopy(); 22 | wc.setAttribute(ILaunchTarget.ATTR_OS, 23 | ZephyrLaunchConstants.LAUNCH_TARGET_OS); 24 | wc.setAttribute(ILaunchTarget.ATTR_ARCH, 25 | ZephyrLaunchConstants.LAUNCH_TARGET_ARCH); 26 | wc.save(); 27 | } 28 | 29 | if (targetManager.getLaunchTarget( 30 | ZephyrLaunchConstants.LAUNCH_TARGET_HARDWARE_RUN_TYPE_ID, 31 | ZephyrLaunchConstants.LAUNCH_TARGET_HARDWARE_RUN_NAME) == null) { 32 | ILaunchTarget target = targetManager.addLaunchTarget( 33 | ZephyrLaunchConstants.LAUNCH_TARGET_HARDWARE_RUN_TYPE_ID, 34 | ZephyrLaunchConstants.LAUNCH_TARGET_HARDWARE_RUN_NAME); 35 | ILaunchTargetWorkingCopy wc = target.getWorkingCopy(); 36 | wc.setAttribute(ILaunchTarget.ATTR_OS, 37 | ZephyrLaunchConstants.LAUNCH_TARGET_OS); 38 | wc.setAttribute(ILaunchTarget.ATTR_ARCH, 39 | ZephyrLaunchConstants.LAUNCH_TARGET_ARCH); 40 | wc.save(); 41 | } 42 | } 43 | 44 | @Override 45 | public TargetStatus getStatus(ILaunchTarget arg0) { 46 | return TargetStatus.OK_STATUS; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/preferences/ZephyrPreferenceConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.preferences; 8 | 9 | /** 10 | * Constant definitions for plug-in preferences 11 | */ 12 | public class ZephyrPreferenceConstants { 13 | 14 | public static final String P_ZEPHYR_BASE = "ZEPHYR_BASE"; //$NON-NLS-1$ 15 | 16 | public static final String P_ZEPHYR_SDK_INSTALL_DIR = 17 | "ZEPHYR_SDK_INSTALL_DIR"; //$NON-NLS-1$ 18 | 19 | public static final String P_GNUARMEMB_TOOLCHAIN_PATH = 20 | "GNUARMEMB_TOOLCHAIN_PATH"; //$NON-NLS-1$ 21 | 22 | public static final String P_XTOOLS_TOOLCHAIN_PATH = 23 | "XTOOLS_TOOLCHAIN_PATH"; //$NON-NLS-1$ 24 | 25 | public static final String P_CROSS_COMPILE_PREFIX = "CROSS_COMPILE_PREFIX"; //$NON-NLS-1$ 26 | 27 | } 28 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/preferences/ZephyrPreferenceInitializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.preferences; 8 | 9 | import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; 10 | import org.eclipse.jface.preference.IPreferenceStore; 11 | import org.zephyrproject.ide.eclipse.core.ZephyrPlugin; 12 | import org.zephyrproject.ide.eclipse.core.ZephyrStrings; 13 | 14 | /** 15 | * Class used to initialize default preference values. 16 | */ 17 | public class ZephyrPreferenceInitializer extends AbstractPreferenceInitializer { 18 | 19 | /* 20 | * (non-Javadoc) 21 | * 22 | * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer# 23 | * initializeDefaultPreferences() 24 | */ 25 | @Override 26 | public void initializeDefaultPreferences() { 27 | IPreferenceStore store = ZephyrPlugin.getDefault().getPreferenceStore(); 28 | 29 | store.setDefault(ZephyrPreferenceConstants.P_ZEPHYR_BASE, 30 | ZephyrStrings.EMPTY_STRING); 31 | 32 | store.setDefault(ZephyrPreferenceConstants.P_ZEPHYR_SDK_INSTALL_DIR, 33 | ZephyrStrings.EMPTY_STRING); 34 | store.setDefault(ZephyrPreferenceConstants.P_GNUARMEMB_TOOLCHAIN_PATH, 35 | ZephyrStrings.EMPTY_STRING); 36 | store.setDefault(ZephyrPreferenceConstants.P_XTOOLS_TOOLCHAIN_PATH, 37 | ZephyrStrings.EMPTY_STRING); 38 | store.setDefault(ZephyrPreferenceConstants.P_CROSS_COMPILE_PREFIX, 39 | ZephyrStrings.EMPTY_STRING); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/src/org/zephyrproject/ide/eclipse/core/preferences/ZephyrProjectPreferences.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.core.preferences; 8 | 9 | import org.eclipse.core.resources.IProject; 10 | import org.eclipse.ui.preferences.ScopedPreferenceStore; 11 | import org.zephyrproject.ide.eclipse.core.ZephyrStrings; 12 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 13 | 14 | public final class ZephyrProjectPreferences { 15 | 16 | public static class ZephyrBase { 17 | 18 | public static final String ZEPHYR_BASE = "ZEPHYR_BASE"; //$NON-NLS-1$ 19 | 20 | public static final String DESCRIPTION = "Zephyr Base"; 21 | 22 | public static final String DIRECTORY_DESCRIPTION = String.join( 23 | ZephyrStrings.ONE_EMPTY_SPACE, DESCRIPTION, ZephyrStrings.PATH); 24 | 25 | public static final String ZEPHYR_BASE_LOCATION = 26 | "ZEPHYR_BASE_LOCATION"; //$NON-NLS-1$ 27 | 28 | } 29 | 30 | public static final String BOARD = "BOARD"; //$NON-NLS-1$ 31 | 32 | public static final String BUILD_DIR = "BUILD_DIR"; //$NON-NLS-1$ 33 | 34 | public static final String BUILD_DIR_DEFAULT = "build"; //$NON-NLS-1$ 35 | 36 | public static final String SOURCE_DIR = "SOURCE_DIR"; //$NON-NLS-1$ 37 | 38 | public static final String SOURCE_DIR_DEFAULT = "src"; //$NON-NLS-1$ 39 | 40 | /** 41 | * Get the project relative path of build directory. 42 | * 43 | * @param pStore Project ScopedPreferenceStore 44 | * @return Build directory 45 | */ 46 | public static String getBuildDirectory(ScopedPreferenceStore pStore) { 47 | String buildDir = ZephyrHelpers.getProjectPreference(pStore, 48 | ZephyrProjectPreferences.BUILD_DIR); 49 | 50 | if (buildDir == null) { 51 | buildDir = ZephyrProjectPreferences.BUILD_DIR_DEFAULT; 52 | } 53 | 54 | return buildDir; 55 | } 56 | 57 | /** 58 | * Get the project relative path of build directory. 59 | * 60 | * @param project Project 61 | * @return Build directory 62 | */ 63 | public static String getBuildDirectory(IProject project) { 64 | return getBuildDirectory( 65 | ZephyrHelpers.getProjectPreferenceStore(project)); 66 | } 67 | 68 | /** 69 | * Get the project relative path of source directory. 70 | * 71 | * @param pStore Project ScopedPreferenceStore 72 | * @return Source directory 73 | */ 74 | public static String getSourceDirectory(ScopedPreferenceStore pStore) { 75 | String buildDir = ZephyrHelpers.getProjectPreference(pStore, 76 | ZephyrProjectPreferences.BUILD_DIR); 77 | 78 | if (buildDir == null) { 79 | buildDir = ZephyrProjectPreferences.BUILD_DIR_DEFAULT; 80 | } 81 | 82 | return buildDir; 83 | } 84 | 85 | /** 86 | * Get the project relative path of source directory. 87 | * 88 | * @param project Project 89 | * @return Source directory 90 | */ 91 | public static String getSourceDirectory(IProject project) { 92 | return getBuildDirectory( 93 | ZephyrHelpers.getProjectPreferenceStore(project)); 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/templates/ZephyrApplication/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ===== DO NOT REMOVE ===== 2 | cmake_minimum_required(VERSION 3.13.1) 3 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 4 | # ===== DO NOT REMOVE ===== 5 | 6 | project(${projectName}) 7 | 8 | target_sources(app PRIVATE src/main.c) 9 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/templates/ZephyrApplication/prj.conf: -------------------------------------------------------------------------------- 1 | # nothing here 2 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/templates/ZephyrApplication/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void main(void) 5 | { 6 | printk("Hello World! %s\n", CONFIG_BOARD); 7 | } 8 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.core/templates/ZephyrApplication/template.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 10 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /target/ 3 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.zephyrproject.ide.eclipse.ui 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.m2e.core.maven2Nature 31 | org.eclipse.pde.PluginNature 32 | org.eclipse.jdt.core.javanature 33 | 34 | 35 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | cleanup.add_default_serial_version_id=true 2 | cleanup.add_generated_serial_version_id=false 3 | cleanup.add_missing_annotations=true 4 | cleanup.add_missing_deprecated_annotations=true 5 | cleanup.add_missing_methods=false 6 | cleanup.add_missing_nls_tags=false 7 | cleanup.add_missing_override_annotations=true 8 | cleanup.add_missing_override_annotations_interface_methods=true 9 | cleanup.add_serial_version_id=false 10 | cleanup.always_use_blocks=true 11 | cleanup.always_use_parentheses_in_expressions=true 12 | cleanup.always_use_this_for_non_static_field_access=false 13 | cleanup.always_use_this_for_non_static_method_access=false 14 | cleanup.convert_functional_interfaces=false 15 | cleanup.convert_to_enhanced_for_loop=false 16 | cleanup.correct_indentation=true 17 | cleanup.format_source_code=false 18 | cleanup.format_source_code_changes_only=false 19 | cleanup.insert_inferred_type_arguments=false 20 | cleanup.make_local_variable_final=true 21 | cleanup.make_parameters_final=false 22 | cleanup.make_private_fields_final=true 23 | cleanup.make_type_abstract_if_missing_method=false 24 | cleanup.make_variable_declarations_final=false 25 | cleanup.never_use_blocks=false 26 | cleanup.never_use_parentheses_in_expressions=false 27 | cleanup.organize_imports=false 28 | cleanup.qualify_static_field_accesses_with_declaring_class=false 29 | cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true 30 | cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true 31 | cleanup.qualify_static_member_accesses_with_declaring_class=true 32 | cleanup.qualify_static_method_accesses_with_declaring_class=false 33 | cleanup.remove_private_constructors=true 34 | cleanup.remove_redundant_type_arguments=false 35 | cleanup.remove_trailing_whitespaces=true 36 | cleanup.remove_trailing_whitespaces_all=true 37 | cleanup.remove_trailing_whitespaces_ignore_empty=false 38 | cleanup.remove_unnecessary_casts=true 39 | cleanup.remove_unnecessary_nls_tags=true 40 | cleanup.remove_unused_imports=true 41 | cleanup.remove_unused_local_variables=false 42 | cleanup.remove_unused_private_fields=true 43 | cleanup.remove_unused_private_members=false 44 | cleanup.remove_unused_private_methods=true 45 | cleanup.remove_unused_private_types=true 46 | cleanup.sort_members=false 47 | cleanup.sort_members_all=false 48 | cleanup.use_anonymous_class_creation=false 49 | cleanup.use_blocks=true 50 | cleanup.use_blocks_only_for_return_and_throw=false 51 | cleanup.use_lambda=true 52 | cleanup.use_parentheses_in_expressions=false 53 | cleanup.use_this_for_non_static_field_access=false 54 | cleanup.use_this_for_non_static_field_access_only_if_necessary=true 55 | cleanup.use_this_for_non_static_method_access=false 56 | cleanup.use_this_for_non_static_method_access_only_if_necessary=true 57 | cleanup_profile=_Zephyr 58 | cleanup_settings_version=2 59 | eclipse.preferences.version=1 60 | formatter_profile=_Zephyr 61 | formatter_settings_version=12 62 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/.settings/org.eclipse.pde.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | resolve.requirebundle=false 3 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Zephyr Project Development Support - UI 4 | Bundle-SymbolicName: org.zephyrproject.ide.eclipse.ui;singleton:=true 5 | Bundle-Version: 0.2.99.qualifier 6 | Bundle-Activator: org.zephyrproject.ide.eclipse.ui.ZephyrUIPlugin 7 | Bundle-Vendor: Zephyr Project 8 | Require-Bundle: org.eclipse.core.runtime;bundle-version="3.17.0", 9 | org.eclipse.core.resources;bundle-version="3.13.600", 10 | org.eclipse.cdt.build.gcc.core;bundle-version="1.0.200", 11 | org.eclipse.cdt.core;bundle-version="6.10.0", 12 | org.eclipse.cdt.debug.core;bundle-version="8.4.0", 13 | org.eclipse.cdt.debug.gdbjtag.core;bundle-version="9.4.0", 14 | org.eclipse.cdt.debug.gdbjtag.ui;bundle-version="8.1.100", 15 | org.eclipse.cdt.debug.ui;bundle-version="8.3.300", 16 | org.eclipse.cdt.dsf;bundle-version="2.8.200", 17 | org.eclipse.cdt.dsf.gdb;bundle-version="5.8.0", 18 | org.eclipse.cdt.dsf.gdb.ui;bundle-version="2.6.400", 19 | org.eclipse.cdt.dsf.ui;bundle-version="2.5.300", 20 | org.eclipse.cdt.launch;bundle-version="9.3.100", 21 | org.eclipse.cdt.ui;bundle-version="6.6.100", 22 | org.eclipse.debug.ui;bundle-version="3.14.300", 23 | org.eclipse.tools.templates.ui;bundle-version="1.1.2", 24 | org.eclipse.tools.templates.freemarker;bundle-version="1.1.2", 25 | org.eclipse.equinox.bidi;bundle-version="1.2.200", 26 | org.eclipse.launchbar.core;bundle-version="2.3.0", 27 | org.eclipse.launchbar.ui;bundle-version="2.3.0", 28 | org.eclipse.platform;bundle-version="4.14.0", 29 | org.eclipse.swt;bundle-version="3.113.0", 30 | org.eclipse.ui;bundle-version="3.115.0", 31 | org.eclipse.ui.ide;bundle-version="3.16.100", 32 | org.zephyrproject.ide.eclipse.core;bundle-version="0.2.99" 33 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 34 | Automatic-Module-Name: org.zephyrproject.ide.eclipse.ui 35 | Bundle-ActivationPolicy: lazy 36 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/about.ini: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: EPL-2.0 5 | # 6 | 7 | aboutText=%blurb 8 | 9 | featureImage=icons/zephyr-kite-logo_32x32.png 10 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/about.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: EPL-2.0 5 | # 6 | 7 | blurb=Zephyr Project Development Support\n\ 8 | \n\ 9 | Version: {featureVersion}\n\ 10 | \n\ 11 | (c) Copyright (c) 2019 Intel Corporation\n\ 12 | \n\ 13 | Visit https://www.zephyrproject.org/ 14 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = target/classes/ 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | about.ini,\ 6 | about.properties,\ 7 | plugin.xml,\ 8 | icons/ 9 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/icons/wizard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zephyrproject-rtos/eclipse-plugin/2eec01f5508c25d4f2e7f8547dbece8a4581acd8/plugins/org.zephyrproject.ide.eclipse.ui/icons/wizard.png -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/icons/zephyr-kite-logo-txt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zephyrproject-rtos/eclipse-plugin/2eec01f5508c25d4f2e7f8547dbece8a4581acd8/plugins/org.zephyrproject.ide.eclipse.ui/icons/zephyr-kite-logo-txt.png -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/icons/zephyr-kite-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zephyrproject-rtos/eclipse-plugin/2eec01f5508c25d4f2e7f8547dbece8a4581acd8/plugins/org.zephyrproject.ide.eclipse.ui/icons/zephyr-kite-logo.png -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/icons/zephyr-kite-logo_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zephyrproject-rtos/eclipse-plugin/2eec01f5508c25d4f2e7f8547dbece8a4581acd8/plugins/org.zephyrproject.ide.eclipse.ui/icons/zephyr-kite-logo_16x16.png -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/icons/zephyr-kite-logo_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zephyrproject-rtos/eclipse-plugin/2eec01f5508c25d4f2e7f8547dbece8a4581acd8/plugins/org.zephyrproject.ide.eclipse.ui/icons/zephyr-kite-logo_32x32.png -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/icons/zephyr-kite-logo_48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zephyrproject-rtos/eclipse-plugin/2eec01f5508c25d4f2e7f8547dbece8a4581acd8/plugins/org.zephyrproject.ide.eclipse.ui/icons/zephyr-kite-logo_48x48.png -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/icons/zephyr-project-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zephyrproject-rtos/eclipse-plugin/2eec01f5508c25d4f2e7f8547dbece8a4581acd8/plugins/org.zephyrproject.ide.eclipse.ui/icons/zephyr-project-icon.png -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/plugin.properties: -------------------------------------------------------------------------------- 1 | bundle.name = Zephyr Project Eclipse Plugin 2 | bundle.vendor = Zephyr Project 3 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | 7 | org.zephyrproject 8 | org.zephyrproject.ide.eclipse.parent 9 | 0.2.99-SNAPSHOT 10 | ../../maven/parent 11 | 12 | 13 | Zephyr Project Eclipse Plugin - UI 14 | https://www.zephyrproject.org/ 15 | 16 | 17 | Zephyr Project 18 | https://www.zephyrproject.org/ 19 | 20 | 21 | org.zephyrproject.ide.eclipse.ui 22 | eclipse-plugin 23 | 24 | 25 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/ZephyrUIPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui; 8 | 9 | import org.eclipse.jface.resource.ImageRegistry; 10 | import org.eclipse.jface.resource.ResourceLocator; 11 | import org.eclipse.ui.plugin.AbstractUIPlugin; 12 | import org.osgi.framework.BundleContext; 13 | import org.osgi.framework.ServiceReference; 14 | 15 | /** 16 | * The activator class controls the plug-in life cycle 17 | */ 18 | public class ZephyrUIPlugin extends AbstractUIPlugin { 19 | 20 | // The plug-in ID 21 | public static final String PLUGIN_ID = "org.zephyrproject.ide.eclipse.ui"; //$NON-NLS-1$ 22 | 23 | public static final String IMG_ZEPHYR_KITE16 = PLUGIN_ID + "zephyr.kite.16"; //$NON-NLS-1$ 24 | 25 | public static final String IMG_ZEPHYR_KITE32 = PLUGIN_ID + "zephyr.kite.32"; //$NON-NLS-1$ 26 | 27 | public static final String IMG_ZEPHYR_KITE48 = PLUGIN_ID + "zephyr.kite.48"; //$NON-NLS-1$ 28 | 29 | // The shared instance 30 | private static ZephyrUIPlugin plugin; 31 | 32 | /** 33 | * The constructor 34 | */ 35 | public ZephyrUIPlugin() { 36 | } 37 | 38 | /* 39 | * (non-Javadoc) 40 | * 41 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework. 42 | * BundleContext) 43 | */ 44 | @Override 45 | public void start(BundleContext context) throws Exception { 46 | super.start(context); 47 | plugin = this; 48 | } 49 | 50 | /* 51 | * (non-Javadoc) 52 | * 53 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework. 54 | * BundleContext) 55 | */ 56 | @Override 57 | public void stop(BundleContext context) throws Exception { 58 | plugin = null; 59 | super.stop(context); 60 | } 61 | 62 | /** 63 | * Returns the shared instance 64 | * 65 | * @return the shared instance 66 | */ 67 | public static ZephyrUIPlugin getDefault() { 68 | return plugin; 69 | } 70 | 71 | public static String getId() { 72 | return plugin.getBundle().getSymbolicName(); 73 | } 74 | 75 | public static T getService(Class service) { 76 | BundleContext context = plugin.getBundle().getBundleContext(); 77 | ServiceReference ref = context.getServiceReference(service); 78 | return ref != null ? context.getService(ref) : null; 79 | } 80 | 81 | @Override 82 | protected ImageRegistry createImageRegistry() { 83 | ImageRegistry registry = super.createImageRegistry(); 84 | 85 | registry.put(IMG_ZEPHYR_KITE16, 86 | ResourceLocator.imageDescriptorFromBundle(PLUGIN_ID, 87 | "icons/zephyr-kite-logo_16x16.png").get()); //$NON-NLS-1$ 88 | 89 | registry.put(IMG_ZEPHYR_KITE32, 90 | ResourceLocator.imageDescriptorFromBundle(PLUGIN_ID, 91 | "icons/zephyr-kite-logo_32x32.png").get()); //$NON-NLS-1$ 92 | 93 | registry.put(IMG_ZEPHYR_KITE48, 94 | ResourceLocator.imageDescriptorFromBundle(PLUGIN_ID, 95 | "icons/zephyr-kite-logo_48x48.png").get()); //$NON-NLS-1$ 96 | 97 | return registry; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/internal/debug/JTagDeviceDesc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.internal.debug; 8 | 9 | public class JTagDeviceDesc { 10 | 11 | public static final String GENERIC_TCPIP_DEVICE = 12 | "org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.genericDevice"; //$NON-NLS-1$ 13 | 14 | public static final String IP_ADDR_LOCALHOST = "localhost"; //$NON-NLS-1$ 15 | 16 | public String id; 17 | public String jtag; 18 | public String host; 19 | public Integer port; 20 | public String connection; 21 | 22 | private JTagDeviceDesc(String id, String jtag) { 23 | this.id = id; 24 | this.jtag = jtag; 25 | } 26 | 27 | public JTagDeviceDesc(String id, String jtag, String host, Integer port) { 28 | this(id, jtag); 29 | this.host = host; 30 | this.port = port; 31 | this.connection = null; 32 | } 33 | 34 | public JTagDeviceDesc(String id, String jtag, String connection) { 35 | this(id, jtag); 36 | this.connection = connection; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/internal/launch/tabs/CommonDebugLaunchDebuggerTab.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.internal.launch.tabs; 8 | 9 | import org.eclipse.cdt.core.build.IToolChain; 10 | import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants; 11 | import org.eclipse.cdt.debug.gdbjtag.ui.GDBJtagDSFDebuggerTab; 12 | import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; 13 | import org.eclipse.core.resources.IProject; 14 | import org.eclipse.core.resources.IResource; 15 | import org.eclipse.core.runtime.CoreException; 16 | import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 17 | import org.zephyrproject.ide.eclipse.core.build.ZephyrApplicationBuildConfiguration; 18 | import org.zephyrproject.ide.eclipse.core.build.toolchain.ZephyrGCCToolChain; 19 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 20 | import org.zephyrproject.ide.eclipse.ui.internal.debug.JTagDeviceDesc; 21 | 22 | public abstract class CommonDebugLaunchDebuggerTab 23 | extends GDBJtagDSFDebuggerTab { 24 | 25 | protected String defaultJtagDevice = JTagDeviceDesc.GENERIC_TCPIP_DEVICE; 26 | protected String defaultConnection = 27 | String.format("%s:%d", JTagDeviceDesc.IP_ADDR_LOCALHOST, 10000); 28 | 29 | protected JTagDeviceDesc[] jtagDevices = new JTagDeviceDesc[] { 30 | 31 | /* Emulator targets */ 32 | 33 | new JTagDeviceDesc("arc-nsim", //$NON-NLS-1$ 34 | "org.zephyrproject.ide.eclipse.core.debug.jtagdevice.arcnSimDevice", //$NON-NLS-1$ 35 | String.format("%s:%d", JTagDeviceDesc.IP_ADDR_LOCALHOST, 3333)), 36 | new JTagDeviceDesc("qemu", //$NON-NLS-1$ 37 | "org.zephyrproject.ide.eclipse.core.debug.jtagdevice.qemuDevice", //$NON-NLS-1$ 38 | String.format("%s:%d", JTagDeviceDesc.IP_ADDR_LOCALHOST, 1234)), 39 | 40 | /* Hardware targets */ 41 | 42 | new JTagDeviceDesc("blackmagicprobe", //$NON-NLS-1$ 43 | "org.zephyrproject.ide.eclipse.core.debug.jtagdevice.blackMagicProbe", //$NON-NLS-1$ 44 | "/dev/ttyACM0"), //$NON-NLS-1$ 45 | new JTagDeviceDesc("intel_s1000", //$NON-NLS-1$ 46 | "org.zephyrproject.ide.eclipse.core.debug.jtagdevice.xtOCDDevice", //$NON-NLS-1$ 47 | String.format("%s:%d", JTagDeviceDesc.IP_ADDR_LOCALHOST, 48 | 20000)), 49 | new JTagDeviceDesc("JLink", //$NON-NLS-1$ 50 | "org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.SeggerJLink", //$NON-NLS-1$ 51 | String.format("%s:%d", JTagDeviceDesc.IP_ADDR_LOCALHOST, 2331)), 52 | new JTagDeviceDesc("nios2", //$NON-NLS-1$ 53 | "org.zephyrproject.ide.eclipse.core.debug.jtagdevice.nios2Device", //$NON-NLS-1$ 54 | String.format("%s:%d", JTagDeviceDesc.IP_ADDR_LOCALHOST, 3333)), 55 | new JTagDeviceDesc("openocd", //$NON-NLS-1$ 56 | "org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.OpenOCDSocket", //$NON-NLS-1$ 57 | String.format("%s:%d", JTagDeviceDesc.IP_ADDR_LOCALHOST, 3333)), 58 | new JTagDeviceDesc("openipc", //$NON-NLS-1$ 59 | "org.zephyrproject.ide.eclipse.core.debug.jtagdevice.openIPCDevice", //$NON-NLS-1$ 60 | String.format("%s:%d", JTagDeviceDesc.IP_ADDR_LOCALHOST, 8086)), 61 | }; 62 | 63 | @Override 64 | public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { 65 | super.setDefaults(configuration); 66 | 67 | configuration.setAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, 68 | true); 69 | 70 | String device = defaultJtagDevice; 71 | String connection = defaultConnection; 72 | 73 | /* Grab GDB path and runner from CMake */ 74 | try { 75 | IResource[] resources = configuration.getMappedResources(); 76 | if ((resources != null) && (resources.length > 0)) { 77 | IProject project = resources[0].getProject(); 78 | ZephyrApplicationBuildConfiguration appBuildCfg = 79 | ZephyrHelpers.Launch 80 | .getZephyrBuildConfiguration(project); 81 | 82 | IToolChain toolchain = appBuildCfg.getToolChain(); 83 | if (toolchain instanceof ZephyrGCCToolChain) { 84 | ZephyrGCCToolChain zToolChain = 85 | ((ZephyrGCCToolChain) toolchain); 86 | 87 | String gdb = zToolChain.getGdbProgramPath(); 88 | if ((gdb != null) && !gdb.trim().isEmpty()) { 89 | configuration.setAttribute( 90 | IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, 91 | gdb); 92 | } 93 | 94 | /* Setup reasonable defaults for connection */ 95 | String runner = zToolChain.getDebugRunner(); 96 | if (runner != null) { 97 | for (JTagDeviceDesc jtag : jtagDevices) { 98 | if (runner.equals(jtag.id)) { 99 | device = jtag.jtag; 100 | 101 | if (jtag.connection != null) { 102 | connection = jtag.connection; 103 | } else { 104 | connection = defaultConnection; 105 | } 106 | 107 | break; 108 | } 109 | } 110 | 111 | } 112 | } 113 | } 114 | } catch (CoreException e) { 115 | } 116 | 117 | configuration.setAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE_ID, 118 | device); 119 | 120 | String connText; 121 | if (connection != null) { 122 | connText = connection; 123 | } else { 124 | connText = defaultConnection; 125 | } 126 | 127 | /* The ATTR_CONNECTION attribute needs "gdb:" prefix */ 128 | connText = String.format("gdb:%s", connText); 129 | 130 | configuration.setAttribute(IGDBJtagConstants.ATTR_CONNECTION, connText); 131 | } 132 | 133 | } 134 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/launch/ZephyrApplicationEmulatorDebugLaunchConfigurationTabGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.launch; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | import org.eclipse.debug.core.ILaunchManager; 13 | import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; 14 | import org.eclipse.debug.ui.CommonTab; 15 | import org.eclipse.debug.ui.ILaunchConfigurationDialog; 16 | import org.eclipse.debug.ui.ILaunchConfigurationTab; 17 | import org.eclipse.debug.ui.sourcelookup.SourceLookupTab; 18 | import org.zephyrproject.ide.eclipse.ui.launch.tabs.EmulatorDebugLaunchDebuggerTab; 19 | import org.zephyrproject.ide.eclipse.ui.launch.tabs.EmulatorDebugLaunchMainTab; 20 | import org.zephyrproject.ide.eclipse.ui.launch.tabs.CommonDebugLaunchStartupTab; 21 | 22 | public class ZephyrApplicationEmulatorDebugLaunchConfigurationTabGroup 23 | extends AbstractLaunchConfigurationTabGroup { 24 | 25 | public ZephyrApplicationEmulatorDebugLaunchConfigurationTabGroup() { 26 | super(); 27 | } 28 | 29 | @Override 30 | public void createTabs(ILaunchConfigurationDialog dialog, String mode) { 31 | List tabs = new ArrayList<>(); 32 | 33 | if (mode.equals(ILaunchManager.DEBUG_MODE)) { 34 | tabs.add(new EmulatorDebugLaunchMainTab()); 35 | tabs.add(new EmulatorDebugLaunchDebuggerTab()); 36 | tabs.add(new CommonDebugLaunchStartupTab()); 37 | tabs.add(new SourceLookupTab()); 38 | tabs.add(new CommonTab()); 39 | } 40 | 41 | setTabs(tabs.toArray(new ILaunchConfigurationTab[0])); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/launch/ZephyrApplicationEmulatorRunLaunchConfigurationTabGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.launch; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | import org.eclipse.debug.core.ILaunchManager; 13 | import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; 14 | import org.eclipse.debug.ui.ILaunchConfigurationDialog; 15 | import org.eclipse.debug.ui.ILaunchConfigurationTab; 16 | import org.zephyrproject.ide.eclipse.ui.launch.tabs.EmulatorRunLaunchMainTab; 17 | 18 | public class ZephyrApplicationEmulatorRunLaunchConfigurationTabGroup 19 | extends AbstractLaunchConfigurationTabGroup { 20 | 21 | public ZephyrApplicationEmulatorRunLaunchConfigurationTabGroup() { 22 | super(); 23 | } 24 | 25 | @Override 26 | public void createTabs(ILaunchConfigurationDialog dialog, String mode) { 27 | List tabs = new ArrayList<>(); 28 | 29 | if (mode.equals(ILaunchManager.RUN_MODE)) { 30 | tabs.add(new EmulatorRunLaunchMainTab()); 31 | } 32 | 33 | setTabs(tabs.toArray(new ILaunchConfigurationTab[0])); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/launch/ZephyrApplicationHardwareDebugLaunchConfigurationTabGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.launch; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | import org.eclipse.debug.core.ILaunchManager; 13 | import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; 14 | import org.eclipse.debug.ui.CommonTab; 15 | import org.eclipse.debug.ui.ILaunchConfigurationDialog; 16 | import org.eclipse.debug.ui.ILaunchConfigurationTab; 17 | import org.eclipse.debug.ui.sourcelookup.SourceLookupTab; 18 | import org.zephyrproject.ide.eclipse.ui.launch.tabs.CommonDebugLaunchStartupTab; 19 | import org.zephyrproject.ide.eclipse.ui.launch.tabs.HardwareDebugLaunchDebuggerTab; 20 | import org.zephyrproject.ide.eclipse.ui.launch.tabs.HardwareDebugLaunchMainTab; 21 | 22 | public class ZephyrApplicationHardwareDebugLaunchConfigurationTabGroup 23 | extends AbstractLaunchConfigurationTabGroup { 24 | 25 | public ZephyrApplicationHardwareDebugLaunchConfigurationTabGroup() { 26 | super(); 27 | } 28 | 29 | @Override 30 | public void createTabs(ILaunchConfigurationDialog dialog, String mode) { 31 | List tabs = new ArrayList<>(); 32 | 33 | if (mode.equals(ILaunchManager.DEBUG_MODE)) { 34 | tabs.add(new HardwareDebugLaunchMainTab()); 35 | tabs.add(new HardwareDebugLaunchDebuggerTab()); 36 | tabs.add(new CommonDebugLaunchStartupTab()); 37 | tabs.add(new SourceLookupTab()); 38 | tabs.add(new CommonTab()); 39 | } 40 | 41 | setTabs(tabs.toArray(new ILaunchConfigurationTab[0])); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/launch/ZephyrApplicationHardwareRunLaunchConfigurationTabGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.launch; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | import org.eclipse.debug.core.ILaunchManager; 13 | import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; 14 | import org.eclipse.debug.ui.ILaunchConfigurationDialog; 15 | import org.eclipse.debug.ui.ILaunchConfigurationTab; 16 | import org.zephyrproject.ide.eclipse.ui.launch.tabs.HardwareRunLaunchMainTab; 17 | 18 | public class ZephyrApplicationHardwareRunLaunchConfigurationTabGroup 19 | extends AbstractLaunchConfigurationTabGroup { 20 | 21 | public ZephyrApplicationHardwareRunLaunchConfigurationTabGroup() { 22 | super(); 23 | } 24 | 25 | @Override 26 | public void createTabs(ILaunchConfigurationDialog dialog, String mode) { 27 | List tabs = new ArrayList<>(); 28 | 29 | if (mode.equals(ILaunchManager.RUN_MODE)) { 30 | tabs.add(new HardwareRunLaunchMainTab()); 31 | } 32 | 33 | setTabs(tabs.toArray(new ILaunchConfigurationTab[0])); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/launch/tabs/CommonDebugLaunchStartupTab.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.launch.tabs; 8 | 9 | import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants; 10 | import org.eclipse.cdt.debug.gdbjtag.ui.GDBJtagStartupTab; 11 | import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 12 | 13 | public class CommonDebugLaunchStartupTab extends GDBJtagStartupTab { 14 | 15 | @Override 16 | public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { 17 | super.setDefaults(configuration); 18 | 19 | configuration.setAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, false); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/launch/tabs/EmulatorDebugLaunchDebuggerTab.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.launch.tabs; 8 | 9 | import org.zephyrproject.ide.eclipse.ui.internal.debug.JTagDeviceDesc; 10 | import org.zephyrproject.ide.eclipse.ui.internal.launch.tabs.CommonDebugLaunchDebuggerTab; 11 | 12 | public class EmulatorDebugLaunchDebuggerTab 13 | extends CommonDebugLaunchDebuggerTab { 14 | 15 | public EmulatorDebugLaunchDebuggerTab() { 16 | super(); 17 | 18 | /* 19 | * Some QEMU boards do not have runner 'qemu' set. So set QEMU as 20 | * default here. 21 | */ 22 | super.defaultJtagDevice = 23 | "org.zephyrproject.ide.eclipse.core.debug.jtagdevice.qemuDevice"; //$NON-NLS-1$ 24 | super.defaultConnection = 25 | String.format("%s:%d", JTagDeviceDesc.IP_ADDR_LOCALHOST, 1234); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/launch/tabs/HardwareDebugLaunchDebuggerTab.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.launch.tabs; 8 | 9 | import org.zephyrproject.ide.eclipse.ui.internal.debug.JTagDeviceDesc; 10 | import org.zephyrproject.ide.eclipse.ui.internal.launch.tabs.CommonDebugLaunchDebuggerTab; 11 | 12 | public class HardwareDebugLaunchDebuggerTab 13 | extends CommonDebugLaunchDebuggerTab { 14 | 15 | public HardwareDebugLaunchDebuggerTab() { 16 | super(); 17 | 18 | /* Most boards use OpenOCD or pyOCD, so set it as default */ 19 | super.defaultJtagDevice = 20 | "org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.OpenOCDSocket"; //$NON-NLS-1$ 21 | super.defaultConnection = 22 | String.format("%s:%d", JTagDeviceDesc.IP_ADDR_LOCALHOST, 3333); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/launchbar/ZephyrApplicationLaunchBarConfigurationLabelProvider.java: -------------------------------------------------------------------------------- 1 | package org.zephyrproject.ide.eclipse.ui.launchbar; 2 | 3 | import org.eclipse.jface.viewers.LabelProvider; 4 | import org.eclipse.launchbar.core.ILaunchDescriptor; 5 | import org.eclipse.swt.graphics.Image; 6 | import org.zephyrproject.ide.eclipse.core.ZephyrPlugin; 7 | import org.zephyrproject.ide.eclipse.ui.ZephyrUIPlugin; 8 | 9 | public class ZephyrApplicationLaunchBarConfigurationLabelProvider 10 | extends LabelProvider { 11 | 12 | @Override 13 | public Image getImage(Object element) { 14 | return ZephyrPlugin.getDefault().getImageRegistry() 15 | .get(ZephyrUIPlugin.IMG_ZEPHYR_KITE16); 16 | } 17 | 18 | @Override 19 | public String getText(Object element) { 20 | if (element instanceof ILaunchDescriptor) { 21 | return ((ILaunchDescriptor) element).getName(); 22 | } 23 | return super.getText(element); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/launchbar/ZephyrApplicationLaunchBarTargetLabelProvider.java: -------------------------------------------------------------------------------- 1 | package org.zephyrproject.ide.eclipse.ui.launchbar; 2 | 3 | import org.eclipse.jface.viewers.LabelProvider; 4 | import org.eclipse.launchbar.core.target.ILaunchTarget; 5 | import org.eclipse.swt.graphics.Image; 6 | import org.zephyrproject.ide.eclipse.core.ZephyrPlugin; 7 | import org.zephyrproject.ide.eclipse.ui.ZephyrUIPlugin; 8 | 9 | public class ZephyrApplicationLaunchBarTargetLabelProvider 10 | extends LabelProvider { 11 | 12 | @Override 13 | public Image getImage(Object element) { 14 | return ZephyrPlugin.getDefault().getImageRegistry() 15 | .get(ZephyrUIPlugin.IMG_ZEPHYR_KITE16); 16 | } 17 | 18 | @Override 19 | public String getText(Object element) { 20 | if (element instanceof ILaunchTarget) { 21 | return ((ILaunchTarget) element).getId(); 22 | } 23 | return super.getText(element); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/preferences/ZephyrPreferenceToolchainPage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.preferences; 8 | 9 | import org.eclipse.jface.preference.DirectoryFieldEditor; 10 | import org.eclipse.jface.preference.FieldEditorPreferencePage; 11 | import org.eclipse.jface.preference.StringFieldEditor; 12 | import org.eclipse.ui.IWorkbench; 13 | import org.eclipse.ui.IWorkbenchPreferencePage; 14 | import org.zephyrproject.ide.eclipse.core.ZephyrPlugin; 15 | import org.zephyrproject.ide.eclipse.core.preferences.ZephyrPreferenceConstants; 16 | 17 | /** 18 | * Preference page for toolchain defaults. 19 | */ 20 | public class ZephyrPreferenceToolchainPage extends FieldEditorPreferencePage 21 | implements IWorkbenchPreferencePage { 22 | 23 | public ZephyrPreferenceToolchainPage() { 24 | super(GRID); 25 | setPreferenceStore(ZephyrPlugin.getDefault().getPreferenceStore()); 26 | setDescription("Toolchain Defaults for Zephyr"); 27 | } 28 | 29 | /** 30 | * Creates the field editors. Field editors are abstractions of the common 31 | * GUI blocks needed to manipulate various types of preferences. Each field 32 | * editor knows how to save and restore itself. 33 | */ 34 | @Override 35 | public void createFieldEditors() { 36 | /* Official Zephyr SDK Install Directory */ 37 | DirectoryFieldEditor zephyrSDK = new DirectoryFieldEditor( 38 | ZephyrPreferenceConstants.P_ZEPHYR_SDK_INSTALL_DIR, 39 | "Default Zephyr &SDK Install Directory:", 40 | getFieldEditorParent()); 41 | zephyrSDK.setEmptyStringAllowed(true); 42 | addField(zephyrSDK); 43 | 44 | /* GNU ARM EMB Toolchain Path */ 45 | DirectoryFieldEditor gnuArmEmbPath = new DirectoryFieldEditor( 46 | ZephyrPreferenceConstants.P_GNUARMEMB_TOOLCHAIN_PATH, 47 | "Default GNU &ARM EMB Toolchain Path:", getFieldEditorParent()); 48 | gnuArmEmbPath.setEmptyStringAllowed(true); 49 | addField(gnuArmEmbPath); 50 | 51 | /* Crosstool-NG Toolchains Path */ 52 | DirectoryFieldEditor xtoolsPath = new DirectoryFieldEditor( 53 | ZephyrPreferenceConstants.P_XTOOLS_TOOLCHAIN_PATH, 54 | "Default Crosstool-&NG Toolchains Path:", 55 | getFieldEditorParent()); 56 | xtoolsPath.setEmptyStringAllowed(true); 57 | addField(xtoolsPath); 58 | 59 | /* Cross compile prefix */ 60 | StringFieldEditor crossCompilePrefix = new StringFieldEditor( 61 | ZephyrPreferenceConstants.P_CROSS_COMPILE_PREFIX, 62 | "Default &Cross Compile Prefix:", getFieldEditorParent()); 63 | crossCompilePrefix.setEmptyStringAllowed(true); 64 | addField(crossCompilePrefix); 65 | } 66 | 67 | /* 68 | * (non-Javadoc) 69 | * 70 | * @see 71 | * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) 72 | */ 73 | @Override 74 | public void init(IWorkbench workbench) { 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/preferences/ZephyrPreferenceTopPage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.preferences; 8 | 9 | import org.eclipse.jface.preference.FieldEditorPreferencePage; 10 | import org.eclipse.ui.IWorkbench; 11 | import org.eclipse.ui.IWorkbenchPreferencePage; 12 | import org.zephyrproject.ide.eclipse.core.ZephyrPlugin; 13 | import org.zephyrproject.ide.eclipse.core.ZephyrStrings; 14 | import org.zephyrproject.ide.eclipse.core.preferences.ZephyrPreferenceConstants; 15 | import org.zephyrproject.ide.eclipse.ui.preferences.internal.ZephyrBaseLocationDirectoryFieldEditor; 16 | 17 | /** 18 | * Preference page for Zephyr to define various defaults. 19 | */ 20 | public class ZephyrPreferenceTopPage extends FieldEditorPreferencePage 21 | implements IWorkbenchPreferencePage { 22 | 23 | public ZephyrPreferenceTopPage() { 24 | super(GRID); 25 | setPreferenceStore(ZephyrPlugin.getDefault().getPreferenceStore()); 26 | setDescription(ZephyrStrings.EMPTY_STRING); 27 | } 28 | 29 | /** 30 | * Creates the field editors. Field editors are abstractions of the common 31 | * GUI blocks needed to manipulate various types of preferences. Each field 32 | * editor knows how to save and restore itself. 33 | */ 34 | @Override 35 | public void createFieldEditors() { 36 | addField(new ZephyrBaseLocationDirectoryFieldEditor( 37 | ZephyrPreferenceConstants.P_ZEPHYR_BASE, 38 | "Default &Zephyr Base:", getFieldEditorParent())); 39 | } 40 | 41 | /* 42 | * (non-Javadoc) 43 | * 44 | * @see 45 | * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) 46 | */ 47 | @Override 48 | public void init(IWorkbench workbench) { 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/preferences/internal/ZephyrBaseLocationDirectoryFieldEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.preferences.internal; 8 | 9 | import org.eclipse.jface.preference.DirectoryFieldEditor; 10 | import org.eclipse.swt.widgets.Composite; 11 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 12 | import org.zephyrproject.ide.eclipse.core.preferences.ZephyrProjectPreferences.ZephyrBase; 13 | 14 | /** 15 | * Directory field editor for specifying Zephyr Base as preference. 16 | * 17 | * This extends {@code DirectoryFieldEditor} so it can check for a valid 18 | * Zephyr Base directory. 19 | */ 20 | public class ZephyrBaseLocationDirectoryFieldEditor 21 | extends DirectoryFieldEditor { 22 | 23 | public ZephyrBaseLocationDirectoryFieldEditor(String name, String labelText, 24 | Composite parent) { 25 | super(name, labelText, parent); 26 | setErrorMessage("Not a valid " + ZephyrBase.DIRECTORY_DESCRIPTION); 27 | } 28 | 29 | /** 30 | * Check if the specified directory is a valid Zephyr Base directory. 31 | * 32 | * Note that this allows an empty string in the field editor so that 33 | * there is simply no default directory to be used for project creation. 34 | * 35 | * @return True if the directory is valid, false otherwise. 36 | * 37 | * @see org.eclipse.jface.preference.DirectoryFieldEditor#doCheckState() 38 | */ 39 | @Override 40 | protected boolean doCheckState() { 41 | if (!super.doCheckState()) { 42 | return false; 43 | } 44 | 45 | String path = getStringValue(); 46 | if (path == null) { 47 | return false; 48 | } 49 | if (!path.isEmpty() && !ZephyrHelpers.checkValidZephyrBase(path)) { 50 | /* Empty string is allowed */ 51 | return false; 52 | } 53 | 54 | return true; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/property/ZephyrApplicationTopPropertyPage.java: -------------------------------------------------------------------------------- 1 | package org.zephyrproject.ide.eclipse.ui.property; 2 | 3 | import java.io.IOException; 4 | 5 | import org.eclipse.core.resources.IProject; 6 | import org.eclipse.jface.dialogs.IDialogConstants; 7 | import org.eclipse.swt.SWT; 8 | import org.eclipse.swt.events.ModifyEvent; 9 | import org.eclipse.swt.events.ModifyListener; 10 | import org.eclipse.swt.layout.GridData; 11 | import org.eclipse.swt.layout.GridLayout; 12 | import org.eclipse.swt.widgets.Composite; 13 | import org.eclipse.swt.widgets.Control; 14 | import org.eclipse.swt.widgets.Label; 15 | import org.eclipse.swt.widgets.Text; 16 | import org.eclipse.ui.IWorkbenchPropertyPage; 17 | import org.eclipse.ui.dialogs.PropertyPage; 18 | import org.eclipse.ui.preferences.ScopedPreferenceStore; 19 | import org.zephyrproject.ide.eclipse.core.internal.ZephyrHelpers; 20 | import org.zephyrproject.ide.eclipse.core.preferences.ZephyrProjectPreferences; 21 | 22 | public class ZephyrApplicationTopPropertyPage extends PropertyPage 23 | implements IWorkbenchPropertyPage { 24 | 25 | private Text boardNameText; 26 | 27 | public ZephyrApplicationTopPropertyPage() { 28 | } 29 | 30 | @Override 31 | protected Control createContents(Composite parent) { 32 | IProject project = getElement().getAdapter(IProject.class); 33 | 34 | noDefaultButton(); 35 | 36 | GridData gridData; 37 | Composite composite = new Composite(parent, SWT.NONE); 38 | 39 | /* Create a grid with 2 columns */ 40 | composite.setLayout(new GridLayout(2, false)); 41 | composite.setLayoutData(new GridData(GridData.FILL_BOTH)); 42 | 43 | /* Show board name */ 44 | Label boardNameLabel = new Label(composite, SWT.NONE); 45 | gridData = new GridData(); 46 | boardNameLabel.setLayoutData(gridData); 47 | boardNameLabel.setText("Board Name:"); //$NON-NLS-1$ 48 | 49 | /* Input field for board name */ 50 | boardNameText = new Text(composite, SWT.BORDER); 51 | gridData = new GridData(GridData.FILL_HORIZONTAL); 52 | gridData.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; 53 | boardNameText.setLayoutData(gridData); 54 | boardNameText.setFont(parent.getFont()); 55 | boardNameText.setText(ZephyrHelpers.getBoardName(project)); 56 | boardNameText.addModifyListener(new ModifyListener() { 57 | @Override 58 | public void modifyText(ModifyEvent e) { 59 | updateApplyButton(); 60 | } 61 | }); 62 | 63 | return composite; 64 | } 65 | 66 | @Override 67 | public boolean isValid() { 68 | boolean valid = true; 69 | 70 | if (boardNameText.getText().trim().isEmpty()) { 71 | valid = false; 72 | setErrorMessage("Board name must be specified"); //$NON-NLS-1$ 73 | } 74 | 75 | if (valid) { 76 | setErrorMessage(null); 77 | } 78 | 79 | return valid; 80 | } 81 | 82 | @Override 83 | protected void performApply() { 84 | 85 | IProject project = getElement().getAdapter(IProject.class); 86 | ScopedPreferenceStore pStore = 87 | ZephyrHelpers.getProjectPreferenceStore(project); 88 | 89 | pStore.setValue(ZephyrProjectPreferences.BOARD, 90 | boardNameText.getText()); 91 | 92 | try { 93 | pStore.save(); 94 | } catch (IOException e) { 95 | e.printStackTrace(); 96 | } 97 | } 98 | 99 | @Override 100 | public boolean performOk() { 101 | performApply(); 102 | return true; 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/wizards/ZephyrApplicationEmptyProjectWizard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.wizards; 8 | 9 | import org.zephyrproject.ide.eclipse.ui.wizards.internal.ZephyrApplicationAbstractProjectWizard; 10 | 11 | public class ZephyrApplicationEmptyProjectWizard 12 | extends ZephyrApplicationAbstractProjectWizard { 13 | 14 | public ZephyrApplicationEmptyProjectWizard() { 15 | super(null); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /plugins/org.zephyrproject.ide.eclipse.ui/src/org/zephyrproject/ide/eclipse/ui/wizards/ZephyrApplicationNewProjectWizard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: EPL-2.0 5 | */ 6 | 7 | package org.zephyrproject.ide.eclipse.ui.wizards; 8 | 9 | import org.zephyrproject.ide.eclipse.ui.wizards.internal.ZephyrApplicationAbstractProjectWizard; 10 | 11 | public class ZephyrApplicationNewProjectWizard 12 | extends ZephyrApplicationAbstractProjectWizard { 13 | 14 | public ZephyrApplicationNewProjectWizard() { 15 | super("templates/ZephyrApplication/template.xml"); //$NON-NLS-1$ 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | 7 | org.zephyrproject 8 | org.zephyrproject.ide.eclipse.parent 9 | 0.2.99-SNAPSHOT 10 | maven/parent 11 | 12 | 13 | org.zephyrproject.ide.eclipse.root 14 | pom 15 | 16 | Zephyr Project Eclipse Plugin root 17 | https://www.zephyrproject.org/ 18 | 19 | 20 | Zephyr Project 21 | https://www.zephyrproject.org/ 22 | 23 | 24 | 25 | plugins/org.zephyrproject.ide.eclipse.core 26 | plugins/org.zephyrproject.ide.eclipse.core.linux 27 | plugins/org.zephyrproject.ide.eclipse.core.java11 28 | plugins/org.zephyrproject.ide.eclipse.core.macosx 29 | plugins/org.zephyrproject.ide.eclipse.core.win32 30 | plugins/org.zephyrproject.ide.eclipse.ui 31 | features/org.zephyrproject.ide.eclipse-feature 32 | maven/repository 33 | 34 | 35 | 36 | --------------------------------------------------------------------------------