Skip to content

Commit 93db899

Browse files
SpenceKondefacchinm
authored andcommitted
Automatically grab specified atpack with wget.
Also grab the DA-series ones too.
1 parent 1f9005a commit 93db899

5 files changed

+115
-13
lines changed

atpack.Dx.build.bash

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash -ex
2+
# Copyright (c) 2017 Arduino LLC
3+
#
4+
# This program is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU General Public License
6+
# as published by the Free Software Foundation; either version 2
7+
# of the License, or (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program; if not, write to the Free Software
16+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
18+
source build.conf
19+
20+
wget ${ATMEL_DX_PACK_URL}
21+
22+
mkdir -p atpack
23+
cd atpack
24+
rm -rf *
25+
mv ../${ATMEL_DX_PACK_FILENAME}.atpack .
26+
27+
mv ${ATMEL_DX_PACK_FILENAME}.atpack ${ATMEL_DX_PACK_FILENAME}.zip
28+
unzip ${ATMEL_DX_PACK_FILENAME}.zip
29+
30+
ALL_FILES=`find ../objdir`
31+
32+
#copy relevant files to the right folders
33+
# 1- copy includes definitions
34+
EXTRA_INCLUDES=`diff -q ../objdir/avr/include/avr ../atpack/include/avr | grep "Only in" | grep atpack | cut -f4 -d" "`
35+
for x in $EXTRA_INCLUDES; do
36+
cp include/avr/${x} ../objdir/avr/include/avr
37+
done
38+
39+
# 2 - compact specs into a single folder
40+
SPECS_FOLDERS=`ls gcc/dev`
41+
mkdir temp
42+
for folder in $SPECS_FOLDERS; do
43+
cp -r gcc/dev/${folder}/* temp/
44+
done
45+
46+
# 3 - find different files (device-specs)
47+
EXTRA_SPECS=`diff -q ../objdir/lib/gcc/avr/${GCC_VERSION}/device-specs/ temp/device-specs | grep "Only in" | grep temp | cut -f4 -d" "`
48+
for x in $EXTRA_SPECS; do
49+
cp temp/device-specs/${x} ../objdir/lib/gcc/avr/${GCC_VERSION}/device-specs/
50+
done
51+
52+
#since https://github.com/gcc-mirror/gcc/commit/21a6b87b86defda10ac903a9cd49e34b1f8ce6fb a lot of devices has specs but avr-libc doesn't support them yet
53+
ALL_DEVICE_SPECS=`ls temp/device-specs`
54+
rm -rf temp/device-specs
55+
56+
EXTRA_LIBS=`diff -r -q ../objdir/avr/lib temp/ | grep "Only in" | grep temp | cut -f4 -d" "`
57+
for x in $EXTRA_LIBS; do
58+
if [ ! -d temp/${x} ]; then
59+
cd temp
60+
LOCATION=`find . | grep ${x}`
61+
cd ..
62+
else
63+
LOCATION=${x}
64+
fi
65+
cp -r temp/${LOCATION} ../objdir/avr/lib/${LOCATION}
66+
done
67+
68+
# 4 - extract the correct includes and add them to io.h
69+
# ARGH! difficult!
70+
echo "STARTING THE MAGIC"
71+
for x in $ALL_DEVICE_SPECS; do
72+
DEFINITION=`cat ../objdir/lib/gcc/avr/${GCC_VERSION}/device-specs/${x} | grep __AVR_DEVICE_NAME__ | cut -f 1 -d " " | cut -b 4-`
73+
FANCY_NAME=`cat ../objdir/lib/gcc/avr/${GCC_VERSION}/device-specs/${x} | grep __AVR_DEVICE_NAME__ | cut -f2 -d"="`
74+
echo $DEFINITION
75+
echo $FANCY_NAME
76+
LOWERCASE_DEFINITION="${DEFINITION,,}"
77+
echo $LOWERCASE_DEFINITION
78+
HEADER_TEMP="${LOWERCASE_DEFINITION#__avr_}"
79+
echo $HEADER_TEMP
80+
HEADER="${HEADER_TEMP%__}"
81+
echo $HEADER
82+
_DEFINITION="#elif defined (${DEFINITION})"
83+
echo $__DEFINITION
84+
_HEADER="# include <avr/io${HEADER}.h>"
85+
echo $__HEADER
86+
if [ "$(grep -c "${DEFINITION}" ../objdir/avr/include/avr/io.h)" == 0 ]; then
87+
NEWFILE=`awk '/iom3000.h/ { print; print "____DEFINITION____"; print "____HEADER____"; next }1' ../objdir/avr/include/avr/io.h | sed "s/____DEFINITION____/$_DEFINITION/g" | sed "s@____HEADER____@$_HEADER@g"`
88+
echo $NEWFILE
89+
echo "$NEWFILE" > ../objdir/avr/include/avr/io.h
90+
fi
91+
done
92+
echo "ENDING THE MAGIC"
93+
#NEW_ALL_FILES=`find ../objdir`
94+
95+
#echo "NEW FILES ADDED: "
96+
#diff <(echo "$ALL_FILES" ) <(echo "$NEW_ALL_FILES")
97+
98+
cd ..
99+

atpack.build.bash

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55
# modify it under the terms of the GNU General Public License
66
# as published by the Free Software Foundation; either version 2
77
# of the License, or (at your option) any later version.
8-
#
8+
#
99
# This program is distributed in the hope that it will be useful,
1010
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1111
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
# GNU General Public License for more details.
13-
#
13+
#
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program; if not, write to the Free Software
1616
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717

1818
source build.conf
1919

20+
wget ${ATMEL_ATMEGA_PACK_URL}
21+
2022
mkdir -p atpack
2123
cd atpack
2224
rm -rf *

atpack.tiny.build.bash

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55
# modify it under the terms of the GNU General Public License
66
# as published by the Free Software Foundation; either version 2
77
# of the License, or (at your option) any later version.
8-
#
8+
#
99
# This program is distributed in the hope that it will be useful,
1010
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1111
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
# GNU General Public License for more details.
13-
#
13+
#
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program; if not, write to the Free Software
1616
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717

1818
source build.conf
1919

20+
wget ${ATMEL_ATTINY_PACK_URL}
21+
2022
mkdir -p atpack
2123
cd atpack
2224
rm -rf *

build.conf

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ MPFR_VERSION=3.1.0
2121

2222
ATMEL_ATMEGA_PACK_VERSION=1.4.351
2323
ATMEL_ATMEGA_PACK_FILENAME=Atmel.ATmega_DFP.${ATMEL_ATMEGA_PACK_VERSION}
24-
ATMEL_ATMEGA_PACK_URL=${ATMEL_PACKS_SOURCES}/${ATMEL_ATMEGA_PACK_FILENAME}.atpack
24+
ATMEL_ATMEGA_PACK_URL=${ATMEL_PACKS_SOURCES}${ATMEL_ATMEGA_PACK_FILENAME}.atpack
2525

2626
ATMEL_ATTINY_PACK_VERSION=1.4.310
2727
ATMEL_ATTINY_PACK_FILENAME=Atmel.ATtiny_DFP.${ATMEL_ATTINY_PACK_VERSION}
28-
ATMEL_ATTINY_PACK_URL=${ATMEL_PACKS_SOURCES}/${ATMEL_ATTINY_PACK_FILENAME}.atpack
28+
ATMEL_ATTINY_PACK_URL=${ATMEL_PACKS_SOURCES}${ATMEL_ATTINY_PACK_FILENAME}.atpack
29+
30+
ATMEL_DX_PACK_VERSION=1.0.27
31+
ATMEL_DX_PACK_FILENAME=Atmel.AVR-Dx_DFP.${ATMEL_DX_PACK_VERSION}
32+
ATMEL_DX_PACK_URL=${ATMEL_PACKS_SOURCES}${ATMEL_DX_PACK_FILENAME}.atpack
2933

3034
# With any luck, you don't need to edit the below
3135
################################################################################

package-avr-gcc.bash

+2-7
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,10 @@ rm -rf toolsdir objdir *-build
9999

100100
rm -rf objdir/{info,man,share}
101101

102-
if [[ -f ${ATMEL_ATMEGA_PACK_FILENAME}.atpack ]] ; then
103-
#add extra files from atpack (only if the package is altrady there)
104102
${BASH} ./atpack.build.bash
105-
fi
106-
107-
if [[ -f ${ATMEL_ATTINY_PACK_FILENAME}.atpack ]] ; then
108-
#add extra files from atpack (only if the package is altrady there)
109103
${BASH} ./atpack.tiny.build.bash
110-
fi
104+
${BASH} ./atpack.Dx.build.bash
105+
111106

112107
# if producing a windows build, compress as zip and
113108
# copy *toolchain-precompiled* content to any folder containing a .exe

0 commit comments

Comments
 (0)