jgabaut / helapordo

A roguelike terminal game, using ncurses.
https://jgabaut.github.io/helapordo-docs
GNU General Public License v3.0
15 stars 0 forks source link

[BUG] Build can fail on system with different awk #52

Open jgabaut opened 8 months ago

jgabaut commented 8 months ago

Describe the bug Since building needs anvil to generate its template header, it seems on some platforms build might fail due to anvil relying on awk to parse its config file.

To Reproduce Steps to reproduce the behavior:

  1. Try building
  2. See awk invalid syntax errors

Expected behavior Build succeeds even if awk fails.

Additional context

See the related issue on amboso

My version of awk (working):

$ awk -W version
GNU Awk 5.2.2, API 3.2, PMA Avon 8-g1, (GNU MPFR 4.2.1, GNU MP 6.3.0)
Copyright (C) 1989, 1991-2023 Free Software Foundation.

Version of awk on the reporter machine:

$ awk -W version
mawk 1.3.4 20200120
Copyright 2008-2019,2020, Thomas E. Dickey
Copyright 1991-1996,2014, Michael D. Brennan
jgabaut commented 6 months ago

A quick patch for this would be:

If you have invil already installed and maybe symlinked to anvil, you can do: ./script/bootstrap_anvil.sh -i and pick the global reference instead of the repo one.

A more substantial fix would be updating the ./anvil rule in Makefile.am to use repo_invil.

jgabaut commented 6 months ago

Edit:

This patch is useless after 1.4.4 . Refer to this for avoiding the anvil dependency.

To build the game without needing anvil at all (thus avoiding this issue), you can apply this patch:

diff --git a/Makefile.am b/Makefile.am
index 9a72596..4a4ed7d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,7 +21,7 @@ PACK_NAME = $(TARGET)-$(VERSION)-$(OS)-$(MACHINE)
 PALETTE_PATH = "./static/palette.gpl"

 # Source files
-helapordo_SOURCES = src/helapordo.c src/game_core.c src/game_utils.c src/game_curses.c src/rooms.c src/artifacts.c src/specials.c src/main.c src/sprites.c src/floors.c sprites4curses/s4c-animate/animate.c koliseo/src/koliseo.c src/anvil__helapordo.c src/animations/mummy_shuffle.c src/animations/ghost_spell.c src/animations/boar_scream.c src/animations/troll_club.c src/animations/goblin_shoot.c src/animations/zombie_walk.c src/animations/imp_fireball.c src/animations/werewolf_transform.c src/animations/knight_tapis.c src/animations/mage_spark.c src/animations/archer_drop.c src/animations/assassin_poof.c src/animations/crawlingdude_crawl.c src/animations/srwarthog_square.c src/animations/headlessninja_throw.c src/animations/bluetroll_wonder.c src/animations/enter_door.c src/animations/alt_chest_opening.c src/game_lore.c src/game_lore_alt.c src/palette.c
+helapordo_SOURCES = src/helapordo.c src/game_core.c src/game_utils.c src/game_curses.c src/rooms.c src/artifacts.c src/specials.c src/main.c src/sprites.c src/floors.c sprites4curses/s4c-animate/animate.c koliseo/src/koliseo.c src/animations/mummy_shuffle.c src/animations/ghost_spell.c src/animations/boar_scream.c src/animations/troll_club.c src/animations/goblin_shoot.c src/animations/zombie_walk.c src/animations/imp_fireball.c src/animations/werewolf_transform.c src/animations/knight_tapis.c src/animations/mage_spark.c src/animations/archer_drop.c src/animations/assassin_poof.c src/animations/crawlingdude_crawl.c src/animations/srwarthog_square.c src/animations/headlessninja_throw.c src/animations/bluetroll_wonder.c src/animations/enter_door.c src/animations/alt_chest_opening.c src/game_lore.c src/game_lore_alt.c src/palette.c

 # Linking rule
 LDADD = $(HELAPORDO_LDFLAGS)
@@ -194,7 +194,7 @@ cleanob:
    @echo -e "\033[1;33mDone.\e[0m"

 # Default target (builds everything)
-all: ./anvil ./src/anvil__helapordo.c ./src/palette.c ./koliseo/src/koliseo.o ./sprites4curses/s4c-animate/animate.o $(TARGET)
+all: ./src/palette.c ./koliseo/src/koliseo.o ./sprites4curses/s4c-animate/animate.o $(TARGET)

 # Target to clean and rebuild
 rebuild: clean all
diff --git a/src/helapordo.h b/src/helapordo.h
index fa50d35..42e800a 100644
--- a/src/helapordo.h
+++ b/src/helapordo.h
@@ -52,7 +52,7 @@
 #include "game_curses.h"
 #include "sprites.h"
 #include "floors.h"
-#include "anvil__helapordo.h"
+//#include "anvil__helapordo.h"
 #include "game_lore.h"
 #include "game_lore_alt.h"
jgabaut commented 6 months ago

Since reverting the included amboso to <1.8.x doesn't seem mantainable, I'd rather switch the default anvil implementation for the bootstrap to be invil. This would mean the build fails instead on any system not having cargo and the Rust build chain ready.

To do things properly ,the anvil__helapordo.h inclusion should be guarded by a configure macro.

jgabaut commented 6 months ago

Version 1.3.6 adds --enable-anvilpick to turn on interactive selection of anvil implementation.

jgabaut commented 6 months ago

Version 1.4.0 changes default anvil implementation to be invil on macOS. This means by default you also need the Rust buildchain on your machine to build, but it's not like amboso was gonna save the day without:

You can use --enable-anvilpick to have the interactive selection. When doing so, default for empty pick is now invil for all platforms.

jgabaut commented 4 months ago

Version 1.4.3 (see PR) updates README.md to show that the requirement for amboso is actually gawk.

jgabaut commented 3 months ago

Version 1.4.4 adds --enable-anvil to ./configure so that a build can be done without needing anvil header at all.