-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
96 lines (63 loc) · 1.7 KB
/
SConstruct
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Copyright (C) 2023 Jacob Koziej <[email protected]>
EnsureSConsVersion(4, 5)
EnsurePythonVersion(3, 11)
import os
import subprocess
license = 'GPL-3.0-or-later'
version = 'v0.1.1'
Export('license')
Export('version')
build = 'build'
lib = 'lib/zgtc'
src = 'src'
env = Environment(tools=[
'default',
'CommandOutput',
'CommandSubst',
'Release',
])
if path := os.environ.get('PATH'):
env['ENV']['PATH'] = path
if term := os.environ.get('TERM'):
env['ENV']['TERM'] = term
env.Replace(CC='clang')
env['COMMANDSUBST_DICT']['@CC@'] = '$CC'
env.Replace(PDFLATEX='lualatex')
env.AppendUnique(PDFLATEXFLAGS=[
'--halt-on-error',
'--shell-escape',
])
git = env.WhereIs('git')
python = env.WhereIs('python')
Export('env')
Export('git')
# use git version if possible
if git:
version = subprocess.run(
[git, 'describe', '--always', '--broken', '--dirty', '--tags'],
capture_output=True,
encoding='utf-8').stdout.strip()
Export('version')
env['RELEASE_VERSION'] = version
env['zgtc'] = [ ]
# virtual environment
venv_path = env.Dir(f'{build}/venv')
venv = env.Command(venv_path, '', f'{python} -m venv {venv_path}')
env['ENV']['VIRTUAL_ENV'] = venv_path.abspath
env.PrependENVPath('PATH', f'{venv_path.abspath}/bin')
env['zgtc'] += venv
# change python's path to be within the virtual environment
python = f'{venv_path.abspath}/bin/python'
Export('python')
Export('venv')
VariantDir(f'{build}/{lib}', lib)
VariantDir(f'{build}/{src}', src)
SConscript([
f'{build}/{lib}/SConscript',
f'{build}/{src}/SConscript',
])
Import('zgtc')
env.Default(zgtc)
env.Release('release', zgtc, GPG_SIGN=True)