blob: 5400a1d560cda552b8d46f326b07ae121e872cb3 [file] [log] [blame]
# Copyright (c) 2017 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Starboard's abstract Toolchain which is implemented for each platform."""
import abc
import imp
import logging
import os
import starboard
from starboard.tools import paths
from starboard.tools import platform
class ABCMetaSingleton(abc.ABCMeta):
instances = {}
def __call__(self, *args, **kwargs):
if self not in self.instances:
self.instances[self] = super(ABCMetaSingleton, self).__call__(
*args, **kwargs)
return self.instances[self]
class Toolchain(object):
"""This is an abstract interface of the Toolchain."""
""" TODO: move variables / commands
AR / _HOST
ARFLAGS / _HOST
ARTHINFLAGS / _HOST
CC / CC_HOST
CXX / CXX_HOST
LD / LD_HOST
RC / RC_HOST
And / or implement NinjaWriter.WriteSources & GenerateOutputForConfig body
here.
"""
__metaclass__ = ABCMetaSingleton
@abc.abstractmethod
def Define(self, d):
pass
@abc.abstractmethod
def EncodeRspFileList(self, args):
pass
@abc.abstractmethod
def ExpandEnvVars(self, path, env):
pass
@abc.abstractmethod
def ExpandRuleVariables(self, path, root, dirname, source, ext, name):
pass
@abc.abstractmethod
def GenerateEnvironmentFiles(self, toplevel_build_dir, generator_flags,
open_out):
pass
@abc.abstractmethod
def GetCompilerSettings(self):
pass
@abc.abstractmethod
def GetPrecompiledHeader(self, **kwargs):
pass
@abc.abstractmethod
def InitCompilerSettings(self, spec, **kwargs):
pass
@abc.abstractmethod
def SetAdditionalGypVariables(self, default_variables, **kwargs):
pass
@abc.abstractmethod
def VerifyMissingSources(self, sources, **kwargs):
pass
@abc.abstractmethod
def QuoteForRspFile(self, arg):
pass
class PrecompiledHeader:
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __init__(self):
pass
@abc.abstractmethod
def GetFlagsModifications(self, input_flags, output, implicit, command,
cflags_c, cflags_cc, expand_special):
pass
@abc.abstractmethod
def GetPchBuildCommands(self):
pass
@abc.abstractmethod
def GetInclude(self):
pass
@abc.abstractmethod
def GetObjDependencies(self, sources, output):
pass
class CompilerSettings:
"""Abstract Compiler Settings class."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __init__(self):
pass
@abc.abstractmethod
def GetArch(self, config):
pass
@abc.abstractmethod
def GetCflags(self, config):
pass
@abc.abstractmethod
def GetCflagsC(self, config):
pass
@abc.abstractmethod
def GetCflagsCC(self, config):
pass
@abc.abstractmethod
def GetCflagsObjectiveC(self, config):
pass
@abc.abstractmethod
def GetCflagsObjectiveCC(self, config):
pass
@abc.abstractmethod
def GetDefines(self, config):
pass
@abc.abstractmethod
def GetLdFlags(self, config, **kwargs):
pass
@abc.abstractmethod
def GetLibFlags(self, config, gyp_path_to_ninja):
pass
@abc.abstractmethod
def GetRcFlags(self, config, gyp_path_to_ninja):
pass
@abc.abstractmethod
def ProcessIncludeDirs(self, include_dirs, config_name):
pass
@abc.abstractmethod
def ProcessLibraries(self, libraries, config_name):
pass