Python生成的文件无法正确执行

时间:2018-09-20 15:36:53

标签: python cmake sh

我用Python生成的文件有问题。我有一些要动态创建的文件(.sh文件)。文件本身可以正确执行并执行应做的事情。

但是Python生成的文件是IDENTICAL,Linux中的diff命令的结果为空!但是当我执行生成的.sh脚本时,它们给了我随机错误。

这是我的普通文件(例如):

OBJDUMP=`which riscv32-unknown-elf-objdump`
OBJCOPY=`which riscv32-unknown-elf-objcopy`

COMPILER=`which riscv32-unknown-elf-gcc`
RANLIB=`which riscv32-unknown-elf-ranlib`

VSIM=`which vsim`
echo $VSIM

TARGET_C_FLAGS="-O3 -m32 -g"
#TARGET_C_FLAGS="-O2 -g -falign-functions=16  -funroll-all-loops"

# if you want to have compressed instructions, set this to 1
RVC=0

# if you are using zero-riscy, set this to 1, otherwise it uses RISCY
USE_ZERO_RISCY=0

# set this to 1 if you are using the Floating Point extensions for riscy only
RISCY_RV32F=0

# zeroriscy with the multiplier
ZERO_RV32M=0
# zeroriscy with only 16 registers
ZERO_RV32E=0

# riscy with PULPextensions, it is assumed you use the ETH GCC Compiler
GCC_MARCH="IMXpulpv2"
#compile arduino lib
ARDUINO_LIB=1

PULP_GIT_DIRECTORY=../../
SIM_DIRECTORY="$PULP_GIT_DIRECTORY/vsim"
#insert here your post-layout netlist if you are using IMPERIO
PL_NETLIST=""

cmake "$PULP_GIT_DIRECTORY"/sw/ \
    -DPULP_MODELSIM_DIRECTORY="$SIM_DIRECTORY" \
    -DCMAKE_C_COMPILER="$COMPILER" \
    -DVSIM="$VSIM" \
    -DRVC="$RVC" \
    -DRISCY_RV32F="$RISCY_RV32F" \
    -DUSE_ZERO_RISCY="$USE_ZERO_RISCY" \
    -DZERO_RV32M="$ZERO_RV32M" \
    -DZERO_RV32E="$ZERO_RV32E" \
    -DGCC_MARCH="$GCC_MARCH" \
    -DARDUINO_LIB="$ARDUINO_LIB" \
    -DPL_NETLIST="$PL_NETLIST" \
    -DCMAKE_C_FLAGS="$TARGET_C_FLAGS" \
    -DCMAKE_OBJCOPY="$OBJCOPY" \
    -DCMAKE_OBJDUMP="$OBJDUMP"

这是python生成的一个。

OBJDUMP=`which riscv32-unknown-elf-objdump`
OBJCOPY=`which riscv32-unknown-elf-objcopy`    

COMPILER=`which riscv32-unknown-elf-gcc`
RANLIB=`which riscv32-unknown-elf-ranlib`    

VSIM=`which vsim`
TARGET_C_FLAGS="-O3 -m32 -g"    

RVC=0   

USE_ZERO_RISCY=0   

RISCY_RV32F=0   

ZERO_RV32M=0    

ZERO_RV32E=0    

GCC_MARCH="IMXpulpv2"   

ARDUINO_LIB=1    

PULP_GIT_DIRECTORY=../../
SIM_DIRECTORY="$PULP_GIT_DIRECTORY/vsim"
PL_NETLIST=""
cmake "$PULP_GIT_DIRECTORY"/sw/ \ 
    -DPULP_MODELSIM_DIRECTORY="$SIM_DIRECTORY" \ 
    -DCMAKE_C_COMPILER="$COMPILER" \ 
    -DVSIM="$VSIM" \ 
    -DRVC="$RVC" \ 
    -DRISCY_RV32F="$RISCY_RV32F" \ 
    -DUSE_ZERO_RISCY="$USE_ZERO_RISCY" \ 
    -DZERO_RV32M="$ZERO_RV32M" \ 
    -DZERO_RV32E="$ZERO_RV32E" \ 
    -DGCC_MARCH="$GCC_MARCH" \ 
    -DARDUINO_LIB="$ARDUINO_LIB" \ 
    -DPL_NETLIST="$PL_NETLIST" \ 
    -DCMAKE_C_FLAGS="$TARGET_C_FLAGS" \ 
    -DCMAKE_OBJCOPY="$OBJCOPY" \ 
    -DCMAKE_OBJDUMP="$OBJDUMP"

我不知道这对您有多大帮助。但是,就是这样。

现在,我使用./script执行此脚本,然后执行第一个脚本。第二个错误给我:

CMake Error: The source directory "../sw/build/ " does not exist. 

脚本所在的路径正好是../sw/build/

这是怎么回事?

0 个答案:

没有答案