<commit_before>#!/usr/bin/env python
"""
simple example script for running and testing notebooks.

Forked from shoyer / ipnbdoctest.py (https://gist.github.com/shoyer/7497853),
who has forked from the original author minrk/ipnbdoctest.py (https://gist.github.com/minrk/2620735)

Usage: `ipnbdoctest.py foo.ipynb [bar.ipynb [...]]`

Each cell is submitted to the kernel, and the outputs are compared with those stored in the notebook.
"""

import os,sys,time
import base64
import hashlib
import traceback
import png
import random
import re
import argparse

from collections import defaultdict
from Queue import Empty
from cStringIO import StringIO

import numpy as np

try:
    from IPython.kernel import KernelManager
except ImportError:
    from IPython.zmq.blockingkernelmanager import BlockingKernelManager as KernelManager

from IPython.nbformat.current import reads, NotebookNode

PNG_DIFF_TOLERANCE = 1e-2

def png_b64_to_ndarray(a64):
    """convert PNG output into a np.ndarray using pypng"""
    pngdata = png.Reader(StringIO(base64.decodestring(a64))).asRGBA8()[2]
    return np.array(list(pngdata))

def print_base64_img(data):
    s = StringIO()
    png.from_array(data, mode='RGBA;8').save(s)
    contents = s.getvalue()
    s.close()
    base64_image = base64.b64encode(contents)

    print ''.format(base64_image)

def diff_png(a64, b64, generate_diff_images=True):
    """compare the pixels of two PNGs"""
    a_data, b_data = map(png_b64_to_ndarray, (a64, b64))
    if a_data.shape != b_data.shape:
        diff = 255
    else:
        diff = np.mean(np.abs(a_data - b_data))
    diff /= 255.0
    if diff > PNG_DIFF_TOLERANCE:
        digest = hashlib.sha1(a64).digest()
        if generate_diff_images:
            if not os.path.exists('.diffs/'):
                os.mkdir('.diffs/')
            prefix = '.diffs/ipnbdoctest-%s-' % base64.urlsafe_b64encode(digest)[:4]
            print 'Images mismatch'
            print 'Expected:'
            print_base64_img(a_data)
            print 'Actual:'
            print_base64_img(b_data)
            if diff < 1:
                print 'Diff:'
                print_base64_img(255 - np.abs(b_data - a_data))

    return diff

def sanitize(s):
    """sanitize a string for comparison.

    fix universal newlines, strip trailing newlines, and normalize likely random values (memory addresses and UUIDs)
    """
    if not isinstance(s, basestring):
        return s
    # normalize newline:
    s = s.replace('\r\n', '\n')

    # ignore trailing newlines (but not space)
    s = s.rstrip('\n')

    # normalize hex addresses:
    s = re.sub(r'0x[a-f0-9]+', '0xFFFFFFFF', s)

    # normalize UUIDs:
    s = re.sub(r'[a-f0-9]{8}(\-[a-f0-9]{4}){3}\-[a-f0-9]{12}', 'U-U-I-D', s)

    # ignore outputs of %time and %timeit magics:
    s = re.sub(r'(CPU times|Wall time|\d+ loops, best of).+', 'TIMING', s)

    # Ignore the %%cache magic output
    s = re.sub(r'Skipped the cell\'s code and loaded variables problems from file.+', 'CACHING', s)

    return s

def consolidate_outputs(outputs):
    """consolidate outputs into a summary dict (incomplete)"""
    data = defaultdict(list)
    data['stdout'] = ''
    data['stderr'] = ''

    for out in outputs:
        if out.type == 'stream':
            data[out.stream] += out.text
        elif out.type == 'pyerr':
            data['pyerr'] = dict(ename=out.ename, evalue=out.evalue)
        else:
            for key in ('png', 'svg', 'latex', 'html', 'javascript', 'text', 'jpeg',):
                if key in out:
                    data[key].append(out[key])
    return data

def compare_outputs(test, ref,
                    skip_compare=('traceback', 'latex', 'prompt_number'),
                    generate_png_diffs=True):
    for key in ref:
        if key not in test:
            print "missing key: %s != %s" % (test.keys(), ref.keys())
            return False
        elif key == 'png':
            diff = diff_png(test[key], ref[key],
                            generate_diff_images=generate_png_diffs)
            if diff > PNG_DIFF_TOLERANCE:
                print "png mismatch %s" % key
                print "%2.6f%% disagree" % diff
                return False
        elif key not in skip_compare and sanitize(test[key]) != sanitize(ref[key]):
            print "mismatch %s:" % key
            print test[key]
            print '  !=  '
            print ref[key]
            return False
    return True

def run_cell(shell, iopub, cell):
    # print cell.input
    shell.execute(cell.input)
    # wait for finish, maximum 10min
    shell.get_msg(timeout=60*10)
    outs = []

    while True:
        try:
            msg = iopub.get_msg(timeout=0.2)
        except Empty:
            break
        msg_type = msg['msg_type']
        if msg_type in ('status', 'pyin'):
            continue
        elif msg_type == 'clear_output':
            outs = []
            continue

        content = msg['content']
        # print msg_type, content
        out = NotebookNode(output_type=msg_type)

        if msg_type == 'stream':
            out.stream = content['name']
            out.text = content['data']
        elif msg_type in ('display_data', 'pyout'):
            out['metadata'] = content['metadata']
            for mime, data in content['data'].iteritems():
                attr = mime.split('/')[-1].lower()
                # this gets most right, but fix svg+html, plain
                attr = attr.replace('+xml', '').replace('plain', 'text')
                setattr(out, attr, data)
            if msg_type == 'pyout':
                out.prompt_number = content['execution_count']
        elif msg_type == 'pyerr':
            out.ename = content['ename']
            out.evalue = content['evalue']
            out.traceback = content['traceback']
        else:
            print "unhandled iopub msg:", msg_type

        outs.append(out)
    return outs

def collapse_stream_outputs(outputs):
    """
    Collapse the stream outputs returned by ipynb as different buffering
    might change the end result
    """

    stream_outputs = {}
    collapsed_outputs = []
    for output in outputs:
        if output[u'output_type'] == u'stream':
            text = output[u'text']
            try:
                stream_outputs[output[u'stream']].append(text)
            except KeyError:
                stream_outputs[output[u'stream']] = [text]
        else:
            collapsed_outputs.append(output)
    sorted_streams = sorted(stream_outputs.iteritems())
    for stream, stream_texts in sorted_streams:

        collapsed_outputs.append({u"output_type" : u"stream",
                                  u"stream" : stream,
                                  u"text": u''.join(stream_texts)})

    return collapsed_outputs

def test_notebook(nb, generate_png_diffs=True):
    km = KernelManager()
    km.start_kernel(extra_arguments=['--pylab=inline'], stderr=open(os.devnull, 'w'))
    try:
        kc = km.client()
        kc.start_channels()
        iopub = kc.iopub_channel
    except AttributeError:
        # IPython 0.13
        kc = km
        kc.start_channels()
        iopub = kc.sub_channel
    shell = kc.shell_channel

    # run %pylab inline, because some notebooks assume this
    # even though they shouldn't
    shell.execute("pass")
    shell.get_msg()
    while True:
        try:
            iopub.get_msg(timeout=1)
        except Empty:
            break

    successes = 0
    failures = 0
    errors = 0
    for ws in nb.worksheets:
        for cell in ws.cells:
            if cell.cell_type != 'code':
                continue
            try:
                outs = run_cell(shell, iopub, cell)
            except Exception as e:
                print
                print "Failed to run cell, got {0!r}".format(e)
                traceback.print_exc()
                print
                print "The cell is:"
                print '-' * 50
                print cell.input
                print '-' * 50
                errors += 1
                break

            failed = False
            outs = collapse_stream_outputs(outs)
            cell_outputs = collapse_stream_outputs(cell.outputs)
            for out, ref in zip(outs, cell_outputs):
                if not compare_outputs(out, ref, generate_png_diffs=generate_png_diffs):
                    failed = True
            if failed:
                failures += 1
            else:
                successes += 1
            sys.stdout.write('.')

    print
    print "tested notebook %s" % nb.metadata.name
    print "    %3i cells successfully replicated" % successes
    if failures:
        print "    %3i cells mismatched output" % failures
    if errors:
        print "    %3i cells failed to complete" % errors
    kc.stop_channels()
    km.shutdown_kernel()
    del km

    return failures, errors

def arguments_parser():

    parser = argparse.ArgumentParser()
    parser.add_argument('notebooks', nargs='+', type=unicode, help='IPython notebooks to test')
    parser.add_argument('--no-png-output', dest='generate_png_images',
                        action="store_false", default=True,
                        help="Do not generate PNG images")
    return parser

if __name__ == '__main__':
    parser = arguments_parser()
    args = parser.parse_args()
    for ipynb in args.notebooks:
        print "testing %s" % ipynb
        with open(ipynb) as f:
            nb = reads(f.read(), 'json')
        test_notebook(nb, generate_png_diffs=args.generate_png_images)
<commit_msg>added javascript to make the images reappear<commit_after>#!/usr/bin/env python
"""
simple example script for running and testing notebooks.

Forked from shoyer / ipnbdoctest.py (https://gist.github.com/shoyer/7497853),
who has forked from the original author minrk/ipnbdoctest.py (https://gist.github.com/minrk/2620735)

Usage: `ipnbdoctest.py foo.ipynb [bar.ipynb [...]]`

Each cell is submitted to the kernel, and the outputs are compared with those stored in the notebook.
"""

import os,sys,time
import base64
import hashlib
import traceback
import png
import random
import re
import argparse

from collections import defaultdict
from Queue import Empty
from cStringIO import StringIO

import numpy as np

try:
    from IPython.kernel import KernelManager
except ImportError:
    from IPython.zmq.blockingkernelmanager import BlockingKernelManager as KernelManager

from IPython.nbformat.current import reads, NotebookNode

PNG_DIFF_TOLERANCE = 1e-2

def png_b64_to_ndarray(a64):
    """convert PNG output into a np.ndarray using pypng"""
    pngdata = png.Reader(StringIO(base64.decodestring(a64))).asRGBA8()[2]
    return np.array(list(pngdata))

def print_base64_img(data):
    s = StringIO()
    png.from_array(data, mode='RGBA;8').save(s)
    contents = s.getvalue()
    s.close()
    base64_image = base64.b64encode(contents)

    print ''.format(base64_image)

def diff_png(a64, b64, generate_diff_images=True):
    """compare the pixels of two PNGs"""
    a_data, b_data = map(png_b64_to_ndarray, (a64, b64))
    if a_data.shape != b_data.shape:
        diff = 255
    else:
        diff = np.mean(np.abs(a_data - b_data))
    diff /= 255.0
    if diff > PNG_DIFF_TOLERANCE:
        digest = hashlib.sha1(a64).digest()
        if generate_diff_images:
            if not os.path.exists('.diffs/'):
                os.mkdir('.diffs/')
            prefix = '.diffs/ipnbdoctest-%s-' % base64.urlsafe_b64encode(digest)[:4]
            print 'Images mismatch'
            print 'Expected:'
            print_base64_img(a_data)
            print 'Actual:'
            print_base64_img(b_data)
            if diff < 1:
                print 'Diff:'
                print_base64_img(255 - np.abs(b_data - a_data))

    return diff

def sanitize(s):
    """sanitize a string for comparison.

    fix universal newlines, strip trailing newlines, and normalize likely random values (memory addresses and UUIDs)
    """
    if not isinstance(s, basestring):
        return s
    # normalize newline:
    s = s.replace('\r\n', '\n')

    # ignore trailing newlines (but not space)
    s = s.rstrip('\n')

    # normalize hex addresses:
    s = re.sub(r'0x[a-f0-9]+', '0xFFFFFFFF', s)

    # normalize UUIDs:
    s = re.sub(r'[a-f0-9]{8}(\-[a-f0-9]{4}){3}\-[a-f0-9]{12}', 'U-U-I-D', s)

    # ignore outputs of %time and %timeit magics:
    s = re.sub(r'(CPU times|Wall time|\d+ loops, best of).+', 'TIMING', s)

    # Ignore the %%cache magic output
    s = re.sub(r'Skipped the cell\'s code and loaded variables problems from file.+', 'CACHING', s)

    return s

def consolidate_outputs(outputs):
    """consolidate outputs into a summary dict (incomplete)"""
    data = defaultdict(list)
    data['stdout'] = ''
    data['stderr'] = ''

    for out in outputs:
        if out.type == 'stream':
            data[out.stream] += out.text
        elif out.type == 'pyerr':
            data['pyerr'] = dict(ename=out.ename, evalue=out.evalue)
        else:
            for key in ('png', 'svg', 'latex', 'html', 'javascript', 'text', 'jpeg',):
                if key in out:
                    data[key].append(out[key])
    return data

def compare_outputs(test, ref,
                    skip_compare=('traceback', 'latex', 'prompt_number'),
                    generate_png_diffs=True):
    for key in ref:
        if key not in test:
            print "missing key: %s != %s" % (test.keys(), ref.keys())
            return False
        elif key == 'png':
            diff = diff_png(test[key], ref[key],
                            generate_diff_images=generate_png_diffs)
            if diff > PNG_DIFF_TOLERANCE:
                print "png mismatch %s" % key
                print "%2.6f%% disagree" % diff
                return False
        elif key not in skip_compare and sanitize(test[key]) != sanitize(ref[key]):
            print "mismatch %s:" % key
            print test[key]
            print '  !=  '
            print ref[key]
            return False
    return True

def run_cell(shell, iopub, cell):
    # print cell.input
    shell.execute(cell.input)
    # wait for finish, maximum 10min
    shell.get_msg(timeout=60*10)
    outs = []

    while True:
        try:
            msg = iopub.get_msg(timeout=0.2)
        except Empty:
            break
        msg_type = msg['msg_type']
        if msg_type in ('status', 'pyin'):
            continue
        elif msg_type == 'clear_output':
            outs = []
            continue

        content = msg['content']
        # print msg_type, content
        out = NotebookNode(output_type=msg_type)

        if msg_type == 'stream':
            out.stream = content['name']
            out.text = content['data']
        elif msg_type in ('display_data', 'pyout'):
            out['metadata'] = content['metadata']
            for mime, data in content['data'].iteritems():
                attr = mime.split('/')[-1].lower()
                # this gets most right, but fix svg+html, plain
                attr = attr.replace('+xml', '').replace('plain', 'text')
                setattr(out, attr, data)
            if msg_type == 'pyout':
                out.prompt_number = content['execution_count']
        elif msg_type == 'pyerr':
            out.ename = content['ename']
            out.evalue = content['evalue']
            out.traceback = content['traceback']
        else:
            print "unhandled iopub msg:", msg_type

        outs.append(out)
    return outs

def collapse_stream_outputs(outputs):
    """
    Collapse the stream outputs returned by ipynb as different buffering
    might change the end result
    """

    stream_outputs = {}
    collapsed_outputs = []
    for output in outputs:
        if output[u'output_type'] == u'stream':
            text = output[u'text']
            try:
                stream_outputs[output[u'stream']].append(text)
            except KeyError:
                stream_outputs[output[u'stream']] = [text]
        else:
            collapsed_outputs.append(output)
    sorted_streams = sorted(stream_outputs.iteritems())
    for stream, stream_texts in sorted_streams:

        collapsed_outputs.append({u"output_type" : u"stream",
                                  u"stream" : stream,
                                  u"text": u''.join(stream_texts)})

    return collapsed_outputs

def test_notebook(nb, generate_png_diffs=True):
    km = KernelManager()
    km.start_kernel(extra_arguments=['--pylab=inline'], stderr=open(os.devnull, 'w'))
    try:
        kc = km.client()
        kc.start_channels()
        iopub = kc.iopub_channel
    except AttributeError:
        # IPython 0.13
        kc = km
        kc.start_channels()
        iopub = kc.sub_channel
    shell = kc.shell_channel

    # run %pylab inline, because some notebooks assume this
    # even though they shouldn't
    shell.execute("pass")
    shell.get_msg()
    while True:
        try:
            iopub.get_msg(timeout=1)
        except Empty:
            break

    successes = 0
    failures = 0
    errors = 0
    for ws in nb.worksheets:
        for cell in ws.cells:
            if cell.cell_type != 'code':
                continue
            try:
                outs = run_cell(shell, iopub, cell)
            except Exception as e:
                print
                print "Failed to run cell, got {0!r}".format(e)
                traceback.print_exc()
                print
                print "The cell is:"
                print '-' * 50
                print cell.input
                print '-' * 50
                errors += 1
                break

            failed = False
            outs = collapse_stream_outputs(outs)
            cell_outputs = collapse_stream_outputs(cell.outputs)
            for out, ref in zip(outs, cell_outputs):
                if not compare_outputs(out, ref, generate_png_diffs=generate_png_diffs):
                    failed = True
            if failed:
                failures += 1
            else:
                successes += 1
            sys.stdout.write('.')

    print
    print "tested notebook %s" % nb.metadata.name
    print "    %3i cells successfully replicated" % successes
    if failures:
        print "    %3i cells mismatched output" % failures
    if errors:
        print "    %3i cells failed to complete" % errors

    if failures or errors:
        print " If image tests failed, but images not displayed, copy and paste the line below to your address bar: "
        print "javascript:pres = document.querySelectorAll('pre'); for (var i = 0; i < pres.length; i++) { pres[i].innerHTML = pres[i].innerHTML.replace(/<img/g, '') };void 0;"
    kc.stop_channels()
    km.shutdown_kernel()
    del km

    return failures, errors

def arguments_parser():

    parser = argparse.ArgumentParser()
    parser.add_argument('notebooks', nargs='+', type=unicode, help='IPython notebooks to test')
    parser.add_argument('--no-png-output', dest='generate_png_images',
                        action="store_false", default=True,
                        help="Do not generate PNG images")
    return parser

if __name__ == '__main__':
    parser = arguments_parser()
    args = parser.parse_args()
    for ipynb in args.notebooks:
        print "testing %s" % ipynb
        with open(ipynb) as f:
            nb = reads(f.read(), 'json')
        test_notebook(nb, generate_png_diffs=args.generate_png_images)
<|endoftext|>


<commit_before># -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from frappe.core.doctype.data_import.importer_new import Importer
from frappe.core.doctype.data_import.exporter_new import Exporter
from frappe.core.page.background_jobs.background_jobs import get_info
from frappe.utils.background_jobs import enqueue

class DataImportBeta(Document):
	def validate(self):
		doc_before_save = self.get_doc_before_save()
		if not self.import_file or (
			doc_before_save and doc_before_save.import_file != self.import_file
		):
			self.template_options = ""
			self.template_warnings = ""

	def get_preview_from_template(self):
		if not self.import_file:
			return

		i = self.get_importer()
		return i.get_data_for_import_preview()

	def start_import(self):
		enqueued_jobs = [d.get("job_name") for d in get_info()]

		if self.name not in enqueued_jobs:
			enqueue(
				start_import,
				queue="default",
				timeout=6000,
				event="data_import",
				job_name=self.name,
				data_import=self.name,
				now=True,
			)

	def get_importer(self):
		return Importer(self.reference_doctype, data_import=self)

	def create_missing_link_values(self, missing_link_values):
		docs = []
		for d in missing_link_values:
			d = frappe._dict(d)
			if not d.has_one_mandatory_field:
				continue

			doctype = d.doctype
			values = d.missing_values
			meta = frappe.get_meta(doctype)
			# find the autoname field
			if meta.autoname and meta.autoname.startswith("field:"):
				autoname_field = meta.autoname[len("field:") :]
			else:
				autoname_field = "name"

			for value in values:
				new_doc = frappe.new_doc(doctype)
				new_doc.set(autoname_field, value)
				docs.append(new_doc.insert())
		return docs

	def export_errored_rows(self):
		return self.get_importer().export_errored_rows()

def start_import(data_import):
	"""This method runs in background job"""
	data_import = frappe.get_doc("Data Import Beta", data_import)
	i = Importer(data_import.reference_doctype, data_import=data_import)
	return i.import_data()

@frappe.whitelist()
def download_template(
	doctype, export_fields=None, export_records=None, export_filters=None, file_type="CSV"
):
	"""
	Download template from Exporter
		:param doctype: Document Type
		:param export_fields=None: Fields to export as dict {'Sales Invoice': ['name', 'customer'], 'Sales Invoice Item': ['item_code']}
		:param export_records=None: One of 'all', 'by_filter', 'blank_template'
		:param export_filters: Filter dict
		:param file_type: File type to export into
	"""

	export_fields = frappe.parse_json(export_fields)
	export_filters = frappe.parse_json(export_filters)
	export_data = export_records != "blank_template"

	e = Exporter(
		doctype,
		export_fields=export_fields,
		export_data=export_data,
		export_filters=export_filters,
		file_type=file_type,
	)
	e.build_response()

@frappe.whitelist()
def download_errored_template(data_import_name):
	data_import = frappe.get_doc('Data Import Beta', data_import_name)
	data_import.export_errored_rows()
<commit_msg>fix: Show message when scheduler in inactive<commit_after># -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from frappe.core.doctype.data_import.importer_new import Importer
from frappe.core.doctype.data_import.exporter_new import Exporter
from frappe.core.page.background_jobs.background_jobs import get_info
from frappe.utils.background_jobs import enqueue
from frappe import _

class DataImportBeta(Document):
	def validate(self):
		doc_before_save = self.get_doc_before_save()
		if not self.import_file or (
			doc_before_save and doc_before_save.import_file != self.import_file
		):
			self.template_options = ""
			self.template_warnings = ""

	def get_preview_from_template(self):
		if not self.import_file:
			return

		i = self.get_importer()
		return i.get_data_for_import_preview()

	def start_import(self):
		if frappe.utils.scheduler.is_scheduler_inactive():
			frappe.throw(_("Scheduler is inactive. Cannot import data."), title=_("Error"))

		enqueued_jobs = [d.get("job_name") for d in get_info()]

		if self.name not in enqueued_jobs:
			enqueue(
				start_import,
				queue="default",
				timeout=6000,
				event="data_import",
				job_name=self.name,
				data_import=self.name,
			)

	def get_importer(self):
		return Importer(self.reference_doctype, data_import=self)

	def create_missing_link_values(self, missing_link_values):
		docs = []
		for d in missing_link_values:
			d = frappe._dict(d)
			if not d.has_one_mandatory_field:
				continue

			doctype = d.doctype
			values = d.missing_values
			meta = frappe.get_meta(doctype)
			# find the autoname field
			if meta.autoname and meta.autoname.startswith("field:"):
				autoname_field = meta.autoname[len("field:") :]
			else:
				autoname_field = "name"

			for value in values:
				new_doc = frappe.new_doc(doctype)
				new_doc.set(autoname_field, value)
				docs.append(new_doc.insert())
		return docs

	def export_errored_rows(self):
		return self.get_importer().export_errored_rows()

def start_import(data_import):
	"""This method runs in background job"""
	data_import = frappe.get_doc("Data Import Beta", data_import)
	i = Importer(data_import.reference_doctype, data_import=data_import)
	return i.import_data()

@frappe.whitelist()
def download_template(
	doctype, export_fields=None, export_records=None, export_filters=None, file_type="CSV"
):
	"""
	Download template from Exporter
		:param doctype: Document Type
		:param export_fields=None: Fields to export as dict {'Sales Invoice': ['name', 'customer'], 'Sales Invoice Item': ['item_code']}
		:param export_records=None: One of 'all', 'by_filter', 'blank_template'
		:param export_filters: Filter dict
		:param file_type: File type to export into
	"""

	export_fields = frappe.parse_json(export_fields)
	export_filters = frappe.parse_json(export_filters)
	export_data = export_records != "blank_template"

	e = Exporter(
		doctype,
		export_fields=export_fields,
		export_data=export_data,
		export_filters=export_filters,
		file_type=file_type,
	)
	e.build_response()

@frappe.whitelist()
def download_errored_template(data_import_name):
	data_import = frappe.get_doc("Data Import Beta", data_import_name)
	data_import.export_errored_rows()
<|endoftext|>


<commit_before><commit_msg>Add the nacl ui test to the Chromium Builder configuration.<commit_after><|endoftext|>


<commit_before>"""
Implementation of simple matrix
"""

def matrix_maker(row_num, col_num, val = None):
	"""
	:param row_num: the number of rows
	:type row_num: int
	:param col_num: the number of columns
	:type col_num: int
	:param val: the default value to fill the matrix
	:type val: any (None by default)
	:return: matrix of rows_num x col_num
	:rtype: matrix
	"""
	matrix = []
	for i in range(col_num):
		col = [val] * row_num
		matrix.append(col)
	return matrix

def _check_matrix_index(matrix, row_no, col_no):
	"""
	check if row_no and col_no are in matrix bound

	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:param rows_no: the index of row to check
	:type rows_no: int
	:param col_no: the index of column to check
	:type col_no: int
	:raise: IndexError if row_no or col_no are out of matrix bounds
	"""
	row_max, col_max = matrix_size(matrix)
	if (row_no < 0 or row_no >= row_max) or (col_no < 0 or col_no >= col_max):
		raise IndexError("matrix index out of range")

def matrix_size(matrix):
	"""
	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:return: the size of matrix (number of rows, number of cols)
	:rtype: typle of 2 int
	"""
	return len(matrix[0]), len(matrix)

def matrix_get_cell(matrix, row_no, col_no):
	"""
	:param matrix: the matrix
	:type matrix: matrix
	:param rows_no: the row number
	:type rows_no: int
	:param col_no: the column number
	:type col_no: int
	:retrun: the content of cell corresponding to row_no x col_no
	:rtype: any
	"""
	_check_matrix_index(matrix, row_no, col_no)
	return matrix[col_no][row_no]

def matrix_set_cell(matrix, row_no, col_no, val):
	"""
	set the value val in cell specified by row_no x col_no

	:param matrix: the matrix to modify
	:type matrix: matrix
	:param row_no: the row number of cell to set
	:type rows_no: int
	:param col_no: the column number of cell to set
	:type col_no: int
	:param val: the value to set in cell
	:type val: int
	"""
	_check_matrix_index(matrix, row_no, col_no)
	matrix[col_no][row_no] = val

def matrix_to_str(matrix):
	"""
	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:return: a string representation of the matrix
	:rtype: str
	"""
	s = ""
	# by design all matrix cols have same size
	for row in zip(*matrix):
		cells = [str(cell) for cell in row]
		s += " ".join(cells) + "\n"
	return s

def matrix_mult(matrix, val):
	"""
	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:param rows_no: the number of rows
	:type rows_no: int
	:param col_no: the number of columns
	:type col_no: int
	:param val: the value to mult the matrix with
	:type val: int
	:return: a new matrix corresponding the scalar product of matrix * val
	:rtype: matrix
	"""
	new_matrix = []
	for col in matrix:
		new_col = [cell * val for cell in col]
		new_matrix.append(new_col)
	return new_matrix

def matrix_get_row(matrix, row_no):
	"""
	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:param rows_no: row number
	:type rows_no: int
	:return: the row of matrix corresponding to row_no
	         a shallow copy of the row
	:rtype: list
	"""
	_check_matrix_index(matrix, row_no, 0)
	row_max, col_max = matrix_size(matrix)
	row = []
	for col_n in range(col_max):
		row.append(matrix_get_cell(matrix, row_no, col_n))
	return row

def matrix_set_row(matrix, row_no, val):
	"""
	set all cells of row row_no with val

	:param matrix: the matrix to modify
	:type matrix: matrix
	:param row_no: the row number
	:type row_no: int
	:param val: the value to put in cells
	:type val: any
	"""
	_check_matrix_index(matrix, row_no, 0)
	row_max, col_max = matrix_size(matrix)
	for col_n in range(col_max):
		matrix_set_cell(matrix, row_no, col_n, val)

def matrix_get_col(matrix, col_no):
	"""
	:param matrix: the matrix get row
	:type matrix: matrix
	:param col_no: the column number
	:type col_no: int
	:return: the column corresponding to col_no of matrix
	         a shallow copy of the col
	:rtype: list
	"""
	_check_matrix_index(matrix, 0, col_no)
	col = matrix[col_no][:]
	return col

def matrix_set_col(matrix, col_no, val):
	"""
	set all cells of col col_no with val

	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:param col_no: the column number
	:type col_no: int
	:param val: the value to put in cells
	:type val: any
	"""
	_check_matrix_index(matrix, 0, col_no)
	row_max, col_max = matrix_size(matrix)
	for row_n in range(im):
		matrix_set_cell(matrix, row_n, col_no, val)

def matrix_replace_col(matrix, col_no, col):
	"""
	replace column col_no with col

	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:param col_no: the column number to replace
	:type col_no: int
	:param col: the list of values to use as replacement of column
	:type col: list
	"""
	row_max, col_max = matrix_size(matrix)
	if len(col) != col_max:
		raise RuntimeError("the size of col {0} does not fit to matrix size {1}x{2}".format(len(col),
																						row_max,
																						col_max))
	_check_matrix_index(matrix, 0, col_no)
	matrix[col_no] = col

