Created
July 9, 2016 17:52
-
-
Save NiklasRosenstein/a200ec682abbbbf3215ec614eb4aede7 to your computer and use it in GitHub Desktop.
LOL, this is what Craftr could've been. Luckily it's not. https://github.com/craftr-build/craftr
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
# Copyright (c) 2014, Niklas Rosenstein | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in | |
# all copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
# THE SOFTWARE. | |
from beak.targets import IOTarget, FileTarget | |
pl = load('beak/platform.py').current | |
c4d_api = load('c4d-api/build.py') | |
plugin_name = basename(env.dirname) | |
def on_setup(session): | |
c4d = session.get_data(c4d_api) | |
data = Attributor() | |
data.sources = localglob('src/*.cpp', 'src/*/*.cpp', 'src/*/*/*.cpp') | |
data.compiler = c4d.compiler.copy() | |
data.compiler.add_include(*map(localpath, ('include', 'res'))) | |
data.linker = c4d.linker.copy() | |
data.linker.link_with(c4d.libname) | |
data.builddir = localpath(joinpath('build', c4d.mode, c4d.arch)) | |
data.objdir = joinpath(data.builddir, 'obj') | |
data.libname = localpath(c4d.gen_libname(plugin_name)) | |
return data | |
@env.register_target | |
class Objects(IOTarget): | |
def get_inputs(self, data): | |
return data.sources | |
def get_output(self, data, fin): | |
return pl.objname(chdir(fin, data.objdir)) | |
def build_file(self, data, fin, fout): | |
data.compiler.compile(fout, [fin]) | |
@env.register_target | |
class Library(FileTarget): | |
dependencies = [Objects, c4d_api.Library] | |
def get_inputs(self, data): | |
return self.dependencies[0].outputs | |
def get_output(self, data): | |
return data.libname | |
def build_file(self, data, inputs, libname): | |
data.linker.compile(libname, inputs) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment