Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Generate _test.go only for _test.py files
Browse files Browse the repository at this point in the history
  • Loading branch information
alanjds committed Dec 15, 2017
1 parent bbf6cb4 commit 9dc9d03
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tools/genmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,17 @@ def main(args):
ar_name = os.path.join(pkg_dir, '__python__', basename + '.a')
go_file = os.path.join(pydir, basename, 'module.go')
gotest_file = os.path.join(pydir, basename, 'module_test.go')
ar_deps = [go_file]
_PrintRule(go_file,
[os.path.join(dirpath, filename)],
['grumpc -modname={} $< > $@'.format(modname)],
echo_debug=True)
_PrintRule(gotest_file,
[os.path.join(dirpath, filename)],
['gentest -modname={} > $@'.format(modname)],
echo_debug=True)
if modname.endswith(('_test', '_tests')):
ar_deps.append(gotest_file)
_PrintRule(gotest_file,
[os.path.join(dirpath, filename)],
['gentest -modname={} > $@'.format(modname)],
echo_debug=True)

recipe = (r"""pydeps -modname=%s $< | awk '{gsub(/\./, "/", $$0); """
r"""print "%s: %s/__python__/" $$0 ".a"}' > $@""")
Expand All @@ -86,8 +89,7 @@ def main(args):
[recipe % (modname, ar_name, pkg_dir)])
go_package = '__python__/' + basename.replace(os.sep, '/')
recipe = 'go tool compile -o $@ -p {} -complete -I {} -pack $<'
_PrintRule(ar_name, [go_file, gotest_file],
[recipe.format(go_package, pkg_dir)])
_PrintRule(ar_name, ar_deps, [recipe.format(go_package, pkg_dir)])
if args.all_target:
_PrintRule(args.all_target, [ar_name], [])
print '-include {}\n'.format(dep_file)
Expand Down

0 comments on commit 9dc9d03

Please sign in to comment.