Browse Source

Build standalone adapter directly from .cpp file instead of via .o

files. Add unicode wmain() wrapper for main() function on Windows.
tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
bab462bb4b
2 changed files with 19 additions and 6 deletions
  1. +4
    -5
      Makefile
  2. +15
    -1
      adapters/standalone.cpp

+ 4
- 5
Makefile View File

@@ -84,12 +84,11 @@ include compile.mk
ifdef ARCH_MAC
STANDALONE_LDFLAGS += $(MAC_SDK_FLAGS)
endif
STANDALONE_OBJECTS += $(patsubst %, build/%.o, $(STANDALONE_SOURCES))
STANDALONE_DEPENDENCIES := $(patsubst %, build/%.d, $(STANDALONE_SOURCES))
STANDALONE_OBJECTS += $(TARGET)
-include $(STANDALONE_DEPENDENCIES)

$(STANDALONE_TARGET): $(STANDALONE_OBJECTS) $(TARGET)
$(CXX) -o $@ $^ $(STANDALONE_LDFLAGS)
$(STANDALONE_TARGET): $(STANDALONE_OBJECTS) $(STANDALONE_SOURCES)
$(CXX) $(CXXFLAGS) -o $@ $^ $(STANDALONE_LDFLAGS)

# Convenience targets

@@ -131,7 +130,7 @@ valgrind: $(STANDALONE_TARGET)
valgrind --suppressions=valgrind.supp ./$< -d

clean:
rm -rfv $(TARGET) $(STANDALONE_TARGET) libRack.dll.a Rack.res build dist
rm -rfv $(TARGET) $(STANDALONE_TARGET) libRack.dll.a Rack.res build dist *.d


# For Windows resources


+ 15
- 1
adapters/standalone.cpp View File

@@ -56,7 +56,6 @@ static void fatalSignalHandler(int sig) {
}


// TODO Use -municode on Windows and change this to wmain. Convert argv to UTF-8.
int main(int argc, char* argv[]) {
#if defined ARCH_WIN
// Windows global mutex to prevent multiple instances
@@ -258,3 +257,18 @@ int main(int argc, char* argv[]) {

return 0;
}


#ifdef UNICODE
/** UTF-16 to UTF-8 wrapper for Windows with unicode */
int wmain(int argc, wchar_t* argvU16[]) {
// Initialize char* array with string-owned buffers
std::string argvStr[argc];
const char* argvU8[argc];
for (int i = 0; i < argc; i++) {
argvStr[i] = string::UTF16toUTF8(argvU16[i]);
argvU8[i] = argvStr[i].c_str();
}
return main(argc, (char**) argvU8);
}
#endif

Loading…
Cancel
Save