-
Notifications
You must be signed in to change notification settings - Fork 0
/
cs_create_pkg.py
executable file
·149 lines (111 loc) · 4.65 KB
/
cs_create_pkg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env python
#wsn: thanks to Chris Swetenham and Hong Kong University for this script
import argparse
import functools
import getpass
import os
import sys
def error(msg):
sys.stderr.write("error: %s\n" % msg)
sys.exit(1)
parser = argparse.ArgumentParser(
description = """
Create a ros package in the current directory using catkin-simple.
"""
)
parser.add_argument('name', help='name of package to create')
parser.add_argument('deps', nargs='*', help='dependencies of package')
args = parser.parse_args()
print("Creating package '" + args.name + "'")
if (os.path.exists('./' + args.name)):
error("Directory '%s' already exists under current directory." % args.name)
os.makedirs(args.name)
os.chdir(args.name)
os.makedirs('src')
os.makedirs('include')
with open('README.md', 'w') as f:
f.write("""# %s
Your description goes here
## Example usage
## Running tests/demos
""" % args.name)
username = getpass.getuser()
build_depends = "\n".join(map(lambda x: "<build_depend>%s</build_depend>" % x, args.deps))
run_depends = "\n".join(map(lambda x: "<run_depend>%s</run_depend>" % x, args.deps))
with open('package.xml', 'w') as f:
f.write("""<?xml version="1.0"?>
<package>
<name>%s</name>
<version>0.0.0</version>
<description>The %s package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="[email protected]">Jane Doe</maintainer> -->
<maintainer email="%[email protected]">%s</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<!-- Url tags are optional, but mutiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://ros.org/wiki/jacobian_publisher</url> -->
<!-- Author tags are optional, mutiple are allowed, one per tag -->
<!-- Authors do not have to be maintianers, but could be -->
<!-- Example: -->
<!-- <author email="[email protected]">Jane Doe</author> -->
<!-- The *_depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use run_depend for packages you need at runtime: -->
<!-- <run_depend>message_runtime</run_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<buildtool_depend>catkin_simple</buildtool_depend>
%s
%s
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- You can specify that this package is a metapackage here: -->
<!-- <metapackage/> -->
<!-- Other tools can request additional information be placed here -->
</export>
</package>
""" % (args.name, args.name, username, username, build_depends, run_depends))
with open('CMakeLists.txt', 'w') as f:
f.write("""cmake_minimum_required(VERSION 2.8.3)
project(%s)
find_package(catkin_simple REQUIRED)
#uncomment next line to use OpenCV library
#find_package(OpenCV REQUIRED)
#uncomment the next 2 lines to use the point-cloud library
#find_package(PCL 1.10 REQUIRED)
#include_directories(${PCL_INCLUDE_DIRS})
#uncomment the following 4 lines to use the Eigen library
#find_package(cmake_modules REQUIRED)
#find_package(Eigen3 REQUIRED)
#include_directories(${EIGEN3_INCLUDE_DIR})
#add_definitions(${EIGEN_DEFINITIONS})
catkin_simple()
# example boost usage
# find_package(Boost REQUIRED COMPONENTS system thread)
# C++0x support - not quite the same as final C++11!
# use carefully; can interfere with point-cloud library
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
# Libraries: uncomment the following and edit arguments to create a new library
# cs_add_library(my_lib src/my_lib.cpp)
# Executables: uncomment the following and edit arguments to compile new nodes
# may add more of these lines for more nodes from the same package
# cs_add_executable(example src/example.cpp)
#the following is required, if desire to link a node in this package with a library created in this same package
# edit the arguments to reference the named node and named library within this package
# target_link_libraries(example my_lib)
cs_install()
cs_export()
""" % args.name)
print('Done.')