Sunday, May 14, 2017

premake5 android and ios support

newoption {
    trigger = 'platform',
    description = 'platform name',
    value = 'name',
    allowed = {
        { 'android', '' },
        { 'ios', '' },
    }
}

workspace 'mylib'
location '_build'
configurations { 'debug', 'release' }

-------------------
-- Android specific

filter { 'options:platform=android' }
toolset 'gcc'
gccprefix '~/arm14/bin/arm-linux-androideabi-'

if _OPTIONS['platform'] == 'android' then
    premake.override(premake.tools.clang, "gettoolname", function(base, cfg, tool)
        local basetool = base(cfg, tool)
        local toolchain_prefix = cfg.gccprefix
        print("prefix = " .. tostring(toolchain_prefix))
        if toolchain_prefix and basetool then
            return toolchain_prefix .. basetool
        end
        print('tool = ', tool, 'basetool = ', basetool)
        return nil
    end)
end

---------------
-- iOS specific

filter { 'options:platform=ios' }
xcodebuildsettings {
            --["CODE_SIGN_IDENTITY[sdk=iphoneos*]"] = "iPhone Developer",
            --IPHONEOS_DEPLOYMENT_TARGET = "10.2",
            SDKROOT = "iphoneos",
            OTHER_LDFLAGS = "-ObjC",
}

if _OPTIONS['platform'] == 'ios' then
--[[
/* Begin XCBuildConfiguration section */
C20C96B51EC86B9100D730E8 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
SDKROOT = iphoneos;
         }

OTHER_LDFLAGS = "-ObjC";

--]]
end

------------------
-- Common

filter {}

project 'my_lib'
kind 'StaticLib'
language 'C'
files { '*.h', '*.c' }

filter { 'configurations:debug' }
defines { 'DEBUG' }
-- flags { 'Symbols' }
symbols 'On'

filter { 'configurations:release' }
defines { 'NDEBUG' }
optimize 'On'


No comments: