forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Disable Stats Timer (fixes #92) - Include revision as part of product version in addition to suffix (fixes #91) - Include license file in NuGet (fixes #98) - Add Source Link to linker (fixes #102) This is ported from the v0.11 branch. We bump the version up to 0.12 (even though no such version exists in upstream) to signal we're no longer compatible with 0.11 (and RN 0.68).
- Loading branch information
Showing
6 changed files
with
222 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
# Copied from https://github.com/microsoft/Azure-Kinect-Sensor-SDK/blob/develop/cmake/GitCommands.cmake | ||
|
||
find_package(Git REQUIRED QUIET) | ||
if (NOT Git_FOUND) | ||
message(FATAL_ERROR "Unable to find git, which is needed for versioning") | ||
endif() | ||
|
||
function(get_git_dir DIRECTORY OUTPUT_VAR) | ||
execute_process( | ||
COMMAND | ||
${GIT_EXECUTABLE} rev-parse --git-dir | ||
WORKING_DIRECTORY | ||
${DIRECTORY} | ||
RESULT_VARIABLE | ||
GIT_DIR_RESULT | ||
OUTPUT_VARIABLE | ||
GIT_DIR_OUTPUT | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
# Allow to fail | ||
set(${OUTPUT_VAR} ${GIT_DIR_OUTPUT} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(get_git_current_hash DIRECTORY OUTPUT_VAR) | ||
execute_process( | ||
COMMAND | ||
${GIT_EXECUTABLE} rev-parse --verify HEAD | ||
WORKING_DIRECTORY | ||
${DIRECTORY} | ||
RESULT_VARIABLE | ||
GIT_CURRENT_HASH_RESULT | ||
OUTPUT_VARIABLE | ||
GIT_CURRENT_HASH_OUTPUT | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
if (NOT ("${GIT_CURRENT_HASH_RESULT}" STREQUAL "0")) | ||
message(${GIT_CURRENT_HASH_OUTPUT}) | ||
message(FATAL_ERROR "Failed to get ${DIRECTORY} git hash") | ||
endif() | ||
|
||
set(${OUTPUT_VAR} ${GIT_CURRENT_HASH_OUTPUT} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(get_git_remote_url DIRECTORY OUTPUT_VAR) | ||
execute_process( | ||
COMMAND | ||
${GIT_EXECUTABLE} config --get remote.origin.url | ||
RESULT_VARIABLE | ||
GIT_REMOTE_URL_RESULT | ||
OUTPUT_VARIABLE | ||
GIT_REMOTE_URL_OUTPUT | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
WORKING_DIRECTORY | ||
${DIRECTORY} | ||
) | ||
|
||
if (NOT ("${GIT_REMOTE_URL_RESULT}" STREQUAL "0")) | ||
message(${GIT_REMOTE_URL_OUTPUT}) | ||
message(FATAL_ERROR "Failed to get ${DIRECTORY} git remote") | ||
endif() | ||
|
||
set(${OUTPUT_VAR} ${GIT_REMOTE_URL_OUTPUT} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(run_git_submodule_foreach CMD DIRECTORY OUTPUT_VALUE) | ||
execute_process( | ||
COMMAND | ||
${GIT_EXECUTABLE} submodule foreach --quiet --recursive "${CMD}" | ||
RESULT_VARIABLE | ||
GIT_SUBMODULE_CMD_RESULT | ||
OUTPUT_VARIABLE | ||
GIT_SUBMODULE_CMD_OUTPUT | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
WORKING_DIRECTORY | ||
${DIRECTORY} | ||
) | ||
|
||
if (NOT ("${GIT_SUBMODULE_CMD_RESULT}" STREQUAL "0")) | ||
message(${GIT_SUBMODULE_CMD_OUTPUT}) | ||
message(FATAL_ERROR "Failed to run git submodule foreach command: ${CMD} in ${DIRECTORY}") | ||
endif() | ||
set(${OUTPUT_VALUE} ${GIT_SUBMODULE_CMD_OUTPUT} PARENT_SCOPE) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Copied from https://github.com/microsoft/Azure-Kinect-Sensor-SDK/blob/develop/cmake/SourceLink.cmake | ||
# CMake Module to generate Source Link JSON for the MSVC compiler | ||
# | ||
# Microsoft defines Source Link as the following: | ||
# | ||
# > Source Link is a developer productivity feature that allows unique | ||
# > information about an assembly's original source code to be embedded in its | ||
# > PDB during compilation. | ||
# https://github.com/dotnet/designs/blob/master/accepted/diagnostics/source-link.md | ||
# | ||
# Specifically, this script will embedded information into the PDB of where to | ||
# download the source code from. This will allow developers to use the PDB without | ||
# the source located on disk. | ||
# | ||
# This script currently only works with GitHub but could be extended to support | ||
# other source control servers. Any server which hosts their code as raw source | ||
# over HTTP should work. | ||
# | ||
include(GitCommands) | ||
|
||
# Warn if this is included and the compiler doesn't support source link | ||
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") | ||
if ("${CMAKE_C_COMPILER_VERSION}" VERSION_GREATER_EQUAL "19.20") | ||
# Good to go! | ||
elseif("${CMAKE_C_COMPILER_VERSION}" VERSION_GREATER_EQUAL "19.14") | ||
message(STATUS "SourceLink enabled but case insensitive") | ||
else() | ||
message(WARNING "SourceLink will not work on version of MSVC less than 19.14") | ||
endif() | ||
else() | ||
message(WARNING "SourceLink will not work on the ${CMAKE_C_COMPILER_ID} compiler") | ||
endif() | ||
|
||
# REPO_ROOT is the path to the repository where code it stored. | ||
# | ||
# SOURCE_LINK_JSON_PATH is the file to output the json | ||
function(source_link REPO_ROOT SOURCE_LINK_JSON_PATH) | ||
if (NOT (IS_DIRECTORY ${REPO_ROOT})) | ||
message(FATAL_ERROR "\"${REPO_ROOT}\" is not a directory") | ||
endif() | ||
|
||
get_git_remote_url(${REPO_ROOT} GIT_REMOTE) | ||
get_git_current_hash(${REPO_ROOT} GIT_CURRENT_HASH) | ||
|
||
build_source_link_rule(${REPO_ROOT} ${GIT_REMOTE} ${GIT_CURRENT_HASH} ROOT_RULE) | ||
|
||
set(SOURCE_LINK_RULES) | ||
list(APPEND SOURCE_LINK_RULES ${ROOT_RULE}) | ||
|
||
# Also build rules for submodules | ||
run_git_submodule_foreach("echo $displaypath,$sha1,`git config --get remote.origin.url`" ${REPO_ROOT} SUBMODULE_INFO) | ||
|
||
if (NOT ("${SUBMODULE_INFO}" STREQUAL "")) | ||
# Turn output of new lines into a CMake list | ||
string(REPLACE "\r\n" ";" SUBMODULE_INFO ${SUBMODULE_INFO}) | ||
string(REPLACE "\n" ";" SUBMODULE_INFO ${SUBMODULE_INFO}) | ||
|
||
foreach(ITEM ${SUBMODULE_INFO}) | ||
# Turn each line into a list of path;hash;url | ||
string(REPLACE "," ";" SUBMODULE ${ITEM}) | ||
list(GET SUBMODULE 0 LOCAL_PATH) | ||
list(GET SUBMODULE 1 CURRENT_HASH) | ||
list(GET SUBMODULE 2 REMOTE) | ||
string(CONCAT LOCAL_PATH "${REPO_ROOT}/" ${LOCAL_PATH}) | ||
build_source_link_rule(${LOCAL_PATH} ${REMOTE} ${CURRENT_HASH} RULE) | ||
list(APPEND SOURCE_LINK_RULES ${RULE}) | ||
endforeach() | ||
endif() | ||
|
||
set(OUTPUT) | ||
string(APPEND OUTPUT "{\n") | ||
string(APPEND OUTPUT "\"documents\": {\n") | ||
string(JOIN ",\n" EXPANDED_RULES ${SOURCE_LINK_RULES}) | ||
string(APPEND OUTPUT "${EXPANDED_RULES}\n") | ||
string(APPEND OUTPUT "}\n") | ||
string(APPEND OUTPUT "}\n") | ||
|
||
file(WRITE ${SOURCE_LINK_JSON_PATH} ${OUTPUT}) | ||
|
||
endfunction() | ||
|
||
function(build_source_link_rule LOCAL_PATH GIT_REMOTE GIT_CURRENT_HASH OUTPUT) | ||
# Verify local path exists | ||
if (NOT (IS_DIRECTORY ${LOCAL_PATH})) | ||
message(FATAL_ERROR "${LOCAL_PATH} is not a directory") | ||
endif() | ||
|
||
# Change local path to native path | ||
file(TO_NATIVE_PATH "${LOCAL_PATH}/*" LOCAL_PATH) | ||
# Escape any backslashes for JSON | ||
string(REPLACE "\\" "\\\\" LOCAL_PATH ${LOCAL_PATH}) | ||
|
||
# Verify this is a GitHub URL | ||
# In the future we could support other source servers but currently they | ||
# are not supported | ||
if (NOT ("${GIT_REMOTE}" MATCHES "https://github\\.com")) | ||
message(STATUS "Unable to sourcelink remote: \"${GIT_REMOTE}\". Unknown host") | ||
return() | ||
endif() | ||
|
||
string(REPLACE ".git" "" RAW_GIT_URL ${GIT_REMOTE}) | ||
string(REPLACE "github.com" "raw.githubusercontent.com" RAW_GIT_URL ${RAW_GIT_URL}) | ||
string(CONCAT RAW_GIT_URL ${RAW_GIT_URL} "/${GIT_CURRENT_HASH}/*") | ||
|
||
set(${OUTPUT} "\"${LOCAL_PATH}\" : \"${RAW_GIT_URL}\"" PARENT_SCOPE) | ||
|
||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters