Skip to content

Commit eef1e60

Browse files
authored
opencv: install native libraries (#46)
* opencv: install native libraries * nit: fix typo * nits: format code
1 parent 268a78d commit eef1e60

File tree

1 file changed

+41
-34
lines changed

1 file changed

+41
-34
lines changed

tasks/opencv.py

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -103,42 +103,49 @@ def build(
103103
run(cmake_cmd, shell=True, check=True, cwd=build_dir, env=work_env)
104104
run("ninja", shell=True, check=True, cwd=build_dir)
105105

106+
# Manually install headers and libraries
107+
106108
if not native:
107-
# Manually install headers and libraries
108-
header_dirs = [
109-
"include",
110-
"build/wasm",
111-
"modules/core/include",
112-
"modules/calib3d/include",
113-
"modules/features2d/include",
114-
"modules/flann/include",
115-
"modules/imgcodecs/include",
116-
"modules/imgproc/include",
117-
"modules/ml/include",
118-
"modules/photo/include",
119-
"modules/video/include",
120-
]
121109
dst_header_dir = join(
122110
work_env["FAASM_WASM_HEADER_INSTALL_DIR"], "opencv2"
123111
)
124-
makedirs(dst_header_dir, exist_ok=True)
125-
for header_dir in header_dirs:
126-
for header_file in listdir(
127-
join(opencv_dir, header_dir, "opencv2")
128-
):
129-
src_path = join(opencv_dir, header_dir, "opencv2", header_file)
130-
dst_path = join(dst_header_dir, header_file)
131-
if isdir(src_path):
132-
run(
133-
f"cp -r {src_path} {dst_header_dir}",
134-
shell=True,
135-
check=True,
136-
)
137-
else:
138-
copy(src_path, dst_path)
112+
dst_lib_dir = work_env["FAASM_WASM_LIB_INSTALL_DIR"]
113+
else:
114+
dst_header_dir = "/usr/include/opencv2"
115+
dst_lib_dir = "/usr/local/lib/opencv2"
116+
117+
makedirs(dst_header_dir, exist_ok=True)
118+
makedirs(dst_lib_dir, exist_ok=True)
139119

140-
for lib_name in listdir(join(build_dir, "lib")):
141-
copy(
142-
join(build_dir, "lib", lib_name),
143-
join(work_env["FAASM_WASM_LIB_INSTALL_DIR"], lib_name),
144-
)
120+
header_dirs = [
121+
"include",
122+
"build/wasm",
123+
"modules/core/include",
124+
"modules/calib3d/include",
125+
"modules/features2d/include",
126+
"modules/flann/include",
127+
"modules/imgcodecs/include",
128+
"modules/imgproc/include",
129+
"modules/ml/include",
130+
"modules/photo/include",
131+
"modules/video/include",
132+
]
133+
134+
for header_dir in header_dirs:
135+
for header_file in listdir(join(opencv_dir, header_dir, "opencv2")):
136+
src_path = join(opencv_dir, header_dir, "opencv2", header_file)
137+
dst_path = join(dst_header_dir, header_file)
138+
if isdir(src_path):
139+
run(
140+
f"cp -r {src_path} {dst_header_dir}",
141+
shell=True,
142+
check=True,
143+
)
144+
else:
145+
copy(src_path, dst_path)
146+
147+
for lib_name in listdir(join(build_dir, "lib")):
148+
copy(
149+
join(build_dir, "lib", lib_name),
150+
join(dst_lib_dir, lib_name),
151+
)

0 commit comments

Comments
 (0)