Coq.py 885 Bytes
Newer Older
Robbert Krebbers's avatar
Robbert Krebbers committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright (c) 2012-2015, Robbert Krebbers.
# This file is distributed under the terms of the BSD license.
import SCons.Defaults, SCons.Tool, SCons.Util, os

def coq_emitter(target, source, env):
  base, _ = os.path.splitext(str(target[0]))
  target.append(base + ".glob")
  return target, source
Coq = SCons.Builder.Builder(
  action = '$COQC $COQFLAGS -q $SOURCE',
  suffix = '.vo',
  src_suffix = '.v',
  emitter = coq_emitter
)

def make_coqidescript(target, source, env):
  open('coqidescript', 'w').write('#!/bin/sh\n' +
    env['COQIDE'] + ' ' + env['COQFLAGS'] + ' $@ \n')
  os.chmod('coqidescript', 0755)
  return 0
CoqIdeScript = SCons.Builder.Builder(action = make_coqidescript)

def generate(env):
  env['COQC'] = 'coqc'
  env['COQIDE'] = 'coqide'
  env.Append(BUILDERS = {
    'Coq' : Coq, 'CoqIdeScript' : CoqIdeScript
  })

def exists(env):
  return env.Detect('coqc')