Par Chimrod, il y a 6 ans
Hello !
This is my first post on the forum :-) I didn't receive my gamebuino yet, but I've started to work with the emulator.
I'm here to share with you a Makefile for compiling a sketch without running arduino IDE. This makefile will automaticaly create the .bin and the .hex file, as arduino would have.
It assume that you already have configured correctly the arduino environment (actualy, the Makefile relies on the arduino binaries)
Makefile
LOCAL_PATH=~/.arduino15 ARDUINO_PATH=~/Téléchargements/arduino-1.8.5SKETCHBOOK_PATH=$(shell grep sketchbook $(LOCAL_PATH)/preferences.txt | cut -d= -f2)
.PHONY: clean
tmp/%.deps: $(LOCAL_PATH)/package_%_index.json tmp python3 config.py $(LOCAL_PATH) < $< > $@
%.bin %.hex: %.ino *.h tmp/gamebuino.deps | tmp
cp $< tmp/sketch/ cp *.h tmp/sketch/ $(ARDUINO_PATH)/arduino-builder \ -compile \ -logger=machine \ -hardware $(ARDUINO_PATH)/hardware \ -hardware $(LOCAL_PATH)/packages \ -hardware $(SKETCHBOOK_PATH)/hardware \ -tools $(ARDUINO_PATH)/tools-builder \ -tools $(ARDUINO_PATH)/hardware/tools/avr \ -tools $(LOCAL_PATH)/packages \ -built-in-libraries $(ARDUINO_PATH)/libraries \ -libraries $(SKETCHBOOK_PATH)/libraries \ -fqbn=gamebuino:samd:gamebuino_meta_native \ -ide-version=10805 \ -build-path $$(realpath tmp/build) \ -warnings=none \ -build-cache $$(realpath tmp/cache) \ -prefs=build.warn_data_percentage=75 \ $$(cat tmp/gamebuino.deps) \ -verbose \ "tmp/sketch/$<" cp tmp/build/$<.bin $*.bin cp tmp/build/$<.hex $*.hex rm -r tmp/sketch/$<
tmp: mkdir -p tmp/sketch mkdir -p tmp/build mkdir -p tmp/cache
clean: rm -r tmp
You have to edit the two first line in the Makefile according with the arduino installation directory.
There is also a python script which extract all the dependancies from the gamebuino configuration file :
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys, jsonif name == "main": deps = json.load(sys.stdin)['packages'][0]['platforms'][0]['toolsDependencies'] for dep in deps: print("-prefs=runtime.tools.%s.path=%s/packages/%s/tools/%s/%s/" %
(dep['name'],
sys.argv[1],
dep['packager'],
dep['name'],
dep['version']),
end=' ') sys.stdout.flush()
Just put the two files in the same directory as the ino project. Now you can run make sketch.bin
or make sketch.hex
in order the compile your project.
The Makefile run for me (debian stable), and my fail for you. Please tell me if you encountered some trouble (and better, how to make this script better :) )