diff --git a/Makefile b/Makefile index 8b7563e..9e6b8fc 100755 --- a/Makefile +++ b/Makefile @@ -15,8 +15,15 @@ # along with this program; if not, write to the Free Software # 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 # and the link process. Without this option Netbeans will not recognise the # binary, so it is not possible to debug the binary in NetBeans. @@ -57,6 +64,11 @@ endif # OS := $(shell uname -s) +# +# Targets: +# check1 uses cppcheck +# check2 uses clang-tidy +# ifeq ($(MAKECMDGOALS),check1) ifeq ($(OS),Linux) # installed by system and in PATH @@ -76,6 +88,8 @@ endif ifeq ($(MAKECMDGOALS),check2) CPPCHECK := clang-tidy CHECKFLAGS := --checks=* + #CHECKFLAGS := --checks=clang-analyzer-* + #CHECKFLAGS := --checks=cppcoreguidelines-*, clang-analyzer-* endif @@ -135,13 +149,14 @@ _CXXFLAGS=-Wall -Weffc++ -pedantic \ -Werror=narrowing \ -ftrapv -Wfloat-equal -Wpointer-arith \ -D_FORTIFY_SOURCE=2 -O2 -APP_CXXFLAGS= -CXXFLAGS = $(NETBEANSBUILD) $(DBG_REL) -I./include/ $(_CXXFLAGS) $(APP_CXXFLAG) - -APP_LIBS= -LIBS = $(NETBEANSBUILD) $(APP_LIBS) +# app specific includes +_APP_CXXFLAGS = +CXXFLAGS = -std=c++17 $(NETBEANSBUILD) $(DBG_REL) -I./include/ $(_CXXFLAGS) $(_APP_CXXFLAGS) +# app specific libs +_APP_LIBS = +LIBS = $(NETBEANSBUILD) $(_APP_LIBS) debug release: DIRS $(APP) diff --git a/compile_commands.json b/compile_commands.json new file mode 100644 index 0000000..a681b7c --- /dev/null +++ b/compile_commands.json @@ -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", + } +] diff --git a/include/add.h b/include/add.h deleted file mode 100755 index 65f5c8d..0000000 --- a/include/add.h +++ /dev/null @@ -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 */ - diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml index cebd620..d0f1e6f 100644 --- a/nbproject/configurations.xml +++ b/nbproject/configurations.xml @@ -3,9 +3,7 @@ - add.cpp myapp.cpp - testptr.cpp false - - @@ -53,16 +50,9 @@ - - - include - . - - - - + include . @@ -74,9 +64,6 @@ false false - - - @@ -99,9 +86,51 @@ - - - + + + + default + false + false + + + + + + . + ${MAKE} check1 + ${MAKE} clean + + + + . + + + + + + + + + default + false + false + + + + + + . + ${MAKE} check2 + ${MAKE} clean + + + + . + + + + diff --git a/nbproject/project.xml b/nbproject/project.xml index a088206..4f634ad 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -3,10 +3,10 @@ org.netbeans.modules.cnd.makeproject - 3_multi_files + nb_generic cpp - h + UTF-8 @@ -21,6 +21,14 @@ Default 0 + + check1 + 0 + + + check2 + 0 + false