mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Go: recognize CODEQL_PATH_TRANSFORMER env var
This commit is contained in:
@@ -273,7 +273,7 @@ func createPathTransformerFile(newdir string) *os.File {
|
||||
log.Fatalf("Failed to chdir into %s: %s\n", newdir, err.Error())
|
||||
}
|
||||
|
||||
// set up SEMMLE_PATH_TRANSFORMER to ensure paths in the source archive and the snapshot
|
||||
// set up CODEQL_PATH_TRANSFORMER to ensure paths in the source archive and the snapshot
|
||||
// match the original source location, not the location we moved it to
|
||||
pt, err := os.CreateTemp("", "path-transformer")
|
||||
if err != nil {
|
||||
@@ -292,9 +292,9 @@ func writePathTransformerFile(pt *os.File, realSrc, root, newdir string) {
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to close path transformer file: %s.", err.Error())
|
||||
}
|
||||
err = os.Setenv("SEMMLE_PATH_TRANSFORMER", pt.Name())
|
||||
err = os.Setenv("CODEQL_PATH_TRANSFORMER", pt.Name())
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to set SEMMLE_PATH_TRANSFORMER environment variable: %s.\n", err.Error())
|
||||
log.Fatalf("Unable to set CODEQL_PATH_TRANSFORMER environment variable: %s.\n", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,7 +501,8 @@ func installDependenciesAndBuild() {
|
||||
|
||||
srcdir := getSourceDir()
|
||||
|
||||
// we set `SEMMLE_PATH_TRANSFORMER` ourselves in some cases, so blank it out first for consistency
|
||||
// we set `CODEQL_PATH_TRANSFORMER` ourselves in some cases, so blank it out first for consistency
|
||||
os.Setenv("CODEQL_PATH_TRANSFORMER", "")
|
||||
os.Setenv("SEMMLE_PATH_TRANSFORMER", "")
|
||||
|
||||
// determine how to install dependencies and whether a GOPATH needs to be set up before
|
||||
|
||||
1
go/extractor/srcarchive/BUILD.bazel
generated
1
go/extractor/srcarchive/BUILD.bazel
generated
@@ -10,6 +10,7 @@ go_library(
|
||||
],
|
||||
importpath = "github.com/github/codeql-go/extractor/srcarchive",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//go/extractor/util"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
|
||||
@@ -7,12 +7,14 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/github/codeql-go/extractor/util"
|
||||
)
|
||||
|
||||
var pathTransformer *ProjectLayout
|
||||
|
||||
func init() {
|
||||
pt := os.Getenv("SEMMLE_PATH_TRANSFORMER")
|
||||
pt := util.Getenv("CODEQL_PATH_TRANSFORMER", "SEMMLE_PATH_TRANSFORMER")
|
||||
if pt != "" {
|
||||
ptf, err := os.Open(pt)
|
||||
if err != nil {
|
||||
@@ -69,7 +71,7 @@ func srcArchive() (string, error) {
|
||||
return srcArchive, nil
|
||||
}
|
||||
|
||||
// TransformPath applies the transformations specified by `SEMMLE_PATH_TRANSFORMER` (if any) to the
|
||||
// TransformPath applies the transformations specified by `CODEQL_PATH_TRANSFORMER` (if any) to the
|
||||
// given path
|
||||
func TransformPath(path string) string {
|
||||
if pathTransformer != nil {
|
||||
|
||||
Reference in New Issue
Block a user