def matrix_replace_row(matrix, row_no, row):
	"""
	replace row row_no with row

	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:param row_no: the column number
	:type row_no: int
	:param row: the list of value to use as replacement of row
	:type row: list
	"""
	row_max, col_max = matrix_size(matrix)
	if len(row) != row_max:
		raise RuntimeError("the size of row {0} does not fit to matrix size {1}x{2}".format(len(row),
																						row_max,
																						col_max))
	_check_matrix_index(matrix, row_no, 0)
	for col_no, value in enumerate(row):
		matrix_set_cell(matrix, row_no, col_no, value)

if __name__ == '__main__':
	m = matrix_maker(5, 3)
	print m
	matrix_set_cell(m,0, 0, 1)
	matrix_set_cell(m,0, 2, 2)
	matrix_set_cell(m,4, 0, 12)
	matrix_set_cell(m,4, 2, 15)
	print matrix_to_str(m)
	print "get row 0",  matrix_get_row(m, 0)
	print "get col 0", matrix_get_col(m, 0)

<commit_msg>rename functions<commit_after>"""
Implementation of simple matrix
"""

def create(row_num, col_num, val = None):
	"""
	:param row_num: the number of rows
	:type row_num: int
	:param col_num: the number of columns
	:type col_num: int
	:param val: the default value to fill the matrix
	:type val: any (None by default)
	:return: matrix of rows_num x col_num
	:rtype: matrix
	"""
	matrix = []
	for i in range(col_num):
		col = [val] * row_num
		matrix.append(col)
	return matrix

def _check_index(matrix, row_no, col_no):
	"""
	check if row_no and col_no are in matrix bound

	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:param rows_no: the index of row to check
	:type rows_no: int
	:param col_no: the index of column to check
	:type col_no: int
	:raise: IndexError if row_no or col_no are out of matrix bounds
	"""
	row_max, col_max = size(matrix)
	if (row_no < 0 or row_no >= row_max) or (col_no < 0 or col_no >= col_max):
		raise IndexError("matrix index out of range")

def size(matrix):
	"""
	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:return: the size of matrix (number of rows, number of cols)
	:rtype: typle of 2 int
	"""
	return len(matrix[0]), len(matrix)

def get_cell(matrix, row_no, col_no):
	"""
	:param matrix: the matrix
	:type matrix: matrix
	:param rows_no: the row number
	:type rows_no: int
	:param col_no: the column number
	:type col_no: int
	:retrun: the content of cell corresponding to row_no x col_no
	:rtype: any
	"""
	_check_index(matrix, row_no, col_no)
	return matrix[col_no][row_no]

def set_cell(matrix, row_no, col_no, val):
	"""
	set the value val in cell specified by row_no x col_no

	:param matrix: the matrix to modify
	:type matrix: matrix
	:param row_no: the row number of cell to set
	:type rows_no: int
	:param col_no: the column number of cell to set
	:type col_no: int
	:param val: the value to set in cell
	:type val: int
	"""
	_check_index(matrix, row_no, col_no)
	matrix[col_no][row_no] = val

def to_str(matrix):
	"""
	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:return: a string representation of the matrix
	:rtype: str
	"""
	s = ""
	# by design all matrix cols have same size
	for row in zip(*matrix):
		cells = [str(cell) for cell in row]
		s += " ".join(cells) + "\n"
	return s

def mult(matrix, val):
	"""
	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:param rows_no: the number of rows
	:type rows_no: int
	:param col_no: the number of columns
	:type col_no: int
	:param val: the value to mult the matrix with
	:type val: int
	:return: a new matrix corresponding the scalar product of matrix * val
	:rtype: matrix
	"""
	new_matrix = []
	for col in matrix:
		new_col = [cell * val for cell in col]
		new_matrix.append(new_col)
	return new_matrix

def get_row(matrix, row_no):
	"""
	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:param rows_no: row number
	:type rows_no: int
	:return: the row of matrix corresponding to row_no
	         a shallow copy of the row
	:rtype: list
	"""
	_check_index(matrix, row_no, 0)
	row_max, col_max = size(matrix)
	row = []
	for col_n in range(col_max):
		row.append(get_cell(matrix, row_no, col_n))
	return row

def set_row(matrix, row_no, val):
	"""
	set all cells of row row_no with val

	:param matrix: the matrix to modify
	:type matrix: matrix
	:param row_no: the row number
	:type row_no: int
	:param val: the value to put in cells
	:type val: any
	"""
	_check_index(matrix, row_no, 0)
	row_max, col_max = size(matrix)
	for col_n in range(col_max):
		set_cell(matrix, row_no, col_n, val)

def get_col(matrix, col_no):
	"""
	:param matrix: the matrix get row
	:type matrix: matrix
	:param col_no: the column number
	:type col_no: int
	:return: the column corresponding to col_no of matrix
	         a shallow copy of the col
	:rtype: list
	"""
	_check_index(matrix, 0, col_no)
	col = matrix[col_no][:]
	return col

def set_col(matrix, col_no, val):
	"""
	set all cells of col col_no with val

	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:param col_no: the column number
	:type col_no: int
	:param val: the value to put in cells
	:type val: any
	"""
	_check_index(matrix, 0, col_no)
	row_max, col_max = size(matrix)
	for row_n in range(im):
		set_cell(matrix, row_n, col_no, val)

def replace_col(matrix, col_no, col):
	"""
	replace column col_no with col

	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:param col_no: the column number to replace
	:type col_no: int
	:param col: the list of values to use as replacement of column
	:type col: list
	"""
	row_max, col_max = size(matrix)
	if len(col) != col_max:
		raise RuntimeError("the size of col {0} does not fit to matrix size {1}x{2}".format(len(col),
																						row_max,
																						col_max))
	_check_index(matrix, 0, col_no)
	matrix[col_no] = col

def replace_row(matrix, row_no, row):
	"""
	replace row row_no with row

	:param matrix: the matrix to compute the size
	:type matrix: matrix
	:param row_no: the column number
	:type row_no: int
	:param row: the list of value to use as replacement of row
	:type row: list
	"""
	row_max, col_max = size(matrix)
	if len(row) != row_max:
		raise RuntimeError("the size of row {0} does not fit to matrix size {1}x{2}".format(len(row),
																						row_max,
																						col_max))
	_check_index(matrix, row_no, 0)
	for col_no, value in enumerate(row):
		set_cell(matrix, row_no, col_no, value)

if __name__ == '__main__':
	m = create(5, 3)
	print m
	set_cell(m,0, 0, 1)
	set_cell(m,0, 2, 2)
	set_cell(m,4, 0, 12)
	set_cell(m,4, 2, 15)
	print to_str(m)
	print "get row 0",  get_row(m, 0)
	print "get col 0", get_col(m, 0)

<|endoftext|>


<commit_before># Copyright (c) 2009 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

