-D targets are confusing

i wish it were documented succinctly somewhere... so anyway when i build for html5, i was expecting then i could do #if html5 but that didn't work so looking at the build.hxml it appears to be #if web and looking at my old code it sees li…

Viewing 1 to 7 (7 Total)
-D targets are confusing

raould

raould
Total Posts: 224
Joined: December 03, 2011

i wish it were documented succinctly somewhere...

so anyway when i build for html5, i was expecting then i could do

#if html5

but that didn't work so looking at the build.hxml it appears to be

#if web

and looking at my old code it sees like long ago it was

#if target_html5

i think i wish it was just the same thing that was told to the invocation of nme, e.g. in this case just "html5".

Tags:
Posted on August 08, 2012 at 5:00 PM

raould

raould
Total Posts: 224
Joined: December 03, 2011

Re: -D targets are confusing

hang on now i'm really confused is it doing "-D web" for both js and flash?

Posted on August 08, 2012 at 5:10 PM

raould

raould
Total Posts: 224
Joined: December 03, 2011

Re: -D targets are confusing

oh wait, maybe i'm getting it (again,maybe)

there are 2 parts to the build process:

(1) the target given to nme command line e.g. html5 or flash.
(1a) that passes things like "target_html5" or "target_flash" into the nme.nmml context.
(2) invoking the haxe compiler.
(2a) this gets things if they were defined in nme.nmml, but if they weren't "chained" through then they are dropped and can't be used for #if's.

Posted on August 08, 2012 at 5:12 PM

raould

raould
Total Posts: 224
Joined: December 03, 2011

Re: -D targets are confusing

hm but target_html5 doesn't seem to be happening?

i wish i knew how to see what the command line invocation of nme is passing into nme.nmml.

Posted on August 08, 2012 at 5:14 PM

Philippe

Philippe
Total Posts: 261
Joined: September 08, 2011

Re: -D targets are confusing

For HTML5 you get 'js' defined:
#if js

I agree it's a bit confusing and they should also define 'html5'

Posted on August 09, 2012 at 2:36 AM

mlopes

mlopes
Total Posts: 42
Joined: November 20, 2011

Re: -D targets are confusing

I just tried the following:

nme display LazOr.nmml html5 -nmml


And I notice that html5, target_html5 and web variables are all being set to 1.

Hope this helps, apparently you can do this for any target you want.

Still seems that there are some flags missing, since I'm using an "# if iphone" on my code, which is working, but I can't see it on the output of the command above. But I can see them if I run

nme display LazOr.nmml ios -hxml

Posted on August 09, 2012 at 4:30 AM

singmajesty

singmajesty
Total Posts: 2139
Joined: August 25, 2011

Re: -D targets are confusing

Here are the defines:


Languages

cpp, neko, js, flash

Targets

windows, mac, linux, ios, android, blackberry, webos, flash, html5

Environments

desktop, web, mobile


These should all come through in your Haxe code, but when processing NMML, only the target and environment defines will be present, if I remember correctly.

You should be able to check based on your desired platform, but the more general environment defines are there to help determine how an application should act whether it is online, or on a mobile device... and sometimes this can be different for the same target. For example, the development builds of NME are able to publish HTML5 applications to mobile platforms. In this case, you may have "html5", "blackberry" and "mobile" all defined.

By default, a mobile application will be fullscreen (unless you have overwritten it with your own <window width="" height="" /> NMML tag), but a web or desktop application defaults to 640 x 480. So this means that an HTML5 application for mobile defaults to the size of the device, while it defaults to a different size when it is running in a browser.

Please let me know if NME is working differently than I've tried to describe above, and if there are any changes you think we could or should make to improve the system

Posted on August 09, 2012 at 10:49 AM