Unify "script" and "project" under "util".

This commit is contained in:
Bob Nystrom
2015-09-22 07:45:58 -07:00
parent 2f9ba2beaa
commit 36f7d74183
17 changed files with 29 additions and 182 deletions
+353
View File
@@ -0,0 +1,353 @@
#!/usr/bin/env python
from __future__ import print_function
import argparse
import math
import os
import os.path
import re
import subprocess
import sys
# Runs the benchmarks.
#
# It runs several benchmarks across several languages. For each
# benchmark/language pair, it runs a number of trials. Each trial is one run of
# a single benchmark script. It spawns a process and runs the script. The
# script itself is expected to output some result which this script validates
# to ensure the benchmark is running correctly. Then the benchmark prints an
# elapsed time. The benchmark is expected to do the timing itself and only time
# the interesting code under test.
#
# This script then runs several trials and takes the best score. (It does
# multiple trials to account for random variance in running time coming from
# OS, CPU rate-limiting, etc.) It takes the best time on the assumption that
# that represents the language's ideal performance and any variance coming from
# the OS will just slow it down.
#
# After running a series of trials the benchmark runner will compare all of the
# language's performance for a given benchmark. It compares by running time
# and score, which is just the inverse running time.
#
# For Wren benchmarks, it can also compare against a "baseline". That's a
# recorded result of a previous run of the Wren benchmarks. This is useful --
# critical, actually -- for seeing how Wren performance changes. Generating a
# set of baselines before a change to the VM and then comparing those to the
# performance after a change is how we track improvements and regressions.
#
# To generate a baseline file, run this script with "--generate-baseline".
WREN_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
WREN_BIN = os.path.join(WREN_DIR, 'bin')
BENCHMARK_DIR = os.path.join(WREN_DIR, 'test', 'benchmark')
# How many times to run a given benchmark.
NUM_TRIALS = 10
BENCHMARKS = []
def BENCHMARK(name, pattern):
regex = re.compile(pattern + "\n" + r"elapsed: (\d+\.\d+)", re.MULTILINE)
BENCHMARKS.append([name, regex, None])
BENCHMARK("binary_trees", """stretch tree of depth 13 check: -1
8192 trees of depth 4 check: -8192
2048 trees of depth 6 check: -2048
512 trees of depth 8 check: -512
128 trees of depth 10 check: -128
32 trees of depth 12 check: -32
long lived tree of depth 12 check: -1""")
BENCHMARK("delta_blue", "14065400")
BENCHMARK("fib", r"""317811
317811
317811
317811
317811""")
BENCHMARK("fibers", r"""4999950000""")
BENCHMARK("for", r"""499999500000""")
BENCHMARK("method_call", r"""true
false""")
BENCHMARK("map_numeric", r"""500000500000""")
BENCHMARK("map_string", r"""12799920000""")
BENCHMARK("string_equals", r"""3000000""")
LANGUAGES = [
("wren", [os.path.join(WREN_BIN, 'wren')], ".wren"),
("lua", ["lua"], ".lua"),
("luajit (-joff)", ["luajit", "-joff"], ".lua"),
("python", ["python"], ".py"),
("python3", ["python3"], ".py"),
("ruby", ["ruby"], ".rb")
]
results = {}
if sys.platform == 'win32':
GREEN = NORMAL = RED = YELLOW = ''
else:
GREEN = '\033[32m'
NORMAL = '\033[0m'
RED = '\033[31m'
YELLOW = '\033[33m'
def green(text):
return GREEN + text + NORMAL
def red(text):
return RED + text + NORMAL
def yellow(text):
return YELLOW + text + NORMAL
def get_score(time):
"""
Converts time into a "score". This is the inverse of the time with an
arbitrary scale applied to get the number in a nice range. The goal here is
to have benchmark results where faster = bigger number.
"""
return 1000.0 / time
def standard_deviation(times):
"""
Calculates the standard deviation of a list of numbers.
"""
mean = sum(times) / len(times)
# Sum the squares of the differences from the mean.
result = 0
for time in times:
result += (time - mean) ** 2
return math.sqrt(result / len(times))
def run_trial(benchmark, language):
"""Runs one benchmark one time for one language."""
args = []
args.extend(language[1])
args.append(os.path.join(BENCHMARK_DIR, benchmark[0] + language[2]))
try:
out = subprocess.check_output(args, universal_newlines=True)
except OSError:
print('Interpreter was not found')
return None
match = benchmark[1].match(out)
if match:
return float(match.group(1))
else:
print("Incorrect output:")
print(out)
return None
def run_benchmark_language(benchmark, language, benchmark_result):
"""
Runs one benchmark for a number of trials for one language.
Adds the result to benchmark_result, which is a map of language names to
results.
"""
name = "{0} - {1}".format(benchmark[0], language[0])
print("{0:30s}".format(name), end=' ')
if not os.path.exists(os.path.join(
BENCHMARK_DIR, benchmark[0] + language[2])):
print("No implementation for this language")
return
times = []
for i in range(0, NUM_TRIALS):
sys.stdout.flush()
time = run_trial(benchmark, language)
if not time:
return
times.append(time)
sys.stdout.write(".")
best = min(times)
score = get_score(best)
comparison = ""
if language[0] == "wren":
if benchmark[2] != None:
ratio = 100 * score / benchmark[2]
comparison = "{:6.2f}% relative to baseline".format(ratio)
if ratio > 105:
comparison = green(comparison)
if ratio < 95:
comparison = red(comparison)
else:
comparison = "no baseline"
else:
# Hack: assumes wren gets run first.
wren_score = benchmark_result["wren"]["score"]
ratio = 100.0 * wren_score / score
comparison = "{:6.2f}%".format(ratio)
if ratio > 105:
comparison = green(comparison)
if ratio < 95:
comparison = red(comparison)
print(" {:4.2f}s {:4.4f} {:s}".format(
best,
standard_deviation(times),
comparison))
benchmark_result[language[0]] = {
"desc": name,
"times": times,
"score": score
}
return score
def run_benchmark(benchmark, languages, graph):
"""Runs one benchmark for the given languages (or all of them)."""
benchmark_result = {}
results[benchmark[0]] = benchmark_result
num_languages = 0
for language in LANGUAGES:
if not languages or language[0] in languages:
num_languages += 1
run_benchmark_language(benchmark, language, benchmark_result)
if num_languages > 1 and graph:
graph_results(benchmark_result)
def graph_results(benchmark_result):
print()
INCREMENT = {
'-': 'o',
'o': 'O',
'O': '0',
'0': '0'
}
# Scale everything by the highest score.
highest = 0
for language, result in benchmark_result.items():
score = get_score(min(result["times"]))
if score > highest: highest = score
print("{0:30s}0 {1:66.0f}".format("", highest))
for language, result in benchmark_result.items():
line = ["-"] * 68
for time in result["times"]:
index = int(get_score(time) / highest * 67)
line[index] = INCREMENT[line[index]]
print("{0:30s}{1}".format(result["desc"], "".join(line)))
print()
def read_baseline():
baseline_file = os.path.join(BENCHMARK_DIR, "baseline.txt")
if os.path.exists(baseline_file):
with open(baseline_file) as f:
for line in f.readlines():
name, best = line.split(",")
for benchmark in BENCHMARKS:
if benchmark[0] == name:
benchmark[2] = float(best)
def generate_baseline():
print("generating baseline")
baseline_text = ""
for benchmark in BENCHMARKS:
best = run_benchmark_language(benchmark, LANGUAGES[0], {})
baseline_text += ("{},{}\n".format(benchmark[0], best))
# Write them to a file.
baseline_file = os.path.join(BENCHMARK_DIR, "baseline.txt")
with open(baseline_file, 'w') as out:
out.write(baseline_text)
def print_html():
'''Print the results as an HTML chart.'''
def print_benchmark(benchmark, name):
print('<h3>{}</h3>'.format(name))
print('<table class="chart">')
# Scale everything by the highest time.
highest = 0
for language, result in results[benchmark].items():
time = min(result["times"])
if time > highest: highest = time
languages = sorted(results[benchmark].keys(),
key=lambda lang: results[benchmark][lang]["score"], reverse=True)
for language in languages:
result = results[benchmark][language]
time = float(min(result["times"]))
ratio = int(100 * time / highest)
css_class = "chart-bar"
if language == "wren":
css_class += " wren"
print(' <tr>')
print(' <th>{}</th><td><div class="{}" style="width: {}%;">{:4.2f}s&nbsp;</div></td>'.format(
language, css_class, ratio, time))
print(' </tr>')
print('</table>')
print_benchmark("method_call", "Method Call")
print_benchmark("delta_blue", "DeltaBlue")
print_benchmark("binary_trees", "Binary Trees")
print_benchmark("fib", "Recursive Fibonacci")
def main():
parser = argparse.ArgumentParser(description="Run the benchmarks")
parser.add_argument("benchmark", nargs='?',
default="all",
help="The benchmark to run")
parser.add_argument("--generate-baseline",
action="store_true",
help="Generate a baseline file")
parser.add_argument("--graph",
action="store_true",
help="Display graph results.")
parser.add_argument("-l", "--language",
action="append",
help="Which language(s) to run benchmarks for")
parser.add_argument("--output-html",
action="store_true",
help="Output the results chart as HTML")
args = parser.parse_args()
if args.generate_baseline:
generate_baseline()
return
read_baseline()
# Run the benchmarks.
for benchmark in BENCHMARKS:
if benchmark[0] == args.benchmark or args.benchmark == "all":
run_benchmark(benchmark, args.language, args.graph)
if args.output_html:
print_html()
main()
+59
View File
@@ -0,0 +1,59 @@
#!/usr/bin/env python
import sys
from os.path import basename, dirname, join, realpath
from glob import iglob
import re
INCLUDE_PATTERN = re.compile(r'^\s*#include "([\w.]+)"')
GUARD_PATTERN = re.compile(r'^#ifndef wren(_\w+)?_h$')
WREN_DIR = dirname(dirname(realpath(__file__)))
seen_files = set()
out = sys.stdout
# Prints a plain text file, adding comment markers.
def add_comment_file(filename):
with open(filename, 'r') as f:
for line in f:
out.write('// ')
out.write(line)
# Prints the given C source file, recursively resolving local #includes.
def add_file(filename):
bname = basename(filename)
# Only include each file at most once.
if bname in seen_files:
return
once = False
path = dirname(filename)
out.write('// Begin file "{0}"\n'.format(filename))
with open(filename, 'r') as f:
for line in f:
m = INCLUDE_PATTERN.match(line)
if m:
add_file(join(path, m.group(1)))
else:
out.write(line)
if GUARD_PATTERN.match(line):
once = True
out.write('// End file "{0}"\n'.format(filename))
# Only skip header files which use #ifndef guards.
# This is necessary because of the X Macro technique.
if once:
seen_files.add(bname)
# Print license on top.
add_comment_file(join(WREN_DIR, 'LICENSE'))
out.write('\n')
# Source files.
add_file(join(WREN_DIR, 'src', 'include', 'wren.h'))
# Must be included here because of conditional compilation.
add_file(join(WREN_DIR, 'src', 'vm', 'wren_debug.h'))
for f in iglob(join(WREN_DIR, 'src', 'vm', '*.c')):
add_file(f)
+154
View File
@@ -0,0 +1,154 @@
#!/usr/bin/env python
import codecs
import glob
import fnmatch
import os
import shutil
import subprocess
import sys
import time
import re
from datetime import datetime
import markdown
# Match a "## " style header. We require a space after "#" to avoid
# accidentally matching "#include" in code samples.
MARKDOWN_HEADER = re.compile(r'#+ ')
# Clean up a header to be a valid URL.
FORMAT_ANCHOR = re.compile(r'\.|\?|!|:|/|\*')
with codecs.open("doc/site/template.html", encoding="utf-8") as f:
template = f.read()
with codecs.open("doc/site/template-core.html", encoding="utf-8") as f:
template_core = f.read()
def ensure_dir(path):
if not os.path.exists(path):
os.mkdir(path)
def is_up_to_date(path, out_path):
# See if it's up to date.
source_mod = os.path.getmtime(path)
source_mod = max(source_mod, os.path.getmtime('doc/site/template.html'))
dest_mod = 0
if os.path.exists(out_path):
dest_mod = os.path.getmtime(out_path)
return source_mod < dest_mod
def format_file(path, skip_up_to_date):
basename = os.path.basename(path)
basename = basename.split('.')[0]
in_path = os.path.join('doc/site', path)
out_path = "build/docs/" + os.path.splitext(path)[0] + ".html"
if skip_up_to_date and is_up_to_date(in_path, out_path):
# It's up to date.
return
title = ""
category = ""
# Read the markdown file and preprocess it.
contents = ""
with codecs.open(in_path, "r", encoding="utf-8") as input:
# Read each line, preprocessing the special codes.
for line in input:
stripped = line.lstrip()
indentation = line[:len(line) - len(stripped)]
if stripped.startswith("^"):
command,_,args = stripped.rstrip("\n").lstrip("^").partition(" ")
args = args.strip()
if command == "title":
title = args
elif command == "category":
category = args
else:
print(' '.join(["UNKNOWN COMMAND:", command, args]))
elif MARKDOWN_HEADER.match(stripped):
# Add anchors to the headers.
index = stripped.find(" ")
headertype = stripped[:index]
header = stripped[index:].strip()
anchor = header.lower().replace(' ', '-')
anchor = FORMAT_ANCHOR.sub('', anchor)
contents += indentation + headertype
contents += '{1} <a href="#{0}" name="{0}" class="header-anchor">#</a>\n'.format(anchor, header)
else:
contents = contents + line
html = markdown.markdown(contents, ['def_list', 'codehilite'])
modified = datetime.fromtimestamp(os.path.getmtime(in_path))
mod_str = modified.strftime('%B %d, %Y')
page_template = template
if category == 'core':
page_template = template_core
fields = {
'title': title,
'html': html,
'mod': mod_str,
'category': category
}
# Write the html output.
ensure_dir(os.path.dirname(out_path))
with codecs.open(out_path, "w", encoding="utf-8") as out:
out.write(page_template.format(**fields))
print("converted " + path)
def check_sass():
source_mod = os.path.getmtime('doc/site/style.scss')
dest_mod = 0
if os.path.exists('build/docs/style.css'):
dest_mod = os.path.getmtime('build/docs/style.css')
if source_mod < dest_mod:
return
subprocess.call(['sass', 'doc/site/style.scss', 'build/docs/style.css'])
print("built css")
def format_files(skip_up_to_date):
check_sass()
for root, dirnames, filenames in os.walk('doc/site'):
for filename in fnmatch.filter(filenames, '*.markdown'):
f = os.path.relpath(os.path.join(root, filename), 'doc/site')
format_file(f, skip_up_to_date)
# Clean the output directory.
if os.path.exists("build/docs"):
shutil.rmtree("build/docs")
ensure_dir("build/docs")
# Process each markdown file.
format_files(False)
# Watch files.
if len(sys.argv) == 2 and sys.argv[1] == '--watch':
while True:
format_files(True)
time.sleep(0.3)
Executable
+174
View File
@@ -0,0 +1,174 @@
#!/usr/bin/env python
# Downloads and compiles libuv.
from __future__ import print_function
import os
import os.path
import platform
import shutil
import subprocess
import sys
LIB_UV_VERSION = "v1.6.1"
LIB_UV_DIR = "deps/libuv"
def python2_binary():
"""Tries to find a python 2 executable"""
if sys.version_info.major == 2:
return sys.executable or "python"
else:
return "python2"
def ensure_dir(dir):
"""Creates dir if not already there."""
if os.path.isdir(dir):
return
os.makedirs(dir)
def remove_dir(dir):
"""Recursively removes dir."""
if platform.system() == "Windows":
# rmtree gives up on readonly files on Windows
# rd doesn't like paths with forward slashes
subprocess.check_call(
['cmd', '/c', 'rd', '/s', '/q', dir.replace('/', '\\')])
else:
shutil.rmtree(dir)
def download_libuv():
"""Clones libuv into deps/libuv and checks out the right version."""
# Delete it if already there so we ensure we get the correct version if the
# version number in this script changes.
if os.path.isdir(LIB_UV_DIR):
print("Cleaning output directory...")
remove_dir(LIB_UV_DIR)
ensure_dir("deps")
print("Cloning libuv...")
run([
"git", "clone", "--quiet", "--depth=1",
"https://github.com/libuv/libuv.git",
LIB_UV_DIR
])
print("Getting tags...")
run([
"git", "fetch", "--quiet", "--depth=1", "--tags"
], cwd=LIB_UV_DIR)
print("Checking out libuv " + LIB_UV_VERSION + "...")
run([
"git", "checkout", "--quiet", LIB_UV_VERSION
], cwd=LIB_UV_DIR)
# TODO: Pin gyp to a known-good commit. Update a previously downloaded gyp
# if it doesn't match that commit.
print("Downloading gyp...")
run([
"git", "clone", "--quiet", "--depth=1",
"https://chromium.googlesource.com/external/gyp.git",
LIB_UV_DIR + "/build/gyp"
])
def build_libuv_mac():
# Create the XCode project.
run([
python2_binary(), LIB_UV_DIR + "/gyp_uv.py", "-f", "xcode"
])
# Compile it.
# TODO: Support debug builds too.
run([
"xcodebuild",
# Build a 32-bit + 64-bit universal binary:
"ARCHS=i386 x86_64", "ONLY_ACTIVE_ARCH=NO",
"BUILD_DIR=out",
"-project", LIB_UV_DIR + "/uv.xcodeproj",
"-configuration", "Release",
"-target", "All"
])
def build_libuv_linux(arch):
# Set up the Makefile to build for the right architecture.
args = [python2_binary(), "gyp_uv.py", "-f", "make"]
if arch == "-32":
args.append("-Dtarget_arch=ia32")
elif arch == "-64":
args.append("-Dtarget_arch=x64")
run(args, cwd=LIB_UV_DIR)
run(["make", "-C", "out", "BUILDTYPE=Release"], cwd=LIB_UV_DIR)
def build_libuv_windows():
run(["cmd", "/c", "vcbuild.bat", "release"], cwd=LIB_UV_DIR)
def build_libuv(arch, out):
if platform.system() == "Darwin":
build_libuv_mac()
elif platform.system() == "Linux":
build_libuv_linux(arch)
elif platform.system() == "Windows":
build_libuv_windows()
else:
print("Unsupported platform: " + platform.system())
sys.exit(1)
# Copy the build library to the build directory for Mac and Linux where we
# support building for multiple architectures.
if platform.system() != "Windows":
ensure_dir(os.path.dirname(out))
shutil.copyfile(
os.path.join(LIB_UV_DIR, "out", "Release", "libuv.a"), out)
def run(args, cwd=None):
"""Spawn a process to invoke [args] and mute its output."""
try:
subprocess.check_output(args, cwd=cwd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as error:
print(error.output)
sys.exit(error.returncode)
def main():
expect_usage(len(sys.argv) >= 2)
if sys.argv[1] == "download":
download_libuv()
elif sys.argv[1] == "build":
expect_usage(len(sys.argv) <= 3)
arch = ""
if len(sys.argv) == 3:
arch = sys.argv[2]
out = os.path.join("build", "libuv" + arch + ".a")
build_libuv(arch, out)
else:
expect_usage(false)
def expect_usage(condition):
if (condition): return
print("Usage: libuv.py download")
print(" libuv.py build [-32|-64]")
sys.exit(1)
main()
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/env python
import glob
import fnmatch
import itertools
import os
import re
TODO_PATTERN = re.compile(r'\s*// TODO:')
DOC_PATTERN = re.compile(r'\s*//')
EXPECT_PATTERN = re.compile(r'// expect')
num_files = 0
num_docs = 0
num_code = 0
num_empty = 0
num_todos = 0
num_semicolons = 0
num_test_files = 0
num_test_todos = 0
num_expects = 0
num_test_empty = 0
num_test = 0
num_benchmark_files = 0
num_benchmark_todos = 0
num_benchmark_empty = 0
num_benchmark = 0
files = itertools.chain(glob.iglob("src/vm/*.[ch]"),
glob.iglob("src/include/*.[ch]"))
for source_path in files:
num_files += 1
with open(source_path, "r") as input:
for line in input:
num_semicolons += line.count(';')
match = TODO_PATTERN.match(line)
if match:
num_todos += 1
continue
match = DOC_PATTERN.match(line)
if match:
num_docs += 1
continue
stripped = line.strip()
# Don't count { or } lines since Wren's coding style puts them on their
# own lines but they don't add anything meaningful to the length of the
# program.
if (stripped == "" or stripped == "{" or stripped == "}"):
num_empty += 1
continue
num_code += 1
for dir_path, dir_names, file_names in os.walk("test"):
for file_name in fnmatch.filter(file_names, "*.wren"):
num_test_files += 1
with open(os.path.join(dir_path, file_name), "r") as input:
for line in input:
if (line.strip() == ""):
num_test_empty += 1
else:
num_test += 1
match = TODO_PATTERN.match(line)
if match:
num_test_todos += 1
continue
match = EXPECT_PATTERN.search(line)
if match:
num_expects += 1
continue
print("source:")
print(" files " + str(num_files))
print(" semicolons " + str(num_semicolons))
print(" TODOs " + str(num_todos))
print(" comment lines " + str(num_docs))
print(" code lines " + str(num_code))
print(" empty lines " + str(num_empty))
print("\n")
print("test:")
print(" files " + str(num_test_files))
print(" TODOs " + str(num_test_todos))
print(" expectations " + str(num_expects))
print(" non-empty lines " + str(num_test))
print(" empty lines " + str(num_test_empty))
+30
View File
@@ -0,0 +1,30 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wren", "wren\wren.vcxproj", "{EBF43135-4A7A-400A-8F23-DF49907025AA}"
ProjectSection(ProjectDependencies) = postProject
{89CF2C43-749E-4EC4-A7C3-3F22FBA9B874} = {89CF2C43-749E-4EC4-A7C3-3F22FBA9B874}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wren_lib", "wren_lib\wren_lib.vcxproj", "{89CF2C43-749E-4EC4-A7C3-3F22FBA9B874}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EBF43135-4A7A-400A-8F23-DF49907025AA}.Debug|Win32.ActiveCfg = Debug|Win32
{EBF43135-4A7A-400A-8F23-DF49907025AA}.Debug|Win32.Build.0 = Debug|Win32
{EBF43135-4A7A-400A-8F23-DF49907025AA}.Release|Win32.ActiveCfg = Release|Win32
{EBF43135-4A7A-400A-8F23-DF49907025AA}.Release|Win32.Build.0 = Release|Win32
{89CF2C43-749E-4EC4-A7C3-3F22FBA9B874}.Debug|Win32.ActiveCfg = Debug|Win32
{89CF2C43-749E-4EC4-A7C3-3F22FBA9B874}.Debug|Win32.Build.0 = Debug|Win32
{89CF2C43-749E-4EC4-A7C3-3F22FBA9B874}.Release|Win32.ActiveCfg = Release|Win32
{89CF2C43-749E-4EC4-A7C3-3F22FBA9B874}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
+104
View File
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{89CF2C43-749E-4EC4-A7C3-3F22FBA9B874}</ProjectGuid>
<RootNamespace>wren_lib</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)..\..\src\include;</IncludePath>
<TargetName>wren_static_d</TargetName>
<OutDir>$(SolutionDir)..\..\build\vs\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)..\..\src\include</IncludePath>
<TargetName>wren_static</TargetName>
<OutDir>$(SolutionDir)..\..\build\vs\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_LIB;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PreprocessorDefinitions>_LIB;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\src\vm\wren_compiler.c" />
<ClCompile Include="..\..\..\src\vm\wren_core.c" />
<ClCompile Include="..\..\..\src\vm\wren_debug.c" />
<ClCompile Include="..\..\..\src\vm\wren_io.c" />
<ClCompile Include="..\..\..\src\vm\wren_meta.c" />
<ClCompile Include="..\..\..\src\vm\wren_primitive.c" />
<ClCompile Include="..\..\..\src\vm\wren_utils.c" />
<ClCompile Include="..\..\..\src\vm\wren_value.c" />
<ClCompile Include="..\..\..\src\vm\wren_vm.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\src\vm\wren_common.h" />
<ClInclude Include="..\..\..\src\vm\wren_compiler.h" />
<ClInclude Include="..\..\..\src\vm\wren_core.h" />
<ClInclude Include="..\..\..\src\vm\wren_debug.h" />
<ClInclude Include="..\..\..\src\vm\wren_io.h" />
<ClInclude Include="..\..\..\src\vm\wren_meta.h" />
<ClInclude Include="..\..\..\src\vm\wren_primitive.h" />
<ClInclude Include="..\..\..\src\vm\wren_utils.h" />
<ClInclude Include="..\..\..\src\vm\wren_value.h" />
<ClInclude Include="..\..\..\src\vm\wren_vm.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\src\vm\wren_compiler.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\vm\wren_core.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\vm\wren_debug.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\vm\wren_io.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\vm\wren_utils.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\vm\wren_value.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\vm\wren_vm.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\vm\wren_meta.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\vm\wren_primitive.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\src\vm\wren_common.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\vm\wren_compiler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\vm\wren_core.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\vm\wren_debug.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\vm\wren_io.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\vm\wren_utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\vm\wren_value.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\vm\wren_vm.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\vm\wren_meta.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\vm\wren_primitive.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
Executable
+357
View File
@@ -0,0 +1,357 @@
#!/usr/bin/env python
from __future__ import print_function
from collections import defaultdict
from os import listdir
from os.path import abspath, basename, dirname, isdir, isfile, join, realpath, relpath, splitext
import re
from subprocess import Popen, PIPE
import sys
# Runs the tests.
WREN_DIR = dirname(dirname(realpath(__file__)))
WREN_APP = join(WREN_DIR, 'bin', 'wrend')
TEST_APP = join(WREN_DIR, 'build', 'debug', 'test', 'wrend')
EXPECT_PATTERN = re.compile(r'// expect: ?(.*)')
EXPECT_ERROR_PATTERN = re.compile(r'// expect error(?! line)')
EXPECT_ERROR_LINE_PATTERN = re.compile(r'// expect error line (\d+)')
EXPECT_RUNTIME_ERROR_PATTERN = re.compile(r'// expect runtime error: (.+)')
ERROR_PATTERN = re.compile(r'\[.* line (\d+)\] Error')
STACK_TRACE_PATTERN = re.compile(r'\[main line (\d+)\] in')
STDIN_PATTERN = re.compile(r'// stdin: (.*)')
SKIP_PATTERN = re.compile(r'// skip: (.*)')
NONTEST_PATTERN = re.compile(r'// nontest')
passed = 0
failed = 0
num_skipped = 0
skipped = defaultdict(int)
expectations = 0
class Test:
def __init__(self, path):
self.path = path
self.output = []
self.compile_errors = set()
self.runtime_error_line = 0
self.runtime_error_message = None
self.exit_code = 0
self.input_bytes = None
self.failures = []
def parse(self):
global num_skipped
global skipped
global expectations
input_lines = []
line_num = 1
with open(self.path, 'r') as file:
for line in file:
match = EXPECT_PATTERN.search(line)
if match:
self.output.append((match.group(1), line_num))
expectations += 1
match = EXPECT_ERROR_PATTERN.search(line)
if match:
self.compile_errors.add(line_num)
# If we expect a compile error, it should exit with EX_DATAERR.
self.exit_code = 65
expectations += 1
match = EXPECT_ERROR_LINE_PATTERN.search(line)
if match:
self.compile_errors.add(int(match.group(1)))
# If we expect a compile error, it should exit with EX_DATAERR.
self.exit_code = 65
expectations += 1
match = EXPECT_RUNTIME_ERROR_PATTERN.search(line)
if match:
self.runtime_error_line = line_num
self.runtime_error_message = match.group(1)
# If we expect a runtime error, it should exit with EX_SOFTWARE.
self.exit_code = 70
expectations += 1
match = STDIN_PATTERN.search(line)
if match:
input_lines.append(match.group(1) + '\n')
match = SKIP_PATTERN.search(line)
if match:
num_skipped += 1
skipped[match.group(1)] += 1
return False
match = NONTEST_PATTERN.search(line)
if match:
# Not a test file at all, so ignore it.
return False
line_num += 1
# If any input is fed to the test in stdin, concatetate it into one string.
if input_lines:
self.input_bytes = "".join(input_lines).encode("utf-8")
# If we got here, it's a valid test.
return True
def run(self, app, type):
# Invoke wren and run the test.
test_arg = self.path
if type == "api test":
# Just pass the suite name to API tests.
test_arg = basename(splitext(test_arg)[0])
proc = Popen([app, test_arg], stdin=PIPE, stdout=PIPE, stderr=PIPE)
(out, err) = proc.communicate(self.input_bytes)
self.validate(type == "example", proc.returncode, out, err)
def validate(self, is_example, exit_code, out, err):
if self.compile_errors and self.runtime_error_message:
self.fail("Test error: Cannot expect both compile and runtime errors.")
return
try:
out = out.decode("utf-8").replace('\r\n', '\n')
err = err.decode("utf-8").replace('\r\n', '\n')
except:
self.fail('Error decoding output.')
error_lines = err.split('\n')
# Validate that an expected runtime error occurred.
if self.runtime_error_message:
self.validate_runtime_error(error_lines)
else:
self.validate_compile_errors(error_lines)
self.validate_exit_code(exit_code, error_lines)
# Ignore output from examples.
if is_example: return
self.validate_output(out)
def validate_runtime_error(self, error_lines):
if len(error_lines) < 2:
self.fail('Expected runtime error "{0}" and got none.',
self.runtime_error_message)
return
# Make sure we got the right error.
if error_lines[0] != self.runtime_error_message:
self.fail('Expected runtime error "{0}" and got:',
self.runtime_error_message)
self.fail(error_lines[0])
# Make sure the stack trace has the right line. Skip over any lines that
# come from builtin libraries.
stack_lines = error_lines[1:]
for stack_line in stack_lines:
match = STACK_TRACE_PATTERN.search(stack_line)
if match: break
if not match:
self.fail('Expected stack trace and got:')
for stack_line in stack_lines:
self.fail(stack_line)
else:
stack_line = int(match.group(1))
if stack_line != self.runtime_error_line:
self.fail('Expected runtime error on line {0} but was on line {1}.',
self.runtime_error_line, stack_line)
def validate_compile_errors(self, error_lines):
# Validate that every compile error was expected.
found_errors = set()
for line in error_lines:
match = ERROR_PATTERN.search(line)
if match:
error_line = float(match.group(1))
if error_line in self.compile_errors:
found_errors.add(error_line)
else:
self.fail('Unexpected error:')
self.fail(line)
elif line != '':
self.fail('Unexpected output on stderr:')
self.fail(line)
# Validate that every expected error occurred.
for line in self.compile_errors - found_errors:
self.fail('Missing expected error on line {0}.', line)
def validate_exit_code(self, exit_code, error_lines):
if exit_code == self.exit_code: return
self.fail('Expected return code {0} and got {1}. Stderr:',
self.exit_code, exit_code)
self.failures += error_lines
def validate_output(self, out):
# Remove the trailing last empty line.
out_lines = out.split('\n')
if out_lines[-1] == '':
del out_lines[-1]
index = 0
for line in out_lines:
if sys.version_info < (3, 0):
line = line.encode('utf-8')
if index >= len(self.output):
self.fail('Got output "{0}" when none was expected.', line)
elif self.output[index][0] != line:
self.fail('Expected output "{0}" on line {1} and got "{2}".',
self.output[index][0], self.output[index][1], line)
index += 1
while index < len(self.output):
self.fail('Missing expected output "{0}" on line {1}.',
self.output[index][0], self.output[index][1])
index += 1
def fail(self, message, *args):
if args:
message = message.format(*args)
self.failures.append(message)
def color_text(text, color):
"""Converts text to a string and wraps it in the ANSI escape sequence for
color, if supported."""
# No ANSI escapes on Windows.
if sys.platform == 'win32':
return str(text)
return color + str(text) + '\033[0m'
def green(text): return color_text(text, '\033[32m')
def pink(text): return color_text(text, '\033[91m')
def red(text): return color_text(text, '\033[31m')
def yellow(text): return color_text(text, '\033[33m')
def walk(dir, callback, ignored=None):
"""
Walks [dir], and executes [callback] on each file unless it is [ignored].
"""
if not ignored:
ignored = []
ignored += [".",".."]
dir = abspath(dir)
for file in [file for file in listdir(dir) if not file in ignored]:
nfile = join(dir, file)
if isdir(nfile):
walk(nfile, callback)
else:
callback(nfile)
def print_line(line=None):
# Erase the line.
print('\033[2K', end='')
# Move the cursor to the beginning.
print('\r', end='')
if line:
print(line, end='')
sys.stdout.flush()
def run_script(app, path, type):
global passed
global failed
global num_skipped
if (splitext(path)[1] != '.wren'):
return
# Check if we are just running a subset of the tests.
if len(sys.argv) == 2:
this_test = relpath(path, join(WREN_DIR, 'test'))
if not this_test.startswith(sys.argv[1]):
return
# Update the status line.
print_line('Passed: ' + green(passed) +
' Failed: ' + red(failed) +
' Skipped: ' + yellow(num_skipped))
# Make a nice short path relative to the working directory.
# Normalize it to use "/" since, among other things, wren expects its argument
# to use that.
path = relpath(path).replace("\\", "/")
# Read the test and parse out the expectations.
test = Test(path)
if not test.parse():
# It's a skipped or non-test file.
return
test.run(app, type)
# Display the results.
if len(test.failures) == 0:
passed += 1
else:
failed += 1
print_line(red('FAIL') + ': ' + path)
print('')
for failure in test.failures:
print(' ' + pink(failure))
print('')
def run_test(path, example=False):
run_script(WREN_APP, path, "test")
def run_api_test(path):
run_script(TEST_APP, path, "api test")
def run_example(path):
run_script(WREN_APP, path, "example")
walk(join(WREN_DIR, 'test'), run_test, ignored=['api', 'benchmark'])
walk(join(WREN_DIR, 'test', 'api'), run_api_test)
walk(join(WREN_DIR, 'example'), run_example)
print_line()
if failed == 0:
print('All ' + green(passed) + ' tests passed (' + str(expectations) +
' expectations).')
else:
print(green(passed) + ' tests passed. ' + red(failed) + ' tests failed.')
for key in sorted(skipped.keys()):
print('Skipped ' + yellow(skipped[key]) + ' tests: ' + key)
if failed != 0:
sys.exit(1)
+202
View File
@@ -0,0 +1,202 @@
# Makefile for building a single configuration of Wren. It allows the
# following variables to be passed to it:
#
# MODE - The build mode, "debug" or "release".
# If omitted, defaults to "release".
# LANG - The language, "c" or "cpp".
# If omitted, defaults to "c".
# ARCH - The processor architecture, "32", "64", or nothing, which indicates
# the compiler's default.
# If omitted, defaults to the compiler's default.
#
# It builds a static library, shared library, and command-line interpreter for
# the given configuration. Libraries are built to "lib", and the interpreter
# is built to "bin".
#
# The output file is initially "wren". If in debug mode, "d" is appended to it.
# If the language is "cpp", then "-cpp" is appended to that. If the
# architecture is not the default then "-32" or "-64" is appended to that.
# Then, for the libraries, the correct extension is added.
# Files.
CLI_HEADERS := $(wildcard src/cli/*.h)
CLI_SOURCES := $(wildcard src/cli/*.c)
MODULE_HEADERS := $(wildcard src/module/*.h) $(wildcard src/module/*.wren.inc)
MODULE_SOURCES := $(wildcard src/module/*.c)
VM_HEADERS := $(wildcard src/vm/*.h) $(wildcard src/vm/*.wren.inc)
VM_SOURCES := $(wildcard src/vm/*.c)
TEST_HEADERS := $(wildcard test/api/*.h)
TEST_SOURCES := $(wildcard test/api/*.c)
BUILD_DIR := build
C_WARNINGS := -Wall -Wextra -Werror -Wno-unused-parameter
# Wren uses callbacks heavily, so -Wunused-parameter is too painful to enable.
# Mode configuration.
ifeq ($(MODE),debug)
WREN := wrend
C_OPTIONS += -O0 -DDEBUG -g
BUILD_DIR := $(BUILD_DIR)/debug
else
WREN += wren
C_OPTIONS += -Os
BUILD_DIR := $(BUILD_DIR)/release
endif
# Language configuration.
ifeq ($(LANG),cpp)
WREN := $(WREN)-cpp
C_OPTIONS += -std=c++98
FILE_FLAG := -x c++
BUILD_DIR := $(BUILD_DIR)-cpp
else
C_OPTIONS += -std=c99
endif
# Architecture configuration.
ifeq ($(ARCH),32)
C_OPTIONS += -m32
WREN := $(WREN)-32
BUILD_DIR := $(BUILD_DIR)-32
LIBUV_ARCH := -32
endif
ifeq ($(ARCH),64)
C_OPTIONS += -m64
WREN := $(WREN)-64
BUILD_DIR := $(BUILD_DIR)-64
LIBUV_ARCH := -64
endif
# Some platform-specific workarounds. Note that we use "gcc" explicitly in the
# call to get the machine name because one of these workarounds deals with $(CC)
# itself not working.
OS := $(lastword $(subst -, ,$(shell gcc -dumpmachine)))
# Don't add -fPIC on Windows since it generates a warning which gets promoted
# to an error by -Werror.
ifeq ($(OS),mingw32)
else ifeq ($(OS),cygwin)
# Do nothing.
else
C_OPTIONS += -fPIC
endif
# MinGW--or at least some versions of it--default CC to "cc" but then don't
# provide an executable named "cc". Manually point to "gcc" instead.
ifeq ($(OS),mingw32)
CC = GCC
endif
# Clang on Mac OS X has different flags and a different extension to build a
# shared library.
ifneq (,$(findstring darwin,$(OS)))
SHARED_EXT := dylib
else
SHARED_LIB_FLAGS := -Wl,-soname,$@.so
SHARED_EXT := so
# On Linux we need to explicitly link to these for libuv.
LIBUV_LIBS := -lpthread -lrt
endif
CFLAGS := $(C_OPTIONS) $(C_WARNINGS)
CLI_OBJECTS := $(addprefix $(BUILD_DIR)/cli/, $(notdir $(CLI_SOURCES:.c=.o)))
MODULE_OBJECTS := $(addprefix $(BUILD_DIR)/module/, $(notdir $(MODULE_SOURCES:.c=.o)))
VM_OBJECTS := $(addprefix $(BUILD_DIR)/vm/, $(notdir $(VM_SOURCES:.c=.o)))
TEST_OBJECTS := $(patsubst test/api/%.c, $(BUILD_DIR)/test/%.o, $(TEST_SOURCES))
LIBUV_DIR := deps/libuv
LIBUV := build/libuv$(LIBUV_ARCH).a
# Flags needed to compile source files for the CLI, including the modules and
# API tests.
CLI_FLAGS := -D_XOPEN_SOURCE=600 -Isrc/include -I$(LIBUV_DIR)/include \
-Isrc/cli -Isrc/module
# Targets ---------------------------------------------------------------------
# Builds the VM libraries and CLI interpreter.
all: vm cli
# Builds just the VM libraries.
vm: lib/lib$(WREN).a lib/lib$(WREN).$(SHARED_EXT)
# Builds just the CLI interpreter.
cli: bin/$(WREN)
# Builds the API test executable.
test: $(BUILD_DIR)/test/$(WREN)
# Command-line interpreter.
bin/$(WREN): $(CLI_OBJECTS) $(MODULE_OBJECTS) $(VM_OBJECTS) $(LIBUV)
@ printf "%10s %-30s %s\n" $(CC) $@ "$(C_OPTIONS)"
@ mkdir -p bin
@ $(CC) $(CFLAGS) $^ -o $@ -lm $(LIBUV_LIBS)
# Static library.
lib/lib$(WREN).a: $(VM_OBJECTS)
@ printf "%10s %-30s %s\n" $(AR) $@ "rcu"
@ mkdir -p lib
@ $(AR) rcu $@ $^
# Shared library.
lib/lib$(WREN).$(SHARED_EXT): $(VM_OBJECTS)
@ printf "%10s %-30s %s\n" $(CC) $@ "$(C_OPTIONS) $(SHARED_LIB_FLAGS)"
@ mkdir -p lib
@ $(CC) $(CFLAGS) -shared $(SHARED_LIB_FLAGS) -o $@ $^
# Test executable.
$(BUILD_DIR)/test/$(WREN): $(TEST_OBJECTS) $(MODULE_OBJECTS) $(VM_OBJECTS) \
$(BUILD_DIR)/cli/modules.o $(BUILD_DIR)/cli/vm.o $(LIBUV)
@ printf "%10s %-30s %s\n" $(CC) $@ "$(C_OPTIONS)"
@ mkdir -p $(BUILD_DIR)/test
@ $(CC) $(CFLAGS) $^ -o $@ -lm $(LIBUV_LIBS)
# CLI object files.
$(BUILD_DIR)/cli/%.o: src/cli/%.c $(CLI_HEADERS) $(MODULE_HEADERS) \
$(VM_HEADERS) $(LIBUV)
@ printf "%10s %-30s %s\n" $(CC) $< "$(C_OPTIONS)"
@ mkdir -p $(BUILD_DIR)/cli
@ $(CC) -c $(CFLAGS) $(CLI_FLAGS) -o $@ $(FILE_FLAG) $<
# Module object files.
$(BUILD_DIR)/module/%.o: src/module/%.c $(CLI_HEADERS) $(MODULE_HEADERS) \
$(VM_HEADERS) $(LIBUV)
@ printf "%10s %-30s %s\n" $(CC) $< "$(C_OPTIONS)"
@ mkdir -p $(BUILD_DIR)/module
@ $(CC) -c $(CFLAGS) $(CLI_FLAGS) -o $@ $(FILE_FLAG) $<
# VM object files.
$(BUILD_DIR)/vm/%.o: src/vm/%.c $(VM_HEADERS)
@ printf "%10s %-30s %s\n" $(CC) $< "$(C_OPTIONS)"
@ mkdir -p $(BUILD_DIR)/vm
@ $(CC) -c $(CFLAGS) -Isrc/include -o $@ $(FILE_FLAG) $<
# Test object files.
$(BUILD_DIR)/test/%.o: test/api/%.c $(MODULE_HEADERS) $(VM_HEADERS) $(TEST_HEADERS) $(LIBUV)
@ printf "%10s %-30s %s\n" $(CC) $< "$(C_OPTIONS)"
@ mkdir -p $(dir $@)
@ $(CC) -c $(CFLAGS) $(CLI_FLAGS) -o $@ $(FILE_FLAG) $<
# Download libuv.
$(LIBUV_DIR)/build/gyp/gyp: util/libuv.py
@ ./util/libuv.py download
# Build libuv to a static library.
$(LIBUV): $(LIBUV_DIR)/build/gyp/gyp util/libuv.py
@ ./util/libuv.py build $(LIBUV_ARCH)
# Wren modules that get compiled into the binary as C strings.
src/vm/wren_%.wren.inc: builtin/%.wren util/wren_to_c_string.py
@ ./util/wren_to_c_string.py $@ $<
src/module/%.wren.inc: src/module/%.wren util/wren_to_c_string.py
@ ./util/wren_to_c_string.py $@ $<
.PHONY: all cli test vm
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env python
# coding: utf-8
import argparse
import glob
import os.path
import re
# The source for the Wren modules that are built into the VM or CLI are turned
# include C string literals. This way they can be compiled directly into the
# code so that file IO is not needed to find and read them.
#
# These string literals are stored in files with a ".wren.inc" extension and
# #included directly by other source files. This generates a ".wren.inc" file
# given a ".wren" module.
PREAMBLE = """// Generated automatically from {0}. Do not edit.
static const char* {1}ModuleSource =
{2};
"""
def wren_to_c_string(input_path, wren_source_lines, module):
wren_source = ""
for line in wren_source_lines:
line = line.replace('"', "\\\"")
line = line.replace("\n", "\\n\"")
if wren_source: wren_source += "\n"
wren_source += '"' + line
return PREAMBLE.format(input_path, module, wren_source)
def main():
parser = argparse.ArgumentParser(
description="Convert a Wren library to a C string literal.")
parser.add_argument("output", help="The output file to write")
parser.add_argument("input", help="The source .wren file")
args = parser.parse_args()
with open(args.input, "r") as f:
wren_source_lines = f.readlines()
module = os.path.splitext(os.path.basename(args.input))[0]
c_source = wren_to_c_string(args.input, wren_source_lines, module)
with open(args.output, "w") as f:
f.write(c_source)
print(" str " + args.input)
main()
+496
View File
@@ -0,0 +1,496 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
2901D7641B74F4050083A2C8 /* timer.c in Sources */ = {isa = PBXBuildFile; fileRef = 2901D7621B74F4050083A2C8 /* timer.c */; };
291647C41BA5EA45006142EE /* scheduler.c in Sources */ = {isa = PBXBuildFile; fileRef = 291647C21BA5EA45006142EE /* scheduler.c */; };
291647C71BA5EC5E006142EE /* modules.c in Sources */ = {isa = PBXBuildFile; fileRef = 291647C51BA5EC5E006142EE /* modules.c */; };
291647C81BA5EC5E006142EE /* modules.c in Sources */ = {isa = PBXBuildFile; fileRef = 291647C51BA5EC5E006142EE /* modules.c */; };
291647D01BA5ED26006142EE /* scheduler.wren.inc in Sources */ = {isa = PBXBuildFile; fileRef = 291647CD1BA5ED26006142EE /* scheduler.wren.inc */; };
291647D21BA5ED26006142EE /* timer.wren.inc in Sources */ = {isa = PBXBuildFile; fileRef = 291647CE1BA5ED26006142EE /* timer.wren.inc */; };
29205C8F1AB4E5C90073018D /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 29205C8E1AB4E5C90073018D /* main.c */; };
29205C991AB4E6430073018D /* wren_compiler.c in Sources */ = {isa = PBXBuildFile; fileRef = 29205C921AB4E6430073018D /* wren_compiler.c */; };
29205C9A1AB4E6430073018D /* wren_core.c in Sources */ = {isa = PBXBuildFile; fileRef = 29205C931AB4E6430073018D /* wren_core.c */; };
29205C9B1AB4E6430073018D /* wren_debug.c in Sources */ = {isa = PBXBuildFile; fileRef = 29205C941AB4E6430073018D /* wren_debug.c */; };
29205C9D1AB4E6430073018D /* wren_utils.c in Sources */ = {isa = PBXBuildFile; fileRef = 29205C961AB4E6430073018D /* wren_utils.c */; };
29205C9E1AB4E6430073018D /* wren_value.c in Sources */ = {isa = PBXBuildFile; fileRef = 29205C971AB4E6430073018D /* wren_value.c */; };
29205C9F1AB4E6430073018D /* wren_vm.c in Sources */ = {isa = PBXBuildFile; fileRef = 29205C981AB4E6430073018D /* wren_vm.c */; };
29512C811B91F8EB008C10E6 /* libuv.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 29512C801B91F8EB008C10E6 /* libuv.a */; };
29512C821B91F901008C10E6 /* libuv.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 29512C801B91F8EB008C10E6 /* libuv.a */; };
29729F311BA70A620099CA20 /* io.c in Sources */ = {isa = PBXBuildFile; fileRef = 29729F2E1BA70A620099CA20 /* io.c */; };
29729F321BA70A620099CA20 /* io.c in Sources */ = {isa = PBXBuildFile; fileRef = 29729F2E1BA70A620099CA20 /* io.c */; };
29729F331BA70A620099CA20 /* io.wren.inc in Sources */ = {isa = PBXBuildFile; fileRef = 29729F301BA70A620099CA20 /* io.wren.inc */; };
29729F341BA70A620099CA20 /* io.wren.inc in Sources */ = {isa = PBXBuildFile; fileRef = 29729F301BA70A620099CA20 /* io.wren.inc */; };
2986F6D71ACF93BA00BCE26C /* wren_primitive.c in Sources */ = {isa = PBXBuildFile; fileRef = 2986F6D51ACF93BA00BCE26C /* wren_primitive.c */; };
29C8A9331AB71FFF00DEC81D /* vm.c in Sources */ = {isa = PBXBuildFile; fileRef = 29C8A9311AB71FFF00DEC81D /* vm.c */; };
29DE39531AC3A50A00987D41 /* wren_meta.c in Sources */ = {isa = PBXBuildFile; fileRef = 29DE39511AC3A50A00987D41 /* wren_meta.c */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
29AB1F041816E3AD004B501E /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
29D0099D1B7E397D000CE58C /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
2901D7621B74F4050083A2C8 /* timer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = timer.c; path = ../../src/module/timer.c; sourceTree = "<group>"; };
291647C21BA5EA45006142EE /* scheduler.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = scheduler.c; path = ../../src/module/scheduler.c; sourceTree = "<group>"; };
291647C31BA5EA45006142EE /* scheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = scheduler.h; path = ../../src/module/scheduler.h; sourceTree = "<group>"; };
291647C51BA5EC5E006142EE /* modules.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = modules.c; path = ../../src/cli/modules.c; sourceTree = "<group>"; };
291647C61BA5EC5E006142EE /* modules.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = modules.h; path = ../../src/cli/modules.h; sourceTree = "<group>"; };
291647CD1BA5ED26006142EE /* scheduler.wren.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = scheduler.wren.inc; path = ../../src/module/scheduler.wren.inc; sourceTree = "<group>"; };
291647CE1BA5ED26006142EE /* timer.wren.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = timer.wren.inc; path = ../../src/module/timer.wren.inc; sourceTree = "<group>"; };
29205C8E1AB4E5C90073018D /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = main.c; path = ../../src/cli/main.c; sourceTree = "<group>"; };
29205C901AB4E62B0073018D /* wren.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = wren.h; path = ../../src/include/wren.h; sourceTree = "<group>"; };
29205C921AB4E6430073018D /* wren_compiler.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = wren_compiler.c; path = ../../src/vm/wren_compiler.c; sourceTree = "<group>"; };
29205C931AB4E6430073018D /* wren_core.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = wren_core.c; path = ../../src/vm/wren_core.c; sourceTree = "<group>"; };
29205C941AB4E6430073018D /* wren_debug.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = wren_debug.c; path = ../../src/vm/wren_debug.c; sourceTree = "<group>"; };
29205C961AB4E6430073018D /* wren_utils.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = wren_utils.c; path = ../../src/vm/wren_utils.c; sourceTree = "<group>"; };
29205C971AB4E6430073018D /* wren_value.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = wren_value.c; path = ../../src/vm/wren_value.c; sourceTree = "<group>"; };
29205C981AB4E6430073018D /* wren_vm.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = wren_vm.c; path = ../../src/vm/wren_vm.c; sourceTree = "<group>"; };
29205CA11AB4E65E0073018D /* wren_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wren_common.h; path = ../../src/vm/wren_common.h; sourceTree = "<group>"; };
29205CA21AB4E65E0073018D /* wren_compiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wren_compiler.h; path = ../../src/vm/wren_compiler.h; sourceTree = "<group>"; };
29205CA31AB4E65E0073018D /* wren_core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wren_core.h; path = ../../src/vm/wren_core.h; sourceTree = "<group>"; };
29205CA41AB4E65E0073018D /* wren_debug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wren_debug.h; path = ../../src/vm/wren_debug.h; sourceTree = "<group>"; };
29205CA61AB4E65E0073018D /* wren_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wren_utils.h; path = ../../src/vm/wren_utils.h; sourceTree = "<group>"; };
29205CA71AB4E65E0073018D /* wren_value.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wren_value.h; path = ../../src/vm/wren_value.h; sourceTree = "<group>"; };
29205CA81AB4E65E0073018D /* wren_vm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wren_vm.h; path = ../../src/vm/wren_vm.h; sourceTree = "<group>"; };
29512C7F1B91F86E008C10E6 /* api_test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = api_test; sourceTree = BUILT_PRODUCTS_DIR; };
29512C801B91F8EB008C10E6 /* libuv.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libuv.a; path = ../../build/libuv.a; sourceTree = "<group>"; };
296371B31AC713D000079FDA /* wren_opcodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wren_opcodes.h; path = ../../src/vm/wren_opcodes.h; sourceTree = "<group>"; };
29729F2E1BA70A620099CA20 /* io.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = io.c; path = ../../src/module/io.c; sourceTree = "<group>"; };
29729F301BA70A620099CA20 /* io.wren.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = io.wren.inc; path = ../../src/module/io.wren.inc; sourceTree = "<group>"; };
2986F6D51ACF93BA00BCE26C /* wren_primitive.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wren_primitive.c; path = ../../src/vm/wren_primitive.c; sourceTree = "<group>"; };
2986F6D61ACF93BA00BCE26C /* wren_primitive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wren_primitive.h; path = ../../src/vm/wren_primitive.h; sourceTree = "<group>"; };
29AB1F061816E3AD004B501E /* wren */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = wren; sourceTree = BUILT_PRODUCTS_DIR; };
29C8A9311AB71FFF00DEC81D /* vm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vm.c; path = ../../src/cli/vm.c; sourceTree = "<group>"; };
29C8A9321AB71FFF00DEC81D /* vm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vm.h; path = ../../src/cli/vm.h; sourceTree = "<group>"; };
29D009A61B7E3993000CE58C /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = main.c; path = ../../test/api/main.c; sourceTree = "<group>"; };
29D009A81B7E39A8000CE58C /* foreign_class.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = foreign_class.c; path = ../../test/api/foreign_class.c; sourceTree = "<group>"; };
29D009A91B7E39A8000CE58C /* foreign_class.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = foreign_class.h; path = ../../test/api/foreign_class.h; sourceTree = "<group>"; };
29D009AA1B7E39A8000CE58C /* returns.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = returns.c; path = ../../test/api/returns.c; sourceTree = "<group>"; };
29D009AB1B7E39A8000CE58C /* returns.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = returns.h; path = ../../test/api/returns.h; sourceTree = "<group>"; };
29D009AC1B7E39A8000CE58C /* value.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = value.c; path = ../../test/api/value.c; sourceTree = "<group>"; };
29D009AD1B7E39A8000CE58C /* value.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = value.h; path = ../../test/api/value.h; sourceTree = "<group>"; };
29DE39511AC3A50A00987D41 /* wren_meta.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wren_meta.c; path = ../../src/vm/wren_meta.c; sourceTree = "<group>"; };
29DE39521AC3A50A00987D41 /* wren_meta.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wren_meta.h; path = ../../src/vm/wren_meta.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
29AB1F031816E3AD004B501E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
29512C821B91F901008C10E6 /* libuv.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
29D0099C1B7E397D000CE58C /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
29512C811B91F8EB008C10E6 /* libuv.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
2901D7611B74F3E20083A2C8 /* module */ = {
isa = PBXGroup;
children = (
29729F2E1BA70A620099CA20 /* io.c */,
29729F301BA70A620099CA20 /* io.wren.inc */,
291647C31BA5EA45006142EE /* scheduler.h */,
291647C21BA5EA45006142EE /* scheduler.c */,
291647CD1BA5ED26006142EE /* scheduler.wren.inc */,
2901D7621B74F4050083A2C8 /* timer.c */,
291647CE1BA5ED26006142EE /* timer.wren.inc */,
);
name = module;
sourceTree = "<group>";
};
29205CA01AB4E6470073018D /* vm */ = {
isa = PBXGroup;
children = (
29205CA11AB4E65E0073018D /* wren_common.h */,
29205CA21AB4E65E0073018D /* wren_compiler.h */,
29205C921AB4E6430073018D /* wren_compiler.c */,
29205CA31AB4E65E0073018D /* wren_core.h */,
29205C931AB4E6430073018D /* wren_core.c */,
29205CA41AB4E65E0073018D /* wren_debug.h */,
29205C941AB4E6430073018D /* wren_debug.c */,
29DE39521AC3A50A00987D41 /* wren_meta.h */,
29DE39511AC3A50A00987D41 /* wren_meta.c */,
296371B31AC713D000079FDA /* wren_opcodes.h */,
2986F6D61ACF93BA00BCE26C /* wren_primitive.h */,
2986F6D51ACF93BA00BCE26C /* wren_primitive.c */,
29205CA61AB4E65E0073018D /* wren_utils.h */,
29205C961AB4E6430073018D /* wren_utils.c */,
29205CA71AB4E65E0073018D /* wren_value.h */,
29205C971AB4E6430073018D /* wren_value.c */,
29205CA81AB4E65E0073018D /* wren_vm.h */,
29205C981AB4E6430073018D /* wren_vm.c */,
);
name = vm;
sourceTree = "<group>";
};
29205CA91AB4E67B0073018D /* cli */ = {
isa = PBXGroup;
children = (
29205C8E1AB4E5C90073018D /* main.c */,
291647C61BA5EC5E006142EE /* modules.h */,
291647C51BA5EC5E006142EE /* modules.c */,
29C8A9321AB71FFF00DEC81D /* vm.h */,
29C8A9311AB71FFF00DEC81D /* vm.c */,
);
name = cli;
sourceTree = "<group>";
};
29205CAA1AB4E6840073018D /* include */ = {
isa = PBXGroup;
children = (
29205C901AB4E62B0073018D /* wren.h */,
);
name = include;
sourceTree = "<group>";
};
29AB1EFD1816E3AD004B501E = {
isa = PBXGroup;
children = (
29205CA91AB4E67B0073018D /* cli */,
29205CAA1AB4E6840073018D /* include */,
2901D7611B74F3E20083A2C8 /* module */,
29205CA01AB4E6470073018D /* vm */,
29D0099A1B7E394F000CE58C /* api_test */,
29512C801B91F8EB008C10E6 /* libuv.a */,
29AB1F071816E3AD004B501E /* Products */,
);
sourceTree = "<group>";
};
29AB1F071816E3AD004B501E /* Products */ = {
isa = PBXGroup;
children = (
29AB1F061816E3AD004B501E /* wren */,
29512C7F1B91F86E008C10E6 /* api_test */,
);
name = Products;
sourceTree = "<group>";
};
29D0099A1B7E394F000CE58C /* api_test */ = {
isa = PBXGroup;
children = (
29D009A61B7E3993000CE58C /* main.c */,
29D009A81B7E39A8000CE58C /* foreign_class.c */,
29D009A91B7E39A8000CE58C /* foreign_class.h */,
29D009AA1B7E39A8000CE58C /* returns.c */,
29D009AB1B7E39A8000CE58C /* returns.h */,
29D009AC1B7E39A8000CE58C /* value.c */,
29D009AD1B7E39A8000CE58C /* value.h */,
);
name = api_test;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
29AB1F051816E3AD004B501E /* wren */ = {
isa = PBXNativeTarget;
buildConfigurationList = 29AB1F0F1816E3AD004B501E /* Build configuration list for PBXNativeTarget "wren" */;
buildPhases = (
29AB1F021816E3AD004B501E /* Sources */,
29AB1F031816E3AD004B501E /* Frameworks */,
29AB1F041816E3AD004B501E /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = wren;
productName = wren;
productReference = 29AB1F061816E3AD004B501E /* wren */;
productType = "com.apple.product-type.tool";
};
29D0099E1B7E397D000CE58C /* api_test */ = {
isa = PBXNativeTarget;
buildConfigurationList = 29D009A31B7E397D000CE58C /* Build configuration list for PBXNativeTarget "api_test" */;
buildPhases = (
29D0099B1B7E397D000CE58C /* Sources */,
29D0099C1B7E397D000CE58C /* Frameworks */,
29D0099D1B7E397D000CE58C /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = api_test;
productName = api_test;
productReference = 29512C7F1B91F86E008C10E6 /* api_test */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
29AB1EFE1816E3AD004B501E /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0610;
ORGANIZATIONNAME = "Bob Nystrom";
TargetAttributes = {
29D0099E1B7E397D000CE58C = {
CreatedOnToolsVersion = 6.3.2;
};
};
};
buildConfigurationList = 29AB1F011816E3AD004B501E /* Build configuration list for PBXProject "wren" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 29AB1EFD1816E3AD004B501E;
productRefGroup = 29AB1F071816E3AD004B501E /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
29AB1F051816E3AD004B501E /* wren */,
29D0099E1B7E397D000CE58C /* api_test */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
29AB1F021816E3AD004B501E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
29205C991AB4E6430073018D /* wren_compiler.c in Sources */,
2986F6D71ACF93BA00BCE26C /* wren_primitive.c in Sources */,
291647C71BA5EC5E006142EE /* modules.c in Sources */,
29205C9A1AB4E6430073018D /* wren_core.c in Sources */,
2901D7641B74F4050083A2C8 /* timer.c in Sources */,
29729F331BA70A620099CA20 /* io.wren.inc in Sources */,
29C8A9331AB71FFF00DEC81D /* vm.c in Sources */,
291647C41BA5EA45006142EE /* scheduler.c in Sources */,
29205C9B1AB4E6430073018D /* wren_debug.c in Sources */,
29205C9D1AB4E6430073018D /* wren_utils.c in Sources */,
29729F311BA70A620099CA20 /* io.c in Sources */,
29205C9E1AB4E6430073018D /* wren_value.c in Sources */,
29205C9F1AB4E6430073018D /* wren_vm.c in Sources */,
29DE39531AC3A50A00987D41 /* wren_meta.c in Sources */,
29205C8F1AB4E5C90073018D /* main.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
29D0099B1B7E397D000CE58C /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
29729F341BA70A620099CA20 /* io.wren.inc in Sources */,
291647C81BA5EC5E006142EE /* modules.c in Sources */,
29729F321BA70A620099CA20 /* io.c in Sources */,
291647D21BA5ED26006142EE /* timer.wren.inc in Sources */,
291647D01BA5ED26006142EE /* scheduler.wren.inc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
29AB1F0D1816E3AD004B501E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_PEDANTIC = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
29AB1F0E1816E3AD004B501E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_PEDANTIC = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
SDKROOT = macosx;
};
name = Release;
};
29AB1F101816E3AD004B501E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_PEDANTIC = NO;
LIBRARY_SEARCH_PATHS = ../../build;
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "../../deps/libuv/include ../../src/module";
};
name = Debug;
};
29AB1F111816E3AD004B501E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_PEDANTIC = NO;
LIBRARY_SEARCH_PATHS = ../../build;
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "../../deps/libuv/include ../../src/module";
};
name = Release;
};
29D009A41B7E397D000CE58C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_PEDANTIC = NO;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
LIBRARY_SEARCH_PATHS = ../../build;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "../../deps/libuv/include ../../src/module";
};
name = Debug;
};
29D009A51B7E397D000CE58C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_PEDANTIC = NO;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
LIBRARY_SEARCH_PATHS = ../../build;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "../../deps/libuv/include ../../src/module";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
29AB1F011816E3AD004B501E /* Build configuration list for PBXProject "wren" */ = {
isa = XCConfigurationList;
buildConfigurations = (
29AB1F0D1816E3AD004B501E /* Debug */,
29AB1F0E1816E3AD004B501E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
29AB1F0F1816E3AD004B501E /* Build configuration list for PBXNativeTarget "wren" */ = {
isa = XCConfigurationList;
buildConfigurations = (
29AB1F101816E3AD004B501E /* Debug */,
29AB1F111816E3AD004B501E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
29D009A31B7E397D000CE58C /* Build configuration list for PBXNativeTarget "api_test" */ = {
isa = XCConfigurationList;
buildConfigurations = (
29D009A41B7E397D000CE58C /* Debug */,
29D009A51B7E397D000CE58C /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 29AB1EFE1816E3AD004B501E /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:wren.xcodeproj">
</FileRef>
</Workspace>