Pages: [1] 2 3 4   Go Down
Author Topic: Windows command line build  (Read 8348 times)
0 Members and 1 Guest are viewing this topic.
Florida, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 146
meow!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Because the Arduino Makefile command line build is not very friendly for Windows programmers, I have started a project to make Windows batch files to compile and upload Arduino sketches.  Here is what I have so far...

http://www.arduino.cc/playground/Code/WindowsCommandLine

Be sure to read the instructions carefully so you know what the issues are.  Please post any questions, comments, and bug reports to this thread.  Thanks!

- Don
Logged

Florida, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 146
meow!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

New and improved!  Now the Windows command-line build will parse your preferences.txt file just like the Arduino IDE does to determine your MCU type, programmer type, etc.  Look here for download and documentation:

http://www.arduino.cc/playground/Code/WindowsCommandLine
« Last Edit: January 07, 2007, 05:44:18 pm by CosineKitty » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 134
panta rei resist the resistors!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hey cosine,
that looks great, I started playing with the makefile but couldn't solve it in 5 minutes..

thanks also for all the contributions and addition to the playground smiley-wink

b.
Logged

Austin, TX
Offline Offline
Full Member
***
Karma: 2
Posts: 182
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is great.

If there was a top-level batch file called "make" then the windows command line build would start to look more like the unix one.

Has anyone looked into using a windows version of "make"?  I know there are several out there, and it might be easier to just crib one .exe than to have a whole system of batch files.  Just a thought.
Logged

Chris J. Kiick
Robot builder and all around geek.

Florida, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 146
meow!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If there was a top-level batch file called "make" then the windows command line build would start to look more like the unix one.
Feel free to rename abuild.bat to make.bat ... it's YOUR computer, after all!  smiley
Seriously, I didn't want to call it "make" because I didn't want to introduce conflicts with somebody who had a genuine make utility already there.

Quote
it might be easier to just crib one .exe than to have a whole system of batch files.
The reason I did all this work was because I was going to use the makefile, so I started looking for a Windows version of make.  Then I realized I needed grep and sed also, which meant I was going to need to find them, hope they were compatible, blah blah blah.  It seemed like too much hassle for every single Windows user of Arduino to have to go through.  So now you don't have to search for anything; just download 3 batch files, put them in your path, set your ARDUINO_PATH environment variable, and you're done.  Run abuild.bat and it will call the other 2 batch files as needed.

Oh, and did I mention your binaries will be smaller than with the ones the Makefile or the IDE will produce?
« Last Edit: January 08, 2007, 06:25:21 pm by CosineKitty » Logged

Austin, TX
Offline Offline
Full Member
***
Karma: 2
Posts: 182
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The reason I did all this work was because I was going to use the makefile, so I started looking for a Windows version of make.  Then I realized I needed grep and sed also, which meant I was going to need to find them, hope they were compatible, blah blah blah.  It seemed like too much hassle for every single Windows user of Arduino to have to go through.  So now you don't have to search for anything; just download 3 batch files, put them in your path, set your ARDUINO_PATH environment variable, and you're done.  Run abuild.bat and it will call the other 2 batch files as needed.

Well, I decided to see just how hard it was to do it the other way.  I noticed that the arduino root directory contained cygwin1.dll - cygwin is a port of gnu utilities to Windoze.  The avr-tools binaries are based on cygwin.  So I downloaded the base cygwin utilities and "make". This is very easy via the cygwin setup program. Once I had the actual files installed, I copied make, grep and sed from the cygwin bin directory to arduino/tools/avr/bin.  It turns out that a couple of other dlls are needed to get them working: cygpcre-0.dll and cygiconv-2.dll. Just copy the to the same directory that cygwin1.dll is in.  Now you can run make, sed and grep just like you run, say avr-size.

As far as I can tell, these are gnu compatible utilities and should not have any problems with standard uses.

Given that we already are using cygwin style tools, I don't think it would be that hard to add these utilities to the arduino-win distribution.  I'll play around and see if I can build all the examples from the command line using the cygwin make utility.

Quote
Oh, and did I mention your binaries will be smaller than with the ones the Makefile or the IDE will produce?
Bonus!
Logged

Chris J. Kiick
Robot builder and all around geek.

Florida, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 146
meow!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Given that we already are using cygwin style tools, I don't think it would be that hard to add these utilities to the arduino-win distribution.

That would be great!  In the meantime, you and I could assemble links and instructions into a page on the Playground so that people could use either method.

Another thing to consider:  I am proposing changes to Arduino 0008 that will make many sketches compile to much smaller binaries.  This requires changing some Java code in the Arduino IDE, splitting up lib/targets/arduino source code into smaller source files, and (relevant to this discussion) reworking the build process to link in the runtime as a library instead of object files.  It would be nice to see if we can change the makefile to work with my library patch... see here:
http://www.arduino.cc/playground/Code/LibPatch0007

