On Mon Apr 01, 2019 at 12:04:38PM +0200, Jeremie Courreges-Anglas wrote:
> On Mon, Apr 01 2019, Rafael Sadowski <[email protected]> wrote:
> > Enable clang extra tools in devel/llvm to provide some useful C/C++
> > tools. I started with the extra tools because we don't have an C++ Language
> > Server Protocol (LSP) server in the tree but I want to play with it.
> >
> > However, build and works fine on amd64. Notable changes:
> >
> > - Zap all ":Bool" tags in cmake configure args. It's 2019 and cmake is
> >   smart enough.
> 
> I'm no cmake guru, what do the cmake authors/best practices say here?

https://cmake.org/cmake/help/v3.6/manual/cmake.1.html See -D:

"If the :<type> portion is given it must be one of the types specified
by the set() command documentation for its CACHE signature."

Okay this is useless in almost all our cases because what we do is to
modify an option()[1] and NOT a set() with a type.

For example, LLVM_ENABLE_RTTI is in llvm defined as:

 option(LLVM_ENABLE_RTTI "Enable run time type information" OFF)

and we can read the following in [1]:

"Provide an option for the user to select as ON or OFF. If no initial
value is provided, OFF is used."

I see no type hint. So the best practices should be:

Use ON and OFF without a type!
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is the reason why other stuff works also:

>From logical-expressions:
$<BOOL:string>

    Converts string to 0 or 1 according to the rules of the if()
    command. Evaluates to 0 if any of the following is true:

    - string is empty,
    - string is a case-insensitive equal of 0, FALSE, OFF, N, NO, IGNORE, or 
NOTFOUND, or
    - string ends in the suffix -NOTFOUND (case-sensitive).

    Otherwise evaluates to 1.

1: https://cmake.org/cmake/help/v3.0/command/option.html?highlight=option
2: 
https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#logical-expressions

