[flang] Create a throwaway wrapper for the throwaway driver.

Add a script called flang to the bin directory that calls
f18 with the -I option pointing to the module files for the
predefined modules. The wrapper also sets the module suffix
to .fmf to avoid naming conflicts with module files generated
by other compilers. Now, the build creates and installs both
.mod and .fmf files for the predefined module files to
accommodate the flang script.

Original-commit: flang-compiler/f18@b6c30284e7
Reviewed-on: https://github.com/flang-compiler/f18/pull/653
Tree-same-pre-rewrite: false
This commit is contained in:
Steve Scalpone 2019-08-12 21:40:03 -07:00
parent 9dc7ef171c
commit af794f959b
2 changed files with 40 additions and 0 deletions

View File

@ -55,10 +55,28 @@ foreach(filename ${MODULES})
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include"
DEPENDS f18 ${PROJECT_SOURCE_DIR}/module/${filename}.f90
)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/${filename}.fmf
COMMAND f18 -fparse-only -fdebug-semantics -module-suffix .fmf ${PROJECT_SOURCE_DIR}/module/${filename}.f90
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include"
DEPENDS f18 ${PROJECT_SOURCE_DIR}/module/${filename}.f90
)
list(APPEND MODULE_FILES "${CMAKE_CURRENT_BINARY_DIR}/include/${filename}.mod")
list(APPEND MODULE_FILES "${CMAKE_CURRENT_BINARY_DIR}/include/${filename}.fmf")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/${filename}.mod DESTINATION include)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/${filename}.fmf DESTINATION include)
endforeach()
add_custom_target(module_files ALL DEPENDS ${MODULE_FILES})
install(TARGETS f18 f18-parse-demo DESTINATION bin)
file(COPY flang.sh
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/bin"
FILE_PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
file(RENAME "${CMAKE_CURRENT_BINARY_DIR}/bin/flang.sh" "${CMAKE_CURRENT_BINARY_DIR}/bin/flang")
install(PROGRAMS flang.sh DESTINATION bin RENAME flang)

22
flang/tools/f18/flang.sh Normal file
View File

@ -0,0 +1,22 @@
#!/bin/bash
function abspath() {
pushd . > /dev/null;
if [ -d "$1" ]; then
cd "$1";
dirs -l +0;
else
cd "`dirname \"$1\"`";
cur_dir=`dirs -l +0`;
if [ "$cur_dir" == "/" ]; then
echo "$cur_dir`basename \"$1\"`";
else
echo "$cur_dir/`basename \"$1\"`";
fi;
fi;
popd > /dev/null;
}
wd=`abspath $(dirname "$0")/..`
$wd/bin/f18 -fdebug-semantics -module-suffix .fmf -I $wd/include $*