Skip to content

Commit

Permalink
Added x64 assembly compilation (#940)
Browse files Browse the repository at this point in the history
  • Loading branch information
Amaras committed Nov 28, 2021
1 parent edbf50b commit 9d9e1cb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
15 changes: 8 additions & 7 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ To run the compilation for all implementations in one language, e.g. C, run the
from pathlib import Path
import os

env = Environment(ENV={'PATH': os.environ['PATH']})
env = Environment(ENV={'PATH': os.environ['PATH']},
tools=['gcc', 'gnulink', 'g++', 'gas'])

env['ASFLAGS'] = '--64'

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

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

env.C = env.Program
env.CPlusPlus = env.Program

env.X64 = env.Program

Export('env')

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

6 changes: 6 additions & 0 deletions contents/cooley_tukey/code/asm-x64/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Import('*')
from pathlib import Path

dirname = Path.cwd().parents[1].stem

env.X64(f'#/build/asm-x64/{dirname}', Glob('*.s'), LIBS=['m'], LINKFLAGS='-no-pie')
6 changes: 6 additions & 0 deletions contents/forward_euler_method/code/asm-x64/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Import('*')
from pathlib import Path

dirname = Path.cwd().parents[1].stem

env.X64(f'#/build/asm-x64/{dirname}', Glob('*.s'), LIBS='m', LINKFLAGS='-no-pie')
6 changes: 6 additions & 0 deletions sconscripts/asm-x64_SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Import('files_to_compile language env')
from pathlib import Path

for file in files_to_compile:
chapter_name = file.parent.parent.parent.stem
env.X64(f'#/build/{language}/{chapter_name}', str(file), LINKFLAGS='-no-pie')

0 comments on commit 9d9e1cb

Please sign in to comment.