From da8c33b14c2e429e4a829fa08004c7c597361e32 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Sun, 22 Sep 2024 11:33:04 +0200 Subject: [PATCH] add a clangd and qtcreator make targets Add a clangd make target: $ make clangd This installs a .clangd file with configuration (includes/macros/compiler flags) for the clandg language server. Add a qtcreator make target: $ make qtcreator This installs a .qtcreator directory with QTCreator IDE project files. In the QTCreator you can open a project by selecting the .qtcreator/ezc.creator file. You can use 'make qtcreator' again to refresh .qtcreator/ezc.files, the rest of the project files will not be modified. --- .gitignore | 12 +- .templates/.clangd | 2 + .templates/.qtcreator/ezc.cflags | 1 + .templates/.qtcreator/ezc.config | 1 + .templates/.qtcreator/ezc.creator | 1 + .templates/.qtcreator/ezc.creator.user | 184 +++++++++++++++++++++++++ .templates/.qtcreator/ezc.cxxflags | 1 + .templates/.qtcreator/ezc.files | 1 + .templates/.qtcreator/ezc.includes | 0 .templates/install_clangd.sh | 30 ++++ .templates/install_qtcreator.sh | 65 +++++++++ Makefile | 7 + 12 files changed, 296 insertions(+), 9 deletions(-) create mode 100644 .templates/.clangd create mode 100644 .templates/.qtcreator/ezc.cflags create mode 100644 .templates/.qtcreator/ezc.config create mode 100644 .templates/.qtcreator/ezc.creator create mode 100644 .templates/.qtcreator/ezc.creator.user create mode 100644 .templates/.qtcreator/ezc.cxxflags create mode 100644 .templates/.qtcreator/ezc.files create mode 100644 .templates/.qtcreator/ezc.includes create mode 100755 .templates/install_clangd.sh create mode 100755 .templates/install_qtcreator.sh diff --git a/.gitignore b/.gitignore index 018509d..7d464fc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,12 +3,6 @@ .settings/ *.o *.a -.clangd -.qtc_clangd/ -ezc.cflags -ezc.config -ezc.creator -ezc.creator.user -ezc.cxxflags -ezc.files -ezc.includes +/.clangd +/.qtcreator/ +/.qtc_clangd/ diff --git a/.templates/.clangd b/.templates/.clangd new file mode 100644 index 0000000..bc573b8 --- /dev/null +++ b/.templates/.clangd @@ -0,0 +1,2 @@ +CompileFlags: + Add: [-pthread, -std=c++20, -I%%%CURRENT_DIR%%%/src, -I%%%GLOBAL_WORKING_DIR%%%/pikotools/src, -I%%%GLOBAL_WORKING_DIR%%%/morm/src, -I/usr/include, -I/usr/local/include, -DEZC_HAS_MORM_LIBRARY] diff --git a/.templates/.qtcreator/ezc.cflags b/.templates/.qtcreator/ezc.cflags new file mode 100644 index 0000000..594bcef --- /dev/null +++ b/.templates/.qtcreator/ezc.cflags @@ -0,0 +1 @@ +-std=c20 diff --git a/.templates/.qtcreator/ezc.config b/.templates/.qtcreator/ezc.config new file mode 100644 index 0000000..1a2f6f2 --- /dev/null +++ b/.templates/.qtcreator/ezc.config @@ -0,0 +1 @@ +#define EZC_HAS_MORM_LIBRARY 1 diff --git a/.templates/.qtcreator/ezc.creator b/.templates/.qtcreator/ezc.creator new file mode 100644 index 0000000..e94cbbd --- /dev/null +++ b/.templates/.qtcreator/ezc.creator @@ -0,0 +1 @@ +[General] diff --git a/.templates/.qtcreator/ezc.creator.user b/.templates/.qtcreator/ezc.creator.user new file mode 100644 index 0000000..cdf567a --- /dev/null +++ b/.templates/.qtcreator/ezc.creator.user @@ -0,0 +1,184 @@ + + + + + + EnvironmentId + {5ab9881c-fa5d-4482-9095-89b8f4d69c9e} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + 0 + false + true + false + 0 + true + true + 0 + 8 + true + false + 2 + true + true + true + *.md, *.MD, Makefile + false + true + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + false + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 3 + true + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Desktop + {d8d7580a-b779-40c7-980c-a52adf87b0ab} + 0 + 0 + 0 + + %%%CURRENT_DIR%%% + + + + all + + /usr/local/bin/gmake + true + GenericProjectManager.GenericMakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + clean + + /usr/local/bin/gmake + true + GenericProjectManager.GenericMakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Default + GenericProjectManager.GenericBuildConfiguration + + 1 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + 0 + true + + 2 + + false + -e cpu-cycles --call-graph dwarf,4096 -F 250 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/.templates/.qtcreator/ezc.cxxflags b/.templates/.qtcreator/ezc.cxxflags new file mode 100644 index 0000000..e23b2ae --- /dev/null +++ b/.templates/.qtcreator/ezc.cxxflags @@ -0,0 +1 @@ +-std=c++20 diff --git a/.templates/.qtcreator/ezc.files b/.templates/.qtcreator/ezc.files new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.templates/.qtcreator/ezc.files @@ -0,0 +1 @@ + diff --git a/.templates/.qtcreator/ezc.includes b/.templates/.qtcreator/ezc.includes new file mode 100644 index 0000000..e69de29 diff --git a/.templates/install_clangd.sh b/.templates/install_clangd.sh new file mode 100755 index 0000000..7287ac7 --- /dev/null +++ b/.templates/install_clangd.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +CURRENT_DIR=$(pwd) +GLOBAL_WORKING_DIR=$(realpath ${CURRENT_DIR}/../..) + +# ---------- + +# make sure the current directory is correct +if [ ! -d ${CURRENT_DIR}/.templates ] ; then + echo "this script should be called by make: make clangd (one level up)" + exit 1 +fi + +# change / to \/ in paths +CURRENT_DIR_FOR_SED=$(echo ${CURRENT_DIR} | sed 's/\//\\\//g') +GLOBAL_WORKING_DIR_FOR_SED=$(echo ${GLOBAL_WORKING_DIR} | sed 's/\//\\\//g') + + +if [ -f "${CURRENT_DIR}/.templates/.clangd" ] ; then + if [ ! -f "${CURRENT_DIR}/.clangd" ] ; then + cat "${CURRENT_DIR}/.templates/.clangd" | \ + sed -e "s/%%%CURRENT_DIR%%%/${CURRENT_DIR_FOR_SED}/g" \ + -e "s/%%%GLOBAL_WORKING_DIR%%%/${GLOBAL_WORKING_DIR_FOR_SED}/g" > \ + ${CURRENT_DIR}/.clangd + + echo "added a ${CURRENT_DIR}/.clangd file" + fi +fi + + diff --git a/.templates/install_qtcreator.sh b/.templates/install_qtcreator.sh new file mode 100755 index 0000000..c93a559 --- /dev/null +++ b/.templates/install_qtcreator.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +CURRENT_DIR=$(pwd) +GLOBAL_WORKING_DIR=$(realpath ${CURRENT_DIR}/..) +QTCREATOR_DIR=${CURRENT_DIR}/.qtcreator + +# ---------- + +# make sure the current directory is correct +if [ ! -d ${CURRENT_DIR}/.templates ] ; then + echo "this script should be called by make: make qtcreator (one level up)" + exit 1 +fi + +# change / to \/ in paths +CURRENT_DIR_FOR_SED=$(echo ${CURRENT_DIR} | sed 's/\//\\\//g') +GLOBAL_WORKING_DIR_FOR_SED=$(echo ${GLOBAL_WORKING_DIR} | sed 's/\//\\\//g') + +was_qtcreator_dir=0 + +if [ -d "${QTCREATOR_DIR}" ] ; then + was_qtcreator_dir=1 +else + mkdir -p "${QTCREATOR_DIR}" +fi + +if [ -d "${QTCREATOR_DIR}" ] ; then + + if [ -d ${CURRENT_DIR}/.templates/.qtcreator ] ; then + cd ${CURRENT_DIR}/.templates/.qtcreator + + if [ $? -eq 0 ] ; then + + for i in * ; do + if [ ! -f "${QTCREATOR_DIR}/$i" ] ; then + cat "$i" | \ + sed -e "s/%%%CURRENT_DIR%%%/${CURRENT_DIR_FOR_SED}/g" \ + -e "s/%%%GLOBAL_WORKING_DIR%%%/${GLOBAL_WORKING_DIR_FOR_SED}/g" > \ + "${QTCREATOR_DIR}/$i" + fi + done + + if [ $was_qtcreator_dir -eq 0 ] ; then + echo "QTCreator files generated to ${QTCREATOR_DIR} directory" + echo "select an 'open project...' option and find a ${QTCREATOR_DIR}/*.creator file" + fi + + fi + fi + + + find ${QTCREATOR_DIR} -name "*.files" | while read projectfiles ; do + + cd ${CURRENT_DIR}/src + + if [ $? -eq 0 ] ; then + find ../src -type f \( -iname "*.cpp" -o -iname "*.h" \) | sort > ${projectfiles} + echo "file ${projectfiles} has been updated" + fi + + done + +fi + + diff --git a/Makefile b/Makefile index 14fadc4..d078c90 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,13 @@ depend: FORCE $(MAKE) -C src depend +clangd: FORCE + @.templates/install_clangd.sh + + +qtcreator: clangd + @.templates/install_qtcreator.sh + FORCE: