13
13
14
14
_BAZEL_BIN_PATH = 'bazel-bin'
15
15
_BUILD_PATH = 'build'
16
- _INSTALL_PATH = os . path . join ( 'src' , 'Akihabara' )
16
+ _INSTALL_PATH = 'src'
17
17
18
18
class Console :
19
19
def __init__ (self , verbose ):
@@ -92,6 +92,7 @@ def __init__(self, command_args):
92
92
Command .__init__ (self , command_args )
93
93
94
94
self .system = platform .system ()
95
+ self .install = command_args .args .install
95
96
self .desktop = command_args .args .desktop
96
97
self .protobuf = command_args .args .protobuf
97
98
# self.android = command_args.args.android
@@ -109,7 +110,7 @@ def run(self):
109
110
self ._run_command (self ._build_proto_srcs_commands ())
110
111
self ._unzip (
111
112
os .path .join (_BAZEL_BIN_PATH , 'mediapipe_api' , 'mediapipe_proto_srcs.zip' ),
112
- os .path .join (_BUILD_PATH , 'Framework' , 'Protobuf' ))
113
+ os .path .join (_BUILD_PATH , 'Akihabara' , ' Framework' , 'Protobuf' ))
113
114
self .console .info ('Built protobuf sources' )
114
115
115
116
# # Unity-specific requirements, not needed for .NET
@@ -129,11 +130,14 @@ def run(self):
129
130
self .console .info ('Built resource files' )
130
131
131
132
if self .desktop :
132
- self .console .info ('Building native libraries for Desktop...' )
133
+ self .console .info (f'Building native libraries for { self .system } Desktop...' )
134
+
135
+ native_build_path = os .path .join (_BUILD_PATH , 'Runtime' , f'Akihabara.Runtime.{ self .system } _x64.CPU' )
136
+
133
137
self ._run_command (self ._build_desktop_commands ())
134
138
self ._unzip (
135
139
os .path .join (_BAZEL_BIN_PATH , 'mediapipe_api' , 'mediapipe_desktop.zip' ),
136
- os . path . join ( _BUILD_PATH , 'bin' , 'Debug' , 'net5.0' ) )
140
+ native_build_path )
137
141
138
142
if self .include_opencv_libs :
139
143
if self .opencv == 'cmake' :
@@ -142,7 +146,7 @@ def run(self):
142
146
self ._run_command (self ._build_opencv_libs ())
143
147
self ._unzip (
144
148
os .path .join (_BAZEL_BIN_PATH , 'mediapipe_api' , 'opencv_libs.zip' ),
145
- os .path .join (_BUILD_PATH , 'bin' , 'Debug' , 'net5.0' , 'opencv' ))
149
+ os .path .join (native_build_path , 'opencv' ))
146
150
147
151
self .console .info ('Built native libraries for Desktop' )
148
152
@@ -165,21 +169,23 @@ def run(self):
165
169
166
170
167
171
self .console .info ('Printing build path...' )
168
- for root , directories , files in os .walk (_BUILD_PATH , topdown = False ):
172
+ self ._print_dir_tree (_BUILD_PATH )
173
+ self .console .info ('Done' )
174
+
175
+ if self .install :
176
+ self .console .info ('Installing...' )
177
+ # _copytree fails on Windows, so run `cp -r` instead.
178
+ self ._copytree (_BUILD_PATH , _INSTALL_PATH )
179
+ self ._print_dir_tree (os .path .join (_INSTALL_PATH , 'bin' ))
180
+ self .console .info ('Installed' )
181
+
182
+ def _print_dir_tree (self , dir_path ):
183
+ for root , directories , files in os .walk (dir_path , topdown = False ):
169
184
for name in files :
170
185
print (os .path .join (root , name ))
171
186
for name in directories :
172
187
print (os .path .join (root , name ) + '/' )
173
188
174
- self .console .info ('Installing...' )
175
- # _copytree fails on Windows, so run `cp -r` instead.
176
- self ._copytree (_BUILD_PATH , _INSTALL_PATH )
177
- for root , directories , files in os .walk (os .path .join (_INSTALL_PATH , 'bin' ), topdown = False ):
178
- for name in files :
179
- print (os .path .join (root , name ))
180
- for name in directories :
181
- print (os .path .join (root , name ) + '/' )
182
- self .console .info ('Installed' )
183
189
184
190
def _is_windows (self ):
185
191
return self .system == 'Windows'
@@ -389,11 +395,12 @@ def __init__(self):
389
395
subparsers = self .argument_parser .add_subparsers (dest = 'command' )
390
396
391
397
build_command_parser = subparsers .add_parser ('build' , help = 'Build and install native libraries' )
392
- build_command_parser .add_argument ('--protobuf' , '-p' , action = argparse .BooleanOptionalAction , help = 'Build C# protobuf sources for Akihabara' )
393
- build_command_parser .add_argument ('--desktop' , '-d' , choices = ['cpu' , 'gpu' ])
394
- # build_command_parser.add_argument('--android', '-a', choices=['arm', 'arm64'])
395
- # build_command_parser.add_argument('--ios', '-i', choices=['arm64'])
396
- build_command_parser .add_argument ('--resources' , '-R' , action = argparse .BooleanOptionalAction )
398
+ build_command_parser .add_argument ('--install' , action = argparse .BooleanOptionalAction , help = 'Integrate built artifacts in the repository' , default = True )
399
+ build_command_parser .add_argument ('--protobuf' , action = argparse .BooleanOptionalAction , help = 'Build C# protobuf sources for Akihabara' )
400
+ build_command_parser .add_argument ('--desktop' , choices = ['cpu' , 'gpu' ])
401
+ # build_command_parser.add_argument('--android', choices=['arm', 'arm64'])
402
+ # build_command_parser.add_argument('--ios', choices=['arm64'])
403
+ build_command_parser .add_argument ('--resources' , action = argparse .BooleanOptionalAction )
397
404
build_command_parser .add_argument ('--compilation_mode' , '-c' , choices = ['fastbuild' , 'opt' , 'dbg' ], default = 'opt' )
398
405
build_command_parser .add_argument ('--opencv' , choices = ['local' , 'cmake' ], default = 'local' , help = 'Decide to which OpenCV to link for Desktop native libraries' )
399
406
build_command_parser .add_argument ('--include_opencv_libs' , action = 'store_true' , help = 'Include OpenCV\' s native libraries for Desktop' )
0 commit comments