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

more build system support, license typo #18

Merged
merged 4 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ build/
.vscode/
.idea/

compile_commands.json
compile_commands.json

compiler/lexer/flex_lexer.cpp
compiler/parser/bison_parser.cpp
compiler/parser/bison_parser.hpp
compiler/parser/location.hh

.ninja_deps
.ninja_log
143 changes: 143 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# this is the build file for project swallow
# it is autogenerated by the xmake build system.
# do not edit by hand.

# project
cmake_minimum_required(VERSION 3.15.0)
cmake_policy(SET CMP0091 NEW)
project(swallow VERSION 0.0.1 LANGUAGES CXX)

# target
add_library(stdlib SHARED "")
set_target_properties(stdlib PROPERTIES OUTPUT_NAME "stdlib")
set_target_properties(stdlib PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/build/linux/x86_64/debug")
target_compile_options(stdlib PRIVATE
$<$<COMPILE_LANGUAGE:C>:-m64>
$<$<COMPILE_LANGUAGE:CXX>:-m64>
)
set_target_properties(stdlib PROPERTIES CXX_EXTENSIONS OFF)
target_compile_features(stdlib PRIVATE cxx_std_20)
if(MSVC)
target_compile_options(stdlib PRIVATE $<$<CONFIG:Debug>:-Od>)
else()
target_compile_options(stdlib PRIVATE -O0)
endif()
if(MSVC)
target_compile_options(stdlib PRIVATE -Zi)
else()
target_compile_options(stdlib PRIVATE -g)
endif()
if(MSVC)
set_property(TARGET stdlib PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
target_link_options(stdlib PRIVATE
-m64
)
target_sources(stdlib PRIVATE
stdlib/stdlib.cpp
)

# target
add_executable(swc "")
set_target_properties(swc PROPERTIES OUTPUT_NAME "swc")
set_target_properties(swc PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/build/linux/x86_64/debug")
add_dependencies(swc stdlib)
target_include_directories(swc PRIVATE
compiler
compiler/ast
compiler/type
compiler/lexer
compiler/parser
compiler/diagnostics
compiler/utils
)
target_compile_options(swc PRIVATE
$<$<COMPILE_LANGUAGE:C>:-m64>
$<$<COMPILE_LANGUAGE:CXX>:-m64>
)
set_target_properties(swc PROPERTIES CXX_EXTENSIONS OFF)
target_compile_features(swc PRIVATE cxx_std_20)
if(MSVC)
target_compile_options(swc PRIVATE $<$<CONFIG:Debug>:-Od>)
else()
target_compile_options(swc PRIVATE -O0)
endif()
if(MSVC)
target_compile_options(swc PRIVATE -Zi)
else()
target_compile_options(swc PRIVATE -g)
endif()
if(MSVC)
set_property(TARGET swc PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
target_link_libraries(swc PRIVATE
c++
stdlib
)
target_link_directories(swc PRIVATE
build/linux/x86_64/debug
)
target_link_options(swc PRIVATE
-m64
)
target_sources(swc PRIVATE
compiler/compiler.cpp
compiler/ast/ast.cpp
compiler/ast/dump.cpp
compiler/ast/g-machine.cpp
compiler/ast/type.cpp
compiler/diagnostics/reporter.cpp
compiler/diagnostics/utils.cpp
compiler/diagnostics/diagnostics.cpp
compiler/g-machine/binop.cpp
compiler/g-machine/environment.cpp
compiler/g-machine/instruction.cpp
compiler/lexer/lexer.cpp
compiler/lexer/flex_lexer.cpp
compiler/parser/parser.cpp
compiler/parser/bison_parser.cpp
compiler/type/dump.cpp
compiler/type/environment.cpp
compiler/type/type.cpp
)

# target
add_executable(swi "")
set_target_properties(swi PROPERTIES OUTPUT_NAME "swi")
set_target_properties(swi PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/build/linux/x86_64/debug")
add_dependencies(swi swc)
target_compile_options(swi PRIVATE
$<$<COMPILE_LANGUAGE:C>:-m64>
$<$<COMPILE_LANGUAGE:CXX>:-m64>
)
set_target_properties(swi PROPERTIES CXX_EXTENSIONS OFF)
target_compile_features(swi PRIVATE cxx_std_20)
if(MSVC)
target_compile_options(swi PRIVATE $<$<CONFIG:Debug>:-Od>)
else()
target_compile_options(swi PRIVATE -O0)
endif()
if(MSVC)
target_compile_options(swi PRIVATE -Zi)
else()
target_compile_options(swi PRIVATE -g)
endif()
if(MSVC)
set_property(TARGET swi PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
target_link_libraries(swi PRIVATE
stdlib
)
target_link_directories(swi PRIVATE
build/linux/x86_64/debug
)
target_link_options(swi PRIVATE
-m64
)
target_sources(swi PRIVATE
repl/main.cpp
)

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ are permitted provided that the following conditions are met:
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Terifo nor the names of its contributors
* Neither the name of Swallow nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

Expand Down
16 changes: 0 additions & 16 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ are permitted provided that the following conditions are met:
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Terifo nor the names of its contributors
* Neither the name of Swallow nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

Expand Down
1 change: 1 addition & 0 deletions after_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
find . -iname '*.h' -o -iname '*.cpp' -o -iname '*.hpp' -o -iname '*.hh' | xargs clang-format -i
156 changes: 156 additions & 0 deletions build.ninja
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# this is the build file for project swallow
# it is autogenerated by the xmake build system.
# do not edit by hand.

ninja_required_version = 1.5.1

rule gen
command = xmake project -P . -k ninja
description = regenerating ninja files

# rules for compiler
rule cxx
command = /usr/bin/gcc $ARGS -MMD -MF $out.d -o $out -c $in
deps = gcc
depfile = $out.d
description = compiling.debug $in

rule cu
command = /usr/bin/clang $ARGS -MMD -MF $out.d -o $out -c $in
deps = gcc
depfile = $out.d
description = compiling.debug $in

rule as
command = /usr/bin/gcc $ARGS -MMD -MF $out.d -o $out -c $in
deps = gcc
depfile = $out.d
description = compiling.debug $in

rule cc
command = /usr/bin/gcc $ARGS -MMD -MF $out.d -o $out -c $in
deps = gcc
depfile = $out.d
description = compiling.debug $in

rule mxx
command = /usr/bin/gcc $ARGS -MMD -MF $out.d -o $out -c $in
deps = gcc
depfile = $out.d
description = compiling.debug $in

rule mm
command = /usr/bin/gcc $ARGS -MMD -MF $out.d -o $out -c $in
deps = gcc
depfile = $out.d
description = compiling.debug $in


# rules for linker
rule sh
command = /usr/bin/g++ -o $out $in $ARGS
description = linking.debug $out

rule ld
command = /usr/bin/g++ -o $out $in $ARGS
description = linking.debug $out

rule ar
command = /usr/bin/ar $ARGS $out $in
description = archiving.debug $out


# build targets

# build build.ninja
build build.ninja: gen $
xmake.lua $
compiler/xmake.lua $
stdlib/xmake.lua $
repl/xmake.lua $
compiler/xmake.lua $
stdlib/xmake.lua $
stdlib/xmake.lua

# build target: stdlib
build stdlib: phony build/linux/x86_64/debug/libstdlib.so
build build/linux/x86_64/debug/libstdlib.so: sh build/.objs/stdlib/linux/x86_64/debug/stdlib/stdlib.cpp.o
ARGS = -shared -m64 -fPIC

build build/.objs/stdlib/linux/x86_64/debug/stdlib/stdlib.cpp.o: cxx stdlib/stdlib.cpp
ARGS = -m64 -fPIC -g -O0 -std=c++20

# build target: swi
build swi: phony build/linux/x86_64/debug/swi
build build/linux/x86_64/debug/swi: ld build/.objs/swi/linux/x86_64/debug/repl/main.cpp.o || $
build/linux/x86_64/debug/swc
ARGS = -m64 -Lbuild/linux/x86_64/debug -Wl,-rpath=$ORIGIN -lstdlib

build build/.objs/swi/linux/x86_64/debug/repl/main.cpp.o: cxx repl/main.cpp
ARGS = -m64 -g -O0 -std=c++20

# build target: swc
build swc: phony build/linux/x86_64/debug/swc
build build/linux/x86_64/debug/swc: ld build/.objs/swc/linux/x86_64/debug/compiler/compiler.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/ast/ast.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/ast/dump.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/ast/g-machine.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/ast/type.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/diagnostics/reporter.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/diagnostics/utils.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/diagnostics/diagnostics.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/g-machine/binop.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/g-machine/environment.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/g-machine/instruction.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/lexer/lexer.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/lexer/flex_lexer.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/parser/parser.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/parser/bison_parser.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/type/dump.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/type/environment.cpp.o build/.objs/swc/linux/x86_64/debug/compiler/type/type.cpp.o || $
build/linux/x86_64/debug/libstdlib.so
ARGS = -m64 -Lbuild/linux/x86_64/debug -Wl,-rpath=$ORIGIN -lc++ -lstdlib

build build/.objs/swc/linux/x86_64/debug/compiler/compiler.cpp.o: cxx compiler/compiler.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/ast/ast.cpp.o: cxx compiler/ast/ast.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/ast/dump.cpp.o: cxx compiler/ast/dump.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/ast/g-machine.cpp.o: cxx compiler/ast/g-machine.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/ast/type.cpp.o: cxx compiler/ast/type.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/diagnostics/reporter.cpp.o: cxx compiler/diagnostics/reporter.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/diagnostics/utils.cpp.o: cxx compiler/diagnostics/utils.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/diagnostics/diagnostics.cpp.o: cxx compiler/diagnostics/diagnostics.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/g-machine/binop.cpp.o: cxx compiler/g-machine/binop.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/g-machine/environment.cpp.o: cxx compiler/g-machine/environment.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/g-machine/instruction.cpp.o: cxx compiler/g-machine/instruction.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/lexer/lexer.cpp.o: cxx compiler/lexer/lexer.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/lexer/flex_lexer.cpp.o: cxx compiler/lexer/flex_lexer.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/parser/parser.cpp.o: cxx compiler/parser/parser.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/parser/bison_parser.cpp.o: cxx compiler/parser/bison_parser.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/type/dump.cpp.o: cxx compiler/type/dump.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/type/environment.cpp.o: cxx compiler/type/environment.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build build/.objs/swc/linux/x86_64/debug/compiler/type/type.cpp.o: cxx compiler/type/type.cpp
ARGS = -m64 -g -O0 -std=c++20 -Icompiler -Icompiler/ast -Icompiler/type -Icompiler/lexer -Icompiler/parser -Icompiler/diagnostics -Icompiler/utils

build default: phony stdlib swi swc
build all: phony stdlib swi swc

default default

2 changes: 1 addition & 1 deletion compiler/ast/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// notice,
// this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Terifo nor the names of its contributors
// * Neither the name of Swallow nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
Expand Down
2 changes: 1 addition & 1 deletion compiler/ast/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// notice,
// this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Terifo nor the names of its contributors
// * Neither the name of Swallow nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
Expand Down
2 changes: 1 addition & 1 deletion compiler/ast/dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// notice,
// this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Terifo nor the names of its contributors
// * Neither the name of Swallow nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
Expand Down
Loading
Loading