Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## wscript
- import Configure, Options
- Configure.autoconfig = 1
- VERSION = '0'
- APPNAME = 'Synapse'
- srcdir = '.'
- blddir = '_build_'
- cflags = ['-Wall', '-Wextra']
- linkflags = []
- def set_options(opt):
- opt.add_option('--buildtype', action='store', default='debug', help='Select the type of build.')
- opt.add_option('--arch', action='store', default='x86', help='Select architecture to build for.')
- def configure(conf):
- arch = Options.options.arch
- buildtype = Options.options.buildtype
- # Check for required tools.
- conf.check_tool('gcc nasm')
- conf.env.append_unique('CCFLAGS', cflags)
- conf.env.append_unique('LINKFLAGS', linkflags)
- conf.env.append_unique('NASM_FLAGS', '-f elf')
- # Create the default environment based on the buildtype.
- env = conf.env.copy()
- conf.set_env_name(buildtype, env)
- conf.env.set_variant(arch + '-' + buildtype)
- if buildtype == 'debug':
- conf.env.append_unique('CCFLAGS', ['-g'])
- conf.env.append_unique('LINKFLAGS', ['-g'])
- # Create an environment for building the kernel.
- conf.setenv(buildtype)
- env = conf.env.copy()
- conf.set_env_name('kernel', env)
- conf.setenv('kernel')
- conf.env.append_unique('CCFLAGS', ['-m32', '-nostdlib', '-nodefaultlibs'])
- conf.env.append_unique('LINKFLAGS', ['-Wl,-melf_i386', '-nostartfiles', '-nostdlib', '-nodefaultlibs', '-T../src/kernel/link.ld'])
- def build(bld):
- bld.add_subdirs('src/kernel')
- def shutdown():
- pass
- ## src/kernel/wscript
- import Options
- import os
- def build(bld):
- # Find architecture-specific files.
- fd = os.popen('find src/kernel/arch/%s -name "*.S"' % Options.options.arch)
- archfiles = fd.readline().strip('\n')
- archfiles = archfiles.strip('src/kernel/')
- # Build the kernel.
- kernel = bld.new_task_gen('cc', 'cprogram')
- kernel.env = bld.env_of_name('kernel')
- kernel.source = 'main.c ' + archfiles
- kernel.target = 'kernel'
Add Comment
Please, Sign In to add comment