Skip to content

Commit

Permalink
[Makefile] split up parse into parse and render
Browse files Browse the repository at this point in the history
Make sure that -j3 can still be used

Signed-off-by: Christopher Hall <hsw@openmoko.com>
  • Loading branch information
hxw committed Sep 18, 2009
1 parent 9195de1 commit 44fd616
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 39 deletions.
78 changes: 57 additions & 21 deletions Makefile
Expand Up @@ -61,6 +61,7 @@ all: ${ALL_TARGETS}
# ----- installation ------------------------------------------

DESTDIR_PATH := $(shell readlink -m "${DESTDIR}")
WORKDIR_PATH := $(shell readlink -m "${WORKDIR}")
VERSION_TAG := $(shell basename "${DESTDIR}")
VERSION_FILE := ${DESTDIR_PATH}/version.txt
SHA_LEVEL := 256
Expand Down Expand Up @@ -200,7 +201,7 @@ XML_FILES_PATH := $(foreach f,${XML_FILES},$(shell readlink -m "${f}"))
RENDER_BLOCK ?= 0

.PHONY: index
index: fonts validate-destdir
index: validate-destdir
cd host-tools/offline-renderer && $(MAKE) index \
XML_FILES="${XML_FILES_PATH}" RENDER_BLOCK="${RENDER_BLOCK}" DESTDIR="${DESTDIR_PATH}"

Expand All @@ -209,6 +210,11 @@ parse: validate-destdir
cd host-tools/offline-renderer && $(MAKE) parse \
XML_FILES="${XML_FILES_PATH}" RENDER_BLOCK="${RENDER_BLOCK}" DESTDIR="${DESTDIR_PATH}"

.PHONY: render
render: fonts validate-destdir
cd host-tools/offline-renderer && $(MAKE) render \
XML_FILES="${XML_FILES_PATH}" RENDER_BLOCK="${RENDER_BLOCK}" DESTDIR="${DESTDIR_PATH}"

