Changeset 98975a8 in mainline for boot/meson.build
- Timestamp:
- 2019-08-17T12:49:43Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5b586b9
- Parents:
- 643640a
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-06-28 16:06:30)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-08-17 12:49:43)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/meson.build
r643640a r98975a8 1 subdir('arch' / BARCH) 1 2 2 subdir('arch' / BARCH) 3 if BUILD 4 # Order matters. 5 modules = [ 'boot/kernel.elf' ] + rd_init + [ 'boot/initrd.img' ] 6 moddeps = [] 7 name_transform = '' 8 9 # Collect binary references in the correct order. 10 foreach m : modules 11 found = false 12 foreach bin : rd_init_binaries 13 if bin[1] == m 14 moddeps += bin[0] 15 found = true 16 17 _oldname = run_command(basename, bin[0].full_path(), check: true).stdout().strip() 18 _newname = run_command(basename, bin[1], check: true).stdout().strip() 19 20 name_transform += 's:.*/@0@:@1@:;'.format(_oldname, _newname) 21 break 22 endif 23 endforeach 24 25 if not found 26 error('Could not find dependency ' + m) 27 endif 28 endforeach 29 30 31 boot_include_dirs = include_directories( 32 'generic/include', 33 'arch'/BARCH/'include', 34 'genarch/include', 35 '../abi/arch'/BARCH/'include', 36 '../abi/include', 37 ) 38 39 boot_defs = [ 40 '-imacros', meson.source_root() / 'config.h', 41 '-D_HELENOS_SOURCE', 42 '-DBOOT', 43 '-DRELEASE=' + HELENOS_RELEASE, 44 '-DCOPYRIGHT=' + HELENOS_COPYRIGHT, 45 '-DNAME=' + HELENOS_NAME, 46 '-D__@0@_BITS__'.format(meson.get_cross_property('bits')), 47 ] 48 49 boot_c_args = arch_boot_c_args + boot_defs + [ 50 '-ffreestanding', 51 ] 52 53 boot_link_args = arch_boot_link_args + [ 54 '-nostdlib', 55 '-Wl,--nmagic', 56 '-T', meson.current_build_dir()/'_link.ld', 57 '-Wl,--no-gc-sections', 58 ] 59 60 if cc.get_id() == 'clang' 61 boot_c_args += [ 62 '-fno-stack-protector', 63 '-fno-PIC', 64 # '-mllvm', '-asm-macro-max-nesting-depth=1000', 65 ] 66 endif 67 68 # Preprocess linker script using C preprocessor. 69 boot_ldscript = custom_target('_link.ld', 70 input: 'arch'/KARCH/'_link.ld.in', 71 output: '_link.ld', 72 command: [ 73 cc.cmd_array(), 74 boot_c_args, 75 '-I' + meson.current_source_dir()/'arch'/KARCH/'include', 76 '-D__ASSEMBLER__', 77 '-D__LINKER__', 78 '-E', 79 '-P', 80 '-x', 'c', 81 '@INPUT@', 82 ], 83 capture: true, 84 ) 85 86 # Create empty object file. 87 boot_empty_o = custom_target('empty.o', 88 output: 'empty.o', 89 command: [ 90 cc.cmd_array(), 91 boot_c_args, 92 '-x', 'c', 93 '-c', 94 '-o', '@OUTPUT@', 95 '-', 96 ], 97 ) 98 99 boot_comps_tar = custom_target('components.tar', 100 input: moddeps, 101 output: 'components.tar', 102 command: [ tar, '--transform', name_transform ], 103 ) 104 105 # Add .payload section to the empty object. 106 boot_comps_o = custom_target('components.o', 107 output: 'components.o', 108 input: [ boot_comps_tar, boot_empty_o ], 109 command: [ 110 objcopy, 111 '--add-section', '.payload=@INPUT0@', 112 '@INPUT1@', 113 '@OUTPUT@', 114 ], 115 ) 116 117 boot_image_name = 'image.boot' 118 boot_image_map_path = meson.current_build_dir()/boot_image_name + '.map' 119 120 boot_elf = executable(boot_image_name + '.elf', boot_src, boot_comps_o, 121 include_directories: boot_include_dirs, 122 implicit_include_directories: false, 123 c_args: boot_c_args, 124 link_args: boot_c_args + boot_link_args + [ 125 '-Wl,-Map,' + boot_image_map_path, 126 ], 127 link_depends: boot_ldscript, 128 install: true, 129 install_dir: 'boot', 130 pie: false, 131 ) 132 133 if boot_image_format == 'elf' 134 boot_image = boot_elf 135 endif 136 137 if boot_image_format == 'binary' 138 # Some platforms can't ELF. 139 boot_image = custom_target(boot_image_name, 140 input: boot_elf, 141 output: boot_image_name, 142 command: [ objcopy, '-O', 'binary', '@INPUT@', '@OUTPUT@' ], 143 ) 144 endif 145 endif 146 147 if POSTBUILD == 'raw' 148 POST_INPUT = boot_image 149 endif 3 150 4 151 if POSTBUILD == 'grub' 5 152 subdir('grub') 6 153 endif 154 155 if POSTBUILD == 'uboot' 156 # TODO 157 error('unfinished') 158 endif 159 160
Note:
See TracChangeset
for help on using the changeset viewer.