aboutsummaryrefslogtreecommitdiffhomepage
path: root/internalize_scripts.py
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-07-08 15:20:39 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-07-08 15:20:39 -0700
commit4912967eabc447c31847566f03c50433015e9e9c (patch)
tree939f1d16354f08da8f11b4489e31b38a57022df9 /internalize_scripts.py
parent76e1cda495d6e88cea383d387375588cdf9297bc (diff)
Large set of changes related to making fish relocatable, and improving the build and install story.
- etc/config.fish and share/config.fish are now "universal" and no longer reference install paths or need to be touched by autotools. They've been removed from config.fish.in to config.fish. - fish now attempts to determine __fish_datadir and __fish_sysconfdir relative to the path of the fish executable itself (typically by walking up one directory). This means that you can copy the directory hierarchy around and things will still work. The compiled-in paths are used as a backup. - The fish Xcode project now can build fish natively, without needing autotools. - Version bumped to 2.0
Diffstat (limited to 'internalize_scripts.py')
-rwxr-xr-xinternalize_scripts.py35
1 files changed, 31 insertions, 4 deletions
diff --git a/internalize_scripts.py b/internalize_scripts.py
index b0b06fdf..314fb6c0 100755
--- a/internalize_scripts.py
+++ b/internalize_scripts.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-import string, sys, os.path
+import string, sys, os.path, getopt
escapes = {}
escapes['\a'] = r'\a'
@@ -64,7 +64,34 @@ class cfunc:
TYPES = ['function', 'completion']
type_to_funcs = dict((t, []) for t in TYPES)
-for file in sys.argv[1:]:
+
+def usage(script_name):
+ print("Usage: {0} [--output output_directory] files...".format(script_name))
+ print("""Command options are:
+ --output directory\t\tThe directory to output the files
+ -h, --help\t\t\tShow this help message
+ """)
+
+script_name = sys.argv[0]
+try:
+ opts, file_paths = getopt.gnu_getopt(sys.argv[1:], 'h', ['output=', 'help'])
+except getopt.GetoptError as err:
+ print(err.msg) # will print something like "option -a not recognized"
+ usage(script_name)
+ sys.exit(2)
+
+output_directory = './'
+for opt, value in opts:
+ if opt in ('--output',):
+ output_directory = value
+ elif opt in ('-h', '--help'):
+ usage(script_name)
+ sys.exit(0)
+ else:
+ assert False, "unhandled option"
+
+
+for file in file_paths:
fd = open(file, 'r')
newlines = []
for line in fd:
@@ -89,7 +116,7 @@ for funcs in type_to_funcs.values():
funcs.sort(key=cfunc.cfunc_name)
# Output our header
-fd = open('builtin_scripts.h', 'w')
+fd = open(os.path.join(output_directory, 'builtin_scripts.h'), 'w')
fd.write('/* This file is generated by internalize_scripts.py */\n\n')
fd.write("""struct builtin_script_t {
const wchar_t *name;
@@ -106,7 +133,7 @@ for type in TYPES:
fd.close()
# Output the function definitions
-fd = open('builtin_scripts.cpp', 'w')
+fd = open(os.path.join(output_directory, 'builtin_scripts.cpp'), 'w')
fd.write('/* This file is generated by internalize_scripts.py */\n\n')
fd.write('#include "builtin_scripts.h"\n\n')
for type in TYPES: