Created
February 1, 2011 13:40
-
-
Save nus/805861 to your computer and use it in GitHub Desktop.
ライブラリのコンフィグを表示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import getopt | |
'''ライブラリのコンフィグを表示''' | |
conf = { | |
# OpenGL | |
'gl' : '-L/usr/X11/lib -lGL -lGLU -lglut', | |
# ODE(Open Dynamics Engine) | |
'ode' : '-L/usr/X11/lib -L/opt/ode/lib -lGL -lGLU -lglut -lode -ldrawstuff -DdDOUBLE', | |
# URG for C++ | |
'urg' : '-I/usr/local/include/urg -lurg_monitor -lurg -lurg_coordinate -lurg_geometry -lurg_connection -lurg_connection_sdl -lurg_common -lurg_system', | |
# URG for C | |
'c_urg' : '-I/usr/local/include/c_urg -lc_urg -lc_urg_connection -lc_urg_system', | |
} | |
def usage(): | |
out = 'Usage: myconfig [--help] [--all]' | |
for key in conf.keys(): | |
out += (' [--' + key + ']') | |
print(out) | |
def help(): | |
out = '''ライブラリのコンフィグを表示''' | |
print(out) | |
def opt_all(): | |
out = '' | |
for key, val in conf.items(): | |
out += (val + ' ') | |
print(out) | |
def main(): | |
try: | |
optlist, args = getopt.getopt(sys.argv[1:], 'hx', ['help', 'all'] + conf.keys()) | |
except getopt.GetoptError: | |
usage() | |
sys.exit(2) | |
if len(sys.argv) == 1: | |
# 引数が何も無い時 | |
usage() | |
sys.exit(2) | |
# --all option | |
if ('--all', '') in optlist: | |
opt_all() | |
sys.exit(2) | |
out = '' | |
for o, a in optlist: | |
if (o == '-h') or (o == '--help'): | |
help() | |
sys.exit(2) | |
else: | |
out += ' ' + conf[o[2:]] | |
print(out) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment