0

I need the makefile generated by TI Code Composer Studio 10 to use SHELL = sh.exe instead of SHELL = cmd.exe. The insertion of the SHELL line seems to be specific to TI and not Eclipse. I can't figure out how to do this. I've tried setting environment variables at the system level and in the project build settings. I've tried running TI CCS from a bash shell hoping it might pick up its own environment. I've also looked through the Eclipse sources for generating the makefile.

Example:

Everything from SHELL to just before the -include line is TI specific.

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

SHELL = cmd.exe

CG_TOOL_ROOT := C:/ti/ccs1040/ccs/tools/compiler/ti-cgt-msp430_20.2.5.LTS

GEN_OPTS__FLAG := 
GEN_CMDS__FLAG := 

ORDERED_OBJS += \
"./msp430fr60x7_1.obj" \
"../lnk_msp430fr6047.cmd" \
$(GEN_CMDS__FLAG) \
-llibmpu_init.a \
-llibmath.a \
-llibc.a \

-include ../makefile.init

Reason: gmake creates batch files for commands like echo and our computers have security software that block randomly created batch files from running. If run from bash/sh, gmake doesn't use intermediate batch files.

Update: I may have a workaround by telling the project to invoke gmake like this: sh.exe -c gmake.exe args. That isn't working fully though as the args do not get passed.

Harvey
  • 5,703
  • 1
  • 32
  • 41

1 Answers1

1

After confirming with TI that the SHELL is hardcoded, this workaround is the solution.

You'll need to:

  • Create a make.sh shell script to run the real gmake.exe
  • Create a makefile.defs to fix some SHELL and RM variables inside the TI generated makefile
  • Install another sh.exe. I used the one installed with Git for Windows. The cygwin sh.exe that comes with the TI compiler doesn't work. This is a shame, because it would be nice to have a solution not requiring another tool.

First, modify your project build settings to run the make script. In TI Code Composer Studio:

Project Menu -> Show Build Settings -> CCS Build -> Builder

  • [ ] Uncheck "Use default build command"
  • Build Command: C:/Progra~1/Git/bin/sh.exe ${PROJECT_ROOT}/make.sh ${CCS_UTILS_DIR}/bin/gmake -k -j 8

Note: You have to use the MS-DOS short path for "Program Files," because it's 2021, and Eclipse can't handle spaces in a path.

Create make.sh in the PROJECT_ROOT directory:

#!C:/Progra~1/Git/bin/sh.exe

# The cygwin provided shell from TI doesn't work with make. Use the one from Git instead or even SourceTree's embedded Git shell.
# In TI CCS, Project -> Show Build Settings -> CCS Build -> Builder -> Build Command (Uncheck Use default build command)
# Build Command:    C:/Progra~1/Git/bin/sh.exe ${PROJECT_ROOT}/make.sh ${CCS_UTILS_DIR}/bin/gmake -k -j 8

echo "$@"

# debugging
#echo $#
#env | sort

if [ $# -eq 0 ]; then
    echo Nothing to do. >&2
    exit
fi

export MAKESHELL="$SHELL"
# echo MAKESHELL is \'$MAKESHELL\' inside the script, but will be translated to the DOS path inside make.

"$@"

Create makefile.defs in the PROJECT_ROOT directory. The Eclipse generated makefile includes this file at the very end allowing it to override any settings set by TI.

# The invoking shell sets MAKESHELL so we can grab it here.
SHELL = $(MAKESHELL)
RM = rm -f
$(info "MAKEFLAGS is $(MAKEFLAGS)")
$(info "MAKECMDGOALS is $(MAKECMDGOALS)")
# $(info "SHELL is $(SHELL)")
# $(info "CWD is $(CWD)")
# $(info "PATH is ${PATH}")
Harvey
  • 5,703
  • 1
  • 32
  • 41