Remove buildbot
Fixes #87.
diff --git a/__init__.py b/__init__.py
deleted file mode 100755
index 8db5bb0..0000000
--- a/__init__.py
+++ /dev/null
@@ -1,17 +0,0 @@
-#! /usr/bin/env python
-
-# Copyright 2015 WebAssembly Community Group participants
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Empty __init__.py file: Python treats the directory as containing a package.
diff --git a/buildbot/README.md b/buildbot/README.md
deleted file mode 100644
index b5f3877..0000000
--- a/buildbot/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Build script for use with Buildbot
-
-Build script to drive a complete build and test on buildbot.
-
-See the [waterfall](https://build.chromium.org/p/client.wasm.llvm/console) for results.
diff --git a/buildbot/__init__.py b/buildbot/__init__.py
deleted file mode 100755
index 8db5bb0..0000000
--- a/buildbot/__init__.py
+++ /dev/null
@@ -1,17 +0,0 @@
-#! /usr/bin/env python
-
-# Copyright 2015 WebAssembly Community Group participants
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Empty __init__.py file: Python treats the directory as containing a package.
diff --git a/buildbot/assemble_files.py b/buildbot/assemble_files.py
deleted file mode 100755
index aa92f1d..0000000
--- a/buildbot/assemble_files.py
+++ /dev/null
@@ -1,75 +0,0 @@
-#! /usr/bin/env python
-
-# Copyright 2015 WebAssembly Community Group participants
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import glob
-import os
-import os.path
-import sys
-
-import testing
-
-
-def create_outname(outdir, infile):
- """Create the output file's name."""
- basename = os.path.basename(infile)
- outname = basename + '.wasm'
- return os.path.join(outdir, outname)
-
-
-def assemble(infile, outfile, extras):
- """Create the command-line for an assembler invocation."""
- assembler = extras['assembler']
- basename = os.path.basename(assembler)
- commands = {
- 'sexpr-wasm': [extras['assembler'], infile, '-o', outfile]
- }
- return commands[basename]
-
-
-def run(assembler, files, fails, out):
- """Assemble all files."""
- assert os.path.isfile(assembler), 'Cannot find assembler at %s' % assembler
- assert os.path.isdir(out), 'Cannot find outdir %s' % out
- assembler_files = glob.glob(files)
- assert len(assembler_files), 'No files found by %s' % files
- return testing.execute(
- tester=testing.Tester(
- command_ctor=assemble,
- outname_ctor=create_outname,
- outdir=out,
- extras={'assembler': assembler}),
- inputs=assembler_files,
- fails=fails)
-
-
-def getargs():
- import argparse
- parser = argparse.ArgumentParser(
- description='Assemble .wast files into .wasm.')
- parser.add_argument('--assembler', type=str, required=True,
- help='Assembler path')
- parser.add_argument('--files', type=str, required=True,
- help='Glob pattern for .wast files')
- parser.add_argument('--fails', type=str, required=True,
- help='Expected failures')
- parser.add_argument('--out', type=str, required=True,
- help='Output directory')
- return parser.parse_args()
-
-
-if __name__ == '__main__':
- args = getargs()
- sys.exit(run(args.assembler, args.files, args.fails, args.out))
diff --git a/buildbot/build.py b/buildbot/build.py
deleted file mode 100755
index 0dbb6ba..0000000
--- a/buildbot/build.py
+++ /dev/null
@@ -1,551 +0,0 @@
-#! /usr/bin/env python
-
-# Copyright 2015 WebAssembly Community Group participants
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-import shutil
-import subprocess
-import sys
-import multiprocessing
-import urllib2
-
-import assemble_files
-import compile_torture_tests
-import link_assembly_files
-# Use proc instead of subprocess to get logged subprocess invocation.
-import proc
-
-
-SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
-WORK_DIR = os.path.join(SCRIPT_DIR, 'work')
-
-CLOUD_STORAGE_BASE_URL = 'https://storage.googleapis.com/'
-CLOUD_STORAGE_PATH = 'wasm-llvm/builds/'
-
-IT_IS_KNOWN = 'known_gcc_test_failures.txt'
-
-LLVM_SRC_DIR = os.path.join(WORK_DIR, 'llvm')
-CLANG_SRC_DIR = os.path.join(LLVM_SRC_DIR, 'tools', 'clang')
-LLVM_KNOWN_TORTURE_FAILURES = os.path.join(LLVM_SRC_DIR, 'lib', 'Target',
- 'WebAssembly', IT_IS_KNOWN)
-
-GCC_SRC_DIR = os.path.join(WORK_DIR, 'gcc')
-GCC_TEST_DIR = os.path.join(GCC_SRC_DIR, 'gcc', 'testsuite')
-
-SEXPR_SRC_DIR = os.path.join(WORK_DIR, 'sexpr-wasm-prototype')
-SEXPR_S2WASM_KNOWN_TORTURE_FAILURES = os.path.join(SEXPR_SRC_DIR, 's2wasm_' +
- IT_IS_KNOWN)
-
-SPEC_SRC_DIR = os.path.join(WORK_DIR, 'spec')
-ML_DIR = os.path.join(SPEC_SRC_DIR, 'ml-proto')
-BINARYEN_SRC_DIR = os.path.join(WORK_DIR, 'binaryen')
-S2WASM_KNOWN_TORTURE_FAILURES = os.path.join(BINARYEN_SRC_DIR, 'test',
- 's2wasm_' + IT_IS_KNOWN)
-
-PREBUILT_CLANG = os.path.join(WORK_DIR, 'chromium-clang')
-PREBUILT_CLANG_TOOLS = os.path.join(PREBUILT_CLANG, 'tools')
-PREBUILT_CLANG_TOOLS_CLANG = os.path.join(PREBUILT_CLANG_TOOLS, 'clang')
-PREBUILT_CLANG_BIN = os.path.join(
- PREBUILT_CLANG, 'third_party', 'llvm-build', 'Release+Asserts', 'bin')
-CC = os.path.join(PREBUILT_CLANG_BIN, 'clang')
-CXX = os.path.join(PREBUILT_CLANG_BIN, 'clang++')
-
-LLVM_OUT_DIR = os.path.join(WORK_DIR, 'llvm-out')
-LLVM_INSTALL_DIR = os.path.join(WORK_DIR, 'llvm-install')
-LLVM_INSTALL_BIN = os.path.join(LLVM_INSTALL_DIR, 'bin')
-SEXPR_OUT_DIR = os.path.join(SEXPR_SRC_DIR, 'out')
-BINARYEN_OUT_DIR = os.path.join(WORK_DIR, 'binaryen-out')
-BINARYEN_BIN_DIR = os.path.join(BINARYEN_OUT_DIR, 'bin')
-TORTURE_S_OUT_DIR = os.path.join(WORK_DIR, 'torture-s')
-
-# Avoid flakes: use cached repositories to avoid relying on external network.
-GITHUB_REMOTE = 'github'
-GITHUB_SSH = 'git@github.com:'
-GIT_MIRROR_BASE = 'https://chromium.googlesource.com/'
-WASM_GIT_BASE = GIT_MIRROR_BASE + 'external/github.com/WebAssembly/'
-LLVM_GIT = GIT_MIRROR_BASE + 'chromiumos/third_party/llvm'
-CLANG_GIT = GIT_MIRROR_BASE + 'chromiumos/third_party/clang'
-PREBUILT_CLANG_GIT = GIT_MIRROR_BASE + 'chromium/src/tools/clang'
-GCC_GIT = GIT_MIRROR_BASE + 'chromiumos/third_party/gcc'
-SEXPR_GIT = WASM_GIT_BASE + 'sexpr-wasm-prototype.git'
-SPEC_GIT = WASM_GIT_BASE + 'spec.git'
-BINARYEN_GIT = WASM_GIT_BASE + 'binaryen.git'
-
-# Sync OCaml from a cached tar file because the upstream repository is only
-# http. The file untars into a directory of the same name as the tar file.
-OCAML_STORAGE_BASE = 'https://wasm.storage.googleapis.com/'
-OCAML_VERSION = 'ocaml-4.02.2'
-OCAML_TAR_NAME = OCAML_VERSION + '.tar.gz'
-OCAML_TAR = os.path.join(WORK_DIR, OCAML_TAR_NAME)
-OCAML_URL = OCAML_STORAGE_BASE + OCAML_TAR_NAME
-OCAML_DIR = os.path.join(WORK_DIR, OCAML_VERSION)
-OCAML_OUT_DIR = os.path.join(WORK_DIR, 'ocaml-out')
-OCAML_BIN_DIR = os.path.join(OCAML_OUT_DIR, 'bin')
-
-NPROC = multiprocessing.cpu_count()
-
-# Try to use the LLVM revision provided by buildbot.
-LLVM_REVISION = os.environ.get('BUILDBOT_REVISION', 'None')
-if LLVM_REVISION == 'None':
- LLVM_REVISION = 'origin/master'
-LLVM_SVN_REV = None # Found after the sync step, corresponds to LLVM_REVISION.
-
-# Pin the GCC revision so that new torture tests don't break the bot. This
-# should be manually updated when convenient.
-GCC_REVISION = 'b6125c702850488ac3bfb1079ae5c9db89989406'
-
-# Magic annotations:
-# https://chromium.googlesource.com/chromium/tools/build/+/master/scripts/common/annotator.py
-def BuildStep(name):
- sys.stdout.write('\n@@@BUILD_STEP %s@@@\n' % name)
-
-
-def StepLink(label, url):
- sys.stdout.write('@@@STEP_LINK@%s@%s@@@\n' % (label, url))
-
-
-failed_steps = 0
-
-
-def StepFail():
- """Mark one step as failing, but keep going."""
- sys.stdout.write('\n@@@STEP_FAILURE@@@\n')
- global failed_steps
- failed_steps += 1
-
-
-def Chdir(path):
- print 'Change directory to: %s' % path
- os.chdir(path)
-
-
-def Mkdir(path):
- if os.path.exists(path):
- if not os.path.isdir(path):
- raise Exception('Path %s is not a directory!' % path)
- print 'Directory %s already exists' % path
- else:
- os.mkdir(path)
-
-
-def Remove(path):
- """Remove file or directory if it exists, do nothing otherwise."""
- if os.path.exists(path):
- print 'Removing %s' % path
- if os.path.isdir(path):
- shutil.rmtree(path)
- else:
- os.remove(path)
-
-
-def CopyBinaryToArchive(binary):
- """All binaries are archived in the same tar file."""
- print 'Copying binary %s to archive %s' % (binary, LLVM_INSTALL_BIN)
- shutil.copy2(binary, LLVM_INSTALL_BIN)
-
-
-def Tar(directory):
- """Create a tar file from directory."""
- assert os.path.isdir(directory), 'Must tar a directory to avoid tarbombs'
- (up_directory, basename) = os.path.split(directory)
- tar = os.path.join(up_directory, basename + '.tbz2')
- Remove(tar)
- print 'Creating %s from %s/%s' % (tar, up_directory, basename)
- proc.check_call(['tar', 'cjf', tar, basename], cwd=up_directory)
- return tar
-
-
-def UploadToCloud(local, remote, link_name):
- """Upload file to Cloud Storage."""
- if not os.environ.get('BUILDBOT_BUILDERNAME'):
- return
- remote = CLOUD_STORAGE_PATH + remote
- print 'Uploading %s to %s' % (local, remote)
- proc.check_call(
- ['gsutil', 'cp', '-a', 'public-read', local, 'gs://' + remote])
- StepLink(link_name, CLOUD_STORAGE_BASE_URL + remote)
-
-
-def CopyCloudStorage(copy_from, copy_to, link_name):
- """Copy from one Cloud Storage file to another."""
- if not os.environ.get('BUILDBOT_BUILDERNAME'):
- return
- copy_from = CLOUD_STORAGE_PATH + copy_from
- copy_to = CLOUD_STORAGE_PATH + copy_to
- print 'Copying %s to %s' % (copy_from, copy_to)
- proc.check_call(
- ['gsutil', 'cp', '-a', 'public-read',
- 'gs://' + copy_from, 'gs://' + copy_to])
- StepLink(link_name, CLOUD_STORAGE_BASE_URL + copy_to)
-
-
-def Archive(name, tar):
- """Archive the tar file with the given name, and with the LLVM git hash."""
- if not os.environ.get('BUILDBOT_BUILDERNAME'):
- return
- print 'Archiving %s: %s' % (name, tar)
- svn_gs = 'svn/wasm-%s-r%s.tbz2' % (name, LLVM_SVN_REV)
- git_gs = 'git/wasm-%s-%s.tbz2' % (name, LLVM_REVISION)
- UploadToCloud(tar, svn_gs, 'svn_download')
- CopyCloudStorage(svn_gs, git_gs, 'git_download')
-
-
-def GitRemoteUrl(cwd, remote):
- """Get the URL of a remote."""
- return proc.check_output(['git', 'config', '--get', 'remote.%s.url' %
- remote], cwd=cwd).strip()
-
-
-def HasRemote(cwd, remote):
- """"Checked whether the named remote exists."""
- remotes = proc.check_output(['git', 'remote'],
- cwd=cwd).strip().splitlines()
- return remote in remotes
-
-
-def AddGithubRemote(cwd):
- """When using the cloned repository for development, it's useful to have a
- remote to github because origin points at a cache which is read-only."""
- origin_url = GitRemoteUrl(cwd, 'origin')
- if WASM_GIT_BASE not in origin_url:
- print '%s not a github mirror' % cwd
- return
- if HasRemote(cwd, GITHUB_REMOTE):
- print '%s has %s as its "%s" remote' % (
- cwd, GitRemoteUrl(cwd, GITHUB_REMOTE), GITHUB_REMOTE)
- return
- remote = GITHUB_SSH + '/'.join(GitRemoteUrl(cwd, 'origin').split('/')[-2:])
- print '%s has no github remote, adding %s' % (cwd, remote)
- proc.check_call(['git', 'remote', 'add', GITHUB_REMOTE, remote],
- cwd=cwd)
-
-
-def GitCloneFetchCheckout(name, work_dir, git_repo, checkout='origin/master'):
- """Clone a git repo if not already cloned, then fetch and checkout."""
- if os.path.isdir(work_dir):
- print '%s directory already exists' % name
- else:
- print 'Cloning %s from %s into %s' % (name, git_repo, work_dir)
- proc.check_call(['git', 'clone', git_repo, work_dir])
- print 'Syncing %s' % name
- proc.check_call(['git', 'fetch'], cwd=work_dir)
- print 'Checking out %s' % checkout
- proc.check_call(['git', 'checkout', checkout], cwd=work_dir)
- PrintCurrentGitRev(work_dir)
- AddGithubRemote(work_dir)
-
-
-def GitConfigRebaseMaster(cwd):
- """Avoid generating a non-linear history in the clone
-
- The upstream repository is in Subversion. Use `git pull --rebase` instead of
- git pull: llvm.org/docs/GettingStarted.html#git-mirror
- """
- proc.check_call(
- ['git', 'config', 'branch.master.rebase', 'true'], cwd=cwd)
-
-
-def PrintCurrentGitRev(cwd):
- log = proc.check_output(
- ['git', 'log', '--oneline', '-n1'], cwd=cwd).strip()
- remote = proc.check_output(
- ['git', 'config', '--get', 'remote.origin.url'], cwd=cwd).strip()
- sys.stdout.write('%s from remote %s is at revision %s\n' %
- (cwd, remote, log))
-
-
-def FindPriorRev(path, goal):
- revs = proc.check_output(
- ['git', 'rev-list', 'origin/master'], cwd=path).splitlines()
- for rev in revs:
- num = proc.check_output(
- ['git', 'svn', 'find-rev', rev], cwd=path).strip()
- if int(num) <= goal:
- return rev
- raise Exception('Cannot find clang rev at or before %d' % goal)
-
-
-def SyncLLVMClang():
- if os.path.isdir(LLVM_SRC_DIR):
- assert os.path.isdir(CLANG_SRC_DIR), 'Assuming LLVM implies Clang'
- print 'LLVM and Clang directories already exist'
- else:
- print 'Cloning LLVM and Clang'
- proc.check_call(['git', 'clone', LLVM_GIT, LLVM_SRC_DIR])
- GitConfigRebaseMaster(LLVM_SRC_DIR)
- proc.check_call(['git', 'clone', CLANG_GIT, CLANG_SRC_DIR])
- GitConfigRebaseMaster(CLANG_SRC_DIR)
- print 'Syncing LLVM'
- proc.check_call(['git', 'fetch'], cwd=LLVM_SRC_DIR)
- proc.check_call(['git', 'checkout', LLVM_REVISION], cwd=LLVM_SRC_DIR)
- print 'Getting SVN rev'
- global LLVM_SVN_REV
- LLVM_SVN_REV = int(proc.check_output(
- ['git', 'svn', 'find-rev', 'HEAD'], cwd=LLVM_SRC_DIR).strip())
- print 'SVN REV: %d' % LLVM_SVN_REV
- print 'Finding prior Clang rev'
- proc.check_call(['git', 'fetch'], cwd=CLANG_SRC_DIR)
- prior_rev = FindPriorRev(CLANG_SRC_DIR, LLVM_SVN_REV)
- print 'Checking out Clang rev: %s' % prior_rev
- proc.check_call(['git', 'checkout', prior_rev], cwd=CLANG_SRC_DIR)
- PrintCurrentGitRev(LLVM_SRC_DIR)
- PrintCurrentGitRev(CLANG_SRC_DIR)
-
-
-def SyncPrebuiltClang():
- if os.path.isdir(PREBUILT_CLANG_TOOLS_CLANG):
- print 'Prebuilt Chromium Clang directory already exists'
- else:
- print 'Cloning Prebuilt Chromium Clang directory'
- Mkdir(PREBUILT_CLANG)
- Mkdir(PREBUILT_CLANG_TOOLS)
- proc.check_call(
- ['git', 'clone', PREBUILT_CLANG_GIT, PREBUILT_CLANG_TOOLS_CLANG])
- print 'Syncing Prebuilt Chromium Clang scripts'
- proc.check_call(['git', 'fetch'], cwd=PREBUILT_CLANG_TOOLS_CLANG)
- print 'Syncing Prebuilt Chromium Clang'
- proc.check_call(
- [os.path.join(PREBUILT_CLANG_TOOLS_CLANG, 'scripts', 'update.py')])
- assert os.path.isfile(CC), 'Expect clang at %s' % CC
- assert os.path.isfile(CXX), 'Expect clang++ at %s' % CXX
- PrintCurrentGitRev(PREBUILT_CLANG_TOOLS_CLANG)
-
-
-def SyncOCaml():
- if os.path.isdir(OCAML_DIR):
- print 'OCaml directory already exists'
- else:
- print 'Downloading OCaml %s from %s' % (OCAML_VERSION, OCAML_URL)
- f = urllib2.urlopen(OCAML_URL)
- print 'URL: %s' % f.geturl()
- print 'Info: %s' % f.info()
- with open(OCAML_TAR, 'wb') as out:
- out.write(f.read())
- print 'Download done, untar %s' % OCAML_TAR
- proc.check_call(['tar', '-xvf', OCAML_TAR], cwd=WORK_DIR)
- assert os.path.isdir(OCAML_DIR), 'Untar should produce %s' % OCAML_DIR
-
-
-def Clobber():
- if os.environ.get('BUILDBOT_CLOBBER'):
- BuildStep('Clobbering work dir')
- if os.path.isdir(WORK_DIR):
- print 'Removing %s' % WORK_DIR
- shutil.rmtree(WORK_DIR)
-
-
-def SyncRepos():
- BuildStep('Sync Repos')
- PrintCurrentGitRev(SCRIPT_DIR)
- SyncLLVMClang()
- GitCloneFetchCheckout(name='GCC', work_dir=GCC_SRC_DIR, git_repo=GCC_GIT,
- checkout=GCC_REVISION)
- SyncPrebuiltClang()
- GitCloneFetchCheckout(name='sexpr', work_dir=SEXPR_SRC_DIR,
- git_repo=SEXPR_GIT)
- SyncOCaml()
- GitCloneFetchCheckout(name='spec', work_dir=SPEC_SRC_DIR, git_repo=SPEC_GIT)
- GitCloneFetchCheckout(name='binaryen', work_dir=BINARYEN_SRC_DIR,
- git_repo=BINARYEN_GIT)
-
-
-def BuildLLVM():
- BuildStep('Build LLVM')
- print 'Running cmake on llvm'
- Mkdir(LLVM_OUT_DIR)
- proc.check_call(
- ['cmake', '-G', 'Ninja', LLVM_SRC_DIR,
- '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
- '-DLLVM_BUILD_TESTS=ON',
- '-DCMAKE_C_COMPILER=' + CC,
- '-DCMAKE_CXX_COMPILER=' + CXX,
- '-DCMAKE_BUILD_TYPE=Release',
- '-DCMAKE_INSTALL_PREFIX=' + LLVM_INSTALL_DIR,
- '-DLLVM_ENABLE_ASSERTIONS=ON',
- '-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly',
- '-DLLVM_TARGETS_TO_BUILD=X86'], cwd=LLVM_OUT_DIR)
- print 'Running ninja'
- proc.check_call(['ninja'], cwd=LLVM_OUT_DIR)
-
-
-def TestLLVM():
- BuildStep('Test LLVM')
- proc.check_call(['ninja', 'check-all'], cwd=LLVM_OUT_DIR)
-
-
-def InstallLLVM():
- BuildStep('Install LLVM')
- Remove(LLVM_INSTALL_DIR)
- proc.check_call(['ninja', 'install'], cwd=LLVM_OUT_DIR)
-
-
-def BuildSexpr():
- BuildStep('Build Sexpr')
- # sexpr-wasm builds in its own in-tree out/ folder. The build is fast, so
- # always clobber.
- proc.check_call(['make', 'clean'], cwd=SEXPR_SRC_DIR)
- proc.check_call(['make',
- 'CC=%s' % CC,
- 'CXX=%s' % CXX],
- cwd=SEXPR_SRC_DIR)
- sexpr = os.path.join(SEXPR_OUT_DIR, 'sexpr-wasm')
- CopyBinaryToArchive(sexpr)
-
-
-def BuildOCaml():
- BuildStep('Build OCaml')
- makefile = os.path.join(OCAML_DIR, 'config', 'Makefile')
- if not os.path.isfile(makefile):
- configure = os.path.join(OCAML_DIR, 'configure')
- proc.check_call(
- [configure, '-prefix', OCAML_OUT_DIR, '-cc', CC], cwd=OCAML_DIR)
- proc.check_call(['make', 'world.opt', '-j%s' % NPROC], cwd=OCAML_DIR)
- proc.check_call(['make', 'install'], cwd=OCAML_DIR)
- ocamlbuild = os.path.join(OCAML_BIN_DIR, 'ocamlbuild')
- assert os.path.isfile(ocamlbuild), 'Expected installed %s' % ocamlbuild
- os.environ['PATH'] = OCAML_BIN_DIR + os.pathsep + os.environ['PATH']
-
-
-def BuildSpec():
- BuildStep('Build spec')
- # Spec builds in-tree. Always clobber and run the tests.
- proc.check_call(['make', 'clean'], cwd=ML_DIR)
- proc.check_call(['make', 'all'], cwd=ML_DIR)
- wasm = os.path.join(ML_DIR, 'wasm.opt')
- CopyBinaryToArchive(wasm)
-
-
-def BuildBinaryen():
- BuildStep('Build binaryen')
- Mkdir(BINARYEN_OUT_DIR)
- proc.check_call(
- ['cmake', '-G', 'Ninja', BINARYEN_SRC_DIR,
- '-DCMAKE_C_COMPILER=' + CC,
- '-DCMAKE_CXX_COMPILER=' + CXX],
- cwd=BINARYEN_OUT_DIR)
- print 'Running ninja'
- proc.check_call(['ninja'], cwd=BINARYEN_OUT_DIR)
- assert os.path.isdir(BINARYEN_BIN_DIR), 'Expected %s' % BINARYEN_BIN_DIR
- for node in os.listdir(BINARYEN_BIN_DIR):
- f = os.path.join(BINARYEN_BIN_DIR, node)
- if os.path.isfile(f):
- CopyBinaryToArchive(f)
-
-
-def ArchiveBinaries():
- if LLVM_REVISION == 'origin/master':
- return
- BuildStep('Archive binaries')
- # All relevant binaries were copied to the LLVM directory.
- Archive('binaries', Tar(LLVM_INSTALL_DIR))
-
-
-def CompileLLVMTorture():
- name = 'Compile LLVM Torture'
- BuildStep(name)
- c = os.path.join(LLVM_OUT_DIR, 'bin', 'clang')
- cxx = os.path.join(LLVM_OUT_DIR, 'bin', 'clang++')
- Remove(TORTURE_S_OUT_DIR)
- Mkdir(TORTURE_S_OUT_DIR)
- unexpected_result_count = compile_torture_tests.run(
- c=c, cxx=cxx, testsuite=GCC_TEST_DIR,
- fails=LLVM_KNOWN_TORTURE_FAILURES,
- out=TORTURE_S_OUT_DIR)
- Archive('torture-s', Tar(TORTURE_S_OUT_DIR))
- if 0 != unexpected_result_count:
- StepFail()
-
-
-def LinkLLVMTorture(name, linker, fails):
- BuildStep('Link LLVM Torture with %s' % name)
- assert os.path.isfile(linker), 'Cannot find linker at %s' % linker
- assembly_files = os.path.join(TORTURE_S_OUT_DIR, '*.s')
- out = os.path.join(WORK_DIR, 'torture-%s' % name)
- Remove(out)
- Mkdir(out)
- unexpected_result_count = link_assembly_files.run(
- linker=linker, files=assembly_files, fails=fails, out=out)
- Archive('torture-%s' % name, Tar(out))
- if 0 != unexpected_result_count:
- StepFail()
- return out
-
-
-def AssembleLLVMTorture(name, assembler, indir, fails):
- BuildStep('Assemble LLVM Torture with %s' % name)
- assert os.path.isfile(assembler), 'Cannot find assembler at %s' % assembler
- files = os.path.join(indir, '*.wast')
- out = os.path.join(WORK_DIR, 'torture-%s' % name)
- Remove(out)
- Mkdir(out)
- unexpected_result_count = assemble_files.run(
- assembler=assembler,
- files=files,
- fails=fails,
- out=out)
- Archive('torture-%s' % name, Tar(out))
- if 0 != unexpected_result_count:
- StepFail()
- return out
-
-
-def Summary():
- BuildStep('Summary')
- sys.stdout.write('Failed steps: %s.' % failed_steps)
- if failed_steps:
- StepFail()
- else:
- try:
- with open('lkgr', 'w+') as f:
- f.write(str(LLVM_SVN_REV))
- UploadToCloud('lkgr', 'svn/lkgr', 'svn_lkgr')
- with open('lkgr', 'w+') as f:
- f.write(str(LLVM_REVISION))
- UploadToCloud('lkgr', 'git/lkgr', 'git_lkgr')
- finally:
- Remove('lkgr')
-
-
-def main():
- Clobber()
- Chdir(SCRIPT_DIR)
- Mkdir(WORK_DIR)
- SyncRepos()
- BuildLLVM()
- TestLLVM()
- InstallLLVM()
- BuildSexpr()
- BuildOCaml()
- BuildSpec()
- BuildBinaryen()
- ArchiveBinaries()
- CompileLLVMTorture()
- s2wasm_out = LinkLLVMTorture(
- name='s2wasm',
- linker=os.path.join(LLVM_INSTALL_BIN, 's2wasm'),
- fails=S2WASM_KNOWN_TORTURE_FAILURES)
- s2wasm_sexpr_wasm_out = AssembleLLVMTorture(
- name='s2wasm-sexpr-wasm',
- assembler=os.path.join(LLVM_INSTALL_BIN, 'sexpr-wasm'),
- indir=s2wasm_out,
- fails=SEXPR_S2WASM_KNOWN_TORTURE_FAILURES)
- # Keep the summary step last: it'll be marked as red if the return code is
- # non-zero. Individual steps are marked as red with StepFail().
- Summary()
- return failed_steps
-
-
-if __name__ == '__main__':
- sys.exit(main())
diff --git a/buildbot/compile_torture_tests.py b/buildbot/compile_torture_tests.py
deleted file mode 100755
index 563fb8f..0000000
--- a/buildbot/compile_torture_tests.py
+++ /dev/null
@@ -1,80 +0,0 @@
-#! /usr/bin/env python
-
-# Copyright 2015 WebAssembly Community Group participants
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import glob
-import os
-import os.path
-import sys
-
-import testing
-
-
-CFLAGS = ['--std=gnu89', '--target=wasm32-unknown-unknown', '-S', '-O2',
- '-Wno-implicit-function-declaration', '-Wno-implicit-int']
-
-
-def create_outname(outdir, infile):
- """Create the output file's name."""
- basename = os.path.basename(infile)
- outname = basename + '.s'
- return os.path.join(outdir, outname)
-
-
-def c_compile(infile, outfile, extras):
- """Create the command-line for a C compiler invocation."""
- return [extras['c'], infile, '-o', outfile] + CFLAGS
-
-
-def run(c, cxx, testsuite, fails, out):
- """Compile all torture tests."""
- assert os.path.isfile(c), 'Cannot find C compiler at %s' % c
- assert os.path.isfile(cxx), 'Cannot find C++ compiler at %s' % cxx
- assert os.path.isdir(testsuite), 'Cannot find testsuite at %s' % testsuite
- # TODO(jfb) Also compile other C tests, as well as C++ tests under g++.dg.
- c_torture = os.path.join(testsuite, 'gcc.c-torture', 'execute')
- assert os.path.isdir(c_torture), ('Cannot find C torture tests at %s' %
- c_torture)
- assert os.path.isdir(out), 'Cannot find outdir %s' % out
- c_test_files = glob.glob(os.path.join(c_torture, '*c'))
- return testing.execute(
- tester=testing.Tester(
- command_ctor=c_compile,
- outname_ctor=create_outname,
- outdir=out,
- extras={'c': c}),
- inputs=c_test_files,
- fails=fails)
-
-
-def getargs():
- import argparse
- parser = argparse.ArgumentParser(description='Compile GCC torture tests.')
- parser.add_argument('--c', type=str, required=True,
- help='C compiler path')
- parser.add_argument('--cxx', type=str, required=True,
- help='C++ compiler path')
- parser.add_argument('--testsuite', type=str, required=True,
- help='GCC testsuite tests path')
- parser.add_argument('--fails', type=str, required=True,
- help='Expected failures')
- parser.add_argument('--out', type=str, required=True,
- help='Output directory')
- return parser.parse_args()
-
-
-if __name__ == '__main__':
- args = getargs()
- sys.exit(run(args.c, args.cxx, args.testsuite, args.fails, args.out))
diff --git a/buildbot/link_assembly_files.py b/buildbot/link_assembly_files.py
deleted file mode 100755
index a777377..0000000
--- a/buildbot/link_assembly_files.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#! /usr/bin/env python
-
-# Copyright 2015 WebAssembly Community Group participants
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import glob
-import os
-import os.path
-import sys
-
-import testing
-
-
-def create_outname(outdir, infile):
- """Create the output file's name."""
- basename = os.path.basename(infile)
- outname = basename + '.wast'
- return os.path.join(outdir, outname)
-
-
-def link(infile, outfile, extras):
- """Create the command-line for a linker invocation."""
- linker = extras['linker']
- basename = os.path.basename(linker)
- commands = {
- 's2wasm': [linker, '-o', outfile, infile],
- }
- return commands[basename]
-
-
-def run(linker, files, fails, out):
- """Link all files."""
- assert os.path.isfile(linker), 'Cannot find linker at %s' % linker
- assert os.path.isdir(out), 'Cannot find outdir %s' % out
- assembly_files = glob.glob(files)
- assert len(assembly_files), 'No files found by %s' % files
- return testing.execute(
- tester=testing.Tester(
- command_ctor=link,
- outname_ctor=create_outname,
- outdir=out,
- extras={'linker': linker}),
- inputs=assembly_files,
- fails=fails)
-
-
-def getargs():
- import argparse
- parser = argparse.ArgumentParser(description='Link .s files into .wast.')
- parser.add_argument('--linker', type=str, required=True,
- help='Linker path')
- parser.add_argument('--files', type=str, required=True,
- help='Glob pattern for .s files')
- parser.add_argument('--fails', type=str, required=True,
- help='Expected failures')
- parser.add_argument('--out', type=str, required=True,
- help='Output directory')
- return parser.parse_args()
-
-
-if __name__ == '__main__':
- args = getargs()
- sys.exit(run(args.linker, args.files, args.fails, args.out))
diff --git a/buildbot/proc.py b/buildbot/proc.py
deleted file mode 100755
index 8ca0c67..0000000
--- a/buildbot/proc.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#! /usr/bin/env python
-
-# Copyright 2016 WebAssembly Community Group participants
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# This module is intended to be a drop-in replacement for the standard
-# subprocess module, with the difference that it logs commands before it runs
-# them. Everything not overriden should pass through to the subprocess module
-# via the import trick below.
-
-# Imports subprocess in its own namespace so we can always refer directly to
-# its attributes.
-import subprocess
-# Imports all of subprocess into the current namespace, effectively re-exporting
-# everything.
-from subprocess import *
-
-
-# Now we can override any parts of subprocess we want, while leaving the rest.
-def check_call(cmd, **kwargs):
- print 'check_call Running command:'
- print ' '.join('"' + c + '"' if ' ' in c else c for c in cmd)
- return subprocess.check_call(cmd, **kwargs)
-
-
-def check_output(cmd, **kwargs):
- print 'check_output Running command:'
- print ' '.join('"' + c + '"' if ' ' in c else c for c in cmd)
- return subprocess.check_output(cmd, **kwargs)
diff --git a/buildbot/testing.py b/buildbot/testing.py
deleted file mode 100755
index 15d078a..0000000
--- a/buildbot/testing.py
+++ /dev/null
@@ -1,241 +0,0 @@
-#! /usr/bin/env python
-
-# Copyright 2015 WebAssembly Community Group participants
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import difflib
-import math
-import multiprocessing
-import os
-import os.path
-import sys
-
-# Use proc instead of subprocess to get logged subprocess invocation.
-import proc
-
-class Result:
- """Result from a single test that was run."""
-
- def __init__(self, test, success, output):
- self.test = test
- self.success = success
- self.output = output
-
- def __str__(self):
- return '%s %s%s%s' % ('SUCCEEDED' if self.success else 'FAILED',
- self.test, '\n' if self.output else '', self.output)
-
- def __nonzero__(self):
- return self.success
-
- def __lt__(self, other):
- """Sort by test name so that the output files can be compared easily."""
- return self.test < other.test
-
- def similarity(self, other):
- """Compare output similarity, returning a float in the range [0,1]."""
- return difflib.SequenceMatcher(None, self.output, other.output).ratio()
-
-
-class Tester(object):
- """Test runner."""
-
- def __init__(self, command_ctor, outname_ctor, outdir, extras):
- """Command-line constructor accepting input and output file names."""
- assert os.path.isdir(outdir)
- self.command_ctor = command_ctor
- self.outname_ctor = outname_ctor
- self.outdir = outdir
- self.extras = extras
-
- def __call__(self, test_file):
- """Execute a single test."""
- basename = os.path.basename(test_file)
- outfile = self.outname_ctor(self.outdir, test_file)
- try:
- output = proc.check_output(
- self.command_ctor(test_file, outfile, self.extras),
- stderr=proc.STDOUT, cwd=self.outdir)
- # Flush the logged command sobuildbots don't think the script is dead.
- sys.stdout.flush()
- assert os.path.isfile(outfile), 'Missing output file %s' % outfile
- return Result(test=basename, success=True, output=output)
- except proc.CalledProcessError as e:
- return Result(test=basename, success=False, output=e.output)
-
-
-def get_expected_failures(fails):
- """One failure per line, some whitespace, Python-style comments."""
- assert os.path.isfile(fails), 'Cannot find known failures at %s' % fails
- res = []
- with open(fails, 'r') as fails_file:
- res = fails_file.readlines()
- return sorted([r for r in [r.split('#')[0].strip() for r in res] if len(r)])
-
-
-class TriangularArray:
- """Indexed with two commutable keys."""
-
- def __init__(self):
- self.arr = {}
-
- def canonicalize(self, key):
- return (min(key[0], key[1]), max(key[0], key[1]))
-
- def __getitem__(self, key):
- return self.arr[self.canonicalize(key)]
-
- def __setitem__(self, key, value):
- k = self.canonicalize(key)
- # Support single-insertion only, the intended usage would be a bug if there
- # were multiple insertions of the same key.
- assert k not in self.arr, 'Double insertion of key %s' % k
- self.arr[k] = value
-
- def __iter__(self):
- return self.arr.iteritems()
-
-
-class SimilarityGroup:
- """Group of similar results."""
- def __init__(self, tests, similarities):
- self.tests = sorted(tests)
- self.similarities = [100. * s for s in similarities]
- self.average = (sum(self.similarities) / len(self.similarities)
- if self.similarities else 0.)
- squared_diffs = [(s - self.average)**2 for s in self.similarities]
- self.stddev = (math.sqrt(sum(squared_diffs) / len(squared_diffs))
- if self.similarities else 0.)
-
-
-def similarity(results, cutoff):
- """List of lists of result test names with similar outputs."""
- similarities = TriangularArray()
- for x in range(0, len(results)):
- for y in range(x + 1, len(results)):
- rx = results[x]
- ry = results[y]
- similarities[(rx.test, ry.test)] = rx.similarity(ry)
- # A maximum clique would be better suited to group similarities, but this
- # silly traversal is simpler and seems to do the job pretty well.
- similar_groups = []
- worklist = set()
- for k, v in similarities:
- if v > cutoff:
- worklist.add(k[0])
- worklist.add(k[1])
- for result in results:
- test = result.test
- if test in worklist:
- worklist.remove(test)
- group_tests = [test]
- group_similarities = []
- for other_result in results:
- other_test = other_result.test
- if other_test in worklist:
- similar = similarities[(test, other_test)]
- if similar > cutoff:
- worklist.remove(other_test)
- group_tests.append(other_test)
- group_similarities.append(similar)
- if len(group_tests) > 1:
- # Some tests could have similar matches which were more similar to
- # other tests, leaving this group with a single entry.
- similar_groups.append(SimilarityGroup(tests=group_tests,
- similarities=group_similarities))
- assert len(worklist) == 0, 'Failed emptying worklist %s' % worklist
- # Put all the ungrouped tests into their own group.
- grouped = set()
- for group in similar_groups:
- for test in group.tests:
- grouped.add(test)
- uniques = list(set([r.test for r in results]) - grouped)
- if uniques:
- s = [similarities[(uniques[0], u)] for u in uniques[1:]]
- similar_groups.append(SimilarityGroup(tests=uniques, similarities=s))
- return similar_groups
-
-
-def execute(tester, inputs, fails):
- """Execute tests in parallel, output results, return failure count."""
- input_expected_failures = get_expected_failures(fails)
- pool = multiprocessing.Pool()
- sys.stdout.write('Executing tests.')
- results = sorted(pool.map(tester, inputs))
- sys.stdout.write('\nDone.')
- successes = [r for r in results if r]
- failures = [r for r in results if not r]
- expected_failures = [t for t in failures
- if t.test in input_expected_failures]
- unexpected_failures = [t for t in failures
- if t.test not in input_expected_failures]
- unexpected_successes = [t for t in successes
- if t.test in input_expected_failures]
- sys.stdout.write('\nResults:\n')
- for result in results:
- sys.stdout.write(str(result) + '\n\n')
- cutoff = 0.9
- similar_expected_failures = similarity(expected_failures, cutoff)
- for s in similar_expected_failures:
- tests = ' '.join(s.tests)
- if s.average >= cutoff * 100.:
- sys.stdout.write(('\nSimilar expected failures, '
- 'average %s%% similarity with stddev %s: '
- '%s\n') % (s.average, s.stddev, tests))
- sample = [f for f in expected_failures if f.test == s.tests[0]][0]
- sys.stdout.write('Sample failure: %s\n' % sample)
- else:
- sys.stdout.write(('\nUngrouped expected failures, '
- 'average %s%% similarity with stddev %s: '
- '%s\n') % (s.average, s.stddev, tests))
- similar_unexpected_failures = similarity(unexpected_failures, cutoff)
- for s in similar_unexpected_failures:
- tests = ' '.join(s.tests)
- if s.average >= cutoff * 100.:
- sys.stdout.write(('\nSimilar unexpected failures, '
- 'average %s%% similarity with stddev %s: '
- '%s\n') % (s.average, s.stddev, tests))
- sample = [f for f in unexpected_failures if f.test == s.tests[0]][0]
- sys.stdout.write('Sample failure: %s\n' % sample)
- else:
- sys.stdout.write(('\nUngrouped unexpected failures, '
- 'average %s%% similarity with stddev %s: '
- '%s\n') % (s.average, s.stddev, tests))
- if expected_failures:
- sys.stdout.write('Expected failures:\n')
- for f in expected_failures:
- sys.stdout.write('\t%s\n' % f.test)
- if unexpected_failures:
- sys.stdout.write('Unexpected failures:\n')
- for f in unexpected_failures:
- sys.stdout.write('\t%s\n' % f.test)
- if unexpected_successes:
- sys.stdout.write('Unexpected successes:\n')
- for f in unexpected_successes:
- sys.stdout.write('\t%s\n' % f.test)
- sys.stdout.write(
- '\n'.join(['\n',
- 'Ran %s tests.' % len(results),
- 'Got %s successes.' % len(successes),
- 'Got %s failures.' % len(failures),
- 'Expected %s failures.' % len(input_expected_failures),
- 'Got %s expected failures in %s similarity groups.' % (
- len(expected_failures),
- len(similar_expected_failures)),
- 'Got %s unexpected failures in %s similarity groups.' % (
- len(unexpected_failures),
- len(similar_unexpected_failures)),
- 'Got %s unexpected successes.' % len(unexpected_successes),
- '\n']))
- return len(unexpected_failures) + len(unexpected_successes)
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index 3127ffd..0000000
--- a/setup.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-[pep8]
-ignore = E111,E114