Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor toolchain fixes #2031

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GAME_CODE := BPEE
MAKER_CODE := 01
REVISION := 0
MODERN ?= 0
KEEP_TEMPS ?= 0

# `File name`.gba ('_modern' will be appended to the modern builds)
FILE_NAME := pokeemerald
Expand Down Expand Up @@ -256,18 +257,18 @@ include audio_rules.mk

generated: $(AUTO_GEN_TARGETS)

%.s: ;
%.s: ;
%.png: ;
%.pal: ;
%.aif: ;

%.1bpp: %.png ; $(GFX) $< $@
%.4bpp: %.png ; $(GFX) $< $@
%.8bpp: %.png ; $(GFX) $< $@
%.gbapal: %.pal ; $(GFX) $< $@
%.gbapal: %.png ; $(GFX) $< $@
%.lz: % ; $(GFX) $< $@
%.rl: % ; $(GFX) $< $@
%.1bpp: %.png ; $(GFX) $< $@
%.4bpp: %.png ; $(GFX) $< $@
%.8bpp: %.png ; $(GFX) $< $@
%.gbapal: %.pal ; $(GFX) $< $@
%.gbapal: %.png ; $(GFX) $< $@
%.lz: % ; $(GFX) $< $@
%.rl: % ; $(GFX) $< $@

# NOTE: Tools must have been built prior (FIXME)
generated: tools $(AUTO_GEN_TARGETS)
Expand Down Expand Up @@ -305,7 +306,7 @@ endef
# $1: Output file without extension, $2 input file, $3 temp path (if keeping)
define C_DEP_IMPL
$1.o: $2
ifeq (,$(KEEP_TEMPS))
ifneq ($(KEEP_TEMPS),1)
@echo "$$(CC1) <flags> -o $$@ $$<"
@$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) -i $$< charmap.txt | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ -
else
Expand All @@ -314,15 +315,11 @@ else
@echo -e ".text\n\t.align\t2, 0\n" >> $3.s
$$(AS) $$(ASFLAGS) -o $$@ $3.s
endif
$(call C_SCANINC,$1,$2)
endef
# Calls SCANINC to find dependencies
define C_SCANINC
ifneq ($(NODEP),1)
$1.o: $1.d
$1.d: $2
$(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I tools/agbcc/include $2
include $1.d
ifneq ($(NODEP),1)
$1.o: $1.d
-include $1.d
endif
endef

Expand Down Expand Up @@ -352,7 +349,7 @@ ifneq ($(NODEP),1)
$1.o: $1.d
$1.d: $2
$(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I "" $2
include $1.d
-include $1.d
endif
endef

Expand Down
17 changes: 8 additions & 9 deletions tools/mapjson/json11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ using std::vector;
using std::map;
using std::make_shared;
using std::initializer_list;
using std::move;

/* Helper for representing null - just a do-nothing struct, plus comparison
* operators so the helpers in JsonValue work. We can't use nullptr_t because
Expand Down Expand Up @@ -149,7 +148,7 @@ class Value : public JsonValue {

// Constructors
explicit Value(const T &value) : m_value(value) {}
explicit Value(T &&value) : m_value(move(value)) {}
explicit Value(T &&value) : m_value(std::move(value)) {}

// Get type tag
Json::Type type() const override {
Expand Down Expand Up @@ -196,23 +195,23 @@ class JsonString final : public Value<Json::STRING, string> {
const string &string_value() const override { return m_value; }
public:
explicit JsonString(const string &value) : Value(value) {}
explicit JsonString(string &&value) : Value(move(value)) {}
explicit JsonString(string &&value) : Value(std::move(value)) {}
};

class JsonArray final : public Value<Json::ARRAY, Json::array> {
const Json::array &array_items() const override { return m_value; }
const Json & operator[](size_t i) const override;
public:
explicit JsonArray(const Json::array &value) : Value(value) {}
explicit JsonArray(Json::array &&value) : Value(move(value)) {}
explicit JsonArray(Json::array &&value) : Value(std::move(value)) {}
};

class JsonObject final : public Value<Json::OBJECT, Json::object> {
const Json::object &object_items() const override { return m_value; }
const Json & operator[](const string &key) const override;
public:
explicit JsonObject(const Json::object &value) : Value(value) {}
explicit JsonObject(Json::object &&value) : Value(move(value)) {}
explicit JsonObject(Json::object &&value) : Value(std::move(value)) {}
};

class JsonNull final : public Value<Json::NUL, NullStruct> {
Expand Down Expand Up @@ -254,12 +253,12 @@ Json::Json(double value) : m_ptr(make_shared<JsonDouble>(value)) {
Json::Json(int value) : m_ptr(make_shared<JsonInt>(value)) {}
Json::Json(bool value) : m_ptr(value ? statics().t : statics().f) {}
Json::Json(const string &value) : m_ptr(make_shared<JsonString>(value)) {}
Json::Json(string &&value) : m_ptr(make_shared<JsonString>(move(value))) {}
Json::Json(string &&value) : m_ptr(make_shared<JsonString>(std::move(value))) {}
Json::Json(const char * value) : m_ptr(make_shared<JsonString>(value)) {}
Json::Json(const Json::array &values) : m_ptr(make_shared<JsonArray>(values)) {}
Json::Json(Json::array &&values) : m_ptr(make_shared<JsonArray>(move(values))) {}
Json::Json(Json::array &&values) : m_ptr(make_shared<JsonArray>(std::move(values))) {}
Json::Json(const Json::object &values) : m_ptr(make_shared<JsonObject>(values)) {}
Json::Json(Json::object &&values) : m_ptr(make_shared<JsonObject>(move(values))) {}
Json::Json(Json::object &&values) : m_ptr(make_shared<JsonObject>(std::move(values))) {}

/* * * * * * * * * * * * * * * * * * * *
* Accessors
Expand Down Expand Up @@ -357,7 +356,7 @@ struct JsonParser final {
* Mark this parse as failed.
*/
Json fail(string &&msg) {
return fail(move(msg), Json());
return fail(std::move(msg), Json());
}

template <typename T>
Expand Down
5 changes: 5 additions & 0 deletions tools/scaninc/scaninc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ int main(int argc, char **argv)
if (!exists && (file.FileType() == SourceFileType::Asm || file.FileType() == SourceFileType::Inc))
{
path = include;
if (CanOpenFile(path))
exists = true;
}
if (!exists)
continue;

dependencies_includes.insert(path);
bool inserted = dependencies.insert(path).second;
if (inserted && exists)
Expand Down