executor

package
v0.0.0-...-c0f1611 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommonHeader = func() []byte {
	data, err := src.ReadFile("common.h")
	if err != nil {
		panic(err)
	}
	headers := make(map[string]bool)
	for _, glob := range []string{"*.h", "android/*.h"} {
		files, err := fs.Glob(src, glob)
		if err != nil {
			panic(err)
		}
		for _, file := range files {
			if file == "common.h" || file == "common_ext_example.h" {
				continue
			}
			headers[file] = true
		}
	}

	unused := maps.Clone(headers)
	for {
		relacedSomething := false
		for file := range headers {
			replace := []byte("#include \"" + path.Base(file) + "\"")
			if !bytes.Contains(data, replace) {
				replace = []byte("#include \"android/" + path.Base(file) + "\"")
				if !bytes.Contains(data, replace) {
					continue
				}
			}
			contents, err := src.ReadFile(file)
			if err != nil {
				panic(err)
			}
			data = bytes.ReplaceAll(data, replace, contents)
			delete(unused, file)
			relacedSomething = true
		}
		if !relacedSomething {
			break
		}
	}
	if len(unused) != 0 {
		panic(fmt.Sprintf("can't find includes for %v", unused))
	}

	for _, remove := range []string{
		"(\n|^)\\s*//$",
		"(\n|^)\\s*//[^%].*",
		"\\s*//$",
		"\\s*//[^%].*",
	} {
		data = regexp.MustCompile(remove).ReplaceAll(data, nil)
	}
	return data
}()

CommonHeader contains all executor common headers used by pkg/csource to generate C reproducers. All includes in common.h are transitively replaced with their contents so that it's just a single blob.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL