aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2020-08-13 11:21:22 +0800
committerLi Jin <dragon-fly@qq.com>2020-08-13 11:21:22 +0800
commit1afca4888b2ee8e49c2e4d0bef478d0728d5ed41 (patch)
tree5eeba783f9b56b2e74297cd1ce3e8bd8a1fa4d5d
parentb842635fe941ab8f22d52d453bac91b6edd38f91 (diff)
downloadyuescript-1afca4888b2ee8e49c2e4d0bef478d0728d5ed41.tar.gz
yuescript-1afca4888b2ee8e49c2e4d0bef478d0728d5ed41.tar.bz2
yuescript-1afca4888b2ee8e49c2e4d0bef478d0728d5ed41.zip
add make target to build .so file.
-rw-r--r--README.md14
-rw-r--r--makefile24
2 files changed, 33 insertions, 5 deletions
diff --git a/README.md b/README.md
index ab2f857..4275320 100644
--- a/README.md
+++ b/README.md
@@ -26,13 +26,21 @@ So MoonPlus is a new code base for pushing the language to go forward and being
26 26
27* **Lua Module** 27* **Lua Module**
28 28
29 Install [luarocks](https://luarocks.org), a package manager for Lua modules. Then install it as a Lua module. 29&emsp;&emsp;Build `moonp.so` file with
30
31```sh
32> make shared LUAI=/usr/local/include/lua LUAL=/usr/local/lib/lua
33```
34
35&emsp;&emsp;Then get the binary file from path `bin/shared/moonp.so`.
36
37&emsp;&emsp;Or you can install [luarocks](https://luarocks.org), a package manager for Lua modules. Then install it as a Lua module with
30 38
31```sh 39```sh
32> luarocks install moonplus 40> luarocks install moonplus
33``` 41```
34 42
35&emsp;&emsp;Require the module in Lua: 43&emsp;&emsp;Then require the module in Lua:
36 44
37```Lua 45```Lua
38require("moonp")("main") -- require `main.moon` 46require("moonp")("main") -- require `main.moon`
@@ -54,7 +62,7 @@ f!
54 62
55* **Binary Tool** 63* **Binary Tool**
56 64
57 Clone this repo, then build and install executable with: 65&emsp;&emsp;Clone this repo, then build and install executable with:
58 66
59```sh 67```sh
60> make install 68> make install
diff --git a/makefile b/makefile
index 0c29230..70d6c97 100644
--- a/makefile
+++ b/makefile
@@ -79,12 +79,15 @@ release: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(RCOMPILE_FLAGS)
79release: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(RLINK_FLAGS) 79release: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(RLINK_FLAGS)
80debug: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(DCOMPILE_FLAGS) 80debug: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(DCOMPILE_FLAGS)
81debug: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(DLINK_FLAGS) 81debug: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(DLINK_FLAGS)
82shared: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(RCOMPILE_FLAGS)
82 83
83# Build and output paths 84# Build and output paths
84release: export BUILD_PATH := build/release 85release: export BUILD_PATH := build/release
85release: export BIN_PATH := bin/release 86release: export BIN_PATH := bin/release
86debug: export BUILD_PATH := build/debug 87debug: export BUILD_PATH := build/debug
87debug: export BIN_PATH := bin/debug 88debug: export BIN_PATH := bin/debug
89shared: export BUILD_PATH := build/shared
90shared: export BIN_PATH := bin/shared
88install: export BIN_PATH := bin/release 91install: export BIN_PATH := bin/release
89 92
90# Find all source files in the source directory, sorted by most 93# Find all source files in the source directory, sorted by most
@@ -154,7 +157,7 @@ endif
154.PHONY: release 157.PHONY: release
155release: dirs 158release: dirs
156ifeq ($(USE_VERSION), true) 159ifeq ($(USE_VERSION), true)
157 @echo "Beginning release build v$(VERSION_STRING)" 160 @echo "Beginning release build $(VERSION_STRING)"
158else 161else
159 @echo "Beginning release build" 162 @echo "Beginning release build"
160endif 163endif
@@ -168,7 +171,7 @@ endif
168.PHONY: debug 171.PHONY: debug
169debug: dirs 172debug: dirs
170ifeq ($(USE_VERSION), true) 173ifeq ($(USE_VERSION), true)
171 @echo "Beginning debug build v$(VERSION_STRING)" 174 @echo "Beginning debug build $(VERSION_STRING)"
172else 175else
173 @echo "Beginning debug build" 176 @echo "Beginning debug build"
174endif 177endif
@@ -178,6 +181,23 @@ endif
178 @echo -n "Total build time: " 181 @echo -n "Total build time: "
179 @$(END_TIME) 182 @$(END_TIME)
180 183
184$(BUILD_PATH)/moonp.so: src/MoonP/ast.cpp src/MoonP/moon_compiler.cpp src/MoonP/moon_parser.cpp src/MoonP/moonplus.cpp src/MoonP/parser.cpp
185 $(CMD_PREFIX)$(CXX) $(CXXFLAGS) -I $(SRC_PATH) -I $(LUAI) -L $(LUAL) -llua -o $@ -fPIC -shared $?
186
187# Standard, non-optimized release build
188.PHONY: shared
189shared: dirs
190ifeq ($(USE_VERSION), true)
191 @echo "Beginning release build $(VERSION_STRING)"
192else
193 @echo "Beginning release build"
194endif
195 @$(START_TIME)
196 @$(MAKE) $(BUILD_PATH)/moonp.so --no-print-directory
197 @echo -n "Total build time: "
198 @$(END_TIME)
199 @mv $(BUILD_PATH)/moonp.so $(BIN_PATH)/moonp.so
200
181# Create the directories used in the build 201# Create the directories used in the build
182.PHONY: dirs 202.PHONY: dirs
183dirs: 203dirs: