mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-12 06:45:16 +00:00
tools: Fixes for intrinsic-gen on windows
Fix slash-related issues. Change-Id: I618649578746450df7cb2dcd372c5a778eb719ba Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56776 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
f83e406b37
commit
892aaf377f
45
tools/src/fileutils/fileutils_common.go
Normal file
45
tools/src/fileutils/fileutils_common.go
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright 2021 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package fileutils contains utility functions for files
|
||||
package fileutils
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// GoSourcePath returns the absolute path to the .go file that calls the
|
||||
// function
|
||||
func GoSourcePath() string {
|
||||
_, filename, _, ok := runtime.Caller(1)
|
||||
if !ok {
|
||||
panic("No caller information")
|
||||
}
|
||||
path, err := filepath.Abs(filename)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// ProjectRoot returns the path to the tint project root
|
||||
func ProjectRoot() string {
|
||||
toolRoot := filepath.Dir(GoSourcePath())
|
||||
root, err := filepath.Abs(filepath.Join(toolRoot, "../../.."))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return root
|
||||
}
|
||||
@@ -19,8 +19,6 @@ package fileutils
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// IsExe returns true if the file at path is an executable
|
||||
@@ -31,27 +29,3 @@ func IsExe(path string) bool {
|
||||
}
|
||||
return s.Mode()&0100 != 0
|
||||
}
|
||||
|
||||
// GoSourcePath returns the absolute path to the .go file that calls the
|
||||
// function
|
||||
func GoSourcePath() string {
|
||||
_, filename, _, ok := runtime.Caller(1)
|
||||
if !ok {
|
||||
panic("No caller information")
|
||||
}
|
||||
path, err := filepath.Abs(filename)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// ProjectRoot returns the path to the tint project root
|
||||
func ProjectRoot() string {
|
||||
toolRoot := filepath.Dir(GoSourcePath())
|
||||
root, err := filepath.Abs(filepath.Join(toolRoot, "../../.."))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return root
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user