This Gist contains a bunch of Craftfiles to compile various libraries.
Last active
July 8, 2016 00:15
-
-
Save NiklasRosenstein/9e32d94f12a47b0e2ac70787a59871ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Craftfile to compile libcURL. | |
# Currently only tested on Windows. | |
from craftr import * | |
from craftr.ext import platform, rules | |
staticbuild = options.get_bool('staticbuild', False) | |
compile_examples = options.get_bool('compile_examples', False) | |
libcurl = Framework( | |
include = [path.local('include')], | |
defines = ['CURL_STATICLIB'] if staticbuild else [], | |
msvc_libs = ['ws2_32', 'winmm', 'Wldap32'] | |
) | |
objects = platform.cc.compile( | |
sources = path.glob('src/*.c', 'lib/**/*.c'), | |
include = [path.local('lib')], | |
defines = ['BUILDING_LIBCURL'], | |
frameworks = [libcurl] | |
) | |
if staticbuild: | |
lib = platform.ar.staticlib( | |
inputs = objects, | |
output = 'cURL' | |
) | |
else: | |
lib = platform.ld.link( | |
inputs = objects, | |
output = 'cURL', | |
output_type = 'dll' | |
) | |
libcurl['external_libs'] = [lib.meta['link_target']] | |
if compile_examples: | |
for fname in path.glob('docs/examples/*.c'): | |
target_name = path.basename(path.rmvsuffix(fname)) | |
target = platform.ld.link( | |
inputs = platform.cc.compile( | |
sources = [fname], | |
frameworks = [libcurl], | |
target_name = target_name + '_compile' | |
), | |
output = target_name, | |
target_name = target_name + '_bin' | |
) | |
rules.run(target, target_name = target_name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Craftfile to compile SDL v1. | |
# Currently only tested on Windows. | |
from craftr import * | |
from craftr.ext import platform | |
sources = path.glob( | |
'src/*.c', | |
'src/audio/*.c', | |
'src/cdrom/*.c', | |
'src/cpuinfo/*.c', | |
'src/events/*.c', | |
'src/file/*.c', | |
'src/joystick/*.c', | |
'src/stdlib/*.c', | |
'src/thread/*.c', | |
'src/timer/*.c', | |
'src/video/*.c', | |
'src/audio/dummy/*.c', | |
'src/video/dummy/*.c', | |
'src/joystick/dummy/*.c', | |
'src/cdrom/dummy/*.c', | |
'src/thread/generic/*.c', | |
'src/timer/dummy/*.c', | |
'src/loadso/dummy/*.c', | |
) | |
include = path.local(['include']) | |
defines = [] | |
libs = [] | |
if platform.name == platform.WIN32: | |
sources += path.glob( | |
'src/audio/disk/*.c', | |
'src/audio/windx5/*.c', | |
'src/audio/windib/*.c', | |
'src/cdrom/win32/*.c', | |
'src/joystick/win32/*.c', | |
'src/timer/win32/*.c', | |
'src/video/windib/*.c', | |
'src/video/windx5/*.c', | |
'src/video/wincommon/*.c', | |
) | |
defines += [ | |
'_CRT_SECURE_NO_DEPRECATE', '_WINDOWS', '_WIN32', | |
'__WIN32__', '_WIN32_WINNT=0x0400', 'NDEBUG', | |
] | |
libs += ['winmm', 'dxguid', 'User32', 'Gdi32'] | |
obj = platform.cc.compile( | |
sources = sources, | |
include = include, | |
defines = defines, | |
) | |
lib = platform.ar.staticlib( | |
inputs = obj, | |
output = 'SDL', | |
) | |
dll = platform.ld.link( | |
inputs = obj, | |
output = 'SDL', | |
output_type = 'dll', | |
libs = libs, | |
) | |
fw = Framework( | |
include = include, | |
libs = libs, | |
external_libs = [dll.meta['link_target']], | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment