Skip to content

Commit

Permalink
Added SCons compilation instructions (#885)
Browse files Browse the repository at this point in the history
* Added C compilation to SCons (not all work, though)

* First fully functional version of the build system for C code

* Simplified SConstruct file

* Simplified SConscript files

SConscript files are now mostly universal for C programs.
Additionally, the build hierarchy is now flattened (executables under the language folder)

* fixing chapter to use split-op code (#888)

Removed the quantum_systems SConscript

* modified Dockerfile for ntindle

* Changed my name in CONTRIBUTORS.md

* apparently forgot an algorithm

Co-authored-by: James Schloss <jrs.schloss@gmail.com>
  • Loading branch information
Amaras and leios authored Oct 26, 2021
1 parent 83df0b9 commit cfcfccc
Show file tree
Hide file tree
Showing 23 changed files with 149 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends build-essential software-properties-common xz-utils g++ sbcl julia python3 python3-pip python3-dev ghc openjdk-11-jdk rustc libssl-dev gfortran libxml2-dev libyaml-dev libgmp-dev libz-dev libncurses5 gnuplot nodejs npm lua5.3 ocaml php ruby-full gnu-smalltalk scratch
&& apt-get -y install --no-install-recommends build-essential software-properties-common xz-utils g++ sbcl julia python3 python3-pip python3-dev ghc openjdk-11-jdk rustc libssl-dev gfortran libxml2-dev libyaml-dev libgmp-dev libz-dev libncurses5 gnuplot nodejs npm lua5.3 ocaml php ruby-full gnu-smalltalk scratch libfftw3-dev

# Setup Crystal
RUN echo 'deb http://download.opensuse.org/repositories/devel:/languages:/crystal/xUbuntu_20.04/ /' | sudo tee /etc/apt/sources.list.d/devel:languages:crystal.list
Expand Down Expand Up @@ -98,6 +98,7 @@ ENV PATH=$PATH:~/swift/usr/bin
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends crystal dart nim powershell scala dotnet-sdk-5.0 r-base racket

RUN pip install wheel matplotlib numpy coconut
RUN pip install wheel matplotlib numpy coconut scons

RUN sudo sh -c 'npm install -g typescript'

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,10 @@ vscode/

# aspell
*.bak

# SCons intermidiate files
.sconsign.dblite
*.o

# SCons build directory
build/
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ This file lists everyone, who contributed to this repo and wanted to show up her
- Vincent Zalzal
- Jonathan D B Van Schenck
- James Goytia
- Amaras
- Sammy Plat
- Jonathan Dönszelmann
- Ishaan Verma
- Delphi1024
Expand Down
10 changes: 10 additions & 0 deletions SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pathlib import Path

Import('*')

for p in Path('contents').iterdir():
if (q := (p / 'code')).exists():
for path in q.iterdir():
if path.stem in languages:
env.SConscript(path / 'SConscript', exports='env',
must_exist=0)
20 changes: 20 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
SCons top-level build description (SConstruct) for the Arcane Algorithm Achive
This provides Builder objects for each of the language implementations in the AAA; however, this work cannot be considered exhaustive until every language has been covered.
Currently, the aim is to provide a way to compile or copy the implementation files to the build directory, as well as to provide ways to run them and capture their output.
To run the compilation for all implmeentations in one language, e.g. Rust, run the command `scons build/c`, and the resulting executables will be available in the `cuild/c` directory, each in their respective algorithm directory, containing the executable."""

from pathlib import Path

env = Environment()

# Add other languages here when you want to add language targets
languages = ['c']

env.C = env.Program

SConscript('SConscript', exports='env languages')

6 changes: 6 additions & 0 deletions contents/IFS/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'))
6 changes: 6 additions & 0 deletions contents/approximate_counting/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'), LIBS='m')
6 changes: 6 additions & 0 deletions contents/barnsley/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'))
6 changes: 6 additions & 0 deletions contents/computus/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'))
6 changes: 6 additions & 0 deletions contents/cooley_tukey/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'), LIBS=['m', 'fftw3'])
6 changes: 6 additions & 0 deletions contents/euclidean_algorithm/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'))
6 changes: 6 additions & 0 deletions contents/flood_fill/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'))
6 changes: 6 additions & 0 deletions contents/forward_euler_method/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'), LIBS='m')
6 changes: 6 additions & 0 deletions contents/gaussian_elimination/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'))
6 changes: 6 additions & 0 deletions contents/graham_scan/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'), LIBS='m')
6 changes: 6 additions & 0 deletions contents/huffman_encoding/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'))
6 changes: 6 additions & 0 deletions contents/jarvis_march/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'))
6 changes: 6 additions & 0 deletions contents/monte_carlo_integration/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'))
6 changes: 6 additions & 0 deletions contents/split-operator_method/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'), LIBS=['m', 'fftw3'])
6 changes: 6 additions & 0 deletions contents/stable_marriage_problem/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'))
6 changes: 6 additions & 0 deletions contents/thomas_algorithm/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'))
6 changes: 6 additions & 0 deletions contents/tree_traversal/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'))
6 changes: 6 additions & 0 deletions contents/verlet_integration/code/c/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.C(f'#/build/c/{dirname}', Glob('*.c'))

0 comments on commit cfcfccc

Please sign in to comment.