Makefile reimports when import script changes
This commit is contained in:
@@ -12,20 +12,24 @@ ALL_DIRS := $(addprefix $(BUILD_DIR)/,$(SRC_DIRS))
|
|||||||
BIN_FILE := $(DIST_DIR)/libsm64.so
|
BIN_FILE := $(DIST_DIR)/libsm64.so
|
||||||
LIB_H_FILE := $(DIST_DIR)/include/libsm64.h
|
LIB_H_FILE := $(DIST_DIR)/include/libsm64.h
|
||||||
|
|
||||||
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))
|
C_IMPORTED := src/mario/geo.inc.c src/mario/model.inc.c
|
||||||
|
H_IMPORTED := $(C_IMPORTED:.c=.h)
|
||||||
|
IMPORTED := $(C_IMPORTED) $(H_IMPORTED)
|
||||||
|
|
||||||
|
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) $(C_IMPORTED)
|
||||||
O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o))
|
O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o))
|
||||||
DEP_FILES := $(O_FILES:.o=.d)
|
DEP_FILES := $(O_FILES:.o=.d)
|
||||||
|
|
||||||
|
DUMMY != mkdir -p src/mario
|
||||||
DUMMY != mkdir -p $(ALL_DIRS)
|
DUMMY != mkdir -p $(ALL_DIRS)
|
||||||
DUMMY != mkdir -p $(DIST_DIR)/include
|
DUMMY != mkdir -p $(DIST_DIR)/include
|
||||||
|
|
||||||
DUMMY != ./import-mario-geo.py >&2 || echo FAIL
|
$(filter-out src/mario/geo.inc.c,$(IMPORTED)): src/mario/geo.inc.c
|
||||||
ifeq ($(DUMMY),FAIL)
|
src/mario/geo.inc.c: ./import-mario-geo.py
|
||||||
$(error Script import-mario-geo.py failed)
|
./import-mario-geo.py
|
||||||
endif
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o: %.c
|
$(BUILD_DIR)/%.o: %.c $(IMPORTED)
|
||||||
$(CC) $(CFLAGS) -MM -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
|
@$(CC) $(CFLAGS) -MM -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
|
||||||
$(CC) -c $(CFLAGS) -o $@ $<
|
$(CC) -c $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
$(BIN_FILE): $(O_FILES)
|
$(BIN_FILE): $(O_FILES)
|
||||||
|
|||||||
+2
-4
@@ -38,6 +38,7 @@ const GeoLayout mario_geo_libsm64[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void *mario_geo_ptr = (void*)mario_geo_libsm64;
|
void *mario_geo_ptr = (void*)mario_geo_libsm64;
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
geo_inc_h = """
|
geo_inc_h = """
|
||||||
@@ -56,10 +57,6 @@ model_inc_h = """
|
|||||||
def main():
|
def main():
|
||||||
global model_inc_h
|
global model_inc_h
|
||||||
|
|
||||||
if os.path.exists("src/mario/geo.inc.c") and os.path.exists("src/mario/model.inc.c") \
|
|
||||||
and os.path.exists("src/mario/geo.inc.h") and os.path.exists("src/mario/model.inc.h"):
|
|
||||||
return;
|
|
||||||
|
|
||||||
shutil.rmtree("src/mario", ignore_errors=True)
|
shutil.rmtree("src/mario", ignore_errors=True)
|
||||||
os.makedirs("src/mario", exist_ok=True)
|
os.makedirs("src/mario", exist_ok=True)
|
||||||
|
|
||||||
@@ -85,6 +82,7 @@ def main():
|
|||||||
lines.insert(0, "#include \"../load_tex_data.h\"")
|
lines.insert(0, "#include \"../load_tex_data.h\"")
|
||||||
model_inc_c = "\n".join(lines)
|
model_inc_c = "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
with open("src/mario/geo.inc.c", "w") as file:
|
with open("src/mario/geo.inc.c", "w") as file:
|
||||||
file.write(geo_inc_c_header + geo_inc_c + geo_inc_c_footer)
|
file.write(geo_inc_c_header + geo_inc_c + geo_inc_c_footer)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user