Skip to content

Commit 9183dce

Browse files
committed
allow overrides of environment variables.
1 parent d032b0e commit 9183dce

File tree

3 files changed

+38
-23
lines changed

3 files changed

+38
-23
lines changed

cmake/rosjava.cmake.em

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,17 @@ macro(find_gradle_repo_root)
3838
get_filename_component(${PROJECT_NAME}_gradle_ROOT ${${PROJECT_NAME}_gradle_SETTINGS} PATH)
3939
endmacro()
4040

41-
# Sets environment variables that are used by gradle to customise a build.
42-
# This is better than modifying a gradle script - gradle should be able
43-
# to be called alone without cmake intervention.
44-
#
45-
# Actually, this will naturally be picked up by setup.bash->env-hooks after the
46-
# first build, but this does help it find variables if you're compiling the env-hooks
47-
# from rosjava_build_tools in the same 'make' build.
41+
# These are used to seed the environment variables if the workspace is
42+
# containing rosjava_build_tools to be built as well. In this situtation
43+
# CATKIN_ENV won't have any configuration, so we need some incoming here.
44+
# Note that we check for the variable existence as well so we don't
45+
# override a user setting.
4846
macro(_rosjava_env)
49-
set(ROSJAVA_MAVEN_DEPLOYMENT_PATH $ENV{ROS_MAVEN_DEPLOYMENT_PATH})
50-
if(NOT ROSJAVA_MAVEN_DEPLOYMENT_PATH)
51-
set(ROSJAVA_ENV "ROS_MAVEN_DEPLOYMENT_PATH=${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_MAVEN_DESTINATION}")
47+
set(ROS_MAVEN_DEPLOYMENT_REPOSITORY $ENV{ROS_MAVEN_DEPLOYMENT_REPOSITORY})
48+
if(NOT ROS_MAVEN_DEPLOYMENT_REPOSITORY)
49+
set(ROSJAVA_ENV "ROS_MAVEN_DEPLOYMENT_REPOSITORY=${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_MAVEN_DESTINATION}")
5250
else()
53-
set(ROSJAVA_ENV "ROS_MAVEN_DEPLOYMENT_PATH=${ROSJAVA_ENV}")
51+
set(ROSJAVA_ENV "${ROS_MAVEN_DEPLOYMENT_REPOSITORY}")
5452
endif()
5553
set(ROSJAVA_GRADLE_USER_HOME $ENV{GRADLE_USER_HOME})
5654
if(NOT ROSJAVA_GRADLE_USER_HOME)
@@ -82,6 +80,8 @@ macro(catkin_rosjava_setup)
8280
endif()
8381
add_custom_target(gradle-${PROJECT_NAME}
8482
ALL
83+
COMMAND ${ROSJAVA_ENV} ${CATKIN_ENV} "env" "|" "grep" "GRADLE"
84+
COMMAND ${ROSJAVA_ENV} ${CATKIN_ENV} "env" "|" "grep" "ROS"
8585
COMMAND ${ROSJAVA_ENV} ${CATKIN_ENV} ${${PROJECT_NAME}_gradle_BINARY} ${gradle_tasks}
8686
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
8787
VERBATIM

env-hooks/15.rosjava.bash.em

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
#!/bin/bash
22

33
@[if DEVELSPACE]@
4-
export ROS_MAVEN_PATH=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py --maven-path`
5-
export ROS_MAVEN_DEPLOYMENT_PATH=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py --maven-deployment-repository`
6-
export GRADLE_USER_HOME=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py --gradle-user-home`
7-
mkdir -p ${GRADLE_USER_HOME}
4+
SCRIPT=@(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py
85
@[else]@
9-
export ROS_MAVEN_PATH=`python @(CMAKE_INSTALL_PREFIX)/share/rosjava_build_tools/generate_environment_variables.py --maven-path`
10-
export ROS_MAVEN_DEPLOYMENT_PATH=`python @(CMAKE_INSTALL_PREFIX)/share/rosjava_build_tools/generate_environment_variables.py --maven-deployment-repository`
6+
SCRIPT=@(CMAKE_INSTALL_PREFIX)/share/rosjava_build_tools/generate_environment_variables.py
117
@[end if]@
128

9+
# Conditionally set these variables - i.e. if the user wants to override them, that is ok.
10+
: ${ROS_MAVEN_PATH:=`python ${SCRIPT} --maven-path`}
11+
: ${ROS_MAVEN_DEPLOYMENT_REPOSITORY:=`python ${SCRIPT} --maven-deployment-repository`}
12+
: ${GRADLE_USER_HOME:=`python ${SCRIPT} --gradle-user-home`}
13+
export ROS_MAVEN_PATH
14+
export ROS_MAVEN_DEPLOYMENT_REPOSITORY
15+
export GRADLE_USER_HOME
16+
17+
#export ROS_MAVEN_PATH=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py --maven-path`
18+
#export ROS_MAVEN_DEPLOYMENT_REPOSITORY=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py --maven-deployment-repository`
19+
#export GRADLE_USER_HOME=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py --gradle-user-home`

env-hooks/15.rosjava.sh.em

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
#!/bin/sh
22

33
@[if DEVELSPACE]@
4-
export ROS_MAVEN_PATH=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py --maven-path`
5-
export ROS_MAVEN_DEPLOYMENT_PATH=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py --maven-deployment-repository`
6-
export GRADLE_USER_HOME=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py --gradle-user-home`
7-
mkdir -p ${GRADLE_USER_HOME}
4+
SCRIPT=@(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py
85
@[else]@
9-
export ROS_MAVEN_PATH=`python @(CMAKE_INSTALL_PREFIX)/share/rosjava_build_tools/generate_environment_variables.py --maven-path`
10-
export ROS_MAVEN_DEPLOYMENT_PATH=`python @(CMAKE_INSTALL_PREFIX)/share/rosjava_build_tools/generate_environment_variables.py --maven-deployment-repository`
6+
SCRIPT=@(CMAKE_INSTALL_PREFIX)/share/rosjava_build_tools/generate_environment_variables.py
117
@[end if]@
8+
9+
# Conditionally set these variables - i.e. if the user wants to override them, that is ok.
10+
: ${ROS_MAVEN_PATH:=`python ${SCRIPT} --maven-path`}
11+
: ${ROS_MAVEN_DEPLOYMENT_REPOSITORY:=`python ${SCRIPT} --maven-deployment-repository`}
12+
: ${GRADLE_USER_HOME:=`python ${SCRIPT} --gradle-user-home`}
13+
export ROS_MAVEN_PATH
14+
export ROS_MAVEN_DEPLOYMENT_REPOSITORY
15+
export GRADLE_USER_HOME
16+
17+
#export ROS_MAVEN_PATH=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py --maven-path`
18+
#export ROS_MAVEN_DEPLOYMENT_REPOSITORY=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py --maven-deployment-repository`
19+
#export GRADLE_USER_HOME=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_environment_variables.py --gradle-user-home`

0 commit comments

Comments
 (0)