summaryrefslogtreecommitdiff
path: root/dev-embedded/arduino/arduino-1.8.5-r2.ebuild
blob: 1f5388a52bfd7e196678f1b48e07856ad6c14e4c (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=6

inherit java-pkg-2 java-ant-2 gnome2-utils

DESCRIPTION="An open-source AVR electronics prototyping platform"
HOMEPAGE="https://arduino.cc/ https://github.com/arduino/"

ARDUINO_LIBRARIES=(
	"Firmata 2.5.6"
	"Bridge 1.6.3"
	"Robot_Control 1.0.4"
	"Robot_Motor 1.0.3"
	"RobotIRremote 2.0.0"
	"SpacebrewYun 1.0.1"
	"Temboo 1.2.1"
	"Esplora 1.0.4"
	"Mouse 1.0.1"
	"Keyboard 1.0.1"
	"SD 1.1.1"
	"Servo 1.1.2"
	"LiquidCrystal 1.0.7"
	"Adafruit_CircuitPlayground 1.6.8 https://github.com/Adafruit/Adafruit_CircuitPlayground/archive/1.6.8.zip"
	"WiFi101-Updater-ArduinoIDE-Plugin 0.9.1 https://github.com/arduino-libraries/WiFi101-FirmwareUpdater-Plugin/releases/download/v0.9.1/WiFi101-Updater-ArduinoIDE-Plugin-0.9.1.zip build/shared/"
)

for lib in "${ARDUINO_LIBRARIES[@]}"; do
	lib=( $lib )
	default_url="https://github.com/arduino-libraries/${lib[0]}/archive/${lib[1]}.zip"
	url=${lib[2]:-$default_url}
	ARDUINO_LIBRARIES_URI+=" ${url} -> ${P}-${lib[0]}-${lib[1]}.zip"
done

ARDUINO_DOCS=(
	"reference-1.6.6-3"
	"Galileo_help_files-1.6.2"
	"Edison_help_files-1.6.2"
)

for docname in "${ARDUINO_DOCS[@]}"; do
	ARDUINO_DOCS_URI+=" https://downloads.arduino.cc/${docname}.zip -> ${P}-${docname}.zip"
done

SRC_URI="https://github.com/arduino/Arduino/archive/${PV}.tar.gz -> ${P}.tar.gz
	${ARDUINO_LIBRARIES_URI}
	doc? (
		${ARDUINO_DOCS_URI}
	)"

LICENSE="GPL-2 LGPL-2.1 CC-BY-SA-3.0"
SLOT="0"
KEYWORDS="amd64 x86"

# bincheck RESTRICT is needed because firmware that ships with arduino contains code that makes
# scanelf bark. It's also why we need a separate package for arduino-listserialportsc because if
# we install it in the context of this package, we will get QA notices telling us we're doing a
# bad thing.
RESTRICT="strip"
QA_PREBUILT="usr/share/arduino/hardware/arduino/avr/firmwares/*
	usr/share/arduino/libraries/WiFi/extras/*"
IUSE="doc"

CDEPEND="dev-embedded/arduino-builder"

RDEPEND="${CDEPEND}
	>=dev-util/astyle-3.1[java]
	dev-embedded/arduino-listserialportsc
	>=virtual/jre-1.8"

DEPEND="${CDEPEND}
	app-arch/unzip
	>=virtual/jdk-1.8"

EANT_BUILD_TARGET="build"
# don't run the default "javadoc" target, we don't have one.
EANT_DOC_TARGET=""
EANT_BUILD_XML="build/build.xml"
EANT_EXTRA_ARGS="-Dno_arduino_builder=1 -Dlocal_sources=1"

S="${WORKDIR}/Arduino-${PV}"
SHARE="/usr/share/${PN}"

src_unpack() {
	# We don't want to unpack libraries, just move zip files into the work dir
	unpack `echo ${A} | cut -d ' ' -f1`
	local lib
	for lib in "${ARDUINO_LIBRARIES[@]}"; do
		lib=( $lib )
		local destfolder=${lib[3]:-build/}
		cp "${DISTDIR}/${P}-${lib[0]}-${lib[1]}.zip" "${S}/${destfolder}/${lib[0]}-${lib[1]}.zip" || die
	done
	if use doc; then
		local docname
		for docname in "${ARDUINO_DOCS[@]}"; do
			cp "${DISTDIR}/${P}-${docname}.zip" "${S}/build/shared/${docname}.zip" || die
		done
	fi
}

src_prepare() {
	# We need to disable astyle/listserialportsc and toolchain (avr-gcc, avrdude) bundling.
	eapply "${FILESDIR}/${PN}-1.8.5-build.xml.patch"

	# We need to replace relative paths for toolchain executable by paths to system ones.
	eapply "${FILESDIR}/${PN}-1.8.5-avr-platform.txt.patch"

	# We need to load system astyle/listserialportsc instead of bundled ones.
	eapply "${FILESDIR}/${PN}-1.8.5-lib-loading.patch"
	default
}

src_compile() {
	if ! use doc; then
		EANT_EXTRA_ARGS+=" -Dno_docs=1"
	fi
	java-pkg-2_src_compile
}

src_install() {
	cd "${S}"/build/linux/work || die

	java-pkg_dojar lib/*.jar
	java-pkg_dolauncher ${PN} \
		--pwd "${SHARE}" \
		--main "processing.app.Base" \
		--java_args "-DAPP_DIR=${SHARE} -Djava.library.path=${EPREFIX}/usr/$(get_libdir)"

	# Install libraries
	insinto "${SHARE}"

	doins -r examples hardware lib libraries tools

	# In upstream's build process, we copy these fiels below from the bundled arduino-builder.
	# Here we do the same thing, but from the system arduino-builder.
	dosym "../../arduino-builder/platform.txt" "${SHARE}/hardware/platform.txt"
	dosym "../../arduino-builder/platform.keys.rewrite.txt" "${SHARE}/hardware/platform.keys.rewrite.txt"
	dosym "../../bin/arduino-builder" "${SHARE}/arduino-builder"

	# hardware/tools/avr needs to exist or arduino-builder will
	# complain about missing required -tools arg
	dodir "${SHARE}/hardware/tools/avr"

	if use doc; then
		HTML_DOCS=( reference )
		einstalldocs

		# arduino expects its doc in its "main" directory. symlink it.
		dosym "../doc/${PF}/html/reference" "${SHARE}/reference"
	fi

	# Install menu and icons
	domenu "${FILESDIR}/${PN}.desktop"
	cd lib/icons || die
	local icondir
	for icondir in *; do
		# icondir name is something like "24x24" we want the "24" part
		local iconsize=`cut -dx -f1 <<< "${icondir}"`
		newicon -s $iconsize \
			"${icondir}/apps/arduino.png" \
			"${PN}.png"
	done
}

pkg_postinst() {
	gnome2_icon_cache_update
	[[ ! -x /usr/bin/avr-g++ ]] && ewarn "Missing avr-g++; you need to crossdev -s4 avr"
}