From patchwork Wed Jan 17 03:49:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "plaisthos (Code Review)" X-Patchwork-Id: 3571 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:a213:b0:100:d2e5:60d with SMTP id bs19csp4599665dyb; Tue, 16 Jan 2024 19:50:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsHvyRuDQUYJDJvRv2vKjMSYWfax06jSl9KKisNtPvn1zlwdcoahQJLtXSGEItWTS7DQak X-Received: by 2002:a05:6870:2051:b0:206:dd16:3ef5 with SMTP id l17-20020a056870205100b00206dd163ef5mr1044762oad.3.1705463448394; Tue, 16 Jan 2024 19:50:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705463448; cv=none; d=google.com; s=arc-20160816; b=aAYqRnQUeuZfgmoaueMTzttgnkt38VwMQPnPH1WUx/cqd9G5/8FkwY1dmYUdgaNJUH 0ZN2mrSrLeloh2l2kLuDm09wMNoyJnrrBRY/BzGn/KfTYw0tK+UOIsHXP/01Zox0s7Tk qNBDUn9PvCDutWxBv9oKINbFdLdr3223l3kD8r3jJXwUzo6/YardXMMiIEcZT/Xr2RGQ lrTHla2LGQdM3NvTdcBLF+bhb/qWpRAy2N3/Mk3ptW9syiPuvtT2y/2hqtlbaFAc7ZMm p5wUDVnS0WHBFFDZHrqbZvzSqCvcACaeWniNGDDVXzeHN4zo8QXwmudSMvY4oqVj0sLT YsTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:to:date:from :dkim-signature:dkim-signature:dkim-signature; bh=5jPbpm4AaNObaxs39Ruh7nj6CGYA75Vsq4XlEn42wKU=; fh=U7wEyxtwz2o5+UdevFSA47vNeG9knhWH0KV//QhD5a0=; b=Jt5gZMVfHvoEQv1ySB9WF1KtTLwX3zehg40W2JFw4AZP/cYhUjpDqRtviWhoD6/E6r DqhZ7NcFSteBJkVyktcS0+lHWlToo7dvjD8YtdjAssi16aTRi6HgcbHMz4ugNH2PL2/U XxJubMlGdTiBXyPn241314/q4VhevTR/SYkmj62Mf6UhB6+10QddUYlhZv2c5hr4yhlG iTyqM5B5Ro+fmjqz1ModBR8H9silVllO/uEUCQhzvmYQmZzIWkbIYVuhHTxHzVMZxf15 /WcJlMbL/FND5q4DBY9OnOj8CwGtuxgqUEAKoDwDe+FmZ+qLTVSYjMsY/08KjUbSF+dw noaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=BR45Hk53; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=TKvID8ZV; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=QZi3ZzAT; 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=openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id a193-20020a6390ca000000b005cec867ecf0si12263023pge.105.2024.01.16.19.50.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2024 19:50:48 -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=BR45Hk53; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=TKvID8ZV; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=QZi3ZzAT; 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=openvpn.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rPwwW-0002Xz-L2; Wed, 17 Jan 2024 03:50:20 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rPwwV-0002Xt-VD for openvpn-devel@lists.sourceforge.net; Wed, 17 Jan 2024 03:50:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:To:Date: From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=/Yg1ykQDuFGn0tbql4KH7xvxtlB8xGbT/ChuiCZINsA=; b=BR45Hk537Rx79GqpQx8/XU8EsP NyBL3OmigFR7Df99Oc3qUUijhPmbygrhNmHdo7kJR+901vdHFul1qOgtmGx/u0fi7r9uf6cHTmlAg 9Ha7bAJew0xOow/jrZx2j8xUpa/y5iaD75S2J1GWAj0J6W6jESvbLwT8xhbl3taWNbMg=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:To:Date:From:Sender:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=/Yg1ykQDuFGn0tbql4KH7xvxtlB8xGbT/ChuiCZINsA=; b=T KvID8ZVFoEhi3kZjwWoRkKwg4h5+ZhjHS2Nb8/9uG091XyRL9Z6cI5QqSxYkUKQ3iqKfJU2htPCEE o6kBdovloDlzJWICPXBr6ccgqKtZohawjuFfdVVRM1ITlzMeJnubv/Ib4frQjQjn+PoyNMUaREi4h BXzIjkjN1r4XOWlc=; Received: from mail-wm1-f51.google.com ([209.85.128.51]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1rPwwM-00017i-JM for openvpn-devel@lists.sourceforge.net; Wed, 17 Jan 2024 03:50:19 +0000 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-40e760e5b49so29693735e9.1 for ; Tue, 16 Jan 2024 19:50:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1705463400; x=1706068200; darn=lists.sourceforge.net; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=/Yg1ykQDuFGn0tbql4KH7xvxtlB8xGbT/ChuiCZINsA=; b=QZi3ZzAT/riacChjxvw7I4gr7ImT2auHMM9s8d7NGsuVj1lQ8AUiy/PrMYL84nhRuu F8UKIIBwVVyojitUzhZEDUU7m08jWvC2WOSB55MNg+/aAJriia+G+bKl2gHi4M1se4bk 5+1Y8kEVsHhb4n8LPxbKDUYQ7ul3wTDcz0X1myf0HXxLq3u0tbuRuvmebiJXTtt2a9uX mJFbY+ge0PE619rNoi8EG+4VwVrfEGzu8Q9A7IXWBdDZFd6Np553F2K/ACnFtx6XUn7K hXbBiKrh6+oA4cYukl9UAxtJvdMo9bNFYugvTkiM+XAd8AoSXndqdTZG79p8K5YSpnzU r6aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705463400; x=1706068200; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/Yg1ykQDuFGn0tbql4KH7xvxtlB8xGbT/ChuiCZINsA=; b=ZePvEHmNJa/fuUc+96ssYhHkyEDKx+RVYnmcM1+whwf8nFsp/9mjynFYiBS1/ZW9iW lkIub4FC3y7m9ttKIf2jtduBazdIENohLXL7DG8ygQcHqbqiJk7LRaILPYECchrKcdTM 679ePb4BZa0m+li4QDmFGGlbW4UP8xqmLeNJ+NkaA8mcAgfgQ97eWiTlvJucHlPl1zvy qYat/XVXfI+Irr8C3MiaGSPMQ17/BEcdLA+ZcqZHqUWKajLMw4h5BQcF2yG5toQV/15R 6ue3DUr4a/bd6Thd66GuQVdT1e8s4dRwMCmu8I8nD1jFBh7Pqytmb2eAlRFsKDfYRSHL hx9w== X-Gm-Message-State: AOJu0YxmqmyHkcE/rNo5VBVNBWBQaQX3nlI204HbPSnrOFYpA6GKjbT4 vNg/LC3iJY5BUyo43N7WOvxbUkgOOZubRokJ0TrJ+ney138= X-Received: by 2002:a05:600c:5103:b0:40c:2c42:ea56 with SMTP id o3-20020a05600c510300b0040c2c42ea56mr2943588wms.273.1705463400086; Tue, 16 Jan 2024 19:50:00 -0800 (PST) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id j28-20020a05600c1c1c00b0040e6726befcsm17218767wms.10.2024.01.16.19.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 19:49:59 -0800 (PST) From: "d12fk (Code Review)" X-Google-Original-From: "d12fk (Code Review)" X-Gerrit-PatchSet: 1 Date: Wed, 17 Jan 2024 03:49:59 +0000 To: plaisthos , flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: Ib1a5c788269949d8de95d1da2cb0c32a65bf13f2 X-Gerrit-Change-Number: 501 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 534826e894c53b2bdcd335e2dc3d79c70eb85b3c References: Message-ID: <9e05cfffe76aed0ef7d93db19560a28a69c9ea41-HTML@gerrit.openvpn.net> MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: -0.2 (/) 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: Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.51 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.51 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 T_SCC_BODY_TEXT_LINE No description available. 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1rPwwM-00017i-JM Subject: [Openvpn-devel] [M] Change in openvpn[master]: 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: , Reply-To: heiko@openvpn.net, arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net, frank@lichtenheld.com Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1788308040853043845?= X-GMAIL-MSGID: =?utf-8?q?1788308040853043845?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/501?usp=email to review the following change. Change subject: cmake: symlink whole build dir not just .json file ...................................................................... cmake: symlink whole build dir not just .json file 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 --- M .gitignore M CMakeLists.txt M Makefile.am M README.cmake.md D build/Makefile.am M configure.ac R ltrc.inc M src/openvpn/Makefile.am M src/openvpnmsica/Makefile.am M src/openvpnserv/Makefile.am M src/tapctl/Makefile.am 11 files changed, 32 insertions(+), 25 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/01/501/1 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/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/build/ltrc.inc b/ltrc.inc similarity index 100% rename from build/ltrc.inc rename to ltrc.inc 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