Skip to content

Commit 32b20e1

Browse files
authored
Merge pull request #13549 from LabNConsulting/chopps/cclsopt
doc: configure: add configure option to generate .ccls file
2 parents f8bcb70 + 2596308 commit 32b20e1

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ GSYMS
106106
GRTAGS
107107
GPATH
108108
compile_commands.json
109+
.ccls
109110
.ccls-cache
110111
.dirstamp
111112
refix

configure.ac

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,9 @@ if test "$ac_cv_lib_json_c_json_object_get" = "no"; then
794794
fi
795795
])
796796

797+
AC_ARG_ENABLE([ccls],
798+
AS_HELP_STRING([--enable-ccls], [Write .ccls config for this build]))
799+
797800
AC_ARG_ENABLE([dev_build],
798801
AS_HELP_STRING([--enable-dev-build], [build for development]))
799802

@@ -2820,6 +2823,42 @@ AC_CONFIG_FILES([tools/frrcommon.sh])
28202823
AC_CONFIG_FILES([tools/frr.service])
28212824
AC_CONFIG_FILES([tools/frr@.service])
28222825

2826+
# dnl write out a ccls file with our compile configuration
2827+
# dnl have to add -Wno-unused-function otherwise foobar_cmd_magic causes
2828+
# dnl all DEFPY(), et al., macros to flag as errors.
2829+
AS_IF([test "$enable_ccls" = "yes"], [
2830+
AC_CONFIG_COMMANDS([gen-dot-ccls], [
2831+
cat > "${srcdir}/.ccls" <<EOF
2832+
clang
2833+
-DHAVE_CONFIG_H
2834+
-I.
2835+
-I./include
2836+
-I./lib
2837+
-I./lib/assert
2838+
-DSYSCONFDIR="${ac_frr_sysconfdir}"
2839+
-DCONFDATE=${ac_frr_confdate}
2840+
EOF
2841+
if test "$ac_abs_top_builddir" != "$ac_abs_top_srcdir"; then
2842+
echo "-I${ac_abs_top_builddir}" >> "${srcdir}/.ccls"
2843+
fi
2844+
if test -n "$FRR_ALL_CCLS_FLAGS"; then
2845+
echo ${FRR_ALL_CCLS_FLAGS} | tr ' ' '\n' >> "${srcdir}/.ccls"
2846+
fi
2847+
if test -n "$FRR_ALL_CCLS_CFLAGS"; then
2848+
cat >> "${srcdir}/.ccls" <<EOF
2849+
%c $(echo ${FRR_ALL_CCLS_CFLAGS} | sed -e 's/ */\n%c /g')
2850+
%c -Wno-unused-function
2851+
EOF
2852+
fi
2853+
], [
2854+
FRR_ALL_CCLS_FLAGS="$(echo ${LIBYANG_CFLAGS} ${LUA_INCLUDE} ${SQLITE3_CFLAGS} | sed -e 's/ */ /g')"
2855+
FRR_ALL_CCLS_CFLAGS="$(echo ${CFLAGS} ${WERROR} ${AC_CFLAGS} ${SAN_FLAGS} | sed -e 's/ */ /g')"
2856+
ac_frr_confdate="${CONFDATE}"
2857+
ac_frr_sysconfdir="${sysconfdir}/"
2858+
])
2859+
])
2860+
2861+
28232862
AS_IF([test "$with_pkg_git_version" = "yes"], [
28242863
AC_CONFIG_COMMANDS([lib/gitversion.h], [
28252864
dst="${ac_abs_top_builddir}/lib/gitversion.h"

doc/user/installation.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,18 @@ and the configuration files in :file:`/usr/local/etc`. The :file:`/usr/local/`
390390
installation prefix and other directories may be changed using the following
391391
options to the configuration script.
392392

393+
.. option:: --enable-ccls
394+
395+
Enable the creation of a :file:`.ccls` file in the top level source
396+
directory.
397+
398+
Some development environments (e.g., LSP server within emacs, et al.) can
399+
utilize :clicmd:`ccls` to provide highly sophisticated IDE features (e.g.,
400+
semantically accurate jump-to definition/reference, and even code
401+
refactoring). The `--enable-ccls` causes :file:`configure` to generate a
402+
configuration for the :clicmd:`ccls` command, based on the configured
403+
FRR build environment.
404+
393405
.. option:: --prefix <prefix>
394406

395407
Install architecture-independent files in `prefix` [/usr/local].

0 commit comments

Comments
 (0)