1. Emaker (binding resources)

Here's a little utility i've been using:

--- CODE START ---

-- Name: EMaker (A usefull program to translate eu4 programs to C
adding resource files)
-- Author: Guillermo Bonvehi (pampeano at rocketmail.com)

-- Notes: First of all, I know there's a nice program made by R.
Stowasser, but honestly
-- I like using command line utilities like this one. I wrote this one
to do my job easier
-- it's not finished and it's not error prove.

without warning
with trace

include file.e
include get.e
include wildcard.e

trace(1)
object line
atom fn
sequence files, dires, cm
files = {}
dires = {}

function removeEnd(sequence text)
    if length(text) > 1 then
	    while text[length(text)] = 10 or text[length(text)] = 13 do
		text = text[1..length(text)-1]
	    end while
   elsif equal(text,"\n") or equal(text,"\r") then
		text = ""
    end if
    return text
end function

procedure show_sintax()
	puts(1,"\tSintax:\n")
	puts(1, "\t\tUsing Bcc: exw emaker -bor file.exw file.rc")
	puts(1,"\t\tUsing Lcc: exw emaker -lcc file.exw file.rc")
	abort(1)
end procedure

cm = command_line()

if length(cm) = 2 or length(cm) < 5 then
	show_sintax()
end if

if match(".",cm[4]) then
	cm[4] = cm[4][1..match(".",cm[4])-1]
end if

if match(".",cm[5]) then
	cm[5] = cm[5][1..match(".",cm[5])-1]
end if

if equal(cm[3],"-bor") then
	system("@ecw -bor "&cm[4]&" > null",2)
	fn = open("objfiles.lnk","r")
	line = gets(fn)
	while sequence(line) do
		line = removeEnd(line)
		if match(".c",lower(line)) then
			line = line[1..length(line)-2]
			files = append(files,line)
		end if
		line = gets(fn)
	end while
	close(fn)

	fn = open("emake.bat","r")
	line = gets(fn)
	while sequence(line) do
		line = removeEnd(line)
		if match("-I",line) and match("-L",line) then
			line = line[match("-I",line)+2..length(line)]
			dires = append(dires,line[1..match(" ",line)-1])
			line = line[match("-L",line)+2..length(line)]
			dires = append(dires,line[1..match(" ",line)-1])
			exit
		end if
		line = gets(fn)
	end while
	close(fn)


	fn = open("emake.bat","w")

	puts(fn,"@brc32 -r -32 -I"&dires[1]&" "&cm[5]&".rc\n")
	puts(fn,"@bcc32 -tW -q -w- -O1 -4 -a4 -c -I"&dires[1]&" -L"&dires[2]&"
"&cm[4]&".c @objfiles.lnk\n")
	puts(fn,"@ilink32 -aa -Tpe -q -Gn c0w32 "&cm[4])

	for I = 1 to length(files) do
		puts(fn, " "&files[I])
	end for

	puts(fn,","&cm[4]&".exe,,E:\\euphoria\\bin\\ecwb.lib import32
cw32,,"&cm[5]&".res\n")

	close(fn)

elsif equal(cm[3],"-lcc") then
	system("@ecw -lcc "&cm[4]&" > null",2)
	fn = open("emake.bat","r")
	line = gets(fn)
	while sequence(line) do
		if match("@echo linking",line) then
			files = append(files,"@echo creating resource file\n")
			files = append(files,"@lrc "&cm[5]&".rc\n")
			files = append(files,"@echo linking\n")
			files = append(files,"@lcclnk -s -subsystem windows "&cm[4]&".obj
@objfiles.lnk "&cm[5]&".res\n")
		elsif match("@lcclnk",line) then -- Skip next line
		else
			files = append(files,line)
		end if
		line = gets(fn)
	end while
	close(fn)
	fn = open("emake.bat","w")
	for I = 1 to length(files) do
		puts(fn,files[I])
	end for
	close(fn)
else
	show_sintax()
end if

system("emake.bat",2)

--- CODE END ---

Hope you like it.

=====
Best Regards,
    Guillermo Bonvehi
    AKA: Knixeur - Caballero Rojo

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu