Exemple #1
0
def configure_distcc(cfg, cmake):
    global ENV
    with log.info('Configuring distcc...'):
        if not cfg.get('env.distcc.enabled', False):
            log.info('distcc disabled, skipping.')
            return
        distcc_hosts = []
        english_hosts = []
        maxjobs = 0
        canpump = False
        for hostname, hostcfg in cfg['env']['distcc']['hosts'].items():
            h = hostname
            info_e = []
            if 'max-jobs' in hostcfg:
                njobs = hostcfg.get('max-jobs', 0)
                if njobs > 0:
                    h += '/' + str(njobs)
                    info_e += ['{} max jobs'.format(njobs)]
                    maxjobs += njobs
            if 'opts' in hostcfg:
                h += ',' + ','.join(hostcfg['opts'])
                info_e += [
                    'with options: ({})'.format(', '.join(hostcfg['opts']))
                ]
                # Check for lzo & cpp before permitting distcc-pump.
                if 'lzo' in hostcfg['opts'] and 'cpp' in hostcfg['opts']:
                    canpump = True
            if len(info_e) > 0:
                english_hosts += [
                    '* {}: {}'.format(hostname, ', '.join(info_e))
                ]

            distcc_hosts += [h]
        if len(distcc_hosts) > 0:
            with log.info('Compiling with {} hosts:'.format(
                    len(distcc_hosts))):
                for hostline in english_hosts:
                    log.info(hostline)
            log.info('Max jobs    : {0}'.format(maxjobs))
            cfg['env']['make']['jobs'] = maxjobs

            pump_enabled = maxjobs > 0 and canpump and cfg.get(
                'env.distcc.pump.enabled', False)
            with log.info('Pump enabled: {0}'.format(bool2yn(pump_enabled))):
                if pump_enabled:
                    pump = cfg.get('bin.pump', which('distcc-pump'))
                    make = cfg.get('bin.make', which('make'))
                    cfg['bin']['make'] = '{pump} {make}'.format(pump=pump,
                                                                make=make)
                    log.info('DistCC Pump : ' + pump)
                    log.info('Make        : ' + make)

            ENV.set('DISTCC_HOSTS', ' '.join(distcc_hosts))
            #if not cfg.get('env.ccache.enabled', False):
            DISTCC = cfg.get('bin.distcc', which('distcc'))

            ENV.set('CC', DISTCC + ' ' + ENV.get('CC', 'gcc'))
            ENV.set('CXX', DISTCC + ' ' + ENV.get('CXX', 'g++'))
Exemple #2
0
 def build(self):
     with os_utils.Chdir(os.path.join(self.base_path)):
         os_utils.cmd([os_utils.which('yarn')],
                      echo=True,
                      show_output=True,
                      critical=True)
         os_utils.cmd([os_utils.which('grunt'), 'requirejs', 'uglify:main'],
                      echo=True,
                      show_output=True,
                      critical=True)
Exemple #3
0
    def __init__(self,
                 invocation,
                 base_command=None,
                 working_dir='.',
                 opts=[],
                 files=[],
                 target=None,
                 dependencies=[],
                 exe_path=None,
                 specfile=None,
                 lockfile=None,
                 modules_dir=None):
        self.specfile = specfile
        self.lockfile = lockfile

        self.working_dir = working_dir
        self.opts = opts
        self.exe_path = exe_path
        self.base_command = base_command
        self.invocation = invocation

        self.modules_dir = modules_dir

        if self.exe_path is None:
            self.exe_path = os_utils.which(invocation)
        super().__init__(target=target, files=files, dependencies=dependencies)
Exemple #4
0
 def __init__(self,
              target=None,
              files=[],
              dependencies=[],
              import_paths=[],
              output_style='expanded',
              sass_path=None,
              imported=[],
              source_map=None):
     self.source_map = source_map
     if self.source_map is None:
         self.source_map = output_style == 'expanded'
     if sass_path is None:
         sass_path = os_utils.which('sass')
         if sass_path is None:
             log.warn(
                 'Unable to find sass on this OS.  Is it in PATH?  Remember to run `npm install -g sass`!'
             )
     super().__init__(target,
                      files,
                      dependencies,
                      import_paths=import_paths,
                      output_style=output_style,
                      sass_path=sass_path,
                      imported=imported)
 def __init__(self, target=None, files=[], dependencies=[], j2coffee_opts=['-i', '2'], js2coffee_path=None):
     if js2coffee_path is None:
         js2coffee_path = os_utils.which('js2coffee')
         if js2coffee_path is None:
             log.warn('Unable to find coffee on this OS.  Is it in PATH?  Remember to run `gem install -g js2coffee`!')
     self.js2coffee_path = js2coffee_path
     super(JS2CoffeeBuildTarget, self).__init__(target, files, [os.path.abspath(__file__)]+dependencies)
     self.js2coffee_opts = j2coffee_opts
    def __init__(self, target=None, files=[], dependencies=[], coffee_opts=['--no-header','-bc'], coffee_executable=None, make_map=False, coffee_concat_executable=None):
        if coffee_executable is None:
            coffee_executable = os_utils.which('coffee')
        if coffee_executable is None:
            log.warn('Unable to find coffee on this OS.  Is it in PATH?  Remember to run `gem install -g coffee-script`!')

        if coffee_concat_executable is None:
            coffee_concat_executable = os_utils.which('coffee-concat')
        if coffee_concat_executable is None:
            log.warn('Unable to find coffee-concat on this OS.  Is it in PATH? Remember to run `yarn global add coffee-concat`!')

        self.coffee_executable = coffee_executable
        self.coffee_concat_executable = coffee_concat_executable
        if make_map:
            coffee_opts += ['-M']
        super(CoffeeBuildTarget, self).__init__(target, files, dependencies)
        self.coffee_opts=coffee_opts
Exemple #7
0
def main():
    argp = argparse.ArgumentParser()
    argp.add_argument('--go', action='store_true')
    args = argp.parse_args()

    files_to_proc = []
    for root, _, files in os.walk(IN_DIR):
        for bfn in files:
            fullpath = os.path.abspath(os.path.join(root, bfn))
            if bfn.endswith('.bak'):
                log.info('rm %s', fullpath)
                os.remove(fullpath)
            if bfn.endswith('.php'):
                files_to_proc += [fullpath]

    for filename in tqdm.tqdm(files_to_proc, desc='Moving files...', unit='file'):
        namespace = None
        outpath = None
        with open(filename, 'r') as f:
            for line in f:
                m = re.match(REG_NS, line)
                if m is not None:
                    namespace = m.group(1)
                    break
        if namespace is None:
            continue
        nschunks = namespace.split('\\')
        if nschunks[0] == '':
            nschunks = nschunks[1:]
        nschunks = nschunks[1:]

        nschunks += [os.path.basename(filename).replace('.class', '').replace('.interface','')]
        outpath = os.path.abspath(os.path.join(OUT_DIR, *nschunks))
        if outpath == filename:
            continue

        cmd = [os_utils.which('git'), 'mv', os.path.relpath(filename), os.path.relpath(outpath)]
        if args.go:
            os_utils.ensureDirExists(os.path.dirname(outpath), noisy=True)
            os_utils.cmd([os_utils.which('git'), 'add', os.path.relpath(filename)], echo=True, show_output=True)
            os_utils.cmd(cmd, echo=True, critical=True)
        else:
            log.info(' '.join(cmd))
    os_utils.del_empty_dirs(IN_DIR, quiet=False)
Exemple #8
0
 def __init__(self,
              target,
              inputfiles,
              dependencies=[],
              convert_executable=None):
     self.convert_executable = convert_executable
     if self.convert_executable is None:
         self.convert_executable = os_utils.which('convert')
     super(ICOBuildTarget, self).__init__(target,
                                          files=inputfiles,
                                          dependencies=dependencies)
Exemple #9
0
 def __init__(self,
              target=None,
              files=[],
              dependencies=[],
              sass_convert_path=None):
     super(SCSSConvertTarget, self).__init__(target, files, dependencies)
     if sass_convert_path is None:
         sass_convert_path = os_utils.which('sass-convert')
         if sass_convert_path is None:
             log.warn(
                 'Unable to find sass-convert on this OS.  Is it in PATH?  Remember to run `gem install sass compass`!'
             )
     self.sass_convert_path = sass_convert_path
Exemple #10
0
    def __init__(self,
                 target,
                 inputfile,
                 height,
                 width,
                 dependencies=[],
                 inkscape=None):
        self.height = height
        self.width = width

        self.inkscape = inkscape
        if self.inkscape is None:
            # Last-ditch for Windows.
            self.inkscape = os_utils.which(
                'inkscape') or 'C:\\Program Files\\Inkscape\\inkscape.exe'

        super(SVG2PNGBuildTarget, self).__init__(target,
                                                 files=[inputfile],
                                                 dependencies=dependencies)
Exemple #11
0
 def __init__(self,
              sources,
              destination,
              rsync_executable=None,
              progress=False,
              delete=False,
              opts=['-Rruhavp'],
              chmod=0o755,
              chown=None,
              chgrp=None,
              show_output=False,
              dependencies=[],
              provides=[],
              name='rsync',
              keyfile=None):
     self.rsync_executable = rsync_executable or os_utils.which('rsync')
     self.opts = opts
     self.progress = progress
     self.chmod = chmod
     self.chown = chown
     self.chgrp = chgrp
     self.show_output = show_output
     self.progress = progress
     self.sources = sources
     self.delete = delete
     self.destination = destination
     self.keyfile = keyfile
     files = []
     for source in sources:
         with log.info('Scanning %s...', source):
             if os.path.isdir(source):
                 files += os_utils.get_file_list(source)
             if os.path.isfile(source):
                 files += [source]
     super().__init__(target=str(
         Path('.build',
              hashlib.sha256(self.name).hexdigest() + '.target')),
                      files=files,
                      dependencies=dependencies,
                      provides=provides,
                      name=name)
Exemple #12
0
    def __init__(self,
                 target,
                 source,
                 dependencies=[],
                 svgo_opts=['-q'],
                 svgo_executable=None):
        self.source = source
        self.svgo_opts = svgo_opts
        self.svgo_cmd = os_utils.which('svgo')
        if svgo_executable is not None:
            self.svgo_cmd = svgo_executable
        if self.svgo_cmd is None:
            log.warn(
                'Unable to find svgo on this OS.  Is it in PATH?  Remember to run `npm install -g svgo`!'
            )

        super(MinifySVGTarget,
              self).__init__(target,
                             dependencies=dependencies,
                             files=[self.source,
                                    os.path.abspath(__file__)])
Exemple #13
0
 def __init__(self,
              sources,
              destination,
              rsync_executable=None,
              progress=False,
              delete=False,
              opts=['-Rruavp'],
              chmod=0o755,
              chown=None,
              chgrp=None,
              show_output=False,
              dependencies=[],
              provides=[],
              name='rsync',
              keyfile=None):
     self.rsync_executable = rsync_executable or os_utils.which('rsync')
     self.opts = opts
     self.progress = progress
     self.chmod = chmod
     self.chown = chown
     self.chgrp = chgrp
     self.show_output = show_output
     self.progress = progress
     self.sources = sources
     self.delete = delete
     self.destination = destination
     self.keyfile = keyfile
     files = []
     for source in sources:
         with log.info('Scanning %s...', source):
             if os.path.isdir(source):
                 files += os_utils.get_file_list(source)
             if os.path.isfile(source):
                 files += [source]
     super().__init__(target=self.genVirtualTarget(
         name.replace('\\', '_').replace('/', '_')),
                      files=files,
                      dependencies=dependencies,
                      provides=provides,
                      name=name)
Exemple #14
0
 def __init__(self,
              target=None,
              files=[],
              dependencies=[],
              compass=False,
              import_paths=[],
              output_style='compact',
              sass_path=None,
              imported=[]):
     if sass_path is None:
         sass_path = os_utils.which('sass')
         if sass_path is None:
             log.warn(
                 'Unable to find sass on this OS.  Is it in PATH?  Remember to run `gem install sass compass`!'
             )
     super().__init__(target,
                      files,
                      dependencies,
                      import_paths=import_paths,
                      output_style=output_style,
                      sass_path=sass_path,
                      imported=imported)
     self.compass = compass
