From d4e1b47a922576e6af98cd84913471a6d3096ac0 Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Wed, 18 Nov 2009 02:42:31 +0100 Subject: Basic build infrastructure for Python scripts This patch adds basic boilerplate support (based on corresponding Perl sections) for enabling the building and installation Python scripts. There are currently no Python scripts being built, and when Python scripts are added in future patches, their building and installation can be disabled by defining NO_PYTHON. Signed-off-by: Johan Herland Signed-off-by: Junio C Hamano --- Makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 268aede56..b27a7d603 100644 --- a/Makefile +++ b/Makefile @@ -164,6 +164,8 @@ all:: # # Define NO_PERL if you do not want Perl scripts or libraries at all. # +# Define NO_PYTHON if you do not want Python scripts or libraries at all. +# # Define NO_TCLTK if you do not want Tcl/Tk GUI. # # The TCL_PATH variable governs the location of the Tcl interpreter @@ -308,6 +310,7 @@ LIB_H = LIB_OBJS = PROGRAMS = SCRIPT_PERL = +SCRIPT_PYTHON = SCRIPT_SH = TEST_PROGRAMS = @@ -345,6 +348,7 @@ SCRIPT_PERL += git-svn.perl SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ $(patsubst %.perl,%,$(SCRIPT_PERL)) \ + $(patsubst %.py,%,$(SCRIPT_PYTHON)) \ git-instaweb # Empty... @@ -398,8 +402,12 @@ endif ifndef PERL_PATH PERL_PATH = /usr/bin/perl endif +ifndef PYTHON_PATH + PYTHON_PATH = /usr/bin/python +endif export PERL_PATH +export PYTHON_PATH LIB_FILE=libgit.a XDIFF_LIB=xdiff/lib.a @@ -1308,6 +1316,10 @@ ifeq ($(PERL_PATH),) NO_PERL=NoThanks endif +ifeq ($(PYTHON_PATH),) +NO_PYTHON=NoThanks +endif + QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir QUIET_SUBDIR1 = @@ -1355,6 +1367,7 @@ prefix_SQ = $(subst ','\'',$(prefix)) SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) +PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH)) TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH)) LIBS = $(GITLIBS) $(EXTLIBS) -- cgit v1.2.1 From 2fe40b63001844f9a884ac9cb49cabd5e183b62f Mon Sep 17 00:00:00 2001 From: Sverre Rabbelier Date: Wed, 18 Nov 2009 02:42:32 +0100 Subject: Add Python support library for remote helpers This patch introduces parts of a Python package called "git_remote_helpers" containing the building blocks for remote helpers written in Python. No actual remote helpers are part of this patch, this patch only includes the common basics needed to start writing such helpers. The patch includes the necessary Makefile additions to build and install the git_remote_helpers Python package along with the rest of Git. This patch is based on Johan Herland's git_remote_cvs patch and has been improved by the following contributions: - David Aguilar: Lots of Python coding style fixes - David Aguilar: DESTDIR support in Makefile Cc: David Aguilar Cc: Johan Herland Signed-off-by: Sverre Rabbelier Signed-off-by: Johan Herland Signed-off-by: Junio C Hamano --- Makefile | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b27a7d603..a95ffda23 100644 --- a/Makefile +++ b/Makefile @@ -1398,6 +1398,9 @@ ifndef NO_TCLTK endif ifndef NO_PERL $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all +endif +ifndef NO_PYTHON + $(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all endif $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) @@ -1517,6 +1520,35 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh mv $@+ $@ endif # NO_PERL +ifndef NO_PYTHON +$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS +$(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py + $(QUIET_GEN)$(RM) $@ $@+ && \ + INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \ + --no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \ + instlibdir` && \ + sed -e '1{' \ + -e ' s|#!.*python|#!$(PYTHON_PATH_SQ)|' \ + -e '}' \ + -e 's|^import sys.*|&; \\\ + import os; \\\ + sys.path[0] = os.environ.has_key("GITPYTHONLIB") and \\\ + os.environ["GITPYTHONLIB"] or \\\ + "@@INSTLIBDIR@@"|' \ + -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \ + $@.py >$@+ && \ + chmod +x $@+ && \ + mv $@+ $@ +else # NO_PYTHON +$(patsubst %.py,%,$(SCRIPT_PYTHON)): % : unimplemented.sh + $(QUIET_GEN)$(RM) $@ $@+ && \ + sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ + -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \ + unimplemented.sh >$@+ && \ + chmod +x $@+ && \ + mv $@+ $@ +endif # NO_PYTHON + configure: configure.ac $(QUIET_GEN)$(RM) $@ $<+ && \ sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ @@ -1741,6 +1773,9 @@ install: all ifndef NO_PERL $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install endif +ifndef NO_PYTHON + $(MAKE) -C git_remote_helpers prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install +endif ifndef NO_TCLTK $(MAKE) -C gitk-git install $(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install @@ -1854,6 +1889,9 @@ clean: ifndef NO_PERL $(RM) gitweb/gitweb.cgi $(MAKE) -C perl clean +endif +ifndef NO_PYTHON + $(MAKE) -C git_remote_helpers clean endif $(MAKE) -C templates/ clean $(MAKE) -C t/ clean -- cgit v1.2.1 From ac10a85785baee56bb4a04ad5f847d15ffba0893 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 7 Dec 2009 00:32:50 -0500 Subject: tests: handle NO_PYTHON setting Without this, test-lib checks that the git_remote_helpers directory has been built. However, if we are building without python, we will not have done anything at all in that directory, and test-lib's sanity check will fail. We bump the inclusion of GIT-BUILD-OPTIONS further up in test-lib; it contains configuration, and as such should be read before we do any checks (and in this particular case, we need its value to do our check properly). Signed-off-by: Jeff King Looks-fine-to-me-by: Brandon Casey Acked-by: Johan Herland Signed-off-by: Junio C Hamano --- Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a95ffda23..b43725210 100644 --- a/Makefile +++ b/Makefile @@ -1674,6 +1674,7 @@ GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@ @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@ @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@ + @echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@ ### Detect Tck/Tk interpreter path changes ifndef NO_TCLTK -- cgit v1.2.1