|
| 1 | +project( |
| 2 | + 'libromfs', |
| 3 | + 'c', |
| 4 | + version: '0.7.0', |
| 5 | + meson_version: '>=1.2.0', |
| 6 | + default_options: { |
| 7 | + 'c_std': ['c11'], |
| 8 | + }, |
| 9 | +) |
| 10 | + |
| 11 | +deps = [] |
| 12 | + |
| 13 | + |
| 14 | +if meson.is_cross_build() |
| 15 | + if host_machine.system() == 'wiiu' |
| 16 | + |
| 17 | + object_target = 'elf32-powerpc' |
| 18 | + binary_arch = 'powerpc:common' |
| 19 | + ## deps +='wut' |
| 20 | + |
| 21 | + elif host_machine.system() == 'wii' |
| 22 | + |
| 23 | + object_target = 'elf32-powerpc' |
| 24 | + binary_arch = 'powerpc:common' |
| 25 | + |
| 26 | + else |
| 27 | + error('not supported platform: ' + host_machine.system()) |
| 28 | + endif |
| 29 | +else |
| 30 | + error('only cross build is supported') |
| 31 | +endif |
| 32 | + |
| 33 | +romfs_dir = get_option('romfs_dir') |
| 34 | + |
| 35 | +if romfs_dir == '' |
| 36 | + error('\'romfs_dir\' option is required') |
| 37 | +endif |
| 38 | + |
| 39 | +fs = import('fs') |
| 40 | + |
| 41 | +if not fs.exists(romfs_dir) |
| 42 | + error('\'romfs_dir\' should exist, but doesn\'t: \'' + romfs_dir + '\'') |
| 43 | +endif |
| 44 | + |
| 45 | +tar = find_program('tar', native: true) |
| 46 | + |
| 47 | +objcopy = find_program('objcopy', native: false) |
| 48 | + |
| 49 | +romfs_tar_name = 'romfs.tar' |
| 50 | +romfs_obj_name = 'romfs.o' |
| 51 | + |
| 52 | + |
| 53 | +romfs_tar = custom_target( |
| 54 | + romfs_tar_name, |
| 55 | + command: [ |
| 56 | + tar, |
| 57 | + '--format', 'ustar', |
| 58 | + '-cvf', '@OUTPUT@', |
| 59 | + '-C', romfs_dir, |
| 60 | + '.', |
| 61 | + ], |
| 62 | + output: [romfs_tar_name], |
| 63 | +) |
| 64 | + |
| 65 | +romfs_object = custom_target( |
| 66 | + romfs_obj_name, |
| 67 | + command: [ |
| 68 | + objcopy, |
| 69 | + '--input-target', 'binary', |
| 70 | + '--output-target', object_target, |
| 71 | + '--binary-architecture', binary_arch, |
| 72 | + '@INPUT@', |
| 73 | + '@OUTPUT@', |
| 74 | + ], |
| 75 | + input: romfs_tar, |
| 76 | + output: [romfs_obj_name], |
| 77 | +) |
| 78 | + |
| 79 | +inc_dirs = include_directories('include') |
| 80 | + |
| 81 | +libromfs_lib = library( |
| 82 | + 'libromfs', |
| 83 | + files('source/romfs.c'), |
| 84 | + include_directories: inc_dirs, |
| 85 | + dependencies: deps, |
| 86 | + install: true, |
| 87 | + objects: romfs_object, |
| 88 | +) |
| 89 | + |
| 90 | +libromfs_dep = declare_dependency( |
| 91 | + include_directories: inc_dirs, |
| 92 | + version: meson.project_version(), |
| 93 | + link_with: libromfs_lib, |
| 94 | +) |
0 commit comments