Did you know? All of these messages will likely be replaced before release.

UnrealEngine1 PreProcessor

For questions and discussion about UnrealEd, UnrealScript, and other aspects of Unreal Engine design.

Moderators: Semfry, ividyon

User avatar Raven
Skaarj Warlord Skaarj Warlord
Posts: 807
Joined: 12 Nov 2007, 09:39
Location: Nørresundby
Contact:

Subject: UnrealEngine1 PreProcessor

Post Posted: 24 Aug 2008, 14:53

This preprocessor is inspired by the one existing in Unreal Engine 3.

Install:
Copy files in the archive to your <UTdir>/system folder.

Download

http://turniej.unreal.pl/files/uenginepp.zip (~570 kb)

ReadMe

ReadMe at WIKI
Last edited by Raven on 27 Aug 2008, 11:48, edited 4 times in total.
Madness, as you know, is like gravity…all it takes is a little push!
Image
http://turniej.unreal.pl/portfolio

User avatar ividyon
Administrator Administrator
Posts: 2352
Joined: 12 Nov 2007, 14:43
Location: Germany
Contact:

Subject:

Post Posted: 24 Aug 2008, 15:45

Yeah, excuse the question, but.. it does exactly what? :B

User avatar Creavion
Skaarj Warlord Skaarj Warlord
Posts: 745
Joined: 12 Nov 2007, 09:43

Subject:

Post Posted: 24 Aug 2008, 15:46

sana wrote:Yeah, excuse the question, but.. it does exactly what? :B

Same here.. I dont understand anything. :lol:
>:E
--------------------------------------------------
Waffnuffly wrote:Holy shit a HOUSE-SIZED BOX

--------------------------------------------------
>:E

User avatar Raven
Skaarj Warlord Skaarj Warlord
Posts: 807
Joined: 12 Nov 2007, 09:39
Location: Nørresundby
Contact:

Subject:

Post Posted: 24 Aug 2008, 16:02

In computer science, a preprocessor is a program that processes its input data to produce output that is used as input to another program. The output is said to be a preprocessed form of the input data, which is often used by some subsequent programs like compilers. The amount and kind of processing done depends on the nature of the preprocessor; some preprocessors are only capable of performing relatively simple textual substitutions and macro expansions, while others have the power of fully-fledged programming languages.


Unreal Engine 3 has preprocessor which is kinda useful in scripting. I wrote it for debugging of TCO. So you can define some value like

Code: Select all

`define _FINALRELEASE=0


and check it to delete some parts of the code automatically. It's similar to all others preprocessors.
Madness, as you know, is like gravity…all it takes is a little push!
Image
http://turniej.unreal.pl/portfolio

User avatar Jethro
Skaarj Warlord Skaarj Warlord
Posts: 686
Joined: 12 Nov 2007, 00:15
Location: Aboard Von Braun

Subject:

Post Posted: 24 Aug 2008, 16:03

Well, it looks like (surprise!) preprocessor - the tool that does some additional pre-processing to the source code before the actual compiler (ucc in this case) does it's job. It allows you to divide code into separate files, just like in c/c++, include them, create conditional code (eg. debug/release version) and so on.
BUT I might be mistaken.

Question: is -clean for piping or it butchers the input file?

EDIT: Raven already explained it...
UBerserker wrote:Story: totally guessed that Skeletor was the thief.

User avatar Raven
Skaarj Warlord Skaarj Warlord
Posts: 807
Joined: 12 Nov 2007, 09:39
Location: Nørresundby
Contact:

Subject:

Post Posted: 24 Aug 2008, 16:08

when preprocessor will find -clean argument or clean in project file, it'll produce pure UnrealScript without all other stuff. If false, all things like preprocessor directives will be commented out. Just working on one new thing.
Madness, as you know, is like gravity…all it takes is a little push!
Image
http://turniej.unreal.pl/portfolio

User avatar Jethro
Skaarj Warlord Skaarj Warlord
Posts: 686
Joined: 12 Nov 2007, 00:15
Location: Aboard Von Braun

Subject:

Post Posted: 24 Aug 2008, 16:28

Raven wrote:when preprocessor will find -clean argument or clean in project file, it'll produce pure UnrealScript without all other stuff. If false, all things like preprocessor directives will be commented out.

Don't get it. So how does it work? You put something like

Code: Select all

var int bodycount = 1; //is this a proper UScript? :P
'define EXTRA_GORE
'ifdef EXTRAGORE
bodycount = 1000;
'endif


Now, i run compile on the project (that just part of one uc I've shown here). So it actually produces set of temporary uc's and compile them?
So what do I need clean for?
Also, about writing the variables. What's the syntax? And, if I understand correctly it writes string representing value of the variable, right? Where is it written? Any example use?
Also, can I define variables from command line? Something like -DVARIABLE[=Value] from GCC?
UBerserker wrote:Story: totally guessed that Skeletor was the thief.

User avatar Raven
Skaarj Warlord Skaarj Warlord
Posts: 807
Joined: 12 Nov 2007, 09:39
Location: Nørresundby
Contact:

Subject:

Post Posted: 24 Aug 2008, 16:43

Let's say you have project file in <UTDir>/system called RUI.upc with content:

Code: Select all

[project]
path=../RComputerUI/
debug=true
make=true
make_ini=make.ini
clean=true
output=classes
input=classes_ucp


whe you'll call uenginepp.exe RUI.upc parser will process all files in classes_ucp, and generates output code in classes, which will be striped out (or not) from preprocessor directives. Let's say you have class:


Code: Select all

`process
`define int1=120
`define int2=123
`define nc=var() class<actor> NewActor;
class PreProcessorTest extends Actor;

`check int1>int2
var() int test1;
`else
var() int test2;
`write nc
`endif


You run preprocessor and:

1. `process directive is found, so preprocessor knows that this class has to be parsed
2. it sets int1 variable as 120
3. it sets int2 variable as 123
4. it sets nc variable as var() class<actor> NewActor;
5. it detects `check directive and compare int1 and int2. because int1 is smaller then int2, expression evaluates to false and all next lines are skipped and deleted
6. it detects `else directive. preprocessor stops deleting lines and searches for next directives
7. var() int test2; is not detected as directive so it's left alone
8. directive `write is detected. preprocessor searches for variable named nc and (if found) writes it in .uc file
9. directive `endif stops conditional expression

output .uc file in classes will look like:

Code: Select all

class PreProcessorTest extends Actor;

var() int test2;
var() class<actor> NewActor;


Of course input file can look different, but most important thing is to write `process in first line.

EDIT:

Now same output code with clean turned off:

Code: Select all

////`process
//`define int1=120
//`define int2=123
//`define nc=var() class<actor> NewActor;
class PreProcessorTest extends Actor;

////`check int1>int2
//var() int test1;
//`else
var() int test2;
var() class<actor> NewActor; //`write nc
//`endif
Madness, as you know, is like gravity…all it takes is a little push!
Image
http://turniej.unreal.pl/portfolio

User avatar Jethro
Skaarj Warlord Skaarj Warlord
Posts: 686
Joined: 12 Nov 2007, 00:15
Location: Aboard Von Braun

Subject:

Post Posted: 24 Aug 2008, 16:55

Now I get it. It takes source code from folder <input>, writes files with the same names but stripped/commented out into <output> and then, if specified, compules all uc files from <output> with ucc? Brilliant! :tup:
Still, possibility of using -D or make-style labels in project files *might* speed-up debugging/developement/including-excluding features etc.
UBerserker wrote:Story: totally guessed that Skeletor was the thief.

User avatar Raven
Skaarj Warlord Skaarj Warlord
Posts: 807
Joined: 12 Nov 2007, 09:39
Location: Nørresundby
Contact:

Subject:

Post Posted: 24 Aug 2008, 17:05

Cool idea, will add it in next release.
Madness, as you know, is like gravity…all it takes is a little push!
Image
http://turniej.unreal.pl/portfolio

User avatar Jethro
Skaarj Warlord Skaarj Warlord
Posts: 686
Joined: 12 Nov 2007, 00:15
Location: Aboard Von Braun

Subject:

Post Posted: 24 Aug 2008, 18:36

OK, now I'm confused.
1. I don't have utpreprocessor.exe, the package you've linked contains only uengineapp.exe, but I assume that's the same thing.
2. I created folder named 'Projects' in <utdir>\system, and placed following structure there:

Code: Select all

2008-08-24  18:17    <DIR>          classes
2008-08-24  18:11    <DIR>          classes_ucp
2008-08-24  18:18               102 test.upc


test.upc is:

Code: Select all

[project]
   path=projects/
   debug=true
   make=false
   clean=true
   output=classes
   input=classes_ucp


The directory classes_ucp contains 2 files:
globals.uc

Code: Select all

'define DEBUG


main.uc

Code: Select all

'process
'include globals.uc
//Don't care if it actually compiles ATM
class TestWeapon extends TournamentWeapon
{
   void Test() {
      var int bodycount = 10;
   'ifdef DEBUG
      bodycount = 100;
   'else
      bodycount = 15;
   'endif
   }
}


Test result?:

Code: Select all

?>uenginepp.exe projects\test.upc
------------------------------------------
         UnralEngine PreProcessor
