Add default compile database

This commit is contained in:
benn 2025-05-30 10:28:10 +02:00
parent 7532011245
commit 2306dbfa94
5 changed files with 146 additions and 46 deletions

View file

@ -15,8 +15,15 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# #
# Platforms: Linux OpenIndiana
# Works from command line (use gmake on OpenIndiana) and from NetBeans
# Targets
# debug
# release
# check1 --> uses cppcheck (ensure it is installed to use)
# check2 --> uses clang-tidy (currently not available on OpenIndiana)
# Uses the variable NETBEANSBUILD which is added to _both_ the compile flags # Uses the variable NETBEANSBUILD which is added to _both_ the compile flags
# and the link process. Without this option Netbeans will not recognise the # and the link process. Without this option Netbeans will not recognise the
# binary, so it is not possible to debug the binary in NetBeans. # binary, so it is not possible to debug the binary in NetBeans.
@ -57,6 +64,11 @@ endif
# #
OS := $(shell uname -s) OS := $(shell uname -s)
#
# Targets:
# check1 uses cppcheck
# check2 uses clang-tidy
#
ifeq ($(MAKECMDGOALS),check1) ifeq ($(MAKECMDGOALS),check1)
ifeq ($(OS),Linux) ifeq ($(OS),Linux)
# installed by system and in PATH # installed by system and in PATH
@ -76,6 +88,8 @@ endif
ifeq ($(MAKECMDGOALS),check2) ifeq ($(MAKECMDGOALS),check2)
CPPCHECK := clang-tidy CPPCHECK := clang-tidy
CHECKFLAGS := --checks=* CHECKFLAGS := --checks=*
#CHECKFLAGS := --checks=clang-analyzer-*
#CHECKFLAGS := --checks=cppcoreguidelines-*, clang-analyzer-*
endif endif
@ -135,13 +149,14 @@ _CXXFLAGS=-Wall -Weffc++ -pedantic \
-Werror=narrowing \ -Werror=narrowing \
-ftrapv -Wfloat-equal -Wpointer-arith \ -ftrapv -Wfloat-equal -Wpointer-arith \
-D_FORTIFY_SOURCE=2 -O2 -D_FORTIFY_SOURCE=2 -O2
APP_CXXFLAGS=
CXXFLAGS = $(NETBEANSBUILD) $(DBG_REL) -I./include/ $(_CXXFLAGS) $(APP_CXXFLAG) # app specific includes
_APP_CXXFLAGS =
APP_LIBS= CXXFLAGS = -std=c++17 $(NETBEANSBUILD) $(DBG_REL) -I./include/ $(_CXXFLAGS) $(_APP_CXXFLAGS)
LIBS = $(NETBEANSBUILD) $(APP_LIBS)
# app specific libs
_APP_LIBS =
LIBS = $(NETBEANSBUILD) $(_APP_LIBS)
debug release: DIRS $(APP) debug release: DIRS $(APP)

68
compile_commands.json Normal file
View file

@ -0,0 +1,68 @@
[
{
"arguments": [
"/usr/bin/g++",
"-std=c++17",
"-I./include/",
"-Wall",
"-Weffc++",
"-pedantic",
"-pedantic-errors",
"-Waggregate-return",
"-Wcast-align",
"-Wcast-qual",
"-Wchar-subscripts",
"-Wcomment",
"-Wdisabled-optimization",
"-Wformat",
"-Wformat=2",
"-Wformat-nonliteral",
"-Wformat-security",
"-Wformat-y2k",
"-Wimport",
"-Winit-self",
"-Winline",
"-Winvalid-pch",
"-Wlong-long",
"-Wmissing-braces",
"-Wmissing-format-attribute",
"-Wmissing-include-dirs",
"-Wmissing-noreturn",
"-Wpacked",
"-Wparentheses",
"-Wpointer-arith",
"-Wredundant-decls",
"-Wreturn-type",
"-Wsequence-point",
"-Wshadow",
"-Wsign-compare",
"-fstack-protector-all",
"-Wstack-protector",
"-Wstrict-aliasing",
"-Wstrict-aliasing=2",
"-Wswitch",
"-Wswitch-default",
"-Wswitch-enum",
"-Wtrigraphs",
"-Wunknown-pragmas",
"-Wunreachable-code",
"-Wvariadic-macros",
"-Wvolatile-register-var",
"-Wwrite-strings",
"-Werror=return-type",
"-Werror=narrowing",
"-ftrapv",
"-Wfloat-equal",
"-Wpointer-arith",
"-D_FORTIFY_SOURCE=2",
"-O2",
"-c",
"-o",
"obj/myapp.o",
"src/myapp.cpp"
],
"directory": "/home/benn/devl/cpp/projects/NetBeans/nb_generic",
"file": "/home/benn/devl/cpp/projects/NetBeans/nb_generic/src/nb_generic.cpp",
"output": "/home/benn/devl/cpp/projects/NetBeans/nb_generic/obj/nb_generic.obj",
}
]

View file

@ -1,20 +0,0 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/cppFiles/file.h to edit this template
*/
/*
* File: add.h
* Author: benn
*
* Created on February 24, 2023, 11:07 PM
*/
#ifndef ADD_H
#define ADD_H
int add(int x, int y);
#endif /* ADD_H */

View file

