Browse Source

Improve Meson + Cargo integration

Signed-off-by: main <magic_rb@redalder.org>
master
main 9 months ago
parent
commit
cee6c79eb2
Signed by: Magic_RB
GPG Key ID: 08D5287CC5DDCA0E
  1. 2
      i386-unknown-none.txt
  2. 44
      meson.build

2
i386-unknown-none.txt

@ -12,7 +12,7 @@ has_function_printf = false
[built-in options]
c_args = [ '-ffreestanding' ]
cpp_args = [ '-ffreestanding' ]
c_link_args = ['-ffreestanding', '-fno-pic', '-fno-pie', '-nostdlib', '--target=i386-unknown-none', '-march=i386' ]
c_link_args = ['-ffreestanding', '-fno-pic', '-fno-pie', '-nostdlib', '--target=i386-unknown-none' ]
rust_link_args = ['-ffreestanding', '-nostdlib' ]
cpp_link_args = ['-ffreestanding', '-nostdlib' ]

44
meson.build

@ -25,33 +25,37 @@ if get_option('release')
cargo_args += '--release'
endif
## Run `cargo build` to generate the Rust static library containing all the Rust stuff
cargo_result = run_command(
'sh'
, '-c'
, 'cd $MESON_SOURCE_ROOT ; ' + cargo.path() + ' build ' + ''.join(cargo_args) + ' --color always'
rust_lib = custom_target(
'x86os-rust'
, output: 'libx86os.a' # target/i386-unknown-none/debug/
, command:
[ cargo, 'build', '--color', 'always', '-Zunstable-options', '--out-dir', '@OUTDIR@' ] + cargo_args
, input:
[ 'Cargo.toml'
, 'Cargo.lock'
, 'src/gdt/access.rs'
, 'src/gdt/entry.rs'
, 'src/gdt/granularity.rs'
, 'src/gdt/mod.rs'
, 'src/idt/access.rs'
, 'src/idt/entry.rs'
, 'src/idt/mod.rs'
, 'src/rlibc/memory.rs'
, 'src/rlibc/mod.rs'
, 'src/screen/mod.rs'
, 'src/lib.rs'
, 'src/limited_pointer.rs'
, 'src/ring.rs'
]
)
cargo_stdout = cargo_result.stdout().strip()
cargo_stderr = cargo_result.stderr().strip()
if cargo_stderr != ''
message(cargo_stderr)
elif cargo_stdout != ''
message(cargo_stdout)
else
message('Cargo is done')
endif
if cargo_result.returncode() > 0
exit(1)
endif
#
kernel = executable(
'x86os'
, compiled_asm
, link_args: [ '-Wl,-T../ld/linker.ld', '-Wl,-melf_i386' ]
, objects: [ 'target/i386-unknown-none/debug/libx86os.a' ]
, link_depends: [ 'ld/linker.ld' ]
, link_with: [ rust_lib ]
, link_language: 'c'
)
# include_directories: 'src',
# link_depends: 'ld/linker.ld'

Loading…
Cancel
Save