{
  'targets': [
    {
      'target_name': 'All',
      'type': 'none',
      'xcode_create_dependents_test_runner': 1,
      'dependencies': [
        '../app/app.gyp:*',
        '../base/base.gyp:*',
        '../chrome/browser/sync/tools/sync_tools.gyp:*',
        '../chrome/chrome.gyp:*',
        '../gfx/gfx.gyp:*',
        '../gpu/gpu.gyp:*',
        '../gpu/demos/demos.gyp:*',
        '../ipc/ipc.gyp:*',
        '../jingle/jingle.gyp:*',
        '../media/media.gyp:*',
        '../net/net.gyp:*',
        '../net/third_party/nss/ssl.gyp:*',
        '../printing/printing.gyp:*',
        '../sdch/sdch.gyp:*',
        '../skia/skia.gyp:*',
        '../testing/gmock.gyp:*',
        '../testing/gtest.gyp:*',
        '../third_party/bzip2/bzip2.gyp:*',
        '../third_party/cacheinvalidation/cacheinvalidation.gyp:*',
        '../third_party/cld/cld.gyp:*',
        '../third_party/codesighs/codesighs.gyp:*',
        '../third_party/ffmpeg/ffmpeg.gyp:*',
        '../third_party/icu/icu.gyp:*',
        '../third_party/libjpeg/libjpeg.gyp:*',
        '../third_party/libpng/libpng.gyp:*',
        '../third_party/libxml/libxml.gyp:*',
        '../third_party/libxslt/libxslt.gyp:*',
        '../third_party/lzma_sdk/lzma_sdk.gyp:*',
        '../third_party/mesa/mesa.gyp:*',
        '../third_party/modp_b64/modp_b64.gyp:*',
        '../third_party/npapi/npapi.gyp:*',
        '../third_party/ppapi/ppapi.gyp:*',
        '../third_party/ots/ots.gyp:*',
        '../third_party/sqlite/sqlite.gyp:*',
        '../third_party/WebKit/WebKit/chromium/WebKit.gyp:*',
        '../third_party/zlib/zlib.gyp:*',
        '../webkit/support/webkit_support.gyp:*',
        '../webkit/webkit.gyp:*',
        'util/build_util.gyp:*',
        'temp_gyp/googleurl.gyp:*',
      ],
      'conditions': [
        ['javascript_engine=="v8"', {
          'dependencies': [
            '../v8/tools/gyp/v8.gyp:*',
          ],
        }],
        ['OS=="mac" or OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
          'dependencies': [
            '../third_party/yasm/yasm.gyp:*#host',
           ],
        }],
        ['OS=="mac" or OS=="win"', {
          'dependencies': [
            '../third_party/nss/nss.gyp:*',
           ],
        }],
        ['OS=="mac"', {
          'dependencies': [
            '../third_party/ocmock/ocmock.gyp:*',
          ],
        }],
        ['OS=="linux"', {
          'dependencies': [
            '../breakpad/breakpad.gyp:*',
            '../courgette/courgette.gyp:*',
            '../sandbox/sandbox.gyp:*',
          ],
          'conditions': [
            ['branding=="Chrome"', {
              'dependencies': [
                '../chrome/chrome.gyp:linux_packages_<(channel)',
              ],
            }],
          ],
        }],
        ['OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
          'dependencies': [
            '../tools/gtk_clipboard_dump/gtk_clipboard_dump.gyp:*',
            '../tools/xdisplaycheck/xdisplaycheck.gyp:*',
          ],
        }],
        ['OS=="win"', {
          'conditions': [
            ['win_use_allocator_shim==1', {
              'dependencies': [
                '../base/allocator/allocator.gyp:*',
              ],
            }],
          ],
          'dependencies': [
            '../breakpad/breakpad.gyp:*',
            '../chrome/app/locales/locales.gyp:*',
            '../chrome_frame/chrome_frame.gyp:*',
            '../courgette/courgette.gyp:*',
            '../gears/gears.gyp:*',
            '../rlz/rlz.gyp:*',
            '../sandbox/sandbox.gyp:*',
            '../third_party/bsdiff/bsdiff.gyp:*',
            '../third_party/bspatch/bspatch.gyp:*',
            '../third_party/gles2_book/gles2_book.gyp:*',
            '../tools/memory_watcher/memory_watcher.gyp:*',
          ],
        }, {
          'dependencies': [
            '../third_party/libevent/libevent.gyp:*',
          ],
        }],
        ['toolkit_views==1', {
          'dependencies': [
            '../views/views.gyp:*',
          ],
        }],
        ['chromeos==1', {
          'dependencies': [
            '../chrome/browser/chromeos/input_method/candidate_window.gyp:*',
          ],
        }],
        ['remoting==1', {
          'dependencies': [
            '../remoting/remoting.gyp:*',
          ],
        }],
      ],
    },
  ],
  'conditions': [
    ['OS=="mac"', {
      'targets': [
        {
          # Target to build everything plus the dmg.  We don't put the dmg
          # in the All target because developers really don't need it.
          'target_name': 'all_and_dmg',
          'type': 'none',
          'dependencies': [
            'All',
            '../chrome/chrome.gyp:build_app_dmg',
          ],
        },
        # These targets are here so the build bots can use them to build
        # subsets of a full tree for faster cycle times.
        {
          'target_name': 'chromium_builder_dbg',
          'type': 'none',
          'dependencies': [
            '../app/app.gyp:app_unittests',
            '../chrome/chrome.gyp:browser_tests',
            '../chrome/chrome.gyp:nacl_ui_tests',
            '../chrome/chrome.gyp:sync_unit_tests',
            '../chrome/chrome.gyp:ui_tests',
            '../chrome/chrome.gyp:unit_tests',
            '../gfx/gfx.gyp:gfx_unittests',
            '../gpu/gpu.gyp:gpu_unittests',
            '../ipc/ipc.gyp:ipc_tests',
            '../jingle/jingle.gyp:notifier_unit_tests',
            '../media/media.gyp:media_unittests',
            '../printing/printing.gyp:printing_unittests',
            '../remoting/remoting.gyp:remoting_unittests',
            '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
            'temp_gyp/googleurl.gyp:googleurl_unittests',
          ],
        },
        {
          'target_name': 'chromium_builder_rel',
          'type': 'none',
          'dependencies': [
            '../app/app.gyp:app_unittests',
            '../chrome/chrome.gyp:browser_tests',
            '../chrome/chrome.gyp:memory_test',
            '../chrome/chrome.gyp:nacl_ui_tests',
            '../chrome/chrome.gyp:page_cycler_tests',
            '../chrome/chrome.gyp:plugin_tests',
            '../chrome/chrome.gyp:startup_tests',
            '../chrome/chrome.gyp:sync_unit_tests',
            '../chrome/chrome.gyp:tab_switching_test',
            '../chrome/chrome.gyp:ui_tests',
            '../chrome/chrome.gyp:unit_tests',
            '../chrome/chrome.gyp:url_fetch_test',
            '../gfx/gfx.gyp:gfx_unittests',
            '../gpu/gpu.gyp:gpu_unittests',
            '../ipc/ipc.gyp:ipc_tests',
            '../jingle/jingle.gyp:notifier_unit_tests',
            '../media/media.gyp:media_unittests',
            '../printing/printing.gyp:printing_unittests',
            '../remoting/remoting.gyp:remoting_unittests',
            '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
            'temp_gyp/googleurl.gyp:googleurl_unittests',
          ],
        },
        {
          'target_name': 'chromium_builder_dbg_tsan_mac',
          'type': 'none',
          'dependencies': [
            '../base/base.gyp:base_unittests',
            'temp_gyp/googleurl.gyp:googleurl_unittests',
            '../net/net.gyp:net_unittests',
            '../ipc/ipc.gyp:ipc_tests',
            '../jingle/jingle.gyp:notifier_unit_tests',
            '../media/media.gyp:media_unittests',
            '../printing/printing.gyp:printing_unittests',
            '../remoting/remoting.gyp:remoting_unittests',
            '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
          ],
        },
      ],  # targets
    }], # OS="mac"
    ['OS=="win"', {
      'targets': [
        # These targets are here so the build bots can use them to build
        # subsets of a full tree for faster cycle times.
        {
          'target_name': 'chromium_builder',
          'type': 'none',
          'dependencies': [
            '../app/app.gyp:app_unittests',
            '../chrome/chrome.gyp:browser_tests',
            '../chrome/chrome.gyp:installer_util_unittests',
            '../chrome/chrome.gyp:interactive_ui_tests',
            '../chrome/chrome.gyp:memory_test',
            '../chrome/chrome.gyp:mini_installer_test',
            '../chrome/chrome.gyp:nacl_ui_tests',
            '../chrome/chrome.gyp:page_cycler_tests',
            '../chrome/chrome.gyp:plugin_tests',
            '../chrome/chrome.gyp:selenium_tests',
            '../chrome/chrome.gyp:startup_tests',
            '../chrome/chrome.gyp:sync_unit_tests',
            '../chrome/chrome.gyp:tab_switching_test',
            '../chrome/chrome.gyp:ui_tests',
            '../chrome/chrome.gyp:unit_tests',
            '../chrome/chrome.gyp:url_fetch_test',
            # mini_installer_tests depends on mini_installer. This should be
            # defined in installer.gyp.
            '../chrome/installer/mini_installer.gyp:mini_installer',
            '../courgette/courgette.gyp:courgette_unittests',
            '../gfx/gfx.gyp:gfx_unittests',
            '../gpu/gpu.gyp:gpu_unittests',
            '../ipc/ipc.gyp:ipc_tests',
            '../jingle/jingle.gyp:notifier_unit_tests',
            '../media/media.gyp:media_unittests',
            '../printing/printing.gyp:printing_unittests',
            '../remoting/remoting.gyp:remoting_unittests',
            '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
            '../webkit/support/webkit_support.gyp:npapi_layout_test_plugin',
            # TODO(nsylvain) ui_tests.exe depends on test_shell_common.
            # This should:
            # 1) not be the case. OR.
            # 2) be expressed in the ui tests dependencies.
            '../webkit/webkit.gyp:test_shell_common',
            'temp_gyp/googleurl.gyp:googleurl_unittests',
            '../chrome_frame/chrome_frame.gyp:chrome_frame_net_tests',
            '../chrome_frame/chrome_frame.gyp:chrome_frame_perftests',
            '../chrome_frame/chrome_frame.gyp:chrome_frame_reliability_tests',
            '../chrome_frame/chrome_frame.gyp:chrome_frame_tests',
            '../chrome_frame/chrome_frame.gyp:chrome_frame_unittests',
            '../chrome_frame/chrome_frame.gyp:npchrome_frame',
            '../third_party/angle/src/build_angle.gyp:*',
          ],
        },
        {
          'target_name': 'chromium_builder_dbg_tsan_win',
          'type': 'none',
          'dependencies': [
            '../app/app.gyp:app_unittests',
            # TODO(bradnelson): app_unittests should depend on locales.
            # However, we can't add dependencies on chrome/ to app/
            # See http://crbug.com/43603
            '../base/base.gyp:base_unittests',
            '../chrome/app/locales/locales.gyp:*',
            '../chrome/chrome.gyp:sync_unit_tests',
            '../chrome/chrome.gyp:unit_tests',
            '../ipc/ipc.gyp:ipc_tests',
            '../jingle/jingle.gyp:notifier_unit_tests',
            '../media/media.gyp:media_unittests',
            '../net/net.gyp:net_unittests',
            '../printing/printing.gyp:printing_unittests',
            '../remoting/remoting.gyp:remoting_unittests',
            '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
            'temp_gyp/googleurl.gyp:googleurl_unittests',
          ],
        },
      ],  # targets
    }], # OS="win"
    ['chromeos==1', {
      'targets': [
        {
          'target_name': 'chromeos_builder',
          'type': 'none',
          'sources': [
            # TODO(bradnelson): This is here to work around gyp issue 137.
            #     Remove this sources list when that issue has been fixed.
            'all.gyp',
          ],
          'dependencies': [
            '../app/app.gyp:app_unittests',
            '../base/base.gyp:base_unittests',
            '../chrome/chrome.gyp:browser_tests',
            '../chrome/chrome.gyp:chrome',
            '../chrome/chrome.gyp:interactive_ui_tests',
            '../chrome/chrome.gyp:memory_test',
            '../chrome/chrome.gyp:page_cycler_tests',
            '../chrome/chrome.gyp:startup_tests',
            '../chrome/chrome.gyp:sync_unit_tests',
            '../chrome/chrome.gyp:tab_switching_test',
            '../chrome/chrome.gyp:ui_tests',
            '../chrome/chrome.gyp:unit_tests',
            '../chrome/chrome.gyp:url_fetch_test',
            '../gfx/gfx.gyp:gfx_unittests',
            '../ipc/ipc.gyp:ipc_tests',
            '../jingle/jingle.gyp:notifier_unit_tests',
            '../media/media.gyp:ffmpeg_tests',
            '../media/media.gyp:media_unittests',
            '../media/media.gyp:omx_test',
            '../net/net.gyp:net_unittests',
            '../printing/printing.gyp:printing_unittests',
            '../remoting/remoting.gyp:remoting_unittests',
            '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
            'temp_gyp/googleurl.gyp:googleurl_unittests',
            '../chrome/browser/chromeos/input_method/candidate_window.gyp:candidate_window',
          ],
        },
      ],  # targets
    }], # "chromeos==1"
  ], # conditions
}

