Skip to content

Updated elgohr/Publish-Docker-Github-Action to a supported version (v5) #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
05e9758
New chapter "Metropolis" with Python Implementation (#929)
shudipto-amin Dec 3, 2021
6b592d5
Fix minor typos in metropolis.md (#965)
ShadowMitia Dec 3, 2021
946d4f1
Change SCons output structure (#963)
PeanutbutterWarrior Dec 5, 2021
2d7ce74
Added parallel scons compilation for actions (#969)
Amaras Dec 5, 2021
b7568f5
Added Coconut compilation (#949)
Amaras Dec 5, 2021
6b30491
Fixed a build target problem (#971)
Amaras Dec 5, 2021
b016c59
Add interpreted languages to SCons (#950)
PeanutbutterWarrior Dec 5, 2021
c69c58f
Removing probability folder (#967)
leios Dec 8, 2021
d127a81
Fixing Huffman Encoding edge case failure for assembly x64 (#662)
Gathros Dec 8, 2021
ff494db
Update JavaScript Jarvis March to use points from Graham Scan (#708)
berquist Dec 8, 2021
508cfb5
Added approximate counting in Rust (#900)
PaddyKe Dec 8, 2021
62f2a31
Added Java compilation (#973)
Amaras Dec 21, 2021
b17f07b
Using SCons tools (#977)
Amaras Dec 26, 2021
fd6b7a6
Updated tree traversal chapter (#979)
ell-hol Dec 27, 2021
51936d7
Rust version of IFS (#755)
Dec 28, 2021
3060849
Forward Euler method, version 1
Amaras Jul 22, 2020
05a9720
Forward Euler method, version 2
Amaras Jul 22, 2020
bf7923a
EUler method, version 2.1
Amaras Jul 22, 2020
62d0ceb
Forward Euler method, version 2.2: as functional as I could make it (…
Amaras Nov 12, 2020
015489e
Merge pull request #737 from Amaras/forward_euler_coconut
berquist Dec 29, 2021
28287e3
Stack queue in cpp (#936)
ishwar00 Jan 12, 2022
525205b
Implement Graham Scan in Rust (#964)
PeanutbutterWarrior Jan 12, 2022
0d3866f
Solved formatting problems (#985)
Amaras Jan 15, 2022
9b58757
Added and adapted Kotlin tool from scons-contrib (#984)
Amaras Jan 15, 2022
7acfce9
Fix warnings and remove VLA on C++ Thomas algorithm (#932)
ShadowMitia Jan 15, 2022
ffab1cb
Removed C++ warnings and unified C/C++ warnings flags (#986)
Amaras Jan 17, 2022
e160e7a
Eliminating C/C++ implicit conversions (#987)
Amaras Jan 18, 2022
b545344
Small revisions to crypto chapter (#988)
leios Jan 31, 2022
a5120ab
Small changes to youtube embeds to prevent google spying on everyone …
leios Feb 6, 2022
83675ef
rebuild pages (#992)
leios Feb 6, 2022
03d21df
Implement huffman encoding in ocaml (#750)
shubhamkumar13 Mar 1, 2022
98ca4ab
Use stricter formatting (#993)
Amaras Mar 15, 2022
3338b23
adding more info on stormer verlet (#998)
leios Apr 14, 2022
5dae366
Edit Complexity Notation in #352 (#601)
dovisutu Apr 18, 2022
8693a37
Box muller chapter (#974)
leios May 6, 2022
6c905ec
Euclidean algorithm: Output standardization (#877)
stormofice Jan 13, 2023
2753cf9
Updated elgohr/Publish-Docker-Github-Action to a supported version (v5)
elgohr Mar 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
HOME: /root
run: |
. "$HOME/.cargo/env"
scons -Q
scons -Q --random -j2
2 changes: 1 addition & 1 deletion .github/workflows/publish_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@master
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: algorithm-archivists/aaa-langs
username: ${{ github.actor }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ paket-files/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

*.ipynb_checkpoints*
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ This file lists everyone, who contributed to this repo and wanted to show up her
- Hugo Salou
- Dimitri Belopopsky
- Henrik Abel Christensen
- K. Shudipto Amin
- Peanutbutter_Warrior
- Thijs Raymakers
123 changes: 94 additions & 29 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,128 @@ Currently, the aim is to provide a way to compile or copy the implementation fil
To run the compilation for all implementations in one language, e.g. C, run the command `scons build/c`, and the resulting executables will be available in the `build/c` directory, each in their respective algorithm directory, containing the executable."""

from pathlib import Path
from collections import namedtuple
import os

rust_cargo_builder = Builder(action=['cargo build --bins --manifest-path $MANIFEST',
Move('$TARGET$PROGSUFFIX', '$SOURCE_DIR/target/debug/main$PROGSUFFIX')])
import SCons
SCons.Warnings.warningAsException()

rust_rustc_builder = Builder(action='rustc $SOURCE -o $TARGET$PROGSUFFIX')

go_builder = Builder(action='go build -o $TARGET$PROGSUFFIX $SOURCE')
# For interpreted languages to copy to build directory
copy_builder = Builder(action=Copy('$TARGET', '$SOURCE'))

env = Environment(ENV=os.environ,
BUILDERS={'rustc': rust_rustc_builder,
'cargo': rust_cargo_builder,
'Go': go_builder},
tools=['gcc', 'gnulink', 'g++', 'gas', 'gfortran'])
BUILDERS={'Copier': copy_builder},
tools=[
'g++', 'gas', 'gcc', 'gfortran', 'gnulink', 'javac'],
toolpath=['builders'])

available_languages = {
'asm-x64',
'bash',
'c',
'cpp',
'fortran',
'java',
'julia',
'lolcode'
'lua',
'php',
'powershell',
'python',
'ruby',
'viml',
}

languages_to_import = {
'coconut': ['coconut'],
'go': ['go'],
'rust': ['rustc', 'cargo'],
'kotlin': ['kotlin'],
}

for language, tools in languages_to_import.items():
for tool in tools:
try:
env.Tool(tool)
except SCons.Warnings.SConsWarning as w:
print(f'{w.args[0][0]}, ignoring')
break
else:
available_languages.add(language)


Export('env')

env['CFLAGS'] = '-Wall -Wextra -Werror'
env['CXXFLAGS'] = '-std=c++17'
env['CCFLAGS'] = '-Wall -Wextra -Werror -pedantic -Wconversion'
env['CFLAGS'] = '-std=gnu99'
env['CXXFLAGS'] = '-std=c++17 -Wold-style-cast'
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'

languages = {
'asm-x64': 's',
'bash': 'bash',
'c': 'c',
'coconut': 'coco',
'cpp': 'cpp',
'asm-x64': 's',
'rust': 'rs',
'go': 'go',
'fortran': 'f90',
'go': 'go',
'java': 'java',
'javascript': 'js',
'julia': 'jl',
'kotlin': 'kt',
'lolcode': 'lol',
'lua': 'lua',
'php': 'php',
'powershell': 'ps1',
'python': 'py',
'ruby': 'rb',
'rust': 'rs',
'viml': 'vim',
}

# Do not add new Builders here, add them to the BUILDERS argument in the call to Environment above
env.C = env.Program
env.CPlusPlus = env.Program
env.X64 = env.Program
env.Fortran = env.Program

Export('env')
for language in available_languages:
Alias(language, f'#/build/{language}')

sconscripts = []
files_to_compile = {language: [] for language in languages}

for chapter_dir in Path.cwd().joinpath('contents').iterdir():
if (code_dir := (chapter_dir / 'code')).exists():
for path in code_dir.iterdir():
if path.stem in languages:
# Check for overriding sconscript
if (sconscript_path := path / 'SConscript').exists():
sconscripts.append(sconscript_path)
SConscript(sconscript_path, exports='env')
files_to_compile = {language: [] for language in languages if language in available_languages}

FileInformation = namedtuple('FileInformation', ['path', 'chapter', 'language'])


contents_path = Path.cwd().joinpath('contents')
for chapter_dir in contents_path.iterdir():
for code_dir in chapter_dir.glob('**/code'):
# For nested chapters e.g. contents/convolutions/1d/
extended_chapter_path = code_dir.relative_to(contents_path).parent

for language_dir in code_dir.iterdir():
if (language := language_dir.stem) in available_languages:
new_files = [FileInformation(path=file_path,
chapter=extended_chapter_path,
language=language)
for file_path in language_dir.glob(f'**/*.{languages[language]}')
]
# Check for overriding SConscript
if (sconscript_path := language_dir / 'SConscript').exists():
SConscript(sconscript_path, exports={'files_to_compile': new_files})
else:
files_to_compile[path.stem].extend(path.glob(f'*.{languages[path.stem]}'))
files_to_compile[language].extend(new_files)

sconscript_dir_path = Path('sconscripts')
sconscript_dir_path = Path.cwd().joinpath('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,
'language': language})
SConscript(sconscript_path, exports = {'files_to_compile': files})
else:
print(f'{language} file found at {files[0]}, but no sconscript file is present ')

5 changes: 5 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@
* [Multiplication as a Convolution](contents/convolutions/multiplication/multiplication.md)
* [Convolutions of Images (2D)](contents/convolutions/2d/2d.md)
* [Convolutional Theorem](contents/convolutions/convolutional_theorem/convolutional_theorem.md)
* [Box Muller Transform](contents/box_muller/box_muller.md)
* [How costly is rejection sampling?](contents/box_muller/box_muller_rejection.md)
* [Probability Distributions](contents/probability_distributions/distributions.md)
* [Tree Traversal](contents/tree_traversal/tree_traversal.md)
* [Euclidean Algorithm](contents/euclidean_algorithm/euclidean_algorithm.md)
* [Monte Carlo](contents/monte_carlo_integration/monte_carlo_integration.md)
* [Metropolis](contents/metropolis/metropolis.md)
* [Matrix Methods](contents/matrix_methods/matrix_methods.md)
* [Gaussian Elimination](contents/gaussian_elimination/gaussian_elimination.md)
* [Thomas Algorithm](contents/thomas_algorithm/thomas_algorithm.md)
Expand All @@ -42,5 +46,6 @@
* [Computer Graphics](contents/computer_graphics/computer_graphics.md)
* [Flood Fill](contents/flood_fill/flood_fill.md)
* [Quantum Information](contents/quantum_information/quantum_information.md)
* [Cryptography](contents/cryptography/cryptography.md)
* [Computus](contents/computus/computus.md)
* [Approximate Counting Algorithm](contents/approximate_counting/approximate_counting.md)
41 changes: 41 additions & 0 deletions builders/cargo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from SCons.Builder import Builder
from SCons.Script import Move
import SCons.Util

class ToolCargoWarning(SCons.Warnings.SConsWarning):
pass

class CargoNotFound(ToolCargoWarning):
pass

SCons.Warnings.enableWarningClass(ToolCargoWarning)

def _detect(env):
try:
return env['cargo']
except KeyError:
pass

cargo = env.WhereIs('cargo')
if cargo:
return cargo

SCons.Warnings.warn(CargoNotFound, 'Could not detect cargo')

def exists(env):
return env.Detect('cargo')


def generate(env):
env['CARGO'] = _detect(env)
env['CARGOFLAGS'] = []
env['MANIFEST'] = []

rust_cargo_builder = Builder(
action=['"$CARGO" build $CARGOFLAGS --bins --manifest-path $MANIFEST',
Move('$TARGET$PROGSUFFIX',
'$SOURCE_DIR/target/debug/main$PROGSUFFIX')
],
suffix='$PROGSUFFIX',
)
env.Append(BUILDERS={'cargo': rust_cargo_builder})
40 changes: 40 additions & 0 deletions builders/coconut.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from SCons.Builder import Builder
import SCons.Util

class ToolCocoWarning(SCons.Warnings.SConsWarning):
pass

class CoconutNotFound(ToolCocoWarning):
pass

SCons.Warnings.enableWarningClass(ToolCocoWarning)

def _detect(env):
try:
return env['coconut']
except KeyError:
pass

coconut = env.WhereIs('coconut')
if coconut:
return coconut

SCons.Warnings.warn(CoconutNotFound, 'Could not find Coconut executable')


def generate(env):
env['COCONUT'] = _detect(env)
env['COCONUTFLAGS'] = []

coconut_compiler = Builder(
action='"$COCONUT" $COCONUTFLAGS $SOURCE $TARGET',
src_suffix='.coco',
suffix='.py',
)

env.Append(BUILDERS={'Coconut': coconut_compiler})

def exists(env):
return env.Detect('coconut')


37 changes: 37 additions & 0 deletions builders/go.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from SCons.Builder import Builder
import SCons.Util

class ToolGoWarning(SCons.Warnings.SConsWarning):
pass

class GoNotFound(ToolGoWarning):
pass

SCons.Warnings.enableWarningClass(ToolGoWarning)

def _detect(env):
try:
return env['go']
except KeyError:
pass

go = env.WhereIs('go')
if go:
return go

SCons.Warnings.warn(GoNotFound, 'Could not find go executable')

def exists(env):
env.Detect('go')

def generate(env):
env['GO'] = _detect(env)
env['GOFLAGS'] = []

go_builder = Builder(
action='"$GO" build -o $TARGET $GOFLAGS $SOURCE',
src_suffix='.go',
suffix='$PROGSUFFIX',
)

env.Append(BUILDERS={'Go': go_builder})
Loading