diff mbox series

[2/2] meson: use subproject for keycodemapdb

Message ID 20230518124645.1011316-3-pbonzini@redhat.com
State New
Headers show
Series meson: use subprojects for bundled projects | expand

Commit Message

Paolo Bonzini May 18, 2023, 12:46 p.m. UTC
By using a subproject, our own meson.build can use variables from
the subproject instead of hard-coded paths.  In the future, it may
also be possible to use wrap to download the submodule.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 .gitmodules                      | 4 ++--
 configure                        | 4 ++--
 scripts/archive-source.sh        | 2 +-
 {ui => subprojects}/keycodemapdb | 0
 ui/meson.build                   | 6 ++++--
 5 files changed, 9 insertions(+), 7 deletions(-)
 rename {ui => subprojects}/keycodemapdb (100%)

Comments

Daniel P. Berrangé May 18, 2023, 12:55 p.m. UTC | #1
On Thu, May 18, 2023 at 02:46:45PM +0200, Paolo Bonzini wrote:
> By using a subproject, our own meson.build can use variables from
> the subproject instead of hard-coded paths.  In the future, it may
> also be possible to use wrap to download the submodule.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  .gitmodules                      | 4 ++--
>  configure                        | 4 ++--
>  scripts/archive-source.sh        | 2 +-
>  {ui => subprojects}/keycodemapdb | 0
>  ui/meson.build                   | 6 ++++--
>  5 files changed, 9 insertions(+), 7 deletions(-)
>  rename {ui => subprojects}/keycodemapdb (100%)
> 
> diff --git a/.gitmodules b/.gitmodules
> index 3ed5d073d630..f8b2ddf3877c 100644
> --- a/.gitmodules
> +++ b/.gitmodules
> @@ -25,8 +25,8 @@
>  [submodule "roms/QemuMacDrivers"]
>  	path = roms/QemuMacDrivers
>  	url = https://gitlab.com/qemu-project/QemuMacDrivers.git
> -[submodule "ui/keycodemapdb"]
> -	path = ui/keycodemapdb
> +[submodule "subprojects/keycodemapdb"]
> +	path = subprojects/keycodemapdb
>  	url = https://gitlab.com/qemu-project/keycodemapdb.git
>  [submodule "roms/seabios-hppa"]
>  	path = roms/seabios-hppa
> diff --git a/configure b/configure
> index 5bbca83d9a31..2b6995e16756 100755
> --- a/configure
> +++ b/configure
> @@ -254,7 +254,7 @@ else
>      git_submodules_action="ignore"
>  fi
>  
> -git_submodules="ui/keycodemapdb"
> +git_submodules="subprojects/keycodemapdb"
>  git="git"
>  debug_tcg="no"
>  docs="auto"
> @@ -806,7 +806,7 @@ case $git_submodules_action in
>          fi
>      ;;
>      ignore)
> -        if ! test -f "$source_path/ui/keycodemapdb/README"
> +        if ! test -f "$source_path/subprojects/keycodemapdb/README"
>          then
>              echo
>              echo "ERROR: missing GIT submodules"
> diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh
> index b15f6fe6b8fe..a0a3153faa99 100755
> --- a/scripts/archive-source.sh
> +++ b/scripts/archive-source.sh
> @@ -26,7 +26,7 @@ sub_file="${sub_tdir}/submodule.tar"
>  # independent of what the developer currently has initialized
>  # in their checkout, because the build environment is completely
>  # different to the host OS.
> -submodules="subprojects/dtc meson ui/keycodemapdb"
> +submodules="subprojects/dtc meson subprojects/keycodemapdb"
>  submodules="$submodules tests/fp/berkeley-softfloat-3 tests/fp/berkeley-testfloat-3"
>  sub_deinit=""
>  
> diff --git a/ui/keycodemapdb b/subprojects/keycodemapdb
> similarity index 100%
> rename from ui/keycodemapdb
> rename to subprojects/keycodemapdb
> diff --git a/ui/meson.build b/ui/meson.build
> index 330369707dd7..e24d52b89941 100644
> --- a/ui/meson.build
> +++ b/ui/meson.build
> @@ -162,13 +162,15 @@ keymaps = [
>  ]
>  
>  if have_system or xkbcommon.found()
> +  keycodemapdb_proj = subproject('keycodemapdb', required: true)
> +  keymap_gen = find_program('keymap-gen', required: true)

This variable isn't used, is it ?

