mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
add shell script to automate generation of ports/cef/interfaces/mod.rs
This commit is contained in:
parent
c2ed3b258f
commit
ad91db7224
1 changed files with 33 additions and 0 deletions
33
ports/cef/regen_interface_mod_rs.sh
Normal file
33
ports/cef/regen_interface_mod_rs.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/zsh
|
||||
|
||||
# loop all files in interfaces dir
|
||||
for x in interfaces/^*mod.rs
|
||||
do
|
||||
# open the use statement
|
||||
echo -n "pub use interfaces::$(basename $x .rs)::{" >>| interfaces_mod.rs
|
||||
# append all pub struct names which do not begin with '_'
|
||||
grep -E '^pub struct [^_]' $x|sed 's/.*struct \(.*\) .*/\1/'|tr '\n' ',' >>| interfaces_mod.rs
|
||||
# append all pub types
|
||||
grep -E '^pub type ' $x|sed 's/pub type \([^ ]*\) .*/\1/'|tr '\n' ',' >>| interfaces_mod.rs
|
||||
# close the use statement
|
||||
echo '};' >>| interfaces_mod.rs
|
||||
done
|
||||
# open use statement for manually-generated types.rs
|
||||
echo -n "pub use types::{" >>| interfaces_mod.rs
|
||||
# append all pub types
|
||||
grep -E '^pub type ' types.rs|sed 's/pub type \([^ ]*\) .*/\1/'|uniq|tr '\n' ',' >>| interfaces_mod.rs
|
||||
# append all pub enums
|
||||
grep -E '^pub enum ' types.rs|sed 's/pub enum \([^ ]*\) .*/\1/'|uniq|tr '\n' ',' >>| interfaces_mod.rs
|
||||
# close use statement
|
||||
echo '};' >>| interfaces_mod.rs
|
||||
# append all pub structs beginning with "Cef" to alias them from types:: -> interfaces::
|
||||
# some generated code from cef uses interfaces:: for types that it does not generate
|
||||
grep -E '^pub struct Cef' types.rs|sed 's/pub struct \([^ ]*\) .*/pub use types::\1 as \1;/'|uniq >>| interfaces_mod.rs
|
||||
# newline separators
|
||||
echo -e '\n\n' >>| interfaces_mod.rs
|
||||
# loop all files in interfaces dir again
|
||||
for x in interfaces/^*mod.rs
|
||||
do
|
||||
# add mod statements for all interfaces
|
||||
echo "pub mod $(basename $x .rs);" >>| interfaces_mod.rs
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue