diff options
author | John Hodge <tpg@mutabah.net> | 2018-03-18 10:48:26 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2018-03-18 10:48:26 +0800 |
commit | 5b0450395af81ceba0d0ac27fc73b16f966bd7d3 (patch) | |
tree | e3c753b83a562be78cdbd74b8164dab785bf07a6 /tools | |
parent | 363e6fa172f787e970c8abc8f631b6d60d571248 (diff) | |
download | mrust-5b0450395af81ceba0d0ac27fc73b16f966bd7d3.tar.gz |
All - Move toml parser and path header to a common library, start on custom target specs.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/common/Makefile | 36 | ||||
-rw-r--r-- | tools/common/debug.cpp (renamed from tools/minicargo/debug.cpp) | 0 | ||||
-rw-r--r-- | tools/common/debug.h (renamed from tools/minicargo/debug.h) | 0 | ||||
-rw-r--r-- | tools/common/helpers.h (renamed from tools/minicargo/helpers.h) | 0 | ||||
-rw-r--r-- | tools/common/path.cpp (renamed from tools/minicargo/path.cpp) | 0 | ||||
-rw-r--r-- | tools/common/path.h (renamed from tools/minicargo/path.h) | 0 | ||||
-rw-r--r-- | tools/common/toml.cpp (renamed from tools/minicargo/toml.cpp) | 0 | ||||
-rw-r--r-- | tools/common/toml.h (renamed from tools/minicargo/toml.h) | 12 | ||||
-rw-r--r-- | tools/minicargo/Makefile | 9 | ||||
-rw-r--r-- | tools/minicargo/build.h | 2 | ||||
-rw-r--r-- | tools/minicargo/manifest.h | 3 | ||||
-rw-r--r-- | tools/testrunner/Makefile | 4 | ||||
-rw-r--r-- | tools/testrunner/main.cpp | 4 |
13 files changed, 60 insertions, 10 deletions
diff --git a/tools/common/Makefile b/tools/common/Makefile new file mode 100644 index 00000000..36251680 --- /dev/null +++ b/tools/common/Makefile @@ -0,0 +1,36 @@ +# +# Mini version of cargo +# - Interprets Cargo.toml files and emits makefiles +# - Supports overriding build script output +# + +V ?= @ + +OBJDIR := .obj/ + +BIN := ../bin/common_lib.a +OBJS = toml.o path.o debug.o + +CXXFLAGS := -Wall -std=c++14 -g -O2 + +OBJS := $(OBJS:%=$(OBJDIR)%) + +.PHONY: all clean + +all: $(BIN) + +clean: + rm $(BIN) $(OBJS) + +$(BIN): $(OBJS) + @mkdir -p $(dir $@) + @echo [AR] rcu $@ + $V$(AR) rcu $@ $(OBJS) + +$(OBJDIR)%.o: %.cpp + @mkdir -p $(dir $@) + @echo [CXX] $< + $V$(CXX) -o $@ -c $< $(CXXFLAGS) -MMD -MP -MF $@.dep + +-include $(OBJS:%.o=%.o.dep) + diff --git a/tools/minicargo/debug.cpp b/tools/common/debug.cpp index a3fb9956..a3fb9956 100644 --- a/tools/minicargo/debug.cpp +++ b/tools/common/debug.cpp diff --git a/tools/minicargo/debug.h b/tools/common/debug.h index ace00876..ace00876 100644 --- a/tools/minicargo/debug.h +++ b/tools/common/debug.h diff --git a/tools/minicargo/helpers.h b/tools/common/helpers.h index 8111483a..8111483a 100644 --- a/tools/minicargo/helpers.h +++ b/tools/common/helpers.h diff --git a/tools/minicargo/path.cpp b/tools/common/path.cpp index 12e505bb..12e505bb 100644 --- a/tools/minicargo/path.cpp +++ b/tools/common/path.cpp diff --git a/tools/minicargo/path.h b/tools/common/path.h index dd97f9be..dd97f9be 100644 --- a/tools/minicargo/path.h +++ b/tools/common/path.h diff --git a/tools/minicargo/toml.cpp b/tools/common/toml.cpp index 9fad0ec4..9fad0ec4 100644 --- a/tools/minicargo/toml.cpp +++ b/tools/common/toml.cpp diff --git a/tools/minicargo/toml.h b/tools/common/toml.h index 315cf62f..e57c28ae 100644 --- a/tools/minicargo/toml.h +++ b/tools/common/toml.h @@ -97,6 +97,18 @@ struct TomlValue } return m_int_value != 0; } + uint64_t as_int() const { + if(m_type != Type::Integer) { + throw TypeError { m_type, Type::Integer }; + } + return m_int_value; + } + const ::std::vector<TomlValue>& as_list() const { + if(m_type != Type::List) { + throw TypeError { m_type, Type::List }; + } + return m_sub_values; + } friend ::std::ostream& operator<<(::std::ostream& os, const TomlValue& x) { switch(x.m_type) diff --git a/tools/minicargo/Makefile b/tools/minicargo/Makefile index 71e266b0..01010fb5 100644 --- a/tools/minicargo/Makefile +++ b/tools/minicargo/Makefile @@ -14,10 +14,10 @@ OBJDIR := .obj/ BIN := ../bin/minicargo$(EXESUF) OBJS := main.o build.o manifest.o repository.o -OBJS += toml.o path.o debug.o LINKFLAGS := -g -lpthread CXXFLAGS := -Wall -std=c++14 -g -O2 +CXXFLAGS += -I ../common OBJS := $(OBJS:%=$(OBJDIR)%) @@ -28,15 +28,18 @@ all: $(BIN) clean: rm $(BIN) $(OBJS) -$(BIN): $(OBJS) +$(BIN): $(OBJS) ../bin/common_lib.a @mkdir -p $(dir $@) @echo [CXX] -o $@ - $V$(CXX) -o $@ $(OBJS) $(LINKFLAGS) + $V$(CXX) -o $@ $(OBJS) ../bin/common_lib.a $(LINKFLAGS) $(OBJDIR)%.o: %.cpp @mkdir -p $(dir $@) @echo [CXX] $< $V$(CXX) -o $@ -c $< $(CXXFLAGS) -MMD -MP -MF $@.dep +../bin/common_lib.a: + make -C ../common + -include $(OBJS:%.o=%.o.dep) diff --git a/tools/minicargo/build.h b/tools/minicargo/build.h index 0b3e949b..54d03575 100644 --- a/tools/minicargo/build.h +++ b/tools/minicargo/build.h @@ -1,7 +1,7 @@ #pragma once #include "manifest.h" -#include "path.h" +#include <path.h> class StringList; class StringListKV; diff --git a/tools/minicargo/manifest.h b/tools/minicargo/manifest.h index bbe2c34b..e48e7f2a 100644 --- a/tools/minicargo/manifest.h +++ b/tools/minicargo/manifest.h @@ -5,8 +5,7 @@ #include <map> #include <memory> #include <functional> -#include "path.h" -#include <functional> +#include <path.h> class PackageManifest; class Repository; diff --git a/tools/testrunner/Makefile b/tools/testrunner/Makefile index 1285d732..7107eaf2 100644 --- a/tools/testrunner/Makefile +++ b/tools/testrunner/Makefile @@ -26,8 +26,8 @@ $(OBJDIR)%.o: %.cpp @mkdir -p $(dir $@) @echo [CXX] $< $V$(CXX) -o $@ -c $< $(CXXFLAGS) -MMD -MP -MF $@.dep -# - Include files from minicargo -$(OBJDIR)%.o: ../minicargo/%.cpp +# - Include files from common (TODO: Be less hacky) +$(OBJDIR)%.o: ../common/%.cpp @mkdir -p $(dir $@) @echo [CXX] $< $V$(CXX) -o $@ -c $< $(CXXFLAGS) -MMD -MP -MF $@.dep diff --git a/tools/testrunner/main.cpp b/tools/testrunner/main.cpp index 2aa7e696..63391fc5 100644 --- a/tools/testrunner/main.cpp +++ b/tools/testrunner/main.cpp @@ -7,8 +7,8 @@ #include <vector> #include <fstream> #include <cctype> // std::isblank -#include "../minicargo/debug.h" -#include "../minicargo/path.h" +#include "../common/debug.h" +#include "../common/path.h" #ifdef _WIN32 # include <Windows.h> # define MRUSTC_PATH "x64\\Release\\mrustc.exe" |