mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-11 06:29:11 +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:
parent
f83e406b37
commit
892aaf377f
@ -106,7 +106,7 @@ func run() error {
|
|||||||
writeFile := func(relpath, body string) error {
|
writeFile := func(relpath, body string) error {
|
||||||
// Write the common file header
|
// Write the common file header
|
||||||
sb := strings.Builder{}
|
sb := strings.Builder{}
|
||||||
sb.WriteString(fmt.Sprintf(header, relTmplPath, defProjectRelPath))
|
sb.WriteString(fmt.Sprintf(header, filepath.ToSlash(relTmplPath), filepath.ToSlash(defProjectRelPath)))
|
||||||
sb.WriteString(body)
|
sb.WriteString(body)
|
||||||
content := sb.String()
|
content := sb.String()
|
||||||
abspath := filepath.Join(filepath.Dir(tmplPath), relpath)
|
abspath := filepath.Join(filepath.Dir(tmplPath), relpath)
|
||||||
|
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 (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsExe returns true if the file at path is an executable
|
// 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
|
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
|
|
||||||
}
|
|
||||||
|
@ -192,6 +192,7 @@ func (c Config) shouldExamine(root, absPath string) bool {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
relPath = filepath.ToSlash(relPath) // Canonicalize
|
||||||
|
|
||||||
res := false
|
res := false
|
||||||
for _, rule := range c.Paths {
|
for _, rule := range c.Paths {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user