premake / premake-xcode

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

Per-File C/C++/ObjC Compiler Settings #27

Open DavidLudwig opened 8 years ago

DavidLudwig commented 8 years ago

Hi. I'm just getting started with premake. I've been able to get pretty far in having it build a large, custom library, but am having issues getting it to compile some files with Objective-C ARC, and some without.

Using either a precompiled OSX binary of premake5 alpha 9, or a custom OSX build from a 'git clone' of 1d817779dff730ca1d39e496b3f8d182f863f3a4, attempting to add per-file compiler settings (to selectively enable, or disable, Objective-C ARC), such as through the following filter, doesn't seem to work:

filter "files:src/Foo.m"
    buildoptions { "-fobjc-arc" }

I'm not sure if this is the correct, premake5.lua syntax for doing per-file compiler settings, however, I did take a look through the Xcode plugin's source, and at a glance, it doesn't look like it has support to add the .xcodeproj text, 'settings = { COMPILER_FLAGS = "whatnot"; };', for specific files (via xcode.PBXBuildFile(tr), in premake-xcode's xcode_common.lua).

Cheers! -- David L.

starkos commented 8 years ago

I don't believe per-file settings has made it into the Xcode exporter yet. The Visual Studio exporter does support it, and could be used as a reference (though this is an area that I am actively working to simplify now, it could took a little while before I can get it done).

DavidLudwig commented 8 years ago

Might you have any recommendations for areas within the VS exporter, such as source-files + lines, that I could look at, to get an idea of how to work with premake5.lua file-data? I'm especially curious how to get 'buildoptions' data, given a file-to-build.

I started an attempt to put a patch together to add support for Xcode, and was able to put 'settings = {}' blocks into each PBXBuildFile block, but only by hard-coding some stuff into the nodes created by 'function xcode.buildprjtree(prj)' (in xcode_project.lua).

starkos commented 8 years ago

Might you have any recommendations for areas within the VS exporter, such as source-files + lines

Sorry, off the top of my head no, but if you search for "buildoptions" in the VS exporter you should be able to find it.

That said, the structure of the Xcode exporter is very different from VS (and everything else). Seemed like a good idea at the time; wish I hadn't done it that way now.