summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 71e040e201ff0ea5db668fab3628d009920816ec (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

pkgname=arduino-builder-rc
pkgver=1.4.7
pkgrel=1
pkgdesc="A command line tool for compiling Arduino sketches -- stable and release candidates"
arch=('x86_64')
url="https://github.com/arduino/arduino-builder"
license=('GPL')
conflicts=('arduino-builder')
provides=('arduino-builder')
depends=('arduino-ctags')
makedepends=('go' 'git' 'unzip')
optdepends=('arduino-avr-core: AVR core with upstream avr-gcc and avrdude'
	   'arduino-cli: Arduino command line interface')
source=("https://github.com/arduino/arduino-builder/archive/${pkgver}.tar.gz")

sha512sums=('7550a8ec97e20ce88f519a33158df575c76b2de133d57db0323453f04a0bbe8484030f80e71fdcd095127289e53bcd635a056eb32845b7a7203003be2f5a9ab7')


prepare(){
  export GOPATH="$srcdir"/gopath

  mkdir -p "$GOPATH"/src/github.com/arduino
  ln -rTsf "${pkgname//-rc}-$pkgver" "$GOPATH"/src/github.com/arduino/arduino-builder
  #cp -a "${pkgname//-rc}-$pkgver" "$GOPATH"/src/github.com/arduino/arduino-builder
  cd "$GOPATH"/src/github.com/arduino/arduino-builder

  export GO111MODULE=on

  go mod vendor
  go mod download
}

build() {
	export GOPATH="$srcdir"/gopath
	cd "$GOPATH"/src/github.com/arduino/arduino-builder
	
	go build \
		-buildmode=pie \
		-gcflags "all=-trimpath=$GOPATH" \
		-asmflags "all=-trimpath=$GOPATH" \
		-ldflags "-extldflags $LDFLAGS" \
		-gccgoflags "$CFLAGS $LDFLAGS" \
		-v .

	chmod -R 744 "$GOPATH"
}

#check() {
#	# Test will download ~1GB of testfiles
#	cd "$GOPATH"/src/github.com/arduino/arduino-builder
#	go test -v -timeout 60m .
#}

package() {
	# Fix platform.txt for arch arduino-ctags
	#cd "${srcdir}/build/src/github.com/arduino/arduino-builder/hardware"
	#sed -i 's#^tools.ctags.path=.*#tools.ctags.path=/usr/bin#' platform.txt
	#sed -i 's#^tools.ctags.cmd.path=.*#tools.ctags.cmd.path={path}/arduino-ctags#' platform.txt

	cd "$GOPATH"/src/github.com/arduino/arduino-builder

	# Install main tool
	install -Dm755 "arduino-builder" "${pkgdir}/usr/bin/arduino-builder"

	# Install platform.txt files
	#install -Dm644 -t "${pkgdir}/usr/share/arduino/hardware/" "${srcdir}"/build/src/github.com/arduino/arduino-builder/hardware/*

	# Add documentation
	install -Dm644 -t "${pkgdir}/usr/share/doc/${pkgname//-rc}" "${srcdir}/${pkgname//-rc}-${pkgver}/README.md"
}