diff --git a/3ds/logo.bcma.lz b/3ds/logo.bcma.lz new file mode 100644 index 0000000..dd9db8c Binary files /dev/null and b/3ds/logo.bcma.lz differ diff --git a/3ds/servefiles.py b/3ds/servefiles.py new file mode 100755 index 0000000..2a3ac00 --- /dev/null +++ b/3ds/servefiles.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python +import os +import socket +import struct +import sys +import threading +import time +import urllib + +try: + from SimpleHTTPServer import SimpleHTTPRequestHandler + from SocketServer import TCPServer + from urlparse import urljoin + from urllib import pathname2url, quote +except ImportError: + from http.server import SimpleHTTPRequestHandler + from socketserver import TCPServer + from urllib.parse import urljoin, quote + from urllib.request import pathname2url + +if len(sys.argv) < 3: + print("Usage: " + sys.argv[0] + " [host ip]") + sys.exit(1) + +ip = sys.argv[1] +directory = sys.argv[2] + +if not os.path.exists(directory): + print(directory + ": No such file or directory.") + sys.exit(1) + +if len(sys.argv) >= 4: + hostIp = sys.argv[3] +else: + hostIp = [(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1] + +print("Preparing data...") + +baseUrl = hostIp + ":8080/" +payload = "" + +if os.path.isfile(directory): + payload += baseUrl + quote(os.path.basename(directory)) + directory = os.path.dirname(directory) +else: + for file in [ file for file in next(os.walk(directory))[2] if file.endswith(('.cia', '.tik')) ]: + payload += baseUrl + quote(file) + "\n" + +if len(payload) == 0: + print("No files to serve.") + sys.exit(1) + +payloadBytes = payload.encode("ascii") + +if not directory == "": + os.chdir(directory) + +print("") +print("URLS:") +print(payload) +print("") + +print("Opening HTTP server on port 8080...") + +server = TCPServer(("", 8080), SimpleHTTPRequestHandler) +thread = threading.Thread(target=server.serve_forever) +thread.start() + +try: + print("Sending URL(s) to " + ip + ":5000...") + + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect((ip, 5000)) + sock.sendall(struct.pack('!L', len(payloadBytes)) + payloadBytes) + while len(sock.recv(1)) < 1: + time.sleep(0.05) + + sock.close() +except Exception as e: + print("Error: " + str(e)) + server.shutdown() + sys.exit(1) + +print("Shutting down HTTP server...") + +server.shutdown() diff --git a/README.md b/README.md index adf4966..f698196 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,5 @@ Common build tools for C/C++ projects. Supports PC and 3DS targets. Requires some form of the zip/unzip commands. When embedding binary files, xxd is required as well. + +Credit for 3DS homebrew logo goes to [PabloMK7](http://gbatemp.net/members/pablomk7.345712/). diff --git a/make_base b/make_base index 1c70110..17b048b 100644 --- a/make_base +++ b/make_base @@ -151,9 +151,17 @@ OBJECT_FILES := $(filter-out $(BUILT_FILTER),$(OBJECT_FILES)) OUTPUT_ZIP_FILE ?= $(OUTPUT_DIR)/$(STRIPPED_NAME).zip -VERSION_MAJOR ?= 0 -VERSION_MINOR ?= 0 -VERSION_MICRO ?= 0 +ifeq ($(strip $(VERSION_MAJOR)),) + VERSION_MAJOR := 0 +endif + +ifeq ($(strip $(VERSION_MINOR)),) + VERSION_MINOR := 0 +endif + +ifeq ($(strip $(VERSION_MICRO)),) + VERSION_MICRO := 0 +endif LD_FLAGS := $(patsubst %,-L%/lib,$(LIBRARY_DIRS)) $(patsubst %,-l%,$(LIBRARIES)) COMMON_CC_FLAGS := $(sort $(foreach dir,$(SOURCE_DIRS),$(patsubst %,-I$(TARGET_BUILD_DIR)/%,$(dir $(call rwildcard,$(dir),*))))) $(patsubst %,-I%,$(INCLUDE_DIRS)) $(patsubst %,-I%/include,$(LIBRARY_DIRS)) -g -Wall -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_MICRO=$(VERSION_MICRO) $(BUILD_FLAGS) @@ -294,6 +302,8 @@ else ifeq ($(TARGET_OS),3ds) _3DSXTOOL := $(DEVKITARM)/bin/3dsxtool _3DSLINK := $(DEVKITARM)/bin/3dslink + SERVEFILES := python $(BUILDTOOLS_DIR)/3ds/servefiles.py + ifeq ($(HOST_OS),windows) ifeq ($(HOST_ARCH),x86_64) MAKEROM := $(BUILDTOOLS_DIR)/3ds/makerom64.exe @@ -345,6 +355,8 @@ else ifeq ($(TARGET_OS),3ds) ifneq ("$(wildcard $(LOGO))","") COMMON_MAKEROM_FLAGS += -logo "$(LOGO)" + else ifneq ($(LOGO),plain) + COMMON_MAKEROM_FLAGS += -logo "$(BUILDTOOLS_DIR)/3ds/logo.bcma.lz" endif ifeq ($(suffix $(BANNER_IMAGE)),.cgfx) @@ -422,6 +434,11 @@ runhw: $(OUTPUT_ZIP_FILE) @echo "Running..." @$(_3DSLINK) --address $(REMOTE_IP) $(TARGET_OUTPUT_DIR)/3ds/$(STRIPPED_NAME)/$(STRIPPED_NAME).3dsx +install: $(OUTPUT_ZIP_FILE) + @echo "Installing..." + @$(SERVEFILES) $(REMOTE_IP) $(TARGET_OUTPUT_DIR)/$(STRIPPED_NAME).cia + @echo "Installed." + endif $(TARGET_BUILD_DIR)/%.shbin.o: $(TARGET_BUILD_DIR)/%.shbin.c