Skip to content

Commit 3c25475

Browse files
committed
set the go path from cmake
1 parent 5805dd2 commit 3c25475

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

builder/actions/cmake.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,12 @@ def _project_dirs(env, project):
103103
def _build_project(env, project, cmake_extra, build_tests=False, args_transformer=None, coverage=False):
104104
sh = env.shell
105105
config = project.get_config(env.spec)
106+
build_env = []
106107
toolchain = env.toolchain
108+
if toolchain.cross_compile and env.variables['go_path'] is not None:
109+
# We need to set the envrionment variable of GO_PATH for cross compile
110+
build_env = ["GO_PATH={}\n".format(env.variables['go_path'])]
111+
107112
# build dependencies first, let cmake decide what needs doing
108113
for dep in project.get_dependencies(env.spec):
109114
_build_project(env, dep, cmake_extra)
@@ -178,13 +183,11 @@ def _build_project(env, project, cmake_extra, build_tests=False, args_transforme
178183
cmake_args = args_transformer(env, project, cmake_args)
179184

180185
# When cross compiling, we must inject the build_env into the cross compile container
181-
build_env = []
182186
if toolchain.cross_compile:
183-
build_env = ['{}={}\n'.format(key, val)
187+
build_env = build_env + ['{}={}\n'.format(key, val)
184188
for key, val in config.get('build_env', {}).items()]
185189
with open(toolchain.env_file, 'a') as f:
186190
f.writelines(build_env)
187-
188191
# set parallism via env var (cmake's --parallel CLI option doesn't exist until 3.12)
189192
if os.environ.get('CMAKE_BUILD_PARALLEL_LEVEL') is None:
190193
sh.setenv('CMAKE_BUILD_PARALLEL_LEVEL', str(os.cpu_count()))

0 commit comments

Comments
 (0)