diff mbox series

[05/10] meson: compile bundled device trees

Message ID 20230829082931.67601-6-pbonzini@redhat.com
State New
Headers show
Series configure cleanups for QEMU 8.2 | expand

Commit Message

Paolo Bonzini Aug. 29, 2023, 8:29 a.m. UTC
If dtc is available, compile the .dts files in the pc-bios directory
instead of using the precompiled binaries.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 pc-bios/Makefile    | 19 -------------------
 pc-bios/meson.build | 25 +++++++++++++++++++++----
 2 files changed, 21 insertions(+), 23 deletions(-)
 delete mode 100644 pc-bios/Makefile

Comments

Philippe Mathieu-Daudé Aug. 29, 2023, 2:25 p.m. UTC | #1
On 29/8/23 10:29, Paolo Bonzini wrote:
> If dtc is available, compile the .dts files in the pc-bios directory
> instead of using the precompiled binaries.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   pc-bios/Makefile    | 19 -------------------
>   pc-bios/meson.build | 25 +++++++++++++++++++++----
>   2 files changed, 21 insertions(+), 23 deletions(-)
>   delete mode 100644 pc-bios/Makefile


> +dtc = find_program('dtc', required: false)
> +foreach f : [
> +  'bamboo.dts',
> +  'canyonlands.dts',
> +  'petalogix-s3adsp1800.dts',
> +  'petalogix-ml605.dts',
> +]
> +  out = fs.replace_suffix(f, '.dtb')

Does that work when building from read-only source directory?

> +  if dtc.found()
> +    custom_target(f,
> +        build_by_default: have_system,
> +        input: files(f),
> +        output: out,
> +        install: get_option('install_blobs'),
> +        install_dir: qemu_datadir,
> +        command: [ dtc, '-I', 'dts', '-O', 'dtb', '-o', '@OUTPUT@', '@INPUT0@' ])
> +  else
> +    blobs += out
> +  endif
> +endforeach
> +
>   if get_option('install_blobs')
>     install_data(blobs, install_dir: qemu_datadir)
>   endif
Richard Henderson Aug. 29, 2023, 6:47 p.m. UTC | #2
On 8/29/23 01:29, Paolo Bonzini wrote:
> If dtc is available, compile the .dts files in the pc-bios directory
> instead of using the precompiled binaries.
> 
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> ---
>   pc-bios/Makefile    | 19 -------------------
>   pc-bios/meson.build | 25 +++++++++++++++++++++----
>   2 files changed, 21 insertions(+), 23 deletions(-)
>   delete mode 100644 pc-bios/Makefile

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Richard Henderson Aug. 29, 2023, 6:48 p.m. UTC | #3
On 8/29/23 07:25, Philippe Mathieu-Daudé wrote:
> On 29/8/23 10:29, Paolo Bonzini wrote:
>> If dtc is available, compile the .dts files in the pc-bios directory
>> instead of using the precompiled binaries.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>   pc-bios/Makefile    | 19 -------------------
>>   pc-bios/meson.build | 25 +++++++++++++++++++++----
>>   2 files changed, 21 insertions(+), 23 deletions(-)
>>   delete mode 100644 pc-bios/Makefile
> 
> 
>> +dtc = find_program('dtc', required: false)
>> +foreach f : [
>> +  'bamboo.dts',
>> +  'canyonlands.dts',
>> +  'petalogix-s3adsp1800.dts',
>> +  'petalogix-ml605.dts',
>> +]
>> +  out = fs.replace_suffix(f, '.dtb')
> 
> Does that work when building from read-only source directory?
> 
>> +  if dtc.found()
>> +    custom_target(f,
>> +        build_by_default: have_system,
>> +        input: files(f),
>> +        output: out,

Yes, because the output will be in the build directory, and installed from there,

>> +        install: get_option('install_blobs'),
>> +        install_dir: qemu_datadir,
>> +        command: [ dtc, '-I', 'dts', '-O', 'dtb', '-o', '@OUTPUT@', '@INPUT0@' ])
>> +  else
>> +    blobs += out

whereas the fallback case copies from the source directory.


r~

>> +  endif
>> +endforeach
>> +
>>   if get_option('install_blobs')
>>     install_data(blobs, install_dir: qemu_datadir)
>>   endif
> 
>
diff mbox series

Patch

diff --git a/pc-bios/Makefile b/pc-bios/Makefile
deleted file mode 100644
index 315288df84e..00000000000
--- a/pc-bios/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@ 
-#
-# NOTE: only compilable with x86 cross compile tools
-#
-include ../config-host.mak
-
-DEFINES=
-
-TARGETS=
-
-all: $(TARGETS)
-
-%.o: %.S
-	$(CC) $(DEFINES) -c -o $@ $<
-
-%.dtb: %.dts
-	dtc -I dts -O dtb -o $@ $<
-
-clean:
-	rm -f $(TARGETS) *.o *~
diff --git a/pc-bios/meson.build b/pc-bios/meson.build
index a7224ef4699..e67fa433a1b 100644
--- a/pc-bios/meson.build
+++ b/pc-bios/meson.build
@@ -57,10 +57,6 @@  blobs = [
   'efi-e1000e.rom',
   'efi-vmxnet3.rom',
   'qemu-nsis.bmp',
-  'bamboo.dtb',
-  'canyonlands.dtb',
-  'petalogix-s3adsp1800.dtb',
-  'petalogix-ml605.dtb',
   'multiboot.bin',
   'multiboot_dma.bin',
   'linuxboot.bin',
@@ -84,6 +80,27 @@  blobs = [
   'vof-nvram.bin',
 ]
 
+dtc = find_program('dtc', required: false)
+foreach f : [
+  'bamboo.dts',
+  'canyonlands.dts',
+  'petalogix-s3adsp1800.dts',
+  'petalogix-ml605.dts',
+]
+  out = fs.replace_suffix(f, '.dtb')
+  if dtc.found()
+    custom_target(f,
+        build_by_default: have_system,
+        input: files(f),
+        output: out,
+        install: get_option('install_blobs'),
+        install_dir: qemu_datadir,
+        command: [ dtc, '-I', 'dts', '-O', 'dtb', '-o', '@OUTPUT@', '@INPUT0@' ])
+  else
+    blobs += out
+  endif
+endforeach
+
 if get_option('install_blobs')
   install_data(blobs, install_dir: qemu_datadir)
 endif