From 754060f6711887b0c4fa93db69764ab897bd7001 Mon Sep 17 00:00:00 2001 From: Maxwell Anderson Date: Sun, 29 Sep 2019 10:52:34 -0400 Subject: [PATCH] convert tasks.py to justfile (#36) * convert tasks.py to justfile * install just in pipelines * remove virtualenv traces * move just install --- .ci/Dockerfile | 2 +- .gitignore | 4 +--- .vscode/settings.json | 3 --- README.md | 2 +- azure-pipelines.yaml | 8 +++---- build.sh | 13 +---------- docs/00-getting-started.md | 1 + justfile | 35 +++++++++++++++++++++++++++++ requirements.txt | 1 - tasks.py | 45 -------------------------------------- 10 files changed, 43 insertions(+), 71 deletions(-) delete mode 100644 .vscode/settings.json create mode 100644 justfile delete mode 100644 requirements.txt delete mode 100644 tasks.py diff --git a/.ci/Dockerfile b/.ci/Dockerfile index ea555e2..5a93fa1 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get update && \ COPY llvm.list /etc/apt/sources.list.d/ RUN apt-get update && \ apt-get install -y sudo && \ - apt-get install -y python3 python3-pip && \ + apt-get install -y python3 && \ apt-get install -y clang binutils && \ apt-get install -y llvm-8-dev && \ apt-get install -y zlib1g-dev diff --git a/.gitignore b/.gitignore index d6418bf..101a58c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,4 @@ target/ docs/build/ # Binaries for spec tests specbin/ -a.out -# Python virtual env for `invoke` -venv/ \ No newline at end of file +a.out \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 5b80df3..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "python.pythonPath": "venv/bin/python" -} \ No newline at end of file diff --git a/README.md b/README.md index 5d5f5fe..fba5109 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ You can also mess around with constant strings: ## Building and Testing The main build is performed by `cargo`. For running the functional -tests and benchmarks you'll need Python. The suggested process is to +tests and benchmarks you'll need Python and to `cargo install just`. The suggested process is to use the `build.sh` script: * `$ ./build.sh` will build the compiler `target/release/ullage`. diff --git a/azure-pipelines.yaml b/azure-pipelines.yaml index b81a40c..c693c6e 100644 --- a/azure-pipelines.yaml +++ b/azure-pipelines.yaml @@ -17,7 +17,7 @@ jobs: export PATH=/usr/local/bin:$PATH # Local bin (brew) source ~/.cargo/env export LLVM_SYS_80_PREFIX=/usr/local/opt/llvm - pip3 install virtualenv + cargo install just ./build.sh test displayName: './build.sh test' - job: Linux @@ -27,16 +27,14 @@ jobs: steps: - script: | python3 --version - pip3 --version - pip3 install virtualenv export PATH=${PATH}:~/.local/bin/ - virtualenv --version - displayName: Virtualenv Install + displayName: Python - script: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup.sh && sh rustup.sh -y" displayName: Rustup - script: | source ~/.cargo/env export PATH=${PATH}:~/.local/bin/ export LLVM_SYS_80_PREFIX=/usr/lib/llvm-8 + cargo install just ./build.sh test displayName: './build.sh test' diff --git a/build.sh b/build.sh index 74b4b90..d99be3a 100755 --- a/build.sh +++ b/build.sh @@ -10,16 +10,5 @@ function check_for() } check_for python3 -check_for pip3 -check_for virtualenv -if [ ! -d ${DIR}/venv ] -then - # make sure to use a Python3 interpreter - virtualenv -p python3 venv -fi - -source ${DIR}/venv/bin/activate -pip3 install -r ${DIR}/requirements.txt - -invoke "$@" +just "$@" diff --git a/docs/00-getting-started.md b/docs/00-getting-started.md index 190f66a..f767d10 100644 --- a/docs/00-getting-started.md +++ b/docs/00-getting-started.md @@ -3,6 +3,7 @@ This is only known to work on my machine at the moment. I'm running macOS and stable Rust If you'd still like to give it a go then make sure you have: * Rust - to compile the compiler + * Just - to run help commands * Python - to run the functional tests * Clang - Used to link the output to create the final executables. diff --git a/justfile b/justfile new file mode 100644 index 0000000..56ff39a --- /dev/null +++ b/justfile @@ -0,0 +1,35 @@ +build: + cargo build --release + +test: build + cargo test + python3 specs.py + +clean: + rm -f a.out + rm -rf specbin/ + cargo clean + +docs: + cd docs/; docket + +clippy: + cargo clippy + +bench opt_level="3": build + #!/usr/bin/env python3 + import os + import glob + import subprocess + + for bench in glob.glob("spec/bench/*.ulg"): + output = bench.lstrip('spec/').rstrip('.ulg') + output = os.path.join("specbin", "bench", output) + try: + os.makedirs(os.path.dirname(output)) + except OSError: + pass + print("bench={0}, output={1}, opt={2}".format(bench, output, {{opt_level}})) + subprocess.call("target/release/ullage {0} -O{1} -o {2}" + .format(bench, {{opt_level}}, output)) + subprocess.call("time {0}".format(output)) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 14dec14..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -invoke==1.2.0 diff --git a/tasks.py b/tasks.py deleted file mode 100644 index 963ddec..0000000 --- a/tasks.py +++ /dev/null @@ -1,45 +0,0 @@ -from invoke import task -import os -import glob - -@task -def clean(ctx): - ctx.run("rm -f a.out") - ctx.run("rm -rf specbin/") - ctx.run("cargo clean") - -@task(default=True) -def build(ctx, release=True): - cargo_args = "build" - if release: - cargo_args += " --release" - ctx.run("cargo " + cargo_args) - -@task -def docs(ctx): - with ctx.cd("docs/"): - ctx.run("docket") - -@task(build) -def test(ctx): - ctx.run("cargo test") - ctx.run("python3 specs.py") - -@task -def clippy(ctx): - ctx.run("cargo clippy") - -@task(build) -def bench(ctx, opt_level=3): - for bench in glob.glob("spec/bench/*.ulg"): - output = bench.lstrip('spec/').rstrip('.ulg') - output = os.path.join("specbin", "bench", output) - try: - os.makedirs(os.path.dirname(output)) - except OSError: - pass - print("bench={0}, output={1}, opt={2}".format(bench, output, opt_level)) - ctx.run("target/release/ullage {0} -O{1} -o {2}" - .format(bench, opt_level, output)) - ctx.run("time {0}".format(output)) -