From 79666e5764eeff013bc7d4a54e9317146941bd24 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Sat, 16 May 2026 00:53:56 +0800 Subject: [PATCH] revert sdcpp build steps to use makefile and cmake without external txt files --- CMakeLists.txt | 35 +++++++++---- Makefile | 32 +++++------- otherarch/sdcpp/src_common.txt | 94 ---------------------------------- otherarch/sdcpp/src_main.txt | 14 ----- 4 files changed, 38 insertions(+), 137 deletions(-) delete mode 100644 otherarch/sdcpp/src_common.txt delete mode 100644 otherarch/sdcpp/src_main.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a62f932f..af1855d75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -474,17 +474,30 @@ target_compile_features(common2 PUBLIC cxx_std_17) # don't bump target_link_libraries(common2 PRIVATE ggml ${LLAMA_EXTRA_LIBS}) set_target_properties(common2 PROPERTIES POSITION_INDEPENDENT_CODE ON) -file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/otherarch/sdcpp/src_common.txt" SDCPP_COMMON_SOURCES) -list(FILTER SDCPP_COMMON_SOURCES EXCLUDE REGEX "^#") -list(REMOVE_ITEM SDCPP_COMMON_SOURCES "") - -set(SDCPP_SOURCES) -list(APPEND SDCPP_SOURCES "otherarch/sdcpp/sdtype_adapter.cpp") -foreach(src_file ${SDCPP_COMMON_SOURCES}) - list(APPEND SDCPP_SOURCES "otherarch/sdcpp/${src_file}") -endforeach() - -add_library(sdtype_adapter ${SDCPP_SOURCES}) +add_library(sdtype_adapter + otherarch/sdcpp/sdtype_adapter.cpp + otherarch/sdcpp/ggml_graph_cut.cpp + otherarch/sdcpp/ggml_graph_cut.h + otherarch/sdcpp/image_metadata.cpp + otherarch/sdcpp/model.cpp + otherarch/sdcpp/sample-cache.cpp + otherarch/sdcpp/util.cpp + otherarch/sdcpp/name_conversion.cpp + otherarch/sdcpp/upscaler.cpp + otherarch/sdcpp/stable-diffusion.cpp + otherarch/sdcpp/thirdparty/zip.c + otherarch/sdcpp/model_io/gguf_io.cpp + otherarch/sdcpp/model_io/pickle_io.cpp + otherarch/sdcpp/model_io/safetensors_io.cpp + otherarch/sdcpp/model_io/torch_legacy_io.cpp + otherarch/sdcpp/model_io/torch_zip_io.cpp + otherarch/sdcpp/tokenizers/bpe_tokenizer.cpp + otherarch/sdcpp/tokenizers/clip_tokenizer.cpp + otherarch/sdcpp/tokenizers/mistral_tokenizer.cpp + otherarch/sdcpp/tokenizers/qwen2_tokenizer.cpp + otherarch/sdcpp/tokenizers/t5_unigram_tokenizer.cpp + otherarch/sdcpp/tokenizers/tokenizer.cpp + otherarch/sdcpp/tokenizers/tokenize_util.cpp) target_include_directories(sdtype_adapter PUBLIC . ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/sdcpp ./otherarch/sdcpp/thirdparty ./tools ./common) target_compile_features(sdtype_adapter PUBLIC cxx_std_17) # don't bump target_link_libraries(sdtype_adapter PRIVATE common2 ggml ${LLAMA_EXTRA_LIBS}) diff --git a/Makefile b/Makefile index d85b7eafb..f58236d33 100644 --- a/Makefile +++ b/Makefile @@ -683,35 +683,31 @@ llama-impl.o: src/llama-impl.cpp src/llama-impl.h budget.o: common/reasoning-budget.cpp common/reasoning-budget.h $(CXX) $(CXXFLAGS) -c $< -o $@ -SDCPP_DIR := otherarch/sdcpp +SDCPP_COMMON_BASENAMES := anima.hpp auto_encoder_kl.hpp avi_writer.h cache_dit.hpp clip.hpp common_block.hpp common_dit.hpp condition_cache_utils.hpp conditioner.hpp control.hpp convert.cpp denoiser.hpp diffusion_model.hpp easycache.hpp ernie_image.hpp esrgan.hpp flux.hpp ggml_extend_backend.hpp ggml_extend.hpp image_metadata.cpp image_metadata.h kcpp_sd_extensions.h latent-preview.h llm.hpp lora.hpp ltxv.hpp mmdit.hpp model.cpp model.h model_io/binary_io.h model_io/gguf_io.cpp model_io/gguf_io.h model_io/gguf_reader_ext.h model_io/pickle_io.cpp model_io/pickle_io.h model_io/safetensors_io.cpp model_io/safetensors_io.h model_io/tensor_storage.h model_io/torch_legacy_io.cpp model_io/torch_legacy_io.h model_io/torch_zip_io.cpp model_io/torch_zip_io.h msf_gif.h name_conversion.cpp name_conversion.h ordered_map.hpp pmid.hpp preprocessing.hpp qwen_image.hpp rng.hpp rng_mt19937.hpp rng_philox.hpp rope.hpp sample-cache.cpp sample-cache.h spectrum.hpp stable-diffusion.cpp stable-diffusion.h t5.hpp tae.hpp tensor_ggml.hpp tensor.hpp thirdparty/darts.h thirdparty/miniz.h thirdparty/stb_image_resize.h thirdparty/stb_image_write.h thirdparty/zip.c thirdparty/zip.h tokenizers/bpe_tokenizer.cpp tokenizers/bpe_tokenizer.h tokenizers/clip_tokenizer.cpp tokenizers/clip_tokenizer.h tokenizers/mistral_tokenizer.cpp tokenizers/mistral_tokenizer.h tokenizers/qwen2_tokenizer.cpp tokenizers/qwen2_tokenizer.h tokenizers/t5_unigram_tokenizer.cpp tokenizers/t5_unigram_tokenizer.h tokenizers/tokenizer.cpp tokenizers/tokenizer.h tokenizers/tokenize_util.cpp tokenizers/tokenize_util.h tokenizers/vocab/vocab.h ucache.hpp unet.hpp upscaler.cpp upscaler.h util.cpp util.h vae.hpp version.cpp wan.hpp z_image.hpp ggml_graph_cut.cpp ggml_graph_cut.h -SDCPP_COMMON_FILES := $(shell cat $(SDCPP_DIR)/src_common.txt) -SDCPP_COMMON_FILENAMES := $(foreach f,$(filter-out #%,$(SDCPP_COMMON_FILES)),$(SDCPP_DIR)/$(f)) -SOURCES_C_SDCOMMON := $(filter %.c,$(SDCPP_COMMON_FILENAMES)) -SOURCES_CPP_SDCOMMON := $(filter %.cpp,$(SDCPP_COMMON_FILENAMES)) -HEADERS_SDCOMMON := $(filter %.h %.hpp,$(SDCPP_COMMON_FILENAMES)) -OBJS_SDCOMMON := $(patsubst %.cpp,%.o,$(SOURCES_CPP_SDCOMMON)) $(patsubst %.c,%.o,$(SOURCES_C_SDCOMMON)) +SDCPP_MAIN_BASENAMES := common/common.cpp common/common.h common/log.cpp common/log.h common/media_io.cpp common/media_io.cpp common/media_io.h common/resource_owners.hpp convert.cpp image_metadata.cpp main.cpp version.cpp tokenizers/vocab/clip_t5.hpp tokenizers/vocab/mistral.hpp tokenizers/vocab/qwen.hpp tokenizers/vocab/umt5.hpp tokenizers/vocab/vocab.cpp -SDCPP_MAIN_FILES := $(shell cat $(SDCPP_DIR)/src_main.txt) -SDCPP_MAIN_FILENAMES := $(foreach f,$(filter-out #%,$(SDCPP_MAIN_FILES)),$(SDCPP_DIR)/$(f)) -SOURCES_C_SDMAIN := $(filter %.c,$(SDCPP_MAIN_FILENAMES)) -SOURCES_CPP_SDMAIN := $(filter %.cpp,$(SDCPP_MAIN_FILENAMES)) -HEADERS_SDMAIN := $(filter %.h %.hpp,$(SDCPP_MAIN_FILENAMES)) -OBJS_SDMAIN := $(patsubst %.cpp,%.o,$(SOURCES_CPP_SDMAIN)) $(patsubst %.c,%.o,$(SOURCES_C_SDMAIN)) +SOURCES_SDCOMMON := $(foreach f,$(SDCPP_COMMON_BASENAMES),otherarch/sdcpp/$(f)) +HEADERS_SDCOMMON := $(filter %.h,$(SOURCES_SDCOMMON)) $(filter %.hpp, $(SOURCES_SDCOMMON)) +OBJS_SDCOMMON := $(patsubst %.cpp,%.o,$(filter %.cpp,$(SOURCES_SDCOMMON))) otherarch/sdcpp/thirdparty/zip.o -$(SDCPP_DIR)/%.o: $(HEADERS_SDCOMMON) +SOURCES_SDMAIN := $(foreach f,$(SDCPP_MAIN_BASENAMES),otherarch/sdcpp/$(f)) +HEADERS_SDMAIN := $(filter %.h,$(SOURCES_SDMAIN)) $(filter %.hpp, $(SOURCES_SDMAIN)) +OBJS_SDMAIN := $(patsubst %.cpp,%.o,$(filter %.cpp,$(SOURCES_SDMAIN))) + +otherarch/sdcpp/%.o: $(HEADERS_SDCOMMON) $(OBJS_SDMAIN): $(HEADERS_SDMAIN) SDCPP_FLAGS := -I./vendor/nlohmann -$(SDCPP_DIR)/%.o: $(SDCPP_DIR)/%.cpp +otherarch/sdcpp/%.o: otherarch/sdcpp/%.cpp $(CXX) $(CXXFLAGS) $(SDCPP_FLAGS) -c $< -o $@ -$(SDCPP_DIR)/%.o: $(SDCPP_DIR)/%.c - $(CC) $(CFLAGS) -c $< -o $@ +otherarch/sdcpp/thirdparty/zip.o: otherarch/sdcpp/thirdparty/zip.c + $(CC) $(CFLAGS) $(SDCPP_FLAGS) -c $< -o $@ -OBJS_SDTYPE := $(SDCPP_DIR)/sdtype_adapter.o $(OBJS_SDCOMMON) +OBJS_SDTYPE := otherarch/sdcpp/sdtype_adapter.o $(OBJS_SDCOMMON) #whisper objects diff --git a/otherarch/sdcpp/src_common.txt b/otherarch/sdcpp/src_common.txt deleted file mode 100644 index 9165de3ff..000000000 --- a/otherarch/sdcpp/src_common.txt +++ /dev/null @@ -1,94 +0,0 @@ -anima.hpp -auto_encoder_kl.hpp -avi_writer.h -cache_dit.hpp -clip.hpp -common_block.hpp -common_dit.hpp -condition_cache_utils.hpp -conditioner.hpp -control.hpp -convert.cpp -denoiser.hpp -diffusion_model.hpp -easycache.hpp -ernie_image.hpp -esrgan.hpp -flux.hpp -ggml_extend.hpp -ggml_extend_backend.hpp -ggml_graph_cut.cpp -ggml_graph_cut.h -image_metadata.cpp -image_metadata.h -kcpp_sd_extensions.h -latent-preview.h -llm.hpp -lora.hpp -ltxv.hpp -mmdit.hpp -model.cpp -model.h -model_io/binary_io.h -model_io/gguf_io.cpp -model_io/gguf_io.h -model_io/gguf_reader_ext.h -model_io/pickle_io.cpp -model_io/pickle_io.h -model_io/safetensors_io.cpp -model_io/safetensors_io.h -model_io/tensor_storage.h -model_io/torch_legacy_io.cpp -model_io/torch_legacy_io.h -model_io/torch_zip_io.cpp -model_io/torch_zip_io.h -msf_gif.h -name_conversion.cpp -name_conversion.h -ordered_map.hpp -pmid.hpp -preprocessing.hpp -qwen_image.hpp -rng.hpp -rng_mt19937.hpp -rng_philox.hpp -rope.hpp -sample-cache.cpp -sample-cache.h -spectrum.hpp -stable-diffusion.cpp -stable-diffusion.h -t5.hpp -tae.hpp -tensor.hpp -tensor_ggml.hpp -thirdparty/darts.h -thirdparty/miniz.h -thirdparty/stb_image_resize.h -thirdparty/stb_image_write.h -thirdparty/zip.c -thirdparty/zip.h -tokenizers/bpe_tokenizer.cpp -tokenizers/bpe_tokenizer.h -tokenizers/clip_tokenizer.cpp -tokenizers/clip_tokenizer.h -tokenizers/mistral_tokenizer.cpp -tokenizers/mistral_tokenizer.h -tokenizers/qwen2_tokenizer.cpp -tokenizers/qwen2_tokenizer.h -tokenizers/t5_unigram_tokenizer.cpp -tokenizers/t5_unigram_tokenizer.h -tokenizers/tokenize_util.cpp -tokenizers/tokenize_util.h -tokenizers/tokenizer.cpp -tokenizers/tokenizer.h -tokenizers/vocab/vocab.h -ucache.hpp -unet.hpp -upscaler.cpp -upscaler.h -util.cpp -util.h -vae.hpp -wan.hpp -z_image.hpp diff --git a/otherarch/sdcpp/src_main.txt b/otherarch/sdcpp/src_main.txt deleted file mode 100644 index 84d60b98c..000000000 --- a/otherarch/sdcpp/src_main.txt +++ /dev/null @@ -1,14 +0,0 @@ -common/common.cpp -common/common.h -common/log.cpp -common/log.h -common/media_io.cpp -common/media_io.h -common/resource_owners.hpp -main.cpp -tokenizers/vocab/clip_t5.hpp -tokenizers/vocab/mistral.hpp -tokenizers/vocab/qwen.hpp -tokenizers/vocab/umt5.hpp -tokenizers/vocab/vocab.cpp -version.cpp