summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRevo <projectrevotpp@hotmail.com>2020-07-13 08:58:36 -0400
committerGitHub <noreply@github.com>2020-07-13 08:58:36 -0400
commit6ebca13d4c5a290e239364f90bf137c12f332a13 (patch)
treeff14d8b27642992a839200e7cc2e45c19c209006
parentc396ec8d1509dc8145b6415e3c20b471291a4922 (diff)
parent684d80aa076088ee018d963004539c9ee5330403 (diff)
Merge pull request #230 from PikalaxALT/pikalax_work
Update knarc Makefile; nuke csv2bin
-rw-r--r--.travis.yml4
-rw-r--r--CMakeLists.txt2
-rw-r--r--CONTRIBUTING.md6
-rw-r--r--Makefile10
-rw-r--r--tools/csv2bin/.gitignore1
-rw-r--r--tools/csv2bin/Makefile13
-rw-r--r--tools/csv2bin/csv2bin.c103
-rw-r--r--tools/knarc/Makefile44
8 files changed, 50 insertions, 133 deletions
diff --git a/.travis.yml b/.travis.yml
index b2dca34e..71bc101a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,10 +4,12 @@ language: c
env:
global:
- LM_LICENSE_FILE="$TRAVIS_BUILD_DIR/tools/mwccarm/license.dat"
+ - CC=gcc-8
+ - CXX=g++-8
addons:
apt:
packages:
- - gcc-multilib
+ - g++-8-multilib
- linux-libc-dev
- binutils-arm-none-eabi
- wine32
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 398b650f..6a8fbb58 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,7 +20,7 @@ target_include_directories(PokeDiamond PRIVATE include include-mw arm9/lib/inclu
add_executable(calcrom .travis/calcrom/calcrom.cpp)
target_include_directories(calcrom PRIVATE /usr/local/include)
-add_executable(knarc tools/knarc/Source.cpp tools/knarc/Narc.cpp)
+add_executable(knarc tools/knarc/Source.cpp tools/knarc/Narc.cpp tools/knarc/fnmatch.c)
add_executable(jsonproc tools/jsonproc/jsonproc.cpp)
target_include_directories(jsonproc PRIVATE SYSTEM tools/jsonproc)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index ff323116..f36b82d0 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -96,11 +96,11 @@ Your attempt was incorrect. Don't be discouraged, this is all part of the proces
OBJDUMP_ARCH="${OBJDUMP_ARCH:-armv5te}"
OBJDUMP_MODE="${OBJDUMP_MODE:-force-thumb}"
-OBJDUMP_VMA="${OBJDUMP_VMA:-0x02000000}"
-OBJDUMP="arm-none-eabi-objdump -Drz -bbinary -m${OBJDUMP_ARCH} -M${OBJDUMP_MODE}"
+OBJDUMP_VMA=0x02000000
+OBJDUMP="arm-none-eabi-objdump -Drz -bbinary -m${OBJDUMP_ARCH} -M${OBJDUMP_MODE} --adjust-vma=$((OBJDUMP_VMA))"
OPTIONS="--start-address=$(($1 + OBJDUMP_VMA)) --stop-address=$(($1 + $2 + OBJDUMP_VMA))"
$OBJDUMP $OPTIONS $(dirname $0)/baserom.sbin > $(dirname $0)/baserom.dump || exit 1
-$OBJDUMP $OPTIONS $(dirname $0)/build/arm9.sbin > $(dirname $0)/arm9.dump
+$OBJDUMP $OPTIONS $(dirname $0)/build/diamond.us/arm9.sbin > $(dirname $0)/arm9.dump
diff -u $(dirname $0)/baserom.dump $(dirname $0)/arm9.dump
```
Place a clean version of the ARM9 binary as arm9/baserom.sbin (arm9/build/arm9.bin from a successful build should suffice). In your terminal, navigate to the arm9 directory and run `./asmdiff.sh 0 $(wc -c baserom.sbin) | less`, then scroll through to where the grievances begin. Fix any obvious problems in your code/tree, and rerun. If the differences are extensive, you may have induced a shift in the binary either by writing incorrect code or placing it incorrectly into the LSF. *Tip: you can specify a start address and size to only compare the portion of the ROM you are working on.*
diff --git a/Makefile b/Makefile
index e7fecae4..07235c57 100644
--- a/Makefile
+++ b/Makefile
@@ -142,7 +142,7 @@ endif
.SECONDARY:
.DELETE_ON_ERROR:
.SECONDEXPANSION:
-.PHONY: all libs clean mostlyclean tidy tools $(TOOLDIRS) patch_mwasmarm arm9 arm7
+.PHONY: all libs clean mostlyclean tidy tools clean-tools $(TOOLDIRS) patch_mwasmarm arm9 arm7
MAKEFLAGS += --no-print-directory
@@ -151,10 +151,9 @@ ifeq ($(COMPARE),1)
@$(SHA1SUM) -c $(TARGET).sha1
endif
-clean: mostlyclean clean-fs
+clean: mostlyclean clean-fs clean-tools
$(MAKE) -C arm9 clean
$(MAKE) -C arm7 clean
- $(MAKE) -C tools/mwasmarm_patcher clean
clean-fs:
$(RM) $(filter %.narc %.arc,$(HOSTFS_FILES))
@@ -176,10 +175,13 @@ tools: $(TOOLDIRS)
$(TOOLDIRS):
@$(HOST_VARS) $(MAKE) -C $@
+clean-tools:
+ $(foreach tool,$(TOOLDIRS),$(MAKE) clean -C $(tool);)
+
$(MWASMARM): patch_mwasmarm
@:
-patch_mwasmarm:
+patch_mwasmarm: tools/mwasmarm_patcher
$(MWASMARM_PATCHER) $(MWASMARM)
ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS))
diff --git a/tools/csv2bin/.gitignore b/tools/csv2bin/.gitignore
deleted file mode 100644
index acf9f588..00000000
--- a/tools/csv2bin/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-csv2bin
diff --git a/tools/csv2bin/Makefile b/tools/csv2bin/Makefile
deleted file mode 100644
index 818e6579..00000000
--- a/tools/csv2bin/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-CC = gcc
-CFLAGS = -O3
-
-.PHONY: all clean
-
-all: csv2bin $(growth_rates_bin)
- @:
-
-clean:
- $(RM) csv2bin
-
-csv2bin: csv2bin.c
- $(CC) $(CFLAGS) -o $@ $^
diff --git a/tools/csv2bin/csv2bin.c b/tools/csv2bin/csv2bin.c
deleted file mode 100644
index 5c8b5111..00000000
--- a/tools/csv2bin/csv2bin.c
+++ /dev/null
@@ -1,103 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <ctype.h>
-
-char * ReadWholeFile(char * filename) {
- FILE * infile = fopen(filename, "rb");
- if (infile == NULL) return NULL;
- fseek(infile, 0, SEEK_END);
- size_t fsize = ftell(infile);
- fseek(infile, 0, SEEK_SET);
- char * ret = malloc(fsize);
- if (ret != NULL) {
- if (fread(ret, 1, fsize, infile) != fsize) {
- free(ret);
- ret = NULL;
- }
- }
- fclose(infile);
- return ret;
-}
-
-int main(int argc, char ** argv) {
- int width = 4;
- char * buffer = NULL;
- char * endptr = NULL;
- FILE * outfile = NULL;
- char * infname = NULL;
- for (int i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-w") == 0 || strcmp(argv[i], "--width") == 0) {
- ++i;
- width = strtol(argv[i], &endptr, 10);
- if (width == 0) {
- fprintf(stderr, "invalid integer value for %s: %s\n", argv[i - 1], argv[i]);
- return EXIT_FAILURE;
- }
- } else if (strcmp(argv[i], "-o") == 0 || strcmp(argv[i], "--output") == 0) {
- ++i;
- outfile = fopen(argv[i], "wb");
- if (outfile == NULL) {
- fprintf(stderr, "unable to open file '%s' for writing\n", argv[i]);
- return EXIT_FAILURE;
- }
- } else {
- if (buffer == NULL)
- {
- buffer = ReadWholeFile(argv[i]);
- }
- if (buffer == NULL)
- {
- fprintf(stderr, "invalid argument: %s\n", argv[i]);
- return EXIT_FAILURE;
- }
- infname = argv[i];
- }
- }
- if (buffer == NULL) {
- fprintf(stderr, "missing required argument: INFILE\n");
- return EXIT_FAILURE;
- }
- if (outfile == NULL) {
- char * infname_ext = strrchr(infname, '.');
- char * outfname = malloc(infname_ext - infname + 5);
- char * outfname_ext = stpncpy(outfname, argv[1], infname_ext - argv[1]);
- strcpy(outfname_ext, ".bin");
- outfile = fopen(outfname, "wb");
- if (outfile == NULL) {
- fprintf(stderr, "unable to open file '%s' for writing\n", outfname);
- return EXIT_FAILURE;
- }
- free(outfname);
- }
- uint32_t value;
- size_t size = 0;
- char * ptr = buffer;
- char * end = NULL;
- int lineno = 1;
- int colno = 1;
- while (1) {
- while (isspace(*ptr) || *ptr == ',') {
- if (*ptr == 0) break;
- if (*ptr == '\n')
- { lineno++; colno = 1; }
- if (*ptr == ',') colno++;
- ptr++;
- };
- if (*ptr == 0) break;
- value = strtoul(ptr, &end, 10);
- if (value == 0 && ptr == end) {
- fprintf(stderr, "syntax error: %d:%d\n", lineno, colno);
- return EXIT_FAILURE;
- }
- if (fwrite(&value, 1, width, outfile) != width) {
- fprintf(stderr, "write error\n");
- return EXIT_FAILURE;
- }
- ptr = end;
- }
- fclose(outfile);
- free(buffer);
- return EXIT_SUCCESS;
-}
diff --git a/tools/knarc/Makefile b/tools/knarc/Makefile
index ef75789b..1c33e9f6 100644
--- a/tools/knarc/Makefile
+++ b/tools/knarc/Makefile
@@ -1,15 +1,45 @@
-CXXFLAGS := -std=c++17 -O2 -Wall -Wno-switch -lstdc++fs
+CXXFLAGS := -std=c++17 -O2 -Wall -Wno-switch
+CFLAGS := -O2 -Wall -Wno-switch
-SRCS := Source.cpp Narc.cpp fnmatch.c
-HEADERS := Narc.h fnmatch.h
+WSLENV ?= no
+ifeq ($(OS),Windows_NT)
+C_SRCS := fnmatch.c
+LDFLAGS += -lstdc++fs
+else
+C_SRCS :=
+UNAME_S := $(shell uname -s)
+ifeq ($(UNAME_S),Darwin)
+LDFLAGS += -lstdc++ -lc++ -lc
+else
+ifneq ($(WSLENV),)
+LDFLAGS += -lstdc++fs
+endif
+endif
+endif
+CXX_SRCS := Source.cpp Narc.cpp
+C_OBJS := $(C_SRCS:%.c=%.o)
+CXX_OBJS := $(CXX_SRCS:%.cpp=%.o)
+OBJS := $(C_OBJS) $(CXX_OBJS)
+HEADERS := Narc.h fnmatch.h
.PHONY: all clean
all: knarc
@:
-knarc: $(SRCS) $(HEADERS)
- $(CXX) $(SRCS) -o $@ $(LDFLAGS) $(CXXFLAGS)
-
clean:
- $(RM) knarc knarc.exe
+ $(RM) knarc knarc.exe $(OBJS)
+
+ifeq ($(OS),Windows_NT)
+knarc: $(OBJS)
+ $(CXX) $^ -o $@ $(LDFLAGS) $(CXXFLAGS)
+
+%.o: %.c $(HEADERS)
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+%.o: %.cpp $(HEADERS)
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+else
+knarc: $(CXX_SRCS) $(HEADERS)
+ $(CXX) $(CXX_SRCS) -o $@ $(LDFLAGS) $(CXXFLAGS)
+endif