🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.4 KiB

  1. #
  2. # Native File Dialog
  3. #
  4. # Scons build script -- GCC, Clang, Visual Studio
  5. # Does not build test
  6. import os
  7. # target arch is build arch -- extend here for OS cross compiling
  8. target_os=str(Platform())
  9. # Corresponds to TARGET_ARCH set to environ.
  10. target_arch = ARGUMENTS.get('target_arch', None)
  11. # visual studio does not import from environment
  12. if target_os != 'win32':
  13. IMPORT_FROM_ENV =['CC', 'CXX', 'CFLAGS', 'CXXFLAGS', 'ARFLAGS']
  14. else:
  15. IMPORT_FROM_ENV =[]
  16. debug = int(ARGUMENTS.get( 'debug', 0 ))
  17. nfd_files = ['nfd_common.c']
  18. # Due to a Scons limitation, TARGET_ARCH cannot be appended to an existing environment.
  19. if target_arch != None:
  20. nfd_env = Environment( TARGET_ARCH=target_arch )
  21. else:
  22. nfd_env = Environment()
  23. # import specific environment variables from the command line, overriding
  24. # Scons environment defaults
  25. for env_key in IMPORT_FROM_ENV:
  26. if env_key in os.environ:
  27. print "Making %s => %s" % ( env_key, os.environ[env_key] )
  28. nfd_env[env_key] = os.environ[env_key]
  29. # Windows runtime library types
  30. win_rtl = {'debug': '/MDd',
  31. 'release': '/MD'}
  32. def set_debug(env):
  33. if target_os == 'win32':
  34. env.Append( CCFLAGS=['/Z7', # obj contains full symbols
  35. win_rtl['debug']
  36. ])
  37. else:
  38. env.Append( CFLAGS=['-g'] )
  39. def set_release(env):
  40. if target_os == 'win32':
  41. env.Append( CCFLAGS=[win_rtl['release'],
  42. '/O2'] )
  43. else:
  44. env.Append( CFLAGS=['-O3'] )
  45. def set_warnings(env):
  46. if target_os == 'win32':
  47. env.Append( CCFLAGS=['/W3'],
  48. CPPDEFINES=['_CRT_SECURE_NO_WARNINGS'] )
  49. else:
  50. env.Append( CFLAGS=['-Wall', '-pedantic'] )
  51. def get_lib_name(base, is_debug):
  52. if is_debug:
  53. return base + '_d'
  54. else:
  55. return base
  56. # Cocoa OS X builds - clang
  57. if target_os == 'darwin':
  58. nfd_files.append('nfd_cocoa.m')
  59. nfd_env.CC='clang -fcolor-diagnostics'
  60. # Linux GTK+ 3 builds - GCC
  61. elif target_os == 'posix':
  62. nfd_files.append('nfd_gtk.c')
  63. nfd_env.ParseConfig( 'pkg-config --cflags gtk+-3.0' )
  64. # Windows builds - Visual Studio
  65. elif target_os == 'win32':
  66. nfd_files.append('nfd_win.cpp')
  67. if debug:
  68. set_debug(nfd_env)
  69. else:
  70. set_release(nfd_env)
  71. set_warnings(nfd_env)
  72. nfd_env.Append( CPPPATH=['.','./include'] )
  73. nfd_env.StaticLibrary( get_lib_name('nfd', debug), nfd_files )