├── .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