------------------------------------------
 Version : 0.1.0
 Build   : 24.08.2008
------------------------------------------
 Using project definition: projects\test.upc.
 Using project directory projects/.
 Debug mode: on.
 Run ucc make with
------------------------------------------
------------------------------------------
4 uc files found.
0 uc files parsed.
Execution time: 0.03 seconds.
------------------------------------------
 Executing: ucc.exe make
--------------------Core--------------------
--------------------Engine--------------------
--------------------Editor--------------------
--------------------UWindow--------------------
--------------------Fire--------------------
--------------------IpDrv--------------------
--------------------UWeb--------------------
--------------------UBrowser--------------------
--------------------UnrealShare--------------------
--------------------UnrealI--------------------
--------------------UMenu--------------------
--------------------IpServer--------------------
--------------------Botpack--------------------
--------------------UTServerAdmin--------------------
--------------------UTMenu--------------------
--------------------UTBrowser--------------------
Success - 0 error(s), 0 warnings

Wher did he got 4 files from? Also, no output written to projects\classes

I've tried also:

Code: Select all

?>uenginepp.exe ..\system\projects -clean -debug
------------------------------------------
         UnralEngine PreProcessor
------------------------------------------
 Version : 0.1.0
 Build   : 24.08.2008
------------------------------------------
 Using project directory ..\system\projects.
 Debug mode: on.
------------------------------------------
------------------------------------------
5 uc files found.
0 uc files parsed.
Execution time: 0.03 seconds.

Why bodycount (uc count :P) increased? Still, no files were processed (no output in classes/, the default output directory).

Also, I again don't quite understand the idea. Or do I? make.ini contains the information about where compiler (u-file name) should put the output, right? Can you post sample make.ini?
UBerserker wrote:Story: totally guessed that Skeletor was the thief.

User avatar Raven
Skaarj Warlord Skaarj Warlord
Posts: 807
Joined: 12 Nov 2007, 09:39
Location: Nørresundby
Contact:

Subject:

Post Posted: 24 Aug 2008, 18:42

It's not:

'process

but

`process. Just found bug. It returns number of all files (directories, etc), not uc files. Will be fixed in next release :). Ok, and included file is not processed. Will also fix it.
Madness, as you know, is like gravity…all it takes is a little push!
Image
http://turniej.unreal.pl/portfolio

User avatar Jethro
Skaarj Warlord Skaarj Warlord
Posts: 686
Joined: 12 Nov 2007, 00:15
Location: Aboard Von Braun

Subject:

Post Posted: 24 Aug 2008, 18:57

Raven wrote:`process

Oops, my bad :oops: Changed all 's to `

Ok, so I know my answer if includes are processed :P

Now, the program hanged my system once - no idea why. How about logger?

Another thing: `include globals.uc fails. What should be the path? Even if it's not processed it should be included to produce non-stripped code.

One more thing: output is always empty for me, even if I remove all the tags.

Also, I've test-added `ifdef at the end, without any parameters, without closing, without anyting and the program didn't even complain.

Another.... undocumented feature -

Code: Select all

//`include xxx.uc

is actually parsed (perhaps regex matching lines beginning with whitespaces` would help here?) as including file "// xxx.uc" - it obviously fails.

Oh, and, to clarify things. It's not that I complain only to complain. I'm no UScript programmer and probably never will be. But I have some background in programming and I know what do I expect from the tools I use, that's why I try to give some feedback. Please, don't be mad at me...
UBerserker wrote:Story: totally guessed that Skeletor was the thief.

User avatar Raven
Skaarj Warlord Skaarj Warlord
Posts: 807
Joined: 12 Nov 2007, 09:39
Location: Nørresundby
Contact:

Subject:

Post Posted: 24 Aug 2008, 19:15

Tnx for testing :). Update:

-path to included files is now relative to project path
-new directive - `inc_process was added. it includes file and parse it.
Madness, as you know, is like gravity…all it takes is a little push!
Image
http://turniej.unreal.pl/portfolio

User avatar Creavion
Skaarj Warlord Skaarj Warlord
Posts: 745
Joined: 12 Nov 2007, 09:43

Subject:

Post Posted: 24 Aug 2008, 22:19

I see, its nothing for the 08/15 mapper, if I look to your "slugfest" :o
>:E

--------------------------------------------------

Waffnuffly wrote:Holy shit a HOUSE-SIZED BOX


--------------------------------------------------

>:E

Next

Who is online

Users browsing this forum: No registered users and 8 guests

Copyright © 2001-2024 UnrealSP.org

Powered by phpBB® Forum Software © phpBB Limited