Skip to content

Commit

Permalink
Automatically grab specified atpack with wget.
Browse files Browse the repository at this point in the history
Also grab the DA-series ones too.
  • Loading branch information
SpenceKonde authored and facchinm committed May 26, 2020
1 parent 1f9005a commit 93db899
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 13 deletions.
99 changes: 99 additions & 0 deletions atpack.Dx.build.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash -ex
# Copyright (c) 2017 Arduino LLC
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

source build.conf

wget ${ATMEL_DX_PACK_URL}

mkdir -p atpack
cd atpack
rm -rf *
mv ../${ATMEL_DX_PACK_FILENAME}.atpack .

mv ${ATMEL_DX_PACK_FILENAME}.atpack ${ATMEL_DX_PACK_FILENAME}.zip
unzip ${ATMEL_DX_PACK_FILENAME}.zip

ALL_FILES=`find ../objdir`

#copy relevant files to the right folders
# 1- copy includes definitions
EXTRA_INCLUDES=`diff -q ../objdir/avr/include/avr ../atpack/include/avr | grep "Only in" | grep atpack | cut -f4 -d" "`
for x in $EXTRA_INCLUDES; do
cp include/avr/${x} ../objdir/avr/include/avr
done

# 2 - compact specs into a single folder
SPECS_FOLDERS=`ls gcc/dev`
mkdir temp
for folder in $SPECS_FOLDERS; do
cp -r gcc/dev/${folder}/* temp/
done

# 3 - find different files (device-specs)
EXTRA_SPECS=`diff -q ../objdir/lib/gcc/avr/${GCC_VERSION}/device-specs/ temp/device-specs | grep "Only in" | grep temp | cut -f4 -d" "`
for x in $EXTRA_SPECS; do
cp temp/device-specs/${x} ../objdir/lib/gcc/avr/${GCC_VERSION}/device-specs/
done

#since https://github.com/gcc-mirror/gcc/commit/21a6b87b86defda10ac903a9cd49e34b1f8ce6fb a lot of devices has specs but avr-libc doesn't support them yet
ALL_DEVICE_SPECS=`ls temp/device-specs`
rm -rf temp/device-specs

EXTRA_LIBS=`diff -r -q ../objdir/avr/lib temp/ | grep "Only in" | grep temp | cut -f4 -d" "`
for x in $EXTRA_LIBS; do
if [ ! -d temp/${x} ]; then
cd temp
LOCATION=`find . | grep ${x}`
cd ..
else
LOCATION=${x}
fi
cp -r temp/${LOCATION} ../objdir/avr/lib/${LOCATION}
done

# 4 - extract the correct includes and add them to io.h
# ARGH! difficult!
echo "STARTING THE MAGIC"
for x in $ALL_DEVICE_SPECS; do
DEFINITION=`cat ../objdir/lib/gcc/avr/${GCC_VERSION}/device-specs/${x} | grep __AVR_DEVICE_NAME__ | cut -f 1 -d " " | cut -b 4-`
FANCY_NAME=`cat ../objdir/lib/gcc/avr/${GCC_VERSION}/device-specs/${x} | grep __AVR_DEVICE_NAME__ | cut -f2 -d"="`
echo $DEFINITION
echo $FANCY_NAME
LOWERCASE_DEFINITION="${DEFINITION,,}"
echo $LOWERCASE_DEFINITION
HEADER_TEMP="${LOWERCASE_DEFINITION#__avr_}"
echo $HEADER_TEMP
HEADER="${HEADER_TEMP%__}"
echo $HEADER
_DEFINITION="#elif defined (${DEFINITION})"
echo $__DEFINITION
_HEADER="# include <avr/io${HEADER}.h>"
echo $__HEADER
if [ "$(grep -c "${DEFINITION}" ../objdir/avr/include/avr/io.h)" == 0 ]; then
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"`
echo $NEWFILE
echo "$NEWFILE" > ../objdir/avr/include/avr/io.h
fi
done
echo "ENDING THE MAGIC"
#NEW_ALL_FILES=`find ../objdir`

#echo "NEW FILES ADDED: "
#diff <(echo "$ALL_FILES" ) <(echo "$NEW_ALL_FILES")

cd ..

6 changes: 4 additions & 2 deletions atpack.build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

source build.conf

wget ${ATMEL_ATMEGA_PACK_URL}

mkdir -p atpack
cd atpack
rm -rf *
Expand Down
6 changes: 4 additions & 2 deletions atpack.tiny.build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

source build.conf

wget ${ATMEL_ATTINY_PACK_URL}

mkdir -p atpack
cd atpack
rm -rf *
Expand Down
8 changes: 6 additions & 2 deletions build.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ MPFR_VERSION=3.1.0

ATMEL_ATMEGA_PACK_VERSION=1.4.351
ATMEL_ATMEGA_PACK_FILENAME=Atmel.ATmega_DFP.${ATMEL_ATMEGA_PACK_VERSION}
ATMEL_ATMEGA_PACK_URL=${ATMEL_PACKS_SOURCES}/${ATMEL_ATMEGA_PACK_FILENAME}.atpack
ATMEL_ATMEGA_PACK_URL=${ATMEL_PACKS_SOURCES}${ATMEL_ATMEGA_PACK_FILENAME}.atpack

ATMEL_ATTINY_PACK_VERSION=1.4.310
ATMEL_ATTINY_PACK_FILENAME=Atmel.ATtiny_DFP.${ATMEL_ATTINY_PACK_VERSION}
ATMEL_ATTINY_PACK_URL=${ATMEL_PACKS_SOURCES}/${ATMEL_ATTINY_PACK_FILENAME}.atpack
ATMEL_ATTINY_PACK_URL=${ATMEL_PACKS_SOURCES}${ATMEL_ATTINY_PACK_FILENAME}.atpack

ATMEL_DX_PACK_VERSION=1.0.27
ATMEL_DX_PACK_FILENAME=Atmel.AVR-Dx_DFP.${ATMEL_DX_PACK_VERSION}
ATMEL_DX_PACK_URL=${ATMEL_PACKS_SOURCES}${ATMEL_DX_PACK_FILENAME}.atpack

# With any luck, you don't need to edit the below
################################################################################
Expand Down
9 changes: 2 additions & 7 deletions package-avr-gcc.bash
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,10 @@ rm -rf toolsdir objdir *-build

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

if [[ -f ${ATMEL_ATMEGA_PACK_FILENAME}.atpack ]] ; then
#add extra files from atpack (only if the package is altrady there)
${BASH} ./atpack.build.bash
fi

if [[ -f ${ATMEL_ATTINY_PACK_FILENAME}.atpack ]] ; then
#add extra files from atpack (only if the package is altrady there)
${BASH} ./atpack.tiny.build.bash
fi
${BASH} ./atpack.Dx.build.bash


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

0 comments on commit 93db899

Please sign in to comment.