From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id iIP/A+4uQWCSNQAA0tVLHw (envelope-from ) for ; Thu, 04 Mar 2021 19:03:10 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 2HRPO+0uQWBrWwAAbx9fmQ (envelope-from ) for ; Thu, 04 Mar 2021 19:03:09 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 239042BB06 for ; Thu, 4 Mar 2021 20:03:09 +0100 (CET) Received: from localhost ([::1]:38028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHtFb-0001t5-7U for larch@yhetil.org; Thu, 04 Mar 2021 14:03:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHtFN-0001sm-SA for help-guix@gnu.org; Thu, 04 Mar 2021 14:02:54 -0500 Received: from mout01.posteo.de ([185.67.36.65]:40246) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHtFK-0007Jy-3A for help-guix@gnu.org; Thu, 04 Mar 2021 14:02:53 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id AB76E160060 for ; Thu, 4 Mar 2021 20:02:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1614884566; bh=sCSdQtQJDrWLBFnBWlfjjKQdKE8wHeTIdJ/+9imn5y8=; h=From:To:Subject:Date:From; b=W6xR7z1pH3sNpKFM9l459U8H6lXbSXc1xIZnxH1rv/GLprIZFJnVuRAOuQKrsfZTP /iKHX/UdAK7n2IHAGJm3QiwAlITQH8A01hQxOn3K1FRJ9PPGlvyUDwNgkVakK0f3sW N8jupxSAcCe+CmDtFr/bniuPOjymCcm531TrbGFwXTe2ZKGVe+YAOS289rRtJhHSHy tBBHUFVlsZg83T4pkvJSLydcL4rxuGdLqA+M0DRooXPN/gU3v1Xi4tYy6PJblnASFv 9JYSQ7mjHyPweumUlyWl1AfI1cyQhjL22N4FhmWrh3nPQ77KNDhjDGELW0I4F66Iu0 Paw0lFhfrKecA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Ds0cP3q02z9rxN; Thu, 4 Mar 2021 20:02:45 +0100 (CET) From: Fredrik Salomonsson To: Roy Lemmon , help-guix@gnu.org Subject: Re: setup c/c++ development environment In-Reply-To: <87zgzianxa.fsf@roylemmon.com> References: <87zgzianxa.fsf@roylemmon.com> Date: Thu, 04 Mar 2021 11:02:43 -0800 Message-ID: <87czweeo8c.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=plattfot@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: "Help-Guix" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1614884589; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=2XyppVbvxc/UT/ntlExmAa/7IwEspA18DvOL5dIC0Ts=; b=A0VujjnO+BN3UphXaijdu7BAy03whAWGg90fR6bpNg/n8ODcaHYAmT107hpYO7rkK3wrOr EnCayguAR+DoJF2K5q9tBpkMYLDOjgxThQgk6pT8Ymp4tZMwJGicT1Hvp0LpGIv/Ojfbtf sy+PmflNaYBJ9ygPJckMj5EV32PQBXDmAOPlRlqo1Xi3QUvu/dKqxW5YYQYHsVxmS0Z8B4 kBQFOy+fUaimXW5CjRFGbKNW/McNTnU4Wx/Q3SCi1El5dwvB/aX+i0TJ+PD1gLhESh5+LQ w3zOEbjLQkUrqj0cUqn3kYvwiJ8bjDnD6yZII7nllwwXkTXcIA064i/DNYchAg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1614884589; a=rsa-sha256; cv=none; b=oX/enV0Wu4RSi8VEkIFs3/2Y8xaLLrcbP5Jof9+nVXVrmLSPM8HNe3Xn6a662LgVpIaJ+3 LRaRHbz/dC6Ead2v5oiPFxfsvfFMGqJo2g8YZlAssEmm5l+uRB5Lp3N15faiK1/p+rpYCO QZaaP7dygXJibruNi2QlnfQgXhBhlLHC3y2M2cIZvblxh58IesMVPjeQTp3EQ8I79UMtp0 1zMbrDsXjaVdQ8g5QOaD6vwSbeYFt2aqGYpW66gksq/Qy7k4QyBwxrM6B4rjAvB3CF7bnr jPGIMq9XhuNGqozATG8FaIeMioBs/qXP1FOy3iC5vw0NvlswDNZsoPy3Zd5WEQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=W6xR7z1p; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of help-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=help-guix-bounces@gnu.org X-Migadu-Spam-Score: -3.06 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=W6xR7z1p; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of help-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=help-guix-bounces@gnu.org X-Migadu-Queue-Id: 239042BB06 X-Spam-Score: -3.06 X-Migadu-Scanner: scn0.migadu.com X-TUID: AuKz13ClDND9 Hi Roy, Roy Lemmon writes: > I would like to setup a c/c++ development environment on guix. At the moment, I > have used gcc-toolchain to bring in the compiler etc. Are other pieces > necessary ? That would be the bare minimum for c/c++. I would recommend using a build system to build your stuff like GNU autotools[0], cmake[1] or meson[2]. [0] https://www.gnu.org/software/automake/manual/html_node/Autotools-Introduction.html [1] https://cmake.org/cmake/help/latest/ [2] https://mesonbuild.com/Tutorial.html For the ease of use I would recommend meson. A cool thing I learned from the Guix days last year was from the talk "Just build it with Guix" by Efraim Flashner [3]. And that was using guix to do the testing. It works really well. [3] https://xana.lepiller.eu/guix-days-2020/guix-days-2020-efraim-flashner-build-it-with-guix.mp4 Here is a simplified template of what I use for C++. It uses meson to build and googletest[4] as the testing framework. But it should be fairly simple to change to autotools or cmake or another testing framework, e.g. catch2 [5]. [4] https://github.com/google/googletest/blob/master/docs/primer.md [5] https://github.com/catchorg/Catch2/blob/devel/docs/why-catch.md#top -------8<----------------------------------------------------------------------- (use-modules (guix build-system meson) (guix gexp) (guix git-download) (guix packages) (guix utils) ((guix licenses) #:prefix license:) (gnu packages pkg-config) (gnu packages check) (gnu packages build-tools) (gnu packages gcc) (ice-9 popen) (ice-9 rdelim) ) ;; From the talk "Just build it with Guix" by Efraim Flashner ;; presented on the Guix days 2020 ;; https://guix.gnu.org/en/blog/2020/online-guix-day-announce-2/ (define %source-dir (dirname (current-filename))) (define %git-commit (read-string (open-pipe "git show HEAD | head -1 | cut -d ' ' -f2" OPEN_READ))) (define (skip-git-and-build-directory file stat) "Skip the `.git` and `build` directory when collecting the sources." (let ((name (basename file))) (not (or (string=? name ".git") (string=? name "build"))))) (define-public package-name-here (package (name "package-name-here") (version (git-version "0.1.0" "HEAD" %git-commit)) (source (local-file %source-dir #:recursive? #t #:select? skip-git-and-build-directory)) (build-system meson-build-system) (arguments `(#:meson ,meson-0.55 ;; Pass flags to meson ;; #:configure-flags '("-Dinstall=true") )) (native-inputs `(("pkg-config" ,pkg-config) ("googletest" ,googletest) ("gcc" ,gcc-9))) (synopsis "Template for building with meson.") (description "Simple template for building with meson-0.55 and gcc-9. Using googletest as the testing framework.") ;; (home-page "https://...") (license license:gpl3+) )) package-name-here ---------------------------------------------------------------------->8-------- To use it, simply copy the template above into a file called guix.scm, update the package-name-here and version accordingly and place it at the root of your project. Note the trailing `package-name-here` at end of the template, which is there to return a package definition to guix. Then you can run: guix build -f guix.scm That build your project and run the tests. If you want to place the guix.scm in a subdirectory, say build-aux. Change (define %source-dir (dirname (current-filename))) to (define %source-dir (dirname (current-source-directory))) In the template above. After that you just run it with guix build -f build-aux/guix.scm I hope that helps. -- s/Fred[re]+i[ck]+/Fredrik/g