From patchwork Sun Jun 8 14:03:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 357194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id 36FE91400B0 for ; Mon, 9 Jun 2014 00:04:14 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 504FD8B282; Sun, 8 Jun 2014 14:04:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yo+VPMP4AVdj; Sun, 8 Jun 2014 14:04:08 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 664BD8B0AC; Sun, 8 Jun 2014 14:04:04 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 4D3561C2879 for ; Sun, 8 Jun 2014 14:04:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 4A3D187BE4 for ; Sun, 8 Jun 2014 14:04:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1dpme9YxWfeo for ; Sun, 8 Jun 2014 14:04:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-we0-f172.google.com (mail-we0-f172.google.com [74.125.82.172]) by hemlock.osuosl.org (Postfix) with ESMTPS id 8B51287464 for ; Sun, 8 Jun 2014 14:04:00 +0000 (UTC) Received: by mail-we0-f172.google.com with SMTP id k48so4835390wev.3 for ; Sun, 08 Jun 2014 07:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=DQDcEQcnVcEEapslbl61s5OCwKerwS8MNZgND8tjpsA=; b=Nmr2pmH2HXul+GmSrtROPOCPd8k/sLU0sQ8OQtj49fqFkSp2ZlhbNnRQsiQwQb6SZ2 SFYNpimcAxhhVEP30GZpnvP6UduPneFtV7ExZIyZ7gcHqGIRCQpT/2pZ53p31+LvUwyf L7RQ1ncpy1hL/d59f0DBxjwkDQIfAK6Z67oHe2bbLlMyH05PoaMiZsI0YPqqJGEGjJ11 a37hrqmRP0YGePwvirlg/EZxqotOABJm60Dlt4k1kG41DgpfCDop6v9OPIpRDxwH5bKg vybKTXxKi8qI46QyJ/67Th+eo5067rD0ngI9+wyNfXJczQg5aYx/CnKex7l15zwkeViv lTTA== X-Received: by 10.180.182.115 with SMTP id ed19mr12318734wic.29.1402236238916; Sun, 08 Jun 2014 07:03:58 -0700 (PDT) Received: from gourin.bzh.lan (ks3095497.kimsufi.com. [94.23.60.27]) by mx.google.com with ESMTPSA id rw4sm20694240wjb.44.2014.06.08.07.03.57 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 08 Jun 2014 07:03:58 -0700 (PDT) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sun, 8 Jun 2014 16:03:47 +0200 Message-Id: <10fe9d34229645229305893556c28298bc99ed2c.1402236171.git.yann.morin.1998@free.fr> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: References: Cc: Thomas Petazzoni , "Yann E. MORIN" Subject: [Buildroot] [PATCH 3/9] graphs-depends: merge redundant-dependencies elimination X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net From: "Yann E. MORIN" Merge the redundant-dependencies elimination into the newly introduced transitive-dependencies elimination. This makes the code cleaner and much shorter, because: - the ('all',pkg) redundant dependency is in fact a transitive dependency, and we now have code to deal with that - the (pkg,'toolchain') dependency is easy enough to deal with that having a separate function for that is overkill Signed-off-by: "Yann E. MORIN" Cc: Thomas Petazzoni Cc: Maxime Hadjinlian Cc: Samuel Martin --- support/scripts/graph-depends | 46 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends index c5fb520..3560a15 100755 --- a/support/scripts/graph-depends +++ b/support/scripts/graph-depends @@ -146,40 +146,6 @@ def get_all_depends(pkgs): def pkg_node_name(pkg): return pkg.replace("-","") -# Helper function for remove_redundant_deps(). This function tells -# whether package "pkg" is the dependency of another package that is -# not the special "all" package. -def has_redundant_deps(deps, pkg): - for dep in deps: - if dep[0] != "all" and dep[1] == pkg: - return True - return False - -# This function removes redundant dependencies of the special "all" -# package. This "all" package is created to reflect the origin of the -# selection for all packages that are not themselves selected by any -# other package. So for example if you enable libpng, zlib is enabled -# as a dependency. But zlib being selected by libpng, it also appears -# as a dependency of the "all" package. This needlessly complicates -# the generated dependency graph. So when we have the dependency list -# (all -> zlib, all -> libpn, libpng -> zlib), we get rid of the 'all -# -> zlib' dependency, because zlib is already a dependency of a -# regular package. -def remove_redundant_deps(deps): - newdeps = [] - for dep in deps: - if dep[0] == "all" and dep[1] == "toolchain": - newdeps.append(dep) - continue - if dep[0] != "all" and dep[1] != "toolchain": - newdeps.append(dep) - continue - if not has_redundant_deps(deps, dep[1]): - newdeps.append(dep) - continue - sys.stderr.write("Removing redundant dep %s -> %s\n" % (dep[0],dep[1])) - return newdeps - TARGET_EXCEPTIONS = [ "target-generic-securetty", "target-generic-issue", @@ -217,8 +183,6 @@ if mode == FULL_MODE: elif mode == PKG_MODE: dependencies = get_all_depends([rootpkg]) -dependencies = remove_redundant_deps(dependencies) - # Make the dependencies a dictionnary { 'pkg':[dep1, dep2, ...] } dict_deps = {} for dep in dependencies: @@ -260,10 +224,18 @@ def remove_transitive_deps(pkg,deps): new_d.append(d[i]) return new_d +# This function removes the dependency on the 'toolchain' package +def remove_toolchain_deps(pkg,deps): + return [p for p in deps[pkg] if not p == 'toolchain'] + # This functions trims down the dependency list of all packages. +# It applies in sequence all the dependency-elimination methods. def remove_extra_deps(deps): for pkg in deps.keys(): - if not transitive: + if not pkg == 'all': + deps[pkg] = remove_toolchain_deps(pkg,deps) + for pkg in deps.keys(): + if not transitive or pkg == 'all': deps[pkg] = remove_transitive_deps(pkg,deps) return deps