From 74f36630ff5f4c89f542f5a78167c8bc87ef1710 Mon Sep 17 00:00:00 2001 From: Diego Argueta Date: Fri, 20 Sep 2024 20:50:28 -0700 Subject: [PATCH 1/3] Move compiler-specific flags to CI --- .github/workflows/ci.yml | 4 ++++ Makefile | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ca5b379..296094fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,5 +45,9 @@ jobs: run: luarocks config - name: Install Binding run: luarocks build + env: + USER_CXX_FLAGS: -std=c++11 -Wall -Wextra -Werror -Wpedantic -pedantic-errors - name: Run tests run: luarocks test + env: + USER_CXX_FLAGS: -std=c++11 -Wall -Wextra -Werror -Wpedantic -pedantic-errors diff --git a/Makefile b/Makefile index 91579c62..9b14d075 100644 --- a/Makefile +++ b/Makefile @@ -97,8 +97,6 @@ ifndef USER_CXX_FLAGS USER_CXX_FLAGS = endif -OTHER_CXXFLAGS = -std=c++11 -DIS_LUAJIT=$(IS_LUAJIT) -WARN_FLAGS = -Wall -Wextra -Werror -Wpedantic -pedantic-errors INCLUDE_PATH_FLAGS = $(addprefix -I,$(HEADER_DIRECTORIES)) LIB_PATH_FLAGS = $(addprefix -L,$(LIBRARY_DIRECTORIES)) REQUIRED_LIBS = unicorn pthread stdc++ @@ -123,7 +121,7 @@ ifeq ($(OS),Darwin) endif endif -CXX_CMD = $(CC) $(OTHER_CXXFLAGS) $(USER_CXX_FLAGS) $(WARN_FLAGS) $(INCLUDE_PATH_FLAGS) +CXX_CMD = $(CC) $(USER_CXX_FLAGS) $(INCLUDE_PATH_FLAGS) LINK_CMD = $(LD) $(LIB_PATH_FLAGS) $(LDFLAGS) DOCTEST_TAG = v2.4.11 From d47adc68743ccdb8628b61a0b965f4a35073b076 Mon Sep 17 00:00:00 2001 From: Diego Argueta Date: Sat, 21 Sep 2024 05:36:10 -0700 Subject: [PATCH 2/3] JDIR was renamed to JROOT at some point --- src/unicornlua/compat.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unicornlua/compat.hpp b/src/unicornlua/compat.hpp index f36c99d6..39943e72 100644 --- a/src/unicornlua/compat.hpp +++ b/src/unicornlua/compat.hpp @@ -71,7 +71,7 @@ LUALIB_API void lua_rawsetp(lua_State *L, int index, const void *p); // http://lua-users.org/lists/lua-l/2011-11/msg01149.html #ifndef IS_LUAJIT -# ifdef LUA_JDIR +# if defined(LUA_JDIR) || defined(LUA_JROOT) # define IS_LUAJIT 1 # else # define IS_LUAJIT 0 From de922a595b2f9748e162c476684ec310c2e9798f Mon Sep 17 00:00:00 2001 From: Diego Argueta Date: Sat, 21 Sep 2024 21:27:16 -0700 Subject: [PATCH 3/3] Makefile simplifications and restructuring (#44) * Remove standard flags no longer needed, upgrade MacOS version tested * Fix C++ flags on MacOS * Fix table syntax, rearrange rockfile * Forgot to pass in Lua version to tests * I give up, always use C++11 * Reorganize stuff * Clang warnings about operator precedence in macro * Reorganize repo to simplify Busted invocation * Relocate stuff to simplify directory structure, rename things * No need to split `busted` invocation across multiple lines * CC -> CXX, remove extra paths * Try testing Unicorn 1.x only on Mac <14 * Those "extra paths" were not extra * Explain need for .SUFFIXES --- .github/workflows/ci.yml | 26 +++- .gitignore | 12 +- Makefile | 127 ++++++++---------- .../basic_control_functions.template | 0 {src => csrc}/compat.cpp | 0 {src => csrc}/context.cpp | 0 {src => csrc}/control_functions.cpp | 1 - {src => csrc}/engine.cpp | 0 {src => csrc}/errors.cpp | 0 {src => csrc}/hooks.cpp | 0 {src => csrc}/memory.cpp | 0 {src => csrc}/registers.template | 0 {src => csrc}/registers_const.template | 0 {src => csrc}/registers_misc.cpp | 0 .../template_data/basic_control_functions.lua | 0 .../template_data/register_types.lua | 0 {src => csrc}/transaction.cpp | 0 {src => csrc}/unicorn.cpp | 0 {src => csrc}/unicornlua/compat.hpp | 0 {src => csrc}/unicornlua/context.hpp | 0 .../unicornlua/control_functions.hpp | 0 {src => csrc}/unicornlua/engine.hpp | 0 {src => csrc}/unicornlua/errors.hpp | 0 {src => csrc}/unicornlua/hooks.hpp | 0 .../unicornlua/integer_conversions.hpp | 0 {src => csrc}/unicornlua/lua.hpp | 0 {src => csrc}/unicornlua/memory.hpp | 0 .../register_template_functions.hpp | 0 .../unicornlua/register_types.template | 0 {src => csrc}/unicornlua/registers.hpp | 0 {src => csrc}/unicornlua/transaction.hpp | 0 {src => csrc}/unicornlua/unicornlua.hpp | 0 {src => csrc}/unicornlua/utils.hpp | 0 {src => csrc}/utils.cpp | 0 tests/c/utils.cpp | 2 +- unicorn-2.2.1-1.rockspec | 68 +++++----- 36 files changed, 121 insertions(+), 115 deletions(-) rename {src => csrc}/basic_control_functions.template (100%) rename {src => csrc}/compat.cpp (100%) rename {src => csrc}/context.cpp (100%) rename {src => csrc}/control_functions.cpp (99%) rename {src => csrc}/engine.cpp (100%) rename {src => csrc}/errors.cpp (100%) rename {src => csrc}/hooks.cpp (100%) rename {src => csrc}/memory.cpp (100%) rename {src => csrc}/registers.template (100%) rename {src => csrc}/registers_const.template (100%) rename {src => csrc}/registers_misc.cpp (100%) rename {src => csrc}/template_data/basic_control_functions.lua (100%) rename {src => csrc}/template_data/register_types.lua (100%) rename {src => csrc}/transaction.cpp (100%) rename {src => csrc}/unicorn.cpp (100%) rename {src => csrc}/unicornlua/compat.hpp (100%) rename {src => csrc}/unicornlua/context.hpp (100%) rename {src => csrc}/unicornlua/control_functions.hpp (100%) rename {src => csrc}/unicornlua/engine.hpp (100%) rename {src => csrc}/unicornlua/errors.hpp (100%) rename {src => csrc}/unicornlua/hooks.hpp (100%) rename {src => csrc}/unicornlua/integer_conversions.hpp (100%) rename {src => csrc}/unicornlua/lua.hpp (100%) rename {src => csrc}/unicornlua/memory.hpp (100%) rename {src => csrc}/unicornlua/register_template_functions.hpp (100%) rename {src => csrc}/unicornlua/register_types.template (100%) rename {src => csrc}/unicornlua/registers.hpp (100%) rename {src => csrc}/unicornlua/transaction.hpp (100%) rename {src => csrc}/unicornlua/unicornlua.hpp (100%) rename {src => csrc}/unicornlua/utils.hpp (100%) rename {src => csrc}/utils.cpp (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 296094fb..5932eeb1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: matrix: operating-system: - ubuntu-latest - - macos-13 + - macos-latest lua-version: - "5.1" - "5.2" @@ -23,6 +23,26 @@ jobs: unicorn-version: - "1.0.3" - "2.0.1.post1" + exclude: + # Unicorn 1.x breaks on macOS 14+ + - operating-system: macos-latest + unicorn-version: "1.0.3" + include: + - operating-system: macos-13 + unicorn-version: "1.0.3" + lua-version: "5.1" + - operating-system: macos-13 + unicorn-version: "1.0.3" + lua-version: "5.2" + - operating-system: macos-13 + unicorn-version: "1.0.3" + lua-version: "5.3" + - operating-system: macos-13 + unicorn-version: "1.0.3" + lua-version: "5.4" + - operating-system: macos-13 + unicorn-version: "1.0.3" + lua-version: "luajit-openresty" steps: - uses: actions/checkout@v4.1.7 with: @@ -46,8 +66,8 @@ jobs: - name: Install Binding run: luarocks build env: - USER_CXX_FLAGS: -std=c++11 -Wall -Wextra -Werror -Wpedantic -pedantic-errors + USER_CXX_FLAGS: -Wall -Wextra -Werror -Wpedantic -pedantic-errors - name: Run tests run: luarocks test env: - USER_CXX_FLAGS: -std=c++11 -Wall -Wextra -Werror -Wpedantic -pedantic-errors + USER_CXX_FLAGS: -Wall -Wextra -Werror -Wpedantic -pedantic-errors diff --git a/.gitignore b/.gitignore index 00189311..cf70b6a8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,17 +5,17 @@ *.a *.lib .git/ -build/ tests/c/doctest.h .idea/ .vscode/ # Autogenerated files: -src/constants/ -src/basic_control_functions.cpp -src/registers.cpp -src/registers_const.cpp -src/unicornlua/register_types.hpp +csrc/*_const.cpp +csrc/cpp_test +csrc/basic_control_functions.cpp +csrc/registers.cpp +csrc/registers_const.cpp +csrc/unicornlua/register_types.hpp # Other garbage core* diff --git a/Makefile b/Makefile index 9b14d075..cc38c357 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ -# WARNING: This makefile is intended to be invoked by LuaRocks, not manually. +# WARNING: This makefile is intended to be invoked by LuaRocks, not manually. Only use +# it form `clean`, `format` and if your IDE is grumpy, `autogen-files` might work. -# Disable all default build rules so that we have full control. +# If we don't disable suffixes, Make fails to detect our default %.o rule because it has +# extra prerequisites. Because of this, it falls back to its internal built-in recipe for +# %.o from %.cpp. This default rule doesn't have any of the header search paths, and will +# fail. .SUFFIXES: ################################################################################ @@ -8,25 +12,22 @@ # These are only used when this Makefile is run manually. You should only be # doing that for `make clean`. Use `luarocks` for everything else. +CP = cp +CURL = curl +LIB_EXTENSION = so LUAROCKS = luarocks -get_luarocks_var = $(shell $(LUAROCKS) config variables.$1) - -BUSTED := $(call get_luarocks_var,SCRIPTS_DIR)/busted -CC := $(call get_luarocks_var,CC) -CXXFLAGS := $(call get_luarocks_var,CFLAGS) -CURL := $(call get_luarocks_var,CURL) -LD := $(call get_luarocks_var,LD) -LIBFLAG := $(call get_luarocks_var,LIBFLAG) -LIB_EXTENSION := $(call get_luarocks_var,LIB_EXTENSION) -LUA := $(call get_luarocks_var,LUA) -LUA_DIR := $(call get_luarocks_var,LUA_DIR) -LUA_INCDIR := $(call get_luarocks_var,LUA_INCDIR) -LUA_LIBDIR := $(call get_luarocks_var,LUA_LIBDIR) -LUA_VERSION := $(call get_luarocks_var,LUA_VERSION) -MKDIR := $(call get_luarocks_var,MKDIR) -OBJ_EXTENSION := $(call get_luarocks_var,OBJ_EXTENSION) +MKDIR = mkdir +OBJ_EXTENSION = o UNICORN_INCDIR = /usr/include +BUSTED := $(shell $(LUAROCKS) config variables.SCRIPTS_DIR)/busted +LIBFLAG := $(shell $(LUAROCKS) config variables.LIBFLAG) +LUA := $(shell $(LUAROCKS) config variables.LUA) +LUA_DIR := $(shell $(LUAROCKS) config variables.LUA_DIR) +LUA_INCDIR = $(LUA_DIR)/include +LUA_LIBDIR = $(LUA_DIR)/lib +LUA_VERSION = $(shell $(LUA) -e 'print(_VERSION:sub(5))') + ################################################################################ # Disable 64-bit integer tests for Lua <5.3 @@ -53,39 +54,40 @@ else FALLBACK_LUA_INCDIR = $(LUA_DIR)/include endif -BUILD_DIR = $(CURDIR)/build ARCHITECTURE_HEADERS = $(wildcard $(UNICORN_INCDIR)/unicorn/*.h) ARCHITECTURE_SLUGS = $(filter-out platform,$(basename $(notdir $(ARCHITECTURE_HEADERS)))) -CONSTS_DIR = src/constants -CONSTANT_FILES = $(foreach s,$(ARCHITECTURE_SLUGS),$(CONSTS_DIR)/$(s)_const.cpp) +SOURCE_DIR = csrc +CONSTANT_FILES = $(foreach s,$(ARCHITECTURE_SLUGS),$(SOURCE_DIR)/$(s)_const.cpp) -CPP_TEMPLATE_SOURCES = $(wildcard src/*.template) +CPP_TEMPLATE_SOURCES = $(wildcard $(SOURCE_DIR)/*.template) AUTOGENERATED_CPP_FILES = $(CPP_TEMPLATE_SOURCES:.template=.cpp) -HEADER_TEMPLATE_SOURCES = $(wildcard src/unicornlua/*.template) +HEADER_TEMPLATE_SOURCES = $(wildcard $(SOURCE_DIR)/unicornlua/*.template) AUTOGENERATED_HPP_FILES = $(HEADER_TEMPLATE_SOURCES:.template=.hpp) -LIB_BUILD_TARGET = $(BUILD_DIR)/unicorn.$(LIB_EXTENSION) -LIB_CPP_SOURCES = $(wildcard src/*.cpp) $(CONSTANT_FILES) $(AUTOGENERATED_CPP_FILES) +LIB_BUILD_TARGET = $(SOURCE_DIR)/unicorn.$(LIB_EXTENSION) +LIB_CPP_SOURCES = $(wildcard $(SOURCE_DIR)/*.cpp) $(CONSTANT_FILES) $(AUTOGENERATED_CPP_FILES) LIB_OBJECT_FILES = $(LIB_CPP_SOURCES:.cpp=.$(OBJ_EXTENSION)) -TEST_EXECUTABLE = $(BUILD_DIR)/cpp_test +TEST_EXECUTABLE = $(SOURCE_DIR)/cpp_test TEST_CPP_SOURCES = $(wildcard tests/c/*.cpp) TEST_LUA_SOURCES = $(wildcard tests/lua/*.lua) TEST_HEADERS = $(wildcard tests/c/*.hpp) TEST_CPP_OBJECT_FILES = $(TEST_CPP_SOURCES:.cpp=.$(OBJ_EXTENSION)) -TEMPLATE_DATA_FILES = $(wildcard src/template_data/*.lua) +TEMPLATE_DATA_FILES = $(wildcard $(SOURCE_DIR)/template_data/*.lua) +# Unicorn 1.x gets put into places not on the typical linker search path, so we need to +# hardcode these additional directories it could appear in. LIBRARY_DIRECTORIES = $(strip $(LUA_LIBDIR) $(UNICORN_LIBDIR) $(PTHREAD_LIBDIR) /usr/lib64 /usr/local/lib) # The hardcoded version-specific paths here are fallbacks because my IDE can't find the # Lua headers without them. Is it necessary? No. Will it cause problems? Unlikely. But # without it, every file is a sea of red squiggles and I'm. Losing. My. Mind. HEADER_DIRECTORIES = $(strip \ - src \ + $(SOURCE_DIR) \ $(LUA_INCDIR) \ $(FALLBACK_LUA_INCDIR) \ $(UNICORN_INCDIR) \ @@ -93,10 +95,6 @@ HEADER_DIRECTORIES = $(strip \ /usr/include/lua$(LUA_VERSION) \ /usr/local/include/lua$(LUA_VERSION)) -ifndef USER_CXX_FLAGS - USER_CXX_FLAGS = -endif - INCLUDE_PATH_FLAGS = $(addprefix -I,$(HEADER_DIRECTORIES)) LIB_PATH_FLAGS = $(addprefix -L,$(LIBRARY_DIRECTORIES)) REQUIRED_LIBS = unicorn pthread stdc++ @@ -108,11 +106,7 @@ REQUIRED_LIBS_FLAGS = $(addprefix -l,$(REQUIRED_LIBS)) LINK_TO_LUA_FLAG = $(if $(LUALIB),-l:$(LUALIB),-l$(DEFAULT_LUA_LIB_NAME)) # https://github.com/PowerDNS/pdns/issues/4295 -ifndef OS - OS = $(shell uname -s) -endif - -ifeq ($(OS),Darwin) +ifeq ($(shell uname -s),Darwin) ifeq ($(IS_LUAJIT),1) # This workaround isn't needed for LuaJIT 2.1+ ifeq ($(LUAJIT_VERSION),2.0) @@ -121,7 +115,10 @@ ifeq ($(OS),Darwin) endif endif -CXX_CMD = $(CC) $(USER_CXX_FLAGS) $(INCLUDE_PATH_FLAGS) + +# On MacOS, we need to explicitly tell the compiler to use C++11 because it defaults to an +# older standard. GCC on Linux appears to work fine without it. +CXX_CMD = $(CXX) $(USER_CXX_FLAGS) $(INCLUDE_PATH_FLAGS) -std=c++11 LINK_CMD = $(LD) $(LIB_PATH_FLAGS) $(LDFLAGS) DOCTEST_TAG = v2.4.11 @@ -142,28 +139,24 @@ _space = $(_empty) $(_empty) LIBRARY_COLON_PATHS = $(subst $(_space),:,$(LIBRARY_DIRECTORIES)) -# DYLD_FALLBACK_LIBRARY_PATH is for MacOS, LD_LIBRARY_PATH is for all other *NIX systems. -export LD_LIBRARY_PATH := $(LIBRARY_COLON_PATHS):$(LD_LIBRARY_PATH) -export DYLD_FALLBACK_LIBRARY_PATH := $(LIBRARY_COLON_PATHS):$(DYLD_FALLBACK_LIBRARY_PATH) export LUA_PATH := $(shell $(LUAROCKS) path --lr-path) export LUA_CPATH := $(shell $(LUAROCKS) path --lr-cpath) export PATH := $(shell $(LUAROCKS) path --lr-bin):$(PATH) +# DYLD_FALLBACK_LIBRARY_PATH is for MacOS, LD_LIBRARY_PATH is for all other *NIX systems. +export LD_LIBRARY_PATH := $(LIBRARY_COLON_PATHS):$(LD_LIBRARY_PATH) +export DYLD_FALLBACK_LIBRARY_PATH := $(LIBRARY_COLON_PATHS):$(DYLD_FALLBACK_LIBRARY_PATH) -$(LIB_BUILD_TARGET): $(LIB_OBJECT_FILES) | $(BUILD_DIR) +# This must be the first rule, don't move it. +$(LIB_BUILD_TARGET): $(LIB_OBJECT_FILES) $(LINK_CMD) $(LIBFLAG) -o $@ $^ $(REQUIRED_LIBS_FLAGS) -.PHONY: install -install: $(LIB_BUILD_TARGET) - install $^ $(INST_LIBDIR) - - -$(TEST_EXECUTABLE): $(TEST_CPP_OBJECT_FILES) $(LIB_OBJECT_FILES) | $(BUILD_DIR) +$(TEST_EXECUTABLE): $(TEST_CPP_OBJECT_FILES) $(LIB_OBJECT_FILES) $(LINK_CMD) -o $@ $^ $(REQUIRED_LIBS_FLAGS) $(LINK_TO_LUA_FLAG) -lm -$(CONSTS_DIR)/%_const.cpp: $(UNICORN_INCDIR)/unicorn/%.h | $(CONSTS_DIR) +$(SOURCE_DIR)/%_const.cpp: $(UNICORN_INCDIR)/unicorn/%.h $(LUA) tools/generate_constants.lua $< $@ @@ -187,12 +180,9 @@ $(DOCTEST_HEADER): $(CURL) -sSo $@ https://raw.githubusercontent.com/doctest/doctest/$(DOCTEST_TAG)/doctest/doctest.h -$(CONSTS_DIR) $(BUILD_DIR): - $(MKDIR) $@ - - -$(BUSTED): - $(LUAROCKS) install --local busted +.PHONY: __install +__install: $(LIB_BUILD_TARGET) + $(CP) $^ $(INST_LIBDIR) .PHONY: all @@ -201,27 +191,16 @@ all: $(LIB_BUILD_TARGET) $(TEST_EXECUTABLE) .PHONY: clean clean: - $(RM) $(LIB_OBJECT_FILES) $(CONSTANT_FILES) $(LIB_BUILD_TARGET) - $(RM) $(TEST_EXECUTABLE) $(TEST_CPP_OBJECT_FILES) $(DOCTEST_HEADER) - $(RM) -r $(BUILD_DIR) $(CONSTS_DIR) $(AUTOGENERATED_CPP_FILES) $(AUTOGENERATED_HPP_FILES) - - -.PHONY: test -test: $(TEST_EXECUTABLE) $(TEST_LUA_SOURCES) | $(BUSTED) - $(TEST_EXECUTABLE) - $(BUSTED) $(BUSTED_FLAGS) \ - --cpath="$(BUILD_DIR)/?.$(LIB_EXTENSION)" \ - --lua=$(LUA) \ - --shuffle \ - -p lua \ - tests/lua + $(RM) $(LIB_OBJECT_FILES) $(CONSTANT_FILES) $(LIB_BUILD_TARGET) \ + $(TEST_EXECUTABLE) $(TEST_CPP_OBJECT_FILES) $(DOCTEST_HEADER) \ + $(AUTOGENERATED_CPP_FILES) $(AUTOGENERATED_HPP_FILES) .PHONY: format format: @clang-format --Werror -i --verbose \ - $(filter-out $(AUTOGENERATED_CPP_FILES),$(wildcard src/*.cpp)) \ - $(filter-out $(AUTOGENERATED_HPP_FILES),$(wildcard src/unicornlua/*.hpp)) \ + $(filter-out $(AUTOGENERATED_CPP_FILES),$(wildcard $(SOURCE_DIR)/*.cpp)) \ + $(filter-out $(AUTOGENERATED_HPP_FILES),$(wildcard $(SOURCE_DIR)/unicornlua/*.hpp)) \ $(wildcard tests/c/*.cpp) \ $(wildcard tests/c/*.hpp) @@ -230,3 +209,9 @@ format: # making IDEs and linters shut up about "missing" files. .PHONY: autogen-files autogen-files: $(AUTOGENERATED_CPP_FILES) $(AUTOGENERATED_HPP_FILES) $(CONSTANT_FILES) + + +.PHONY: __test +__test: $(TEST_EXECUTABLE) $(TEST_LUA_SOURCES) | $(BUSTED) + $(TEST_EXECUTABLE) + $(BUSTED) $(BUSTED_FLAGS) --lua=$(LUA) --shuffle --pattern lua tests/lua diff --git a/src/basic_control_functions.template b/csrc/basic_control_functions.template similarity index 100% rename from src/basic_control_functions.template rename to csrc/basic_control_functions.template diff --git a/src/compat.cpp b/csrc/compat.cpp similarity index 100% rename from src/compat.cpp rename to csrc/compat.cpp diff --git a/src/context.cpp b/csrc/context.cpp similarity index 100% rename from src/context.cpp rename to csrc/context.cpp diff --git a/src/control_functions.cpp b/csrc/control_functions.cpp similarity index 99% rename from src/control_functions.cpp rename to csrc/control_functions.cpp index 2d66a077..f20ab01b 100644 --- a/src/control_functions.cpp +++ b/csrc/control_functions.cpp @@ -14,7 +14,6 @@ // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - #include #include diff --git a/src/engine.cpp b/csrc/engine.cpp similarity index 100% rename from src/engine.cpp rename to csrc/engine.cpp diff --git a/src/errors.cpp b/csrc/errors.cpp similarity index 100% rename from src/errors.cpp rename to csrc/errors.cpp diff --git a/src/hooks.cpp b/csrc/hooks.cpp similarity index 100% rename from src/hooks.cpp rename to csrc/hooks.cpp diff --git a/src/memory.cpp b/csrc/memory.cpp similarity index 100% rename from src/memory.cpp rename to csrc/memory.cpp diff --git a/src/registers.template b/csrc/registers.template similarity index 100% rename from src/registers.template rename to csrc/registers.template diff --git a/src/registers_const.template b/csrc/registers_const.template similarity index 100% rename from src/registers_const.template rename to csrc/registers_const.template diff --git a/src/registers_misc.cpp b/csrc/registers_misc.cpp similarity index 100% rename from src/registers_misc.cpp rename to csrc/registers_misc.cpp diff --git a/src/template_data/basic_control_functions.lua b/csrc/template_data/basic_control_functions.lua similarity index 100% rename from src/template_data/basic_control_functions.lua rename to csrc/template_data/basic_control_functions.lua diff --git a/src/template_data/register_types.lua b/csrc/template_data/register_types.lua similarity index 100% rename from src/template_data/register_types.lua rename to csrc/template_data/register_types.lua diff --git a/src/transaction.cpp b/csrc/transaction.cpp similarity index 100% rename from src/transaction.cpp rename to csrc/transaction.cpp diff --git a/src/unicorn.cpp b/csrc/unicorn.cpp similarity index 100% rename from src/unicorn.cpp rename to csrc/unicorn.cpp diff --git a/src/unicornlua/compat.hpp b/csrc/unicornlua/compat.hpp similarity index 100% rename from src/unicornlua/compat.hpp rename to csrc/unicornlua/compat.hpp diff --git a/src/unicornlua/context.hpp b/csrc/unicornlua/context.hpp similarity index 100% rename from src/unicornlua/context.hpp rename to csrc/unicornlua/context.hpp diff --git a/src/unicornlua/control_functions.hpp b/csrc/unicornlua/control_functions.hpp similarity index 100% rename from src/unicornlua/control_functions.hpp rename to csrc/unicornlua/control_functions.hpp diff --git a/src/unicornlua/engine.hpp b/csrc/unicornlua/engine.hpp similarity index 100% rename from src/unicornlua/engine.hpp rename to csrc/unicornlua/engine.hpp diff --git a/src/unicornlua/errors.hpp b/csrc/unicornlua/errors.hpp similarity index 100% rename from src/unicornlua/errors.hpp rename to csrc/unicornlua/errors.hpp diff --git a/src/unicornlua/hooks.hpp b/csrc/unicornlua/hooks.hpp similarity index 100% rename from src/unicornlua/hooks.hpp rename to csrc/unicornlua/hooks.hpp diff --git a/src/unicornlua/integer_conversions.hpp b/csrc/unicornlua/integer_conversions.hpp similarity index 100% rename from src/unicornlua/integer_conversions.hpp rename to csrc/unicornlua/integer_conversions.hpp diff --git a/src/unicornlua/lua.hpp b/csrc/unicornlua/lua.hpp similarity index 100% rename from src/unicornlua/lua.hpp rename to csrc/unicornlua/lua.hpp diff --git a/src/unicornlua/memory.hpp b/csrc/unicornlua/memory.hpp similarity index 100% rename from src/unicornlua/memory.hpp rename to csrc/unicornlua/memory.hpp diff --git a/src/unicornlua/register_template_functions.hpp b/csrc/unicornlua/register_template_functions.hpp similarity index 100% rename from src/unicornlua/register_template_functions.hpp rename to csrc/unicornlua/register_template_functions.hpp diff --git a/src/unicornlua/register_types.template b/csrc/unicornlua/register_types.template similarity index 100% rename from src/unicornlua/register_types.template rename to csrc/unicornlua/register_types.template diff --git a/src/unicornlua/registers.hpp b/csrc/unicornlua/registers.hpp similarity index 100% rename from src/unicornlua/registers.hpp rename to csrc/unicornlua/registers.hpp diff --git a/src/unicornlua/transaction.hpp b/csrc/unicornlua/transaction.hpp similarity index 100% rename from src/unicornlua/transaction.hpp rename to csrc/unicornlua/transaction.hpp diff --git a/src/unicornlua/unicornlua.hpp b/csrc/unicornlua/unicornlua.hpp similarity index 100% rename from src/unicornlua/unicornlua.hpp rename to csrc/unicornlua/unicornlua.hpp diff --git a/src/unicornlua/utils.hpp b/csrc/unicornlua/utils.hpp similarity index 100% rename from src/unicornlua/utils.hpp rename to csrc/unicornlua/utils.hpp diff --git a/src/utils.cpp b/csrc/utils.cpp similarity index 100% rename from src/utils.cpp rename to csrc/utils.cpp diff --git a/tests/c/utils.cpp b/tests/c/utils.cpp index cd0fad81..569d197c 100644 --- a/tests/c/utils.cpp +++ b/tests/c/utils.cpp @@ -74,7 +74,7 @@ const char *gExpectedErrorMessage; int crash_handler(lua_State *L) { const char *error_message = lua_tostring(L, -1); - CHECK_MESSAGE(strcmp(gExpectedErrorMessage, error_message) == 0, + CHECK_MESSAGE((strcmp(gExpectedErrorMessage, error_message) == 0), "Error messages don't match."); // Error message matches, jump back into the test. diff --git a/unicorn-2.2.1-1.rockspec b/unicorn-2.2.1-1.rockspec index 38be1c80..64c03d6f 100644 --- a/unicorn-2.2.1-1.rockspec +++ b/unicorn-2.2.1-1.rockspec @@ -36,36 +36,6 @@ external_dependencies = { } external_dependencies.platforms.macos = external_dependencies.platforms.linux -test_dependencies = { - "busted", -} - -test = { - type = "command", - command = "make", - flags = { - "test", - "BUSTED=$(SCRIPTS_DIR)/busted", - "CC=$(CC)", - "CURL=$(CURL)", - "CXXFLAGS=$(CFLAGS)", - "LD=$(LD)", - "LIB_EXTENSION=$(LIB_EXTENSION)", - "LUA=$(LUA)", - "LUALIB=$(LUALIB)", -- Always empty on *NIX systems - "LUA_DIR=$(LUA_DIR)", - "LUAROCKS=$(SCRIPTS_DIR)/luarocks", - "OBJ_EXTENSION=$(OBJ_EXTENSION)", - "MKDIR=$(MKDIR)", - -- The following are needed but not provided by LuaRocks - "LUA_INCDIR=$(LUA_DIR)/include", - "LUA_LIBDIR=$(LUA_DIR)/lib", - -- "UNICORN_INCDIR=$(UNICORN_INCDIR)", - -- "UNICORN_LIBDIR=$(UNICORN_LIBDIR)", - -- "PTHREAD_LIBDIR=$(PTHREAD_LIBDIR)", - }, -} - build_dependencies = { "penlight >=1.8.1, <2.0", } @@ -73,14 +43,16 @@ build_dependencies = { build = { type = "make", variables = { + CALLED_FROM_LUAROCKS = "1", + CP = "$(CP)", LIB_EXTENSION = "$(LIB_EXTENSION)", LUA = "$(LUA)", LUAROCKS = "$(SCRIPTS_DIR)/luarocks", - OBJ_EXTENSION = "$(OBJ_EXTENSION)", LUA_VERSION = "$(LUA_VERSION)", + OBJ_EXTENSION = "$(OBJ_EXTENSION)", }, build_variables = { - CC = "$(CC)", + CXX = "$(CC)", CURL = "$(CURL)", CXXFLAGS = "$(CFLAGS)", LD = "$(LD)", @@ -90,10 +62,40 @@ build = { UNICORN_INCDIR = "$(UNICORN_INCDIR)", UNICORN_LIBDIR = "$(UNICORN_LIBDIR)", PTHREAD_LIBDIR = "$(PTHREAD_LIBDIR)", - MKDIR = "$(MKDIR)", LUALIB = "$(LUALIB)", }, + install_target = "__install", install_variables = { INST_LIBDIR = "$(LIBDIR)", }, } + + +test_dependencies = { + "busted", +} + +test = { + type = "command", + command = "make", + flags = { + "__test", + "BUSTED=$(SCRIPTS_DIR)/busted", + "CALLED_FROM_LUAROCKS=1", + "CXX=$(CC)", + "CXXFLAGS=$(CFLAGS)", + "CURL=$(CURL)", + "LD=$(LD)", + "LIB_EXTENSION=$(LIB_EXTENSION)", + "LUA=$(LUA)", + "LUA_VERSION=$(LUA_VERSION)", + "LUALIB=$(LUALIB)", -- Always empty on *NIX systems + "LUA_DIR=$(LUA_DIR)", + "LUAROCKS=$(SCRIPTS_DIR)/luarocks", + "OBJ_EXTENSION=$(OBJ_EXTENSION)", + -- The following are needed for building the tests, but aren't provided by + -- LuaRocks when testing. + "LUA_INCDIR=$(LUA_DIR)/include", + "LUA_LIBDIR=$(LUA_DIR)/lib", + }, +}