[msitools: 1/2] Add sys.BUILDARCH preprocessor variable.
- From: Marc-André Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [msitools: 1/2] Add sys.BUILDARCH preprocessor variable.
- Date: Mon, 15 Nov 2021 07:33:54 +0000 (UTC)
commit 8ad533b9e03b7deed1c4fa246b72637d1e2288b9
Author: roblabla <unfiltered roblab la>
Date: Fri Nov 12 23:09:19 2021 +0100
Add sys.BUILDARCH preprocessor variable.
This variable can be used to know which target we are currently building
against (as set by the --arch argument).
tools/wixl/builder.vala | 11 ++++++++++-
tools/wixl/preprocessor.vala | 6 +++++-
2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/tools/wixl/builder.vala b/tools/wixl/builder.vala
index 319006d..3a403c5 100644
--- a/tools/wixl/builder.vala
+++ b/tools/wixl/builder.vala
@@ -10,6 +10,15 @@ namespace Wixl {
public static Arch from_string(string s) throws GLib.Error {
return enum_from_string<Arch> (s);
}
+
+ public string to_string() {
+ switch (this) {
+ case X86: return "x86";
+ case IA64: return "ia64";
+ case X64: return "x64";
+ default: return "";
+ }
+ }
}
enum Extension {
@@ -124,7 +133,7 @@ namespace Wixl {
string data;
FileUtils.get_contents (file.get_path (), out data);
- var p = new Preprocessor (variables, includedirs);
+ var p = new Preprocessor (variables, includedirs, arch);
var doc = p.preprocess (data, file);
if (preproc_only) {
doc.dump_format (FileStream.fdopen (1, "w"));
diff --git a/tools/wixl/preprocessor.vala b/tools/wixl/preprocessor.vala
index 81e90c4..1769d3c 100644
--- a/tools/wixl/preprocessor.vala
+++ b/tools/wixl/preprocessor.vala
@@ -4,17 +4,19 @@ namespace Wixl {
unowned List<File> includedirs;
HashTable<string, string> variables;
+ Arch arch;
construct {
variables = new HashTable<string, string> (str_hash, str_equal);
}
- public Preprocessor (HashTable<string, string> globals, List<File> includedirs) {
+ public Preprocessor (HashTable<string, string> globals, List<File> includedirs, Arch arch) {
string name, value;
var it = HashTableIter <string, string> (globals);
while (it.next (out name, out value))
define_variable (name, value);
this.includedirs = includedirs;
+ this.arch = arch;
}
public void define_variable (string name, string value) {
@@ -47,6 +49,8 @@ namespace Wixl {
return file.get_basename ();
case "SOURCEFILEPATH":
return file.get_path ();
+ case "BUILDARCH":
+ return arch.to_string();
}
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]