VDrift / vdrift

VDrift source code
http://vdrift.net/
GNU General Public License v3.0
347 stars 93 forks source link

Premake build configuration #34

Closed logzero closed 13 years ago

logzero commented 13 years ago

I've played a bit with premake4 http://industriousone.com/what-premake as a possible replacement for scons/codeblocks/xcode.

Tested on win32 with codeblocks and msvc. It has worked flawlessly. Will test on linux/ubuntu next. I need some help with macosx.

It works analogous to cmake generating make/project files but has a very clean syntax:

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

    configuration "Release"
        defines {"NDEBUG"}
        flags {"OptimizeSpeed"}

    configuration "Debug"
        defines {"DEBUG"}
        flags {"ExtraWarnings", "Symbols"}

    project "vdrift"
        kind "ConsoleApp"
        language "C++"
        location "."
        targetdir "."
        includedirs {"include", "src"}
        links {"SDL_image", "SDL_gfx", "vorbisfile", "curl", "archive"}
        files {"include/**.h", "src/**.cpp"}
        -- excludes { "foo.h", "bar.c" }

-- windows
if os.is("windows") then
        flags("StaticRuntime")
        includedirs {"win32/include", "win32/bullet"}
        libdirs {"win32/lib"}
        links {"opengl32", "glu32", "glew32", "SDLmain", "SDL", "wsock32", "ws2_32"}
        if _ACTION == "codeblocks" then links {"mingw32"} end
        files {"win32/bullet/**.h", "win32/bullet/**.cpp"}
        postbuildcommands {"xcopy /d /y ..\\win32\\lib\\*.dll ..\\"}

-- macosx
elseif os.is("macosx") then
        links {SDL.framework"}

-- posix
else
        libdirs {"/usr/X11R6/lib"}
        links {"GL", "GLU", "GLEW"}
end
antoniovazquezblanco commented 13 years ago

I can test on mac os. Why do you want to replace scons? Thanks

logzero commented 13 years ago

It is not about testing. You would have to write it for macos, complete includedirs/libdirs/links.

The idea is to reduce maintenance. You won't have to update the project files anymore because they would be generated by premake. You would run premake to update/create them. The frameworks could be moved into a separate dependencies package. The above premake script allows to generate make files, codeblocks and msvc projects.

I don't want to enforce this, am just curious how it works out, if it is a viable alternative.

starkos commented 13 years ago

You could clean up the syntax even more by replacing the if-else statements with additional configuration blocks.

configuration { "windows" }
        flags { "StaticRuntime" }
        includedirs {"win32/include", "win32/bullet"}
        libdirs {"win32/lib"}
        links {"opengl32", "glu32", "glew32", "SDLmain", "SDL", "wsock32", "ws2_32"}
        files {"win32/bullet/**.h", "win32/bullet/**.cpp"}
        postbuildcommands {"xcopy /d /y ..\\win32\\lib\\*.dll ..\\"}

configuration { "windows", "codeblocks" }
        links {"mingw32"}

configuration { "macosx" }
        links {SDL.framework"}

configuration { "not windows or macosx" }
        libdirs {"/usr/X11R6/lib"}
        links {"GL", "GLU", "GLEW"}
antoniovazquezblanco commented 13 years ago

I've started testing this. Is there any way of making this work just by typing premake? it is just that I had to type premake xcode3. second thing is that under mac os framework search path is not set so that it won't find the frameworks you're linking.

antoniovazquezblanco commented 13 years ago

I'm trying to implement premake in our system for mac os. I'm having some problems. I will post my questions here. Force feedback is enabled at compile time by a preprocessor definition. Is there any problem if force feedback is left always enabled? Why is that preprocessor flag there?

logzero commented 13 years ago

I've pushed a premake4.lua so you can work on it.

Add the search paths for the frameworks with libdir{}.

Wasn't aware that force feedback has to be enabled by a flag.

antoniovazquezblanco commented 13 years ago

I have to tell you that framework search paths can't be set by the moment but I had reported the bug to premake. I will require a little workaround. I will leave include/definitions.h as it is for faster implementation of the premake system. I've realised there are some problems with definitions.h and some classes called VERSION and other little things. I also need someone for reviewing some comented code I think is causing some game problems but I will do all of this after merging the actual pull request I sent you. Thanks.

logzero commented 13 years ago

We should be able to generate the definitions.h file with premake.

Create new issues for the code you think is causing problems.

antoniovazquezblanco commented 13 years ago

I'm on premake4 for linux. Almost builds :P

antoniovazquezblanco commented 13 years ago

Builds and seems to run :D

logzero commented 13 years ago

includedirs {"/usr/local/include/bullet/"} ? Where do you have your bullet package from?

antoniovazquezblanco commented 13 years ago

That's the default installation directory... I think I've compiled it from source :P

logzero commented 13 years ago

Should be /usr/include/bullet for system lib. http://pkgs.org/ubuntu-11.04/getdeb-games-i386/libbullet-dev_2.77-1~getdeb1_all.deb.html

antoniovazquezblanco commented 13 years ago

also included that dir.

antoniovazquezblanco commented 13 years ago

mac build stills buggy and needs fixes because premake stils too new :P

logzero commented 13 years ago

"needs fixes because premake stils too new" That sucks :(

Btw can you try "glPixelStorei(GL_UNPACK_SWAP_BYTES, 1)" before glTexImage2D in GenTextures.

http://www.gamedev.net/topic/371606-converting-bgr-to-rgb-in-sdl/

antoniovazquezblanco commented 13 years ago

I'll test after trying to fix premake xcode build :D

antoniovazquezblanco commented 13 years ago

It doesn't work...

antoniovazquezblanco commented 13 years ago

I think the solution is to add particular cases for mac os that use BGR instead of RGB when assigning the value of the "format" variable.

antoniovazquezblanco commented 13 years ago

Have a look at the latest patch and tell me what you think.

antoniovazquezblanco commented 13 years ago

I think this can be closed. Am i right?

logzero commented 13 years ago

Can you do a quick ubuntu check?

antoniovazquezblanco commented 13 years ago

Compiles and runs. :D

logzero commented 13 years ago

Closing. Can be reopened if there are issues.