From ca96786d7808e440dced511b42bad0652c96fc97 Mon Sep 17 00:00:00 2001 From: Sammy Plat Date: Mon, 29 Nov 2021 00:01:45 +0100 Subject: [PATCH 1/2] Added Coconut compilation --- SConstruct | 7 ++++++- sconscripts/coconut_SConscript | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 sconscripts/coconut_SConscript diff --git a/SConstruct b/SConstruct index 222ae14c0..c3fef1fc9 100644 --- a/SConstruct +++ b/SConstruct @@ -17,15 +17,19 @@ rust_rustc_builder = Builder(action='rustc $SOURCE -o $TARGET$PROGSUFFIX') go_builder = Builder(action='go build -o $TARGET$PROGSUFFIX $SOURCE') +coconut_builder = Builder(action='coconut $COCONUTFLAGS $SOURCE $TARGET', src_suffix='.coco', target_suffix='.py') + env = Environment(ENV=os.environ, BUILDERS={'rustc': rust_rustc_builder, 'cargo': rust_cargo_builder, - 'Go': go_builder}, + 'Go': go_builder, + 'Coconut': coconut_builder}, tools=['gcc', 'gnulink', 'g++', 'gas', 'gfortran']) env['CCFLAGS'] = '' env['CXXFLAGS'] = '-std=c++17' env['ASFLAGS'] = '--64' +env['COCONUTFLAGS'] = '--target 3.8' # Add other languages here when you want to add language targets # Put 'name_of_language_directory' : 'file_extension' @@ -36,6 +40,7 @@ languages = { 'rust': 'rs', 'go': 'go', 'fortran': 'f90', + 'coconut': 'coco', } env.C = env.Program diff --git a/sconscripts/coconut_SConscript b/sconscripts/coconut_SConscript new file mode 100644 index 000000000..3c5e18130 --- /dev/null +++ b/sconscripts/coconut_SConscript @@ -0,0 +1,6 @@ +Import('files_to_compile env') +from pathlib import Path + +for file in files_to_compile: + chapter_name = file.parent.parent.parent.stem + env.Coconut(f'#/build/coconut/{chapter_name}.py', str(file)) From d45623843df7df42a0813f47f636aa1bb84b7840 Mon Sep 17 00:00:00 2001 From: Sammy Plat Date: Sun, 5 Dec 2021 12:38:20 +0100 Subject: [PATCH 2/2] Fixed the compilation step w.r.t #963 --- sconscripts/coconut_SConscript | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sconscripts/coconut_SConscript b/sconscripts/coconut_SConscript index 3c5e18130..1356343eb 100644 --- a/sconscripts/coconut_SConscript +++ b/sconscripts/coconut_SConscript @@ -1,6 +1,6 @@ Import('files_to_compile env') -from pathlib import Path -for file in files_to_compile: - chapter_name = file.parent.parent.parent.stem - env.Coconut(f'#/build/coconut/{chapter_name}.py', str(file)) +for file_info in files_to_compile: + build_target = f'#/build/{file_info.language}/{file_info.chapter}/{file_info.path.stem}' + build_result = env.Coconut(build_target, str(file_info.path)) + env.Alias(str(file_info.chapter), build_result)