diff --git a/utils/Makefile b/utils/Makefile index 528cc548..556ee497 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -2,6 +2,16 @@ CC ?= gcc CXX ?= g++ +TARGET_MACHINE := $(shell $(CC) -dumpmachine) + +ifneq (,$(findstring apple,$(TARGET_MACHINE))) +MACOS = true +else ifneq (,$(findstring mingw,$(TARGET_MACHINE))) +WINDOWS = true +else ifneq (,$(findstring wasm,$(TARGET_MACHINE))) +WASM = true +endif + CFLAGS += -Wall -Wextra -std=c99 -fPIC CXXFLAGS += -Wall -Wextra -Wshadow -std=gnu++0x -fPIC ifeq ($(DEBUG),1) @@ -10,10 +20,10 @@ CXXFLAGS += -g -O0 -DDEBUG else CFLAGS += -O3 -DNDEBUG CXXFLAGS += -O3 -DNDEBUG -ifneq (,$(findstring apple,$(shell $(CC) -dumpmachine))) -LDFLAGS += -Wl,-dead_strip -Wl,-dead_strip_dylibs -Wl,-x +ifeq ($(MACOS),true) +LDFLAGS += -Wl,-dead_strip,-dead_strip_dylibs,-x else -LDFLAGS += -Wl,-O1 -Wl,--no-undefined -Wl,--strip-all +LDFLAGS += -Wl,-O1,--no-undefined,--strip-all endif endif diff --git a/utils/utils_lilv.cpp b/utils/utils_lilv.cpp index 61219290..a575eb25 100644 --- a/utils/utils_lilv.cpp +++ b/utils/utils_lilv.cpp @@ -69,16 +69,6 @@ static char* realpath(const char* const name, char* const resolved) return _fullpath(retname, name, PATH_MAX); } - -static void setenv(const char* const key, const char* const value, int) -{ - SetEnvironmentVariableA(key, value); -} - -static void unsetenv(const char* const key) -{ - SetEnvironmentVariableA(key, nullptr); -} #else # include # include @@ -4577,8 +4567,6 @@ const PedalboardInfo_Mini* const* get_all_pedalboards(const int ptype) if (ptype == kPedalboardInfoFactoryOnly && FACTORYINFO != nullptr) return FACTORYINFO; - char* const oldlv2path = getenv_strdup_or_null("LV2_PATH"); - const char* pedalboard_lv2_path; switch (ptype) { @@ -4599,20 +4587,13 @@ const PedalboardInfo_Mini* const* get_all_pedalboards(const int ptype) break; } - setenv("LV2_PATH", pedalboard_lv2_path, 1); - LilvWorld* const w = lilv_world_new(); - lilv_world_load_all(w); - if (oldlv2path != nullptr) - { - setenv("LV2_PATH", oldlv2path, 1); - free(oldlv2path); - } - else - { - unsetenv("LV2_PATH"); - } + LilvNode* const lv2path = lilv_new_string(w, pedalboard_lv2_path); + lilv_world_set_option(w, LILV_OPTION_LV2_PATH, lv2path); + lilv_free(lv2path); + + lilv_world_load_all(w); LilvNode* const versiontypenode = lilv_new_uri(w, LILV_NS_MODPEDAL "version"); LilvNode* const rdftypenode = lilv_new_uri(w, LILV_NS_RDF "type"); @@ -4667,22 +4648,13 @@ const PedalboardInfo_Mini* const* get_all_pedalboards(const int ptype) const char* const* get_broken_pedalboards(void) { - // Custom path for pedalboards - char* const oldlv2path = getenv_strdup_or_null("LV2_PATH"); - setenv("LV2_PATH", _get_lv2_pedalboards_path(), 1); - LilvWorld* const w = lilv_world_new(); - lilv_world_load_all(w); - if (oldlv2path != nullptr) - { - setenv("LV2_PATH", oldlv2path, 1); - free(oldlv2path); - } - else - { - unsetenv("LV2_PATH"); - } + LilvNode* const lv2path = lilv_new_string(w, _get_lv2_pedalboards_path()); + lilv_world_set_option(w, LILV_OPTION_LV2_PATH, lv2path); + lilv_free(lv2path); + + lilv_world_load_all(w); LilvNode* const ingenblocknode = lilv_new_uri(w, LILV_NS_INGEN "block"); LilvNode* const lv2protonode = lilv_new_uri(w, LILV_NS_LV2 "prototype"); @@ -5802,11 +5774,11 @@ const StatePortValue* get_state_port_values(const char* const state) LilvWorld* const w = W; - setenv("LILV_STATE_SKIP_PROPERTIES", "2", 1); + putenv("LILV_STATE_SKIP_PROPERTIES=2"); LilvState* const lstate = lilv_state_new_from_string(w, &uridMap, state); - unsetenv("LILV_STATE_SKIP_PROPERTIES"); + putenv("LILV_STATE_SKIP_PROPERTIES="); if (lstate != nullptr) {