SConstruct 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!python
  2. import os
  3. target = ARGUMENTS.get("target", "debug")
  4. platform = ARGUMENTS.get("platform", "windows")
  5. bits = ARGUMENTS.get("bits", 64)
  6. final_lib_path = 'demo/bin/'
  7. # This makes sure to keep the session environment variables on windows,
  8. # that way you can run scons in a vs 2017 prompt and it will find all the required tools
  9. env = Environment()
  10. if platform == "windows":
  11. env = Environment(ENV = os.environ)
  12. def add_sources(sources, directory):
  13. for file in os.listdir(directory):
  14. if file.endswith('.cpp'):
  15. sources.append(directory + '/' + file)
  16. if platform == "osx":
  17. env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64', '-std=c++14'])
  18. env.Append(LINKFLAGS = ['-arch', 'x86_64'])
  19. final_lib_path = final_lib_path + 'osx/'
  20. elif platform == "linux":
  21. env.Append(CCFLAGS = ['-fPIC', '-g','-O3', '-std=c++14'])
  22. final_lib_path = final_lib_path + 'x11/'
  23. elif platform == "windows":
  24. if target == "debug":
  25. env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '-MDd'])
  26. else:
  27. env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '-MD'])
  28. final_lib_path = final_lib_path + 'win' + str(bits) + '/'
  29. env.Append(CPPPATH=['.', 'src/', "godot-cpp/godot_headers/", 'godot-cpp/include/', 'godot-cpp/include/core/', 'godot-cpp/include/gen/'])
  30. env.Append(LIBPATH="godot-cpp/bin")
  31. env.Append(LIBS=["godot-cpp" + "." + platform + "." + str(bits)])
  32. sources = []
  33. add_sources(sources, "src")
  34. library = env.SharedLibrary(target=final_lib_path + 'libgdexample', source=sources)
  35. Default(library)