Skip to content

Commit

Permalink
Merge pull request #7 from luncliff/port/tensorflow-lite
Browse files Browse the repository at this point in the history
Support ports for TensorFlow Lite
  • Loading branch information
luncliff authored Oct 10, 2021
2 parents 44180f8 + 023725c commit 2a74c70
Show file tree
Hide file tree
Showing 27 changed files with 7,472 additions and 7 deletions.
35 changes: 35 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ stages:
parameters:
job_name: "zlib_ng"
port_name: "zlib-ng"
- template: azure/jobs-arm-windows.yml
parameters:
job_name: "zlib_ng"
port_name: "zlib-ng"

- template: azure/jobs-windows.yml
parameters:
Expand All @@ -95,6 +99,10 @@ stages:
parameters:
job_name: "openssl3"
port_name: "openssl3"
- template: azure/jobs-arm-windows.yml
parameters:
job_name: "openssl3"
port_name: "openssl3"
- template: azure/jobs-android.yml
parameters:
job_name: "openssl3"
Expand All @@ -104,6 +112,33 @@ stages:
job_name: "openssl3"
port_name: "openssl3"

- template: azure/jobs-windows.yml
parameters:
job_name: "tflite"
port_name: "tensorflow-lite"
- template: azure/jobs-linux.yml
parameters:
job_name: "tflite"
port_name: "tensorflow-lite"
- template: azure/jobs-osx.yml
parameters:
job_name: "tflite"
port_name: "tensorflow-lite"

- template: azure/jobs-android.yml
parameters:
job_name: "xnnpack"
port_name: "xnnpack"

- template: azure/jobs-android.yml
parameters:
job_name: "cpuinfo"
port_name: "cpuinfo"
- template: azure/jobs-ios.yml
parameters:
job_name: "cpuinfo"
port_name: "cpuinfo"

# - stage: "Registry" # todo: Use of this registry
# jobs:
# - job: "windows_2022"
Expand Down
1 change: 1 addition & 0 deletions azure/jobs-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- job: "android_${{ parameters.job_name }}"
pool:
vmImage: ubuntu-20.04
timeoutInMinutes: 300
steps:
- template: run-vcpkg-with-overlay.yml
parameters:
Expand Down
34 changes: 34 additions & 0 deletions azure/jobs-arm-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Author: github.com/luncliff (luncliff@gmail.com)
#
# References
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#job-reuse
#

parameters:
- name: job_name
type: string
- name: port_name
type: string

