Skip to content

Commit 99bab24

Browse files
committed
add some functions for auto-updating the package_index.json file
1 parent 248ecb5 commit 99bab24

7 files changed

Lines changed: 425 additions & 73 deletions

board-manager/Makefile.core

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
NAME=Sduino
2+
VERSION=0.3.0-pre1
3+
4+
5+
PACKAGEFILE=package_sduino_stm8_index.json
6+
7+
# Ignore all files matching one of these shell patterns:
8+
IGNORE=*~ *bak x build-* *.orig *.rej
9+
EXCLUDES=$(addprefix --exclude=, $(IGNORE))
10+
11+
COREFILE=release/$(NAME)-core-$(VERSION).tar.bz2
12+
13+
.PHONY: release add-platform-entry
14+
15+
release: add-platform-entry
16+
17+
# insert the new entry at first position of the platforms list:
18+
add-platform-entry: platform-entry
19+
@SHA=$$(grep SHA-256 $^|cut -d\" -f4); \
20+
grep -q $$SHA $(PACKAGEFILE); \
21+
if [ $$? -ne 0 ]; then \
22+
sed -i -e '/"platforms" : \[/r $^' $(PACKAGEFILE); \
23+
echo "added new core definition to package file."; \
24+
else echo "core definiton already included in package file."; fi
25+
26+
# generate one platform entry for the new core file
27+
platform-entry: $(COREFILE)
28+
./gen_platform_entry.sh $^ "$(VERSION)" > $@
29+
30+
$(COREFILE):
31+
echo "Generating the core archive file."
32+
tar cjf $@ $(EXCLUDES) -C ../sduino/hardware/sduino/stm8 .

board-manager/Makefile.sdcc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
NAME=sdcc
2+
VERSION=10088
3+
4+
# The package file the information should be added to
5+
PACKAGEFILE=package_sduino_stm8_index.json
6+
7+
# The filename stem of the tools archives to be generated
8+
# (up to the first dash '-')
9+
TOOLS_STEM=release/$(NAME)
10+
11+
# filename for the new tools entries
12+
TOOLS_ENTRY=tools-entry-$(NAME)-$(VERSION).txt
13+
14+
15+
#
16+
### No user serviceable part below here. Only generated content. ########
17+
#
18+
19+
# The individual filenames for the different sdcc archives
20+
SDCC_TARS=$(wildcard $(TOOLS_STEM)-*-$(VERSION).*)
21+
22+
23+
.PHONY: release add-tools-entry
24+
25+
release: add-tools-entry
26+
27+
28+
# insert the new entry at first position of the platforms list:
29+
add-tools-entry: $(TOOLS_ENTRY)
30+
@SHA=$$(grep SHA-256 $^|head -1|cut -d\" -f4); \
31+
grep -q $$SHA $(PACKAGEFILE); \
32+
if [ $$? -ne 0 ]; then \
33+
sed -ie '/"tools" : \[/r $^' $(PACKAGEFILE); \
34+
echo "added new tools to package file."; \
35+
else echo "tools definiton already included in package file."; fi
36+
37+
# generate one tools entry for each new tools file
38+
39+
$(TOOLS_ENTRY) : $(SDCC_TARS)
40+
./gen_tools_entry.sh "$(TOOLS_STEM)" "$(VERSION)" > $@

board-manager/Makefile.tools

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
NAME=Sduino-tools
2+
VERSION=2017.10.21
3+
4+
# The package file the information should be added to
5+
PACKAGEFILE=package_sduino_stm8_index.json
6+
7+
# The filename stem of the tools archives to be generated
8+
# (up to the first dash '-')
9+
TOOLS_STEM=release/$(NAME)
10+
11+
# Where to find the tools to be included in the archive
12+
TOOLSDIR=../sduino/hardware/sduino/tools
13+
14+
# filename for the new tools entries
15+
TOOLS_ENTRY=tools-entry-$(NAME)-$(VERSION).txt
16+
17+
18+
#
19+
### No user serviceable part below here. Only generated content. ########
20+
#
21+
22+
# The individual filenames for the different tools archives
23+
TOOLS_LINUX32=release/$(NAME)_linux32-$(VERSION).tar.bz2
24+
TOOLS_LINUX64=release/$(NAME)_linux64-$(VERSION).tar.bz2
25+
TOOLS_WINDOWS=release/$(NAME)_mingw32-$(VERSION).tar.bz2
26+
27+
TOOLS_TARS=$(TOOLS_LINUX32) $(TOOLS_LINUX64) $(TOOLS_WINDOWS)
28+
29+
30+
# Ignore all files matching one of these shell patterns:
31+
IGNORE=*~ *bak x build-* *.orig *.rej
32+
EXCLUDES=$(addprefix --exclude=, $(IGNORE))
33+
34+
TARFLAGS=$(EXCLUDES) --show-transformed-names --transform
35+
36+
.PHONY: release add-tools-entry
37+
38+
release: add-tools-entry
39+
40+
41+
# insert the new entry at first position of the platforms list:
42+
add-tools-entry: $(TOOLS_ENTRY)
43+
@SHA=$$(grep SHA-256 $^|head -1|cut -d\" -f4); \
44+
grep -q $$SHA $(PACKAGEFILE); \
45+
if [ $$? -ne 0 ]; then \
46+
sed -ie '/"tools" : \[/r $^' $(PACKAGEFILE); \
47+
echo "added new tools to package file."; \
48+
else echo "tools definiton already included in package file."; fi
49+
50+
# generate one tools entry for each new tools file
51+
52+
$(TOOLS_ENTRY) : $(TOOLS_TARS)
53+
./gen_tools_entry.sh "$(TOOLS_STEM)" "$(VERSION)" > $@
54+
55+
$(TOOLS_LINUX32):
56+
@echo "Generating the tools archive file for Linux 32 bit."
57+
tar cjf $@ $(EXCLUDES) -C $(TOOLSDIR) --transform s/linux32/linux/ \
58+
wrapper linux32
59+
60+
$(TOOLS_LINUX64):
61+
@echo "Generating the tools archive file for Linux 64 bit."
62+
tar cjf $@ $(EXCLUDES) -C $(TOOLSDIR) --transform s/linux64/linux/ \
63+
wrapper linux64
64+
65+
$(TOOLS_WINDOWS):
66+
@echo "Generating the tools archive file for Windows."
67+
tar cjf $@ $(EXCLUDES) -C $(TOOLSDIR) wrapper win
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/bash
2+
3+
# helper script for automatic releases.
4+
#
5+
# Prints one platform entry for the given file to be added to the
6+
# package_*.json file.
7+
8+
9+
if [ $# -ne 2 ]; then
10+
echo
11+
echo "helper script for automatic releases."
12+
echo
13+
echo "Prints one platform entry for the given file to be added to the"
14+
echo "package_*_index.json file."
15+
echo
16+
echo "usage: $0 corefile version"
17+
exit 1
18+
fi
19+
20+
COREFILE=$1
21+
VERSION=$2
22+
PACKAGER=Sduino
23+
24+
25+
### helper functions #####################################################
26+
27+
# format ID information for a file
28+
print_filedata()
29+
{
30+
URL=file://$(realpath $1)
31+
FILENAME=$(basename "$1")
32+
SIZE=$(stat --printf="%s" $1)
33+
CHKSUM=$(shasum -a 256 $1|cut "-d " -f1)
34+
cat << EOF
35+
"url": "$URL",
36+
"archiveFileName": "$FILENAME",
37+
"checksum": "SHA-256:$CHKSUM",
38+
"size": "$SIZE"
39+
EOF
40+
}
41+
42+
43+
44+
# list of supported boards in current boards.txt
45+
list_boards()
46+
{
47+
echo -n " \"boards\": ["
48+
n=0
49+
sed -n "s/.*\.name=//p" ../sduino/hardware/sduino/stm8/boards.txt |\
50+
while read line; do
51+
if [ $n -ne 0 ]; then echo -n ","; fi
52+
echo
53+
echo -n " {\"name\": \"$line\"}"
54+
n=$((n+1))
55+
done
56+
echo
57+
echo " ],"
58+
}
59+
60+
61+
62+
### print a platform entry for the given file ############################
63+
64+
cat << EOF
65+
{
66+
"name": "Sduino test core",
67+
"architecture": "stm8",
68+
"version": "$VERSION",
69+
"category": "Contributed",
70+
EOF
71+
list_boards
72+
cat << EOF
73+
"toolsDependencies": [
74+
{
75+
"name": "STM8Tools",
76+
"version": "2017.10.21",
77+
"packager": "$PACKAGER"
78+
},
79+
{
80+
"name": "sdcc",
81+
"version": "build.10088",
82+
"packager": "$PACKAGER"
83+
}
84+
],
85+
EOF
86+
print_filedata "$COREFILE"
87+
echo "},"
88+

board-manager/gen_tools_entry.sh

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/bin/bash
2+
3+
# helper script for automatic releases.
4+
#
5+
# Prints one platform entry for the given file to be added to the
6+
# package_*.json file.
7+
8+
9+
if [ $# -ne 2 ]; then
10+
echo "
11+
helper script for automatic releases.
12+
13+
Prints a full tool entry for the given filename stem to be added to the
14+
package_*_index.json file. It will include all OS variants found with the
15+
same filename stem and the same version specifier.
16+
17+
usage: $0 toolfile-stem version
18+
19+
Lists info for all files matching the filename pattern
20+
[toolsfile-stem]*[version]*
21+
22+
Example: $0 release/Sduino-tools 2017-10-21 prints information for all files
23+
matching the filename pattern release/Sduino-tools*2017-10-21*.
24+
"
25+
exit 1
26+
fi
27+
28+
TRUNK=$1
29+
VERSION=$2
30+
31+
32+
### helper functions #####################################################
33+
34+
# format ID information for a file
35+
print_filedata()
36+
{
37+
URL=file://$(realpath $1)
38+
FILENAME=$(basename "$1")
39+
SIZE=$(stat --printf="%s" $1)
40+
CHKSUM=$(shasum -a 256 $1|cut "-d " -f1)
41+
cat << EOF
42+
"url": "$URL",
43+
"archiveFileName": "$FILENAME",
44+
"checksum": "SHA-256:$CHKSUM",
45+
"size": "$SIZE"
46+
EOF
47+
}
48+
49+
50+
# detect the host system type for the given file
51+
detect_hosttype()
52+
{
53+
case $1 in
54+
*amd64-unknown-linux* | *linux64* )
55+
HOST="x86_64-pc-linux-gnu"
56+
;;
57+
*mingw32*)
58+
HOST="i686-mingw32"
59+
;;
60+
*i386-unknown-linux* | *linux32* )
61+
HOST="i686-pc-linux-gnu"
62+
;;
63+
*macosx*)
64+
HOST="x86_64-apple-darwin"
65+
;;
66+
esac
67+
}
68+
69+
70+
# detect the tool type/name for the given file
71+
detect_tooltype()
72+
{
73+
case $1 in
74+
*Sduino-tools* )
75+
NAME=STM8Tools
76+
;;
77+
*sdcc* )
78+
NAME=sdcc
79+
;;
80+
esac
81+
}
82+
83+
84+
85+
### print a tool entry for the given file ############################
86+
87+
88+
89+
detect_tooltype "$TRUNK"
90+
cat << EOF
91+
{
92+
"name": "$NAME",
93+
"version": "$VERSION",
94+
"systems": [
95+
{
96+
EOF
97+
n=0
98+
for FILE in $TRUNK*$VERSION*; do
99+
if [ $n -gt 0 ]; then
100+
echo " },{"
101+
fi
102+
detect_hosttype "$FILE"
103+
echo " \"host\": \"$HOST\","
104+
print_filedata "$FILE"
105+
n=$((n+1))
106+
done
107+
cat << EOF
108+
}
109+
]
110+
},
111+
EOF

0 commit comments

Comments
 (0)