> 
> > - Set CLANG_ENABLE_STATIC_ANALYZER=True, CLANG_INCLUDE_TESTS=True to
> >   build clang-tidy and enable test. (It is ignored if the folder extra
> >   don't exists)
> > - Adjust WANTLIB
> >
> > Comments? OK?
> 
> In this port I'm caring mostly about what is actually used by the ports
> tree.  So if the extras subpackage breaks somehow, expect me to disable
> it, not to fix it.

I'll take care of -extras

> 
> You say you "want to play with it".  Do you have an actual use case?
> I think it's too late to add "extra" stuff in this release cycle.

Clang-tidy and clangd worked-out-of box with qt-creator and a camke+c/c++
project.

My future use-case is clangd+vim = c++ autocomplete. But qt-creator
proves to me that it works, now.

> 
> Comments inline,
> 

New diff with Stuart'S notes. Thanks Stuart.

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/llvm/Makefile,v
retrieving revision 1.216
diff -u -p -u -p -r1.216 Makefile
--- Makefile    9 Mar 2019 06:18:11 -0000       1.216
+++ Makefile    1 Apr 2019 18:37:38 -0000
@@ -8,9 +8,10 @@ ONLY_FOR_ARCHS = ${LLVM_ARCHS}
 
 DPB_PROPERTIES = parallel
 
-MULTI_PACKAGES =       -main -python -lldb
+MULTI_PACKAGES =       -main -python -lldb -extras
 COMMENT-main = modular, fast C/C++/ObjC compiler, static analyzer and tools
 COMMENT-lldb = LLDB debugger
+COMMENT-extras =       clang extra tools
 COMMENT-python =       Python bindings for Clang
 
 LLVM_V =       7.0.1
@@ -20,13 +21,15 @@ PKGSPEC-main =      llvm-=${LLVM_V}
 PKGNAME-main = llvm-${LLVM_V}
 PKGNAME-python =       py-llvm-${LLVM_V}
 PKGNAME-lldb = lldb-${LLVM_V}
+PKGNAME-extras =       extras-${LLVM_V}
 REVISION-main =        9
 REVISION-lldb =        0
 CATEGORIES =   devel
 DISTFILES =    llvm-${LLVM_V}.src${EXTRACT_SUFX} \
                cfe-${LLVM_V}.src${EXTRACT_SUFX} \
                lld-${LLVM_V}.src${EXTRACT_SUFX} \
-               lldb-${LLVM_V}.src${EXTRACT_SUFX}
+               lldb-${LLVM_V}.src${EXTRACT_SUFX} \
+               clang-tools-extra-${LLVM_V}.src${EXTRACT_SUFX}
 MASTER_SITES = https://www.llvm.org/releases/${LLVM_V}/
 EXTRACT_SUFX = .tar.xz
 
@@ -42,10 +45,10 @@ MAINTAINER= Jeremie Courreges-Anglas <jc
 # BSD
 PERMIT_PACKAGE_CDROM = Yes
 
-WANTLIB =      ${COMPILER_LIBCXX} c curses edit form m panel pthread \
+WANTLIB =      ${COMPILER_LIBCXX} c edit form m panel pthread \
                ${MODPY_WANTLIB} z
 
-PSEUDO_FLAVORS = no_lldb
+PSEUDO_FLAVORS = no_lldb no_tools
 FLAVOR ?=
 NOT_FOR_ARCHS-lldb = ${GCC4_ARCHS}
 
@@ -72,15 +75,21 @@ WANTLIB-python =    clang
 RUN_DEPENDS-python =   ${MODPY_RUN_DEPENDS}
 LIB_DEPENDS-python =   ${BUILD_PKGPATH},-main
 
-WANTLIB-lldb =         clang
+WANTLIB-lldb =         ${COMPILER_LIBCXX} clang c curses edit form m panel
+WANTLIB-lldb +=                ${MODPY_WANTLIB}
 LIB_DEPENDS-lldb =     ${BUILD_PKGPATH},-main
 RUN_DEPENDS-lldb =     ${MODPY_RUN_DEPENDS} \
                        devel/py-six
 
-SEPARATE_BUILD =       Yes
+WANTLIB-extras =       ${COMPILER_LIBCXX} c m clang
+LIB_DEPENDS-extras =   ${BUILD_PKGPATH},-main
+RUN_DEPENDS-extras =   ${MODPY_RUN_DEPENDS}
+
 CONFIGURE_ARGS =       -DLLVM_ENABLE_FFI:Bool=False \
                        -DLLVM_ENABLE_TERMINFO:Bool=False \
                        -DLLVM_ENABLE_RTTI:Bool=True \
+                       -DCLANG_ENABLE_STATIC_ANALYZER=ON \
+                       -DCLANG_INCLUDE_TESTS=ON \
                        -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2:Bool=True \
                        -DLLVM_LINK_LLVM_DYLIB:Bool=True \
                        -DLLVM_BUILD_LLVM_DYLIB:Bool=True \
@@ -111,7 +120,7 @@ PKG_ARGS +=         -Dpowerpc=1
 PKG_ARGS +=            -Dpowerpc=0
 .endif
 
-TEST_TARGET =          check
+TEST_TARGET =          check-clang check-clang-tools
 
 # XXX sync
 GCC_VER =              4.9.4
@@ -127,12 +136,16 @@ post-extract:
        mv ${WRKDIR}/cfe-${LLVM_V}.src ${WRKSRC}/tools/clang
        mv ${WRKDIR}/lld-${LLVM_V}.src ${WRKSRC}/tools/lld
        mv ${WRKDIR}/lldb-${LLVM_V}.src ${WRKSRC}/tools/lldb
+       mv ${WRKDIR}/clang-tools-extra-${LLVM_V}.src 
${WRKSRC}/tools/clang/tools/extra
 
 pre-configure:
        @${SUBST_CMD} ${WRKSRC}/tools/clang/lib/Driver/ToolChains/OpenBSD.cpp
        -@ln -s ${MODPY_BIN} ${WRKDIR}/bin/python
 .if !${BUILD_PACKAGES:M-lldb}
        rm -r ${WRKSRC}/tools/lldb
+.endif
+.if !${BUILD_PACKAGES:M-extras}
+       rm -r ${WRKSRC}/tools/clang/tools/extra
 .endif
 
 post-build:
Index: distinfo
===================================================================
RCS file: /cvs/ports/devel/llvm/distinfo,v
retrieving revision 1.30
diff -u -p -u -p -r1.30 distinfo
--- distinfo    28 Jan 2019 06:27:28 -0000      1.30
+++ distinfo    1 Apr 2019 18:37:38 -0000
@@ -1,8 +1,10 @@
 SHA256 (cfe-7.0.1.src.tar.xz) = pFti3eXX1f3N+odrCvkvFk1DSwbp6JtdCxy8Zd/j9Bg=
+SHA256 (clang-tools-extra-7.0.1.src.tar.xz) = 
TJPH0rsHkjqLJy2j73kUQ4CArraTcl9PxcGc0OJhO+0=
 SHA256 (lld-7.0.1.src.tar.xz) = iGmqst0tjgDWmUM1LTFm0VnX6uJhX2amhPSgmZ/HQDE=
 SHA256 (lldb-7.0.1.src.tar.xz) = drRr51tBKj0i8NJieTBq5+J0/k15iKIYTFKcOKanaYI=
 SHA256 (llvm-7.0.1.src.tar.xz) = o438TbRxAux53MKqYek3IsX28G8KlhBzvYS3j7lJQZs=
 SIZE (cfe-7.0.1.src.tar.xz) = 12488668
+SIZE (clang-tools-extra-7.0.1.src.tar.xz) = 901368
 SIZE (lld-7.0.1.src.tar.xz) = 912812
 SIZE (lldb-7.0.1.src.tar.xz) = 19384628
 SIZE (llvm-7.0.1.src.tar.xz) = 28311056
Index: pkg/DESCR-extras
===================================================================
RCS file: pkg/DESCR-extras
diff -N pkg/DESCR-extras
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ pkg/DESCR-extras    1 Apr 2019 18:37:39 -0000
@@ -0,0 +1,14 @@
+The clang-tools-extra contains helpful developer tools using Clangs tooling
+APIs.
+
+- clang-tidy, is a clang-based C++ linter tool.
+- clang-include-fixer, adds missing namespace qualifiers to all instances of an
+  unidentified symbol if the symbol is missing some prefix namespace
+  qualifiers.
+- modularize,is a standalone tool that checks whether a set of headers provides
+  the consistent definitions required to use modules.
+- pp-trace is a standalone tool that traces preprocessor activity.
+- clang-rename is a C++ refactoring tool.
+- clangd is a language server that implements the Language Server Protocol.
+- clang-doc is a tool for generating C and C++ documenation from source code
+  and comments.
Index: pkg/PLIST-extras
===================================================================
RCS file: pkg/PLIST-extras
diff -N pkg/PLIST-extras
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ pkg/PLIST-extras    1 Apr 2019 18:37:39 -0000
@@ -0,0 +1,46 @@
+@comment $OpenBSD: PLIST-extras,v$
+@bin bin/clang-apply-replacements
+@bin bin/clang-change-namespace
+@bin bin/clang-reorder-fields
+@bin bin/clang-tidy
+@bin bin/clang-query
+@bin bin/clangd
+@bin bin/clang-include-fixer
+@bin bin/find-all-symbols
+@bin bin/modularize
+lib/libclangApplyReplacements.a
+lib/libclangChangeNamespace.a
+lib/libclangDaemon.a
+lib/libclangDoc.a
+lib/libclangIncludeFixer.a
+lib/libclangIncludeFixerPlugin.a
+lib/libclangMove.a
+lib/libclangQuery.a
+lib/libclangReorderFields.a
+lib/libclangTidy.a
+lib/libclangTidyAbseilModule.a
+lib/libclangTidyAndroidModule.a
+lib/libclangTidyBoostModule.a
+lib/libclangTidyBugproneModule.a
+lib/libclangTidyCERTModule.a
+lib/libclangTidyCppCoreGuidelinesModule.a
+lib/libclangTidyFuchsiaModule.a
+lib/libclangTidyGoogleModule.a
+lib/libclangTidyHICPPModule.a
+lib/libclangTidyLLVMModule.a
+lib/libclangTidyMPIModule.a
+lib/libclangTidyMiscModule.a
+lib/libclangTidyModernizeModule.a
+lib/libclangTidyObjCModule.a
+lib/libclangTidyPerformanceModule.a
+lib/libclangTidyPlugin.a
+lib/libclangTidyPortabilityModule.a
+lib/libclangTidyReadabilityModule.a
+lib/libclangTidyUtils.a
+lib/libclangTidyZirconModule.a
+lib/libfindAllSymbols.a
+share/clang/clang-include-fixer.el
+share/clang/clang-include-fixer.py
+share/clang/clang-tidy-diff.py
+share/clang/run-clang-tidy.py
+share/clang/run-find-all-symbols.py

Reply via email to