Skip to content

Commit 2ee5ba5

Browse files
author
Sebastian Blessing
committed
new build system, abandoned premake. Linker issues left to fix
1 parent 712462e commit 2ee5ba5

File tree

128 files changed

+697
-240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+697
-240
lines changed

.gitignore

+1-17
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,7 @@
33
*.s
44
*.ll
55
*.bc
6-
Makefile
76
bin
8-
Build
9-
Bench
10-
*.make
11-
lib
12-
obj
13-
output
14-
hmm*
7+
work
158
.gitattributes
16-
*.bc
179
_ReSharper.*
18-
19-
# Visual Studio files
20-
*.vcxproj*
21-
*.sln
22-
*.suo
23-
*.opensdf
24-
*.sdf
25-

Makefile

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
ifeq ($(verbose),1)
2+
PRINT := @echo "$(1)";
3+
endif
4+
5+
# default settings (silent debug build)
6+
LIB_EXT ?= a
7+
BUILD_FLAGS = -m64 -mcx16 -march=native -Werror
8+
LINKER_FLAGS =
9+
ALL_CFLAGS = -std=gnu11
10+
ALL_CXXFLAGS = -std=gnu++11
11+
DEFINES =
12+
PRINT =
13+
14+
ifeq ($(config),release)
15+
BUILD_FLAGS += -O3
16+
LINKER_FLAGS += -fuse-ld=gold
17+
DEFINES += NDEBUG
18+
else
19+
config = debug
20+
BUILD_FLAGS += -g
21+
DEFINES += DEBUG
22+
endif
23+
24+
PONY_BUILD_DIR ?= build/$(config)
25+
PONY_SOURCE_DIR ?= src
26+
PONY_TEST_DIR ?= test
27+
28+
lib := $(PONY_BUILD_DIR)/lib
29+
bin := $(PONY_BUILD_DIR)/bin
30+
tests := $(PONY_BUILD_DIR)/tests
31+
32+
$(shell mkdir -p $(lib))
33+
$(shell mkdir -p $(bin))
34+
$(shell mkdir -p $(tests))
35+
36+
obj := $(PONY_BUILD_DIR)/obj
37+
38+
LINKER_FLAGS += -L $(lib)/
39+
40+
# libraries
41+
libponyc := $(lib)/libponyc
42+
libponycc := $(lib)/libponycc
43+
libponyrt := $(lib)/libponyrt
44+
45+
# Define special case rules for a targets source files. By default
46+
# this makefile assumes that a targets source files can be found
47+
# relative to a parent directory of the same name in $(PONY_SOURCE_DIR).
48+
# Note that it is possible to collect files and exceptions with
49+
# arbitrarily complex shell commands, as long as ':=' is used
50+
# for definition, instead of '='.
51+
libponycc.dir := src/libponyc
52+
libponycc.files := src/libponyc/debug/dwarf.cc
53+
libponycc.files += src/libponyc/debug/symbols.cc
54+
libponycc.files += src/libponyc/codegen/host.cc
55+
56+
libponyc.except := $(libponycc.files)
57+
libponyc.except += src/libponyc/platform/signed.cc
58+
libponyc.except += src/libponyc/platform/unsigned.cc
59+
libponyc.except += src/libponyc/platform/vcvars.c
60+
61+
# Third party, but requires compilation. Defined as
62+
# (1) a name and output directory.
63+
# (2) a list of the source files to be compiled.
64+
gtest := $(lib)
65+
gtest.dir := lib/gtest
66+
gtest.files := $(gtest.dir)/gtest_main.cc $(gtest.dir)/gtest-all.cc
67+
68+
libraries := libponyc libponycc libponyrt gtest
69+
70+
# Third party, but prebuilt. Prebuilt libraries are defined as
71+
# (1) a name (without a target directory), stored in "prebuilt".
72+
# (2) the linker flags necessary to link against the prebuilt library/libraries.
73+
# (3) a list of include directories for a set of libraries.
74+
# (4) a list of the libraries to link against.
75+
llvm.ldflags := $(shell llvm-config-3.5 --ldflags)
76+
llvm.include := $(shell llvm-config-3.5 --includedir)
77+
llvm.libs := $(shell llvm-config-3.5 --libs)
78+
79+
prebuilt := llvm
80+
81+
# Binaries. Defined as
82+
# (1) a name and output directory.
83+
ponyc := $(bin)
84+
85+
binaries := ponyc
86+
87+
# Define include paths for targets if necessary. Note that these include paths
88+
# will automatically apply to the test suite of a target as well.
89+
libponyc.include := src/common/ $(llvm.include)/
90+
libponycc.include := src/common/ $(llvm.include)/
91+
libponyrt.include := src/common/ src/libponyrt/
92+
93+
ponyc.include := src/common/
94+
gtest.include := lib/gtest/
95+
96+
# Tests suites are directly attached to the libraries they test.
97+
libponyc.tests := $(tests)
98+
libponyrt.tests := $(tests)
99+
100+
tests := libponyc.tests libponyrt.tests
101+
102+
# target specific build options
103+
104+
# link relationships
105+
libponyc.links = -lponycc
106+
107+
# make targets
108+
targets := $(libraries) $(binaries) $(tests)
109+
110+
.PHONY: all $(targets)
111+
112+
all: $(targets)
113+
114+
-include Rules.mk
115+
116+
$(foreach target,$(targets),$(eval $(call EXPAND_COMMAND,$(target))))
117+
118+
# dependencies
119+
libponycc:
120+
libponyrt:
121+
libponyc: libponycc libponyrt
122+
libponyc.tests: libponyc gtest
123+
libponyrt.tests: libponyrt gtest
124+
ponyc: libponyc
125+
gtest:
126+
127+
stats:
128+
@echo
129+
@echo '------------------------------'
130+
@echo 'Compiler and standard library '
131+
@echo '------------------------------'
132+
@echo
133+
@cloc --read-lang-def=misc/pony.cloc src packages
134+
@echo
135+
@echo '------------------------------'
136+
@echo 'Test suite:'
137+
@echo '------------------------------'
138+
@echo
139+
@cloc --read-lang-def=misc/pony.cloc test
140+
141+
clean:
142+
@rm -rf build
143+
@echo 'Repository cleaned.'
144+
145+
help:
146+
@echo
147+
@echo 'Usage: make [config=name] [target]'
148+
@echo
149+
@echo "CONFIGURATIONS:"
150+
@echo " debug"
151+
@echo " release"
152+
@echo
153+
@echo 'TARGETS:'
154+
@echo ' libponyc Pony compiler library'
155+
@echo ' libponycc Pony compiler C++ LLVM bindings'
156+
@echo ' libponyrt Pony runtime'
157+
@echo ' libponyc.tests Test suite for libponyc'
158+
@echo ' libponyrt.tests Test suite for libponyrt'
159+
@echo ' ponyc Pony compiler executable'
160+
@echo
161+
@echo ' all Build all targets (default)'
162+
@echo ' stats Print Pony cloc statistics'
163+
@echo ' clean Delete all build files'
164+
@echo

Rules.mk

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
empty :=
2+
space := $(empty) $(empty)
3+
4+
##########################################################################
5+
# #
6+
# DIRECTORY: determines the source dir of a specific target #
7+
# #
8+
# ENUMERATE: enumerates input and output files for a specific target #
9+
# #
10+
# PICK_COMPILER: Chooses a C or C++ compiler depending on the target. #
11+
# #
12+
# EXPAND_COMMAND: macro that expands to a proper make command for each #
13+
# target. #
14+
##########################################################################
15+
define DIRECTORY
16+
$(eval sourcedir := )
17+
$(eval outdir := $(obj)/$(1))
18+
19+
ifdef $(1).dir
20+
sourcedir := $($(1).dir)
21+
else ifneq ($$(filter $(1),$(tests)),)
22+
sourcedir := $(PONY_TEST_DIR)/$(subst .tests,,$(1))
23+
outdir := $(obj)/tests/$(subst .tests,,$(1))
24+
else
25+
sourcedir := $(PONY_SOURCE_DIR)/$(1)
26+
endif
27+
endef
28+
29+
define ENUMERATE
30+
$(eval sourcefiles := )
31+
32+
ifdef $(1).files
33+
sourcefiles := $$($(1).files)
34+
else
35+
sourcefiles := $$(shell find $$(sourcedir) -type f -name "*.c" -or -name "*.cc" | grep -v '.*/\.')
36+
endif
37+
38+
ifdef $(1).except
39+
sourcefiles := $$(filter-out $($(1).except),$$(sourcefiles))
40+
endif
41+
endef
42+
43+
define PICK_COMPILER
44+
$(eval compiler := $(CC) $(ALL_CFLAGS))
45+
46+
ifneq ($$(filter $(suffix $(sourcefiles)),.cc),)
47+
compiler := $(CXX) $(ALL_CXXFLAGS)
48+
endif
49+
endef
50+
51+
define PREPARE
52+
$(eval $(call DIRECTORY,$(1)))
53+
$(eval $(call ENUMERATE,$(1)))
54+
$(eval $(call PICK_COMPILER,$(sourcefiles)))
55+
$(eval objectfiles := $(subst $(sourcedir)/,$(outdir)/,$(addsuffix .o,$(sourcefiles))))
56+
$(eval dependencies := $(subst .o,.d,$(objectfiles)))
57+
endef
58+
59+
define EXPAND_OBJCMD
60+
$(subst .c,,$(subst .cc,,$(1))): $(subst $(outdir)/,$(sourcedir)/,$(subst .o,,$(1)))
61+
@echo 'COMPILE $$(notdir $$<)'
62+
@mkdir -p $$(dir $$@)
63+
@$(compiler) $(BUILD_FLAGS) -c -o $$@ $$< -I $(subst $(space), -I ,$($(2).include))
64+
endef
65+
66+
define EXPAND_DEPCMD
67+
$(subst .c,,$(subst .cc,,$(1))): $(subst $(outdir)/,$(sourcedir)/,$(subst .d,,$(1)))
68+
@echo 'DEPEND $$(notdir $$@)'
69+
@mkdir -p $$(dir $$@)
70+
@$(compiler) -MM -MT $$(subst .d,.o,$$@) -MF $$@ $(BUILD_FLAGS) $$<
71+
endef
72+
73+
define EXPAND_COMMAND
74+
$(eval $(call PREPARE,$(1)))
75+
$(eval ofiles := $(subst .c,,$(subst .cc,,$(objectfiles))))
76+
77+
ifneq ($(filter $(1),$(libraries)),)
78+
$(1): $(ofiles)
79+
@echo 'LINK $(1)'
80+
@$(compiler) -o $($(1))/$(1).$(LIB_EXT) $(ofiles) $(LINKER_FLAGS) $($(1).ldflags) $($(1).links)
81+
else
82+
$(1): $(ofiles)
83+
@echo 'BINARY $(1)'
84+
@$(compiler) -o $($(1))/$(1) $(ofiles) $(LINKER_FLAGS) $($(1).ldflags) $($(1).links)
85+
endif
86+
87+
$(foreach ofile,$(objectfiles),$(eval $(call EXPAND_OBJCMD,$(ofile),$(1))))
88+
$(foreach dfile,$(dependencies),$(eval $(call EXPAND_DEPCMD,$(dfile))))
89+
90+
endef

build/debug/lib/gtest.a

787 KB
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/examples/gups/gups_opt/main.pony examples/gups/gups_opt/main.pony

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ actor Updater
171171
match others
172172
| var next: Array[Updater] val =>
173173
try next(i).receive(consume data) end
174+
let test = data
174175
end
175176
end
176177
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pony.cloc misc/pony.cloc

File renamed without changes.

pony.g misc/pony.g

File renamed without changes.

0 commit comments

Comments
 (0)