jobs:
- job: "arm_windows_${{ parameters.job_name }}"
pool:
vmImage: windows-2019
# vmImage: windows-2022 # (2021-10-04) VS 2022 Preview is not ready for arm64-windows
timeoutInMinutes: 300
steps:
- task: UsePythonVersion@0
displayName: "Setup: Python 3.9"
inputs:
versionSpec: "3.9"
addToPath: true
architecture: "x64"
- powershell: env
- template: run-vcpkg-with-overlay.yml
parameters:
port_name: "${{ parameters.port_name }}"
target_triplet: "arm64-windows"
- template: steps-publish-logs.yml
parameters:
port_name: "${{ parameters.port_name }}"
3 changes: 2 additions & 1 deletion azure/jobs-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ jobs:
- job: "ios_${{ parameters.job_name }}"
pool:
vmImage: macOS-11
timeoutInMinutes: 300
steps:
- powershell: env
- powershell: brew install autoconf automake libtool
- template: run-vcpkg-with-overlay.yml
parameters:
port_name: "${{ parameters.port_name }}"
Expand Down
1 change: 1 addition & 0 deletions azure/jobs-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- job: "linux_${{ parameters.job_name }}"
pool:
vmImage: ubuntu-20.04
timeoutInMinutes: 300
steps:
- template: run-vcpkg-with-overlay.yml
parameters:
Expand Down
3 changes: 2 additions & 1 deletion azure/jobs-osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ jobs:
- job: "osx_${{ parameters.job_name }}"
pool:
vmImage: macOS-11
timeoutInMinutes: 300
steps:
- powershell: env
- powershell: brew install autoconf automake libtool
- template: run-vcpkg-with-overlay.yml
parameters:
port_name: "${{ parameters.port_name }}"
Expand Down
1 change: 1 addition & 0 deletions azure/jobs-uwp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
pool:
vmImage: windows-2019
# vmImage: windows-2022 # (2021-10-04) VS 2022 Preview is not ready for arm64-windows
timeoutInMinutes: 300
steps:
- task: UsePythonVersion@0
displayName: "Setup: Python 3.9"
Expand Down
5 changes: 1 addition & 4 deletions azure/jobs-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
pool:
vmImage: windows-2019
# vmImage: windows-2022 # (2021-10-04) VS 2022 Preview is not ready for arm64-windows
timeoutInMinutes: 300
steps:
- task: UsePythonVersion@0
displayName: "Setup: Python 3.9"
Expand All @@ -32,10 +33,6 @@ jobs:
parameters:
port_name: "${{ parameters.port_name }}"
target_triplet: "x86-windows"
- template: run-vcpkg-with-overlay.yml
parameters:
port_name: "${{ parameters.port_name }}"
target_triplet: "arm64-windows"
- template: steps-publish-logs.yml
parameters:
port_name: "${{ parameters.port_name }}"
2 changes: 1 addition & 1 deletion azure/run-vcpkg-with-overlay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ steps:
- task: run-vcpkg@0
displayName: "${{ parameters.target_triplet }}: ${{ parameters.port_name }}"
inputs:
vcpkgGitCommitId: "2021.05.12"
vcpkgGitCommitId: "2a31089e777fc187f1cc05338250b8e1810cfb52" # mainstream 2021-10-02
vcpkgArguments: "${{ parameters.port_name }}" # vcpkg install ${port_name} ...
env:
VCPKG_DEFAULT_TRIPLET: ${{ parameters.target_triplet }} # --triplet ${target_triplet}
Expand Down
59 changes: 59 additions & 0 deletions ports/cpuinfo/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# On Windows, we can get a cpuinfo.dll, but it exports no symbols.
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO luncliff/cpuinfo
REF b23b0d3bbc441ac1172458827ef309e9f6c47fd4
SHA512 ea31b46a0375f67de00241aeec48678a476e8979f6ad0943bebee3c46c848f62ae8d282c9ac8625014f77af5a6dbbb9adf9e98d78111dad0cdc95b40f36520ce
HEAD_REF master
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
tools CPUINFO_BUILD_TOOLS
)

if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
list(APPEND LINK_OPTIONS -DCPUINFO_LIBRARY_TYPE=shared)
else()
list(APPEND LINK_OPTIONS -DCPUINFO_LIBRARY_TYPE=static)
endif()

if(VCPKG_CRT_LINKAGE STREQUAL "dynamic")
list(APPEND LINK_OPTIONS -DCPUINFO_RUNTIME_TYPE=shared)
else()
list(APPEND LINK_OPTIONS -DCPUINFO_RUNTIME_TYPE=static)
endif()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
${LINK_OPTIONS}
-DCPUINFO_BUILD_UNIT_TESTS=OFF
-DCPUINFO_BUILD_MOCK_TESTS=OFF
-DCPUINFO_BUILD_BENCHMARKS=OFF
OPTIONS_DEBUG
-DCPUINFO_LOG_LEVEL=debug
OPTIONS_RELEASE
-DCPUINFO_LOG_LEVEL=default
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH "share/${PORT}")
vcpkg_fixup_pkgconfig() # pkg_check_modules(libcpuinfo)

if("tools" IN_LIST FEATURES)
vcpkg_copy_tools(
TOOL_NAMES cache-info cpuid-dump cpu-info isa-info
AUTO_CLEAN
)
endif()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

file(INSTALL "${SOURCE_PATH}/LICENSE"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright
)
22 changes: 22 additions & 0 deletions ports/cpuinfo/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "cpuinfo",
"version-date": "2021-10-10",
"description": "CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)",
"homepage": "https://github.com/pytorch/cpuinfo",
"supports": "!(arm & windows)",
"dependencies":[
{
"name":"vcpkg-cmake",
"host":true
},
{
"name":"vcpkg-cmake-config",
"host":true
}
],
"features": {
"tools": {
"description": "Build cpuinfo command-line tools"
}
}
}
29 changes: 29 additions & 0 deletions ports/eigen3/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
vcpkg_buildpath_length_warning(37)

vcpkg_from_gitlab(
GITLAB_URL https://gitlab.com
OUT_SOURCE_PATH SOURCE_PATH
REPO libeigen/eigen
REF 3.4.0
SHA512 ba75ecb760e32acf4ceaf27115468e65d4f77c44f8d519b5a13e7940af2c03a304ad433368cb6d55431f307c5c39e2666ab41d34442db3cf441638e51f5c3b6a
)

vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
-DBUILD_TESTING=OFF
-DEIGEN_BUILD_PKGCONFIG=ON
OPTIONS_RELEASE
-DCMAKEPACKAGE_INSTALL_DIR=${CURRENT_PACKAGES_DIR}/share/eigen3
-DPKGCONFIG_INSTALL_DIR=${CURRENT_PACKAGES_DIR}/lib/pkgconfig
OPTIONS_DEBUG
-DCMAKEPACKAGE_INSTALL_DIR=${CURRENT_PACKAGES_DIR}/debug/share/eigen3
-DPKGCONFIG_INSTALL_DIR=${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH share/${PORT})
vcpkg_fixup_pkgconfig()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include ${CURRENT_PACKAGES_DIR}/debug/share)

file(INSTALL ${SOURCE_PATH}/COPYING.README DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
16 changes: 16 additions & 0 deletions ports/eigen3/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "eigen3",
"version-string": "3.4.0",
"description": "C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.",
"homepage": "http://eigen.tuxfamily.org",
"dependencies":[
{
"name":"vcpkg-cmake",
"host":true
},
{
"name":"vcpkg-cmake-config",
"host":true
}
]
}
19 changes: 19 additions & 0 deletions ports/farmhash/farmhashConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function(set_library_target NAMESPACE LIB_NAME DEBUG_LIB_FILE_NAME RELEASE_LIB_FILE_NAME INCLUDE_DIR)
add_library(${NAMESPACE}::${LIB_NAME} STATIC IMPORTED)
set_target_properties(${NAMESPACE}::${LIB_NAME} PROPERTIES
IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
IMPORTED_LOCATION_RELEASE "${RELEASE_LIB_FILE_NAME}"
IMPORTED_LOCATION_DEBUG "${DEBUG_LIB_FILE_NAME}"
INTERFACE_INCLUDE_DIRECTORIES "${INCLUDE_DIR}"
)
set(${NAMESPACE}_${LIB_NAME}_FOUND 1)
endfunction()

get_filename_component(ROOT "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(ROOT "${ROOT}" PATH)
get_filename_component(ROOT "${ROOT}" PATH)

set_library_target("GOOGLE" "farmhash"
"${ROOT}/debug/lib/${CMAKE_STATIC_LIBRARY_PREFIX}farmhash${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${ROOT}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}farmhash${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${ROOT}/include/")
37 changes: 37 additions & 0 deletions ports/farmhash/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#Requires a compiler which understands '__builtin_unreachable':
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_download_distfile(WIN_PR_PATCH
URLS "https://github.com/google/farmhash/pull/40.diff"
FILENAME farmhash-pr-40.patch
SHA512 265f5c15c17da2b88c82e6016a181abe73d2d94492cdb0cba892acf67a9d40815d54fa81e07351254fe2a39aea143b125924db0e7df14aac84a7469a78612cbd
)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO google/farmhash
REF 0d859a811870d10f53a594927d0d0b97573ad06d
SHA512 7bc14931e488464c1cedbc17551fb90a8cec494d0e0860db9df8efff09000fd8d91e01060dd5c5149b1104ac4ac8bf7eb57e5b156b05ef42636938edad1518f1
HEAD_REF master
PATCHES ${WIN_PR_PATCH}
)

if((VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX) AND NOT ENV{CXX_FLAGS}) # This should be a compiler check
set(ENV{CXXFLAGS} "-maes -msse4.2")
endif()
file(REMOVE_RECURSE "${SOURCE_PATH}/configure")
vcpkg_configure_make(
AUTOCONFIG
SOURCE_PATH ${SOURCE_PATH}
)
vcpkg_install_make()
vcpkg_copy_pdbs()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/share" # eliminate unused files
)
file(INSTALL "${SOURCE_PATH}/COPYING"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/farmhashConfig.cmake"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
4 changes: 4 additions & 0 deletions ports/farmhash/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The package farmhash is compatible with built-in CMake targets:

FIND_PACKAGE(farmhash REQUIRED)
TARGET_LINK_LIBRARIES(main PRIVATE GOOGLE::farmhash) for linkage
8 changes: 8 additions & 0 deletions ports/farmhash/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "farmhash",
"version-string": "1.1",
"port-version": 4,
"description": "FarmHash, a family of hash functions.",
"homepage": "https://github.com/google/farmhash",
"supports": "!arm"
}
Loading

0 comments on commit 2a74c70

Please sign in to comment.