# Local Variables:
# tab-width:2
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=2 shiftwidth=2:
<commit_msg>Don't build unit_tests on TSan/Win bot. BUG=49756 TBR=thestig TEST=TSan/Win bot should become green Review URL: http://codereview.chromium.org/3031017<commit_after># Copyright (c) 2009 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

{
  'targets': [
    {
      'target_name': 'All',
      'type': 'none',
      'xcode_create_dependents_test_runner': 1,
      'dependencies': [
        '../app/app.gyp:*',
        '../base/base.gyp:*',
        '../chrome/browser/sync/tools/sync_tools.gyp:*',
        '../chrome/chrome.gyp:*',
        '../gfx/gfx.gyp:*',
        '../gpu/gpu.gyp:*',
        '../gpu/demos/demos.gyp:*',
        '../ipc/ipc.gyp:*',
        '../jingle/jingle.gyp:*',
        '../media/media.gyp:*',
        '../net/net.gyp:*',
        '../net/third_party/nss/ssl.gyp:*',
        '../printing/printing.gyp:*',
        '../sdch/sdch.gyp:*',
        '../skia/skia.gyp:*',
        '../testing/gmock.gyp:*',
        '../testing/gtest.gyp:*',
        '../third_party/bzip2/bzip2.gyp:*',
        '../third_party/cacheinvalidation/cacheinvalidation.gyp:*',
        '../third_party/cld/cld.gyp:*',
        '../third_party/codesighs/codesighs.gyp:*',
        '../third_party/ffmpeg/ffmpeg.gyp:*',
        '../third_party/icu/icu.gyp:*',
        '../third_party/libjpeg/libjpeg.gyp:*',
        '../third_party/libpng/libpng.gyp:*',
        '../third_party/libxml/libxml.gyp:*',
        '../third_party/libxslt/libxslt.gyp:*',
        '../third_party/lzma_sdk/lzma_sdk.gyp:*',
        '../third_party/mesa/mesa.gyp:*',
        '../third_party/modp_b64/modp_b64.gyp:*',
        '../third_party/npapi/npapi.gyp:*',
        '../third_party/ppapi/ppapi.gyp:*',
        '../third_party/ots/ots.gyp:*',
        '../third_party/sqlite/sqlite.gyp:*',
        '../third_party/WebKit/WebKit/chromium/WebKit.gyp:*',
        '../third_party/zlib/zlib.gyp:*',
        '../webkit/support/webkit_support.gyp:*',
        '../webkit/webkit.gyp:*',
        'util/build_util.gyp:*',
        'temp_gyp/googleurl.gyp:*',
      ],
      'conditions': [
        ['javascript_engine=="v8"', {
          'dependencies': [
            '../v8/tools/gyp/v8.gyp:*',
          ],
        }],
        ['OS=="mac" or OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
          'dependencies': [
            '../third_party/yasm/yasm.gyp:*#host',
           ],
        }],
        ['OS=="mac" or OS=="win"', {
          'dependencies': [
            '../third_party/nss/nss.gyp:*',
           ],
        }],
        ['OS=="mac"', {
          'dependencies': [
            '../third_party/ocmock/ocmock.gyp:*',
          ],
        }],
        ['OS=="linux"', {
          'dependencies': [
            '../breakpad/breakpad.gyp:*',
            '../courgette/courgette.gyp:*',
            '../sandbox/sandbox.gyp:*',
          ],
          'conditions': [
            ['branding=="Chrome"', {
              'dependencies': [
                '../chrome/chrome.gyp:linux_packages_<(channel)',
              ],
            }],
          ],
        }],
        ['OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
          'dependencies': [
            '../tools/gtk_clipboard_dump/gtk_clipboard_dump.gyp:*',
            '../tools/xdisplaycheck/xdisplaycheck.gyp:*',
          ],
        }],
        ['OS=="win"', {
          'conditions': [
            ['win_use_allocator_shim==1', {
              'dependencies': [
                '../base/allocator/allocator.gyp:*',
              ],
            }],
          ],
          'dependencies': [
            '../breakpad/breakpad.gyp:*',
            '../chrome/app/locales/locales.gyp:*',
            '../chrome_frame/chrome_frame.gyp:*',
            '../courgette/courgette.gyp:*',
            '../gears/gears.gyp:*',
            '../rlz/rlz.gyp:*',
            '../sandbox/sandbox.gyp:*',
            '../third_party/bsdiff/bsdiff.gyp:*',
            '../third_party/bspatch/bspatch.gyp:*',
            '../third_party/gles2_book/gles2_book.gyp:*',
            '../tools/memory_watcher/memory_watcher.gyp:*',
          ],
        }, {
          'dependencies': [
            '../third_party/libevent/libevent.gyp:*',
          ],
        }],
        ['toolkit_views==1', {
          'dependencies': [
            '../views/views.gyp:*',
          ],
        }],
        ['chromeos==1', {
          'dependencies': [
            '../chrome/browser/chromeos/input_method/candidate_window.gyp:*',
          ],
        }],
        ['remoting==1', {
          'dependencies': [
            '../remoting/remoting.gyp:*',
          ],
        }],
      ],
    },
  ],
  'conditions': [
    ['OS=="mac"', {
      'targets': [
        {
          # Target to build everything plus the dmg.  We don't put the dmg
          # in the All target because developers really don't need it.
          'target_name': 'all_and_dmg',
          'type': 'none',
          'dependencies': [
            'All',
            '../chrome/chrome.gyp:build_app_dmg',
          ],
        },
        # These targets are here so the build bots can use them to build
        # subsets of a full tree for faster cycle times.
        {
          'target_name': 'chromium_builder_dbg',
          'type': 'none',
          'dependencies': [
            '../app/app.gyp:app_unittests',
            '../chrome/chrome.gyp:browser_tests',
            '../chrome/chrome.gyp:nacl_ui_tests',
            '../chrome/chrome.gyp:sync_unit_tests',
            '../chrome/chrome.gyp:ui_tests',
            '../chrome/chrome.gyp:unit_tests',
            '../gfx/gfx.gyp:gfx_unittests',
            '../gpu/gpu.gyp:gpu_unittests',
            '../ipc/ipc.gyp:ipc_tests',
            '../jingle/jingle.gyp:notifier_unit_tests',
            '../media/media.gyp:media_unittests',
            '../printing/printing.gyp:printing_unittests',
            '../remoting/remoting.gyp:remoting_unittests',
            '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
            'temp_gyp/googleurl.gyp:googleurl_unittests',
          ],
        },
        {
          'target_name': 'chromium_builder_rel',
          'type': 'none',
          'dependencies': [
            '../app/app.gyp:app_unittests',
            '../chrome/chrome.gyp:browser_tests',
            '../chrome/chrome.gyp:memory_test',
            '../chrome/chrome.gyp:nacl_ui_tests',
            '../chrome/chrome.gyp:page_cycler_tests',
            '../chrome/chrome.gyp:plugin_tests',
            '../chrome/chrome.gyp:startup_tests',
            '../chrome/chrome.gyp:sync_unit_tests',
            '../chrome/chrome.gyp:tab_switching_test',
            '../chrome/chrome.gyp:ui_tests',
            '../chrome/chrome.gyp:unit_tests',
            '../chrome/chrome.gyp:url_fetch_test',
            '../gfx/gfx.gyp:gfx_unittests',
            '../gpu/gpu.gyp:gpu_unittests',
            '../ipc/ipc.gyp:ipc_tests',
            '../jingle/jingle.gyp:notifier_unit_tests',
            '../media/media.gyp:media_unittests',
            '../printing/printing.gyp:printing_unittests',
            '../remoting/remoting.gyp:remoting_unittests',
            '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
            'temp_gyp/googleurl.gyp:googleurl_unittests',
          ],
        },
        {
          'target_name': 'chromium_builder_dbg_tsan_mac',
          'type': 'none',
          'dependencies': [
            '../base/base.gyp:base_unittests',
            'temp_gyp/googleurl.gyp:googleurl_unittests',
            '../net/net.gyp:net_unittests',
            '../ipc/ipc.gyp:ipc_tests',
            '../jingle/jingle.gyp:notifier_unit_tests',
            '../media/media.gyp:media_unittests',
            '../printing/printing.gyp:printing_unittests',
            '../remoting/remoting.gyp:remoting_unittests',
            '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
          ],
        },
      ],  # targets
    }], # OS="mac"
    ['OS=="win"', {
      'targets': [
        # These targets are here so the build bots can use them to build
        # subsets of a full tree for faster cycle times.
        {
          'target_name': 'chromium_builder',
          'type': 'none',
          'dependencies': [
            '../app/app.gyp:app_unittests',
            '../chrome/chrome.gyp:browser_tests',
            '../chrome/chrome.gyp:installer_util_unittests',
            '../chrome/chrome.gyp:interactive_ui_tests',
            '../chrome/chrome.gyp:memory_test',
            '../chrome/chrome.gyp:mini_installer_test',
            '../chrome/chrome.gyp:nacl_ui_tests',
            '../chrome/chrome.gyp:page_cycler_tests',
            '../chrome/chrome.gyp:plugin_tests',
            '../chrome/chrome.gyp:selenium_tests',
            '../chrome/chrome.gyp:startup_tests',
            '../chrome/chrome.gyp:sync_unit_tests',
            '../chrome/chrome.gyp:tab_switching_test',
            '../chrome/chrome.gyp:ui_tests',
            '../chrome/chrome.gyp:unit_tests',
            '../chrome/chrome.gyp:url_fetch_test',
            # mini_installer_tests depends on mini_installer. This should be
            # defined in installer.gyp.
            '../chrome/installer/mini_installer.gyp:mini_installer',
            '../courgette/courgette.gyp:courgette_unittests',
            '../gfx/gfx.gyp:gfx_unittests',
            '../gpu/gpu.gyp:gpu_unittests',
            '../ipc/ipc.gyp:ipc_tests',
            '../jingle/jingle.gyp:notifier_unit_tests',
            '../media/media.gyp:media_unittests',
            '../printing/printing.gyp:printing_unittests',
            '../remoting/remoting.gyp:remoting_unittests',
            '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
            '../webkit/support/webkit_support.gyp:npapi_layout_test_plugin',
            # TODO(nsylvain) ui_tests.exe depends on test_shell_common.
            # This should:
            # 1) not be the case. OR.
            # 2) be expressed in the ui tests dependencies.
            '../webkit/webkit.gyp:test_shell_common',
            'temp_gyp/googleurl.gyp:googleurl_unittests',
            '../chrome_frame/chrome_frame.gyp:chrome_frame_net_tests',
            '../chrome_frame/chrome_frame.gyp:chrome_frame_perftests',
            '../chrome_frame/chrome_frame.gyp:chrome_frame_reliability_tests',
            '../chrome_frame/chrome_frame.gyp:chrome_frame_tests',
            '../chrome_frame/chrome_frame.gyp:chrome_frame_unittests',
            '../chrome_frame/chrome_frame.gyp:npchrome_frame',
            '../third_party/angle/src/build_angle.gyp:*',
          ],
        },
        {
          'target_name': 'chromium_builder_dbg_tsan_win',
          'type': 'none',
          'dependencies': [
            '../app/app.gyp:app_unittests',
            # TODO(bradnelson): app_unittests should depend on locales.
            # However, we can't add dependencies on chrome/ to app/
            # See http://crbug.com/43603
            '../base/base.gyp:base_unittests',
            '../chrome/app/locales/locales.gyp:*',
            '../chrome/chrome.gyp:sync_unit_tests',
            '../ipc/ipc.gyp:ipc_tests',
            '../jingle/jingle.gyp:notifier_unit_tests',
            '../media/media.gyp:media_unittests',
            '../net/net.gyp:net_unittests',
            '../printing/printing.gyp:printing_unittests',
            '../remoting/remoting.gyp:remoting_unittests',
            '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
            'temp_gyp/googleurl.gyp:googleurl_unittests',
          ],
        },
      ],  # targets
    }], # OS="win"
    ['chromeos==1', {
      'targets': [
        {
          'target_name': 'chromeos_builder',
          'type': 'none',
          'sources': [
            # TODO(bradnelson): This is here to work around gyp issue 137.
            #     Remove this sources list when that issue has been fixed.
            'all.gyp',
          ],
          'dependencies': [
            '../app/app.gyp:app_unittests',
            '../base/base.gyp:base_unittests',
            '../chrome/chrome.gyp:browser_tests',
            '../chrome/chrome.gyp:chrome',
            '../chrome/chrome.gyp:interactive_ui_tests',
            '../chrome/chrome.gyp:memory_test',
            '../chrome/chrome.gyp:page_cycler_tests',
            '../chrome/chrome.gyp:startup_tests',
            '../chrome/chrome.gyp:sync_unit_tests',
            '../chrome/chrome.gyp:tab_switching_test',
            '../chrome/chrome.gyp:ui_tests',
            '../chrome/chrome.gyp:unit_tests',
            '../chrome/chrome.gyp:url_fetch_test',
            '../gfx/gfx.gyp:gfx_unittests',
            '../ipc/ipc.gyp:ipc_tests',
            '../jingle/jingle.gyp:notifier_unit_tests',
            '../media/media.gyp:ffmpeg_tests',
            '../media/media.gyp:media_unittests',
            '../media/media.gyp:omx_test',
            '../net/net.gyp:net_unittests',
            '../printing/printing.gyp:printing_unittests',
            '../remoting/remoting.gyp:remoting_unittests',
            '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
            'temp_gyp/googleurl.gyp:googleurl_unittests',
            '../chrome/browser/chromeos/input_method/candidate_window.gyp:candidate_window',
          ],
        },
      ],  # targets
    }], # "chromeos==1"
  ], # conditions
}

# Local Variables:
# tab-width:2
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=2 shiftwidth=2:
<|endoftext|>


<commit_before>{
  'target_defaults': {
    'configurations': {
      'Debug': {
        'defines': [ 'DEBUG', '_DEBUG' ]
      },
      'Release': {
        'defines': [ 'NDEBUG' ]
      }
    }
  },
  'targets': [
    {
      'target_name': 'uv',
      'type': 'static_library',
      'include_dirs': [ '../include' ],
      'direct_dependent_settings': {
        'include_dirs': [ '../include' ],
      },
      'defines': [
        'HAVE_CONFIG_H'
      ],
      'sources': [
        '../src/uv-common.c',
        '../src/ares/ares__close_sockets.c',
        '../src/ares/ares__get_hostent.c',
        '../src/ares/ares__read_line.c',
        '../src/ares/ares__timeval.c',
        '../src/ares/ares_cancel.c',
        '../src/ares/ares_data.c',
        '../src/ares/ares_destroy.c',
        '../src/ares/ares_expand_name.c',
        '../src/ares/ares_expand_string.c',
        '../src/ares/ares_fds.c',
        '../src/ares/ares_free_hostent.c',
        '../src/ares/ares_free_string.c',
        '../src/ares/ares_gethostbyaddr.c',
        '../src/ares/ares_gethostbyname.c',
        '../src/ares/ares_getnameinfo.c',
        '../src/ares/ares_getopt.c',
        '../src/ares/ares_getsock.c',
        '../src/ares/ares_init.c',
        '../src/ares/ares_library_init.c',
        '../src/ares/ares_llist.c',
        '../src/ares/ares_mkquery.c',
        '../src/ares/ares_nowarn.c',
        '../src/ares/ares_options.c',
        '../src/ares/ares_parse_a_reply.c',
        '../src/ares/ares_parse_aaaa_reply.c',
        '../src/ares/ares_parse_mx_reply.c',
        '../src/ares/ares_parse_ns_reply.c',
        '../src/ares/ares_parse_ptr_reply.c',
        '../src/ares/ares_parse_srv_reply.c',
        '../src/ares/ares_parse_txt_reply.c',
        '../src/ares/ares_process.c',
        '../src/ares/ares_query.c',
        '../src/ares/ares_search.c',
        '../src/ares/ares_send.c',
        '../src/ares/ares_strcasecmp.c',
        '../src/ares/ares_strdup.c',
        '../src/ares/ares_strerror.c',
        '../src/ares/ares_timeout.c',
        '../src/ares/ares_version.c',
        '../src/ares/ares_writev.c',
        '../src/ares/bitncmp.c',
        '../src/ares/inet_net_pton.c',
        '../src/ares/inet_ntop.c',
      ],
      'conditions': [
        [ 'OS=="win"', {
          'include_dirs': [
            '../src/ares/config_win32'
          ],
          'sources': [ '../src/ares/windows_port.c' ],
          'defines': [
            '_WIN32_WINNT=0x0502',
            'EIO_STACKSIZE=262144',
            '_GNU_SOURCE',
          ],
          'sources': [
            '../src/win/async.c',
            '../src/win/cares.c',
            '../src/win/core.c',
            '../src/win/error.c',
            '../src/win/getaddrinfo.c',
            '../src/win/handle.c',
            '../src/win/loop-watcher.c',
            '../src/win/pipe.c',
            '../src/win/process.c',
            '../src/win/req.c',
            '../src/win/stdio.c',
            '../src/win/stream.c',
            '../src/win/tcp.c',
            '../src/win/timer.c',
            '../src/win/util.c',
          ]
        }, { # Not Windows i.e. POSIX
          'cflags': [
            '-g',
            '--std=gnu89',
            '-pedantic',
            '-Wall',
            '-Wextra',
            '-Wno-unused-parameter'
          ],
          'sources': [
            '../src/uv-eio.c',
            '../src/eio/eio.c',
            '../src/uv-unix.c',
            '../src/ev/ev.c',
          ],
          'include_dirs': [
            '../src/ev'
          ],
          'defines': [
            '_LARGEFILE_SOURCE',
            '_FILE_OFFSET_BITS=64',
            '_GNU_SOURCE',
            'EIO_STACKSIZE=262144'
          ],
          'libraries': [ '-lm' ]
        }],
        [ 'OS=="mac"', {
          'include_dirs': [ '../src/ares/config_darwin' ],
          'sources': [ '../src/uv-darwin.c' ],
          'direct_dependent_settings': {
            'libraries': [ '-framework CoreServices' ],
          },
          'defines': [
            'EV_CONFIG_H="config_darwin.h"',
            'EIO_CONFIG_H="config_darwin.h"',
          ]
        }],
        [ 'OS=="linux"', {
          'include_dirs': [ '../src/ares/config_linux' ],
          'sources': [ '../src/uv-linux.c' ],
          'defines': [
            'EV_CONFIG_H="config_linux.h"',
            'EIO_CONFIG_H="config_linux.h"',
          ],
          'direct_dependent_settings': {
            'libraries': [ '-lrt' ],
          },
        }],
        # TODO add OS=='sun'
      ]
    },

    {
      'target_name': 'run-tests',
      'type': 'executable',
      'dependencies': [ 'uv' ],
      'sources': [
        '../test/runner.c',
        '../test/run-tests.c',
        '../test/test-async.c',
        '../test/echo-server.c',
        '../test/test-callback-stack.c',
        '../test/test-connection-fail.c',
        '../test/test-delayed-accept.c',
        '../test/test-fail-always.c',
        '../test/test-get-currentexe.c',
        '../test/test-getaddrinfo.c',
        '../test/test-gethostbyname.c',
        '../test/test-getsockname.c',
        '../test/test-hrtime.c',
        '../test/test-idle.c',
        '../test/test-loop-handles.c',
        '../test/test-pass-always.c',
        '../test/test-ping-pong.c',
        '../test/test-pipe-bind-error.c',
        '../test/test-ref.c',
        '../test/test-shutdown-eof.c',
        '../test/test-spawn.c',
        '../test/test-tcp-bind-error.c',
        '../test/test-tcp-bind6-error.c',
        '../test/test-tcp-writealot.c',
        '../test/test-timer-again.c',
        '../test/test-timer.c',
      ],
      'conditions': [
        [ 'OS=="win"', {
          'sources': [ '../test/runner-win.c' ],
          'libraries': [ 'ws2_32.lib' ]
        }, { # POSIX
          'defines': [ '_GNU_SOURCE' ],
          'ldflags': [ '-pthread' ],
          'sources': [ '../test/runner-unix.c' ]
        }]
      ]
    },

    {
      'target_name': 'run-benchmarks',
      'type': 'executable',
      'dependencies': [ 'uv' ],
      'sources': [
        '../test/runner.c',
        '../test/run-benchmarks.c',
        '../test/echo-server.c',
        '../test/dns-server.c',
        '../test/benchmark-ares.c',
        '../test/benchmark-getaddrinfo.c',
        '../test/benchmark-ping-pongs.c',
        '../test/benchmark-pump.c',
        '../test/benchmark-sizes.c',
        '../test/benchmark-spawn.c'
      ],
      'conditions': [
        [ 'OS=="win"', {
          'sources': [ '../test/runner-win.c' ],
          'libraries': [ 'ws2_32.lib' ]
        }, { # POSIX
          'defines': [ '_GNU_SOURCE' ],
          'ldflags': [ '-pthread' ],
          'sources': [ '../test/runner-unix.c' ]
        }]
      ]
    }
  ]
}

