Last active
August 29, 2015 13:56
-
-
Save SteelPangolin/8840105 to your computer and use it in GitHub Desktop.
This file contains 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
""" | |
Decorate SCons Environment constructor so that Homebrew paths are always included. | |
""" | |
from functools import wraps | |
import SCons.Environment | |
# Homebrew install directory | |
homebrew = '/opt/homebrew' | |
flag_prepends = [ | |
('CFLAGS', '-I{}/include'.format(homebrew)), | |
('CXXFLAGS', '-I{}/include'.format(homebrew)), | |
('LDFLAGS', '-L{}/lib' .format(homebrew)), | |
] | |
def add_homebrew_vars(environment_init): | |
@wraps(environment_init) | |
def wrapper(self, *args, **kwargs): | |
for var, flag in flag_prepends: | |
flags_list = [flag] | |
if var in kwargs: | |
flags_list.append(kwargs[var]) | |
kwargs[var] = ' '.join(flags_list) | |
environment_init(self, *args, **kwargs) | |
self.PrependENVPath('PATH', '{}/bin'.format(homebrew)) | |
return wrapper | |
SCons.Environment.Environment.__init__ = add_homebrew_vars(SCons.Environment.Environment.__init__) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment