Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Be more defensive when NetHack's make/make install has also run.
Browse files Browse the repository at this point in the history
In this special case, dat/dungeon etc exists and CMake picks up on
that file instead of the generated one, re-introducing the race
condition on makedefs -e and dlb cf nhdat.
  • Loading branch information
Heinrich Kuttler committed Feb 1, 2022
1 parent f32693f commit 3ac9049
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions dat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,39 +198,41 @@ set(LEVS_GEN
wizard3.lev)

add_custom_command(
DEPENDS makedefs bogusmon.txt engrave.txt epitaph.txt
DEPENDS $<TARGET_FILE:makedefs> bogusmon.txt engrave.txt epitaph.txt
OUTPUT bogusmon epitaph engrave
COMMAND makedefs ARGS -s)

add_custom_command(
DEPENDS makedefs data.base
DEPENDS $<TARGET_FILE:makedefs> data.base
OUTPUT data
COMMAND makedefs ARGS -d)

add_custom_command(
DEPENDS makedefs rumors.tru rumors.fal
DEPENDS $<TARGET_FILE:makedefs> rumors.tru rumors.fal
OUTPUT rumors
COMMAND makedefs ARGS -r)

add_custom_command(
DEPENDS makedefs quest.txt
DEPENDS $<TARGET_FILE:makedefs> quest.txt
OUTPUT quest.dat
COMMAND makedefs ARGS -q)

add_custom_command(
DEPENDS makedefs oracles.txt
DEPENDS $<TARGET_FILE:makedefs> oracles.txt
OUTPUT oracles
COMMAND makedefs ARGS -h)

# Hack: Depend on date.h to avoid race.
add_custom_command(
DEPENDS makedefs ${NLE_INC_GEN}/date.h
DEPENDS $<TARGET_FILE:makedefs> ${NLE_INC_GEN}/date.h
OUTPUT options
COMMAND makedefs ARGS -v)

# Hack: Depend on bogusmon to avoid race wrt. makedef's grep.tmp file.
# Hack: Depend on bogusmon to avoid race wrt. makedef's grep.tmp file. Best to
# be defensive about the paths (matters if NetHack's make install was run).
add_custom_command(
DEPENDS makedefs dgn_comp dungeon.def bogusmon
DEPENDS $<TARGET_FILE:makedefs> $<TARGET_FILE:dgn_comp>
${NLE_DAT_GEN}/dungeon.def ${NLE_DAT_GEN}/bogusmon
OUTPUT dungeon dungeon.pdf
COMMAND makedefs ARGS -e
COMMAND dgn_comp ARGS dungeon.pdf)
Expand All @@ -245,8 +247,20 @@ add_custom_command(
OUTPUT perm record logfile xlogfile COMMAND ${CMAKE_COMMAND} -E touch perm
record logfile xlogfile)

# Defensive dependencies for when we also build NetHack with make/make install.
list(TRANSFORM DATDLB PREPEND ${NLE_DAT_GEN}/ OUTPUT_VARIABLE
NLE_DAT_GEN_DATDLB)
list(TRANSFORM LEVS_GEN PREPEND ${NLE_DAT_GEN}/ OUTPUT_VARIABLE
NLE_DAT_GEN_LEVS_GEN)

# Defensive dependencies for when we also build NetHack with make/make install.
list(TRANSFORM DATDLB PREPEND ${NLE_DAT_GEN}/ OUTPUT_VARIABLE
NLE_DAT_GEN_DATDLB)
list(TRANSFORM LEVS_GEN PREPEND ${NLE_DAT_GEN}/ OUTPUT_VARIABLE
NLE_DAT_GEN_LEVS_GEN)

add_custom_command(
DEPENDS dlb ${DATDLB} ${LEVS_GEN}
DEPENDS dlb ${NLE_DAT_GEN_DATDLB} ${NLE_DAT_GEN_LEVS_GEN}
OUTPUT nhdat
COMMAND LC_ALL=C $<TARGET_FILE:dlb> ARGS cf nhdat ${DATDLB} ${LEVS_GEN})

Expand Down

0 comments on commit 3ac9049

Please sign in to comment.