Guest User

Untitled

a guest
Jun 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. ## wscript
  2. import Configure, Options
  3. Configure.autoconfig = 1
  4.  
  5. VERSION = '0'
  6. APPNAME = 'Synapse'
  7.  
  8. srcdir = '.'
  9. blddir = '_build_'
  10.  
  11. cflags = ['-Wall', '-Wextra']
  12. linkflags = []
  13.  
  14. def set_options(opt):
  15. opt.add_option('--buildtype', action='store', default='debug', help='Select the type of build.')
  16. opt.add_option('--arch', action='store', default='x86', help='Select architecture to build for.')
  17.  
  18. def configure(conf):
  19. arch = Options.options.arch
  20. buildtype = Options.options.buildtype
  21.  
  22. # Check for required tools.
  23. conf.check_tool('gcc nasm')
  24.  
  25. conf.env.append_unique('CCFLAGS', cflags)
  26. conf.env.append_unique('LINKFLAGS', linkflags)
  27. conf.env.append_unique('NASM_FLAGS', '-f elf')
  28.  
  29. # Create the default environment based on the buildtype.
  30. env = conf.env.copy()
  31. conf.set_env_name(buildtype, env)
  32. conf.env.set_variant(arch + '-' + buildtype)
  33. if buildtype == 'debug':
  34. conf.env.append_unique('CCFLAGS', ['-g'])
  35. conf.env.append_unique('LINKFLAGS', ['-g'])
  36.  
  37. # Create an environment for building the kernel.
  38. conf.setenv(buildtype)
  39. env = conf.env.copy()
  40. conf.set_env_name('kernel', env)
  41. conf.setenv('kernel')
  42. conf.env.append_unique('CCFLAGS', ['-m32', '-nostdlib', '-nodefaultlibs'])
  43. conf.env.append_unique('LINKFLAGS', ['-Wl,-melf_i386', '-nostartfiles', '-nostdlib', '-nodefaultlibs', '-T../src/kernel/link.ld'])
  44.  
  45. def build(bld):
  46. bld.add_subdirs('src/kernel')
  47.  
  48. def shutdown():
  49. pass
  50.  
  51. ## src/kernel/wscript
  52. import Options
  53. import os
  54.  
  55. def build(bld):
  56. # Find architecture-specific files.
  57. fd = os.popen('find src/kernel/arch/%s -name "*.S"' % Options.options.arch)
  58. archfiles = fd.readline().strip('\n')
  59. archfiles = archfiles.strip('src/kernel/')
  60.  
  61. # Build the kernel.
  62. kernel = bld.new_task_gen('cc', 'cprogram')
  63. kernel.env = bld.env_of_name('kernel')
  64. kernel.source = 'main.c ' + archfiles
  65. kernel.target = 'kernel'
Add Comment
Please, Sign In to add comment