The windows batch files I wrote are designed to work with either the original Arduino 0007 distribution, or with the library patch above.

Incidentally, that is why my batch files make smaller binaries; and if you use the library patch also, they get a LOT smaller!
Logged

Austin, TX
Offline Offline
Full Member
***
Karma: 2
Posts: 182
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I got the cygwin windows make working. It's not quite as intuitive as I had hoped. Actually, the make program itself is fine, it's just that full windows path names (eg C:\something with spaces\) don't play well with makefile syntax.  You have to use the "8.3 safe" file names to avoid the spaces, and I haven't figured out how to handle the drive spec yet. When I used relative path names with no spaces, it worked just like the unix version.  The cygwin core programs may have a solution for this - I'll have to do some research.

The Makefile itself could probably use a few tweaks if it's going to build a library.  What I would like to be able to do is go to the top-level sketch directory and type "make SKETCH=foo" and have it automatically build the sketch in directory foo without having to do much, or any, editing.  For both unix and Windows.

If we have a compatible command line build process for both windows and unix (Mac too?) then the IDE could be simplified. Instead of issuing a bunch of compiler commands, it could just go to the right directory and run "make" with the appropriate targets, capturing the output.  This has the advantages of unifying the command line and IDE build process, making the IDE simpler, and allowing modifications to the build process by just editing the Makefile (instead of hacking the java code for the IDE).

eh?
Logged

Chris J. Kiick
Robot builder and all around geek.

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The first versions of Arduino worked by simply running "make" against an appropriate Makefile, but it was more work than doing the compilation from within the IDE.  For one, we had all sorts of weird problems with things working differently on different platforms (e.g. some Windows machine needed forward slashes in the Makefile, others double-backslashes).  Plus, we're doing a reasonable amount of pre-processing in Java (like automatically generating function prototypes) that seem like they'd be more difficult to do with a Makefile (nor does distributing Perl or Python or whatever with Arduino seem like a good idea).  At this point, so few people use the command line build that I'm reluctant to put more work into it.  But don't let me stop you from playing around.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am having a problem with running these batch files.  I run the following in a batch file:

SET ARDUINO_PATH="C:\Program Files\arduino-0007"
Call abuild.bat MCcode_temp.cpp

Where MCcode_temp.cpp is the file I want to compile and upload to the Arduino.  However, I always receive the following error dialog box:
"This application has failed to start because cygwin1.dll was not found.  Reinstalling the application may fix this problem" with a dialog box heading name "avr-g++.exe -Unable to locate component".

The commandline reports the following: "abuild.bat: ***ERROR: cannot compile MCCode_temp.cpp"

Is there something obvious I am missing?  The above mentioned DLL file is located in the arduino folder, as expected.

Any help would be greatly appreciated.

Cheers
Logged

Florida, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 146
meow!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmmm... I am not sure, but I would try changing the line:


SET ARDUINO_PATH="C:\Program Files\arduino-0007"

to:


SET ARDUINO_PATH=C:\Program Files\arduino-0007

Make absolutely sure you have NO SPACES at the end of this line also.
Logged

Florida, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 146
meow!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Wait... never mind.  I see what the problem is:  my batch files cannot cope with spaces in the ARDUINO_PATH, with or without quotes.  I am working on a fix, but in the mean time, you could try moving the entire directory "c:\program files\arduino-0007" to "c:\arduino-0007", then do:

set ARDUINO_PATH=c:\arduino-0007

When I get the spaces issue fixed, I will update the batch files on the Playground and post a message here.  (It may take me a couple of days to get around to it.)

- Don
Logged

Florida, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 146
meow!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, actually it turned out to be a lot simpler to fix than I thought! smiley

I have fixed the batch file abuild.bat in the Playground:

http://www.arduino.cc/playground/uploads/Code/abuild.txt

Delete your existing abuild.bat, download the above, then rename it from abuild.txt to abuild.bat.

You will need to remove the double-quotes (") from your calling batch file:

set ARDUINO_PATH=c:\Program Files\arduino-0007

Let me know how it works...

- Don
Logged

San Diego, CA
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm trying to use the command line/batch utility and keep getting the error: "Missing build.f_cpu in file preferences.txt"

Here is the output:
C:\>abuild.bat C:\arduino-0010\examples\Communication\PhysicalPixel\PhysicalPixe
l.pde
Missing build.f_cpu in file "C:\Documents and Settings\sweddle\Application Data\
arduino\preferences.txt"

I looked over the preferences.txt file and no such luck, does this utility work with VER 10?

Thanks
Shane
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

please update the batch files to work with arduino-0011. agetpref.bat does not work anymore, because the preference file changed, as it seems.

cheers, stahl
Logged

Pages: [1] 2 3 4   Go Up
Jump to: