The cache entries specified here will be passed to cmake on the command-line for each project in the workbench
9 | that gets build with cmake4eclipse.
10 |
10 | The Symbols tab allows to let cmake create and remove entries in its cache during build-script generation.
11 | Each entry defined on the Symbols tab is passed as a
12 | -D
13 | command-line option (or -U resp.) to cmake.
14 |
15 |
16 |
--------------------------------------------------------------------------------
/releng/targetplatform/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | de.marw.cmake4eclipse
7 | parent
8 | 1.1.0
9 | ../..
10 |
11 |
12 | targetplatform
13 | 1.0.1
14 | eclipse-target-definition
15 |
16 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/package-info.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | /**
11 | * Classes for the cmake4eclipse MBS UI.
12 | *
13 | * @author Martin Weber
14 | */
15 | package de.marw.cmake4eclipse.mbs.ui;
16 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/slim/package-info.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | /**
11 | * Classes for the simplified MBS UI.
12 | *
13 | * @author Martin Weber
14 | */
15 | package de.marw.cmake4eclipse.mbs.ui.slim;
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/about.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | About
6 |
7 |
8 |
9 |
About This Content
10 |
11 |
July 24, 2021
12 |
License
13 |
14 | Unless otherwise indicated below, the Content is provided to you under the
15 | terms and conditions of the Eclipse Public License Version 2.0 ("EPL").
16 | A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
17 | For purposes of the EPL, "Program" will mean the Content.
18 |
14 | Unless otherwise indicated below, the Content is provided to you under the
15 | terms and conditions of the Eclipse Public License Version 2.0 ("EPL").
16 | A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
17 | For purposes of the EPL, "Program" will mean the Content.
18 |
19 |
20 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/navigator/package-info.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | /**
11 | * Tree content provider for the project explorer view.
12 | *
13 | * @author Martin Weber
14 | */
15 | package de.marw.cmake4eclipse.mbs.ui.navigator;
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | de.marw.cmake4eclipse.mbs
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 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | de.marw.cmake4eclipse.mbs.ui
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.pde.ManifestBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.pde.SchemaBuilder
20 |
21 |
22 |
23 |
24 |
25 | org.eclipse.pde.PluginNature
26 | org.eclipse.jdt.core.javanature
27 |
28 |
29 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/cmakecache/package-info.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | @org.eclipse.jdt.annotation.NonNullByDefault({ DefaultLocation.PARAMETER, DefaultLocation.RETURN_TYPE,
11 | DefaultLocation.TYPE_BOUND, DefaultLocation.TYPE_ARGUMENT })
12 | package de.marw.cmake4eclipse.mbs.cmakecache;
13 |
14 | import org.eclipse.jdt.annotation.DefaultLocation;
15 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/internal/package-info.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | @org.eclipse.jdt.annotation.NonNullByDefault({ DefaultLocation.PARAMETER, DefaultLocation.RETURN_TYPE,
11 | DefaultLocation.TYPE_BOUND, DefaultLocation.TYPE_ARGUMENT })
12 | package de.marw.cmake4eclipse.mbs.internal;
13 |
14 | import org.eclipse.jdt.annotation.DefaultLocation;
15 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/preferences/package-info.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | @org.eclipse.jdt.annotation.NonNullByDefault({ DefaultLocation.PARAMETER, DefaultLocation.RETURN_TYPE,
11 | DefaultLocation.TYPE_BOUND, DefaultLocation.TYPE_ARGUMENT })
12 | package de.marw.cmake4eclipse.mbs.preferences;
13 |
14 | import org.eclipse.jdt.annotation.DefaultLocation;
15 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | de.marw.cmake4eclipse
7 | parent
8 | 1.1.0
9 | ../pom.xml
10 |
11 |
12 | de.marw.cmake4eclipse.mbs
13 |
15 | 3.0.2-SNAPSHOT
16 | eclipse-plugin
17 |
18 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/internal/storage/package-info.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | @org.eclipse.jdt.annotation.NonNullByDefault({ DefaultLocation.PARAMETER, DefaultLocation.RETURN_TYPE,
11 | DefaultLocation.TYPE_BOUND, DefaultLocation.TYPE_ARGUMENT })
12 | package de.marw.cmake4eclipse.mbs.internal.storage;
13 |
14 | import org.eclipse.jdt.annotation.DefaultLocation;
15 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | de.marw.cmake4eclipse
7 | parent
8 | 1.1.0
9 | ../pom.xml
10 |
11 |
12 | de.marw.cmake4eclipse.mbs.ui
13 |
15 | 3.1.0-SNAPSHOT
16 | eclipse-plugin
17 |
18 |
--------------------------------------------------------------------------------
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3 |
4 | name: Java CI with Maven
5 |
6 | on:
7 | push:
8 | branches: [ master ]
9 | pull_request:
10 | branches: [ master ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v3
19 |
20 | - name: Set up JDK
21 | uses: actions/setup-java@v3
22 | with:
23 | java-version: '17'
24 | distribution: 'adopt'
25 | cache: 'maven'
26 |
27 | - name: Set up Maven
28 | uses: stCarolas/setup-maven@v4.5
29 | with:
30 | maven-version: 3.9.0
31 |
32 | - name: Build
33 | run: mvn -P release -B -ntp verify
34 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/doc/html/ref/build_configs.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Build Configurations
6 |
7 |
8 |
9 |
Build Configurations
10 |
The build configurations provided by cmake4eclipse map to cmake`s CMAKE_BUILD_TYPE cache variable as following:
11 |
12 |
Debug sets CMAKE_BUILD_TYPE=Debug.
13 |
Release sets CMAKE_BUILD_TYPE=Release.
14 |
Default does not set CMAKE_BUILD_TYPE at all, allowing you to use cmake`s default value.
15 |
16 | Please note that if you specify a value for CMAKE_BUILD_TYPE on the
17 | Symbols tab that value will override the value from the configuration.
18 |
the locations of the tools that actually perform the build and
14 |
optionally the location of the cmake executable that generates the build scripts.
15 |
16 | The locations of the tools is made available through the Eclipse dynamic variable named cmake4eclipse_btk_PATH.
17 | The cmake4eclipse_btk_PATH variable might be useful to specify a different PATH environment variable
18 | in a debugger configuration.
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/slim/Page_CMake.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.ui.slim;
10 |
11 | import org.eclipse.cdt.ui.newui.AbstractPage;
12 |
13 | /**
14 | * Page for CMake project settings in the simplified MBS UI.
15 | *
16 | * @author Martin Weber
17 | */
18 | public class Page_CMake extends AbstractPage {
19 | @Override
20 | protected boolean isSingle() {
21 | return false;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/slim/Page_BuildTop.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.ui.slim;
10 |
11 | import org.eclipse.cdt.ui.newui.AbstractPage;
12 |
13 | /**
14 | * Page for CMake project settings in the simplified MBS UI.
15 | *
16 | * @author Martin Weber
17 | */
18 | public class Page_BuildTop extends AbstractPage {
19 | @Override
20 | protected boolean isSingle() {
21 | return false;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/settings/package-info.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | /**
11 | * Classes and interfaces related to project properties.
12 | */
13 | @org.eclipse.jdt.annotation.NonNullByDefault({ DefaultLocation.PARAMETER, DefaultLocation.RETURN_TYPE,
14 | DefaultLocation.TYPE_BOUND, DefaultLocation.TYPE_ARGUMENT })
15 | package de.marw.cmake4eclipse.mbs.settings;
16 |
17 | import org.eclipse.jdt.annotation.DefaultLocation;
18 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/.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.methodParameters=do not generate
4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6 | org.eclipse.jdt.core.compiler.compliance=17
7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
12 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
13 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
14 | org.eclipse.jdt.core.compiler.release=enabled
15 | org.eclipse.jdt.core.compiler.source=17
16 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/CMakePropertyPage.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2013 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.ui;
10 |
11 | import org.eclipse.cdt.ui.newui.AbstractPage;
12 |
13 | /**
14 | * Page for CMake project settings.
15 | *
16 | * @author Martin Weber
17 | */
18 | public class CMakePropertyPage extends AbstractPage {
19 |
20 | /*-
21 | * @see org.eclipse.cdt.ui.newui.AbstractPage#isSingle()
22 | */
23 | @Override
24 | protected boolean isSingle() {
25 | return false;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/slim/IBuildTargetListener.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.ui.slim;
11 |
12 | /**
13 | * Listens for changes in the list of build targets of a project (add/remove/modify).
14 | *
15 | * @author Martin Weber
16 | */
17 | public interface IBuildTargetListener {
18 | /**
19 | * Notified when a change in the list of build targets of a project (add/remove/modify) happened.
20 | *
21 | * @param event
22 | */
23 | void targetsChanged(BuildTargetEvent event);
24 | }
25 |
--------------------------------------------------------------------------------
/releng/comp-update/compositeContent.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
--------------------------------------------------------------------------------
/releng/comp-update/compositeArtifacts.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/HostOSPropertyPage.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.ui;
10 |
11 | import org.eclipse.cdt.ui.newui.AbstractPage;
12 |
13 | /**
14 | * Page for CMake host OS specific project settings.
15 | *
16 | * @author Martin Weber
17 | * @deprecated obsolete, settings must be specified as workbench preferences now
18 | */
19 | @Deprecated
20 | public class HostOSPropertyPage extends AbstractPage {
21 |
22 | /*-
23 | * @see org.eclipse.cdt.ui.newui.AbstractPage#isSingle()
24 | */
25 | @Override
26 | protected boolean isSingle() {
27 | return false;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/settings/LinuxSettings.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.settings;
10 |
11 |
12 | /**
13 | * Preferences that override/augment the generic properties when running under
14 | * Linux.
15 | *
16 | * @author Martin Weber
17 | */
18 | public class LinuxSettings extends AbstractOsSettings {
19 |
20 | /**
21 | * Creates a new object, initialized with all default values.
22 | */
23 | public LinuxSettings() {
24 | }
25 |
26 | /**
27 | * @return the String "linux".
28 | */
29 | protected String getStorageElementName() {
30 | return "linux";
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/console/CdtConsoleConstants.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.console;
11 |
12 | /**
13 | * Constants for the CBuildConsole extension point id.
14 | *
15 | * @author Martin Weber
16 | */
17 | public interface CdtConsoleConstants {
18 | /** CBuildConsole extension point id for the cmake console */
19 | public static final String CMAKE_CONSOLE_ID = "cmake4eclipse.mbs.cmakeConsole";
20 | /** CBuildConsole extension point id for the compiler-builtins detection console */
21 | public static final String BUILTINS_DETECTION_CONSOLE_ID = "cmake4eclipse.mbs.builtinsConsole";
22 | }
23 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/settings/BuildTarget.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.settings;
11 |
12 | import java.util.Objects;
13 |
14 | /**
15 | * Represents a build target owned by a project with {@code C4ENature}.
16 | *
17 | * @author Martin Weber
18 | */
19 | public class BuildTarget {
20 |
21 | private String name;
22 |
23 | public BuildTarget(String name) {
24 | this.name = Objects.requireNonNull(name, "name");
25 | }
26 |
27 | public String getName() {
28 | return name;
29 | }
30 |
31 | @Override
32 | public String toString() {
33 | return "BuildTarget [" + name + "]";
34 | }
35 | }
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/settings/WindowsSettings.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.settings;
10 |
11 | /**
12 | * Preferences that override/augment the generic properties when running under
13 | * Windows.
14 | *
15 | * @author Martin Weber
16 | */
17 | public class WindowsSettings extends AbstractOsSettings {
18 |
19 | /** Overridden to set a sensible generator. */
20 | public void reset() {
21 | super.reset();
22 | setGenerator(CmakeGenerator.MinGWMakefiles);
23 | }
24 |
25 | /**
26 | * @return the String "win32".
27 | */
28 | protected String getStorageElementName() {
29 | return "win32";
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/navigator/EditBuildTargetsActionProvider.java:
--------------------------------------------------------------------------------
1 | package de.marw.cmake4eclipse.mbs.ui.navigator;
2 |
3 | import org.eclipse.jface.action.IMenuManager;
4 | import org.eclipse.jface.viewers.IStructuredSelection;
5 | import org.eclipse.ui.actions.ActionContext;
6 | import org.eclipse.ui.navigator.CommonActionProvider;
7 | import org.eclipse.ui.navigator.ICommonActionExtensionSite;
8 |
9 | public class EditBuildTargetsActionProvider extends CommonActionProvider {
10 |
11 | private EditBuildTargetsAction action;
12 |
13 | @Override
14 | public void init(ICommonActionExtensionSite aSite) {
15 | super.init(aSite);
16 | action = new EditBuildTargetsAction(aSite.getViewSite().getShell());
17 | }
18 |
19 | @Override
20 | public void fillContextMenu(IMenuManager menu) {
21 | menu.add(action);
22 | }
23 |
24 | @Override
25 | public void setContext(ActionContext context) {
26 | super.setContext(context);
27 | if (context != null) {
28 | IStructuredSelection selection = (IStructuredSelection) context.getSelection();
29 | action.selectionChanged(selection);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/slim/Page_SourceFolders.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.ui.slim;
11 |
12 | import org.eclipse.cdt.ui.newui.AbstractPage;
13 |
14 | /**
15 | * Holds the 'Source Location' tab. The only need to create it is distinguishing tabs.
16 | * NOTE: The source location is not the location of the top-level CMakeLists.txt file. It is used by
17 | * the project explorer view in the Includes folder to organize the include dirs.
18 | * See issue #176.
19 | *
20 | * @author Martin Weber
21 | */
22 | public class Page_SourceFolders extends AbstractPage {
23 |
24 | @Override
25 | protected boolean isSingle() {
26 | return true;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/slim/Page_CMakeProjectProperty.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.ui.slim;
10 |
11 | import org.eclipse.cdt.ui.newui.AbstractPage;
12 |
13 | /**
14 | * Page for CMake general project properties in the simplified MBS UI.
15 | *
16 | * @author Martin Weber
17 | */
18 | public class Page_CMakeProjectProperty extends AbstractPage {
19 | public Page_CMakeProjectProperty() {
20 | setDescription("Properties that apply to each configuration.");
21 | }
22 |
23 | @Override
24 | protected boolean isSingle() {
25 | return true; // currently only one tab to show
26 | }
27 |
28 | @Override
29 | protected boolean showsConfig() {
30 | return false;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/preferences/AddBuildToolkitDialog.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2021 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.ui.preferences;
10 |
11 | import org.eclipse.swt.widgets.Shell;
12 |
13 | import de.marw.cmake4eclipse.mbs.preferences.BuildToolKitDefinition;
14 |
15 | /**
16 | * The dialog used to add, duplicate or edit a build tool kit definition.
17 | *
18 | * @author Martin Weber
19 | */
20 | class AddBuildToolkitDialog extends AbstractBuildToolkitDialog {
21 | /**
22 | * Creates the dialog.
23 | *
24 | * @param parentShell
25 | * @param toolkit the build tool kit to edit
26 | */
27 | public AddBuildToolkitDialog(Shell parentShell, BuildToolKitDefinition toolkit) {
28 | super(parentShell, toolkit, "Add CMake Build Tool Kit");
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/preferences/EditBuildToolkitDialog.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2021 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.ui.preferences;
10 |
11 | import org.eclipse.swt.widgets.Shell;
12 |
13 | import de.marw.cmake4eclipse.mbs.preferences.BuildToolKitDefinition;
14 |
15 | /**
16 | * The dialog used to add, duplicate or edit a build tool kit definition.
17 | *
18 | * @author Martin Weber
19 | */
20 | class EditBuildToolkitDialog extends AbstractBuildToolkitDialog {
21 | /**
22 | * Creates the dialog.
23 | *
24 | * @param parentShell
25 | * @param toolkit the build tool kit to edit
26 | */
27 | public EditBuildToolkitDialog(Shell parentShell, BuildToolKitDefinition toolkit) {
28 | super(parentShell, toolkit, "Edit CMake Build Tool Kit");
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/doc/html/ref/wb_general_tab.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | General cmake commandline options
6 |
7 |
8 |
General cmake commandline options
9 |
These preferences specify commandline options for cmake for each project in the workbench
10 | that gets build with cmake4eclipse.
11 |
12 |
The Default build system corresponds to an implied Build Toolkit
13 | that gererates scripts for the specified build-system and finds each of the tools required to build a project
14 | on the executable file search path — as specified in the PATH environment variable.
15 | While it is common on Linux to find each tool through the PATH environment variable, this does not
16 | hold for users of the windows OS. Therefore, these users are given means to
17 | specify the file-system tool-locations of their special needs along with the corresponding build system
18 | and overwrite the Default build system.
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve cmake4eclipse.
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | If you have any question, please **consult the mailing list first** before you raise issues here.
11 |
12 | **Describe the bug**
13 | A clear and concise description of what the bug is.
14 |
15 | **To Reproduce**
16 | Steps to reproduce the behavior:
17 | 1. Go to '...'
18 | 2. Click on '....'
19 | 3. Scroll down to '....'
20 | 4. See error
21 |
22 | **Expected behavior**
23 | A clear and concise description of what you expected to happen.
24 |
25 | **Screenshots**
26 | If applicable, add screenshots to help explain your problem.
27 |
28 | **Useful Information**
29 | - cmake4eclipse version:
30 | - CDT version:
31 | - Which OS do you use:
32 | - Cmake version:
33 |
34 | ***What is in Eclipse's Error Log?***
35 |
38 | Sanitized stack traces:
39 |
40 | **Additional context**
41 | Add any other context about the problem here.
42 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/BuiltinsDetectionConsole.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.ui;
10 |
11 | import org.eclipse.cdt.ui.CUIPlugin;
12 | import org.eclipse.cdt.ui.IBuildConsoleManager;
13 |
14 | import de.marw.cmake4eclipse.mbs.console.CdtConsoleConstants;
15 |
16 | /**
17 | * A console for compiler built-in detection invocations.
18 | *
19 | * @author Martin Weber
20 | */
21 | public class BuiltinsDetectionConsole extends AbstractConsole {
22 |
23 | private static final String CONSOLE_CONTEXT_MENU_ID = "menu." + CdtConsoleConstants.BUILTINS_DETECTION_CONSOLE_ID; //$NON-NLS-1$
24 |
25 | @Override
26 | protected IBuildConsoleManager getConsoleManager() {
27 | return CUIPlugin.getDefault().getConsoleManager("Compiler Built-ins Detection Console", CONSOLE_CONTEXT_MENU_ID);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/CMakeConsole.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2013-2018 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.ui;
10 |
11 | import org.eclipse.cdt.ui.CUIPlugin;
12 | import org.eclipse.cdt.ui.IBuildConsoleManager;
13 |
14 | import de.marw.cmake4eclipse.mbs.console.CdtConsoleConstants;
15 |
16 | /**
17 | * A console for cmake invocations.
18 | *
19 | * @author Martin Weber
20 | */
21 | public class CMakeConsole extends AbstractConsole {
22 |
23 | public static final String CONSOLE_CONTEXT_MENU_ID = "menu." + CdtConsoleConstants.CMAKE_CONSOLE_ID; //$NON-NLS-1$
24 |
25 | @Override
26 | protected IBuildConsoleManager getConsoleManager() {
27 | return CUIPlugin.getDefault().getConsoleManager("CMake Console", CONSOLE_CONTEXT_MENU_ID,
28 | Activator.getDefault().getBundle().getEntry("icons/CMakeLogo.gif"));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/navigator/NavBuildTarget.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.ui.navigator;
11 |
12 | import java.util.Objects;
13 |
14 | import de.marw.cmake4eclipse.mbs.settings.BuildTarget;
15 |
16 | /**
17 | * Represents a build target owned by a project with {@code C4ENature} in the project explorer view.
18 | *
19 | * @author Martin Weber
20 | */
21 | class NavBuildTarget extends BuildTarget {
22 |
23 | private final BuildTargetsContainer container;
24 | /**
25 | * @param container
26 | * @param name
27 | */
28 | NavBuildTarget(BuildTargetsContainer container, String name) {
29 | super(name);
30 | this.container = Objects.requireNonNull(container, "container");
31 | }
32 |
33 | BuildTargetsContainer getContainer() {
34 | return container;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/doc/help_contexts.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | This tab is used to specify which CMake cache entries are passed to cmake.
5 |
6 |
7 |
8 | This tab is used to specify general options which are passed to cmake.
9 |
10 |
11 | This tab is used to set preferences for how and when cmake is run.
12 |
13 |
14 |
15 | This page is used to set preferences for specifying CMake cache entries.
16 |
17 |
18 |
19 | This preference page is used to add, remove, edit or activate Cmake4eclipse build toolkits.
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/doc/html/ref/languageSettingsProviders.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Available Language Settings Providers
6 |
14 |
15 |
16 |
Preprocessor Include Paths, Macros
17 |
Include paths and preprocessor macros for the CDT source code indexer are supplied by
18 | Language Settings Providers using the
19 | Scanner Discovery
20 | mechanism. The C/C++/CUDA editors use the indexer to improve syntax highlighting, allowing you to jump to
21 | macro definitions and to browse through include files.
22 |
This is a provider which is based on the JSON compilation database parsers that were introduced in
29 | CDT 10.4 (2021-09). The documentation can be found in the
30 |
31 | JSON Compilation Database Parser User Guide.
32 |
First of all: Do not try to manually generate an Eclipse project using cmake -G Eclipse CDT4 - Unix Makefiles
13 | and import it, as that will make cmake4eclipse unavailable in your project!
14 |
15 |
As a first start, you may want to try one of the
16 | example projects.
17 |
18 |
As of cmake4eclipse version 4, the plugin comes with a project creation wizard of its own.
19 | Create a Cmake4eclipse Managed Build project.
20 |
21 |
A Cmake4eclipse Managed Build project is essentially the same as a Managed Build project. Since cmake4eclipse
22 | takes the user`s CMakeLists.txt files as the source of truth — in contrast to Managed Build
23 | which uses the data entered in lots of project property pages — a Cmake4eclipse Managed Build project
24 | does only display the project property pages and tabs that effect cmake`s buildscript generation; in the hope of
25 | reducing end user`s confusion.
26 |
27 |
28 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/Activator.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2021 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.ui;
10 |
11 | import org.eclipse.ui.plugin.AbstractUIPlugin;
12 | import org.osgi.framework.BundleContext;
13 |
14 | /**
15 | * @author Martin Weber
16 | */
17 | public class Activator extends AbstractUIPlugin {
18 |
19 | public static final String PLUGIN_ID = "de.marw.cmake4eclipse.mbs.ui"; //$NON-NLS-1$
20 |
21 | // The shared instance.
22 | private static Activator plugin;
23 |
24 | /**
25 | * This method is called upon plug-in activation
26 | */
27 | @Override
28 | public void start(BundleContext context) throws Exception {
29 | plugin = this;
30 | super.start(context);
31 | }
32 |
33 | /**
34 | * This method is called when the plug-in is stopped
35 | */
36 | @Override
37 | public void stop(BundleContext context) throws Exception {
38 | super.stop(context);
39 | plugin = null;
40 | }
41 |
42 | /**
43 | * Returns the shared instance.
44 | */
45 | public static Activator getDefault() {
46 | return plugin;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/internal/storage/BuildTargetSerializer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.internal.storage;
11 |
12 | import org.eclipse.cdt.core.settings.model.ICStorageElement;
13 |
14 | /**
15 | * Responsible for serialization/de-serialization of build target objects. Each build target is represented as a String.
16 | *
17 | * @author Martin Weber
18 | */
19 | public class BuildTargetSerializer implements StorageSerializer {
20 | private static final String ELEM_TARGET = "target";
21 | private static final String ATTR_NAME = "name";
22 |
23 | @Override
24 | public void toStorage(ICStorageElement parent, String buildTarget) {
25 | ICStorageElement elem = parent.createChild(ELEM_TARGET);
26 | elem.setAttribute(ATTR_NAME, buildTarget);
27 | }
28 |
29 | @Override
30 | public String fromStorage(ICStorageElement item) {
31 | if (!ELEM_TARGET.equals(item.getName()))
32 | return null; // item is not an element representing a build target
33 | String nameVal = item.getAttribute(ATTR_NAME);
34 | return nameVal;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/internal/PreferenceInitializer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2021 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.internal;
10 |
11 | import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
12 | import org.eclipse.core.runtime.preferences.DefaultScope;
13 | import org.eclipse.core.runtime.preferences.IEclipsePreferences;
14 |
15 | import de.marw.cmake4eclipse.mbs.preferences.PreferenceAccess;
16 | import de.marw.cmake4eclipse.mbs.settings.CmakeGenerator;
17 |
18 | /**
19 | * Class used to initialize default workbench preference values.
20 | */
21 | public class PreferenceInitializer extends AbstractPreferenceInitializer {
22 | @Override
23 | public void initializeDefaultPreferences() {
24 | IEclipsePreferences preferences = DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID);
25 | preferences.put(PreferenceAccess.CMAKE_GENERATOR, CmakeGenerator.Ninja.name());
26 | // "[]" is the JSON equivalent of an empty list. set here to avoid to store the empty list in the preferences store
27 | final String empty = "[]";
28 | preferences.put(PreferenceAccess.CMAKE_CACHE_ENTRIES, empty);
29 | preferences.put(PreferenceAccess.TOOLKITS, empty);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/settings/CmakeVariableType.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.settings;
10 |
11 | /**
12 | * The type identifier of a cmake variable.
13 | *
14 | * @author Martin Weber
15 | */
16 | public enum CmakeVariableType {
17 | /** Boolean ON/OFF checkbox */
18 | BOOL {
19 | @Override
20 | public String getCmakeArg() {
21 | return "BOOL";
22 | }
23 | },
24 | /** File chooser dialog */
25 | FILEPATH {
26 | @Override
27 | public String getCmakeArg() {
28 | return "FILEPATH";
29 | }
30 | },
31 | /** Directory chooser dialog */
32 | PATH {
33 | @Override
34 | public String getCmakeArg() {
35 | return "PATH";
36 | }
37 | },
38 | /** Arbitrary string */
39 | STRING {
40 | @Override
41 | public String getCmakeArg() {
42 | return "STRING";
43 | }
44 | },
45 | /** No GUI entry (used for persistent variables) */
46 | INTERNAL {
47 | @Override
48 | public String getCmakeArg() {
49 | return "INTERNAL";
50 | }
51 | };
52 |
53 | /**
54 | * Gets the type as a valid commandline argument for cmake.
55 | */
56 | public abstract String getCmakeArg();
57 | }
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/internal/storage/StorageSerializer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.internal.storage;
10 |
11 | import org.eclipse.cdt.core.settings.model.ICStorageElement;
12 |
13 | /**
14 | * Responsible for serialization/de-serialization of objects to/from
15 | * {@link ICStorageElement}s.
16 | *
17 | * @author Martin Weber
18 | * @param
19 | * the type of the object to serialize/de-serialize
20 | */
21 | public interface StorageSerializer {
22 | /**
23 | * Converts a {@code T} object to an {@link ICStorageElement}.
24 | *
25 | * @param parent
26 | * the parent storage lement, must not be {@code null}.
27 | * @param item
28 | * the object to convert, must not be {@code null}.
29 | */
30 | void toStorage(ICStorageElement parent, T item);
31 |
32 | /**
33 | * Converts an {@link ICStorageElement} to a {@code T} object.
34 | *
35 | * @param item
36 | * the storage element for the object to read, must not be {@code null}
37 | * .
38 | * @return the object, or {@code null} if the storage element could not be
39 | * converted.
40 | */
41 | T fromStorage(ICStorageElement item);
42 | }
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/doc/html/tasks/configure_project_mbs.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Configuring an existing Eclipse C/C++-project
6 |
8 |
9 |
10 |
11 |
Configuring an existing Eclipse C/C++-project
12 |
13 | Cmake4eclipse requires an existing CDT C/C++ project to work with.
14 | It does not work with Eclipse projects generated
15 | by the cmake -G Eclipse CDT4 - Unix Makefiles command.
16 |
17 |
18 |
19 | To configure an existing Eclipse C/C++ project, check the following project properties:
20 |
Select the C/C++ General ➢ Preprocessor Include Path. Macros etc node and the
26 | Providers
27 | tab and make sure the CMake Compilation DB provider is checked. You may safely uncheck any other provider here.
28 |
29 |
Build the project. This will first invoke cmake to generate the build scripts and then pass control to CDT to run the generated scripts.
30 | You will find the full build output in the CDT Global Build Console of the Console View.
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/slim/BuildTargetEvent.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.ui.slim;
11 |
12 | import java.util.Collections;
13 | import java.util.List;
14 | import java.util.Objects;
15 |
16 | import org.eclipse.core.resources.IProject;
17 |
18 | /**
19 | * Represents a change in the list of build targets of a project (add/remove/modify).
20 | *
21 | * @author Martin Weber
22 | */
23 | public class BuildTargetEvent {
24 |
25 | private final IProject project;
26 | private final List targets;
27 |
28 | /**
29 | * @param project
30 | * the project associated to the build targets
31 | * @param targets
32 | * he new build targets
33 | */
34 | BuildTargetEvent(IProject project, List targets) {
35 | this.project = Objects.requireNonNull(project);
36 | this.targets = Collections.unmodifiableList( Objects.requireNonNull(targets));
37 | }
38 |
39 | /**
40 | * Gets the project associated to the build targets.
41 | */
42 | public IProject getProject() {
43 | return project;
44 | }
45 |
46 | /**
47 | * Gets the new build targets.
48 | */
49 | public List getTargets() {
50 | return targets;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: %bundleName
4 | Bundle-Description: CDT CMake build integration
5 | Bundle-Copyright: 2013 Martin Weber
6 | Bundle-SymbolicName: de.marw.cmake4eclipse.mbs;singleton:=true
7 | Bundle-Version: 3.0.2.qualifier
8 | Bundle-Vendor: Martin Weber
9 | Bundle-Localization: plugin
10 | Bundle-RequiredExecutionEnvironment: JavaSE-17
11 | Bundle-ActivationPolicy: lazy
12 | Import-Package: com.google.gson;version="2.8.7",
13 | com.google.gson.reflect;version="2.8.7",
14 | org.eclipse.cdt.docker.launcher;resolution:=optional,
15 | org.eclipse.core.resources,
16 | org.eclipse.core.runtime,
17 | org.eclipse.core.runtime.jobs,
18 | org.eclipse.core.runtime.preferences;version="3.4.0",
19 | org.eclipse.e4.core.contexts;version="1.7.0",
20 | org.eclipse.jetty.util;version="[12.0.0,13.0.0)",
21 | org.osgi.framework,
22 | org.osgi.service.prefs;version="1.1.1"
23 | Bundle-Activator: de.marw.cmake4eclipse.mbs.internal.Activator
24 | Export-Package: de.marw.cmake4eclipse.mbs.cmakecache,
25 | de.marw.cmake4eclipse.mbs.console,
26 | de.marw.cmake4eclipse.mbs.internal;x-friends:="de.marw.cmake4eclipse.mbs.ui",
27 | de.marw.cmake4eclipse.mbs.internal.storage;x-friends:="de.marw.cmake4eclipse.mbs.ui",
28 | de.marw.cmake4eclipse.mbs.nature;x-friends:="de.marw.cmake4eclipse.mbs.ui",
29 | de.marw.cmake4eclipse.mbs.preferences;x-friends:="de.marw.cmake4eclipse.mbs.ui",
30 | de.marw.cmake4eclipse.mbs.settings
31 | Automatic-Module-Name: de.marw.cmake4eclipse.mbs
32 | Require-Bundle: org.eclipse.cdt.core;bundle-version="8.3.0",
33 | org.eclipse.cdt.managedbuilder.core;bundle-version="9.6.200",
34 | org.eclipse.cdt.jsoncdb.core;bundle-version="1.0.0",
35 | org.eclipse.core.variables,
36 | org.eclipse.jdt.annotation;resolution:=optional,
37 | org.eclipse.cdt.managedbuilder.gnu.ui
38 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/internal/storage/CMakeUndefineSerializer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.internal.storage;
10 |
11 | import org.eclipse.cdt.core.settings.model.ICStorageElement;
12 |
13 | import de.marw.cmake4eclipse.mbs.settings.CmakeUnDefine;
14 |
15 | /**
16 | * Responsible for serialization/de-serialization of CmakeUndefine objects.
17 | *
18 | * @author Martin Weber
19 | */
20 | public class CMakeUndefineSerializer implements
21 | StorageSerializer {
22 | /** */
23 | private static final String ELEM_UNDEFINE = "undef";
24 | /** */
25 | private static final String ATTR_NAME = "name";
26 |
27 | public void toStorage(ICStorageElement parent, CmakeUnDefine item) {
28 | ICStorageElement elem = parent.createChild(ELEM_UNDEFINE);
29 | elem.setAttribute(ATTR_NAME, item.getName());
30 | }
31 |
32 | /*-
33 | * @see de.marw.cmake4eclipse.mbs.internal.storage.StorageSerializer#fromStorage(org.eclipse.cdt.core.settings.model.ICStorageElement)
34 | */
35 | @Override
36 | public CmakeUnDefine fromStorage(ICStorageElement item) {
37 | if (!ELEM_UNDEFINE.equals(item.getName()))
38 | return null; // item is not an element representing a cmake undefine
39 | String nameVal = item.getAttribute(ATTR_NAME);
40 | if (nameVal != null) {
41 | return new CmakeUnDefine(nameVal);
42 | }
43 | return null;
44 | }
45 | }
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/doc/toc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/AbstractConsole.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2018 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.ui;
11 |
12 | import org.eclipse.cdt.core.ConsoleOutputStream;
13 | import org.eclipse.cdt.core.resources.IConsole;
14 | import org.eclipse.cdt.ui.IBuildConsoleManager;
15 | import org.eclipse.core.resources.IProject;
16 | import org.eclipse.core.runtime.CoreException;
17 |
18 | /**
19 | * @author Martin Weber
20 | */
21 | public abstract class AbstractConsole implements IConsole {
22 |
23 | protected IConsole console;
24 |
25 | /**
26 | * Gets a console manager that is configured to the console`s display-name, the ID and icon.
27 | *
28 | * @see org.eclipse.cdt.ui.CUIPlugin#getConsoleManager(String, String, URL)
29 | */
30 | protected abstract IBuildConsoleManager getConsoleManager();
31 |
32 | @Override
33 | public ConsoleOutputStream getOutputStream() throws CoreException {
34 | return console.getOutputStream();
35 | }
36 |
37 | @Override
38 | public ConsoleOutputStream getInfoStream() throws CoreException {
39 | return console.getInfoStream();
40 | }
41 |
42 | @Override
43 | public ConsoleOutputStream getErrorStream() throws CoreException {
44 | return console.getErrorStream();
45 | }
46 |
47 | @Override
48 | public void start(IProject project) {
49 | IBuildConsoleManager consoleManager = getConsoleManager();
50 | console = consoleManager.getConsole(project);
51 | console.start(project);
52 | }
53 |
54 | }
--------------------------------------------------------------------------------
/releng/repo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | de.marw.cmake4eclipse
7 | parent
8 | 1.1.0
9 | ../../pom.xml
10 |
11 |
12 |
13 | repo
14 | 5.1.0
15 | eclipse-repository
16 |
17 |
18 |
19 |
20 |
21 | maven-install-plugin
22 |
23 | true
24 |
25 |
26 |
27 | maven-deploy-plugin
28 |
29 | true
30 |
31 |
32 |
33 |
34 | org.eclipse.tycho
35 | tycho-p2-repository-plugin
36 | ${tycho-version}
37 |
38 | cmake4eclipse ${project.version}
39 |
40 | cmake4eclipse-${project.version}
41 | false
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.feature/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | 4.0.0
7 |
8 |
9 | de.marw.cmake4eclipse
10 | parent
11 | 1.1.0
12 | ../pom.xml
13 |
14 |
15 | de.marw.cmake4eclipse.feature
16 |
18 | 5.1.0
19 | eclipse-feature
20 |
21 |
22 |
23 |
24 | org.eclipse.tycho
25 | tycho-source-plugin
26 |
27 |
28 |
29 | false
30 |
31 |
32 |
33 |
34 | feature-source
35 |
36 | feature-source
37 |
38 |
39 |
40 |
41 |
42 | org.eclipse.tycho
43 | tycho-p2-plugin
44 |
45 |
46 | attach-p2-metadata
47 | package
48 |
49 | p2-metadata
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/cmakecache/SimpleCMakeCacheEntry.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.cmakecache;
10 |
11 | /**
12 | * Represents an entry of a CMakeCache.txt file in a simple form: Holds only
13 | * key-value-pairs of an entry. It does not extract any help texts nor entry
14 | * types.
15 | *
16 | * @author Martin Weber
17 | */
18 | public class SimpleCMakeCacheEntry {
19 | private final String key;
20 | private final String value;
21 |
22 | /**
23 | * @throws IllegalArgumentException
24 | * if {@code key} is empty
25 | * @throws NullPointerException
26 | * if {@code key} is {@code null} or if {@code value} is {@code null}
27 | */
28 | public SimpleCMakeCacheEntry(String key, String value) {
29 | if (key == null) {
30 | throw new NullPointerException("key");
31 | }
32 | if (key.length() == 0) {
33 | throw new IllegalArgumentException("key");
34 | }
35 | if (value == null) {
36 | throw new NullPointerException("value");
37 | }
38 |
39 | this.value = value;
40 | this.key = key;
41 | }
42 |
43 | /**
44 | * Gets the key property.
45 | *
46 | * @return the current key property.
47 | */
48 | public String getKey() {
49 | return this.key;
50 | }
51 |
52 | /**
53 | * Gets the value.
54 | *
55 | * @return the current value.
56 | */
57 | public String getValue() {
58 | return this.value;
59 | }
60 |
61 | public String toString() {
62 | return key + "=" + value;
63 | }
64 |
65 | }
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/navigator/BuildTargetsContainer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.ui.navigator;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 | import java.util.Objects;
15 |
16 | import org.eclipse.core.resources.IProject;
17 |
18 | /**
19 | * Represents a container for build targets owned by a project with {@code C4ENature} in the project explorer view.
20 | *
21 | * @author Martin Weber
22 | */
23 | class BuildTargetsContainer {
24 |
25 | private final IProject project;
26 | private List navBuildTargets = new ArrayList<>(5);
27 |
28 | /**
29 | * @param project
30 | */
31 | private BuildTargetsContainer(IProject project) {
32 | this.project = Objects.requireNonNull(project);
33 | }
34 |
35 | IProject getProject() {
36 | return project;
37 | }
38 |
39 | List getBuildTargets() {
40 | return navBuildTargets;
41 | }
42 |
43 | void updateTargets(List newTargetNames) {
44 | navBuildTargets = new ArrayList<>(5);
45 | for (String name : newTargetNames) {
46 | navBuildTargets.add(new NavBuildTarget(this, name));
47 | }
48 | }
49 | /**
50 | * @param project
51 | * @param targetNames
52 | * @return
53 | */
54 | public static BuildTargetsContainer create(IProject project, List targetNames) {
55 | BuildTargetsContainer container = new BuildTargetsContainer(project);
56 | for (String name : targetNames) {
57 | container.navBuildTargets.add(new NavBuildTarget(container, name));
58 | }
59 | return container;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/.github/workflows/upload-release.yml:
--------------------------------------------------------------------------------
1 | name: Cloudsmith Push Repository
2 | on:
3 | workflow_dispatch:
4 | # release:
5 | # types: [created]
6 |
7 | jobs:
8 | build:
9 | runs-on: ubuntu-latest
10 |
11 | steps:
12 | - uses: actions/checkout@v2
13 |
14 | - name: Set up JDK
15 | uses: actions/setup-java@v2
16 | with:
17 | java-version: '17'
18 | distribution: 'adopt'
19 | settings-path: ${{ github.workspace }}
20 |
21 | - name: Set up Maven
22 | uses: stCarolas/setup-maven@v4.5
23 | with:
24 | maven-version: 3.9.0
25 |
26 | - name: Build
27 | run: mvn -P release -B -ntp package
28 |
29 | - name: Determine artifact to upload
30 | id: TheZIP
31 | # uses: actions/github-script@v4
32 | # with:
33 | # result-encoding: string
34 | # script: |
35 | # const globber = await glob.create('releng/*-repo/target/cmake4eclipse-[0-9]*.[0-9]*.[0-9]*.zip')
36 | # return await globber.glob()
37 | # NOTE: glob gives us absolute paths which is not understood by cloudsmith-io/action
38 | run: 'echo "::set-output name=result::$(find releng/repo/target/ -type f -name cmake4eclipse-\*.zip)"'
39 |
40 | - name: Artifact to upload
41 | run: echo "${{steps.TheZIP.outputs.result}}"
42 |
43 | - name: Upload
44 | id: push
45 | uses: cloudsmith-io/action@master
46 | with:
47 | api-key: ${{ secrets.CLOUDSMITH_AUTH }}
48 | command: 'push'
49 | format: 'raw'
50 | # If true, the uploaded package will overwrite any others with the same attributes.
51 | republish: false # optional, default is false
52 | owner: '15knots' # Your Cloudsmith account name or org name (namespace)
53 | repo: 'p2-zip' # Your Cloudsmith Repository name (slug)
54 | file: '${{steps.TheZIP.outputs.result}}' # Name of file
55 | no-wait-for-sync: true # Skip the waiting for package synchronisation (i.e. upload only)
56 | # name: 'NAME' # Name for Raw package
57 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/settings/CmakeUnDefine.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.settings;
10 |
11 | /**
12 | * Represents a cmake variable to undefine.
13 | *
14 | * @author Martin Weber
15 | */
16 | public class CmakeUnDefine implements Cloneable {
17 | private String name;
18 |
19 | /**
20 | * Creates a new object.
21 | *
22 | * @param name
23 | * the variable name, must not be empty.
24 | * @throws IllegalArgumentException
25 | * if {@code name} is empty
26 | * @throws NullPointerException
27 | * if {@code name} is {@code null}
28 | */
29 | public CmakeUnDefine(String name) {
30 | setName(name);
31 | }
32 |
33 | /**
34 | * Gets the name property.
35 | *
36 | * @return the current name property.
37 | */
38 | public String getName() {
39 | return this.name;
40 | }
41 |
42 | /**
43 | * Sets the name property.
44 | *
45 | * @throws IllegalArgumentException
46 | * if {@code name} is empty
47 | * @throws NullPointerException
48 | * if {@code name} is {@code null}
49 | */
50 | public void setName(String name) {
51 | if (name == null) {
52 | throw new NullPointerException("name");
53 | }
54 | if (name.length() == 0) {
55 | throw new IllegalArgumentException("name");
56 | }
57 | this.name = name;
58 | }
59 |
60 | public String toString() {
61 | return name;
62 | }
63 |
64 | /*-
65 | * @see java.lang.Object#clone()
66 | */
67 | public CmakeUnDefine clone() {
68 | try {
69 | return (CmakeUnDefine) super.clone();
70 | } catch (CloneNotSupportedException ex) { // ignore
71 | return null;
72 | }
73 | }
74 | }
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/internal/ParsingConsoleOutputStream.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2020 Martin Weber.
3 | *
4 | * This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License 2.0
6 | * which accompanies this distribution, and is available at
7 | * https://www.eclipse.org/legal/epl-2.0/
8 | *
9 | * SPDX-License-Identifier: EPL-2.0
10 | *******************************************************************************/
11 |
12 | package de.marw.cmake4eclipse.mbs.internal;
13 |
14 | import java.io.IOException;
15 | import java.util.Objects;
16 |
17 | import org.eclipse.cdt.core.ConsoleOutputStream;
18 |
19 | /**
20 | * Intercepts output to a console output stream and forwards it to a CMakeErrorParser for processing.
21 | *
22 | * @author Martin Weber
23 | */
24 | class ParsingConsoleOutputStream extends ConsoleOutputStream {
25 |
26 | private final ConsoleOutputStream os;
27 | private final CMakeErrorParser parser;
28 |
29 | /**
30 | * @param outputStream the OutputStream to write to
31 | * @param cmakeErrorParser the CMakeErrorParser for processing the output
32 | */
33 | public ParsingConsoleOutputStream(ConsoleOutputStream outputStream, CMakeErrorParser cmakeErrorParser) {
34 | this.os = Objects.requireNonNull(outputStream);
35 | this.parser = Objects.requireNonNull(cmakeErrorParser);
36 | }
37 |
38 | @Override
39 | public void write(int c) throws IOException {
40 | write(new byte[] { (byte) c }, 0, 1);
41 | }
42 |
43 | @Override
44 | public void write(byte[] b, int off, int len) throws IOException {
45 | os.write(b, off, len);
46 | parser.addInput(new String(b, off, len));
47 | }
48 |
49 | // interface ConsoleOutputStream
50 | @Override
51 | public void write(String msg) throws IOException {
52 | os.write(msg);
53 | parser.addInput(msg);
54 | }
55 |
56 | @Override
57 | public void flush() throws IOException {
58 | os.flush();
59 | }
60 |
61 | @Override
62 | public void close() throws IOException {
63 | os.close();
64 | parser.close();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/navigator/EditBuildTargetsAction.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.ui.navigator;
11 |
12 | import java.net.MalformedURLException;
13 | import java.net.URL;
14 |
15 | import org.eclipse.jface.resource.ImageDescriptor;
16 | import org.eclipse.swt.widgets.Shell;
17 | import org.eclipse.ui.actions.SelectionListenerAction;
18 | import org.eclipse.ui.dialogs.PreferencesUtil;
19 |
20 | /**
21 | * @author Martin Weber
22 | */
23 | class EditBuildTargetsAction extends SelectionListenerAction {
24 |
25 | private final Shell shell;
26 |
27 | public EditBuildTargetsAction(Shell shell) {
28 | super("Edit Build T&argets");
29 | this.shell = shell;
30 | URL url = null;
31 | try {
32 | url = new URL("platform:/plugin/org.eclipse.cdt.make.ui/icons/etool16/target_edit.gif");
33 | ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url);
34 | setImageDescriptor(imageDescriptor);
35 | } catch (MalformedURLException ignore) {
36 | }
37 | setEnabled(false);
38 | }
39 |
40 | private Object getSelectedElement() {
41 | if (getStructuredSelection().size() == 1) {
42 | return getStructuredSelection().getFirstElement();
43 | }
44 | return null;
45 | }
46 |
47 | @Override
48 | public void run() {
49 | Object selection = getSelectedElement();
50 | if (selection instanceof BuildTargetsContainer || selection instanceof NavBuildTarget) {
51 | BuildTargetsContainer container = selection instanceof BuildTargetsContainer ? (BuildTargetsContainer) selection
52 | : ((NavBuildTarget) selection).getContainer();
53 | PreferencesUtil.createPropertyDialogOn(shell, container.getProject(),
54 | "cmake4eclipse.mbs.ui.page_CMakeProjectProperty", null, null).open();
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: %bundleName
4 | Bundle-SymbolicName: de.marw.cmake4eclipse.mbs.ui;singleton:=true
5 | Bundle-Version: 3.1.0.qualifier
6 | Bundle-Vendor: Martin Weber
7 | Bundle-Localization: plugin
8 | Automatic-Module-Name: de.marw.cmake4eclipse.mbs.ui
9 | Bundle-RequiredExecutionEnvironment: JavaSE-17
10 | Import-Package: com.google.gson;version="2.8.7",
11 | de.marw.cmake4eclipse.mbs.console,
12 | de.marw.cmake4eclipse.mbs.internal,
13 | de.marw.cmake4eclipse.mbs.internal.storage,
14 | de.marw.cmake4eclipse.mbs.nature,
15 | de.marw.cmake4eclipse.mbs.preferences,
16 | de.marw.cmake4eclipse.mbs.settings,
17 | org.eclipse.cdt.core,
18 | org.eclipse.cdt.core.model,
19 | org.eclipse.cdt.core.resources,
20 | org.eclipse.cdt.core.settings.model,
21 | org.eclipse.cdt.core.settings.model.extension,
22 | org.eclipse.cdt.managedbuilder.buildproperties,
23 | org.eclipse.cdt.managedbuilder.core,
24 | org.eclipse.cdt.newmake.core,
25 | org.eclipse.core.commands.common,
26 | org.eclipse.core.resources,
27 | org.eclipse.core.runtime,
28 | org.eclipse.core.runtime.jobs,
29 | org.eclipse.core.runtime.preferences;version="3.4.0",
30 | org.eclipse.jface.text,
31 | org.eclipse.swt,
32 | org.eclipse.swt.events,
33 | org.eclipse.swt.graphics,
34 | org.eclipse.swt.layout,
35 | org.eclipse.swt.widgets,
36 | org.eclipse.tools.templates.core,
37 | org.eclipse.ui,
38 | org.eclipse.ui.actions,
39 | org.eclipse.ui.dialogs,
40 | org.eclipse.ui.editors.text,
41 | org.eclipse.ui.help,
42 | org.eclipse.ui.ide,
43 | org.eclipse.ui.plugin,
44 | org.eclipse.ui.wizards.newresource,
45 | org.osgi.framework,
46 | org.osgi.service.prefs;version="1.1.1"
47 | Bundle-ActivationPolicy: lazy
48 | Bundle-Activator: de.marw.cmake4eclipse.mbs.ui.Activator
49 | Require-Bundle: org.eclipse.cdt.ui,
50 | org.eclipse.ui,
51 | org.eclipse.cdt.jsoncdb.core.doc;bundle-version="1.0.0",
52 | org.eclipse.cdt.jsoncdb.core.ui;bundle-version="1.0.100",
53 | org.eclipse.cdt.managedbuilder.ui,
54 | org.eclipse.cdt.docker.launcher;resolution:=optional,
55 | org.eclipse.tools.templates.ui,
56 | org.eclipse.core.filesystem,
57 | org.eclipse.help,
58 | org.eclipse.core.resources,
59 | org.eclipse.ui.navigator,
60 | org.eclipse.ui.navigator.resources,
61 | org.eclipse.jdt.annotation;bundle-version="2.2.700";resolution:=optional
62 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/slim/BuildTargetsManager.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.ui.slim;
11 |
12 | import org.eclipse.core.resources.IProject;
13 | import org.eclipse.core.runtime.CoreException;
14 | import org.eclipse.core.runtime.ListenerList;
15 |
16 | import de.marw.cmake4eclipse.mbs.nature.C4ENature;
17 |
18 | /**
19 | * Manages {@code BuildTargetEvent} listeners.
20 | *
21 | * @author Martin Weber
22 | */
23 | public class BuildTargetsManager {
24 | private static BuildTargetsManager instance;
25 |
26 | private final ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY);
27 |
28 | /**
29 | * Gets the singleton {@code BuildTargetsManager} object.
30 | */
31 | public static BuildTargetsManager getDefault() {
32 | if (instance == null) {
33 | instance = new BuildTargetsManager();
34 | }
35 | return instance;
36 | }
37 |
38 | public void notifyListeners(BuildTargetEvent event) {
39 | for (Object listener : listeners.getListeners()) {
40 | ((IBuildTargetListener) listener).targetsChanged(event);
41 | }
42 | }
43 |
44 | public void addListener(IBuildTargetListener listener) {
45 | listeners.add(listener);
46 | }
47 |
48 | public void removeListener(IBuildTargetListener listener) {
49 | listeners.remove(listeners);
50 | }
51 |
52 | /**
53 | * Gets whether the specified element is an instance of {@code IProject} and has our project nature.
54 | *
55 | * @param project
56 | */
57 | public static boolean hasC4ENature(Object project) {
58 | if (project instanceof IProject) {
59 | try {
60 | if (((IProject) project).hasNature(C4ENature.NATURE_ID)) {
61 | return true;
62 | }
63 | } catch (CoreException e) {
64 | // TODO Auto-generated catch block
65 | e.printStackTrace();
66 | }
67 | }
68 | return false;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/navigator/NavBuildTargetActionProvider.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.ui.navigator;
11 |
12 | import org.eclipse.jface.action.IMenuManager;
13 | import org.eclipse.jface.viewers.DoubleClickEvent;
14 | import org.eclipse.jface.viewers.IDoubleClickListener;
15 | import org.eclipse.jface.viewers.IStructuredSelection;
16 | import org.eclipse.swt.widgets.Shell;
17 | import org.eclipse.ui.actions.ActionContext;
18 | import org.eclipse.ui.navigator.CommonActionProvider;
19 | import org.eclipse.ui.navigator.ICommonActionExtensionSite;
20 |
21 | /**
22 | * Provides actions for a node of type [@code NavBuildTarget}.
23 | *
24 | * @author Martin Weber
25 | */
26 | public class NavBuildTargetActionProvider extends CommonActionProvider {
27 |
28 | private BuildTargetAction buildTargetAction;
29 |
30 | @Override
31 | public void init(ICommonActionExtensionSite aSite) {
32 | super.init(aSite);
33 |
34 | Shell shell = aSite.getViewSite().getShell();
35 | buildTargetAction = new BuildTargetAction();
36 |
37 | aSite.getStructuredViewer().addDoubleClickListener(new IDoubleClickListener() {
38 | @Override
39 | public void doubleClick(DoubleClickEvent event) {
40 | IStructuredSelection selection = (IStructuredSelection) event.getSelection();
41 | Object element = selection.getFirstElement();
42 | if (element instanceof NavBuildTarget) {
43 | buildTargetAction.run();
44 | }
45 | }
46 | });
47 | }
48 |
49 | @Override
50 | public void fillContextMenu(IMenuManager menu) {
51 | menu.add(buildTargetAction);
52 | }
53 |
54 | @Override
55 | public void setContext(ActionContext context) {
56 | super.setContext(context);
57 |
58 | if (context != null) {
59 | IStructuredSelection selection = (IStructuredSelection) context.getSelection();
60 | buildTargetAction.selectionChanged(selection);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/doc/html/tasks/create_project_cmake4eclipse.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Creating a Cmake4eclipse Managed Build project
6 |
8 |
9 |
10 |
11 |
Creating a Cmake4eclipse Managed Build project
12 |
To set up your own project with or without existing source code, please follow these steps:
13 |
If your top level CMakeLists.txt does not reside in the project`s root directory , click the
26 | Advanced settings... button and
27 |
28 |
select the Cmake4eclipse Build node,
29 |
then the Source Location tab
30 |
and adjust the source folder to point to the directory containing your top level CMakeLists.txt
31 | file.
32 |
Click the Apply and Close button to return to the project build configurations wizard step.
33 |
34 |
35 |
Finish project creation.
36 |
Build the project. This will first invoke cmake to generate the build scripts and then pass control to CDT to run the generated scripts.
37 | To examine the full build log, open Eclipse`s Console View, then set it to display the
38 | CDT Global Build Console. There is also a CMake Console which will display the
39 | output of the most recent cmake invocation only.
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/internal/BTKPathDynamicVariableResolver.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.internal;
11 |
12 | import java.util.Optional;
13 |
14 | import org.eclipse.cdt.core.CCorePlugin;
15 | import org.eclipse.core.runtime.CoreException;
16 | import org.eclipse.core.runtime.Status;
17 | import org.eclipse.core.runtime.preferences.IEclipsePreferences;
18 | import org.eclipse.core.variables.IDynamicVariable;
19 | import org.eclipse.core.variables.IDynamicVariableResolver;
20 |
21 | import com.google.gson.JsonSyntaxException;
22 |
23 | import de.marw.cmake4eclipse.mbs.preferences.BuildToolKitDefinition;
24 | import de.marw.cmake4eclipse.mbs.preferences.PreferenceAccess;
25 |
26 | /**
27 | * Resolves to the value of the path property of the currently overwriting build tool kit. If no overwriting build tool
28 | * kit is present, resolves to the value of the system environment variable {@code PATH}.
29 | *
30 | * @author Martin Weber
31 | */
32 | public class BTKPathDynamicVariableResolver implements IDynamicVariableResolver {
33 |
34 | @Override
35 | public String resolveValue(IDynamicVariable variable, String argument) throws CoreException {
36 | IEclipsePreferences prefs = PreferenceAccess.getPreferences();
37 | try {
38 | Optional overwritingBtk = BuildToolKitUtil.getOverwritingToolkit(prefs);
39 |
40 | if (!overwritingBtk.isEmpty()) {
41 | // PATH is overwritten...
42 | // replace the value of $PATH with the value specified in the overwriting build tool kit
43 | String newPath = CCorePlugin.getDefault().getCdtVariableManager().resolveValue(overwritingBtk.get().getPath(),
44 | "", null, null);
45 | return newPath;
46 | } else {
47 | return System.getenv("PATH");
48 | }
49 | } catch (JsonSyntaxException ex) {
50 | // workbench preferences file format error
51 | throw new CoreException(Status.error("Error loading workbench preferences", ex));
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/internal/storage/CMakeDefineSerializer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.internal.storage;
10 |
11 | import org.eclipse.cdt.core.settings.model.ICStorageElement;
12 |
13 | import de.marw.cmake4eclipse.mbs.settings.CmakeDefine;
14 | import de.marw.cmake4eclipse.mbs.settings.CmakeVariableType;
15 |
16 | /**
17 | * Responsible for serialization/de-serialization of CmakeDefine objects.
18 | *
19 | * @author Martin Weber
20 | */
21 | public class CMakeDefineSerializer implements StorageSerializer {
22 | /** */
23 | private static final String ELEM_DEFINE = "def";
24 | /** */
25 | private static final String ATTR_CMAKEVAR_TYPE = "type";
26 | /** */
27 | private static final String ATTR_CMAKEVAR_VALUE = "val";
28 | /** */
29 | private static final String ATTR_NAME = "name";
30 |
31 | public void toStorage(ICStorageElement parent, CmakeDefine item) {
32 | ICStorageElement elem = parent.createChild(ELEM_DEFINE);
33 | elem.setAttribute(ATTR_NAME, item.getName());
34 | elem.setAttribute(ATTR_CMAKEVAR_TYPE, item.getType().name());
35 | elem.setAttribute(ATTR_CMAKEVAR_VALUE, item.getValue());
36 | }
37 |
38 | /*-
39 | * @see StorageSerializer#fromStorage(org.eclipse.cdt.core.settings.model.ICStorageElement)
40 | */
41 | @Override
42 | public CmakeDefine fromStorage(ICStorageElement item) {
43 | if (!ELEM_DEFINE.equals(item.getName()))
44 | return null; // item is not an element representing a cmake define
45 | String nameVal = item.getAttribute(ATTR_NAME);
46 | String typeVal = item.getAttribute(ATTR_CMAKEVAR_TYPE);
47 | String valueVal = item.getAttribute(ATTR_CMAKEVAR_VALUE);
48 | if (nameVal != null && typeVal != null && valueVal != null) {
49 | try {
50 | final CmakeVariableType type = CmakeVariableType.valueOf(typeVal);
51 | return new CmakeDefine(nameVal, type, valueVal);
52 | } catch (IllegalArgumentException ex) {
53 | // illegal cmake variable type, ignore
54 | }
55 | }
56 | return null;
57 | }
58 | }
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/navigator/BuildTargetsLabelProvider.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.ui.navigator;
11 |
12 | import java.net.MalformedURLException;
13 | import java.net.URL;
14 |
15 | import org.eclipse.jface.resource.ImageDescriptor;
16 | import org.eclipse.jface.resource.JFaceResources;
17 | import org.eclipse.jface.resource.LocalResourceManager;
18 | import org.eclipse.jface.resource.ResourceManager;
19 | import org.eclipse.jface.viewers.LabelProvider;
20 | import org.eclipse.swt.graphics.Image;
21 |
22 | import de.marw.cmake4eclipse.mbs.settings.BuildTarget;
23 |
24 | /**
25 | * @author Martin Weber
26 | */
27 | public class BuildTargetsLabelProvider extends LabelProvider {
28 | private ResourceManager resourceManager;
29 |
30 | /**
31 | */
32 | public BuildTargetsLabelProvider() {
33 | this.resourceManager = new LocalResourceManager(JFaceResources.getResources());
34 | }
35 |
36 | @Override
37 | public String getText(Object element) {
38 | if (element instanceof BuildTargetsContainer) {
39 | return "Build Targets";
40 | } else if (element instanceof NavBuildTarget) {
41 | BuildTarget tgt = (BuildTarget) element;
42 | return tgt.getName();
43 | }
44 | return super.getText(element);
45 | }
46 |
47 | @Override
48 | public Image getImage(Object element) {
49 | if (element instanceof BuildTargetsContainer || element instanceof NavBuildTarget) {
50 | URL url = null;
51 | // Bundle bundle = FrameworkUtil.getBundle(this.getClass());
52 | // FileLocator.find(bundle, new Path("icons/task.png"), null);
53 | try {
54 | url = new URL ("platform:/plugin/org.eclipse.cdt.managedbuilder.ui/icons/obj16/target_obj.gif");
55 | } catch (MalformedURLException ignore) {
56 | }
57 | ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url);
58 | return resourceManager.createImage(imageDescriptor);
59 | }
60 | return null;
61 | }
62 |
63 | @Override
64 | public void dispose() {
65 | super.dispose();
66 | resourceManager.dispose();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/navigator/BuildTargetsContainerActionProvider.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.ui.navigator;
11 |
12 | import org.eclipse.jface.action.IMenuManager;
13 | import org.eclipse.jface.viewers.DoubleClickEvent;
14 | import org.eclipse.jface.viewers.IDoubleClickListener;
15 | import org.eclipse.jface.viewers.IStructuredSelection;
16 | import org.eclipse.swt.widgets.Shell;
17 | import org.eclipse.ui.actions.ActionContext;
18 | import org.eclipse.ui.navigator.CommonActionProvider;
19 | import org.eclipse.ui.navigator.ICommonActionExtensionSite;
20 |
21 | /**
22 | * Provides actions for a node of type [@code BuildTargetsContainer}.
23 | *
24 | * @author Martin Weber
25 | */
26 | public class BuildTargetsContainerActionProvider extends CommonActionProvider {
27 |
28 | private BuildTargetAction buildTargetAction;
29 | // private RebuildLastTargetAction buildLastTargetAction;
30 |
31 | @Override
32 | public void init(ICommonActionExtensionSite aSite) {
33 | super.init(aSite);
34 |
35 | buildTargetAction = new BuildTargetAction();
36 | // buildLastTargetAction = new RebuildLastTargetAction();
37 |
38 | aSite.getStructuredViewer().addDoubleClickListener(new IDoubleClickListener() {
39 | @Override
40 | public void doubleClick(DoubleClickEvent event) {
41 | IStructuredSelection selection = (IStructuredSelection) event.getSelection();
42 | Object element = selection.getFirstElement();
43 | if (element instanceof NavBuildTarget) {
44 | buildTargetAction.run();
45 | }
46 | }
47 | });
48 | }
49 |
50 | @Override
51 | public void fillContextMenu(IMenuManager menu) {
52 | menu.add(buildTargetAction);
53 | // menu.add(buildLastTargetAction);
54 | }
55 |
56 | @Override
57 | public void setContext(ActionContext context) {
58 | super.setContext(context);
59 |
60 | if (context != null) {
61 | IStructuredSelection selection = (IStructuredSelection) context.getSelection();
62 | buildTargetAction.selectionChanged(selection);
63 | // buildLastTargetAction.selectionChanged(selection);
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/JsonCompilationDatabaseParserPage.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2021 Martin Weber
3 | .
4 | *
5 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
6 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
7 | *
8 | * SPDX-License-Identifier: EPL-2.0
9 | *******************************************************************************/
10 |
11 | package de.marw.cmake4eclipse.mbs.ui;
12 |
13 | import org.eclipse.cdt.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage;
14 | import org.eclipse.swt.SWT;
15 | import org.eclipse.swt.events.SelectionEvent;
16 | import org.eclipse.swt.events.SelectionListener;
17 | import org.eclipse.swt.layout.GridData;
18 | import org.eclipse.swt.layout.GridLayout;
19 | import org.eclipse.swt.widgets.Composite;
20 | import org.eclipse.swt.widgets.Link;
21 | import org.eclipse.ui.dialogs.PreferencesUtil;
22 |
23 | public class JsonCompilationDatabaseParserPage extends AbstractLanguageSettingProviderOptionPage {
24 |
25 | @Override
26 | public void createControl(Composite parent) {
27 | final Composite composite = new Composite(parent, SWT.NONE);
28 | {
29 | GridLayout layout = new GridLayout();
30 | layout.numColumns = 1;
31 | layout.marginWidth = 1;
32 | layout.marginHeight = 1;
33 | layout.marginRight = 1;
34 | composite.setLayout(layout);
35 | composite.setLayoutData(new GridData(GridData.FILL_BOTH));
36 | }
37 | createLink(composite, "Configure Workspace Settings...");
38 | setControl(composite);
39 | }
40 |
41 | private Link createLink(Composite composite, String text) {
42 | Link link = new Link(composite, SWT.NONE);
43 | link.setFont(composite.getFont());
44 | link.setText("" + text + ""); //$NON-NLS-1$//$NON-NLS-2$
45 | link.addSelectionListener(new SelectionListener() {
46 | @Override
47 | public void widgetSelected(SelectionEvent e) {
48 | doLinkActivated((Link) e.widget);
49 | }
50 |
51 | @Override
52 | public void widgetDefaultSelected(SelectionEvent e) {
53 | doLinkActivated((Link) e.widget);
54 | }
55 | });
56 | return link;
57 | }
58 |
59 | /**
60 | * Handle link activation.
61 | *
62 | * @param link the link
63 | */
64 | private void doLinkActivated(Link link) {
65 | String id = "org.eclipse.cdt.jsoncdb.core.ui.JsonCdbPreferencePage";
66 | PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { id }, null).open();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/internal/ICMakeExecutionMarkerFactory.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.internal;
11 |
12 | import java.util.Map;
13 |
14 | import org.eclipse.core.resources.IMarker;
15 | import org.eclipse.core.resources.IResource;
16 | import org.eclipse.core.runtime.CoreException;
17 |
18 | /** Responsible for creating problem marker objects related to errors in cmake's output for the project currently being
19 | * build.
20 | *
21 | * @author Martin Weber
22 | */
23 | @FunctionalInterface
24 | interface ICMakeExecutionMarkerFactory {
25 |
26 | /** ID for error markers related to execution of the cmake tool.
27 | * @see IResource#createMarker(String)
28 | */
29 | String CMAKE_PROBLEM_MARKER_ID = Activator.PLUGIN_ID + ".cmakeproblem"; //$NON-NLS-1$
30 |
31 | /**
32 | * Creates a problem marker and/or text marker object related to errors in cmake's output.
33 | *
34 | * @param message
35 | * the complete error message, including the string the message starts with
36 | * @param severity
37 | * the severity of the problem, see {@link IMarker} for acceptable severity values
38 | * @param filePath
39 | * the name of the file where the problem occurred, extracted from the error message.
40 | * This is a String denoting a location in the file system.
41 | * If null, no file information is present in the error message; the marker should be created
42 | * then for the project being build.
43 | * If it is relative, it is relative to the source-root of the project being build (and thus can be
44 | * converted to an {@code IResource}).
45 | * If absolute, the file might not be a workspace resource (e.g. one of cmake's module files).
46 | * @param mandatoryAttributes
47 | * mandatory attributes to add to the marker. Attribute keys must be one of those defined in {@link IMarker}
48 | *
49 | * @throws CoreException
50 | */
51 | void createMarker(String message, int severity, String filePath, Map mandatoryAttributes)
52 | throws CoreException;
53 | }
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/QuirklessAbstractCPropertyTab.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014-2019 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.ui;
10 |
11 | import org.eclipse.cdt.core.settings.model.ICResourceDescription;
12 | import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
13 | import org.eclipse.cdt.ui.newui.ICPropertyTab;
14 | import org.eclipse.swt.widgets.Composite;
15 | import org.eclipse.ui.PlatformUI;
16 |
17 | /**
18 | * Common workarounds of quirks in AbstractCPropertyTab.
19 | *
20 | * @author Martin Weber
21 | */
22 | public abstract class QuirklessAbstractCPropertyTab extends AbstractCPropertyTab {
23 |
24 | private String helpContextId;
25 |
26 | /**
27 | * Overridden because the super class always prefixes the ID with its own
28 | * bundle name.
29 | */
30 | @Override
31 | public final String getHelpContextId() {
32 | return helpContextId;
33 | }
34 |
35 | /**
36 | * Overridden because the super class always prefixes the ID with its own
37 | * bundle name.
38 | *
39 | * @param id
40 | * the help context id, including the plugin id.
41 | */
42 | @Override
43 | public final void setHelpContextId(String id) {
44 | helpContextId = id;
45 | }
46 |
47 | @Override
48 | protected void createControls(Composite parent) {
49 | super.createControls(parent);
50 | PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, getHelpContextId());
51 | }
52 |
53 | /**
54 | * Overridden to have a logic here that I can understand.
55 | */
56 | @Override
57 | public void handleTabEvent(int kind, Object data) {
58 | switch (kind) {
59 | case ICPropertyTab.DEFAULTS:
60 | if (canBeVisible()) {
61 | performDefaults();
62 | }
63 | break;
64 | default:
65 | super.handleTabEvent(kind, data);
66 | break;
67 | }
68 | }
69 |
70 | /**
71 | * Makes the UI display the specified new settings.
72 | * Overridden to have documentation. This documentation is reversed engineered from existing CDT code;
73 | * AbstractCPropertyTab.java lacks documentation.
74 | *
75 | * @param resd
76 | * the setting to display
77 | */
78 | @Override
79 | protected abstract void updateData(ICResourceDescription resd);
80 |
81 | @Override
82 | protected void updateButtons() {
83 | // never called from superclass, but abstract :-)
84 | }
85 | }
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/doc/html/home.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Cmake4eclipse User Guide
6 |
7 |
8 |
9 |
Cmake4eclipse User Guide
10 |
Cmake4eclipse is a plugin that integrates the CMake cross-platform buildscript
12 | generator into the C/C++ Development Toolkit (CDT).
13 |
14 |
Why does Cmake4eclipse exist?
15 |
Blindly invoked, CMake will generate makefiles (or other build scripts)
16 | inside the source tree, cluttering it with lots of files and directories
17 | that have to be fleed out from version control: This practice might be ok
18 | for simple hello-world-projects, but for larger projects, the CMake
19 | developers recommend You to set up a separate directory for building the
20 | source.
21 |
22 | Annoyingly, these recommended out-of-source-builds impose
23 | some tedious tasks on Your co-workers who check out the code and just want
24 | to build it:
25 |
26 |
Leave eclipse workbench,
27 |
Manually fire up a command-line shell,
28 |
Manually create a directory for the out-of-source-build,
29 |
Manually change the CWD to that directory,
30 |
Manually invoke cmake, telling it to generate build scripts, which
31 | kind of build scripts you want and where source source files live,
32 |
Re-enter eclipse workbench, configure the checked out project to
33 | use the generated buildscripts.
34 |
35 |
36 |
Cmake4eclipse aims to address these tasks: Co-workers can just check
37 | out the source and have all the tedious tasks automated.
38 |
Features
39 |
40 |
Automatic generation of build scripts. No need to manually invoke cmake.
Aims to make Eclipse project cross-platform compatible without the need to change platform-specifc project settings.
45 |
Its Language Settings Provider can feed include paths and pre-processor symbols from cmake to the CDT-Indexer.
46 |
47 |
Project Home
48 |
49 | If you have any question, please do not raise issues in the github tracker, but consult the
50 | mailing list first!
51 | Source code, mailing list and issue tracker can be found at https://github.com/15knots/cmake4eclipse.
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/slim/BelowRootPathTextFieldModifyListener.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.ui.slim;
11 |
12 | import java.util.Objects;
13 |
14 | import org.eclipse.core.runtime.Path;
15 | import org.eclipse.jface.preference.PreferencePage;
16 | import org.eclipse.swt.events.ModifyEvent;
17 | import org.eclipse.swt.events.ModifyListener;
18 | import org.eclipse.swt.widgets.Text;
19 |
20 | /**
21 | * A ModifyListener for text fields that ensures that the entered text denotes a relative
22 | * {@link org.eclipse.core.runtime.IPath IPath} below a given root. It checks for {@code ..}-constructs in a given
23 | * input. For example "foo/.." would be allowed, but ".." of "foo/../.." would be not.
24 | *
25 | * @author Martin Weber
26 | */
27 | public class BelowRootPathTextFieldModifyListener implements ModifyListener {
28 |
29 | private final PreferencePage page;
30 | private final String pageErrorMessage;
31 |
32 | /**
33 | * Add a {@code BelowRootPathTextFieldModifyListener} object to the given text field.
34 | *
35 | * @param field
36 | * The text field to listen to modifications
37 | * @param owningPage
38 | * the preference to display an error message if the path is not below the root
39 | * @param pageErrorMessage
40 | * The error message to display if the path is not below the root
41 | */
42 | public static BelowRootPathTextFieldModifyListener addListener(Text field, PreferencePage owningPage,
43 | String pageErrorMessage) {
44 | Objects.requireNonNull(field, "field");
45 | BelowRootPathTextFieldModifyListener listener = new BelowRootPathTextFieldModifyListener(owningPage, pageErrorMessage);
46 | field.addModifyListener(listener);
47 | return listener;
48 | }
49 |
50 | /**
51 | * @param owningPage
52 | * the preference to display an error message if the path is not below the root
53 | * @param pageErrorMessage
54 | * The error message to display if the path is not below the root
55 | */
56 | private BelowRootPathTextFieldModifyListener(PreferencePage owningPage, String pageErrorMessage) {
57 | this.page = Objects.requireNonNull(owningPage, "owningPage");
58 | this.pageErrorMessage = Objects.requireNonNull(pageErrorMessage, "pageErrorMessage");
59 | }
60 |
61 | @Override
62 | public void modifyText(ModifyEvent evt) {
63 | Path path = new Path(((Text) evt.widget).getText());
64 | final boolean ok = !"..".equals(path.segment(0));
65 | page.setValid(ok);
66 | page.setErrorMessage(ok ? null : pageErrorMessage);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/internal/storage/Util.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.internal.storage;
10 |
11 | import java.util.Collection;
12 |
13 | import org.eclipse.cdt.core.settings.model.ICStorageElement;
14 |
15 | /**
16 | * @author Martin Weber
17 | */
18 | public class Util {
19 |
20 | /**
21 | * Nothing to instantiate here, just static methods.
22 | */
23 | private Util() {
24 | }
25 |
26 | /**
27 | * Converts a collection of {@code T} objects to {@link ICStorageElement}s.
28 | *
29 | * @param targetCollectionStorageName
30 | * the name for the ICStorageElement representing the collection. It
31 | * will be created.
32 | * @param parent
33 | * the parent element, must not be {@code null}.
34 | * @param itemSerializer
35 | * the object that converts a collection element.
36 | * @param source
37 | * the collection to convert, must not be {@code null}.
38 | */
39 | public static void serializeCollection(
40 | String targetCollectionStorageName, ICStorageElement parent,
41 | StorageSerializer itemSerializer, Collection source) {
42 | ICStorageElement[] existingColls = parent
43 | .getChildrenByName(targetCollectionStorageName);
44 |
45 | ICStorageElement pColl;
46 | if (existingColls.length > 0) {
47 | pColl = existingColls[0];
48 | if (source.isEmpty()) {
49 | // remove element if collection is empty
50 | parent.removeChild(pColl);
51 | return;
52 | }
53 | } else {
54 | if (source.isEmpty()) {
55 | return;
56 | }
57 | pColl = parent.createChild(targetCollectionStorageName);
58 | }
59 | // to avoid duplicates, since we do not track additions/removals to lists..
60 | pColl.clear();
61 |
62 | // serialize collection elements
63 | for (E elem : source) {
64 | itemSerializer.toStorage(pColl, elem);
65 | }
66 | }
67 |
68 | /**
69 | * Converts an {@link ICStorageElement} to a collection of {@code T} objects.
70 | *
71 | * @param target
72 | * the collection to store the converted objects in, must not be
73 | * {@code null}.
74 | * @param itemSerializer
75 | * the object that converts a collection element to an Object.
76 | * @param sourceParent
77 | * the parent element of the collection to read, must not be
78 | * {@code null}.
79 | */
80 | public static void deserializeCollection(Collection target,
81 | StorageSerializer itemSerializer, ICStorageElement sourceParent) {
82 | for (ICStorageElement elem : sourceParent.getChildren()) {
83 | E item = itemSerializer.fromStorage(elem);
84 | if (item != null)
85 | target.add(item);
86 | }
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/settings/ProjectPropsModifiedDateUtil.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2024 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.settings;
11 |
12 | import java.io.IOException;
13 | import java.nio.file.Files;
14 | import java.nio.file.Path;
15 | import java.nio.file.attribute.FileTime;
16 |
17 | import org.eclipse.core.resources.IProject;
18 | import org.eclipse.core.runtime.IPath;
19 |
20 | import de.marw.cmake4eclipse.mbs.internal.Activator;
21 |
22 | /**
23 | * Utility to persist and query the time stamp of the most recent change to the project properties which affect a forced
24 | * invocation of cmake.
25 | *
26 | * For each project with a nature of {@link de.marw.cmake4eclipse.mbs.nature.C4ENature} a file with the name of the
27 | * project is stored below the plug-in state area for this plug-in. The
28 | * {@link java.nio.file.Files#setLastModifiedTime(Path, FileTime) last modification} time stamp of the file should
29 | * reflect the time stamp of the most recent change to the project properties which affect a forced invocation of cmake.
30 | *
31 | *
32 | * @author Martin Weber
33 | */
34 | public class ProjectPropsModifiedDateUtil {
35 |
36 | private ProjectPropsModifiedDateUtil() {
37 | }
38 |
39 | /**
40 | * Gets the time stamp of the most recent change to the project properties.
41 | *
42 | * @param project
43 | * the project
44 | * @return the value in milliseconds, since the epoch (1970-01-01T00:00:00Z)
45 | */
46 | public static long getLastModified(IProject project) {
47 | long pPropsModified = 0;
48 | try {
49 | pPropsModified = Files.getLastModifiedTime(getTimestampedFile(project.getName())).toMillis();
50 | } catch (IOException ignore) {
51 | }
52 | return pPropsModified;
53 | }
54 |
55 | /**
56 | * Persists the time stamp of the most recent change to the project properties.
57 | *
58 | * @param project
59 | * the project
60 | * @param timestamp
61 | * the value in milliseconds, since the epoch (1970-01-01T00:00:00Z)
62 | */
63 | public static void setLastModified(IProject project, long timestamp) {
64 | final Path timestampedFile = getTimestampedFile(project.getName());
65 | try {
66 | if (!Files.exists(timestampedFile)) {
67 | Files.createFile(timestampedFile);
68 | }
69 | Files.setLastModifiedTime(timestampedFile, FileTime.fromMillis(timestamp));
70 | } catch (IOException ignore) {
71 | }
72 | }
73 |
74 | /**
75 | * Gets the location of the time-stamp file in the local file system.
76 | *
77 | * @param projectName
78 | * the project
79 | */
80 | public static java.nio.file.Path getTimestampedFile(String projectName) {
81 | IPath pPrefsDir = Activator.getDefault().getStateLocation();
82 | return pPrefsDir.append(projectName).addFileExtension("ts").toPath();
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/WidgetHelper.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.ui;
10 |
11 | import org.eclipse.swt.SWT;
12 | import org.eclipse.swt.layout.GridData;
13 | import org.eclipse.swt.layout.GridLayout;
14 | import org.eclipse.swt.widgets.Button;
15 | import org.eclipse.swt.widgets.Composite;
16 | import org.eclipse.swt.widgets.Group;
17 |
18 | /**
19 | * Static methods for unified creation of widgets.
20 | *
21 | * @author Martin Weber
22 | */
23 | public class WidgetHelper {
24 |
25 | private WidgetHelper() {
26 | // nothing to instantiate
27 | }
28 |
29 | /**
30 | * Creates a button.
31 | *
32 | * @param parent
33 | * @param text
34 | * button text
35 | * @param enabled
36 | * whether the button should be initially enabled
37 | */
38 | public static Button createButton(Composite parent, String text, boolean enabled) {
39 | Button button = new Button(parent, SWT.PUSH);
40 | button.setText(text);
41 | if (!enabled)
42 | button.setEnabled(false);
43 | GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false);
44 | // gd.minimumWidth = width;
45 | button.setLayoutData(gd);
46 | return button;
47 | }
48 |
49 | /**
50 | * Creates a checkbox button.
51 | *
52 | * @param parent
53 | * @param horizontalAlignment
54 | * how control will be positioned horizontally within a cell of the
55 | * parent's grid layout, one of: SWT.BEGINNING (or SWT.LEFT),
56 | * SWT.CENTER, SWT.END (or SWT.RIGHT), or SWT.FILL
57 | * @param horizontalSpan
58 | * number of column cells in the parent's grid layout that the control
59 | * will take up.
60 | * @param text
61 | * text to display on the checkbox
62 | */
63 | public static Button createCheckbox(Composite parent, int horizontalAlignment,
64 | int horizontalSpan, String text) {
65 | Button b = new Button(parent, SWT.CHECK);
66 | b.setText(text);
67 | GridData gd = new GridData(horizontalAlignment, SWT.CENTER, false, false);
68 | gd.horizontalSpan = horizontalSpan;
69 | b.setLayoutData(gd);
70 | return b;
71 | }
72 |
73 | /**
74 | * Creates a group with a grid layout.
75 | *
76 | * @param parent
77 | * @param horizontalAlignment
78 | * how control will be positioned horizontally within a cell of the
79 | * parent's grid layout, one of: SWT.BEGINNING (or SWT.LEFT),
80 | * SWT.CENTER, SWT.END (or SWT.RIGHT), or SWT.FILL
81 | * @param horizontalSpan
82 | * number of column cells in the parent's grid layout that the control
83 | * will take up.
84 | * @param text
85 | * title text to display on the group
86 | * @param numColumns
87 | * the number of columns in the grid inside the group
88 | */
89 | public static Group createGroup(Composite parent, int horizontalAlignment,
90 | int horizontalSpan, String text, int numColumns) {
91 | Group gr = new Group(parent, SWT.NONE);
92 | gr.setLayout(new GridLayout(numColumns, false));
93 | gr.setText(text);
94 | GridData gd = new GridData(horizontalAlignment, SWT.CENTER, true, false);
95 | gd.horizontalSpan = horizontalSpan;
96 | gr.setLayoutData(gd);
97 | return gr;
98 | }
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/internal/CMakeExecutionMarkerFactory.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2020 Martin Weber.
3 | *
4 | * This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License 2.0
6 | * which accompanies this distribution, and is available at
7 | * https://www.eclipse.org/legal/epl-2.0/
8 | *
9 | * SPDX-License-Identifier: EPL-2.0
10 | *******************************************************************************/
11 |
12 | package de.marw.cmake4eclipse.mbs.internal;
13 |
14 | import java.util.Map;
15 | import java.util.Map.Entry;
16 | import java.util.Objects;
17 |
18 | import org.eclipse.core.resources.IContainer;
19 | import org.eclipse.core.resources.IMarker;
20 | import org.eclipse.core.runtime.CoreException;
21 | import org.eclipse.core.runtime.IPath;
22 | import org.eclipse.core.runtime.IStatus;
23 | import org.eclipse.core.runtime.Path;
24 | import org.eclipse.core.runtime.Status;
25 |
26 | /**
27 | * Default implementation of {@code ICMakeExecutionMarkerFactory}.
28 | *
29 | * @author Martin Weber
30 | */
31 | public class CMakeExecutionMarkerFactory implements ICMakeExecutionMarkerFactory {
32 |
33 | private final IContainer srcFolder;
34 |
35 | /**
36 | * @param srcFolder source-folder of the project currently being build.
37 | *
38 | */
39 | public CMakeExecutionMarkerFactory(IContainer srcFolder) {
40 | this.srcFolder = Objects.requireNonNull(srcFolder);
41 | }
42 |
43 | @Override
44 | public final synchronized void createMarker(String message, int severity, String filePath, Map mandatoryAttributes)
45 | throws CoreException {
46 | IMarker marker;
47 | if (filePath == null) {
48 | marker = srcFolder.getProject().createMarker(CMAKE_PROBLEM_MARKER_ID);
49 | } else {
50 | // NOTE normally, cmake reports the file name relative to source root.
51 | // BUT some messages give an absolute file-system path which is problematic when the build
52 | // runs in a docker container
53 | // So we do some heuristics here...
54 | IPath path = new Path(filePath);
55 | try {
56 | // normal case: file is rel. to source root
57 | marker = srcFolder.getFile(path).createMarker(CMAKE_PROBLEM_MARKER_ID);
58 | } catch (CoreException ign) {
59 | // try abs. path
60 | IPath srcLocation = srcFolder.getLocation();
61 | if (srcLocation.isPrefixOf(path)) {
62 | // can resolve the cmake file
63 | int segmentsToRemove = srcLocation.segmentCount();
64 | path = path.removeFirstSegments(segmentsToRemove);
65 | marker = srcFolder.getFile(path).createMarker(CMAKE_PROBLEM_MARKER_ID);
66 | } else {
67 | // possibly a build in docker container. we would reach this if the source-dir path inside
68 | // the container is NOT the same as the one in the host/IDE.
69 | // for now, just add the markers to the source dir and lets users file issues:-)
70 | marker = srcFolder.createMarker(CMAKE_PROBLEM_MARKER_ID);
71 | Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID,
72 | String.format("Could not map %s to a workspace resource. Did the build run in a container?",
73 | // Messages.CMakeErrorParser_NotAWorkspaceResource
74 | filePath)));
75 | // Extra case: IDE runs on Linux, build runs on Windows, or vice versa...
76 | }
77 | }
78 | }
79 | marker.setAttribute(IMarker.MESSAGE, message);
80 | marker.setAttribute(IMarker.SEVERITY, severity);
81 | for (Entry elem : mandatoryAttributes.entrySet()) {
82 | marker.setAttribute(elem.getKey(), elem.getValue());
83 | }
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/settings/ConfigurationManager.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.settings;
10 |
11 | import java.util.WeakHashMap;
12 |
13 | import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
14 | import org.eclipse.core.runtime.CoreException;
15 |
16 | /**
17 | * Associates {@link ICConfigurationDescription} objects with our
18 | * CMakeSettings objects in order to avoid redundant de-serialization from
19 | * storage.
20 | *
21 | * @author Martin Weber
22 | */
23 | public final class ConfigurationManager {
24 | private static ConfigurationManager instance;
25 |
26 | /** caches CMakeSettings by ICConfigurationDescription.ID */
27 | private WeakHashMap map = new WeakHashMap<>(
28 | 2);
29 |
30 | /**
31 | * Singleton constructor.
32 | */
33 | private ConfigurationManager() {
34 | }
35 |
36 | /**
37 | * Gets the singleton instance.
38 | */
39 | public static synchronized ConfigurationManager getInstance() {
40 | if (instance == null)
41 | instance = new ConfigurationManager();
42 | return instance;
43 | }
44 |
45 | /**
46 | * Gets the {@code CMakeSettings} object associated with the specified
47 | * {@code ICConfigurationDescription}.
48 | *
49 | * @return the stored {@code CMakeSettings} object, or {@code null} if this
50 | * object contains no mapping for the configuration description
51 | */
52 | public CMakeSettings get(ICConfigurationDescription cfgd) {
53 | return map.get(cfgd.getId());
54 | }
55 |
56 | /**
57 | * Tries to get the {@code CMakeSettings} object associated with the
58 | * specified {@code ICConfigurationDescription}. If no
59 | * {@code CMakeSettings} object is found, a new one is created.
60 | *
61 | * @return the stored {@code CMakeSettings} object, or a newly created one
62 | * if this object contains no mapping for the configuration
63 | * description.
64 | */
65 | public CMakeSettings getOrCreate(ICConfigurationDescription cfgd) {
66 | CMakeSettings pref = get(cfgd);
67 | if (pref == null) {
68 | pref = new CMakeSettings();
69 | map.put(cfgd.getId(), pref);
70 | }
71 | return pref;
72 | }
73 |
74 | /**
75 | * Tries to get the {@code CMakeSettings} object associated with the
76 | * specified {@code ICConfigurationDescription}. If no
77 | * {@code CMakeSettings} object is found, a new one is created, then loaded
78 | * from its storage via {@link CMakeSettings#load}.
79 | *
80 | * @return the stored {@code CMakeSettings} object, or a freshly loaded one
81 | * if this object contains no mapping for the configuration
82 | * description.
83 | * @throws CoreException
84 | * if {@link ICConfigurationDescription#getStorage} throws a
85 | * CoreException.
86 | */
87 | public CMakeSettings getOrLoad(ICConfigurationDescription cfgd)
88 | throws CoreException {
89 | CMakeSettings pref = map.get(cfgd.getId());
90 | if (pref == null) {
91 | pref = new CMakeSettings();
92 | if (!cfgd.getProjectDescription().isCdtProjectCreating()) {
93 | // do not clobber default values when a project is creating
94 | pref.load(cfgd);
95 | }
96 | map.put(cfgd.getId(), pref);
97 | }
98 | return pref;
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/test/java/de/marw/cmake4eclipse/mbs/settings/CmakeGeneratorTest.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2018 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 |
10 | package de.marw.cmake4eclipse.mbs.settings;
11 |
12 | import static org.junit.Assert.*;
13 |
14 | import org.junit.Before;
15 | import org.junit.Test;
16 |
17 | /**
18 | * @author weber
19 | *
20 | */
21 | public class CmakeGeneratorTest {
22 |
23 | /**
24 | * @throws java.lang.Exception
25 | */
26 | @Before
27 | public void setUp() throws Exception {
28 | }
29 |
30 | /**
31 | * Test method for
32 | * {@link de.marw.cmake4eclipse.mbs.settings.CmakeGenerator#getParallelBuildArg(int)}.
33 | */
34 | @Test
35 | public void testGetParallelBuildArg_Off() {
36 | assertEquals(null, CmakeGenerator.UnixMakefiles.getParallelBuildArg(1));
37 | assertEquals("-j 1", CmakeGenerator.Ninja.getParallelBuildArg(1));
38 | assertEquals("-j1", CmakeGenerator.FastBuild.getParallelBuildArg(1));
39 | assertEquals(null, CmakeGenerator.MinGWMakefiles.getParallelBuildArg(1));
40 | assertEquals(null, CmakeGenerator.MSYSMakefiles.getParallelBuildArg(1));
41 | assertEquals(null, CmakeGenerator.NMakeMakefiles.getParallelBuildArg(1));
42 | assertEquals(null, CmakeGenerator.NMakeMakefilesJOM.getParallelBuildArg(1));
43 | assertEquals(null, CmakeGenerator.BorlandMakefiles.getParallelBuildArg(1));
44 | assertEquals(null, CmakeGenerator.WatcomWMake.getParallelBuildArg(1));
45 | }
46 |
47 | /**
48 | * Test method for
49 | * {@link de.marw.cmake4eclipse.mbs.settings.CmakeGenerator#getParallelBuildArg(int)}.
50 | */
51 | @Test
52 | public void testGetParallelBuildArg_Unlimited() {
53 | assertEquals("-j", CmakeGenerator.UnixMakefiles.getParallelBuildArg(Integer.MAX_VALUE));
54 | assertEquals("-j " + Integer.MAX_VALUE, CmakeGenerator.Ninja.getParallelBuildArg(Integer.MAX_VALUE));
55 | assertEquals("-j", CmakeGenerator.FastBuild.getParallelBuildArg(1));
56 | assertEquals("-j", CmakeGenerator.MinGWMakefiles.getParallelBuildArg(Integer.MAX_VALUE));
57 | assertEquals("-j", CmakeGenerator.MSYSMakefiles.getParallelBuildArg(Integer.MAX_VALUE));
58 | assertEquals(null, CmakeGenerator.NMakeMakefiles.getParallelBuildArg(Integer.MAX_VALUE));
59 | assertEquals("-j " + Integer.MAX_VALUE, CmakeGenerator.NMakeMakefilesJOM.getParallelBuildArg(Integer.MAX_VALUE));
60 | assertEquals(null, CmakeGenerator.BorlandMakefiles.getParallelBuildArg(Integer.MAX_VALUE));
61 | assertEquals(null, CmakeGenerator.WatcomWMake.getParallelBuildArg(Integer.MAX_VALUE));
62 | }
63 |
64 | /**
65 | * Test method for
66 | * {@link de.marw.cmake4eclipse.mbs.settings.CmakeGenerator#getParallelBuildArg(int)}.
67 | */
68 | @Test
69 | public void testGetParallelBuildArg_User() {
70 | int value = 123;
71 | assertEquals("-j " + value, CmakeGenerator.UnixMakefiles.getParallelBuildArg(value));
72 | assertEquals("-j " + value, CmakeGenerator.Ninja.getParallelBuildArg(value));
73 | assertEquals("-j" + value, CmakeGenerator.FastBuild.getParallelBuildArg(value));
74 | assertEquals("-j " + value, CmakeGenerator.MinGWMakefiles.getParallelBuildArg(value));
75 | assertEquals("-j " + value, CmakeGenerator.MSYSMakefiles.getParallelBuildArg(value));
76 | assertEquals(null, CmakeGenerator.NMakeMakefiles.getParallelBuildArg(value));
77 | assertEquals("-j " + value, CmakeGenerator.NMakeMakefilesJOM.getParallelBuildArg(value));
78 | assertEquals(null, CmakeGenerator.BorlandMakefiles.getParallelBuildArg(value));
79 | assertEquals(null, CmakeGenerator.WatcomWMake.getParallelBuildArg(value));
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/settings/CmakeDefine.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.settings;
10 |
11 | /**
12 | * Represents a cmake variable to define.
13 | *
14 | * @author Martin Weber
15 | */
16 | public class CmakeDefine implements Cloneable {
17 | private CmakeVariableType type;
18 | private String name;
19 | private String value;
20 |
21 | /**
22 | * Creates a new object with type STRING and an empty value.
23 | *
24 | * @param name
25 | * the variable name, must not be empty.
26 | * @throws IllegalArgumentException
27 | * if {@code name} is empty
28 | * @throws NullPointerException
29 | * if {@code name} is {@code null}
30 | */
31 | public CmakeDefine(String name) {
32 | this(name, CmakeVariableType.STRING, "");
33 | }
34 |
35 | /**
36 | * Creates a new object with the specified values.
37 | *
38 | * @param name
39 | * the variable name, must not be empty.
40 | * @param type
41 | * the variable type.
42 | * @param value
43 | * the value of the variable, may be empty
44 | * @throws IllegalArgumentException
45 | * if {@code name} is empty
46 | * @throws NullPointerException
47 | * if {@code name} or {@code type} is {@code null}
48 | */
49 | public CmakeDefine(String name, CmakeVariableType type, String value) {
50 | if (type == null) {
51 | throw new NullPointerException("type");
52 | }
53 |
54 | setName(name);
55 | setType(type);
56 | this.value = value == null ? "" : value;
57 | }
58 |
59 | /**
60 | * Gets the type.
61 | *
62 | * @return the current type.
63 | */
64 | public CmakeVariableType getType() {
65 | return this.type;
66 | }
67 |
68 | /**
69 | * Sets the type.
70 | *
71 | * @throws NullPointerException
72 | * if {@code type} is {@code null}
73 | */
74 | public void setType(CmakeVariableType type) {
75 | if (type == null) {
76 | throw new NullPointerException("type");
77 | }
78 | this.type = type;
79 | }
80 |
81 | /**
82 | * Gets the name property.
83 | *
84 | * @return the current name property.
85 | */
86 | public String getName() {
87 | return this.name;
88 | }
89 |
90 | /**
91 | * Sets the name property.
92 | *
93 | * @throws IllegalArgumentException
94 | * if {@code name} is empty
95 | * @throws NullPointerException
96 | * if {@code name} is {@code null}
97 | */
98 | public void setName(String name) {
99 | if (name == null) {
100 | throw new NullPointerException("name");
101 | }
102 | if (name.length() == 0) {
103 | throw new IllegalArgumentException("name");
104 | }
105 | this.name = name;
106 | }
107 |
108 | /**
109 | * Gets the value.
110 | *
111 | * @return the current value.
112 | */
113 | public String getValue() {
114 | return this.value;
115 | }
116 |
117 | /**
118 | * Sets the value.
119 | *
120 | * @throws NullPointerException
121 | * if {@code value} is {@code null}
122 | */
123 | public void setValue(String value) {
124 | if (value == null) {
125 | throw new NullPointerException("value");
126 | }
127 | this.value = value;
128 | }
129 |
130 | public String toString() {
131 | return name + ":" + type + "=" + value;
132 | }
133 |
134 | @Override
135 | public CmakeDefine clone() {
136 | try {
137 | return (CmakeDefine) super.clone();
138 | } catch (CloneNotSupportedException ex) { // ignore
139 | return null;
140 | }
141 | }
142 | }
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/cmakecache/SimpleCMakeCacheTxt.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.cmakecache;
10 |
11 | import java.io.File;
12 | import java.io.FileInputStream;
13 | import java.io.IOException;
14 | import java.io.InputStream;
15 | import java.util.ArrayList;
16 | import java.util.Collections;
17 | import java.util.HashSet;
18 | import java.util.List;
19 | import java.util.Set;
20 |
21 | /**
22 | * Represents a simplistic subset of the parsed content of a CMake cache file
23 | * (CMakeCache.txt).
24 | *
25 | * @author Martin Weber
26 | */
27 | public class SimpleCMakeCacheTxt {
28 |
29 | private String buildTool;
30 | private List tools;
31 | private List commands;
32 |
33 | /**
34 | * Creates a new object by parsing the specified file.
35 | *
36 | * @param file
37 | * the file to parse.
38 | * @throws IOException
39 | * if the file could not be read
40 | */
41 | public SimpleCMakeCacheTxt(File file) throws IOException {
42 | ArrayList tools = new ArrayList();
43 | ArrayList commands = new ArrayList();
44 |
45 | // parse CMakeCache.txt...
46 | InputStream is = null;
47 | try {
48 | is = new FileInputStream(file);
49 | final Set entries = new HashSet();
50 | new CMakeCacheFileParser().parse(is, null, entries, null);
51 | for (SimpleCMakeCacheEntry entry : entries) {
52 | final String toolKey = entry.getKey();
53 | final String tool = entry.getValue();
54 | if ("CMAKE_MAKE_PROGRAM".equals(toolKey) ||
55 | "CMAKE_BUILD_TOOL".equals(toolKey) // deprecated since cmake 3.0
56 | ) {
57 | buildTool = tool;
58 | } else if ("CMAKE_COMMAND".equals(toolKey)) {
59 | commands.add(tool);
60 | } else if ("CMAKE_CPACK_COMMAND".equals(toolKey)) {
61 | commands.add(tool);
62 | } else if ("CMAKE_CTEST_COMMAND".equals(toolKey)) {
63 | commands.add(tool);
64 | } else if ("CMAKE_C_COMPILER".equals(toolKey)) {
65 | tools.add(tool);
66 | } else if ("CMAKE_CXX_COMPILER".equals(toolKey)) {
67 | tools.add(tool);
68 | }
69 | }
70 | this.tools = Collections.unmodifiableList(tools);
71 | this.commands = Collections.unmodifiableList(commands);
72 | } finally {
73 | if (is != null) {
74 | try {
75 | is.close();
76 | } catch (IOException ignore) {
77 | }
78 | }
79 | }
80 | }
81 |
82 | /**
83 | * Gets the name of the tool that processes the generated build scripts. In
84 | * most cases, this method will return the absolute file system path of the
85 | * tool, such as {@code /usr/bin/make}.
86 | *
87 | * @return the CMAKE_BUILD_TOOL entry from the CMakeCache.txt file or
88 | * {@code null} if the file could not be parsed
89 | */
90 | public String getBuildTool() {
91 | return buildTool;
92 | }
93 |
94 | /**
95 | * Gets the tools that process the source files to binary files (compilers,
96 | * linkers). In most cases, this method will return the absolute file system
97 | * paths of a tool, for example {@code /usr/bin/cc}.
98 | */
99 | public List getTools() {
100 | return tools;
101 | }
102 |
103 | /**
104 | * Gets the tools provided by CMake itself (cmake, cpack, ctest). In most
105 | * cases, this method will return the absolute file system paths of a tool.
106 | */
107 | public List getCmakeCommands() {
108 | return commands;
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/preferences/PreferenceAccess.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2021 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.preferences;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | import org.eclipse.core.runtime.preferences.IEclipsePreferences;
15 | import org.eclipse.core.runtime.preferences.InstanceScope;
16 |
17 | import com.google.gson.Gson;
18 | import com.google.gson.GsonBuilder;
19 | import com.google.gson.reflect.TypeToken;
20 |
21 | import de.marw.cmake4eclipse.mbs.internal.Activator;
22 |
23 | /**
24 | * Constant definitions for plug-in workbench preferences.
25 | */
26 | public abstract class PreferenceAccess {
27 | /** preference key for the 'verbose build' boolean */
28 | public static final String VERBOSE_BUILD = "VERBOSE_BUILD";
29 | /** preference key for the 'use cmake from path' boolean */
30 | // public static final String CMAKE_FROM_PATH = "CMAKE_FROM_PATH";
31 | /** preference key for the path to the cmake executable file */
32 | // public static final String CMAKE_EXECUTABLE = "CMAKE_EXECUTABLE";
33 |
34 | /** preference key for the 'run cmake on each build' boolean */
35 | public static final String CMAKE_FORCE_RUN = "CMAKE_FORCE_RUN";
36 | /** preference key for the -Wno-dev commandline option */
37 | public static final String CMAKE_WARN_NO_DEV = "CMAKE_WARN_NO_DEV";
38 | /** preference key for the --debug-trycompile commandline option */
39 | public static final String CMAKE_DBG_TRY_COMPILE = "CMAKE_DBG_TRY_COMPILE";
40 | /** preference key for the --debug-output commandline option */
41 | public static final String CMAKE_DBG = "CMAKE_DBG";
42 | /** preference key for the --trace commandline option */
43 | public static final String CMAKE_TRACE = "CMAKE_TRACE";
44 | /** preference key for the --warn-uninitializedv commandline option */
45 | public static final String CMAKE_WARN_UNINITIALIZED = "CMAKE_WARN_UNINITIALIZED";
46 | /** preference key for the --no-warn-unused-cli commandline option */
47 | public static final String CMAKE_NO_WARN_UNUSED = "CMAKE_NO_WARN_UNUSED";
48 |
49 | /** preference key for the list of cache entries to pass to cmake */
50 | public static final String CMAKE_CACHE_ENTRIES = "CMAKE_CACHE_ENTRIES";
51 | /** preference key for the default build system to generate scripts for */
52 | public static final String CMAKE_GENERATOR = "CMAKE_GENERATOR";
53 |
54 | /** preference key for the list of defined build tool kits */
55 | public static final String TOOLKITS = "TOOLKITS";
56 | /**
57 | * UID of the build tool kit that overwrites the default build settings or zero if no overwrite is configured. Falls
58 | * back to 'no overwrite' behavior if no defined build tool kit of the given UID exists.
59 | */
60 | public static final String TOOLKIT_OVERWRITES = "TOOLKIT_OVERWRITE_UID";
61 |
62 | /** preference key for the 'dirty' time stamp (in milliseconds) */
63 | public static final String DIRTY_TS = "DIRTY_TS";
64 |
65 | /**
66 | * Returns this plugin`s preferences.
67 | */
68 | public static final IEclipsePreferences getPreferences() {
69 | return InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
70 | }
71 |
72 | /**
73 | * Converts the specified list of objects to a JSON string.
74 | */
75 | public static String toJsonFromList(List> objects) {
76 | Gson gson = new GsonBuilder().disableHtmlEscaping().create();
77 | return gson.toJson(objects);
78 | }
79 |
80 | /**
81 | * Converts the specified JSON string to a list of objects.
82 | *
83 | * @param json the JSON string to convert.
84 | * @param the type of the objects in the returned list
85 | */
86 | public static List toListFromJson(Class classOfE, String json) {
87 | TypeToken> tt = TypeToken.getParameterized(List.class, classOfE);
88 | Gson gson = new GsonBuilder().disableHtmlEscaping().create();
89 | List entries = gson.fromJson(json, tt.getType());
90 | if (entries == null) {
91 | entries = new ArrayList();
92 | }
93 | return entries;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/nature/C4ENature.java:
--------------------------------------------------------------------------------
1 | /* ******************************************************************************
2 | * Copyright (c) 2021 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.nature;
10 |
11 | import java.util.ArrayList;
12 | import java.util.Arrays;
13 | import java.util.Iterator;
14 | import java.util.List;
15 |
16 | import org.eclipse.cdt.build.core.scannerconfig.ScannerConfigBuilder;
17 | import org.eclipse.cdt.core.CCProjectNature;
18 | import org.eclipse.cdt.core.CProjectNature;
19 | import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
20 | import org.eclipse.core.resources.ICommand;
21 | import org.eclipse.core.resources.IProject;
22 | import org.eclipse.core.resources.IProjectDescription;
23 | import org.eclipse.core.resources.IProjectNature;
24 | import org.eclipse.core.resources.IncrementalProjectBuilder;
25 | import org.eclipse.core.runtime.CoreException;
26 | import org.eclipse.core.runtime.IProgressMonitor;
27 | import org.eclipse.core.runtime.NullProgressMonitor;
28 |
29 | import de.marw.cmake4eclipse.mbs.internal.Activator;
30 |
31 | /**
32 | * A project nature required to show a reduced MBS GUI to avoid end-user confusion on lots of things to configure which
33 | * have no effect when building with cmake.
34 | *
35 | * @author Martin Weber
36 | */
37 | public class C4ENature implements IProjectNature {
38 | public static final String NATURE_ID = "de.marw.cmake4eclipse.mbs.cmake4eclipsenature"; // $NON-NLS-1$
39 |
40 | private IProject project;
41 |
42 | /** extension id of the cmake-generated makefile builder */
43 | public static final String BUILDER_ID = Activator.PLUGIN_ID + ".genscriptbuilder"; //$NON-NLS-1$
44 |
45 | /**
46 | * Sets the natures of the specified project.
47 | *
48 | * @throws CoreException
49 | */
50 | public static void setNatures(IProject project, IProgressMonitor monitor) throws CoreException {
51 | IProjectDescription description = project.getDescription();
52 | String[] newNatures = { NATURE_ID, CProjectNature.C_NATURE_ID, CCProjectNature.CC_NATURE_ID };
53 | description.setNatureIds(newNatures);
54 | project.setDescription(description, monitor);
55 | }
56 |
57 | @Override
58 | public void configure() throws CoreException {
59 | IProgressMonitor monitor = new NullProgressMonitor();
60 | addBuilders(monitor);
61 | }
62 |
63 | private void addBuilders(IProgressMonitor monitor) throws CoreException {
64 | IProjectDescription description = project.getDescription();
65 |
66 | ICommand bldrCommand = description.newCommand();
67 | bldrCommand.setBuilderName(BUILDER_ID);
68 | // do not run on each resource delta change..
69 | bldrCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, false);
70 |
71 | List commands = new ArrayList<>(Arrays.asList(description.getBuildSpec()));
72 | commands.add(0, bldrCommand);
73 |
74 | ICommand[] cmds = commands.stream().filter(c -> !ManagedCProjectNature.BUILDER_ID.equals(c.getBuilderName()))
75 | .filter(c -> !ScannerConfigBuilder.BUILDER_ID.equals(c.getBuilderName())).distinct().toArray(ICommand[]::new);
76 | description.setBuildSpec(cmds);
77 | project.setDescription(description, monitor);
78 | }
79 |
80 | @Override
81 | public void deconfigure() throws CoreException {
82 | IProjectDescription description = project.getDescription();
83 | List commands = new ArrayList<>(Arrays.asList(description.getBuildSpec()));
84 | for (Iterator iter = commands.iterator(); iter.hasNext();) {
85 | ICommand iCommand = iter.next();
86 | if (BUILDER_ID.equals(iCommand.getBuilderName())) {
87 | iter.remove();
88 | break;
89 | }
90 | }
91 | ICommand[] cmds = commands.stream().distinct().toArray(ICommand[]::new);
92 | description.setBuildSpec(cmds);
93 | project.setDescription(description, null);
94 | }
95 |
96 | @Override
97 | public IProject getProject() {
98 | return project;
99 | }
100 |
101 | @Override
102 | public void setProject(IProject project) {
103 | this.project = project;
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/internal/BuildToolKitUtil.java:
--------------------------------------------------------------------------------
1 | /* ******************************************************************************
2 | * Copyright (c) 2021 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.internal;
10 |
11 | import java.util.Iterator;
12 | import java.util.List;
13 | import java.util.Map;
14 | import java.util.Map.Entry;
15 | import java.util.Optional;
16 | import java.util.function.Predicate;
17 |
18 | import org.eclipse.cdt.core.CCorePlugin;
19 | import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
20 | import org.eclipse.core.runtime.CoreException;
21 | import org.eclipse.core.runtime.Platform;
22 | import org.eclipse.core.runtime.Status;
23 | import org.eclipse.core.runtime.preferences.IEclipsePreferences;
24 |
25 | import com.google.gson.JsonSyntaxException;
26 |
27 | import de.marw.cmake4eclipse.mbs.preferences.BuildToolKitDefinition;
28 | import de.marw.cmake4eclipse.mbs.preferences.PreferenceAccess;
29 | import de.marw.cmake4eclipse.mbs.settings.CmakeGenerator;
30 |
31 | /**
32 | * @author weber
33 | */
34 | class BuildToolKitUtil {
35 |
36 | /**
37 | * @param prefs
38 | * @return
39 | */
40 | static CmakeGenerator getEffectiveCMakeGenerator(IEclipsePreferences prefs,
41 | Optional overwritingToolkit) {
42 | if (overwritingToolkit.isPresent()) {
43 | return overwritingToolkit.map(e -> e.getGenerator()).get();
44 | } else {
45 | String genName = prefs.get(PreferenceAccess.CMAKE_GENERATOR, CmakeGenerator.Ninja.name());
46 | return CmakeGenerator.valueOf(genName);
47 | }
48 | }
49 |
50 | static Optional getOverwritingToolkit(IEclipsePreferences prefs) throws JsonSyntaxException {
51 | long ovr = prefs.getLong(PreferenceAccess.TOOLKIT_OVERWRITES, 0);
52 | if (ovr != 0) {
53 | // overwrite is active
54 | String json = prefs.get(PreferenceAccess.TOOLKITS, null);
55 | List entries = PreferenceAccess.toListFromJson(BuildToolKitDefinition.class, json);
56 | if (entries != null) {
57 | return entries.stream().filter(e -> e.getUid() == ovr).findFirst();
58 | }
59 | }
60 | return Optional.empty();
61 | }
62 |
63 | /**
64 | * Replaces the PATH entry in the specified map with the value from the overwriting build tool kit, if any is
65 | * overwriting.
66 | *
67 | * @throws CdtVariableException if expansion of the PATH variable fails
68 | *
69 | * @see BuildToolKitDefinition#getPath()
70 | */
71 | static void replacePathVarFromBuildToolKit(Map environment)
72 | throws CdtVariableException, CoreException {
73 | IEclipsePreferences prefs = PreferenceAccess.getPreferences();
74 | try {
75 | Optional overwritingBtk = BuildToolKitUtil.getOverwritingToolkit(prefs);
76 | // replace $PATH, if necessary
77 | if (overwritingBtk.isPresent()) {
78 | BuildToolKitDefinition buildToolKitDefinition = overwritingBtk.get();
79 | // PATH is overwritten...
80 | Predicate isPATH = n -> false;
81 | if (Platform.OS_WIN32.equals(Platform.getOS())) {
82 | // windows which has case-insensitive envvar names, e.g. 'pAth'
83 | isPATH = n -> "PATH".equalsIgnoreCase(n);
84 | } else {
85 | isPATH = n -> "PATH".equals(n);
86 | }
87 |
88 | for (Iterator> iter = environment.entrySet().iterator(); iter.hasNext();) {
89 | Entry entry = iter.next();
90 | String key = entry.getKey();
91 | if (isPATH.test(key)) {
92 | // replace the value of $PATH with the value specified in the overwriting build tool kit
93 | String newPath = CCorePlugin.getDefault().getCdtVariableManager()
94 | .resolveValue(buildToolKitDefinition.getPath(), "", null, null);
95 | entry.setValue(newPath);
96 | break;
97 | }
98 | }
99 | }
100 | } catch (JsonSyntaxException ex) {
101 | // workbench preferences file format error
102 | throw new CoreException(Status.error("Error loading workbench preferences", ex));
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/settings/CmakeGenerator.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014-2018 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.settings;
10 |
11 | /**
12 | * Represents a cmake build-script generator including information about the
13 | * makefile (build-script) processor that builds from the generated script.
14 | *
15 | * @author Martin Weber
16 | */
17 | public enum CmakeGenerator {
18 | /*
19 | * Implementation Note: Please do not include generators for IDE project files,
20 | * such as "Eclipse CDT4 - Unix Makefiles".
21 | */
22 |
23 | // linux generators
24 | UnixMakefiles("Unix Makefiles"),
25 | // Ninja
26 | Ninja("Ninja", "-k 0") {
27 | @Override
28 | public String getMakefileName(){
29 | return "build.ninja";
30 | }
31 | @Override
32 | public String getParallelBuildArg(int parallelizationNum) {
33 | if (parallelizationNum == 1)
34 | return "-j 1"; // No parallel
35 | else
36 | return "-j " + parallelizationNum; // Unlimited or User specified
37 | }
38 | },
39 | FastBuild("FASTBuild", "-nostoponerror") {
40 | @Override
41 | public String getMakefileName(){
42 | return "fbuild.bff";
43 | }
44 | @Override
45 | public String getParallelBuildArg(int parallelizationNum) {
46 | if (parallelizationNum == 1)
47 | return "-j1"; // No parallel
48 | else if (parallelizationNum == Integer.MAX_VALUE)
49 | return "-j"; // Unlimited
50 | else
51 | return "-j" + parallelizationNum; // User specified
52 | }
53 | },
54 | // windows generators
55 | NMakeMakefilesJOM("NMake Makefiles JOM") {
56 | @Override
57 | public String getParallelBuildArg(int parallelizationNum) {
58 | if (parallelizationNum == 1)
59 | return null; // No parallel
60 | else
61 | return "-j " + parallelizationNum; // Unlimited or User specified
62 | }
63 | },
64 | MinGWMakefiles("MinGW Makefiles"), MSYSMakefiles("MSYS Makefiles"), NMakeMakefiles("NMake Makefiles") {
65 | @Override
66 | public String getParallelBuildArg(int parallelizationNum) {
67 | return null; // parallel build not supported
68 | }
69 | },
70 | BorlandMakefiles("Borland Makefiles") {
71 | @Override
72 | public String getParallelBuildArg(int parallelizationNum) {
73 | return null; // parallel build not supported
74 | }
75 | },
76 | WatcomWMake("Watcom WMake") {
77 | @Override
78 | public String getParallelBuildArg(int parallelizationNum) {
79 | return null; // parallel build not supported
80 | }
81 | };
82 |
83 | private final String name;
84 | private String ignoreErrOption;
85 |
86 | private CmakeGenerator(String name,
87 | String ignoreErrOption) {
88 | this.name = name;
89 | this.ignoreErrOption = ignoreErrOption;
90 | }
91 |
92 | private CmakeGenerator(String name) {
93 | this(name, "-k");
94 | }
95 |
96 | /**
97 | * Gets the cmake argument that specifies the build-script generator.
98 | *
99 | * @return a non-empty string, which must be a valid argument for cmake's -G
100 | * option.
101 | */
102 | public String getCmakeName() {
103 | return name;
104 | }
105 |
106 | /**
107 | * Gets the name of the top-level makefile (build-script) which is interpreted
108 | * by the build-script processor.
109 | *
110 | * @return name of the makefile.
111 | */
112 | public String getMakefileName(){
113 | return "Makefile";
114 | }
115 |
116 | /**
117 | * Gets the build-script processor´s command argument(s) to ignore build errors.
118 | *
119 | * @return the command option string or {@code null} if no argument is needed.
120 | */
121 | public String getIgnoreErrOption() {
122 | return ignoreErrOption;
123 | }
124 |
125 | /**
126 | * Gets the build-script processor´s command argument(s) to run parallel jobs
127 | * in the build. This default implementation returns the argument as specified
128 | * for the {@code GNU make} tool.
129 | *
130 | * @param parallelizationNum
131 | * the number of parallel jobs to run. This is encoded as follows:
132 | *
133 | *
No parallel: 1
134 | *
Unlimited: Integer.MAX_VALUE
135 | *
User specified: >0 (positive number)
136 | *
137 | * @return the command option string or {@code null} if no argument is needed.
138 | */
139 | public String getParallelBuildArg(int parallelizationNum) {
140 | if (parallelizationNum == 1)
141 | return null; // No parallel
142 | else if (parallelizationNum == Integer.MAX_VALUE)
143 | return "-j"; // Unlimited
144 | else
145 | return "-j " + parallelizationNum; // User specified
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/AddCmakeUndefineDialog.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.ui;
10 |
11 | import org.eclipse.jface.dialogs.Dialog;
12 | import org.eclipse.jface.dialogs.IDialogConstants;
13 | import org.eclipse.jface.dialogs.IDialogSettings;
14 | import org.eclipse.swt.SWT;
15 | import org.eclipse.swt.events.ModifyEvent;
16 | import org.eclipse.swt.events.ModifyListener;
17 | import org.eclipse.swt.layout.GridData;
18 | import org.eclipse.swt.layout.GridLayout;
19 | import org.eclipse.swt.widgets.Button;
20 | import org.eclipse.swt.widgets.Composite;
21 | import org.eclipse.swt.widgets.Control;
22 | import org.eclipse.swt.widgets.Label;
23 | import org.eclipse.swt.widgets.Shell;
24 | import org.eclipse.swt.widgets.Text;
25 |
26 | import de.marw.cmake4eclipse.mbs.settings.CmakeUnDefine;
27 |
28 | /**
29 | * The dialog used to create or edit a cmake undefine.
30 | *
31 | * @author Martin Weber
32 | */
33 | public class AddCmakeUndefineDialog extends Dialog {
34 |
35 | private static final String DIALOG_SETTINGS_SECT = "dlg_addCmakeUndefine";
36 |
37 | /**
38 | * the variable to edit or {@code null} if a new variable is going to be
39 | * created.
40 | */
41 | private CmakeUnDefine editedVar;
42 |
43 | private Text variableName;
44 |
45 | /**
46 | * Creates a dialog. If a variable to edit is specified, it will be modified
47 | * in-place when the OK button is pressed. It will remain unchanged, if the
48 | * dialog is cancelled.
49 | *
50 | * @param parentShell
51 | * @param editedVar
52 | * the variable to edit or {@code null} if a new variable is going to
53 | * be created.
54 | * @see #getCmakeUndefine()
55 | */
56 | public AddCmakeUndefineDialog(Shell parentShell, CmakeUnDefine editedVar) {
57 | super(parentShell);
58 | setShellStyle(SWT.SHELL_TRIM | SWT.PRIMARY_MODAL);
59 | this.editedVar = editedVar;
60 | }
61 |
62 | /**
63 | * Gets the edited or newly created cmake define.
64 | *
65 | * @return the modified or new CmakeDefine or {@code null} if this dialog has
66 | * been cancelled.
67 | */
68 | public CmakeUnDefine getCmakeUndefine() {
69 | return editedVar;
70 | }
71 |
72 | @Override
73 | protected void configureShell(Shell shell) {
74 | super.configureShell(shell);
75 | if (editedVar != null)
76 | shell.setText("Edit existing CMake Undefine");
77 | else
78 | shell.setText("Add new CMake Undefine");
79 | }
80 |
81 | /**
82 | * Overridden to read out the widgets before these get disposed.
83 | */
84 | @Override
85 | protected void okPressed() {
86 | if (editedVar != null) {
87 | editedVar.setName(variableName.getText().trim());
88 | } else {
89 | editedVar = new CmakeUnDefine(variableName.getText());
90 | }
91 | super.okPressed();
92 | }
93 |
94 | /**
95 | * Create contents of the dialog.
96 | *
97 | * @param parent
98 | */
99 | @Override
100 | protected Control createDialogArea(Composite parent) {
101 | Composite comp = (Composite) super.createDialogArea(parent);
102 | ((GridLayout) comp.getLayout()).numColumns = 2;
103 |
104 | Label nameLabel = new Label(comp, SWT.NONE);
105 | nameLabel.setText("Variable &name:");
106 | GridData gd_nameLabel = new GridData();
107 | gd_nameLabel.horizontalAlignment = SWT.LEFT;
108 | nameLabel.setLayoutData(gd_nameLabel);
109 |
110 | variableName = new Text(comp, SWT.BORDER);
111 | // disable OK button if variable name is empty..
112 | variableName.addModifyListener(new ModifyListener() {
113 | @Override
114 | public void modifyText(ModifyEvent e) {
115 | final boolean enable = ((Text) e.widget).getText().trim().length() > 0;
116 | final Button button = getButton(IDialogConstants.OK_ID);
117 | button.setEnabled(enable);
118 | }
119 | });
120 | variableName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
121 |
122 | return comp;
123 | }
124 |
125 | /**
126 | * Overridden to set the sensitivity of the dialog's OK-button.
127 | */
128 | @Override
129 | protected Control createContents(Composite parent) {
130 | final Control control = super.createContents(parent);
131 | updateDisplay();
132 | return control;
133 | }
134 |
135 | /**
136 | * Updates displayed values according to the variable to edit.
137 | */
138 | private void updateDisplay() {
139 | if (editedVar == null) {
140 | // create a new define
141 | variableName.setText("");
142 | } else {
143 | variableName.setText(editedVar.getName());
144 | }
145 | }
146 |
147 | /*-
148 | * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
149 | */
150 | @Override
151 | protected IDialogSettings getDialogBoundsSettings() {
152 | IDialogSettings settings = Activator.getDefault().getDialogSettings();
153 | IDialogSettings section = settings.getSection(DIALOG_SETTINGS_SECT);
154 | if (section == null) {
155 | section = settings.addNewSection(DIALOG_SETTINGS_SECT);
156 | }
157 | return section;
158 | }
159 |
160 | }
161 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs/src/main/java/de/marw/cmake4eclipse/mbs/preferences/BuildToolKitDefinition.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2021 Martin Weber.
3 | *
4 | * Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 "EPL".
5 | * A copy of the EPL is available at http://www.eclipse.org/legal/epl-2.0.
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package de.marw.cmake4eclipse.mbs.preferences;
10 |
11 | import java.util.Objects;
12 |
13 | import org.eclipse.jdt.annotation.Nullable;
14 |
15 | import de.marw.cmake4eclipse.mbs.settings.CmakeGenerator;
16 |
17 | /**
18 | * Represents a cmake build tool kit. A build tool kit is comprised of a build-system type (specified through name of
19 | * the generator that cmake will use to generated the scripts) plus a path, that is: a list of directories where
20 | * executable files are looked up from.
21 | *
22 | * @author Martin Weber
23 | */
24 | public class BuildToolKitDefinition {
25 | private static long lastUsedID;
26 | private long uid;
27 | private String name;
28 | private String path;
29 | private CmakeGenerator generator;
30 | private boolean externalCmake;
31 | private String externalCmakeFile;
32 |
33 | /**
34 | * Creates a new object with the specified values.
35 | *
36 | * @param name the name
37 | * @param generator the generator to use for build-system generation
38 | * @param path the path of the build tool kit
39 | *
40 | * @throws NullPointerException if {@code name} or {@code generator} is {@code null}
41 | */
42 | public BuildToolKitDefinition(long uid, String name, CmakeGenerator generator, String path) {
43 | setName(name);
44 | setGenerator(generator);
45 | this.path = path == null ? "" : path;
46 | this.uid = uid;
47 | }
48 |
49 | /**
50 | * Creates a new object from the specified template assigning it a new unique ID.
51 | */
52 | public BuildToolKitDefinition(BuildToolKitDefinition template) {
53 | this(createUniqueId(), template.name, template.generator, template.path);
54 | this.externalCmake = template.externalCmake;
55 | this.externalCmakeFile = template.externalCmakeFile;
56 | }
57 |
58 | /**
59 | * @return the uid
60 | */
61 | public long getUid() {
62 | return uid;
63 | }
64 |
65 | /**
66 | * Gets the name property.
67 | *
68 | * @return the current name property.
69 | */
70 | public String getName() {
71 | return this.name;
72 | }
73 |
74 | /**
75 | * Sets the name property.
76 | *
77 | * @throws NullPointerException if {@code name} is {@code null}
78 | */
79 | public void setName(String name) {
80 | this.name = Objects.requireNonNull(name, "name");
81 | }
82 |
83 | /**
84 | * Gets the generator to use for build-system generation.
85 | */
86 | public CmakeGenerator getGenerator() {
87 | return generator;
88 | }
89 |
90 | /**
91 | * Sets the generator to use for build-system generation
92 | *
93 | * @param generator the generator to set
94 | */
95 | public void setGenerator(CmakeGenerator generator) {
96 | this.generator = Objects.requireNonNull(generator, "generator");
97 | }
98 |
99 | /**
100 | * Gets the path where executable files are looked up from.
101 | *
102 | * @return the current path.
103 | */
104 | public String getPath() {
105 | return this.path;
106 | }
107 |
108 | /**
109 | * Sets the path executable files are looked up from.
110 | *
111 | * @throws NullPointerException if {@code path} is {@code null}
112 | */
113 | public void setPath(String value) {
114 | if (value == null) {
115 | throw new NullPointerException("path");
116 | }
117 | this.path = value;
118 | }
119 |
120 | /**
121 | * Sets whether to use an external cmake executable. An external executable is a file that is not picked up from the
122 | * path specified in the toolkit definition.
123 | *
124 | * @return true if an external cmake executable should be use, otherwise false
125 | * @see #getPath()
126 | */
127 | public boolean isExternalCmake() {
128 | return externalCmake;
129 | }
130 |
131 | /**
132 | * Gets whether to use an external cmake executable.
133 | *
134 | * @see #setExternalCmake(boolean)
135 | */
136 | public void setExternalCmake(boolean externalCmake) {
137 | this.externalCmake = externalCmake;
138 | }
139 |
140 | /**
141 | * Gets the absolute file system path of the external cmake executable. An external executable is a file that is not
142 | * picked up from the path specified in the toolkit definition.
143 | *
144 | * @return the absolute file system path of the external cmake executable or null if none is specified
145 | */
146 | @Nullable
147 | public String getExternalCmakeFile() {
148 | return externalCmakeFile;
149 | }
150 |
151 | /**
152 | * Sets the absolute file system path of the external cmake executable
153 | *
154 | * @param the absolute file system path of the external cmake executable or null. Must not be
155 | * null if {@link #isExternalCmake()} return true
156 | */
157 | public void setExternalCmakeFile(@Nullable String externalCmakePath) {
158 | this.externalCmakeFile = externalCmakePath;
159 | }
160 |
161 | @Override
162 | public String toString() {
163 | return name + ", " + path;
164 | }
165 |
166 | /**
167 | * Find a unique build tool kit id.
168 | */
169 | public static long createUniqueId() {
170 | long id;
171 | for (;;) {
172 | id = System.currentTimeMillis();
173 | if (id != lastUsedID) {
174 | break;
175 | }
176 | try {
177 | Thread.sleep(1);
178 | } catch (InterruptedException ignore) {
179 | }
180 | }
181 | lastUsedID = id;
182 | return id;
183 | }
184 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [Change Log](CHANGELOG.md) |
2 | [Install...](#installation) |
3 | [](http://groups.google.com/d/forum/cmake4eclipse-users)
4 | [](https://github.com/15knots/cmake4eclipse/actions/workflows/maven.yml)
5 | [](https://github.com/15knots/cmake4eclipse/issues)
6 |
7 |
8 | ## Abstract
9 | This Eclipse plug-in automatically generates build-scripts for the Eclipse CDT managed build system from CMake scripts.
10 | Its *Primary claim* is: Co-workers should be able to just **check out the source and build** the project.
11 |
12 | ## Important notice to users that upgrade to version 5.0.x
13 | Since CDT 11.4 broke [compatibility](https://github.com/15knots/cmake4eclipse/issues/198) of this plugin
14 | it may be necessary delete the Eclipse projects using this plugin and re-create each project from scratch. Please delete the `.cproject` file before re-creating.
15 |
16 | ## Design goals
17 | 1. **Automatic** generation of build scripts. See [Primary claim](#pc): No need to **manually** invoke cmake: Cmake options are persisted in the Eclipse project settings files.
18 | 1. Cmake is a cross-platform build tool. So Eclipse projects [should be cross-platform](#pc) as feasible; without the need for co-workers to adjust Eclipse project settings just to build on **their** platform.
19 | 1. Take the CMakeLists.txt as the source of truth.
20 | - Auto-detect the actual build tool to invoke: make, ninja, nmake, MinGW make, MSYS make, ...
21 | - Easy project configuration regarding code completion, symbol-declaration lookup and macro-value tool-tips in the source editor.
22 | - Feed include paths and pre-processor symbols from cmake to the CDT-Indexer (CMake Compilation DB).
23 | - Retrieve compiler-built-in pre-processor symbols and include paths by interrogating the actual compiler and feed these to the CDT-Indexer (CMake Compilation DB). Well, at least as the compiler supports that (GNU C and `nvcc` CUDA compilers do so).
24 |
25 | ## Quick start
26 | 1. If you do not have any existing code, check out the [Sample Projects](https://github.com/15knots/cmake4eclipse-sample-projects), choose one and fill in your code.
27 | 1. If you have an existing C/C++ project code, inside Eclipse, goto `Help:Help Contents`, then read the `Cmake4eclipse User Guide:Tasks` nodes.
28 |
29 | ---
30 | ## License
31 | The plugin is licensed under the Eclipse Public License Version 2.0 ("EPL-2.0").
32 |
33 | ## System Requirements
34 | - CDT v 11.4 or newer and Eclipse v 2023-12 or newer.
35 | - Java 17 or newer.
36 |
37 | ## Installation
38 | The easiest way is to drag this:
39 | to your running Eclipse workbench.
40 |
41 | Alternatively, **cmake4eclipse** can be installed into Eclipse using the "Install New Software..." dialog and entering the update site URL listed below.
42 |
43 | ### Update Site
44 | This composite update site is for use in a Eclipse workbench and contains the latest release as well as selected older releases:
45 | https://raw.githubusercontent.com/15knots/cmake4eclipse/master/releng/comp-update/.
46 |
47 | ### p2 Repositories
48 | Tool integrators will find each release at [cloudsmith](https://cloudsmith.io/~15knots/repos/p2-zip/packages/).
49 | Each release is provided as a stand-alone zipped p2 repository and can be consumed in a PDE target platform. To add one
50 | of these repositories to your target platform, add a **Software Site** and enter a URL for the location as
51 | jar:https://dl.cloudsmith.io/public/15knots/p2-zip/raw/files/cmake4eclipse-3.0.0.zip!/
52 | (note the leading `jar:` and the trailing `!/`).
53 |
54 | If you work at a company that wants to ship cmake4eclipse with your product, please consider to mirror the zip file internally
55 | and reference the company-internal location in your target definition. This will help to reduce the traffic on cloudsmith and
56 | make your product builds immune to downtimes on cloudsmith.
57 |
58 | ## Debug and Build
59 | This project uses Apache maven as its build system.
60 | To build from a command-line, run `mvn package` in the root directory of the project source files.
61 |
62 | There is also a run configuration for eclipse to invoke the maven build: `build cmake4eclipse`.
63 |
64 | To debug the plug-in from Eclipse, first set the Plug-in Development Target platform of your workbench to `cdt/11.4-eclipse/2023-12`,
65 | then run the Eclipse Application launch configuration named `cmake4eclipse`.
66 |
67 | ## References
68 | ### Projects that recommend to use this plugin to develop it using Eclipse.
69 | - CbmRoot https://redmine.cbm.gsi.de/projects/cbmroot/wiki/DevCbmEclipse#Install-CMake-related-Eclipse-plugins
70 | - GnuCash https://wiki.gnucash.org/wiki/Eclipse#Suggested_Plugins
71 | - HTGS https://pages.nist.gov/HTGS/doxygen/tutorial0.html
72 | - Kendryte https://forum.kendryte.com/topic/35/build-kendryte-using-eclipse
73 | - Merlin http://www.accelerators.manchester.ac.uk/merlin/Quickstart/Eclipse.html
74 | - Minres/SystemC-Quickstart https://github.com/Minres/SystemC-Quickstart
75 | - Mixxx https://www.mixxx.org/wiki/doku.php/eclipse#step-by-step_setup
76 | - Navit https://wiki.navit-project.org/index.php/Eclipse#Project_Setup
77 |
78 | ### IDEs with cmake4eclipse
79 | Nsight Eclipse https://devblogs.nvidia.com/drivepx-application-development-using-nsight-eclipse-edition#attachment_10114
80 |
81 | ### Books
82 | Advanced C++ https://books.google.de/books?id=YVG7DwAAQBAJ&pg=PA9&lpg=PA9&dq=cmake4eclipse&source=bl&ots=qgHjAfjlcA&sig=ACfU3U21IppdYpImjXxBfWD69-2NYeHB4w&hl=de&sa=X&ved=2ahUKEwimtrONqJjnAhVKK1AKHVIEC2k4ChDoATAIegQIChAB#v=onepage&q=cmake4eclipse&f=false
83 |
--------------------------------------------------------------------------------
/de.marw.cmake4eclipse.mbs.ui/src/de/marw/cmake4eclipse/mbs/ui/preferences/ViewerComparatorSortHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package de.marw.cmake4eclipse.mbs.ui.preferences;
5 |
6 | import java.util.Arrays;
7 | import java.util.Objects;
8 | import java.util.function.Function;
9 |
10 | import org.eclipse.jface.viewers.ColumnLabelProvider;
11 | import org.eclipse.jface.viewers.LabelProvider;
12 | import org.eclipse.jface.viewers.TableViewer;
13 | import org.eclipse.jface.viewers.Viewer;
14 | import org.eclipse.jface.viewers.ViewerComparator;
15 | import org.eclipse.swt.SWT;
16 | import org.eclipse.swt.events.SelectionEvent;
17 | import org.eclipse.swt.events.SelectionListener;
18 | import org.eclipse.swt.widgets.Table;
19 | import org.eclipse.swt.widgets.TableColumn;
20 |
21 | /**
22 | * A generic ViewerComparator that compares the elements based on the label of a single column. It also acts as a
23 | * selection adapter allowing for users to changes the sorting order and sorting column of a TableViewer.
24 | *
25 | * In order to keep the table sorting UI and the actual sorting of a table viewer synchronized, a single instance of
26 | * this class should be set as the ViewerComparator of a table viewer as well as the selection listener of the
27 | * TableColumn for each of the table's columns.
28 | *
29 | * @author Martin Weber
30 | *
31 | * @see TableViewer#setComparator(ViewerComparator)
32 | * @see TableColumn#addSelectionListener(SelectionListener)
33 | */
34 | public class ViewerComparatorSortHandler extends ViewerComparator implements SelectionListener {
35 | private final TableViewer tv;
36 | private int sortColumn;
37 | private Function