premake / premake-dlang

BSD 3-Clause "New" or "Revised" License
2 stars 3 forks source link

Provide an example ```premake5.lua``` #1

Closed jkm closed 9 years ago

jkm commented 9 years ago

Can you provide a sample premake5.lua compiling some D code? I have some difficulties with versions.

premake5.lua:99: attempt to call global 'versions' (a nil value)

The sample can also be used as a test case.

TurkeyMan commented 9 years ago

Good call. I'll do up some samples and document the API's in the wiki. You need to require "d" at the top of your script. Embedded modules still need to be require-ed. Thanks for taking a moment to try this out. It was only just merged, and I'm happy to field any bugs/issues. I've only tested with my own environments.

@starkos Do you have any thoughts on this situation moving forwards? The actions can be implicitly loaded, but the non-action modules have nothing to imply that they should be loaded...

jkm commented 9 years ago

It's not the require "d". I try to use versions for specifying which version to compile but it is somehow ignored. I used to use defines but that does not work anymore. It also seems that I should now use imports instead of includedirs but imports does not work for me. Can you just upload a sample that works for you such that I can fix this and move on?

starkos commented 9 years ago

If you remove _preload.lua (move everything into the module scripts) Premake will load the module automatically on startup, so the require() isn't needed. As far as loading on demand…I'm not sure, but the current approach I'm using for actions won't scale. Can you ask over on the forums? And I'll give it a bit of thought, I might have some ideas.

TurkeyMan commented 9 years ago

@jkm Where did you see those api's? The ones you are looking for are versionconstants, versionlevel, includedirs (same as C), etc. The D-specific API's are declared in _preload.lua. I'll do up some doco+examples.

Incidentally, I tried to build a clean binary (my local build is hacked a bit), and it doesn't work...

@starkos I mentioned some months ago on the forum about builtin non-action modules not working. It seems that is demonstrated here. Build master, and try language "D" with gmake or vs whatever: invalid value 'D' for language. Works fine when loaded as a not-builtin module, or running debug.

TurkeyMan commented 9 years ago

@jkm master is working properly now.

solution "Test"
    configurations { "Release", "Debug" }

    project "Test"
        language    "D"
        kind        "ConsoleApp"
        includedirs "inc/"
        versionconstants { "VER" }
        versionlevel (2)
premake5 gmake
jkm commented 9 years ago

Oh. Then I misunderstood https://github.com/premake/premake-dlang/blob/master/tools/dmd.lua#L286. My fault. Looked in the wrong place.

BTW the README.md says that premake looks in ./.premake/ but it doesn't. The README.md needs to be fixed (see https://github.com/premake/premake-core/wiki/Locating_Scripts).

TurkeyMan commented 9 years ago

D is a builtin module now. If you get latest (as of a few moments ago) and build it (don't forget to update submodules and embed!), you don't need require "d".

jkm commented 9 years ago

Can't follow. You mean building premake5. I downloaded the binary and set premake.path = ".premake/premake-dlang/" (but the documentation stated that the D module is built in; but it wasn't according to my experience). Then I have require "d" which I still need.

TurkeyMan commented 9 years ago

The D module was only commit a couple of days ago. There are no binary builds with builtin D support yet. You can make use of the D module here as an external module for now, which is to clone the repo into /modules/d/ relative to your premake5.exe, and then use require "d". Careful with the path; the folder name needs to match the module name (require "d" -> modules/d/d.lua).

TurkeyMan commented 9 years ago

Oh, I've updated the readme now, and I'm populating the wiki with docs for the D APIs.

jkm commented 9 years ago

That's what I'm doing. Thanks for pointing out versionconstants. I would prefer version though. It used to be defines.

TurkeyMan commented 9 years ago

So, you're saying that's what you're doing and it still doesn't work? I'll need more context. I use this module as an external module for every D project I have.

version doesn't distinguish between version identifiers and the version level. defines isn't really a meaningful concept in D, it just seems like a poor abuse of existing api's.

Docs are finished.

jkm commented 9 years ago

It works. But I don't get what I need to do to remove require "D". Just curious.

starkos commented 9 years ago

I mentioned some months ago on the forum about builtin non-action modules not working.

Looks like you got it working? No trouble with the latest code here.

TurkeyMan commented 9 years ago

@jkm Wait for the next binary release of premake. Or build it yourself from master.

@starkos Yeah, it's working for me now after your suggestions :) It does always load though, so the D code is active whether people use it or not. Shouldn't harm anything, but you know...