Skip to content

Instantly share code, notes, and snippets.

@dimitarcl
Last active December 11, 2015 07:28
Show Gist options
  • Save dimitarcl/4566204 to your computer and use it in GitHub Desktop.
Save dimitarcl/4566204 to your computer and use it in GitHub Desktop.
Converting a gyp library to premake
solution 'node-lame'
project 'bindings'
includedirs {
'deps/lame/include',
'deps/mpg123/src/libmpg123',
'deps/mpg123/%{GetConfigInclude(cfg)}',
}
include 'deps/lame'
include 'deps/mpg123'
function GetConfigInclude(cfg)
local arch = cfg.architecture
local system = cfg.system
if arch == 'x32' or arch == 'Win32' then
arch = 'ia32'
end
if system == 'windows' then
system = 'win'
end
return string.format('config/%s/%s', system, arch)
end
'target_defaults': {
'default_configuration': 'Debug',
'configurations': {
'Debug': {
'defines': [ 'DEBUG', '_DEBUG' ],
'msvs_settings': {
'VCCLCompilerTool': {
'RuntimeLibrary': 1, # static debug
},
},
},
'Release': {
'defines': [ 'NDEBUG' ],
'msvs_settings': {
'VCCLCompilerTool': {
'RuntimeLibrary': 0, # static release
},
},
}
},
'msvs_settings': {
'VCLinkerTool': {
'GenerateDebugInformation': 'true',
},
},
'conditions': [
['OS=="mac"', {
'conditions': [
['target_arch=="ia32"', { 'xcode_settings': { 'ARCHS': [ 'i386' ] } }],
['target_arch=="x64"', { 'xcode_settings': { 'ARCHS': [ 'x86_64' ] } }]
],
}],
]
},
project 'mpg123'
kind 'StaticLib'
language 'C'
defines {
'HAVE_CONFIG_H',
'PIC',
'NOXFERMEM',
}
includedirs { '%{GetConfigInclude(cfg)}' }
files {
'src/libmpg123/compat.c',
-- all the source files
'src/libmpg123/feature.c',
}
local notOptimizedDefines = {
'OPT_I386',
'REAL_IS_FLOAT',
'NEWOLD_WRITE_SAMPLE',
}
local notOptmizedSynthFiles = {
'src/libmpg123/synth_s32.c',
'src/libmpg123/synth_real.c',
'src/libmpg123/dct64_i386.c',
}
configuration 'x32'
defines(notOptimizedDefines)
files(notOptmizedSynthFiles)
configuration { 'windows', 'x64' }
defines(notOptimizedDefines)
files(notOptmizedSynthFiles)
configuration 'x64'
defines {
'OPT_X86_64',
'REAL_IS_FLOAT',
}
files {
'src/libmpg123/dct64_x86_64.S',
-- more assembler files
'src/libmpg123/synth_x86_64_float.S',
}
solution 'node-lame'
configurations { 'Debug', 'Release' }
if os.is('windows') then
platforms { 'Win32', 'x64' }
else
platforms { 'x32', 'x64' }
end
flags {
'StaticRuntime',
'Symbols'
}
configuration 'Debug'
defines { 'DEBUG', '_DEBUG' }
configuration 'Release'
defines { 'NDEBUG' }
project 'mp3lame'
kind 'StaticLib'
language 'C'
defines { 'HAVE_CONFIG_H' }
includedirs { '%{GetConfigInclude(cfg)}' }
includedirs {
'include',
'mpglib',
'libmp3lame',
}
files {
'libmp3lame/*.c',
'libmp3lame/*.h',
}
vpaths {
['Source Files'] = '*.c',
['Header Files'] = '*.h',
}
newoption {
trigger = 'node',
description = 'node source directory',
value = 'path to nodejs source directory',
}
local node = _OPTIONS['node']
if not node then
error('Missing node source directory. Use --node=path-to-node.')
end
solution 'node-lame'
project 'bindings'
kind 'SharedLib'
language 'C++'
files {
'src/*.cc',
'src/*.h',
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment