about summary refs log tree commit diff stats
path: root/src/version.h
blob: 62a4cd17060ace9d8c3ad959a27da36d112610bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef VERSION_H_C757E53C
#define VERSION_H_C757E53C

#include <iostream>
#include <regex>

struct Version {
  int major = 0;
  int minor = 0;
  int revision = 0;

  constexpr Version(int major_arg, int minor_arg, int rev_arg)
      : major(major_arg), minor(minor_arg), revision(rev_arg) {}

  Version(const std::string& ver_str) {
    const std::regex version_regex("v([0-9]*)\.([0-9]*)\.([0-9]*)");
    std::smatch version_match;

    if (std::regex_match(ver_str, version_match, version_regex)) {
      major = std::atoi(version_match[1].str().c_str());
      minor = std::atoi(version_match[2].str().c_str());
      revision = std::atoi(version_match[3].str().c_str());
    }
  }

  bool operator<(const Version& rhs) const {
    return (major < rhs.major) ||
           (major == rhs.major &&
            (minor < rhs.minor ||
             (minor == rhs.minor && revision < rhs.revision)));
  }
};

std::ostream& operator<<(std::ostream& out, const Version& ver) {
  return out << "v" << ver.major << "." << ver.minor << "." << ver.revision;
}

constexpr const Version kTrackerVersion = Version(0, 6, 5);

#endif /* end of include guard: VERSION_H_C757E53C */
an> := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ $(foreach dir,$(DATA),$(CURDIR)/$(dir)) export DEPSDIR := $(CURDIR)/$(BUILD) #--------------------------------------------------------------------------------- # automatically build a list of object files for our project #--------------------------------------------------------------------------------- CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- # use CXX for linking C++ projects, CC for standard C #--------------------------------------------------------------------------------- ifeq ($(strip $(CPPFILES)),) export LD := $(CC) else export LD := $(CXX) endif export OFILES := $(addsuffix .o,$(BINFILES)) \ $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ $(sFILES:.s=.o) $(SFILES:.S=.o) #--------------------------------------------------------------------------------- # build a list of include paths #--------------------------------------------------------------------------------- export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ -I$(CURDIR)/$(BUILD) \ -I$(LIBOGC_INC) #--------------------------------------------------------------------------------- # build a list of library paths #--------------------------------------------------------------------------------- export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ -L$(LIBOGC_LIB) export OUTPUT := $(CURDIR)/$(TARGET) .PHONY: $(BUILD) clean #--------------------------------------------------------------------------------- $(BUILD): @[ -d $@ ] || mkdir -p $@ @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.gc #--------------------------------------------------------------------------------- clean: @echo clean ... @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol #--------------------------------------------------------------------------------- else DEPENDS := $(OFILES:.o=.d) #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- $(OUTPUT).dol: $(OUTPUT).elf $(OUTPUT).elf: $(OFILES) #--------------------------------------------------------------------------------- # This rule links in binary data with the .jpg extension #--------------------------------------------------------------------------------- %.gba.o : %.gba #--------------------------------------------------------------------------------- @echo $(notdir $<) $(bin2o) -include $(DEPENDS) #--------------------------------------------------------------------------------- endif #---------------------------------------------------------------------------------