summaryrefslogtreecommitdiff
blob: 4c78f65449356707a177774000619fc4d131ab98 (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
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

inherit ninja-utils git-r3
EGIT_REPO_URI=https://github.com/KireinaHoro/android_build_${PN}
EGIT_CHECKOUT_DIR=${WORKDIR}/${P}/build/${PN}

A_URI=http://aosp.airelinux.org/platform/build
# blueprint is a source level dependency of soong.
MPV=8.1.0_p41
SRC_URI="${A_URI}/blueprint/+archive/android-${MPV/p/r}.tar.gz -> blueprint-${MPV}.tar.gz
	https://github.com/LineageOS/android_vendor_lineage/archive/lineage-15.1.tar.gz -> vendor-lineage-15.1.tar.gz"
DESCRIPTION="JSON-like build system for Android."
HOMEPAGE="${A_URI}/${PN}"
LICENSE="Apache-2.0"
KEYWORDS="~amd64"
SLOT=0

DEPEND="dev-lang/go
	dev-util/ninja"
RDEPEND="dev-lang/go"

PATCHES=(
	"${FILESDIR}"/blueprint-test-go-1.10.patch
	"${FILESDIR}"/soong-9999-bootstrap-clean.patch
	"${FILESDIR}"/soong-no-kernel-header.patch
	"${FILESDIR}"/soong-no-bootstrap.patch
	"${FILESDIR}"/soong-no-sysroot.patch
	"${FILESDIR}"/soong-gentoo-toolchain.patch
	"${FILESDIR}"/soong-gentoo-host-bin.patch
)

src_unpack() {
	git-r3_src_unpack

	mkdir -p "${S}"/vendor || die
	cd "${S}"/vendor || die
	unpack vendor-lineage-15.1.tar.gz
	mv android_vendor_lineage-lineage-15.1 lineage || die

	mkdir -p "${S}"/build/blueprint || die
	cd "${S}"/build/blueprint || die
	unpack blueprint-${MPV}.tar.gz
}

src_prepare() {
	default
	ln -s build/soong/root.bp Android.bp || die
	ln -s build/soong/bootstrap.bash || die

	for c in vendor/lineage/*; do
		[[ ${c} = */build ]] || rm -r ${c} || die
	done
}

src_compile() {
	BUILDDIR="${S}"/out bash -xv build/soong/bootstrap.bash || die
	eninja -v -f out/.minibootstrap/build.ninja
	eninja -v -f out/.bootstrap/build.ninja

	cd "${S}"/build/${PN}/cmd/sbox
	go build -v -work
	# go run cmd/microfactory/microfactory.go -s cmd/microfactory \
	#    -pkg-path android/soong=. -o out/soong_ui android/soong/cmd/soong_ui
	# eninja -v -f .bootstrap/build.ninja
}

src_install() {
	dobin out/.bootstrap/bin/* build/${PN}/cmd/sbox/sbox

	sed -n '/\/\/.*host bionic/,$p' < build/soong/Android.bp > "${T}"/Android.bp
	sed -e '/build = \[/,+3d' -e '/vendor/d' < build/soong/root.bp > "${T}"/root.bp
	insinto /usr/share/soong
	doins "${T}"/{Android,root}.bp
	doins -r build/soong/scripts
}