示例#1
0
os.chdir(os.path.dirname(os.path.abspath(__file__)))

parser = OptionParser()

parser.add_option("--verbose", action="store_true", help="enable verbose build")
parser.add_option("--x64", action="store_true", help="force 64-bit build (Windows)")
# TODO: make this --platform to match configure.py.
parser.add_option(
    "--platform",
    help="target platform (" + "/".join(platformHelper.platforms()) + ")",
    choices=platformHelper.platforms(),
)
(options, conf_args) = parser.parse_args()


platform = platformHelper.platform(options.platform)


def run(*args, **kwargs):
    returncode = subprocess.call(*args, **kwargs)
    if returncode != 0:
        sys.exit(returncode)


# Compute system-specific CFLAGS/LDFLAGS as used in both in the below
# g++ call as well as in the later configure.py.
cflags = os.environ.get("CFLAGS", "").split()
ldflags = os.environ.get("LDFLAGS", "").split()
if platform.isFreebsd():
    cflags.append("-I/usr/local/include")
    ldflags.append("-L/usr/local/lib")
示例#2
0
parser.add_option('--debug', action='store_true',
                  help='enable debugging extras',)
parser.add_option('--profile', metavar='TYPE',
                  choices=profilers,
                  help='enable profiling (' + '/'.join(profilers) + ')',)
parser.add_option('--with-gtest', metavar='PATH',
                  help='use gtest unpacked in directory PATH')
parser.add_option('--with-python', metavar='EXE',
                  help='use EXE as the Python interpreter',
                  default=os.path.basename(sys.executable))
(options, args) = parser.parse_args()
if args:
    print('ERROR: extra unparsed command-line arguments:', args)
    sys.exit(1)

platform = platformHelper.platform(options.platform)
if options.host:
    host = platformHelper.platform(options.host)
else:
    host = platform

BUILD_FILENAME = 'build.ninja'
buildfile = open(BUILD_FILENAME, 'w')
n = ninja_syntax.Writer(buildfile)
n.comment('This file is used to build ninja itself.')
n.comment('It is generated by ' + os.path.basename(__file__) + '.')
n.newline()

n.comment('The arguments passed to configure.py, for rerunning it.')
n.variable('configure_args', ' '.join(sys.argv[1:]))
env_keys = set(['CXX', 'AR', 'CFLAGS', 'LDFLAGS'])