jung6717 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Command-line compilation and upload (Commander.java) #124

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What change would like to see?
I would like to see command-line parameters for the ide to pass a .pde file
for compilation and or compilation&upload, much like the two buttons, yet
as simple as calling a compiler. This would, in my imagine, be something like:

Compiling only:
arduino -c "file" [-mcu "328"]

Compile and Upload
arduino -c "file" -u [-p "com3"]

For the whole matter i would suggest the following paramters:

c "file" - Compile the file with the target settings of the IDE
u        - Upload to Port already set inside the IDE

Optional:
-mcu     - Override the Target device
-p       - Override the standard port

Any callbacks could stay the same as inside the IDE.

Why?
This would enable people (like me) using external editors to simply build
via commandline. Currently external editors are only supported with having
the IDE opened, this woul remove that factor and would also make it easier
for people writing their own IDEs to keep up with Arduino Syntax and Includes.

Would this cause any incompatibilities with previous versions?  If so, how
can these be mitigated?
I cant think of any incompatibilities.

Original issue reported on code.google.com by mamage...@gmail.com on 24 Sep 2009 at 10:25

GoogleCodeExporter commented 9 years ago
This functionality is possible with most editors that understand make and 
Makefiles,
of course.

Original comment by clvrm...@gmail.com on 24 Sep 2009 at 2:42

GoogleCodeExporter commented 9 years ago
I wrote a tool for exactly this situation:

http://code.google.com/p/angbt/

Original comment by e.fa...@wayoda.org on 24 Sep 2009 at 3:38

GoogleCodeExporter commented 9 years ago
Angbt is a nice option, yet not exactly what i look for.. i would rather love 
to have
the ide simply allowing command line build so that you always use the very same
arduino environment of libraries and tools and ensure compatibility with the 
ide from
within your code... 

Original comment by mamage...@gmail.com on 24 Sep 2009 at 6:30

GoogleCodeExporter commented 9 years ago
"i would rather love to have
the ide simply allowing command line build ..."
This will not happen with the current codebase of the IDE. 
It is almost impossible to separate the preprocess/compile/upload functions 
from the
code-editor and IDE-window classes. So you simply can't compile a Sketch without
createing (and thereby showing) the Ide-Window classes. 

"... so that you always use the very same
arduino environment of libraries and 
tools and ensure compatibility with the ide from
within your code... "

This was the reason I wrote angbt! It uses the libraries and other hardware 
dependend
code from an existing Arduino installation.

The only change fromthe IDE is that angbt does not use the binary versions of 
the
avr-gcc compiler and AvrDude that are packaged along with the IDE. (Not to 
mention
the usually outdated JavaRuntime)

BTW: It is only on windows and the mac that the binaries are packaged with the 
IDE,
the Linux version expects that the user has already installed the compiler. 
Don't
know why the Windows version doesn't do the same? Simply installing the
WinAVR-package would do the trick. 

Eberhard

Original comment by e.fa...@wayoda.org on 25 Sep 2009 at 12:51

GoogleCodeExporter commented 9 years ago
There's a Command.java file that provides this functionality in Processing.  
It's currently sitting in the Arduino 
source tree, disabled.  If you want to work on adding command line compilation 
and upload functionality to 
Arduino, that would be a good place to start.  I'm hoping this will be 
relatively easy to maintain (e.g. compared to 
a Makefile), because it should only need to change when the APIs change for the 
Compiler, Uploader, etc.

Original comment by dmel...@gmail.com on 28 Jan 2010 at 8:56

GoogleCodeExporter commented 9 years ago
Hi, I created an updated Makefile for 0018 and posted to the Forum. It took me
approx. 1-hour to change from 0015, I find make files relatively easy to 
maintain. I
can probably further change the file to use a "temp" build area just like the 
IDE in
an additional hour. It really is a matter of exposure and experience, I have 
worked
in Unix/Linux environments for years, using anything other than make for 
building
software is re-inventing the wheel. I also have access to Mac and Win (of 
course) so
I will get the Makefile working on those too.

