From patchwork Mon Apr 20 21:52:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Compagnucci X-Patchwork-Id: 1273768 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Kgi57u7/; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 495gRL19SQz9sSJ for ; Tue, 21 Apr 2020 07:52:46 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7A5A886A0F; Mon, 20 Apr 2020 21:52:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R0uhvft67VhH; Mon, 20 Apr 2020 21:52:40 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9CD6C86A1A; Mon, 20 Apr 2020 21:52:40 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 1E7681BF281 for ; Mon, 20 Apr 2020 21:52:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 1A14820552 for ; Mon, 20 Apr 2020 21:52:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zdMxtsw1ounj for ; Mon, 20 Apr 2020 21:52:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by silver.osuosl.org (Postfix) with ESMTPS id 9C02A220C4 for ; Mon, 20 Apr 2020 21:52:36 +0000 (UTC) Received: by mail-wr1-f52.google.com with SMTP id u13so14095106wrp.3 for ; Mon, 20 Apr 2020 14:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p9VFkQTAZkBv9QvdrRP+VBuZwHaSUk3wTUKr8blx9SQ=; b=Kgi57u7/4hdAwZdyT7+RfdoBrErj1w1I2tchyzdmDVt1BjIjUBKNreyudF1XiZoADd 2d7yBlrwiD6wKTJFbirpf40hAjXW9wIv6yeqzPJY/tlY7M46mLeLm15PrrmBRz4pVu+L EayiPnoBKBkcGKYD9M0zdj8JpTd79YaYe+hB4VfSP3Ja8yK9Ge2zV38zDHCna3K3xMRd B6L5ON2TtVqeBHnK/dt0RoWrzB7b+B/yXqMGPx19N9MItQt9AGgKQRPJgH7tJdSbQ4l3 inzc3JJzrwoMgaW8tD7iZEWux0JJ7KW2yf+oteeYhbtd9a16EZH1o9bVJZVfYZXHkQbO 0iQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=p9VFkQTAZkBv9QvdrRP+VBuZwHaSUk3wTUKr8blx9SQ=; b=AmtUEQkPMWOOb1SSJEMF+wWPdR408kvc1uz5/UvhisUXnZjRSgM5dChLhjYnmSkxTT c2lwGbErE4D4nKUaiA0VeBXH4+YP3T2PK/xeIdelY5APlmrExy/6SXOXif3QeVVy73sx 8qd/7eRL4PJQDsXZ3wAIKBDHLjY2n2EKXqTv4BuzCfn14d7Tw0GX2OgWjqzJ3pWlpcEA 7k73BX10r3b4h1/r6T4oE4mPt3zY6K8deLzLPmVenXrmng0W0GiAzVw02CpLb81eJvTn 6wxxEPQz6c44BoZfG83StFycBOWMJqz1tDNEH7QbKzm3TD8FyzrjBY5DvqjSIKtesqc5 wDDQ== X-Gm-Message-State: AGi0PuZkBbj9lH0VjolIaEYxvwCqanrmGLN5N+lpNG3z9wfyZOk1kP0c eJ0gISgCGEeBzpFH3iMmcIAdKmrugCw= X-Google-Smtp-Source: APiQypJZkPY+Q/r+GavigcOA4bAIZfNfEG4V09l7MJ2BfnRzdB2+Hv0vsgn/yRJUP0sLGjvuGmbEMg== X-Received: by 2002:adf:e58e:: with SMTP id l14mr17693022wrm.186.1587419554807; Mon, 20 Apr 2020 14:52:34 -0700 (PDT) Received: from localhost.localdomain (host185100179096.static.fidoka.tech. [185.100.179.96]) by smtp.gmail.com with ESMTPSA id m14sm1007466wrs.76.2020.04.20.14.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 14:52:34 -0700 (PDT) From: Angelo Compagnucci X-Google-Original-From: Angelo Compagnucci To: buildroot@buildroot.org Date: Mon, 20 Apr 2020 23:52:26 +0200 Message-Id: <20200420215228.16175-2-angelo@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420215228.16175-1-angelo@amarulasolutions.com> References: <20200420215228.16175-1-angelo@amarulasolutions.com> Subject: [Buildroot] [PATCH v3 1/3] package/environment-setup: new package X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Angelo Compagnucci MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Install an helper script to setup a build environment based on buildroot. It's useful when a developer wants to use a buildroot generated sdk to build an external project. Due to the nature of the intrusiveness of this script, a new PS1 is installed to let the user understand that the current running shell is not a normal shell. Signed-off-by: Angelo Compagnucci --- docs/manual/using-buildroot-toolchain.txt | 7 +++++ package/Config.in | 1 + package/environment-setup/Config.in | 6 ++++ package/environment-setup/environment-setup | 16 ++++++++++ .../environment-setup/environment-setup.mk | 29 +++++++++++++++++++ 5 files changed, 59 insertions(+) create mode 100644 package/environment-setup/Config.in create mode 100644 package/environment-setup/environment-setup create mode 100644 package/environment-setup/environment-setup.mk diff --git a/docs/manual/using-buildroot-toolchain.txt b/docs/manual/using-buildroot-toolchain.txt index 0c0c35fced..7b2de4bdfa 100644 --- a/docs/manual/using-buildroot-toolchain.txt +++ b/docs/manual/using-buildroot-toolchain.txt @@ -27,6 +27,13 @@ Upon extracting the SDK tarball, the user must run the script +relocate-sdk.sh+ (located at the top directory of the SDK), to make sure all paths are updated with the new location. +For your convenience, by selecting the package BR2_PACKAGE_ENVIRONMENT_SETUP, +you can have a +setup-environment+ script installed in +output/host/+. +This script can be sourced with +. your/sdk/path/environment-setup+ to launch +the buildroot shell. Inside this shell, you will find an environment already +set up with the correct PATH and the complete list of +target configure +options+. + Alternatively, if you just want to prepare the SDK without generating the tarball (e.g. because you will just be moving the +host+ directory, or will be generating the tarball on your own), Buildroot also allows diff --git a/package/Config.in b/package/Config.in index a9c6f6fcbc..b4bcb16ffb 100644 --- a/package/Config.in +++ b/package/Config.in @@ -1952,6 +1952,7 @@ menu "Miscellaneous" source "package/collectl/Config.in" source "package/domoticz/Config.in" source "package/empty/Config.in" + source "package/environment-setup/Config.in" source "package/gnuradio/Config.in" source "package/googlefontdirectory/Config.in" source "package/gqrx/Config.in" diff --git a/package/environment-setup/Config.in b/package/environment-setup/Config.in new file mode 100644 index 0000000000..f0fcc7d0f8 --- /dev/null +++ b/package/environment-setup/Config.in @@ -0,0 +1,6 @@ +config BR2_PACKAGE_ENVIRONMENT_SETUP + bool "Environment setup" + help + Install an helper script to setup a build environment + based on buildroot. It's useful when you export an sdk + and want to use buildroot to build an external project diff --git a/package/environment-setup/environment-setup b/package/environment-setup/environment-setup new file mode 100644 index 0000000000..8819e9f60a --- /dev/null +++ b/package/environment-setup/environment-setup @@ -0,0 +1,16 @@ +cat <<'EOF' + _ _ _ _ _ +| |__ _ _(_) | __| |_ __ ___ ___ | |_ +| '_ \| | | | | |/ _` | '__/ _ \ / _ \| __| +| |_) | |_| | | | (_| | | | (_) | (_) | |_ +|_.__/ \__,_|_|_|\__,_|_| \___/ \___/ \__| shell + + Making embedded Linux easy! + +Some tips: +* PATH is now pointing to the HOST_DIR path +* Target configure options are already exported +* To configure do "./configure $CONFIGURE_FLAGS" + +EOF +SDK_PATH=$(dirname "${BASH_SOURCE[0]}") diff --git a/package/environment-setup/environment-setup.mk b/package/environment-setup/environment-setup.mk new file mode 100644 index 0000000000..fc74594459 --- /dev/null +++ b/package/environment-setup/environment-setup.mk @@ -0,0 +1,29 @@ +################################################################################ +# +# environment-setup +# +################################################################################ + +ENVIRONMENT_SETUP_FILE = $(HOST_DIR)/environment-setup +ENVIRONMENT_SETUP_HOST_DIR_SED_EXP = 's+$(HOST_DIR)+\$$SDK_PATH+g' + +define ENVIRONMENT_SETUP_INSTALL_TARGET_CMDS + cp package/environment-setup/environment-setup $(ENVIRONMENT_SETUP_FILE) + for var in $(TARGET_CONFIGURE_OPTS); do \ + printf "export \"$$var\"\n" >> $(ENVIRONMENT_SETUP_FILE); \ + done + printf "export \"CROSS_COMPILE=$(TARGET_CROSS)\"\n" >> $(ENVIRONMENT_SETUP_FILE) + printf "export \"CONFIGURE_FLAGS=--target=$(GNU_TARGET_NAME) \ + --host=$(GNU_TARGET_NAME) \ + --build=$(GNU_HOST_NAME) \ + --prefix=/usr \ + --exec-prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --program-prefix=\"\n" >> $(ENVIRONMENT_SETUP_FILE) + $(SED) $(ENVIRONMENT_SETUP_HOST_DIR_SED_EXP) $(ENVIRONMENT_SETUP_FILE) + printf "PS1=\"\[\e[32m\]buildroot-$(BR2_VERSION)\[\e[m\]:\[\e[34m\]\w\[\e[m\]\$$ \"\n" \ + >> $(ENVIRONMENT_SETUP_FILE) +endef + +$(eval $(generic-package))