diff options
author | Jesse van den Kieboom <jessevdk@gmail.com> | 2014-01-04 14:51:52 +0100 |
---|---|---|
committer | Jesse van den Kieboom <jessevdk@gmail.com> | 2014-01-04 14:54:28 +0100 |
commit | 4eb9670fd04c457a00f76da42c7c51928cf63b91 (patch) | |
tree | 55a75831b10670bb14c574287f962dd933d91268 /compiler | |
parent | 23cc3054f8069da9679d50084be8262bc944c071 (diff) | |
download | vala-4eb9670fd04c457a00f76da42c7c51928cf63b91.tar.gz |
girwriter: Derive gir namespace from base name
Instead of using the full filename specified by --gir to derive the
gir namespace, this patch uses only the base name of the file specified by
--gir.
https://bugzilla.gnome.org/show_bug.cgi?id=721452
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/valacompiler.vala | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala index 8c7f507b3..16b55f22d 100644 --- a/compiler/valacompiler.vala +++ b/compiler/valacompiler.vala @@ -351,14 +351,15 @@ class Vala.Compiler { if (library != null) { if (gir != null) { - long gir_len = gir.length; - int last_hyphen = gir.last_index_of_char ('-'); + string gir_base = Path.get_basename(gir); + long gir_len = gir_base.length; + int last_hyphen = gir_base.last_index_of_char ('-'); - if (last_hyphen == -1 || !gir.has_suffix (".gir")) { + if (last_hyphen == -1 || !gir_base.has_suffix (".gir")) { Report.error (null, "GIR file name `%s' is not well-formed, expected NAME-VERSION.gir".printf (gir)); } else { - string gir_namespace = gir.substring (0, last_hyphen); - string gir_version = gir.substring (last_hyphen + 1, gir_len - last_hyphen - 5); + string gir_namespace = gir_base.substring (0, last_hyphen); + string gir_version = gir_base.substring (last_hyphen + 1, gir_len - last_hyphen - 5); gir_version.canon ("0123456789.", '?'); if (gir_namespace == "" || gir_version == "" || !gir_version[0].isdigit () || gir_version.contains ("?")) { Report.error (null, "GIR file name `%s' is not well-formed, expected NAME-VERSION.gir".printf (gir)); @@ -371,7 +372,7 @@ class Vala.Compiler { gir_directory = context.directory; } - gir_writer.write_file (context, gir_directory, gir_namespace, gir_version, library); + gir_writer.write_file (context, gir_directory, gir, gir_namespace, gir_version, library); } } |