Exemple #15
0
    def __init__(self,
                 target,
                 inputfile,
                 dependencies=[],
                 compress=True,
                 mangle=True,
                 options=[],
                 compress_opts=[],
                 mangle_opts=[],
                 uglify_executable=None):
        self.uglifyjs_executable = uglify_executable
        if self.uglifyjs_executable is None:
            self.uglifyjs_executable = os_utils.which('uglifyjs')

        self.options = []
        if compress:
            self.options += ['-c'] + compress_opts
        if mangle:
            self.options += ['-m'] + mangle_opts

        self.options += options
        super(UglifyJSTarget, self).__init__(target,
                                             files=[inputfile],
                                             dependencies=dependencies)
    "vc_version": "14.0",
    "build-type": "RelWithDebInfo",
    "ide_projects": True,
    "offline": False,  # if set, non-mandatory network requests won't be made.
    # This is stuff like updating source repositories. The initial
    # download of course can't be surpressed.
    "prefer_binary_dependencies": False,  # currently non-functional
    "optimize": False,  # activate link-time code generation and other optimization.
    # This massively increases build time but produces smaller
    # binaries and marginally faster code
    "repo_update_frequency": 60 * 60 * 24,  # in seconds
}
userconfig = {
    "paths": {
        "executables": {
            "7za": os_utils.which("7z.exe"),
            "cmake": os_utils.which("cmake.exe"),
            "git": os_utils.which("git.exe"),
            "graphviz": "C:\\Program Files (x86)\\Graphviz2.38\\bin\\dot.exe",  # Default Graphviz2 install
            "hg": os_utils.which("hg.exe"),
            "perl": "C:\\Perl64\\bin\\perl.exe",  # ActiveState
            "python": os_utils.which("python.exe"),
            "ruby": os_utils.which("ruby.exe"),
            "svn": os_utils.which("svn.exe"),
        },
        "qt-base": "C:\\Qt\\Qt5.5.1\\5.5\\msvc2013_64",  # Not used. Yet.
    },
    "build": {"job-count": multiprocessing.cpu_count() * 2},
}

config = YAMLConfig("build.yml", config, variables={"nbits": "32"})
Exemple #17
0
def _which_if_basename(subject):
    if '/' in subject or ' ' in subject: return subject
    return which(subject)
import argparse, os
from buildtools import os_utils

argp = argparse.ArgumentParser()
argp.add_argument('--voice', '-V', choices=['fem','mas'], default='mas')
argp.add_argument('words', nargs='+', help='The words you wish to play.')
args = argp.parse_args()
cmd=[os_utils.which('play')]
cmd += [os.path.join('dist', 'sound', f'vox_{args.voice}', w.strip()+'.ogg') for w in args.words]
os_utils.cmd(cmd,echo=True,show_output=True, globbify=False)
Exemple #19
0
 def build(self):
     with os_utils.Chdir(os.path.join(self.base_path)):
         os_utils.cmd([os_utils.which('npm'), 'install'], echo=True, show_output=True, critical=True)
         os_utils.cmd([os_utils.which('grunt'), 'requirejs', 'uglify:main'], echo=True, show_output=True, critical=True)
Exemple #20
0
def _which_if_basename(subject):
    if '/' in subject or ' ' in subject: return subject
    return which(subject)
Exemple #21
0
    'ide_projects': True,
    'offline': False,                       # if set, non-mandatory network requests won't be made.
                                            # This is stuff like updating source repositories. The initial
                                            # download of course can't be surpressed.
    'prefer_binary_dependencies': False,    # currently non-functional
    'optimize': False,                      # activate link-time code generation and other optimization.
                                            # This massively increases build time but produces smaller
                                            # binaries and marginally faster code
    'repo_update_frequency': 60 * 60 * 24,  # in seconds
}

config['paths'] = {
    'download':      "{base_dir}\\downloads",
    'build':         "{base_dir}\\build",
    'progress':      "{base_dir}\\progress",
    'graphviz':      os_utils.which('dot.exe'), #path_or_default("dot.exe",   "Graphviz2.38", "bin"),
    'cmake':         os_utils.which('cmake.exe'), #path_or_default("cmake.exe", "CMake", "bin"),
    'git':           os_utils.which('git.exe'), #path_or_default("git.exe",   "Git", "bin"),
    'hg':            os_utils.which('hg.exe'),
    'perl':          os_utils.which('perl.exe'),
    'ruby':          os_utils.which('ruby.exe'),
    'svn':           os_utils.which('svn.exe'),
    '7z':            os_utils.which('7z.exe'),
    # we need a python that matches the build architecture
    'python':        os_utils.which('python27.exe'),
    'visual_studio': os.path.realpath(
        os.path.join(get_from_hklm(r"SOFTWARE\Microsoft\VisualStudio\{}".format(config['vc_version']),
                                   "InstallDir", True),
                     "..", "..", "VC"
                     )
    )