From patchwork Tue Oct 17 01:11:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 115996 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4295833qgn; Mon, 16 Oct 2017 18:12:38 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCQHcuj2RzUWHrT5FLegqz9JL2fwXX86sUmGUe6dVfNTNycU+yqeu5xAkoCrocHh1UdvS7r X-Received: by 10.80.137.6 with SMTP id e6mr15094458ede.32.1508202758233; Mon, 16 Oct 2017 18:12:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508202758; cv=none; d=google.com; s=arc-20160816; b=YcdRAsrECv7o6hUXSrLQan0wkyTZ4WwX48xYXKG/0JSHHnhO1rTMsLHKLypyw4F20p Dm/s31A3uFHZNRrm4hqsMrHcopFsg6dH1v5HVKr0OOI5Ks1Y13TKyiUgwbo40tFHpawl MknmqHMTuEQfk6ZPaSTOBYYFWtPHPGds0lQqO63QTxay5ejX4rX1hAxGJ6mNS7o/bM8+ hkDQp/7kIuhlDL9iduTi1CxC+qNhVYNo2U+iPYcVGQaAlgBXpJBjF6pl0Z+Rt9l4H3NS 3K8yWj7fHIo5JIXM+o2jPv5gYb7agh7RzjB+CtWlvS5JAVUiE8tivgLwylLwDmw+nXRX MQ7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=Aq/UNJTKdc7c6b6YE7YUksdke/PxIKzQ9OPhp15Qyew=; b=nBtmumkCcz07GLHfB5kBsg2KWcb0C7cgu0FfjGFqctit9qwID5/gF6xP46PdhPOF3f 94DhqfdboZdStbLPwROLoWc8UGWvVe4s+iYebiAm6RWSjpQjOvgWSaMaznub79NcYqqx puvDiExfTsHvEY+rghs5CqZ3Xw4pP9jWDIoPWAFTDuK2AzWSBqWb68pFcKC9UMZvYL11 UW97gOolOHNKboFssvlHJ+79ubIecE7PP7pT9NKekmZz6z9EXLXhA6tt3oyJLHTWct1i Ui83yn3aB2P9urjtSPPBLmxiZso6gjbZsL4NtItXRkR6XYnHK9EeUbqFpCozCMt7V9dO mh7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=lL1eOo8c; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id c60si6320190edd.191.2017.10.16.18.12.37; Mon, 16 Oct 2017 18:12:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=lL1eOo8c; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id C8FA3C21D6A; Tue, 17 Oct 2017 01:12:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2EEDEC21C41; Tue, 17 Oct 2017 01:12:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2F4A8C21C59; Tue, 17 Oct 2017 01:12:31 +0000 (UTC) Received: from conuserg-09.nifty.com (conuserg-09.nifty.com [210.131.2.76]) by lists.denx.de (Postfix) with ESMTPS id 0A252C21C40 for ; Tue, 17 Oct 2017 01:12:29 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id v9H1Bnl4015917; Tue, 17 Oct 2017 10:11:51 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v9H1Bnl4015917 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1508202711; bh=zLaTgaDTmK3rQIdi5LK7KxaA4X2stOBD6mJX0M0/4YU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lL1eOo8cHPqpTkk5xDWZBMyBL5jtIaCQBdHcFkhJ5HY3MEAGsqTgOljFFoQbCJfmd yL466/a4XJ25iF3dEQiATF32jyGj0kQXGxLk12fqoaGD1ID8J7Z/SzEKH8IquLuKUf IXWtXmgaDz71zVSHHv+rUcUp+Vs7RgOdbo+PpA6MHyld86lt4Udce+mS1nGSYBd0Rz YBfzudfSfpxto7Vc4ZpfbLyvULiyE5J+clIvAr5Jk6i39dYHBJdBaH8tm+UTNu9dkO mJyIi+h2N5mH8NyN0mONM14fJAFJQiMEW9CJsD4TrKVj3hZwEQI34Z9VHdAn75cb0E KMdxWB+QMWiJA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Tue, 17 Oct 2017 10:11:42 +0900 Message-Id: <1508202703-23165-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508202703-23165-1-git-send-email-yamada.masahiro@socionext.com> References: <1508202703-23165-1-git-send-email-yamada.masahiro@socionext.com> Cc: Tom Rini Subject: [U-Boot] [PATCH 2/3] pylibfdt: move pylibfdt to scripts/dtc/pylibfdt and refactor makefile X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The pylibfdt is used by dtoc (and, indirectly by binman), but there is no reason why it must be generated in the tools/ directory. Recently, U-Boot switched over to the bundled DTC, and the directory structure under scripts/dtc/ now mirrors the upstream DTC project. So, scripts/dtc/pylibfdt is the best location. I also rewrote the Makefile in a cleaner Kbuild style. The scripts from the upstream have been moved as follows: lib/libfdt/pylibfdt/setup.py -> scripts/dtc/pylibfdt/setup.py lib/libfdt/pylibfdt/libfdt.i -> scripts/dtc/pylibfdt/libfdt.i_shipped The .i_shipped is coped to .i during building because the .i must be located in the objtree when we build it out of tree. Signed-off-by: Masahiro Yamada --- Makefile | 2 +- scripts/Makefile.spl | 4 +-- scripts/dtc/Makefile | 3 +++ scripts/dtc/pylibfdt/.gitignore | 4 +++ scripts/dtc/pylibfdt/Makefile | 30 ++++++++++++++++++++++ .../dtc/pylibfdt/libfdt.i_shipped | 0 {lib/libfdt => scripts/dtc}/pylibfdt/setup.py | 0 tools/.gitignore | 4 --- tools/Makefile | 30 ---------------------- tools/binman/binman.py | 2 +- 10 files changed, 41 insertions(+), 38 deletions(-) create mode 100644 scripts/dtc/pylibfdt/.gitignore create mode 100644 scripts/dtc/pylibfdt/Makefile rename lib/libfdt/pylibfdt/libfdt.i => scripts/dtc/pylibfdt/libfdt.i_shipped (100%) rename {lib/libfdt => scripts/dtc}/pylibfdt/setup.py (100%) diff --git a/Makefile b/Makefile index 888486b..0044503 100644 --- a/Makefile +++ b/Makefile @@ -1380,7 +1380,7 @@ $(timestamp_h): $(srctree)/Makefile FORCE $(call filechk,timestamp.h) checkbinman: tools - @if ! ( echo 'import libfdt' | ( PYTHONPATH=tools $(PYTHON) )); then \ + @if ! ( echo 'import libfdt' | ( PYTHONPATH=scripts/dtc/pylibfdt $(PYTHON) )); then \ echo >&2; \ echo >&2 '*** binman needs the Python libfdt library.'; \ echo >&2 '*** Either install it on your system, or try:'; \ diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index 49b27ac..065bb25 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -257,7 +257,7 @@ quiet_cmd_fdtgrep = FDTGREP $@ $(obj)/$(SPL_BIN).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE $(call if_changed,fdtgrep) -pythonpath = PYTHONPATH=tools +pythonpath = PYTHONPATH=scripts/dtc/pylibfdt quiet_cmd_dtocc = DTOC C $@ cmd_dtocc = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ platdata @@ -381,7 +381,7 @@ ifneq ($(cmd_files),) endif checkdtoc: tools - @if ! ( echo 'import libfdt' | ( PYTHONPATH=tools $(PYTHON) )); then \ + @if ! ( echo 'import libfdt' | ( PYTHONPATH=scripts/dtc/pylibfdt $(PYTHON) )); then \ echo '*** dtoc needs the Python libfdt library. Either '; \ echo '*** install it on your system, or try:'; \ echo '***'; \ diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile index 2a48022..f4a16ed 100644 --- a/scripts/dtc/Makefile +++ b/scripts/dtc/Makefile @@ -29,3 +29,6 @@ $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h # generated files need to be cleaned explicitly clean-files := dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h + +# Added for U-Boot +subdir-y += pylibfdt diff --git a/scripts/dtc/pylibfdt/.gitignore b/scripts/dtc/pylibfdt/.gitignore new file mode 100644 index 0000000..033f23d --- /dev/null +++ b/scripts/dtc/pylibfdt/.gitignore @@ -0,0 +1,4 @@ +/_libfdt.so +/libfdt.py +/libfdt.pyc +/libfdt_wrap.c diff --git a/scripts/dtc/pylibfdt/Makefile b/scripts/dtc/pylibfdt/Makefile new file mode 100644 index 0000000..01d5e0f --- /dev/null +++ b/scripts/dtc/pylibfdt/Makefile @@ -0,0 +1,30 @@ +# Unfortunately setup.py below cannot handle srctree being ".." which it often +# is. It fails with an error like: +# Fatal error: can't create build/temp.linux-x86_64-2.7/../lib/libfdt/fdt.o: +# No such file or directory +# To fix this, use an absolute path. +LIBFDT_srcdir = $(abspath $(srctree)/$(src)/../libfdt) + +include $(LIBFDT_srcdir)/Makefile.libfdt + +# Unfortunately setup.py (or actually the Python distutil implementation) puts +# files into the same directory as the .i file. We cannot touch the source +# directory, so we "ship" .i file into the objtree. +PYLIBFDT_srcs = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_SRCS)) \ + $(obj)/libfdt.i + +quiet_cmd_pymod = PYMOD $@ + cmd_pymod = unset CC; unset CROSS_COMPILE; unset CFLAGS;\ + LDFLAGS="$(HOSTLDFLAGS)" \ + VERSION="u-boot-$(UBOOTVERSION)" \ + CPPFLAGS="$(HOSTCFLAGS) -I$(LIBFDT_srcdir)" OBJDIR=$(obj) \ + SOURCES="$(PYLIBFDT_srcs)" \ + SWIG_OPTS="-I$(LIBFDT_srcdir) -I$(LIBFDT_srcdir)/.." \ + $(PYTHON) $< --quiet build_ext --inplace + +$(obj)/_libfdt.so: $(src)/setup.py $(PYLIBFDT_srcs) FORCE + $(call if_changed,pymod) + +always += _libfdt.so + +clean-files += libfdt.i _libfdt.so libfdt.py libfdt_wrap.c diff --git a/lib/libfdt/pylibfdt/libfdt.i b/scripts/dtc/pylibfdt/libfdt.i_shipped similarity index 100% rename from lib/libfdt/pylibfdt/libfdt.i rename to scripts/dtc/pylibfdt/libfdt.i_shipped diff --git a/lib/libfdt/pylibfdt/setup.py b/scripts/dtc/pylibfdt/setup.py similarity index 100% rename from lib/libfdt/pylibfdt/setup.py rename to scripts/dtc/pylibfdt/setup.py diff --git a/tools/.gitignore b/tools/.gitignore index 5293d44..6a487d2 100644 --- a/tools/.gitignore +++ b/tools/.gitignore @@ -1,4 +1,3 @@ -/_libfdt.so /atmel_pmecc_params /bin2header /bmp_logo @@ -17,9 +16,6 @@ /img2srec /kwboot /lib/ -/libfdt.py -/libfdt.pyc -/libfdt_wrap.c /mips-relocs /mkenvimage /mkexynosspl diff --git a/tools/Makefile b/tools/Makefile index c164774..38090a9 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -64,15 +64,6 @@ LIBFDT_CSRCS := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c \ fdt_empty_tree.c fdt_addresses.c fdt_overlay.c \ fdt_region.c -# Unfortunately setup.py below cannot handle srctree being ".." which it often -# is. It fails with an error like: -# Fatal error: can't create build/temp.linux-x86_64-2.7/../lib/libfdt/fdt.o: -# No such file or directory -# To fix this, use an absolute path. -libfdt_tree := $(shell readlink -f $(srctree)/lib/libfdt) - -LIBFDT_SRCS := $(addprefix $(libfdt_tree)/, $(LIBFDT_CSRCS)) -LIBFDT_SWIG := $(addprefix $(libfdt_tree)/, pylibfdt/libfdt.i) LIBFDT_OBJS := $(addprefix lib/libfdt/, $(patsubst %.c, %.o, $(LIBFDT_CSRCS))) RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \ @@ -124,23 +115,6 @@ mkimage-objs := $(dumpimage-mkimage-objs) mkimage.o fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o -# Unfortunately setup.py (or actually the Python distutil implementation) -# puts files into the same directory as the .i file. We cannot touch the source -# directory, so we copy the .i file into the tools/ build subdirectory before -# calling setup. This directory is safe to write to. This ensures that we get -# all three files in $(obj)/tools: _libfdt.so, libfdt.py and libfdt_wrap.c -# The latter is a temporary file which we could actually remove. -tools/_libfdt.so: $(LIBFDT_SRCS) $(LIBFDT_SWIG) - $(Q)cp $(LIBFDT_SWIG) tools/. - $(Q)unset CC; \ - unset CROSS_COMPILE; \ - LDFLAGS="$(HOSTLDFLAGS)" CFLAGS= VERSION="u-boot-$(UBOOTVERSION)" \ - CPPFLAGS="$(_hostc_flags)" OBJDIR=tools \ - SOURCES="$(LIBFDT_SRCS) tools/libfdt.i" \ - SWIG_OPTS="-I$(srctree)/lib/libfdt -I$(srctree)/lib" \ - $(PYTHON) $(libfdt_tree)/pylibfdt/setup.py --quiet build_ext \ - --build-lib tools - ifneq ($(CONFIG_MX23)$(CONFIG_MX28),) # Add CONFIG_MXS into host CFLAGS, so we can check whether or not register # the mxsimage support within tools/mxsimage.c . @@ -232,10 +206,6 @@ clean-dirs := lib common always := $(hostprogs-y) -# Build a libfdt Python module if swig is available -# Use 'sudo apt-get install swig libpython-dev' to enable this -always += $(if $(shell which swig 2> /dev/null),_libfdt.so) - # Generated LCD/video logo LOGO_H = $(objtree)/include/bmp_logo.h LOGO_DATA_H = $(objtree)/include/bmp_logo_data.h diff --git a/tools/binman/binman.py b/tools/binman/binman.py index 09dc36a..e75a59d 100755 --- a/tools/binman/binman.py +++ b/tools/binman/binman.py @@ -21,7 +21,7 @@ for dirname in ['../patman', '../dtoc', '..']: sys.path.insert(0, os.path.join(our_path, dirname)) # Bring in the libfdt module -sys.path.insert(0, 'tools') +sys.path.insert(0, 'scripts/dtc/pylibfdt') # Also allow entry-type modules to be brought in from the etype directory. sys.path.insert(0, os.path.join(our_path, 'etype'))