Skip to content

Commit

Permalink
[libgo] fix baseline issue (microsoft#19773)
Browse files Browse the repository at this point in the history
* [libgo] fix baseline issue

* [libgo] fix references

* [libgo] fail fast on unsupported archs

* [libgo] fix references

* [libgo] fixes for macOS

* [libgo] fix references

* Minimize the patch

Co-authored-by: PhoebeHui <[email protected]>
  • Loading branch information
cenit and PhoebeHui authored Sep 13, 2021
1 parent 7dc786c commit 259e0bd
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 54 deletions.
127 changes: 114 additions & 13 deletions ports/libgo/cmake.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,114 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dfa9b72..ff9827e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -152,6 +152,8 @@ if (UNIX)

elseif (WIN32)
set_target_properties("${STATIC_T}" PROPERTIES COMPILE_FLAGS "/wd4819 /wd4267")
+ install(TARGETS ${STATIC_T} LIBRARY DESTINATION "lib" ARCHIVE DESTINATION "lib")
+ install(DIRECTORY ${PROJECT_SOURCE_DIR}/libgo/ DESTINATION "include/libgo" FILES_MATCHING PATTERN "*.h")
endif()

if (WIN32)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dfa9b72..e21eee0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,8 +1,9 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.0)

###################################################################################
project(libgo)

+if(0)
enable_language(C ASM)

if (CMAKE_BUILD_TYPE)
@@ -43,34 +44,38 @@ message("-------------- Env ---------------")
message(" CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
message(" CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
message("----------------------------------")
+endif()
+
+enable_language(C CXX ASM)
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+set(INSTALL_BIN_DIR "bin" CACHE PATH "Path where exe and dll will be installed")
+set(INSTALL_LIB_DIR "lib" CACHE PATH "Path where lib will be installed")
+set(INSTALL_INCLUDE_DIR "include/${PROJECT_NAME}" CACHE PATH "Path where headers will be installed")
+set(INSTALL_CMAKE_DIR "share/${PROJECT_NAME}" CACHE PATH "Path where cmake configs will be installed")
+set(RELATIVE_INSTALL_INCLUDE_DIR ${INSTALL_INCLUDE_DIR})
+foreach(p LIB BIN INCLUDE CMAKE)
+ set(var INSTALL_${p}_DIR)
+ if(NOT IS_ABSOLUTE "${${var}}")
+ set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
+ endif()
+endforeach()
+
+set(ENABLE_DEBUGGER 0)
+set(ENABLE_HOOK 0)

configure_file(${PROJECT_SOURCE_DIR}/libgo/common/cmake_config.h.in ${PROJECT_SOURCE_DIR}/libgo/common/cmake_config.h)
message("----------------------------------")

if (UNIX)
- set(CMAKE_CXX_FLAGS "-std=c++11 -fPIC -Wall ${CMAKE_CXX_FLAGS}")
- set(CMAKE_CXX_FLAGS_DEBUG "-g")
- set(CMAKE_CXX_FLAGS_RELEASE "-g -O3 -DNDEBUG")
-
set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS S)
- message("--> select asm source file, please wait about 5 seconds ...")
execute_process(COMMAND "${PROJECT_SOURCE_DIR}/third_party/select_asm.sh" "${PROJECT_SOURCE_DIR}" "jump" OUTPUT_VARIABLE jump_asm_file)
execute_process(COMMAND "${PROJECT_SOURCE_DIR}/third_party/select_asm.sh" "${PROJECT_SOURCE_DIR}" "make" OUTPUT_VARIABLE make_asm_file)
elseif (WIN32)
- # windows platform
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd /EHsc")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT /EHsc")
-
- #set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS asm)
- #file(COPY ${PROJECT_SOURCE_DIR}/third_party/boost.context/libs/context/src/asm/make_x86_64_ms_pe_masm.asm DESTINATION ${PROJECT_SOURCE_DIR}/libgo/context)
- #file(COPY ${PROJECT_SOURCE_DIR}/third_party/boost.context/libs/context/src/asm/jump_x86_64_ms_pe_masm.asm DESTINATION ${PROJECT_SOURCE_DIR}/libgo/context)
endif()

-message("------------ Cxx flags -------------")
-message(" CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}: ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
-message("------------------------------------")
-
include_directories(${PROJECT_SOURCE_DIR})
aux_source_directory(${PROJECT_SOURCE_DIR}/libgo CO_SRC_LIST)
aux_source_directory(${PROJECT_SOURCE_DIR}/libgo/common CO_SRC_LIST)
@@ -97,6 +102,7 @@ else()
aux_source_directory(${PROJECT_SOURCE_DIR}/libgo/netio/disable_hook CO_SRC_LIST)
endif()

+if(0)
set(TARGET "libgo")
set(STATIC_T "libgo_static")
set(STATIC_HOOK "static_hook")
@@ -136,7 +142,6 @@ if (UNIX)
)

set(PROFILE_FLAGS "-pg ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
-
#message("PROFILE_FLAGS: ${PROFILE_FLAGS}")
add_custom_target(profile
COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=PROFILE -DCMAKE_CXX_FLAGS_PROFILE=\\'${PROFILE_FLAGS}\\' ${CMAKE_SOURCE_DIR}
@@ -160,3 +165,27 @@ if (WIN32)
add_subdirectory(${PROJECT_SOURCE_DIR}/tutorial)
endif()
endif()
+endif()
+
+list(APPEND CO_SRC_LIST ${jump_asm_file})
+list(APPEND CO_SRC_LIST ${make_asm_file})
+add_library(${PROJECT_NAME} ${CO_SRC_LIST})
+target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS})
+if (WIN32)
+ target_link_libraries(${PROJECT_NAME} ws2_32)
+ set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/wd4819 /wd4267")
+endif()
+
+install(TARGETS ${PROJECT_NAME}
+ EXPORT "${PROJECT_NAME}Config"
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ RUNTIME DESTINATION bin)
+
+install(DIRECTORY ${PROJECT_SOURCE_DIR}/libgo/
+ DESTINATION ${INSTALL_INCLUDE_DIR}
+ FILES_MATCHING PATTERN "*.h")
+
+install(EXPORT "${PROJECT_NAME}Config"
+ NAMESPACE libgo::
+ DESTINATION "${INSTALL_CMAKE_DIR}")
25 changes: 0 additions & 25 deletions ports/libgo/libgo-config.cmake

This file was deleted.

10 changes: 4 additions & 6 deletions ports/libgo/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vcpkg_fail_port_install(ON_ARCH "arm" ON_TARGET "uwp")
vcpkg_fail_port_install(ON_ARCH "arm" "arm64" ON_TARGET "uwp")
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
Expand All @@ -7,7 +7,8 @@ vcpkg_from_github(
REF 5d4f36508e8eb2d5aa17cf37cd951dc91da23096 #v3.1
SHA512 0f281f58116148ba1dd3904febbc391d47190f8e148b70bed7c4b7e6cb3efa5e41e2b7be4832ceeb805996e085f4c2d89fd0cf3b0651e037b32758d6a441411b
HEAD_REF master
PATCHES cmake.patch
PATCHES
cmake.patch
)

vcpkg_from_github(
Expand All @@ -28,6 +29,7 @@ vcpkg_cmake_configure(
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/libgo/netio/disable_hook")
Expand All @@ -39,8 +41,4 @@ else()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/libgo/netio/unix")
endif()

# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
file(INSTALL "${CURRENT_PORT_DIR}/libgo-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
5 changes: 0 additions & 5 deletions ports/libgo/usage

This file was deleted.

6 changes: 5 additions & 1 deletion ports/libgo/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{
"name": "libgo",
"version": "3.1",
"port-version": 2,
"port-version": 3,
"description": "The best stackful coroutine by c++11.",
"homepage": "https://github.com/yyzybb537/libgo",
"supports": "!(arm | uwp)",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
3 changes: 0 additions & 3 deletions scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,6 @@ libgit2:x64-uwp=fail
libgo:arm-uwp=fail
libgo:x64-uwp=fail
libgo:arm64-windows=fail
libgo:x64-windows=fail
libgo:x86-windows=fail
libgpod:arm64-windows=fail
libgpod:arm-uwp=fail
libgpod:x64-uwp=fail
Expand Down Expand Up @@ -1711,7 +1709,6 @@ fastcgi:x64-windows-static-md=fail
gmp:x64-windows-static-md=fail
ijg-libjpeg:x64-windows-static-md=fail
libcerf:x64-windows-static-md=fail
libgo:x64-windows-static-md=fail
libmicrohttpd:x64-windows-static-md=fail
libspatialite:x64-windows-static-md=fail
linenoise-ng:x64-windows-static-md=fail
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -3298,7 +3298,7 @@
},
"libgo": {
"baseline": "3.1",
"port-version": 2
"port-version": 3
},
"libgpg-error": {
"baseline": "1.42",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/libgo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "120510985335ea4bd1b8a91982d0f95842e43ba3",
"version": "3.1",
"port-version": 3
},
{
"git-tree": "1158e6c06fa6cb413bf12c04065ff58b8930c474",
"version": "3.1",
Expand Down

0 comments on commit 259e0bd

Please sign in to comment.