This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoolchain.ninja
executable file
·120 lines (87 loc) · 3.9 KB
/
toolchain.ninja
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env -S ninja -f
downloadDir = ./download
toolchainDir = ./toolchain
arduinoStudioURI = https://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz
stdlibProgmemPatchURI = https://patch-diff.githubusercontent.com/raw/avrdudes/avr-libc/pull/887.patch
stdlibWdtHAsmImmediatePatchURI = https://patch-diff.githubusercontent.com/raw/avrdudes/avr-libc/pull/888.patch
toolchainArchiveURL = https://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino7-x86_64-pc-linux-gnu.tar.bz2
#cp -R /usr/include/x86_64-linux-gnu/c++/11/bits hardware/tools/avr/avr/include/bits
#cp -R /usr/include/x86_64-linux-gnu/c++/11/bits/error_constants.h hardware/tools/avr/avr/include/bits/error_constants.h
#hardware/tools/avr/avr/include/bits/
#hardware/tools/avr/avr/include/c++
#hardware/tools/avr/avr/include/features.h
rule dummy
command = echo dummy $in "->" $out
description = dummy rule to link $in -> $out
###############
# obsolete versions, don't enable, actual versions are within the IDE archive itself
#ardArchiveURL = https://downloads.arduino.cc/cores/core-ArduinoCore-megaavr-1.8.7.tar.bz2
#ardArchiveURL = https://downloads.arduino.cc/cores/staging/avr-1.8.5.tar.bz2
#build $downloadDir/ard.tbz: aria2c
# uri = $ardArchiveURL
#build $coreDir: untar $downloadDir/ard.tbz | $toolchainDir
# stamp = avr.stamp
# pool = console
# restat = 1
# add $coreDir into side dependencies here, if you update the deps with the downloaded version
build avr.stamp: dummy ./avr.dd | toolchain.stamp
dyndep = ./avr.dd
#################
coresParentDir = $toolchainDir/hardware/arduino
coreDir = $coresParentDir/avr
toolsDir = $toolchainDir/hardware/tools
#toolchain/hardware/arduino/avr/cores/arduino/WInterrupts.c
rule mkDir
command = mkdir -p $out
description = Create dir $out
build $downloadDir: mkDir
#build $toolchainDir: mkDir
rule aria2c
command = aria2c --auto-file-renaming=false --continue -j 15 -x 15 -o $out $uri
description = download $out
build $downloadDir/gcc.tbz: aria2c
uri = $toolchainArchiveURL
build $downloadDir/ard_s.tbz: aria2c
uri = $arduinoStudioURI
build $downloadDir/progmem.patch: aria2c
uri = $stdlibProgmemPatchURI
build $downloadDir/wdt.h_immediate.patch: aria2c
uri = $stdlibWdtHAsmImmediatePatchURI
rule mv
command = mv $in $out
description = moving $in to $out
rule scandir
command = ./scandir.sh $in $out
#printf 'ninja_dyndep_version = 1\nbuild $1 | %s : dyndep\n restat = 1\n' "`find "$2" -type f | tr '\n' ' '`" > $3
rule untar
command = mkdir -p $out && tar -C $out -xf $in --strip-components 1 && touch $stamp
description = unpack $in to $out
build $toolchainDir: untar $downloadDir/ard_s.tbz
stamp = toolchain.stamp
pool = console
restat = 1
build $toolsDir/avr: untar $downloadDir/gcc.tbz | $toolchainDir
stamp = gcc.stamp
pool = console
restat = 1
build toolchain.stamp: dummy ./toolchain.dd | $toolchainDir
dyndep = ./toolchain.dd
build gcc.stamp: dummy ./gcc.dd | $toolsDir/avr avr.stamp
dyndep = ./gcc.dd
rule patch
command = patch -d $mainDir -p 1 < $in
description = patching
restat = 1
build $toolchainDir/hardware/tools/avr/avr/include/avr/pgmspace.h: patch $downloadDir/progmem.patch | gcc.stamp
mainDir = $toolchainDir/hardware/tools/avr/avr/
pool = console
build $toolchainDir/hardware/tools/avr/avr/include/avr/wdt.h: patch $downloadDir/wdt.h_immediate.patch | gcc.stamp
mainDir = $toolchainDir/hardware/tools/avr/avr/
pool = console
build $toolchainDir/hardware/arduino/avr/cores/arduino/WString.h: patch ./patches/F-strings-workaround_patch.patch | toolchain.stamp
mainDir = $toolchainDir/
pool = console
#build $toolchainDir/hardware/arduino/avr/cores/arduino/WString.h: patch ./patches/Some-changes-in-include-bits-to-allow-C-stdlib-usage.patch | toolchain.stamp
# mainDir = $toolchainDir/
# pool = console
build toolchain_ready: dummy ./gcc.dd | toolchain.stamp avr.stamp gcc.stamp $toolchainDir/hardware/tools/avr/avr/include/avr/pgmspace.h