swig_lib.cpp 715 B

12345678910111213141516171819202122232425262728
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #define _STR(a) #a
  5. #define STR(a) _STR(a)
  6. static const char* ArcadiaRoot() {
  7. const char* root = getenv("ARCADIA_ROOT_DISTBUILD");
  8. return root ? root : STR(ARCADIA_ROOT);
  9. }
  10. #ifdef _MSC_VER
  11. static int setenv(const char* name, const char* value, int overwrite) {
  12. return (overwrite || !getenv(name)) ? _putenv_s(name, value) : 0;
  13. }
  14. #endif
  15. static void InitSwigLib() {
  16. const char* root = ArcadiaRoot();
  17. const char* lib = STR(SWIG_LIB_ARCPATH);
  18. char* s = new char[strlen(root) + 1 + strlen(lib) + 1];
  19. sprintf(s, "%s/%s", root, lib);
  20. setenv("SWIG_LIB", s, false);
  21. delete[] s;
  22. }
  23. static int initSwigLib = (InitSwigLib(), 0);