Skip to content

Commit 447a542

Browse files
committed
Adding packaging build system
Signed-off-by: Thibaut VIARD <aethaniel@sam-geek.org>
1 parent 4a28420 commit 447a542

File tree

2 files changed

+136
-0
lines changed

2 files changed

+136
-0
lines changed

Makefile

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#
2+
# ARM CMSIS Arduino IDE Module makefile.
3+
#
4+
# Copyright (c) 2015 Atmel Corp./Thibaut VIARD. All right reserved.
5+
#
6+
# This library is free software; you can redistribute it and/or
7+
# modify it under the terms of the GNU Lesser General Public
8+
# License as published by the Free Software Foundation; either
9+
# version 2.1 of the License, or (at your option) any later version.
10+
#
11+
# This library is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14+
# See the GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public
17+
# License along with this library; if not, write to the Free Software
18+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
#
20+
21+
SHELL = /bin/sh
22+
23+
.SUFFIXES: .tar.bz2
24+
25+
ROOT_PATH := .
26+
27+
PACKAGE_NAME := $(basename $(notdir $(CURDIR)))
28+
PACKAGE_VERSION := 4.5.0
29+
30+
# -----------------------------------------------------------------------------
31+
# packaging specific
32+
PACKAGE_FOLDER := module
33+
34+
ifeq (postpackaging,$(findstring $(MAKECMDGOALS),postpackaging))
35+
PACKAGE_FILENAME=$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.bz2
36+
PACKAGE_CHKSUM := $(firstword $(shell sha256sum "$(PACKAGE_FILENAME)"))
37+
PACKAGE_SIZE := $(firstword $(shell wc -c "$(PACKAGE_FILENAME)"))
38+
endif
39+
40+
# end of packaging specific
41+
# -----------------------------------------------------------------------------
42+
43+
.PHONY: all clean print_info postpackaging
44+
45+
# Arduino module packaging:
46+
# - exclude version control system files, here git files and folders .git, .gitattributes and .gitignore
47+
# - exclude 'extras' folder
48+
all: clean print_info
49+
@echo ----------------------------------------------------------
50+
@echo "Packaging module."
51+
tar --transform "s|module|$(PACKAGE_NAME)-$(PACKAGE_VERSION)|g" --exclude=.gitattributes --exclude=.travis.yml --exclude-vcs -cjf "$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.bz2" "$(PACKAGE_FOLDER)"
52+
$(MAKE) --no-builtin-rules postpackaging -C .
53+
@echo ----------------------------------------------------------
54+
55+
clean:
56+
@echo ----------------------------------------------------------
57+
@echo Cleanup
58+
-$(RM) $(PACKAGE_NAME)-*.tar.bz2 package_$(PACKAGE_NAME)_*.json test_package_$(PACKAGE_NAME)_*.json
59+
@echo ----------------------------------------------------------
60+
61+
print_info:
62+
@echo ----------------------------------------------------------
63+
@echo Building $(PACKAGE_NAME) using
64+
@echo "CURDIR = $(CURDIR)"
65+
@echo "OS = $(OS)"
66+
@echo "SHELL = $(SHELL)"
67+
@echo "PACKAGE_VERSION = $(PACKAGE_VERSION)"
68+
@echo "PACKAGE_NAME = $(PACKAGE_NAME)"
69+
70+
postpackaging:
71+
@echo "PACKAGE_CHKSUM = $(PACKAGE_CHKSUM)"
72+
@echo "PACKAGE_SIZE = $(PACKAGE_SIZE)"
73+
@echo "PACKAGE_FILENAME = $(PACKAGE_FILENAME)"
74+
cat extras/package_index.json.template | sed s/%%VERSION%%/$(PACKAGE_VERSION)/ | sed s/%%FILENAME%%/$(PACKAGE_FILENAME)/ | sed s/%%CHECKSUM%%/$(PACKAGE_CHKSUM)/ | sed s/%%SIZE%%/$(PACKAGE_SIZE)/ > package_$(PACKAGE_NAME)_$(PACKAGE_VERSION)_index.json
75+
cp package_$(PACKAGE_NAME)_$(PACKAGE_VERSION)_index.json test_package_$(PACKAGE_NAME)_$(PACKAGE_VERSION)_index.json
76+
@echo "package_$(PACKAGE_NAME)_$(PACKAGE_VERSION)_index.json created"

extras/package_index.json.template

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"packages":
3+
[
4+
{
5+
"name": "ARM CMSIS",
6+
"maintainer": "Arduino",
7+
"websiteURL": "http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php",
8+
"email": "packages@arduino.cc",
9+
"help":
10+
{
11+
"online": "http://www.keil.com/pack/doc/cmsis/general/html/index.html"
12+
},
13+
"tools":
14+
[
15+
{
16+
"name": "CMSIS",
17+
"version": "%%VERSION%%",
18+
"systems":
19+
[
20+
{
21+
"host": "i686-mingw32",
22+
"url": "https://github.com/AtmelUniversityFrance/atmel-samd21-xpro-boardmanagermodule/releases/download/v%%VERSION%%/%%FILENAME%%",
23+
"archiveFileName": "%%FILENAME%%",
24+
"checksum": "SHA-256:%%CHECKSUM%%",
25+
"size": "%%SIZE%%"
26+
},
27+
{
28+
"host": "x86_64-apple-darwin",
29+
"url": "https://github.com/AtmelUniversityFrance/atmel-samd21-xpro-boardmanagermodule/releases/download/v%%VERSION%%/%%FILENAME%%",
30+
"archiveFileName": "%%FILENAME%%",
31+
"checksum": "SHA-256:%%CHECKSUM%%",
32+
"size": "%%SIZE%%"
33+
},
34+
{
35+
"host": "x86_64-pc-linux-gnu",
36+
"url": "https://github.com/AtmelUniversityFrance/atmel-samd21-xpro-boardmanagermodule/releases/download/v%%VERSION%%/%%FILENAME%%",
37+
"archiveFileName": "%%FILENAME%%",
38+
"checksum": "SHA-256:%%CHECKSUM%%",
39+
"size": "%%SIZE%%"
40+
},
41+
{
42+
"host": "i686-pc-linux-gnu",
43+
"url": "https://github.com/AtmelUniversityFrance/atmel-samd21-xpro-boardmanagermodule/releases/download/v%%VERSION%%/%%FILENAME%%",
44+
"archiveFileName": "%%FILENAME%%",
45+
"checksum": "SHA-256:%%CHECKSUM%%",
46+
"size": "%%SIZE%%"
47+
},
48+
{
49+
"host": "all",
50+
"url": "https://github.com/AtmelUniversityFrance/atmel-samd21-xpro-boardmanagermodule/releases/download/v%%VERSION%%/%%FILENAME%%",
51+
"archiveFileName": "%%FILENAME%%",
52+
"checksum": "SHA-256:%%CHECKSUM%%",
53+
"size": "%%SIZE%%"
54+
}
55+
]
56+
}
57+
]
58+
}
59+
]
60+
}

0 commit comments

Comments
 (0)