summaryrefslogtreecommitdiff
blob: 43a57869bd0962c393e88d8e89ab93c541950a0c (plain)
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
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="2"
PYTHON_DEPEND="2"
inherit multilib python subversion toolchain-funcs

DESCRIPTION="The Mozc engine for IBus Framework"
HOMEPAGE="http://code.google.com/p/mozc/"
# subversion eclass fetches gclient, which will then fetch mozc itself
ESVN_REPO_URI="http://src.chromium.org/svn/trunk/tools/depot_tools"
EGCLIENT_REPO_URI="http://mozc.googlecode.com/svn/trunk/src"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

RDEPEND=">=app-i18n/ibus-1.2
	dev-libs/glib:2
	dev-libs/protobuf
	sys-libs/zlib
	net-misc/curl"
DEPEND="${RDEPEND}
	dev-util/gtest"

BUILDTYPE="${BUILDTYPE:-Release}"

pkg_setup() {
	python_set_active_version 2
}

src_unpack() {
	subversion_src_unpack
	mv "${S}" "${WORKDIR}"/depot_tools

	# Most subversion checks and configurations were already run
	EGCLIENT="${WORKDIR}"/depot_tools/gclient
	cd "${ESVN_STORE_DIR}" || die "gclient: can't chdir to ${ESVN_STORE_DIR}"

	if [[ ! -d ${PN} ]]; then
		mkdir -p "${PN}" || die "gclient: can't mkdir ${PN}."
	fi

	cd "${PN}" || die "gclient: can't chdir to ${PN}"

	if [[ ! -f .gclient ]]; then
		einfo "gclient config -->"
		${EGCLIENT} config ${EGCLIENT_REPO_URI} || die "gclient: error creating config"
	fi

	einfo "gclient sync start -->"
	einfo "     repository: ${EGCLIENT_REPO_URI}"
	${EGCLIENT} sync || die "gclient: can't fetch to ${PN} from ${EGCLIENT_REPO_URI}."
	einfo "   working copy: ${ESVN_STORE_DIR}/${PN}"

	mkdir -p "${S}"
	rsync -rlpgo --exclude=".svn/" src/ "${S}" || die "gclient: can't export to ${S}."
}

src_prepare() {
	sed -i -e "s:/lib:/$(get_libdir):g" unix/ibus/ibus.gyp || die
}

src_configure() {
	# CFLAGS/LDFLAGS
	mkdir -p "${S}"/.gyp || die "cflags mkdir failed"
	cat << EOF > "${S}"/.gyp/include.gypi || die "cflags cat failed"
{
	'target_defaults': {
		'cflags': [ '${CFLAGS// /','}' ],
		'ldflags': [ '${LDFLAGS// /','}' ],
	},
}
EOF
	export HOME="${S}"
	export BUILD_COMMAND="emake"
	"$(PYTHON)" build_mozc.py gyp || die "gyp failed"
}

src_compile() {
	CFLAGS="" CXXFLAGS="" "$(PYTHON)" build_mozc.py build_tools -c "${BUILDTYPE}" || die

	export CXX="$(tc-getCXX)"
	export CC="$(tc-getCC)"
	export AR="$(tc-getAR)"
	export AS="$(tc-getAS)"
	export RANLIB="$(tc-getRANLIB)"
	export LD="$(tc-getLD)"
	"$(PYTHON)" build_mozc.py build -c "${BUILDTYPE}" unix:ibus_mozc || die
}

src_install() {
	exeinto /usr/libexec || die
	newexe "out/${BUILDTYPE}/ibus_mozc" ibus-engine-mozc || die
	insinto /usr/share/ibus/component || die
	doins unix/ibus/mozc.xml || die
}