>    foreach e : keymaps
>      output = 'input-keymap-@0@-to-@1@.c.inc'.format(e[0], e[1])
>      genh += custom_target(output,
>                    output: output,
>                    capture: true,
> -                  input: files('keycodemapdb/data/keymaps.csv'),
> -                  command: [python, files('keycodemapdb/tools/keymap-gen'),
> +                  input: keycodemapdb_proj.get_variable('keymaps_csv'),
> +                  command: [python, keycodemapdb_proj.get_variable('keymap_gen'),
>                              'code-map',
>                              '--lang', 'glib2',
>                              '--varname', 'qemu_input_map_@0@_to_@1@'.format(e[0], e[1]),


With regards,
Daniel
Paolo Bonzini May 18, 2023, 1 p.m. UTC | #2
On 5/18/23 14:55, Daniel P. Berrangé wrote:
> On Thu, May 18, 2023 at 02:46:45PM +0200, Paolo Bonzini wrote:
>> By using a subproject, our own meson.build can use variables from
>> the subproject instead of hard-coded paths.  In the future, it may
>> also be possible to use wrap to download the submodule.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>   .gitmodules                      | 4 ++--
>>   configure                        | 4 ++--
>>   scripts/archive-source.sh        | 2 +-
>>   {ui => subprojects}/keycodemapdb | 0
>>   ui/meson.build                   | 6 ++++--
>>   5 files changed, 9 insertions(+), 7 deletions(-)
>>   rename {ui => subprojects}/keycodemapdb (100%)
>>
>> diff --git a/.gitmodules b/.gitmodules
>> index 3ed5d073d630..f8b2ddf3877c 100644
>> --- a/.gitmodules
>> +++ b/.gitmodules
>> @@ -25,8 +25,8 @@
>>   [submodule "roms/QemuMacDrivers"]
>>   	path = roms/QemuMacDrivers
>>   	url = https://gitlab.com/qemu-project/QemuMacDrivers.git
>> -[submodule "ui/keycodemapdb"]
>> -	path = ui/keycodemapdb
>> +[submodule "subprojects/keycodemapdb"]
>> +	path = subprojects/keycodemapdb
>>   	url = https://gitlab.com/qemu-project/keycodemapdb.git
>>   [submodule "roms/seabios-hppa"]
>>   	path = roms/seabios-hppa
>> diff --git a/configure b/configure
>> index 5bbca83d9a31..2b6995e16756 100755
>> --- a/configure
>> +++ b/configure
>> @@ -254,7 +254,7 @@ else
>>       git_submodules_action="ignore"
>>   fi
>>   
>> -git_submodules="ui/keycodemapdb"
>> +git_submodules="subprojects/keycodemapdb"
>>   git="git"
>>   debug_tcg="no"
>>   docs="auto"
>> @@ -806,7 +806,7 @@ case $git_submodules_action in
>>           fi
>>       ;;
>>       ignore)
>> -        if ! test -f "$source_path/ui/keycodemapdb/README"
>> +        if ! test -f "$source_path/subprojects/keycodemapdb/README"
>>           then
>>               echo
>>               echo "ERROR: missing GIT submodules"
>> diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh
>> index b15f6fe6b8fe..a0a3153faa99 100755
>> --- a/scripts/archive-source.sh
>> +++ b/scripts/archive-source.sh
>> @@ -26,7 +26,7 @@ sub_file="${sub_tdir}/submodule.tar"
>>   # independent of what the developer currently has initialized
>>   # in their checkout, because the build environment is completely
>>   # different to the host OS.
>> -submodules="subprojects/dtc meson ui/keycodemapdb"
>> +submodules="subprojects/dtc meson subprojects/keycodemapdb"
>>   submodules="$submodules tests/fp/berkeley-softfloat-3 tests/fp/berkeley-testfloat-3"
>>   sub_deinit=""
>>   
>> diff --git a/ui/keycodemapdb b/subprojects/keycodemapdb
>> similarity index 100%
>> rename from ui/keycodemapdb
>> rename to subprojects/keycodemapdb
>> diff --git a/ui/meson.build b/ui/meson.build
>> index 330369707dd7..e24d52b89941 100644
>> --- a/ui/meson.build
>> +++ b/ui/meson.build
>> @@ -162,13 +162,15 @@ keymaps = [
>>   ]
>>   
>>   if have_system or xkbcommon.found()
>> +  keycodemapdb_proj = subproject('keycodemapdb', required: true)
>> +  keymap_gen = find_program('keymap-gen', required: true)
> 
> This variable isn't used, is it ?

Hmm, no it isn't.  Do you prefer the code below and removing the 
assignment, or

     command: [python, keymap_gen.full_path(),

?  find_program is nicer, but you have to peek with 
keycodemap_proj.get_variable() anyway to reach the CSV file, so...

Paolo

>>     foreach e : keymaps
>>       output = 'input-keymap-@0@-to-@1@.c.inc'.format(e[0], e[1])
>>       genh += custom_target(output,
>>                     output: output,
>>                     capture: true,
>> -                  input: files('keycodemapdb/data/keymaps.csv'),
>> -                  command: [python, files('keycodemapdb/tools/keymap-gen'),
>> +                  input: keycodemapdb_proj.get_variable('keymaps_csv'),
>> +                  command: [python, keycodemapdb_proj.get_variable('keymap_gen'),
>>                               'code-map',
>>                               '--lang', 'glib2',
>>                               '--varname', 'qemu_input_map_@0@_to_@1@'.format(e[0], e[1]),
> 
> 
> With regards,
> Daniel
Daniel P. Berrangé May 18, 2023, 2:01 p.m. UTC | #3
On Thu, May 18, 2023 at 03:00:44PM +0200, Paolo Bonzini wrote:
> On 5/18/23 14:55, Daniel P. Berrangé wrote:
> > On Thu, May 18, 2023 at 02:46:45PM +0200, Paolo Bonzini wrote:
> > > By using a subproject, our own meson.build can use variables from
> > > the subproject instead of hard-coded paths.  In the future, it may
> > > also be possible to use wrap to download the submodule.
> > > 
> > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > > ---
> > >   .gitmodules                      | 4 ++--
> > >   configure                        | 4 ++--
> > >   scripts/archive-source.sh        | 2 +-
> > >   {ui => subprojects}/keycodemapdb | 0
> > >   ui/meson.build                   | 6 ++++--
> > >   5 files changed, 9 insertions(+), 7 deletions(-)
> > >   rename {ui => subprojects}/keycodemapdb (100%)
> > > 
> > > diff --git a/.gitmodules b/.gitmodules
> > > index 3ed5d073d630..f8b2ddf3877c 100644
> > > --- a/.gitmodules
> > > +++ b/.gitmodules
> > > @@ -25,8 +25,8 @@
> > >   [submodule "roms/QemuMacDrivers"]
> > >   	path = roms/QemuMacDrivers
> > >   	url = https://gitlab.com/qemu-project/QemuMacDrivers.git
> > > -[submodule "ui/keycodemapdb"]
> > > -	path = ui/keycodemapdb
> > > +[submodule "subprojects/keycodemapdb"]
> > > +	path = subprojects/keycodemapdb
> > >   	url = https://gitlab.com/qemu-project/keycodemapdb.git
> > >   [submodule "roms/seabios-hppa"]
> > >   	path = roms/seabios-hppa
> > > diff --git a/configure b/configure
> > > index 5bbca83d9a31..2b6995e16756 100755
> > > --- a/configure
> > > +++ b/configure
> > > @@ -254,7 +254,7 @@ else
> > >       git_submodules_action="ignore"
> > >   fi
> > > -git_submodules="ui/keycodemapdb"
> > > +git_submodules="subprojects/keycodemapdb"
> > >   git="git"
> > >   debug_tcg="no"
> > >   docs="auto"
> > > @@ -806,7 +806,7 @@ case $git_submodules_action in
> > >           fi
> > >       ;;
> > >       ignore)
> > > -        if ! test -f "$source_path/ui/keycodemapdb/README"
> > > +        if ! test -f "$source_path/subprojects/keycodemapdb/README"
> > >           then
> > >               echo
> > >               echo "ERROR: missing GIT submodules"
> > > diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh
> > > index b15f6fe6b8fe..a0a3153faa99 100755
> > > --- a/scripts/archive-source.sh
> > > +++ b/scripts/archive-source.sh
> > > @@ -26,7 +26,7 @@ sub_file="${sub_tdir}/submodule.tar"
> > >   # independent of what the developer currently has initialized
> > >   # in their checkout, because the build environment is completely
> > >   # different to the host OS.
> > > -submodules="subprojects/dtc meson ui/keycodemapdb"
> > > +submodules="subprojects/dtc meson subprojects/keycodemapdb"
> > >   submodules="$submodules tests/fp/berkeley-softfloat-3 tests/fp/berkeley-testfloat-3"
> > >   sub_deinit=""
> > > diff --git a/ui/keycodemapdb b/subprojects/keycodemapdb
> > > similarity index 100%
> > > rename from ui/keycodemapdb
> > > rename to subprojects/keycodemapdb
> > > diff --git a/ui/meson.build b/ui/meson.build
> > > index 330369707dd7..e24d52b89941 100644
> > > --- a/ui/meson.build
> > > +++ b/ui/meson.build
> > > @@ -162,13 +162,15 @@ keymaps = [
> > >   ]
> > >   if have_system or xkbcommon.found()
> > > +  keycodemapdb_proj = subproject('keycodemapdb', required: true)
> > > +  keymap_gen = find_program('keymap-gen', required: true)
> > 
> > This variable isn't used, is it ?
> 
> Hmm, no it isn't.  Do you prefer the code below and removing the assignment,
> or
> 
>     command: [python, keymap_gen.full_path(),
> 
> ?  find_program is nicer, but you have to peek with
> keycodemap_proj.get_variable() anyway to reach the CSV file, so...

I'm pretty ambivalent. If there's no functional reason to use
find_program, I guest we might as well stick with get_variable for
parity with the CSV file


With regards,
Daniel
diff mbox series

Patch

diff --git a/.gitmodules b/.gitmodules
index 3ed5d073d630..f8b2ddf3877c 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -25,8 +25,8 @@ 
 [submodule "roms/QemuMacDrivers"]
 	path = roms/QemuMacDrivers
 	url = https://gitlab.com/qemu-project/QemuMacDrivers.git
-[submodule "ui/keycodemapdb"]
-	path = ui/keycodemapdb
+[submodule "subprojects/keycodemapdb"]
+	path = subprojects/keycodemapdb
 	url = https://gitlab.com/qemu-project/keycodemapdb.git
 [submodule "roms/seabios-hppa"]
 	path = roms/seabios-hppa
diff --git a/configure b/configure
index 5bbca83d9a31..2b6995e16756 100755
--- a/configure
+++ b/configure
@@ -254,7 +254,7 @@  else
     git_submodules_action="ignore"
 fi
 
-git_submodules="ui/keycodemapdb"
+git_submodules="subprojects/keycodemapdb"
 git="git"
 debug_tcg="no"
 docs="auto"
@@ -806,7 +806,7 @@  case $git_submodules_action in
         fi
     ;;
     ignore)
-        if ! test -f "$source_path/ui/keycodemapdb/README"
+        if ! test -f "$source_path/subprojects/keycodemapdb/README"
         then
             echo
             echo "ERROR: missing GIT submodules"
diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh
index b15f6fe6b8fe..a0a3153faa99 100755
--- a/scripts/archive-source.sh
+++ b/scripts/archive-source.sh
@@ -26,7 +26,7 @@  sub_file="${sub_tdir}/submodule.tar"
 # independent of what the developer currently has initialized
 # in their checkout, because the build environment is completely
 # different to the host OS.
-submodules="subprojects/dtc meson ui/keycodemapdb"
+submodules="subprojects/dtc meson subprojects/keycodemapdb"
 submodules="$submodules tests/fp/berkeley-softfloat-3 tests/fp/berkeley-testfloat-3"
 sub_deinit=""
 
diff --git a/ui/keycodemapdb b/subprojects/keycodemapdb
similarity index 100%
rename from ui/keycodemapdb
rename to subprojects/keycodemapdb
diff --git a/ui/meson.build b/ui/meson.build
index 330369707dd7..e24d52b89941 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -162,13 +162,15 @@  keymaps = [
 ]
 
 if have_system or xkbcommon.found()
+  keycodemapdb_proj = subproject('keycodemapdb', required: true)
+  keymap_gen = find_program('keymap-gen', required: true)
   foreach e : keymaps
     output = 'input-keymap-@0@-to-@1@.c.inc'.format(e[0], e[1])
     genh += custom_target(output,
                   output: output,
                   capture: true,
-                  input: files('keycodemapdb/data/keymaps.csv'),
-                  command: [python, files('keycodemapdb/tools/keymap-gen'),
+                  input: keycodemapdb_proj.get_variable('keymaps_csv'),
+                  command: [python, keycodemapdb_proj.get_variable('keymap_gen'),
                             'code-map',
                             '--lang', 'glib2',
                             '--varname', 'qemu_input_map_@0@_to_@1@'.format(e[0], e[1]),