From c6b702c86ecb3ccd16a95fb3a0048da9ea362337 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Thu, 19 Sep 2024 00:11:27 -0700 Subject: Use GITHUB_TOKEN if set (#5070) * Use GITHUB_TOKEN if set We have been having an error from Github saying that API rate limit exceeded for IP. It hits the limit more often if your public IP is shared by many other collegues. {"message":"API rate limit exceeded for 216.228.112.22. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"} The suggested solution from GitHub is to use gh.exe tool with "auth login" arguments. It will store a token and allow us to use API more than the limit set for IP without token. However, our cmake build doesn't use gh.exe and API is called via REST. This commit adds an extra header to the HTTP request with the infomration of the github token if the value is. Usage: cmake.exe --preset vs2019 -DSLANG_GITHUB_TOKEN=your_token_here * Adding a warning message to use LANG_GITHUB_TOKEN --------- Co-authored-by: Yong He --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index e1225022e..6580e2680 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,6 +101,8 @@ option(SLANG_ENABLE_TESTS "Enable test targets, some tests may require SLANG_ENA option(SLANG_ENABLE_EXAMPLES "Enable example targets, requires SLANG_ENABLE_GFX" ON) option(SLANG_ENABLE_REPLAYER "Enable slang-replay tool" ON) +option(SLANG_GITHUB_TOKEN "Use a given token value for accessing Github REST API" "") + enum_option( SLANG_LIB_TYPE # Default @@ -136,7 +138,7 @@ enum_option( if(SLANG_SLANG_LLVM_FLAVOR MATCHES FETCH_BINARY) # If the user didn't specify a URL, find the best one now if(NOT SLANG_SLANG_LLVM_BINARY_URL) - get_best_slang_binary_release_url(url) + get_best_slang_binary_release_url("${SLANG_GITHUB_TOKEN}" url) if(NOT DEFINED url) message(FATAL_ERROR "Unable to find binary release for slang-llvm, please set a different SLANG_SLANG_LLVM_FLAVOR or set SLANG_SLANG_LLVM_BINARY_URL manually") endif() -- cgit v1.2.3