1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
# -*- coding: utf-8 -*-
#
# WAF build script for geany-plugins - Markdown
#
# Copyright 2011 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
# Copyright 2011 Frank Lanitz <frnk(at)frank(dot)uvena(dot)de>
# Copyright 2012 Colomban Wendling <ban(at)herbesfolles(dot)org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from build.wafutils import build_plugin, target_is_win32
from waflib.Task import Task
from waflib.TaskGen import extension
from waflib.Utils import subst_vars
name = 'Markdown'
includes = [ 'src' ]
defines = [ subst_vars('MARKDOWN_DATA_DIR="${PKGDATADIR}/markdown"', bld.env),
subst_vars('MARKDOWN_DOC_DIR="${DOCDIR}/markdown"', bld.env),
subst_vars('MARKDOWN_HELP_FILE="${DOCDIR}/markdown/html/help.html"', bld.env) ]
libraries = [ 'GTK', 'GTHREAD', 'WEBKIT', 'DISCOUNT' ]
sources = [ "src/conf.c",
"src/markdown-gtk-compat.c",
"src/plugin.c",
"src/viewer.c" ]
# sources for embedded peg-markdown library
sources_peg_markdown = [ "peg-markdown/markdown_lib.c",
"peg-markdown/markdown_output.c",
"peg-markdown/markdown_parser.c",
"peg-markdown/odf.c",
"peg-markdown/parsing_functions.c",
"peg-markdown/utility_functions.c" ]
# sources for peg utility
sources_peg = [ "peg-markdown/peg-0.1.9/leg.c",
"peg-markdown/peg-0.1.9/compile.c",
"peg-markdown/peg-0.1.9/tree.c" ]
def _build_peg_markdown():
class PegLeg(Task):
run_str = '${SRC[0].abspath()} -o ${TGT} ${SRC[1].abspath()}'
color = 'PINK'
@extension('.leg')
def process_leg(self, node):
tg = self.bld.get_tgen_by_name('LEG')
leg = tg.link_task.outputs[0]
tsk = self.create_task('PegLeg', [leg, node], node.change_ext('.c'))
self.source.extend(tsk.outputs)
# build peg utility
bld.new_task_gen(
features = ['c', 'cprogram'],
name = 'LEG',
target = 'leg',
source = sources_peg,
includes = ['markdown/peg-markdown/peg-0.1.9'],
install_path = None)
# put all following tasks into a new group to get the build order right
bld.add_group()
# generate markdown_parser.c
bld.new_task_gen(
features = ['c'],
use = libraries,
target = 'markdown_parser.c',
source = 'peg-markdown/markdown_parser.leg',
includes = ['peg-markdown'])
# tell the code about what we want
defines.append('FULL_PRICE=1')
includes.append('peg-markdown')
sources.extend(sources_peg_markdown)
def _build_plugin():
build_plugin(bld, name, sources=sources, includes=includes, libraries=libraries, defines=defines)
def _install_docs():
# install docs
helpfiles = [ 'docs/help.html',
'docs/plugin.png',
'docs/plugin_mgr.png',
'docs/plugin_prefs.png',
'docs/plugin_small.png',
'docs/set_filetype.png',
'docs/settings.png' ]
docdir = '${G_PREFIX}/doc/plugins' if target_is_win32(bld) else '${DOCDIR}'
bld.install_files('%s/markdown/html' % docdir, helpfiles)
# if we didn't find the Discount/libmarkdown library, build and use the embedded peg-markdown library
if not bld.env['LIB_DISCOUNT']:
_build_peg_markdown()
_build_plugin()
_install_docs()
|