diff options
author | Li Jin <dragon-fly@qq.com> | 2020-08-13 11:21:22 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2020-08-13 11:21:22 +0800 |
commit | 1afca4888b2ee8e49c2e4d0bef478d0728d5ed41 (patch) | |
tree | 5eeba783f9b56b2e74297cd1ce3e8bd8a1fa4d5d | |
parent | b842635fe941ab8f22d52d453bac91b6edd38f91 (diff) | |
download | yuescript-1afca4888b2ee8e49c2e4d0bef478d0728d5ed41.tar.gz yuescript-1afca4888b2ee8e49c2e4d0bef478d0728d5ed41.tar.bz2 yuescript-1afca4888b2ee8e49c2e4d0bef478d0728d5ed41.zip |
add make target to build .so file.
-rw-r--r-- | README.md | 14 | ||||
-rw-r--r-- | makefile | 24 |
2 files changed, 33 insertions, 5 deletions
@@ -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 |   Build `moonp.so` file with |
30 | |||
31 | ```sh | ||
32 | > make shared LUAI=/usr/local/include/lua LUAL=/usr/local/lib/lua | ||
33 | ``` | ||
34 | |||
35 |   Then get the binary file from path `bin/shared/moonp.so`. | ||
36 | |||
37 |   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 |   Require the module in Lua: | 43 |   Then require the module in Lua: |
36 | 44 | ||
37 | ```Lua | 45 | ```Lua |
38 | require("moonp")("main") -- require `main.moon` | 46 | require("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 |   Clone this repo, then build and install executable with: |
58 | 66 | ||
59 | ```sh | 67 | ```sh |
60 | > make install | 68 | > make install |
@@ -79,12 +79,15 @@ release: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(RCOMPILE_FLAGS) | |||
79 | release: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(RLINK_FLAGS) | 79 | release: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(RLINK_FLAGS) |
80 | debug: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(DCOMPILE_FLAGS) | 80 | debug: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(DCOMPILE_FLAGS) |
81 | debug: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(DLINK_FLAGS) | 81 | debug: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(DLINK_FLAGS) |
82 | shared: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(RCOMPILE_FLAGS) | ||
82 | 83 | ||
83 | # Build and output paths | 84 | # Build and output paths |
84 | release: export BUILD_PATH := build/release | 85 | release: export BUILD_PATH := build/release |
85 | release: export BIN_PATH := bin/release | 86 | release: export BIN_PATH := bin/release |
86 | debug: export BUILD_PATH := build/debug | 87 | debug: export BUILD_PATH := build/debug |
87 | debug: export BIN_PATH := bin/debug | 88 | debug: export BIN_PATH := bin/debug |
89 | shared: export BUILD_PATH := build/shared | ||
90 | shared: export BIN_PATH := bin/shared | ||
88 | install: export BIN_PATH := bin/release | 91 | install: 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 |
155 | release: dirs | 158 | release: dirs |
156 | ifeq ($(USE_VERSION), true) | 159 | ifeq ($(USE_VERSION), true) |
157 | @echo "Beginning release build v$(VERSION_STRING)" | 160 | @echo "Beginning release build $(VERSION_STRING)" |
158 | else | 161 | else |
159 | @echo "Beginning release build" | 162 | @echo "Beginning release build" |
160 | endif | 163 | endif |
@@ -168,7 +171,7 @@ endif | |||
168 | .PHONY: debug | 171 | .PHONY: debug |
169 | debug: dirs | 172 | debug: dirs |
170 | ifeq ($(USE_VERSION), true) | 173 | ifeq ($(USE_VERSION), true) |
171 | @echo "Beginning debug build v$(VERSION_STRING)" | 174 | @echo "Beginning debug build $(VERSION_STRING)" |
172 | else | 175 | else |
173 | @echo "Beginning debug build" | 176 | @echo "Beginning debug build" |
174 | endif | 177 | endif |
@@ -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 | ||
189 | shared: dirs | ||
190 | ifeq ($(USE_VERSION), true) | ||
191 | @echo "Beginning release build $(VERSION_STRING)" | ||
192 | else | ||
193 | @echo "Beginning release build" | ||
194 | endif | ||
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 |
183 | dirs: | 203 | dirs: |