Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
0d4b13cf
Commit
0d4b13cf
authored
9 years ago
by
murgatroid99
Browse files
Options
Downloads
Patches
Plain Diff
Handle google/protobuf includes in src/proto
parent
1b7c0a2c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/proto/gen_build_yaml.py
+18
-5
18 additions, 5 deletions
src/proto/gen_build_yaml.py
with
18 additions
and
5 deletions
src/proto/gen_build_yaml.py
+
18
−
5
View file @
0d4b13cf
...
@@ -36,7 +36,7 @@ import os
...
@@ -36,7 +36,7 @@ import os
import
re
import
re
import
sys
import
sys
def
update_deps
(
key
,
proto_filename
,
deps
,
is_trans
,
visited
):
def
update_deps
(
key
,
proto_filename
,
deps
,
deps_external
,
is_trans
,
visited
):
if
not
proto_filename
in
visited
:
if
not
proto_filename
in
visited
:
visited
.
append
(
proto_filename
)
visited
.
append
(
proto_filename
)
with
open
(
proto_filename
)
as
inp
:
with
open
(
proto_filename
)
as
inp
:
...
@@ -44,10 +44,17 @@ def update_deps(key, proto_filename, deps, is_trans, visited):
...
@@ -44,10 +44,17 @@ def update_deps(key, proto_filename, deps, is_trans, visited):
imp
=
re
.
search
(
r
'
import
"
([^
"
]*)
"'
,
line
)
imp
=
re
.
search
(
r
'
import
"
([^
"
]*)
"'
,
line
)
if
not
imp
:
continue
if
not
imp
:
continue
imp_proto
=
imp
.
group
(
1
)
imp_proto
=
imp
.
group
(
1
)
# This indicates an external dependency, which we should handle
# differently and not traverse recursively
if
imp_proto
.
startswith
(
'
google/
'
):
if
key
not
in
deps_external
:
deps_external
[
key
]
=
[]
deps_external
[
key
].
append
(
imp_proto
[:
-
6
])
continue
if
key
not
in
deps
:
deps
[
key
]
=
[]
if
key
not
in
deps
:
deps
[
key
]
=
[]
deps
[
key
].
append
(
imp_proto
[:
-
6
])
deps
[
key
].
append
(
imp_proto
[:
-
6
])
if
is_trans
:
if
is_trans
:
update_deps
(
key
,
imp_proto
,
deps
,
is_trans
,
visited
)
update_deps
(
key
,
imp_proto
,
deps
,
deps_external
,
is_trans
,
visited
)
def
main
():
def
main
():
proto_dir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
sys
.
argv
[
0
]))
proto_dir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
sys
.
argv
[
0
]))
...
@@ -55,17 +62,23 @@ def main():
...
@@ -55,17 +62,23 @@ def main():
deps
=
{}
deps
=
{}
deps_trans
=
{}
deps_trans
=
{}
deps_external
=
{}
deps_external_trans
=
{}
for
root
,
dirs
,
files
in
os
.
walk
(
'
src/proto
'
):
for
root
,
dirs
,
files
in
os
.
walk
(
'
src/proto
'
):
for
f
in
files
:
for
f
in
files
:
if
f
[
-
6
:]
!=
'
.proto
'
:
continue
if
f
[
-
6
:]
!=
'
.proto
'
:
continue
look_at
=
os
.
path
.
join
(
root
,
f
)
look_at
=
os
.
path
.
join
(
root
,
f
)
deps_for
=
look_at
[:
-
6
]
deps_for
=
look_at
[:
-
6
]
update_deps
(
deps_for
,
look_at
,
deps
,
False
,
[])
# First level deps
# First level deps
update_deps
(
deps_for
,
look_at
,
deps_trans
,
True
,
[])
# Transitive deps
update_deps
(
deps_for
,
look_at
,
deps
,
deps_external
,
False
,
[])
# Transitive deps
update_deps
(
deps_for
,
look_at
,
deps_trans
,
deps_external_trans
,
True
,
[])
json
=
{
json
=
{
'
proto_deps
'
:
deps
,
'
proto_deps
'
:
deps
,
'
proto_transitive_deps
'
:
deps_trans
'
proto_transitive_deps
'
:
deps_trans
,
'
proto_external_deps
'
:
deps_external
,
'
proto_transitive_external_deps
'
:
deps_external_trans
}
}
print
yaml
.
dump
(
json
)
print
yaml
.
dump
(
json
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment