Skip to content

Commit

Permalink
build: try to code-gen during bootstrap
Browse files Browse the repository at this point in the history
This allows us to create a completely bootstrapped tarball that does not
require java or swig as build-deps.
  • Loading branch information
Cory Fields committed Nov 8, 2012
1 parent 5132cf8 commit 9b04767
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 48 deletions.
1 change: 1 addition & 0 deletions bootstrap
@@ -1,2 +1,3 @@
#!/bin/sh #!/bin/sh
BOOTSTRAP_STANDALONE=1 make -f bootstrap.mk BOOTSTRAP_STANDALONE=1 make -f bootstrap.mk
BOOTSTRAP_STANDALONE=1 make -f codegenerator.mk
60 changes: 60 additions & 0 deletions codegenerator.mk
@@ -0,0 +1,60 @@
TOPDIR ?= .
INTERFACES_DIR ?= xbmc/interfaces

JAVA ?= $(shell which java)
ifeq ($(JAVA),)
JAVA = java-not-found
endif

SWIG ?= $(shell which swig)
ifeq ($(SWIG),)
SWIG = swig-not-found
endif

DOXYGEN ?= $(shell which doxygen)
ifeq ($(DOXYGEN),)
DOXYGEN = doxygen-not-found
else
DOXY_XML_PATH=$(GENDIR)/doxygenxml
endif

GENDIR = $(INTERFACES_DIR)/python/generated
GROOVY_DIR = $(TOPDIR)/lib/groovy

GENERATED = $(GENDIR)/AddonModuleXbmc.cpp
GENERATED += $(GENDIR)/AddonModuleXbmcgui.cpp
GENERATED += $(GENDIR)/AddonModuleXbmcplugin.cpp
GENERATED += $(GENDIR)/AddonModuleXbmcaddon.cpp
GENERATED += $(GENDIR)/AddonModuleXbmcvfs.cpp

vpath %.i $(INTERFACES_DIR)/swig

$(GENDIR)/%.cpp: $(GENDIR)/%.xml $(JAVA) $(SWIG) $(DOXY_XML_PATH)
$(JAVA) -cp "$(GROOVY_DIR)/groovy-all-1.8.4.jar:$(GROOVY_DIR)/commons-lang-2.6.jar:$(TOPDIR)/tools/codegenerator:$(INTERFACES_DIR)/python" \
groovy.ui.GroovyMain $(TOPDIR)/tools/codegenerator/Generator.groovy $< $(INTERFACES_DIR)/python/PythonSwig.cpp.template $@ $(DOXY_XML_PATH)
rm $<

$(GENDIR)/%.xml: %.i $(SWIG) $(JAVA)
mkdir -p $(GENDIR)
$(SWIG) -w401 -c++ -o $@ -xml -I$(TOPDIR)/xbmc -xmllang python $<

codegenerated: $(DOXYGEN) $(SWIG) $(JAVA) $(GENERATED)

$(DOXY_XML_PATH): $(SWIG) $(JAVA)
cd $(INTERFACES_DIR)/python; ($(DOXYGEN) Doxyfile > /dev/null) 2>&1 | grep -v " warning: "
touch $@

$(DOXYGEN):
@echo "Warning: No doxygen installed. The Api will not have any docstrings."
mkdir -p $(GENDIR)/doxygenxml

$(JAVA):
@echo Java not found, it will be used if found after configure.
@echo This is not necessarily an error.
@false

$(SWIG):
@echo Swig not found, it will be used if found after configure.
@echo This is not necessarily an error.
@false

60 changes: 12 additions & 48 deletions xbmc/interfaces/python/Makefile.in
@@ -1,61 +1,25 @@
INCLUDES=-I../../.. -I. -I../../ -I../../linux -I../../../guilib -I. INCLUDES=-I../../.. -I. -I../../ -I../../linux -I../../../guilib -I.


INTERFACES = AddonModuleXbmc.i ifeq (@USE_DOXYGEN@,1)
INTERFACES += AddonModuleXbmcgui.i DOXYGEN=@DOXYGEN_EXE@
INTERFACES += AddonModuleXbmcplugin.i endif
INTERFACES += AddonModuleXbmcaddon.i
INTERFACES += AddonModuleXbmcvfs.i

GENDIR = generated


GENERATED = $(patsubst %.i,$(GENDIR)/%.cpp,$(INTERFACES)) TOPDIR = @abs_top_srcdir@
INTERFACES_DIR = @abs_top_srcdir@/xbmc/interfaces
JAVA=@JAVA_EXE@
SWIG=@SWIG_EXE@
LIB=python_binding.a
all: $(LIB)


GENERATOR=@abs_top_srcdir@/tools/codegenerator include ../../../codegenerator.mk


SRCS= CallbackHandler.cpp LanguageHook.cpp \ SRCS= CallbackHandler.cpp LanguageHook.cpp \
XBPyThread.cpp XBPython.cpp swig.cpp \ XBPyThread.cpp XBPython.cpp swig.cpp \
$(GENERATED) $(GENERATED)


SWIG_INTERFACE_DIR=../swig INCLUDES += @PYTHON_CPPFLAGS@

.SECONDARY: $(GENERATED)
ifeq (@USE_DOXYGEN@,1)
DOXY_XML_PATH=$(GENDIR)/doxygenxml
else
DOXY_XML_PATH=
endif

SWIG_INC += -I@abs_top_srcdir@/xbmc
INCLUDES += @PYTHON_CPPFLAGS@ $(SWIG_INC)

CLEAN_FILES=$(GENDIR)

LIB=python_binding.a

CXXFLAGS+= -DSWIGRUNTIME_DEBUG -DSTATIC_LINKED

# This prevents the removal of the intermediate files. Without
# this target the make will re-reun the generator a second time
# without any changes.
.SECONDARY:


include ../../../Makefile.include include ../../../Makefile.include
-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS))) -include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))


$(GENDIR)/dummy: ../legacy/*.h
mkdir -p $(GENDIR)
touch $(GENDIR)/dummy

$(GENDIR)/doxygenxml/dummy: $(GENDIR)/dummy ./Doxyfile
ifeq (@USE_DOXYGEN@,1)
(@DOXYGEN_EXE@ > /dev/null) 2>&1 | grep -v " warning: "
else
echo "Warning: No doxygen installed. The Api will not have any docstrings."
mkdir -p $(GENDIR)/doxygenxml
endif
touch $(GENDIR)/doxygenxml/dummy

$(GENDIR)/%.xml: $(SWIG_INTERFACE_DIR)/%.i $(GENDIR)/dummy $(GENDIR)/doxygenxml/dummy
@SWIG_EXE@ -w401 -c++ -outdir $(GENDIR) -o $@ -xml $(SWIG_INC) -xmllang python $<

$(GENDIR)/%.cpp: $(GENDIR)/%.xml
@JAVA_EXE@ -cp "../../../lib/groovy/groovy-all-1.8.4.jar:../../../lib/groovy/commons-lang-2.6.jar:$(GENERATOR):./" groovy.ui.GroovyMain $(GENERATOR)/Generator.groovy $< PythonSwig.cpp.template $@ $(DOXY_XML_PATH)

0 comments on commit 9b04767

Please sign in to comment.