.PHONY: combine
combine: validate-destdir
cd host-tools/offline-renderer && $(MAKE) combine \
Expand All @@ -218,41 +224,67 @@ MAKE_BLOCK = $(eval $(call MAKE_BLOCK1,$(strip ${1}),$(strip ${2}),$(strip ${3})

define MAKE_BLOCK1

.PHONY: block${1}
block${1}:
$${MAKE} RENDER_BLOCK=${1} START=${2} COUNT=${3} parse
.PHONY: parse${1}
parse${1}: stamp-r-parse${1}

.PHONY: render${1} fonts parse${1}
render${1}: stamp-r-render${1}

stamp-r-parse${1}:
rm -f "$$@"
$${MAKE} RENDER_BLOCK=${1} parse
touch "$$@"

stamp-r-render${1}:
rm -f "$$@"
$${MAKE} RENDER_BLOCK=${1} START=${2} COUNT=${3} render
touch "$$@"

.PHONY: stamp-r-clean${1}
stamp-r-clean${1}:
rm -f stamp-r-parse${1} stamp-r-render${1}

endef

# ------------------------------------------------
# set this to make even distibution over 24 blocks
# need a better way of setting this
# ------------------------------------------------
count_k := 286
ARTICLE_COUNT_K ?= 286

# the first(0) and last(23) are special
$(call MAKE_BLOCK,0,1,$(shell expr ${count_k} '*' 1000 - 1))
$(call MAKE_BLOCK,0,1,$(shell expr ${ARTICLE_COUNT_K} '*' 1000 - 1))
ITEMS := 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16 17 18 19 20 21 22
$(foreach i,${ITEMS},$(call MAKE_BLOCK,${i},$(shell expr ${i} '*' ${count_k})k,${count_k}k))
$(call MAKE_BLOCK,23,$(shell expr 23 '*' ${count_k})k,all)
$(foreach i,${ITEMS},$(call MAKE_BLOCK,${i},$(shell expr ${i} '*' ${ARTICLE_COUNT_K})k,${ARTICLE_COUNT_K}k))
$(call MAKE_BLOCK,23,$(shell expr 23 '*' ${ARTICLE_COUNT_K})k,all)


MAKE_FARM = $(eval $(call MAKE_FARM1,$(strip ${1}),$(strip ${2}),$(strip ${3})))

define MAKE_FARM1

.PHONY: farm${1}-parse
farm${1}-parse: $$(foreach i,${2},parse$$(strip $${i}))

MAKE_RENDER = $(eval $(call MAKE_RENDER1,$(strip ${1}),$(strip ${2}),$(strip ${3})))
.PHONY: farm${1}-render
farm${1}-render: $$(foreach i,${2},render$$(strip $${i}))

define MAKE_RENDER1
.PHONY: farm${1}-clean
farm${1}-clean: $$(foreach i,${2},stamp-r-clean$$(strip $${i}))

.PHONY: render${1}
render${1}: $$(foreach i,${2},block$$(strip $${i}))
.PHONY: farm${1}
farm${1}: farm${1}-parse farm${1}-render

endef

$(call MAKE_RENDER,1, 0 1 2)
$(call MAKE_RENDER,2, 3 4 5)
$(call MAKE_RENDER,3, 6 7 8)
$(call MAKE_RENDER,4, 9 10 11)
$(call MAKE_RENDER,5,12 13 14)
$(call MAKE_RENDER,6,15 16 17)
$(call MAKE_RENDER,7,18 19 20)
$(call MAKE_RENDER,8,21 22 23)
$(call MAKE_FARM,1, 0 1 2)
$(call MAKE_FARM,2, 3 4 5)
$(call MAKE_FARM,3, 6 7 8)
$(call MAKE_FARM,4, 9 10 11)
$(call MAKE_FARM,5,12 13 14)
$(call MAKE_FARM,6,15 16 17)
$(call MAKE_FARM,7,18 19 20)
$(call MAKE_FARM,8,21 22 23)


# ----- wiki Dump --------------------------------------
Expand Down Expand Up @@ -359,6 +391,7 @@ clean: clean-qt4-simulator clean-console-simulator
$(MAKE) clean -C samo-lib/flash
$(MAKE) clean -C samo-lib/mahatma
cd samo-lib/toppers-jsp && $(MAKE) clean -C wikireader
${RM} stamp-r-*

.PHONY: clean-toolchain
clean-toolchain:
Expand All @@ -384,9 +417,12 @@ help:
@echo ' all - compile all the source'
@echo ' install - install forth, mahatma, fonts in DESTDIR'
@echo ' index - convert XML_FILES to index files in DESTDIR'
@echo ' render<1..8> - render XML_FILES into 3 data files in DESTDIR'
@echo ' parse - render XML_FILES into one big data files in DESTDIR'
@echo ' combine - combine temporary indices to one file in DESTDIR'
@echo ' farm<1..8> - parse/render XML_FILES into 3 data files in DESTDIR (use -j3)'
@echo ' farm<1..8>-parse - parse XML_FILES into 3 HTML files in WORKDIR (use -j3)'
@echo ' farm<1..8>-render - render WORKDIR HTML files into 3 data files in DESTDIR (use -j3)'
@echo ' farm<1..8>-clean - remove stamp files to repeat process'
@echo ' mbr - compile bootloader'
@echo ' mahatma - compile kernel'
@echo ' mahatma-install - install mahatma as kernel in DESTDIR'
Expand Down
46 changes: 28 additions & 18 deletions host-tools/offline-renderer/Makefile
Expand Up @@ -8,55 +8,65 @@ START ?= 1
COUNT ?= all
MODULO ?= 10
DESTDIR ?= .
FONT_PATH ?= ${HOST_TOOLS}/fonts
FONT_PATH ?= $(shell readlink -m ${HOST_TOOLS}/fonts)
WORKDIR ?= /tmp

PREFIX := ${DESTDIR}/pedia
ARTICLES := ${WORKDIR}/articles.pickle
OFFSETS := ${WORKDIR}/offsets.pickle
HTML_ARTICLES := ${WORKDIR}/articles-${RENDER_BLOCK}.html
PREFIX := $(shell readlink -m ${DESTDIR}/pedia)
ARTICLES := $(shell readlink -m ${WORKDIR}/articles.pickle)
OFFSETS := $(shell readlink -m ${WORKDIR}/offsets.pickle)
HTML_ARTICLES := $(shell readlink -m ${WORKDIR}/articles-${RENDER_BLOCK}.html)

PYLZMA_DIR := pylzma-0.3.0

ifneq ($(strip ${VERBOSE}),)
VERBOSE = --verbose
endif

TARGETS =
TARGETS = index parse render combine

.PHONY: all
all: index
all: ${TARGETS}

.PHONY: check-paths
check-paths:
.PHONY: check-xml
check-xml:
@if [ -z "${XML_FILES}" ] ; then echo XML_FILES is not set ; exit 1; fi

.PHONY: check-dirs
check-dirs:
@if [ ! -d "${DESTDIR}" ] ; then echo DESTDIR: "'"${DESTDIR}"'" is not a directory ; exit 1; fi
@if [ ! -d "${WORKDIR}" ] ; then echo WORKDIR: "'"${WORKDIR}"'" is not a directory ; exit 1; fi

.PHONY: check-fonts
check-fonts:
@if [ ! -d "${FONT_PATH}" ] ; then echo FONT_PATH: "'"${FONT_PATH}"'" is not a directory ; exit 1; fi

.PHONY: check-html
check-html:
@if [ -z "${HTML_ARTICLES}" ] ; then echo HTML_ARTICLES is not set ; exit 1; fi


.PHONY: index
index: check-paths
index: check-dirs check-xml
time ./make_article_idx.py ${VERBOSE} \
--article-index="${ARTICLES}" --article-offsets="${OFFSETS}" \
--modulo="${MODULO}" --prefix="${PREFIX}" ${XML_FILES}

.PHONY: article_idx.py
article_idx.py:
@echo Run '"'make index'"' first

.PHONY: parse
parse: pylzma check-paths
parse: check-dirs check-xml check-html
time ./parse_articles.py ${VERBOSE} --xhtml="${HTML_ARTICLES}" \
--start="${START}" --count="${COUNT}" \
--article-offsets="${OFFSETS}" \
${XML_FILES}
time ./make_wrformat.py ${VERBOSE} --font-path="${FONT_PATH}" \
--number="${RENDER_BLOCK}" \

.PHONY: render
render: pylzma check-dirs check-fonts check-html
time ./make_wrformat.py ${VERBOSE} --number="${RENDER_BLOCK}" \
--font-path="${FONT_PATH}" \
--article-index="${ARTICLES}" \
--prefix="${PREFIX}" "${HTML_ARTICLES}"

.PHONY: combine
combine: check-paths
combine: check-dirs
time ./combine_idx.py ${VERBOSE} --prefix="${PREFIX}"

# sudo apt-get install python-dev
Expand Down
1 change: 1 addition & 0 deletions samo-lib/Mk/definitions.mk
Expand Up @@ -111,3 +111,4 @@ CROSS_OBJCOPY = ${CROSS}objcopy
RM = rm -f
MKDIR = mkdir -p
COPY = cp -p
TOUCH = touch

0 comments on commit 44fd616

Please sign in to comment.