Skip to content

Commit

Permalink
add few more cmd options
Browse files Browse the repository at this point in the history
marekmaskarinec committed Jan 20, 2022

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent c1817e1 commit 15ecb3d
Showing 9 changed files with 54 additions and 199 deletions.
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -8,11 +8,13 @@ ifeq ($(PLATFORM), Linux)
CROSS_CC=x86_64-w64-mingw32-gcc
CROSS_FLAGS = -lm -Ldl -Ilib/rawdraw -lopengl32 -lgdi32 -Wl,-Bstatic -lpthread $(WARNS) $(DEFS) -DNO_OPENGL_HEADERS
TARGET=tophat
UMKA_BIN = ./lib/umka/build/umka
else
ifeq ($(SHORT_PLATFORM), MINGW64_NT)
LDLIBS += -lm -lopengl32 -lgdi32 -Wl,-Bstatic -lpthread lib/rawdraw/chew.c
TARGET=tophat.exe
DEFS += -DNO_OPENGL_HEADERS
UMKA_BIN = ./lib/umka/build/umka.exe
endif
endif

@@ -38,12 +40,6 @@ include src/Makefile

deepclean:: clean

install: $(TARGET) cross
./package.sh
cp cmd/tophat-cli /usr/bin
./cmd/tophat-cli install tophat-linux.zip
rm tophat-linux.zip tophat-win.zip

clean::
$(RM) $(TARGET)
$(RM) $(TARGET).exe
3 changes: 0 additions & 3 deletions cmd/init.bat

This file was deleted.

14 changes: 0 additions & 14 deletions cmd/package.bat

This file was deleted.

1 change: 0 additions & 1 deletion cmd/run.bat

This file was deleted.

168 changes: 0 additions & 168 deletions cmd/tophat-cli

This file was deleted.

8 changes: 5 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -7,13 +7,15 @@ SRCS = $(shell find src/ -name \*.c -print)
OBJS = $(sort $(SRCS:.c=.o))
DEPS = $(OBJS:.o=.d)

HELPER_SCRIPT = cmd/buildhelper.um
EM_TARGET = src/staembed.c
UMKA_MODULES = umka/anim.um umka/audio.um umka/csv.um umka/ent.um umka/image.um umka/input.um umka/misc.um umka/canvas.um umka/ray.um umka/rect.um umka/tilemap.um umka/window.um umka/ui.um umka/std/std.um umka/particles.um umka/light.um umka/lerp.um umka/std/map.um umka/std/utf8.um umka/font.um umka/th.um umka/signal.um umka/atlas.um

$(EM_TARGET): $(UMKA_MODULES)
$(EM_TARGET): $(UMKA_MODULES) LICENSE version
@echo EM $@
@./lib/umka/build/umka cmd/buildhelper.um em th_em_modulesrc $(UMKA_MODULES) > $(EM_TARGET)
@./lib/umka/build/umka cmd/buildhelper.um argarr th_em_modulenames $(notdir $(UMKA_MODULES)) >> $(EM_TARGET)
$(UMKA_BIN) $(HELPER_SCRIPT) em th_em_modulesrc $(UMKA_MODULES) > $(EM_TARGET)
@$(UMKA_BIN) $(HELPER_SCRIPT) argarr th_em_modulenames $(notdir $(UMKA_MODULES)) >> $(EM_TARGET)
@$(UMKA_BIN) $(HELPER_SCRIPT) em th_em_misc LICENSE version >> $(EM_TARGET)
rm -f src/bindings.o

%.o: %.c
15 changes: 12 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ int died = 0;

extern char *th_em_modulenames[];
extern char *th_em_modulesrc[];
extern char *th_em_misc[];
extern int th_em_modulenames_count;

void die() {
@@ -36,7 +37,7 @@ int main(int argc, char *argv[]) {
int umkaOK;

if (argc != 1) {
if (strcmp(argv[1], "-modsrc") == 0) {
if (strcmp(argv[1], "modsrc") == 0) {
if (argc != 3) {
printf("modsrc takes one argument\n");
return 1;
@@ -50,12 +51,20 @@ int main(int argc, char *argv[]) {
}

printf("No module named %s\n", argv[2]);
} else if (strcmp(argv[1], "license") == 0) {
printf("%s\n", th_em_misc[0]);
return 0;
} else if (strcmp(argv[1], "version") == 0) {
printf("%s\n", th_em_misc[1]);
} else {
printf(
"tophat - a minimalist game engine for making games in umka.\n"
"Just launching tophat without flags will run main.um or tophat.dat/main.um\n"
"Available flags:\n"
" -modsrc <module name>: print source of a builtin module\n");
"Available modes:\n"
" modsrc <module name> - print source of a builtin module\n"
" license - print the license\n"
" version - print the version\n"
"Visit mrms.cz/tophat.html for more info.");
return 0;
}

34 changes: 34 additions & 0 deletions src/staembed.c
Original file line number Diff line number Diff line change
@@ -2052,3 +2052,37 @@ const char *th_em_modulesrc[] = {
};
const char *th_em_modulenames[] = { "anim.um", "audio.um", "csv.um", "ent.um", "image.um", "input.um", "misc.um", "canvas.um", "ray.um", "rect.um", "tilemap.um", "window.um", "ui.um", "std.um", "particles.um", "light.um", "lerp.um", "map.um", "utf8.um", "font.um", "th.um", "signal.um", "atlas.um", };
int th_em_modulenames_count = 23;
const char *th_em_misc[] = {
"BSD 3-Clause License\n"
"\n"
"Copyright (c) 2021, Marek Maskarinec\n"
"All rights reserved.\n"
"\n"
"Redistribution and use in source and binary forms, with or without\n"
"modification, are permitted provided that the following conditions are met:\n"
"\n"
"1. Redistributions of source code must retain the above copyright notice, this\n"
" list of conditions and the following disclaimer.\n"
"\n"
"2. Redistributions in binary form must reproduce the above copyright notice,\n"
" this list of conditions and the following disclaimer in the documentation\n"
" and/or other materials provided with the distribution.\n"
"\n"
"3. Neither the name of the copyright holder nor the names of its\n"
" contributors may be used to endorse or promote products derived from\n"
" this software without specific prior written permission.\n"
"\n"
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n"
"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n"
"IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n"
"DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n"
"FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n"
"DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n"
"SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n"
"CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n"
"OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n"
"OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
"",
"v20-fde324a\n"
"",
};
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20-fde324a
v0.5

0 comments on commit 15ecb3d

Please sign in to comment.