@ -3,9 +3,7 @@
<logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT"> <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
<df root="." name="0"> <df root="." name="0">
<df name="src"> <df name="src">
<in>add.cpp</in>
<in>myapp.cpp</in> <in>myapp.cpp</in>
<in>testptr.cpp</in>
</df> </df>
</df> </df>
<logicalFolder name="ExternalFiles" <logicalFolder name="ExternalFiles"
@ -29,8 +27,7 @@
<rebuildPropChanged>false</rebuildPropChanged> <rebuildPropChanged>false</rebuildPropChanged>
</toolsSet> </toolsSet>
<flagsDictionary> <flagsDictionary>
<element flagsID="0" commonFlags="-march=x86-64 -fstack-protector-all -O2"/> <element flagsID="0"
<element flagsID="1"
commonFlags="-pedantic -pedantic-errors -fstack-protector-all -O2"/> commonFlags="-pedantic -pedantic-errors -fstack-protector-all -O2"/>
</flagsDictionary> </flagsDictionary>
<codeAssistance> <codeAssistance>
@ -53,16 +50,9 @@
</preBuild> </preBuild>
</makefileType> </makefileType>
<item path="src/myapp.cpp" ex="false" tool="1" flavor2="0"> <item path="src/myapp.cpp" ex="false" tool="1" flavor2="0">
<ccTool flags="1">
<incDir>
<pElem>include</pElem>
<pElem>.</pElem>
</incDir>
</ccTool>
</item>
<item path="src/testptr.cpp" ex="false" tool="1" flavor2="11">
<ccTool flags="0"> <ccTool flags="0">
<incDir> <incDir>
<pElem>include</pElem>
<pElem>.</pElem> <pElem>.</pElem>
</incDir> </incDir>
</ccTool> </ccTool>
@ -74,9 +64,6 @@
<dependencyChecking>false</dependencyChecking> <dependencyChecking>false</dependencyChecking>
<rebuildPropChanged>false</rebuildPropChanged> <rebuildPropChanged>false</rebuildPropChanged>
</toolsSet> </toolsSet>
<flagsDictionary>
<element flagsID="0" commonFlags="-march=x86-64 -fstack-protector-all -O2"/>
</flagsDictionary>
<codeAssistance> <codeAssistance>
</codeAssistance> </codeAssistance>
<makefileType> <makefileType>
@ -99,9 +86,51 @@
<preBuildCommand></preBuildCommand> <preBuildCommand></preBuildCommand>
</preBuild> </preBuild>
</makefileType> </makefileType>
<item path="src/testptr.cpp" ex="false" tool="1" flavor2="0"> </conf>
<ccTool flags="0"> <conf name="check1" type="0">
</ccTool> <toolsSet>
<compilerSet>default</compilerSet>
<dependencyChecking>false</dependencyChecking>
<rebuildPropChanged>false</rebuildPropChanged>
</toolsSet>
<codeAssistance>
</codeAssistance>
<makefileType>
<makeTool>
<buildCommandWorkingDir>.</buildCommandWorkingDir>
<buildCommand>${MAKE} check1</buildCommand>
<cleanCommand>${MAKE} clean</cleanCommand>
<executablePath></executablePath>
</makeTool>
<preBuild>
<preBuildCommandWorkingDir>.</preBuildCommandWorkingDir>
<preBuildCommand></preBuildCommand>
</preBuild>
</makefileType>
<item path="src/myapp.cpp" ex="false" tool="1" flavor2="0">
</item>
</conf>
<conf name="check2" type="0">
<toolsSet>
<compilerSet>default</compilerSet>
<dependencyChecking>false</dependencyChecking>
<rebuildPropChanged>false</rebuildPropChanged>
</toolsSet>
<codeAssistance>
</codeAssistance>
<makefileType>
<makeTool>
<buildCommandWorkingDir>.</buildCommandWorkingDir>
<buildCommand>${MAKE} check2</buildCommand>
<cleanCommand>${MAKE} clean</cleanCommand>
<executablePath></executablePath>
</makeTool>
<preBuild>
<preBuildCommandWorkingDir>.</preBuildCommandWorkingDir>
<preBuildCommand></preBuildCommand>
</preBuild>
</makefileType>
<item path="src/myapp.cpp" ex="false" tool="1" flavor2="0">
</item> </item>
</conf> </conf>
</confs> </confs>

View file

@ -3,10 +3,10 @@
<type>org.netbeans.modules.cnd.makeproject</type> <type>org.netbeans.modules.cnd.makeproject</type>
<configuration> <configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1"> <data xmlns="http://www.netbeans.org/ns/make-project/1">
<name>3_multi_files</name> <name>nb_generic</name>
<c-extensions/> <c-extensions/>
<cpp-extensions>cpp</cpp-extensions> <cpp-extensions>cpp</cpp-extensions>
<header-extensions>h</header-extensions> <header-extensions/>
<sourceEncoding>UTF-8</sourceEncoding> <sourceEncoding>UTF-8</sourceEncoding>
<make-dep-projects/> <make-dep-projects/>
<sourceRootList> <sourceRootList>
@ -21,6 +21,14 @@
<name>Default</name> <name>Default</name>
<type>0</type> <type>0</type>
</confElem> </confElem>
<confElem>
<name>check1</name>
<type>0</type>
</confElem>
<confElem>
<name>check2</name>
<type>0</type>
</confElem>
</confList> </confList>
<formatting> <formatting>
<project-formatting-style>false</project-formatting-style> <project-formatting-style>false</project-formatting-style>