Skip to content

Commit 9d9e1cb

Browse files
authored
Added x64 assembly compilation (#940)
1 parent edbf50b commit 9d9e1cb

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

SConstruct

+8-7
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ To run the compilation for all implementations in one language, e.g. C, run the
1010
from pathlib import Path
1111
import os
1212

13-
env = Environment(ENV={'PATH': os.environ['PATH']})
13+
env = Environment(ENV={'PATH': os.environ['PATH']},
14+
tools=['gcc', 'gnulink', 'g++', 'gas'])
15+
16+
env['ASFLAGS'] = '--64'
1417

15-
env['CC'] = 'gcc'
16-
for tool in ['gcc','gnulink']:
17-
env.Tool(tool)
1818
env['CCFLAGS'] = ''
1919
env['CXXFLAGS'] = '-std=c++17'
2020

2121
# Add other languages here when you want to add language targets
2222
# Put 'name_of_language_directory' : 'file_extension'
23-
languages = {'c': 'c', 'cpp': 'cpp'}
23+
languages = {'c': 'c', 'cpp': 'cpp', 'asm-x64': 's'}
2424

2525
env.C = env.Program
2626
env.CPlusPlus = env.Program
27-
27+
env.X64 = env.Program
2828

2929
Export('env')
3030

@@ -46,7 +46,8 @@ sconscript_dir_path = Path('sconscripts')
4646
for language, files in files_to_compile.items():
4747
if files:
4848
if (sconscript_path := sconscript_dir_path / f"{language}_SConscript").exists():
49-
SConscript(sconscript_path, exports = {'files_to_compile': files})
49+
SConscript(sconscript_path, exports = {'files_to_compile': files,
50+
'language': language})
5051
else:
5152
print(f'{language} file found at {files[0]}, but no sconscript file is present ')
5253

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Import('*')
2+
from pathlib import Path
3+
4+
dirname = Path.cwd().parents[1].stem
5+
6+
env.X64(f'#/build/asm-x64/{dirname}', Glob('*.s'), LIBS=['m'], LINKFLAGS='-no-pie')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Import('*')
2+
from pathlib import Path
3+
4+
dirname = Path.cwd().parents[1].stem
5+
6+
env.X64(f'#/build/asm-x64/{dirname}', Glob('*.s'), LIBS='m', LINKFLAGS='-no-pie')

sconscripts/asm-x64_SConscript

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Import('files_to_compile language env')
2+
from pathlib import Path
3+
4+
for file in files_to_compile:
5+
chapter_name = file.parent.parent.parent.stem
6+
env.X64(f'#/build/{language}/{chapter_name}', str(file), LINKFLAGS='-no-pie')

0 commit comments

Comments
 (0)