Sunday, March 8, 2009

UpperCamel: compiling haxe to a native executable

UpperCamel is a little program for going back and forth between
camel case and underlined uppercase.

Typically camel case is used for class names, variables, and method names.

Whereas underlined uppercase is used for constants, statics, etc.
     Sample Input     | Sample Output
------------------+-------------------
UpperCamel | UPPER_CAMEL
ThisIsNeatoEh | THIS_IS_NEATO_EH
UPPER_CAMEL | upperCamel
MIX-and-Match | mixAndMatch

Somewhat useful... The main point is to show how to compile haxe to create a native executable:
% haxe -main UpperCamel -neko upperCamel.n
% nekotools boot upperCamel.n
% echo hello_world | ./upperCamel
helloWorld

Neat, huh?
% file upperCamel
upperCamel: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), stripped
% ldd upperCamel
linux-gate.so.1 => (0x4001a000)
libneko.so => /usr/lib/libneko.so (0x4002e000)
libpthread.so.0 => /lib/libpthread.so.0 (0x4004d000)
libc.so.6 => /lib/libc.so.6 (0x40065000)
libdl.so.2 => /lib/libdl.so.2 (0x401a8000)
libgc.so.1 => /usr/lib/libgc.so.1 (0x401ad000)
libm.so.6 => /lib/libm.so.6 (0x401e1000)
/lib/ld-linux.so.2 (0x40000000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x40207000)

The code for UpperCamel.hx has a bit of shell script which makes it easy to compile for Unix-env type folks:
% wget http://brianin3d-misc.googlecode.com/svn/trunk/UpperCamel/UpperCamel.hx
% chmod 755 UpperCamel.hx
% ./UpperCamel.hx
% file ./upperCamel
./upperCamel: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), stripped

Haxe to binary executable is a nice path for whipping up custom commands when you need them with a really low price of admission!

Go, Haxe!

No comments:

Post a Comment