From 74a619f49e0beec1cfa5da61bc91900011c342db Mon Sep 17 00:00:00 2001 From: Sharan Yalburgi Date: Fri, 21 Jan 2022 14:57:17 +0530 Subject: [PATCH] [FMUComplianceChecker] Add builder (#4284) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [New Package] FMUComplianceChecker * Update build_tarballs.jl * Update build_tarballs.jl * Update build_tarballs.jl * Update build_tarballs.jl * Update build_tarballs.jl * Update build_tarballs.jl * Update build_tarballs.jl * Update build_tarballs.jl * Update build_tarballs.jl * Update build_tarballs.jl * fix typo * Updates based on review * Update checksum * Move binaries manually * [FMUComplianceChecker] Add patches and build for all platforms * [FMUComplianceChecker] Use proper libtool for macOS * [FMUComplianceChecker] Remove extra stuff from the tarball * Update F/FMUComplianceChecker/build_tarballs.jl Co-authored-by: Mosè Giordano Co-authored-by: Mosè Giordano --- F/FMUComplianceChecker/build_tarballs.jl | 49 +++++++++++++++++++ .../bundled/patches/.gitattributes | 1 + .../fmi-library-cmake-expatex-cmake.patch | 10 ++++ .../patches/forward-cmake-toolchain.patch | 45 +++++++++++++++++ .../patches/windows-linking-lowercase.patch | 28 +++++++++++ .../windows-lowercase-header-file.patch | 11 +++++ 6 files changed, 144 insertions(+) create mode 100644 F/FMUComplianceChecker/build_tarballs.jl create mode 100644 F/FMUComplianceChecker/bundled/patches/.gitattributes create mode 100644 F/FMUComplianceChecker/bundled/patches/fmi-library-cmake-expatex-cmake.patch create mode 100644 F/FMUComplianceChecker/bundled/patches/forward-cmake-toolchain.patch create mode 100644 F/FMUComplianceChecker/bundled/patches/windows-linking-lowercase.patch create mode 100644 F/FMUComplianceChecker/bundled/patches/windows-lowercase-header-file.patch diff --git a/F/FMUComplianceChecker/build_tarballs.jl b/F/FMUComplianceChecker/build_tarballs.jl new file mode 100644 index 00000000000..827f6ae4873 --- /dev/null +++ b/F/FMUComplianceChecker/build_tarballs.jl @@ -0,0 +1,49 @@ +# Note that this script can accept some limited command-line arguments, run +# `julia build_tarballs.jl --help` to see a usage message. +using BinaryBuilder, Pkg + +name = "FMUComplianceChecker" +version = v"2.0.4" + +# Collection of sources required to complete build +sources = [ + ArchiveSource("https://github.com/modelica-tools/FMUComplianceChecker/archive/f0fd0b2ca78c415a725b028deec46c1962799f1d.zip", + "db4607e7b6230d9b7f2e394e6ec132e90cee19ae6625997c09d946ab61dda156"), + DirectorySource("./bundled"), +] + +# Bash recipe for building across all platforms +script = raw""" +cd $WORKSPACE/srcdir/FMUComplianceChecker*/ +atomic_patch -p1 ../patches/forward-cmake-toolchain.patch +atomic_patch -p1 ../patches/windows-lowercase-header-file.patch +export CFLAGS="-I${includedir}" +if [[ "${target}" == *-apple-* ]]; then + # Replace `/usr/bin/libtool` with `libtool` from our toolchain to fix error + # libtool: error: unrecognised option: '-static' + ln -sf $(which libtool) /usr/bin/libtool +fi +mkdir build && cd build +cmake -DCMAKE_INSTALL_PREFIX=${prefix} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} -DCMAKE_BUILD_TYPE=Release .. +make -j${nproc} +install -Dm755 fmuCheck.* "${bindir}/fmuCheck${exeext}" +# Delete expat stuff +rm -rf "${includedir}" "${prefix}/lib" +install_license "../LICENSE" +""" + +# These are the platforms we will build for by default, unless further +# platforms are passed in on the command line +platforms = supported_platforms() + +# The products that we will ensure are always built +products = [ + ExecutableProduct("fmuCheck", :fmucheck), +] + +# Dependencies that must be installed before this package can be built +dependencies = Dependency[ +] + +# Build the tarballs, and possibly a `build.jl` as well. +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6") diff --git a/F/FMUComplianceChecker/bundled/patches/.gitattributes b/F/FMUComplianceChecker/bundled/patches/.gitattributes new file mode 100644 index 00000000000..c480e811fbf --- /dev/null +++ b/F/FMUComplianceChecker/bundled/patches/.gitattributes @@ -0,0 +1 @@ +*.patch binary diff --git a/F/FMUComplianceChecker/bundled/patches/fmi-library-cmake-expatex-cmake.patch b/F/FMUComplianceChecker/bundled/patches/fmi-library-cmake-expatex-cmake.patch new file mode 100644 index 00000000000..e159cac5209 --- /dev/null +++ b/F/FMUComplianceChecker/bundled/patches/fmi-library-cmake-expatex-cmake.patch @@ -0,0 +1,10 @@ +--- a/Config.cmake/fmixml.cmake ++++ b/Config.cmake/fmixml.cmake +@@ -159,6 +159,7 @@ set(EXPAT_SETTINGS + -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_MODULE_LINKER_FLAGS} + -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS} + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/ExpatEx/install ++ -DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE} + ) + + ExternalProject_Add( diff --git a/F/FMUComplianceChecker/bundled/patches/forward-cmake-toolchain.patch b/F/FMUComplianceChecker/bundled/patches/forward-cmake-toolchain.patch new file mode 100644 index 00000000000..a2edfacacfe --- /dev/null +++ b/F/FMUComplianceChecker/bundled/patches/forward-cmake-toolchain.patch @@ -0,0 +1,45 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -108,7 +108,7 @@ + -DFMILIB_BUILD_SHARED_LIB:BOOLEAN=OFF + -DFMILIB_INSTALL_SUBLIBS:BOOLEAN=OFF + -DFMILIB_GENERATE_DOXYGEN_DOC:BOOLEAN=OFF +- -DFMILIB_BUILD_TESTS:BOOLEAN=ON ++ -DFMILIB_BUILD_TESTS:BOOLEAN=OFF + -DFMILIB_GENERATE_BUILD_STAMP:BOOLEAN=OFF + -DFMILIB_ENABLE_LOG_LEVEL_DEBUG:BOOLEAN=${FMUCHK_ENABLE_LOG_LEVEL_DEBUG} + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} +@@ -126,6 +126,7 @@ + -DCMAKE_LINK_LIBRARY_FLAG:STRING=${CMAKE_LINK_LIBRARY_FLAG} + -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_MODULE_LINKER_FLAGS} + -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS} ++ -DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE} + ) + + if(MSVC) +@@ -146,6 +147,16 @@ + ) + + ExternalProject_Add_Step( ++ fmil fmil_patch ++ DEPENDEES patch ++ DEPENDERS configure ++ COMMAND atomic_patch -p1 /workspace/srcdir/patches/fmi-library-cmake-expatex-cmake.patch ++ COMMAND atomic_patch -p1 /workspace/srcdir/patches/windows-linking-lowercase.patch ++ DEPENDS ${FMUCHK_BUILD}/CMakeCache.txt ${FMUCHK_HOME}/CMakeLists.txt ++ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/FMIL" ++) ++ ++ExternalProject_Add_Step( + fmil fmil_reconfigure + DEPENDEES configure + DEPENDERS build +@@ -213,7 +224,7 @@ + add_executable(${fmuCheck} ${SOURCE} ${HEADERS}) + target_link_libraries(${fmuCheck} fmilib) + if(WIN32) +- target_link_libraries(${fmuCheck} Shlwapi) ++ target_link_libraries(${fmuCheck} shlwapi) + endif(WIN32) + if(UNIX) + target_link_libraries(${fmuCheck} dl) diff --git a/F/FMUComplianceChecker/bundled/patches/windows-linking-lowercase.patch b/F/FMUComplianceChecker/bundled/patches/windows-linking-lowercase.patch new file mode 100644 index 00000000000..6940db4fbc0 --- /dev/null +++ b/F/FMUComplianceChecker/bundled/patches/windows-linking-lowercase.patch @@ -0,0 +1,28 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -264,12 +264,12 @@ if(FMILIB_BUILD_STATIC_LIB) + include(mergestaticlibs) + if(WIN32) + merge_static_libs(fmilib ${FMILIB_SUBLIBS}) +- target_link_libraries(fmilib Shlwapi) ++ target_link_libraries(fmilib shlwapi) + foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + set(flags "") + string(TOUPPER "STATIC_LIBRARY_FLAGS_${CONFIG_TYPE}" PROPNAME) + get_target_property(flags fmilib ${PROPNAME}) +- set_target_properties(fmilib PROPERTIES ${PROPNAME} "${flags} Shlwapi.lib") ++ set_target_properties(fmilib PROPERTIES ${PROPNAME} "${flags} shlwapi.lib") + endforeach() + else() + merge_static_libs(fmilib ${FMILIB_SUBLIBS} ) +--- a/Config.cmake/jmutil.cmake ++++ b/Config.cmake/jmutil.cmake +@@ -67,7 +67,7 @@ if(UNIX) + target_link_libraries(jmutils dl) + endif(UNIX) + if(WIN32) +- target_link_libraries(jmutils Shlwapi) ++ target_link_libraries(jmutils shlwapi) + endif(WIN32) + + endif(NOT JMUTILDIR) diff --git a/F/FMUComplianceChecker/bundled/patches/windows-lowercase-header-file.patch b/F/FMUComplianceChecker/bundled/patches/windows-lowercase-header-file.patch new file mode 100644 index 00000000000..cdd15851099 --- /dev/null +++ b/F/FMUComplianceChecker/bundled/patches/windows-lowercase-header-file.patch @@ -0,0 +1,11 @@ +--- a/src/Common/fmuChecker.c ++++ b/src/Common/fmuChecker.c +@@ -17,7 +17,7 @@ + #include + + #if defined(_WIN32) || defined(WIN32) +- #include ++ #include + #endif + + // #include