Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, name):
import ninja
if not os.path.exists(BUILD_DIR):
os.mkdir(BUILD_DIR)
self.ninja_program = os.path.join(ninja.BIN_DIR, 'ninja')
self.name = name
self.filename = os.path.join(BUILD_DIR, 'build.{}.ninja'.format(name))
self.writer = ninja.Writer(open(self.filename, 'w'))
self.writer.rule('do_cmd', '$cmd')
self.writer.rule('compile', '$cmd')
self.compdb_targets = []
def build (self):
yield
self.writer.close()
ninja_program = Path(ninja.BIN_DIR) / 'ninja'
env = os.environ
if not self.is_posix:
# Add vcvarsall.bat to execution
from distutils._msvccompiler import PLAT_TO_VCVARS, _get_vc_env
from distutils.util import get_platform
env = _get_vc_env(PLAT_TO_VCVARS[get_platform()])
cmd = [str(ninja_program), '-f', str(self.writer.path)]
import sys
process = subprocess.Popen(cmd,
env=env,
universal_newlines=True,
stdout=sys.stdout, #subprocess.PIPE,
stderr=sys.stderr)#subprocess.PIPE)
out, err = process.communicate()
if process.returncode != 0:
raise subprocess.CalledProcessError(
def __init__(self, name):
import ninja
if not os.path.exists(BUILD_DIR):
os.mkdir(BUILD_DIR)
self.ninja_program = os.path.join(ninja.BIN_DIR, 'ninja')
self.name = name
self.filename = os.path.join(BUILD_DIR, 'build.{}.ninja'.format(name))
self.writer = ninja.Writer(open(self.filename, 'w'))
self.writer.rule('do_cmd', '$cmd')
self.writer.rule('compile', '$cmd')
self.compdb_targets = []
def ninja_path (): return Path(ninja.BIN_DIR)