<commit_msg>Add pound benchmark.<commit_after>{
  'target_defaults': {
    'configurations': {
      'Debug': {
        'defines': [ 'DEBUG', '_DEBUG' ]
      },
      'Release': {
        'defines': [ 'NDEBUG' ]
      }
    }
  },
  'targets': [
    {
      'target_name': 'uv',
      'type': 'static_library',
      'include_dirs': [ '../include' ],
      'direct_dependent_settings': {
        'include_dirs': [ '../include' ],
      },
      'defines': [
        'HAVE_CONFIG_H'
      ],
      'sources': [
        '../src/uv-common.c',
        '../src/ares/ares__close_sockets.c',
        '../src/ares/ares__get_hostent.c',
        '../src/ares/ares__read_line.c',
        '../src/ares/ares__timeval.c',
        '../src/ares/ares_cancel.c',
        '../src/ares/ares_data.c',
        '../src/ares/ares_destroy.c',
        '../src/ares/ares_expand_name.c',
        '../src/ares/ares_expand_string.c',
        '../src/ares/ares_fds.c',
        '../src/ares/ares_free_hostent.c',
        '../src/ares/ares_free_string.c',
        '../src/ares/ares_gethostbyaddr.c',
        '../src/ares/ares_gethostbyname.c',
        '../src/ares/ares_getnameinfo.c',
        '../src/ares/ares_getopt.c',
        '../src/ares/ares_getsock.c',
        '../src/ares/ares_init.c',
        '../src/ares/ares_library_init.c',
        '../src/ares/ares_llist.c',
        '../src/ares/ares_mkquery.c',
        '../src/ares/ares_nowarn.c',
        '../src/ares/ares_options.c',
        '../src/ares/ares_parse_a_reply.c',
        '../src/ares/ares_parse_aaaa_reply.c',
        '../src/ares/ares_parse_mx_reply.c',
        '../src/ares/ares_parse_ns_reply.c',
        '../src/ares/ares_parse_ptr_reply.c',
        '../src/ares/ares_parse_srv_reply.c',
        '../src/ares/ares_parse_txt_reply.c',
        '../src/ares/ares_process.c',
        '../src/ares/ares_query.c',
        '../src/ares/ares_search.c',
        '../src/ares/ares_send.c',
        '../src/ares/ares_strcasecmp.c',
        '../src/ares/ares_strdup.c',
        '../src/ares/ares_strerror.c',
        '../src/ares/ares_timeout.c',
        '../src/ares/ares_version.c',
        '../src/ares/ares_writev.c',
        '../src/ares/bitncmp.c',
        '../src/ares/inet_net_pton.c',
        '../src/ares/inet_ntop.c',
      ],
      'conditions': [
        [ 'OS=="win"', {
          'include_dirs': [
            '../src/ares/config_win32'
          ],
          'sources': [ '../src/ares/windows_port.c' ],
          'defines': [
            '_WIN32_WINNT=0x0502',
            'EIO_STACKSIZE=262144',
            '_GNU_SOURCE',
          ],
          'sources': [
            '../src/win/async.c',
            '../src/win/cares.c',
            '../src/win/core.c',
            '../src/win/error.c',
            '../src/win/getaddrinfo.c',
            '../src/win/handle.c',
            '../src/win/loop-watcher.c',
            '../src/win/pipe.c',
            '../src/win/process.c',
            '../src/win/req.c',
            '../src/win/stdio.c',
            '../src/win/stream.c',
            '../src/win/tcp.c',
            '../src/win/timer.c',
            '../src/win/util.c',
          ]
        }, { # Not Windows i.e. POSIX
          'cflags': [
            '-g',
            '--std=gnu89',
            '-pedantic',
            '-Wall',
            '-Wextra',
            '-Wno-unused-parameter'
          ],
          'sources': [
            '../src/uv-eio.c',
            '../src/eio/eio.c',
            '../src/uv-unix.c',
            '../src/ev/ev.c',
          ],
          'include_dirs': [
            '../src/ev'
          ],
          'defines': [
            '_LARGEFILE_SOURCE',
            '_FILE_OFFSET_BITS=64',
            '_GNU_SOURCE',
            'EIO_STACKSIZE=262144'
          ],
          'libraries': [ '-lm' ]
        }],
        [ 'OS=="mac"', {
          'include_dirs': [ '../src/ares/config_darwin' ],
          'sources': [ '../src/uv-darwin.c' ],
          'direct_dependent_settings': {
            'libraries': [ '-framework CoreServices' ],
          },
          'defines': [
            'EV_CONFIG_H="config_darwin.h"',
            'EIO_CONFIG_H="config_darwin.h"',
          ]
        }],
        [ 'OS=="linux"', {
          'include_dirs': [ '../src/ares/config_linux' ],
          'sources': [ '../src/uv-linux.c' ],
          'defines': [
            'EV_CONFIG_H="config_linux.h"',
            'EIO_CONFIG_H="config_linux.h"',
          ],
          'direct_dependent_settings': {
            'libraries': [ '-lrt' ],
          },
        }],
        # TODO add OS=='sun'
      ]
    },

    {
      'target_name': 'run-tests',
      'type': 'executable',
      'dependencies': [ 'uv' ],
      'sources': [
        '../test/runner.c',
        '../test/run-tests.c',
        '../test/test-async.c',
        '../test/echo-server.c',
        '../test/test-callback-stack.c',
        '../test/test-connection-fail.c',
        '../test/test-delayed-accept.c',
        '../test/test-fail-always.c',
        '../test/test-get-currentexe.c',
        '../test/test-getaddrinfo.c',
        '../test/test-gethostbyname.c',
        '../test/test-getsockname.c',
        '../test/test-hrtime.c',
        '../test/test-idle.c',
        '../test/test-loop-handles.c',
        '../test/test-pass-always.c',
        '../test/test-ping-pong.c',
        '../test/test-pipe-bind-error.c',
        '../test/test-ref.c',
        '../test/test-shutdown-eof.c',
        '../test/test-spawn.c',
        '../test/test-tcp-bind-error.c',
        '../test/test-tcp-bind6-error.c',
        '../test/test-tcp-writealot.c',
        '../test/test-timer-again.c',
        '../test/test-timer.c',
      ],
      'conditions': [
        [ 'OS=="win"', {
          'sources': [ '../test/runner-win.c' ],
          'libraries': [ 'ws2_32.lib' ]
        }, { # POSIX
          'defines': [ '_GNU_SOURCE' ],
          'ldflags': [ '-pthread' ],
          'sources': [ '../test/runner-unix.c' ]
        }]
      ]
    },

    {
      'target_name': 'run-benchmarks',
      'type': 'executable',
      'dependencies': [ 'uv' ],
      'sources': [
        '../test/runner.c',
        '../test/run-benchmarks.c',
        '../test/echo-server.c',
        '../test/dns-server.c',
        '../test/benchmark-ares.c',
        '../test/benchmark-getaddrinfo.c',
        '../test/benchmark-ping-pongs.c',
        '../test/benchmark-pound.c',
        '../test/benchmark-pump.c',
        '../test/benchmark-sizes.c',
        '../test/benchmark-spawn.c'
      ],
      'conditions': [
        [ 'OS=="win"', {
          'sources': [ '../test/runner-win.c' ],
          'libraries': [ 'ws2_32.lib' ]
        }, { # POSIX
          'defines': [ '_GNU_SOURCE' ],
          'ldflags': [ '-pthread' ],
          'sources': [ '../test/runner-unix.c' ]
        }]
      ]
    }
  ]
}

<|endoftext|>