summaryrefslogtreecommitdiff
path: root/branding/scripts/generate-vendor-make
diff options
context:
space:
mode:
Diffstat (limited to 'branding/scripts/generate-vendor-make')
-rwxr-xr-xbranding/scripts/generate-vendor-make53
1 files changed, 53 insertions, 0 deletions
diff --git a/branding/scripts/generate-vendor-make b/branding/scripts/generate-vendor-make
new file mode 100755
index 0000000..60dc180
--- /dev/null
+++ b/branding/scripts/generate-vendor-make
@@ -0,0 +1,53 @@
+#!/usr/bin/env python3
+
+# Generates a simplified file with variables that
+# can be imported from the main vendorized Makefile.
+
+import os
+import sys
+
+import configparser
+
+from provider import getDefaultProvider
+from provider import getProviderData
+
+
+VERSION = os.environ.get('VERSION', 'unknown')
+
+TEMPLATE = """
+# Variables for the build of {applicationName}.
+# Generated automatically. Do not edit.
+APPNAME := {applicationName}
+BINNAME := {binaryName}
+VERSION := {version}
+"""
+
+
+def writeOutput(data, outfile):
+
+ configString = TEMPLATE.format(
+ binaryName=data['binaryName'],
+ applicationName=data['applicationName'],
+ version=data['version'],
+ )
+
+ with open(outfile, 'w') as outf:
+ outf.write(configString)
+
+
+if __name__ == "__main__":
+ VENDOR_PATH = os.environ.get('VENDOR_PATH')
+ configFile = os.path.join(VENDOR_PATH, 'vendor.conf')
+ config = configparser.ConfigParser()
+ config.read(configFile)
+ provider = getDefaultProvider(config)
+ data = getProviderData(provider, config)
+
+ if len(sys.argv) != 2:
+ print('Usage: generate-vendor-make <output_file>')
+ sys.exit(1)
+
+ outputf = sys.argv[1]
+ data['version'] = VERSION
+
+ writeOutput(data, outputf)