-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
asl.py
124 lines (101 loc) · 4.41 KB
/
asl.py
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
'''
The Macroassembler AS.
.. https://github.com/KubaO/asl.git
This fetches from `ASL.source_repo` and builds the `ASL.source_ref`
branch.
See the module documentation for `setup` for more details.
'''
from os.path import abspath, dirname
import shutil, sys
from t8dev.toolset.setup import *
class ASL(Setup):
# ASL Version Information:
#
# 1.42 Builds 205 through at least 218 are broken for 8bitdev; from
# 205 the "Symbols in Segment NOTHING" section has disappeared from
# the .map file (using the default format=MAP) so that user-defined
# symbols such as as "negoffcalc equ negoff(no_data_end)" (from
# src/asl/simple.asl) as well as predefined symbols such as
# "ARCHITECTURE" and "BIGENDIAN" are no longer present in the file.
# (A bug report was sent to the as-users@ccac.rwth-aachen.de list on
# 2022-02-09.)
def __init__(self):
super().__init__()
self.source_repo \
= 'https://github.com/Macroassembler-AS/asl-releases.git'
self.source_ref = 'upstream'
#self.source_ref = 'dev/cjs/current'
#self.source_ref = 'dev/cjs/testing'
def check_installed(self):
return checkrun(['asl', '-this-is-not-an-option'], 4,
b'Invalid option')
GITIGNORE = '''\
# .o and .obj are the only two TARG_OBJEXTENSION in Makefile.def-samples/
/*.o
/*.obj
# These are generated for most executables; wildcard them to save typing.
/*.msg
/*.rsc
# Generated binaries.
/alink
/asl
/mkdepend
/p2bin
/p2hex
/pbind
/plist
/rescomp
'''
def configure(self):
''' Configure build, if not already done. '''
if self.srcdir().joinpath('Makefile.def').exists():
self.printaction('Using existing build configuration')
return
self.printaction('Configuring {}'.format(self.srcdir()))
dot_gitignore = self.srcdir().joinpath('.gitignore')
with open(str(dot_gitignore), 'wt') as f:
f.write(self.GITIGNORE)
mfdef_template = self.srcdir().joinpath(
'Makefile.def-samples', 'Makefile.def-x86_64-unknown-linux')
mfdef = self.srcdir().joinpath('Makefile.def')
shutil.copyfile(str(mfdef_template), str(mfdef))
with mfdef.open('at') as fd:
print('\n\n#', '-'*73, file=fd)
print('# tool/asl/Setup additional configuration\n', file=fd)
# These are the two dirs defined when compiling.
print('LIBDIR =', self.pdir('lib', 'asl'), file=fd)
print('INCDIR =', self.pdir('include', 'asl'), file=fd)
def build(self):
# Note we avoid building the documentation here.
self.make_src()
def install(self):
''' For ASL we don't use `make install` because that wants to build the
documentation, which requires LaTeX and even then tends to drop to
interactive prompts about missing `german.sty` etc.
As well, it's nicer four our purposes to use symlinks back to the
build directory because then a developer tweaking AS can just
`make` in the source directory to make the new version available to
the build system.
So instead we emulate the parts of install.{bat,cmd,sh} we want,
which is bin/, lib/ (the message files are required) and include/.
'''
binfiles = ('asl', 'plist', 'alink', 'pbind', 'p2hex', 'p2bin',)
for f in binfiles:
self.symlink_toolbin(self.srcdir(), f)
# The localization message files normally go in lib/asl/, but the
# programs don't find them there by default (unless perhaps the
# prefix is /usr/local/). We could emit a setting for the AS_MSGPATH
# environment variable to indicate where they are, but to allow use
# of these tools from the command line without running the Setup
# script, it seems better to just drop the files into bin/, where the
# programs can automatically find them.
#
for path in self.srcdir().glob('*.msg'):
dest = self.pdir('lib', 'asl').joinpath(path.name)
self.symlink_tool(path, dest)
srcs = self.srcdir().joinpath('include')
for src in srcs.glob('**/*'):
if src.is_dir(): continue
dest = self.pdir('include', 'asl').joinpath(src.relative_to(srcs))
self.symlink_tool(src, dest)
TOOLSET_CLASS = ASL