Skip to content

Commit 631995c

Browse files
committed
Added C# compilation through the mono-devel package
1 parent 5aabe09 commit 631995c

File tree

4 files changed

+57
-3
lines changed

4 files changed

+57
-3
lines changed

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
66

77
# [Optional] Uncomment this section to install additional OS packages.
88
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
9-
&& 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 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 cmake
9+
&& 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 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 cmake mono-devel
1010

1111
# Setup Crystal
1212
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
@@ -98,7 +98,7 @@ ENV PATH=$PATH:~/elm
9898

9999
# Setup V
100100
RUN mkdir -p ~/vlang && wget https://github.com/vlang/v/releases/download/weekly.2021.44/v_linux.zip -O ~/vlang/vlang.zip && \
101-
unzip ~/vlang/vlang.zip -d ~/vlang
101+
unzip ~/vlang/vlang.zip -d ~/vlang
102102
ENV PATH=$PATH:~/vlang/v
103103

104104
# Install the packages that needed extra help
@@ -109,4 +109,3 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
109109
RUN pip install wheel matplotlib numpy coconut scons
110110

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

SConstruct

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ available_languages = {
2828
'bash',
2929
'c',
3030
'cpp',
31+
'csharp',
3132
'fortran',
3233
'java',
3334
'julia',
@@ -43,6 +44,7 @@ available_languages = {
4344

4445
languages_to_import = {
4546
'coconut': ['coconut'],
47+
'csharp': ['mcs'],
4648
'go': ['go'],
4749
'rust': ['rustc', 'cargo'],
4850
'kotlin': ['kotlin'],
@@ -77,6 +79,7 @@ languages = {
7779
'c': 'c',
7880
'coconut': 'coco',
7981
'cpp': 'cpp',
82+
'csharp': 'cs',
8083
'fortran': 'f90',
8184
'go': 'go',
8285
'java': 'java',

builders/mcs.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from SCons.Builder import Builder
2+
import SCons.Util
3+
4+
class ToolMCSWarning(SCons.Warnings.SConsWarning):
5+
pass
6+
7+
class MCSNotFound(ToolMCSWarning):
8+
pass
9+
10+
SCons.Warnings.enableWarningClass(ToolMCSWarning)
11+
12+
def _detect(env):
13+
try:
14+
return env['mcs']
15+
except KeyError:
16+
pass
17+
18+
go = env.WhereIs('mcs')
19+
if go:
20+
return go
21+
22+
SCons.Warnings.warn(MCSNotFound, 'Could not find mcs executable')
23+
24+
def exists(env):
25+
env.Detect('mcs')
26+
27+
def generate(env):
28+
env['MCS'] = _detect(env)
29+
env['MCSFLAGS'] = []
30+
31+
mcs_builder = Builder(
32+
action='"$MCS" -out:$TARGET $MCSFLAGS $SOURCES',
33+
src_suffix='.cs',
34+
suffix='$PROGSUFFIX',
35+
)
36+
37+
env.Append(BUILDERS={'MCS': mcs_builder})

sconscripts/csharp_SConscript

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Import('files_to_compile env')
2+
3+
language = files_to_compile[0].language
4+
chapter = files_to_compile[0].chapter
5+
6+
from collections import defaultdict
7+
chapter_files = defaultdict(list)
8+
9+
for file_info in files_to_compile:
10+
chapter_files[file_info.chapter].append(file_info.path)
11+
12+
for chapter, files in chapter_files.items():
13+
build_target = f'#/build/{language}/{chapter}/{chapter}'
14+
build_result = env.MCS(build_target, [str(file) for file in files])
15+
env.Alias(str(chapter), build_result)

0 commit comments

Comments
 (0)