Original comment by rfran...@gmail.com on 8 Feb 2010 at 7:21

GoogleCodeExporter commented 9 years ago
If you want to maintain the Makefile, that's great.  I'd recommend posting it 
on the Arduino playground so it 
doesn't get lost in the forum.

Original comment by dmel...@gmail.com on 8 Feb 2010 at 8:21

GoogleCodeExporter commented 9 years ago
I think it would be nice to have the makefile on a google-code project page. 
Not the main arduino page, 'arduino-makefile' for instance?  
This is easier to maintain when it comes to new releases of the IDE and you 
have the
wiki comments issues list ...

Eberhard

Original comment by e.fa...@wayoda.org on 10 Feb 2010 at 10:53

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 1 Apr 2010 at 6:16

GoogleCodeExporter commented 9 years ago
If you are looking to add a nice command line interface to the code. Check out 
Apache Commons CLI, http://commons.apache.org/cli/index.html, this way you 
aren't writing the command line code from scratch.

Original comment by KLAb...@gmail.com on 5 Aug 2010 at 12:43

GoogleCodeExporter commented 9 years ago
So I'm hoping to develop this feature for Arduino and after much discussion on 
the mailing list, I've whipped up an initial patch. It adds command-line 
parsing and options to the main Arduino executable, so just rebuild Arduino and 
run it with the --help option to see all the possible parameters. I have only 
implemented and tested --preprocess functionality, but it works as expected. I 
wanted to get this patch out to the right people to see what they thought 
before I continued to work on it.

Original comment by bryant.m...@gmail.com on 12 Aug 2010 at 12:08

Attachments:

GoogleCodeExporter commented 9 years ago
Here's an updated version where building now works. I did some code 
reorganizing so that the constructor for Base doesn't automatically create the 
GUI, it just initializes the class. There's now the function startUI(String 
files[]) that will create a UI.

I also found that Base would parse command line arguments expecting them to be 
files. I've moved this code into main() and if files are found, Base() is 
called to initialize a GUI and passed the files, if not and there are arguments 
then Commander() calls the shots.

I've only been able to test this on a Mac, so if someone could pitch in with 
feedback on either Windows or Linux, that would be awesome.

Original comment by bryant.m...@gmail.com on 12 Aug 2010 at 3:40

Attachments:

GoogleCodeExporter commented 9 years ago
Alright, here's another improved version. It adds the serial port (--port) and 
Arduino target (--target) options. I think they're respected by the compiler.

The problem is that uploading doesn't work. The code has been written right now 
such that calling Sketch.upload() will operate on all the code contained within 
the single sketch. I'd be fine if it seemed easy to add arbitrary files to an 
existing Sketch object.

The other way would be to use the AvrdudeUploader class to upload a binary file 
directly, but I'm not certain how to do that or if the code even supports it as 
it's written right now.

At this point it would be nice if anyone with a more clear understanding of the 
code could chip in to help direct me as to a possible solution to getting 
uploading working.

Original comment by bryant.m...@gmail.com on 15 Aug 2010 at 5:12

Attachments:

GoogleCodeExporter commented 9 years ago
Thx for your efforts on getting this working! It's a great help for automizing 
the setup. If you could get the automatic upload working as soon as a sketch is 
loaded, that'll be even greater! :-)

Thx again,
Norbert

Original comment by kinderkram@gmail.com on 6 Oct 2010 at 12:23

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 20 Dec 2010 at 3:26

GoogleCodeExporter commented 9 years ago
i'd like this feature too.

Original comment by chris.ta...@gmail.com on 19 Mar 2011 at 8:20

GoogleCodeExporter commented 9 years ago
Issue 473 has been merged into this issue.

Original comment by dmel...@gmail.com on 24 May 2011 at 4:24

GoogleCodeExporter commented 9 years ago
Maybe someone can point out the difficulties that prevent this from happening?
Once this is working, we hope to include this into Fritzing, so that one can 
work on the circuit and code in parallel.

Original comment by andre.knoerig@gmail.com on 27 Oct 2011 at 12:48

