Perl FRC builder in Linux

I developed a program for building the robot code in Perl. I know that there is already an actual makefile which makes use of “make,” but on my laptop, I have several directories full of code, and thought it would be nice to have one centralized utility to build them.

When you execute the program, it will compile all .c files in the current directory.

Installation Instructions:
cp ./frcbuild /usr/bin
chmod 755 /usr/bin/frcbuild

Type “frcbuild” in your code directory to build.

Comments/criticism would be greatly appreciated.

#!/usr/bin/perl -w

# Builder for MCC18
# FIRST Team 68, Truck Town Thunder

# Coded by: Michael Auchter (auchter.phire.org)
# Questions? Comments? [email][email protected][/email]

use strict;
# Variable Declaration.  Pretty self explanatory...
my $MCC   = "/opt/mcc18";
my $MCC18 = "$MCC/bin/mcc18.exe -p=18F8520";
my $LINK  = "$MCC/bin/mplink.exe";
my $WINE  = "/usr/bin/wine";
my $OPT   = "\"$MCC/h\" -D_FRC_BOARD -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-";
my $DRIVE = "Z";
my $LIB = "$DRIVE:$MCC/lib/";

# Compilation
while (<*.c>) {                 # Case sensitive, change if .C
 print "Compiling: $_
";
 my $o = $_;
 $o =~ s|\.c$|\.o|i;
 system("$WINE $MCC18 \"$_\" -fo=\"$o\" /i$OPT") unless (/print_f/);
 system("$WINE $MCC18 \"$_\" -fo=\"$o\" /i\"$MCC/h\"") if (/print_f/);
}

# Build
print "Building FrcCode.hex
";
my $files = "";
$files = "$files $_ " while (<*.o>);
system("$WINE $LINK /l\"$DRIVE:$MCC/lib/\" \"18f8520user.lkr\" $files \"FRC_library.lib\" /m\"FrcCode.map\" /o\"FrcCode.cof\"");

print "Removing *.o
";
system("rm $_") while (<*.o>);
```<br><br><a class='attachment' href='/uploads/default/original/3X/e/9/e902ea8aa3975b75e5bbe270d4ed3737ed14c2ae.txt'>frcbuild.txt</a> (1.02 KB)<br><br><br><a class='attachment' href='/uploads/default/original/3X/e/9/e902ea8aa3975b75e5bbe270d4ed3737ed14c2ae.txt'>frcbuild.txt</a> (1.02 KB)<br>

Does this code work on Windows and Linux?

It sounds very cool to me.

Have you thought about using PAR to compile it to an executable that is non relient on haveing Perl on the system? or adding a GUI with perl TK? If you haven’t I could probably help you out, becuae I have done a bit of stuff with both…

You’d need only modify the file paths by the looks of it. Perl is farily inutive, except when it looks like line noise. :wink:

Yes, the file paths are all that need to be modified for it to work under Windows. As far as using PAR or a GUI, I had not thought of that, but if you’d like, feel free to modify the code and post it here.

Now this compiles it with using C18?

sounds cool… I might give it a go…