From patchwork Wed Jan 17 13:49:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 3576 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7301:1489:b0:101:b91e:57cc with SMTP id np9csp81408dyc; Wed, 17 Jan 2024 05:50:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpDQoGRUlt9pBhwmV0Rw00cpdswxIeqgpH78C5SHOFu9Wr64HuoZ3nPbk2ZU3JcuHwbTLq X-Received: by 2002:a05:6830:7188:b0:6d9:d486:be6b with SMTP id el8-20020a056830718800b006d9d486be6bmr15925495otb.2.1705499406714; Wed, 17 Jan 2024 05:50:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705499406; cv=none; d=google.com; s=arc-20160816; b=gYoTdx3O6WdRHrJ4VjMfAeWdu2DLrSjX24/BgqZenE/FF1QF9fNrEgNIH9g/hW1oDi r3OrQOapcI39Z4GutNfokqECkDOWDQdtwVshTwMq+kKGwJ+qVsoHIG8w7s7NwWv660J2 yA40f1WUIpz+7FKD0JiOHwwgmm2UVNVdwKidF30V6Y1+tmH4pGT+GFZQ/gcf4ZE7g1mQ TGmydoeORFC9IDXimyx25Lg5tHOE6+ZzIF4Fw6cmsbNm5z+h6SlQp/f08Ypa5wWfKVH2 N4hQdWlzdNJiaK3iIGoEknnNRzX60oeLOocLu+8dBPQZxlA6DIefo3yg4I9jcowInOgl rJow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature; bh=URJ69j5RxOXwz7tJLXhoFO61P7oxahH1gXEL+RMZWYc=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=uEUZO2nDqLvLlujt8GHrx1StoN/p+D4ot0NtJDsoHRGFye2mKODC3vVUsunq967yF5 4LkvBV8JV0UGuxdLaGCniL1hCaI4EOCoUXEp9ShuFaHgiKsIvhxCtyKa7w0qgPFrtsht xAC+JiRMQDlBn0iH7pLDDtQPz7Pm88HWxtN70y04iYoEmXE7Q8EmJg4GfKOvH0uzTRv4 Nio8h4XVCCbrFllThM4rEqW5hPDZiiQAZ2p/GmRd4Rnr9sY4stNBj0J2J1WHeCAVMJ0V +bJRJUuRwXypHGklCt30glYM1iDJwAIqzhhm0V2K7vhRsDAKmue7CNb4caZHq+rxKXwI QbQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=mnKDg48F; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="elV/RMjL"; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id f11-20020a63554b000000b00584ca25959csi13333845pgm.540.2024.01.17.05.50.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jan 2024 05:50:06 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=mnKDg48F; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="elV/RMjL"; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rQ6Ia-0002US-Qh; Wed, 17 Jan 2024 13:49:44 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rQ6IZ-0002UL-5m for openvpn-devel@lists.sourceforge.net; Wed, 17 Jan 2024 13:49:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=gTh3EdKi94aWg9FncoueQPItPkoonQLm0SSxHF9zVUc=; b=mnKDg48Fta9KJ8fvp9c1URUfpm tWUc+CcK6aRboinKgbsVAkpNLYFb6vTy5gD4tz1l9MXOjukvAug/ICaNDG4jeUjTe9GO5ZXiHqCHx nJR1dxbKspc7T7kC8mkFuPC3fzc5YiC4XwfmHTkSXlUXjzJ4hcyk/COKSk87GQ3U8XEQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=gTh3EdKi94aWg9FncoueQPItPkoonQLm0SSxHF9zVUc=; b=elV/RMjLNRSay//owlCFPiAlxT rBZaFFTCXm/MLkMw7z8XFgrLsPrLPCdKV5xkpj51xCnhQx+kxE7YtRP6jzA4rnUuzM5XqjA+4LKa+ IlsFvGbuZbSWYEr86A7rW+6OcZgh1u3ttEJE6j6VrHMYtusxEhSAJA+MHDejuQABRkOI=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rQ6IU-0005iA-M6 for openvpn-devel@lists.sourceforge.net; Wed, 17 Jan 2024 13:49:43 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 40HDnUNj005327 for ; Wed, 17 Jan 2024 14:49:30 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 40HDnU5C005326 for openvpn-devel@lists.sourceforge.net; Wed, 17 Jan 2024 14:49:30 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 17 Jan 2024 14:49:29 +0100 Message-ID: <20240117134929.5317-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Heiko Hund It turned out that symlinking compile_commands.json from the top level source dir has some issues: * file is not created on Windows and symlinking may cause an error * some IDEs create their own json [...] Content analysis details: (-0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Headers-End: 1rQ6IU-0005iA-M6 Subject: [Openvpn-devel] [PATCH v1] cmake: symlink whole build dir not just .json file X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1788345745512645108?= X-GMAIL-MSGID: =?utf-8?q?1788345745512645108?= From: Heiko Hund It turned out that symlinking compile_commands.json from the top level source dir has some issues: * file is not created on Windows and symlinking may cause an error * some IDEs create their own json and error out b/c a file exists Since clangd also looks for the json in build/ directories by default, we now symlink the whole build directory instead, not just the json file. This approach requires for the existing build/ dir in the repo to vanish. Luckily it only contains one automake include file, which is moved to the top level source dir. Lastly, make this an opt-in feature, so that the default configuration of the buildsystem never causes a build failure because of this. Change-Id: Ib1a5c788269949d8de95d1da2cb0c32a65bf13f2 Signed-off-by: Heiko Hund Acked-by: Gert Doering --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/501 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/.gitignore b/.gitignore index 4153a3e..92d65bf 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,7 @@ m4/ltversion.m4 m4/lt~obsolete.m4 -compile_commands.json +build doc/openvpn-examples.5 doc/openvpn-examples.5.html doc/openvpn.8 diff --git a/CMakeLists.txt b/CMakeLists.txt index bc46c27..4e5c8fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,9 +43,17 @@ set(PLUGIN_DIR /usr/local/lib/openvpn/plugins CACHE FILEPATH "Location of the plugin directory") # Create machine readable compile commands -set(CMAKE_EXPORT_COMPILE_COMMANDS 1) -file(CREATE_LINK ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json - ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json SYMBOLIC) +option(ENABLE_COMPILE_COMMANDS "Generate compile_commands.json and a symlink for clangd to find it" OFF) +if (ENABLE_COMPILE_COMMANDS) + if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build AND NOT IS_SYMLINK ${CMAKE_CURRENT_SOURCE_DIR}/build) + message(FATAL_ERROR "The top level source directory contains a 'build' file or directory. Please remove or rename it. CMake creates a symlink with that name during build.") + endif() + set(CMAKE_EXPORT_COMPILE_COMMANDS 1) + add_custom_target( + symlink-build-dir ALL + ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/build + ) +endif () # AddressSanitize - use CXX=clang++ CC=clang cmake -DCMAKE_BUILD_TYPE=asan to build with ASAN set(CMAKE_C_FLAGS_ASAN diff --git a/Makefile.am b/Makefile.am index 2305ab4..792588a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,6 +42,7 @@ EXTRA_DIST = \ contrib \ debug \ + ltrc.inc \ CMakeLists.txt \ CMakePresets.json \ config.h.cmake.in @@ -53,7 +54,7 @@ config-version.h endif -SUBDIRS = build distro include src sample doc tests +SUBDIRS = distro include src sample doc tests dist_doc_DATA = \ README \ diff --git a/README.cmake.md b/README.cmake.md index d181b64..4f41c70 100644 --- a/README.cmake.md +++ b/README.cmake.md @@ -135,3 +135,17 @@ The `unix-native` CMake preset is available for these builds. This preset does not require VCPKG and instead assumes all build-dependencies are provided by the system natively. + +Generating compile_commands.json +-------------------------------- + +To have the CMake buildsystem generate compile_commands.json you can specify +`-DENABLE_COMPILE_COMMANDS=ON` on the command line or enable the CMake option +another way you like. For supported generators the file will then be created. +Additionally, the buildsystem will create a symlink `build/` to the --preset +build directory that contains the generated JSON file. This is done so that +clangd is able to find it. + +Enabling this option may cause an error on Windows, since creating a symlink +is a privileged operation there. If you enable Developer Mode for the system, +symlinks can be created by regular users. diff --git a/build/Makefile.am b/build/Makefile.am deleted file mode 100644 index e7cc4d8..0000000 --- a/build/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -# -# OpenVPN -- An application to securely tunnel IP networks -# over a single UDP port, with support for SSL/TLS-based -# session authentication and key exchange, -# packet encryption, packet authentication, and -# packet compression. -# -# Copyright (C) 2002-2023 OpenVPN Inc -# - -MAINTAINERCLEANFILES = \ - $(srcdir)/Makefile.in - -EXTRA_DIST = \ - ltrc.inc diff --git a/build/ltrc.inc b/build/ltrc.inc deleted file mode 100644 index 701f200..0000000 --- a/build/ltrc.inc +++ /dev/null @@ -1,23 +0,0 @@ -# -# OpenVPN -- An application to securely tunnel IP networks -# over a single UDP port, with support for SSL/TLS-based -# session authentication and key exchange, -# packet encryption, packet authentication, and -# packet compression. -# -# Copyright (C) 2008-2012 Alon Bar-Lev -# -# Required to build Windows resource file - -RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) -LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE) - -.rc.lo: - $(LTRCCOMPILE) -i "$<" -o "$@" - -.rc.o: - $(RCCOMPILE) -i "$<" -o "$@" - -.mc.rc: - $(WINDMC) "$<" diff --git a/configure.ac b/configure.ac index 2823f04..0710f71 100644 --- a/configure.ac +++ b/configure.ac @@ -1515,7 +1515,6 @@ AC_CONFIG_FILES([ Makefile - build/Makefile distro/Makefile distro/systemd/Makefile doc/Makefile diff --git a/ltrc.inc b/ltrc.inc new file mode 100644 index 0000000..701f200 --- /dev/null +++ b/ltrc.inc @@ -0,0 +1,23 @@ +# +# OpenVPN -- An application to securely tunnel IP networks +# over a single UDP port, with support for SSL/TLS-based +# session authentication and key exchange, +# packet encryption, packet authentication, and +# packet compression. +# +# Copyright (C) 2008-2012 Alon Bar-Lev +# +# Required to build Windows resource file + +RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) +LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE) + +.rc.lo: + $(LTRCCOMPILE) -i "$<" -o "$@" + +.rc.o: + $(RCCOMPILE) -i "$<" -o "$@" + +.mc.rc: + $(WINDMC) "$<" diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am index b953961..1dc1dda 100644 --- a/src/openvpn/Makefile.am +++ b/src/openvpn/Makefile.am @@ -9,7 +9,7 @@ # Copyright (C) 2006-2012 Alon Bar-Lev # -include $(top_srcdir)/build/ltrc.inc +include $(top_srcdir)/ltrc.inc MAINTAINERCLEANFILES = \ $(srcdir)/Makefile.in diff --git a/src/openvpnmsica/Makefile.am b/src/openvpnmsica/Makefile.am index dc53f75..b10ce82 100644 --- a/src/openvpnmsica/Makefile.am +++ b/src/openvpnmsica/Makefile.am @@ -18,7 +18,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # -include $(top_srcdir)/build/ltrc.inc +include $(top_srcdir)/ltrc.inc MAINTAINERCLEANFILES = $(srcdir)/Makefile.in diff --git a/src/openvpnserv/Makefile.am b/src/openvpnserv/Makefile.am index d8ba4eb..0c64cce 100644 --- a/src/openvpnserv/Makefile.am +++ b/src/openvpnserv/Makefile.am @@ -9,7 +9,7 @@ # Copyright (C) 2006-2012 Alon Bar-Lev # -include $(top_srcdir)/build/ltrc.inc +include $(top_srcdir)/ltrc.inc MAINTAINERCLEANFILES = $(srcdir)/Makefile.in diff --git a/src/tapctl/Makefile.am b/src/tapctl/Makefile.am index 69ea161..4c2958b 100644 --- a/src/tapctl/Makefile.am +++ b/src/tapctl/Makefile.am @@ -18,7 +18,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # -include $(top_srcdir)/build/ltrc.inc +include $(top_srcdir)/ltrc.inc MAINTAINERCLEANFILES = $(srcdir)/Makefile.in