GoogleCodeExporter commented 9 years ago
I just haven't had a chance to look into yet.  Have you tried out the patch?  
Does it work well enough for Fritzing needs?  How does it apply to Arduino 1.0?

Original comment by dmel...@gmail.com on 27 Oct 2011 at 3:40

GoogleCodeExporter commented 9 years ago
No, we haven't, because Bryant's comment suggests that upload is not yet 
working.
Everything else in Fritzing is ready: code editor, serial port detection, etc. 

So if all that's missing is to send the compiled code to the serial port, we 
could add that. But I assume the uploading requires much more than that..

I have no idea how Arduino 1.0 would change anything.

Original comment by andre.knoerig@gmail.com on 27 Oct 2011 at 4:46

GoogleCodeExporter commented 9 years ago
I've been redirected to here by mellis because I'm looking for command-line 
usage of Arduino.

My idea is to use a more sophisticated editor —e.g. syntax check, function 
parameter tip, code completion, object structure visualisation— and then ask 
Arduino to compile and/or upload the whole project —main sketch and related 
libraries.

I don't want to re-do the job Arduino does nicely nor go into Makefile 
specifics.

The initial post Sep 24, 2009 would fulfil my requirements.

Original comment by Vilo.Rei on 19 Nov 2011 at 10:18

GoogleCodeExporter commented 9 years ago
Issue 1013 has been merged into this issue.

Original comment by dmel...@gmail.com on 22 Aug 2012 at 8:45

GoogleCodeExporter commented 9 years ago
I've added a command-line build option in Arduino, it will be available from 
1.5.2 release.

here the details:

https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-from-command-line

Original comment by c.mag...@bug.st on 16 Jan 2013 at 6:27

GoogleCodeExporter commented 9 years ago
Hi, I've done a build from source under both Linux (Ubuntu 12.04) and Mac (OS X 
10.6.8), but when I launch from the command-line using the parameters as 
described on the page in comment #23, it brings up the Arduino IDE with the 
file whose path is on the command line--but there is no subsequent verify or 
upload. Can you point me to what I might be doing wrong? Verify and upload work 
 from the built IDE GUI. Here is a sample of a command line invocation for mac:

./macosx/work/Arduino.app/Contents/MacOS/JavaApplicationStub --board 
arduino:arduino:uno --verbose --verify --port /dev/tty.usbmodem1d11 
/Users/.../arduino/Arduino/build/shared/examples/01.Basics/Blink/Blink.ino

On the chance that I might not be building 1.5.2, opening the about box to 
check the version, it says "${version}".

Also, will the output from the verify and upload step be sent to 
standard-output so the calling program can read it?

Thanks for the help.

Original comment by irasc...@gmail.com on 21 Jan 2013 at 10:45

GoogleCodeExporter commented 9 years ago
Duh. Was building the wrong branch.

Original comment by irasc...@gmail.com on 21 Jan 2013 at 10:48

GoogleCodeExporter commented 9 years ago
Hello,
I have just downloaded the latest sources from github and tried this new 
feature.
I can confirm that it works with my Due Board. Though, I have one question: 
would it be possible not to open the IDE during the compile/upload process ? if 
called from the command line.

Original comment by dan.corneanu@gmail.com on 22 Jan 2013 at 8:14

GoogleCodeExporter commented 9 years ago
Aside from seconding the request in comment #26, I would like to add the 
following.

-- Under both Linux and Mac, output from verify and upload is sent to standard 
output, so the calling program can read it. This is not true under Windows 
(because typically under Windows applications don't keep a console). Would it 
be possible to send the Windows output to standard output, or if that is not 
possible, to some other shared resource such as the clipboard?

-- Would it be possible to automatically exit the IDE after the verify or 
upload command is executed, so that the calling program knows that the command 
has completed? If the automatic exit is not possible, and standard output were 
available on all platforms a "command complete" output would serve the same 
purpose.

Thanks.

Original comment by irasc...@gmail.com on 23 Jan 2013 at 10:02