Skip to content
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

A new cpp implementation #641

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions IMPLS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ IMPL:
- {IMPL: c}
- {IMPL: c.2}
- {IMPL: cpp}
- {IMPL: cpp.2}
- {IMPL: coffee}
- {IMPL: cs}
- {IMPL: chuck, NO_SELF_HOST_PERF: 1} # perf OOM
Expand Down
3 changes: 2 additions & 1 deletion Makefile.impls
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ wasm_MODE = wasmtime
# Implementation specific settings
#

IMPLS = ada ada.2 awk bash basic bbc-basic c c.2 chuck clojure coffee common-lisp cpp crystal cs d dart \
IMPLS = ada ada.2 awk bash basic bbc-basic c c.2 chuck clojure coffee common-lisp cpp cpp.2 crystal cs d dart \
elisp elixir elm erlang es6 factor fantom fennel forth fsharp go groovy gnu-smalltalk \
guile haskell haxe hy io janet java java-truffle js jq julia kotlin latex3 livescript logo lua make mal \
matlab miniMAL nasm nim objc objpascal ocaml perl perl6 php picolisp pike plpgsql \
Expand Down Expand Up @@ -117,6 +117,7 @@ clojure_STEP_TO_PROG = $(clojure_STEP_TO_PROG_$(clojure_MODE))
coffee_STEP_TO_PROG = impls/coffee/$($(1)).coffee
common-lisp_STEP_TO_PROG = impls/common-lisp/$($(1))
cpp_STEP_TO_PROG = impls/cpp/$($(1))
cpp.2_STEP_TO_PROG = impls/cpp.2/$($(1))
crystal_STEP_TO_PROG = impls/crystal/$($(1))
cs_STEP_TO_PROG = impls/cs/$($(1)).exe
d_STEP_TO_PROG = impls/d/$($(1))
Expand Down
2 changes: 2 additions & 0 deletions impls/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ old
ada/obj/
awk/mal.awk
bash/mal.sh
cc/*.a
cc/.deps
clojure/mal.jar
clojure/target
clojure/.lein-repl-history
Expand Down
27 changes: 27 additions & 0 deletions impls/cpp.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ubuntu:24.04
MAINTAINER Le Yang <[email protected]>
LABEL org.opencontainers.image.source=https://github.com/kanaka/mal
LABEL org.opencontainers.image.description="mal test container: cpp.2"
##########################################################
# General requirements for testing or common across many
# implementations
##########################################################

RUN apt-get -y update

# Required for running tests
RUN apt-get -y install make python3
RUN ln -sf /usr/bin/python3 /usr/bin/python

# Some typical implementation and test requirements
RUN apt-get -y install curl libreadline-dev libedit-dev

RUN mkdir -p /mal
WORKDIR /mal

##########################################################
# Specific implementation requirements
##########################################################

# Install g++ for any C/C++ based implementations
RUN apt-get -y install g++
38 changes: 38 additions & 0 deletions impls/cpp.2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
LD=$(CXX)
DEBUG=-g
CXXFLAGS=-O2 -Wall $(DEBUG) $(INCPATHS) -std=c++17 #-fsanitize=address -fsanitize=leak
LDFLAGS=-O2 $(DEBUG) $(LIBPATHS) -L. -lreadline -lhistory #-fsanitize=address -fsanitize=leak

LIBSOURCES=reader.cc printer.cc core.cc
LIBOBJS=$(LIBSOURCES:%.cc=%.o)

MAINS=$(wildcard step*.cc)
TARGETS=$(MAINS:%.cc=%)

.PHONY: all clean

.SUFFIXES: .cc .o

all: $(TARGETS)

dist: mal

mal: stepA_mal
cp $< $@

.deps: *.cc *.hh
$(CXX) $(CXXFLAGS) -MM *.cc > .deps

$(TARGETS): %: %.o libmal.a
$(LD) $^ -o $@ $(LDFLAGS)

libmal.a: $(LIBOBJS)
$(AR) rcs $@ $^

.cc.o:
$(CXX) $(CXXFLAGS) -c $< -o $@

clean:
rm -rf *.o $(TARGETS) libmal.a .deps mal

-include .deps
Loading
Loading