How to use make method of build Package

Best Syzkaller code snippet using build.make

dumpvars.go

Source:dumpvars.go Github

copy

Full Screen

...30// vars is the list of variables to read. The values will be put in the31// returned map.32//33// variables controlled by soong_ui directly are now returned without needing34// to call into make, to retain compatibility.35func DumpMakeVars(ctx Context, config Config, goals, vars []string) (map[string]string, error) {36 soongUiVars := map[string]func() string{37 "OUT_DIR": func() string { return config.OutDir() },38 "DIST_DIR": func() string { return config.DistDir() },39 }40 makeVars := make([]string, 0, len(vars))41 for _, v := range vars {42 if _, ok := soongUiVars[v]; !ok {43 makeVars = append(makeVars, v)44 }45 }46 var ret map[string]string47 if len(makeVars) > 0 {48 var err error49 ret, err = dumpMakeVars(ctx, config, goals, makeVars, false)50 if err != nil {51 return ret, err52 }53 } else {54 ret = make(map[string]string)55 }56 for _, v := range vars {57 if f, ok := soongUiVars[v]; ok {58 ret[v] = f()59 }60 }61 return ret, nil62}63func dumpMakeVars(ctx Context, config Config, goals, vars []string, write_soong_vars bool) (map[string]string, error) {64 ctx.BeginTrace(metrics.RunKati, "dumpvars")65 defer ctx.EndTrace()66 cmd := Command(ctx, config, "dumpvars",67 config.PrebuiltBuildTool("ckati"),68 "-f", "build/make/core/config.mk",69 "--color_warnings",70 "--kati_stats",71 "dump-many-vars",72 "MAKECMDGOALS="+strings.Join(goals, " "))73 cmd.Environment.Set("CALLED_FROM_SETUP", "true")74 if write_soong_vars {75 cmd.Environment.Set("WRITE_SOONG_VARIABLES", "true")76 }77 cmd.Environment.Set("DUMP_MANY_VARS", strings.Join(vars, " "))78 cmd.Sandbox = dumpvarsSandbox79 output := bytes.Buffer{}80 cmd.Stdout = &output81 pipe, err := cmd.StderrPipe()82 if err != nil {83 ctx.Fatalln("Error getting output pipe for ckati:", err)84 }85 cmd.StartOrFatal()86 // TODO: error out when Stderr contains any content87 status.KatiReader(ctx.Status.StartTool(), pipe)88 cmd.WaitOrFatal()89 ret := make(map[string]string, len(vars))90 for _, line := range strings.Split(output.String(), "\n") {91 if len(line) == 0 {92 continue93 }94 if key, value, ok := decodeKeyValue(line); ok {95 if value, ok = singleUnquote(value); ok {96 ret[key] = value97 ctx.Verboseln(key, value)98 } else {99 return nil, fmt.Errorf("Failed to parse make line: %q", line)100 }101 } else {102 return nil, fmt.Errorf("Failed to parse make line: %q", line)103 }104 }105 if ctx.Metrics != nil {106 ctx.Metrics.SetMetadataMetrics(ret)107 }108 return ret, nil109}110// Variables to print out in the top banner111var BannerVars = []string{112 "PLATFORM_VERSION_CODENAME",113 "PLATFORM_VERSION",114 "LINEAGE_VERSION",115 "TARGET_PRODUCT",116 "TARGET_BUILD_VARIANT",117 "TARGET_BUILD_TYPE",118 "TARGET_BUILD_APPS",119 "TARGET_ARCH",120 "TARGET_ARCH_VARIANT",121 "TARGET_CPU_VARIANT",122 "TARGET_2ND_ARCH",123 "TARGET_2ND_ARCH_VARIANT",124 "TARGET_2ND_CPU_VARIANT",125 "HOST_ARCH",126 "HOST_2ND_ARCH",127 "HOST_OS",128 "HOST_OS_EXTRA",129 "HOST_CROSS_OS",130 "HOST_CROSS_ARCH",131 "HOST_CROSS_2ND_ARCH",132 "HOST_BUILD_TYPE",133 "BUILD_ID",134 "OUT_DIR",135 "AUX_OS_VARIANT_LIST",136 "TARGET_BUILD_PDK",137 "PDK_FUSION_PLATFORM_ZIP",138 "PRODUCT_SOONG_NAMESPACES",139 "WITH_SU",140 "WITH_GMS",141}142func Banner(make_vars map[string]string) string {143 b := &bytes.Buffer{}144 fmt.Fprintln(b, "============================================")145 for _, name := range BannerVars {146 if make_vars[name] != "" {147 fmt.Fprintf(b, "%s=%s\n", name, make_vars[name])148 }149 }150 fmt.Fprint(b, "============================================")151 return b.String()152}153func runMakeProductConfig(ctx Context, config Config) {154 // Variables to export into the environment of Kati/Ninja155 exportEnvVars := []string{156 // So that we can use the correct TARGET_PRODUCT if it's been157 // modified by PRODUCT-*/APP-* arguments158 "TARGET_PRODUCT",159 "TARGET_BUILD_VARIANT",160 "TARGET_BUILD_APPS",161 // compiler wrappers set up by make162 "CC_WRAPPER",163 "CXX_WRAPPER",164 "JAVAC_WRAPPER",165 // ccache settings166 "CCACHE_COMPILERCHECK",167 "CCACHE_SLOPPINESS",168 "CCACHE_BASEDIR",169 "CCACHE_CPP2",170 }171 allVars := append(append([]string{172 // Used to execute Kati and Ninja173 "NINJA_GOALS",174 "KATI_GOALS",175 // To find target/product/<DEVICE>176 "TARGET_DEVICE",177 // So that later Kati runs can find BoardConfig.mk faster178 "TARGET_DEVICE_DIR",179 // Whether --werror_overriding_commands will work180 "BUILD_BROKEN_DUP_RULES",181 // Used to turn on --werror_ options in Kati182 "BUILD_BROKEN_PHONY_TARGETS",183 // Whether to enable the network during the build184 "BUILD_BROKEN_USES_NETWORK",185 // Not used, but useful to be in the soong.log186 "BOARD_VNDK_VERSION",187 "BUILD_BROKEN_ANDROIDMK_EXPORTS",188 "BUILD_BROKEN_DUP_COPY_HEADERS",189 "BUILD_BROKEN_ENG_DEBUG_TAGS",190 }, exportEnvVars...), BannerVars...)191 make_vars, err := dumpMakeVars(ctx, config, config.Arguments(), allVars, true)192 if err != nil {193 ctx.Fatalln("Error dumping make vars:", err)194 }195 env := config.Environment()196 // Print the banner like make does197 if !env.IsEnvTrue("ANDROID_QUIET_BUILD") {198 fmt.Fprintln(ctx.Writer, Banner(make_vars))199 }200 // Populate the environment201 for _, name := range exportEnvVars {202 if make_vars[name] == "" {203 env.Unset(name)204 } else {205 env.Set(name, make_vars[name])206 }207 }208 config.SetKatiArgs(strings.Fields(make_vars["KATI_GOALS"]))209 config.SetNinjaArgs(strings.Fields(make_vars["NINJA_GOALS"]))210 config.SetTargetDevice(make_vars["TARGET_DEVICE"])211 config.SetTargetDeviceDir(make_vars["TARGET_DEVICE_DIR"])212 config.SetPdkBuild(make_vars["TARGET_BUILD_PDK"] == "true")213 config.SetBuildBrokenDupRules(make_vars["BUILD_BROKEN_DUP_RULES"] == "true")214 config.SetBuildBrokenPhonyTargets(make_vars["BUILD_BROKEN_PHONY_TARGETS"] == "true")215 config.SetBuildBrokenUsesNetwork(make_vars["BUILD_BROKEN_USES_NETWORK"] == "true")216}...

Full Screen

Full Screen

make.go

Source:make.go Github

copy

Full Screen

...24// goals can be used to set MAKECMDGOALS, which emulates passing arguments to25// Make without actually building them. So all the variables based on26// MAKECMDGOALS can be read.27//28// extra_targets adds real arguments to the make command, in case other targets29// actually need to be run (like the Soong config generator).30//31// vars is the list of variables to read. The values will be put in the32// returned map.33func DumpMakeVars(ctx Context, config Config, goals, extra_targets, vars []string) (map[string]string, error) {34 ctx.BeginTrace("dumpvars")35 defer ctx.EndTrace()36 cmd := Command(ctx, config, "make",37 "make",38 "--no-print-directory",39 "-f", "build/core/config.mk",40 "dump-many-vars",41 "CALLED_FROM_SETUP=true",42 "BUILD_SYSTEM=build/core",43 "MAKECMDGOALS="+strings.Join(goals, " "),44 "DUMP_MANY_VARS="+strings.Join(vars, " "),45 "OUT_DIR="+config.OutDir())46 cmd.Args = append(cmd.Args, extra_targets...)47 cmd.Sandbox = makeSandbox48 // TODO: error out when Stderr contains any content49 cmd.Stderr = ctx.Stderr()50 output, err := cmd.Output()51 if err != nil {52 return nil, err53 }54 ret := make(map[string]string, len(vars))55 for _, line := range strings.Split(string(output), "\n") {56 if len(line) == 0 {57 continue58 }59 if key, value, ok := decodeKeyValue(line); ok {60 if value, ok = singleUnquote(value); ok {61 ret[key] = value62 ctx.Verboseln(key, value)63 } else {64 return nil, fmt.Errorf("Failed to parse make line: %q", line)65 }66 } else {67 return nil, fmt.Errorf("Failed to parse make line: %q", line)68 }69 }70 return ret, nil71}72func runMakeProductConfig(ctx Context, config Config) {73 // Variables to export into the environment of Kati/Ninja74 exportEnvVars := []string{75 // So that we can use the correct TARGET_PRODUCT if it's been76 // modified by PRODUCT-*/APP-* arguments77 "TARGET_PRODUCT",78 "TARGET_BUILD_VARIANT",79 "TARGET_BUILD_APPS",80 // compiler wrappers set up by make81 "CC_WRAPPER",82 "CXX_WRAPPER",83 "JAVAC_WRAPPER",84 // ccache settings85 "CCACHE_COMPILERCHECK",86 "CCACHE_SLOPPINESS",87 "CCACHE_BASEDIR",88 "CCACHE_CPP2",89 }90 // Variables to print out in the top banner91 bannerVars := []string{92 "PLATFORM_VERSION_CODENAME",93 "PLATFORM_VERSION",94 "TARGET_PRODUCT",95 "TARGET_BUILD_VARIANT",96 "TARGET_BUILD_TYPE",97 "TARGET_BUILD_APPS",98 "TARGET_ARCH",99 "TARGET_ARCH_VARIANT",100 "TARGET_CPU_VARIANT",101 "TARGET_2ND_ARCH",102 "TARGET_2ND_ARCH_VARIANT",103 "TARGET_2ND_CPU_VARIANT",104 "HOST_ARCH",105 "HOST_2ND_ARCH",106 "HOST_OS",107 "HOST_OS_EXTRA",108 "HOST_CROSS_OS",109 "HOST_CROSS_ARCH",110 "HOST_CROSS_2ND_ARCH",111 "HOST_BUILD_TYPE",112 "BUILD_ID",113 "OUT_DIR",114 "AUX_OS_VARIANT_LIST",115 "TARGET_BUILD_PDK",116 "PDK_FUSION_PLATFORM_ZIP",117 }118 allVars := append(append([]string{119 // Used to execute Kati and Ninja120 "NINJA_GOALS",121 "KATI_GOALS",122 // To find target/product/<DEVICE>123 "TARGET_DEVICE",124 }, exportEnvVars...), bannerVars...)125 make_vars, err := DumpMakeVars(ctx, config, config.Arguments(), []string{126 filepath.Join(config.SoongOutDir(), "soong.variables"),127 }, allVars)128 if err != nil {129 ctx.Fatalln("Error dumping make vars:", err)130 }131 // Print the banner like make does132 fmt.Fprintln(ctx.Stdout(), "============================================")133 for _, name := range bannerVars {134 if make_vars[name] != "" {135 fmt.Fprintf(ctx.Stdout(), "%s=%s\n", name, make_vars[name])136 }137 }138 fmt.Fprintln(ctx.Stdout(), "============================================")139 // Populate the environment140 env := config.Environment()141 for _, name := range exportEnvVars {142 if make_vars[name] == "" {143 env.Unset(name)144 } else {145 env.Set(name, make_vars[name])146 }147 }148 config.SetKatiArgs(strings.Fields(make_vars["KATI_GOALS"]))149 config.SetNinjaArgs(strings.Fields(make_vars["NINJA_GOALS"]))150 config.SetTargetDevice(make_vars["TARGET_DEVICE"])151}...

Full Screen

Full Screen

make

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 cmd := exec.Command("go", "build", "-o", "2.exe", "2.go")4 err := cmd.Run()5 if err != nil {6 fmt.Println(err)7 }8}9import (10func main() {11 cmd := exec.Command("go", "build", "-o", "2.exe", "2.go")12 err := cmd.Run()13 if err != nil {14 fmt.Println(err)15 }16}17import (18func main() {19 cmd := exec.Command("go", "build", "-o", "2.exe", "2.go")20 err := cmd.Run()21 if err != nil {22 fmt.Println(err)23 }24}25import (26func main() {27 cmd := exec.Command("go", "build", "-o", "2.exe", "2.go")28 err := cmd.Run()29 if err != nil {30 fmt.Println(err)31 }32}33import (34func main() {35 cmd := exec.Command("go", "build", "-o", "2.exe", "2.go")36 err := cmd.Run()37 if err != nil {38 fmt.Println(err)39 }40}41import (

Full Screen

Full Screen

make

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 cmd := exec.Command("go", "build", "2.go")4 err := cmd.Run()5 if err != nil {6 fmt.Println("Error: ", err)7 }8}9import (10func main() {11 cmd := exec.Command("go", "run", "2.go")12 err := cmd.Run()13 if err != nil {14 fmt.Println("Error: ", err)15 }16}17import (18func main() {19 cmd := exec.Command("go", "install", "2.go")20 err := cmd.Run()21 if err != nil {22 fmt.Println("Error: ", err)23 }24}25import (26func main() {27 cmd := exec.Command("go", "clean", "2.go")28 err := cmd.Run()29 if err != nil {30 fmt.Println("Error: ", err)31 }32}33import (34func main() {35 cmd := exec.Command("go", "get", "2.go")36 err := cmd.Run()37 if err != nil {38 fmt.Println("Error: ", err)39 }40}41import (42func main() {43 cmd := exec.Command("go", "test", "2.go")44 err := cmd.Run()45 if err != nil {46 fmt.Println("Error: ", err)47 }48}49import (50func main() {51 cmd := exec.Command("go", "fmt", "2.go")52 err := cmd.Run()53 if err != nil {54 fmt.Println("Error: ", err)55 }56}

Full Screen

Full Screen

make

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 a = make([]int, 10)4 fmt.Println(a)5}6import (7func main() {8 a = make([]int, 10, 20)9 fmt.Println(a)10}11import (12func main() {13 a = make([]int, 10, 20)14 fmt.Println(a)15 fmt.Println(len(a))16 fmt.Println(cap(a))17}18import (19func main() {20 a = make([]int,

Full Screen

Full Screen

make

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 b := new(build)4 b.make()5}6import "fmt"7func main() {8 b := new(build)9 b.make()10}11import "fmt"12func main() {13 b := new(build)14 b.make()15}16import "fmt"17func main() {18 b := new(build)19 b.make()20}21import "fmt"22func main() {23 b := new(build)24 b.make()25}26import "fmt"27func main() {28 b := new(build)29 b.make()30}31import "fmt"32func main() {33 b := new(build)34 b.make()35}36import "fmt"37func main() {38 b := new(build)39 b.make()40}41import "fmt"42func main() {43 b := new(build)44 b.make()45}46import "fmt"47func main() {48 b := new(build)49 b.make()50}51import "fmt"52func main() {53 b := new(build)54 b.make()55}56import "fmt"57func main() {58 b := new(build)59 b.make()60}61import "fmt"62func main() {63 b := new(build)64 b.make()65}66import "fmt"67func main() {68 b := new(build)69 b.make()70}

Full Screen

Full Screen

make

Using AI Code Generation

copy

Full Screen

1import "fmt"2type Build struct {3}4func (b *Build) make() {5 fmt.Println(b.name, b.age)6}7func main() {8 b := Build{"Dhruv", 25}9 b.make()10}

Full Screen

Full Screen

make

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 build := exec.Command("go", "build", "-o", "output.exe", "1.go", "2.go")4 file, err := os.Create("C:/Users/username/Desktop/output/output.exe")5 if err != nil {6 fmt.Println(err)7 }8 defer file.Close()9 err = build.Run()10 if err != nil {11 fmt.Println(err)12 }13}

Full Screen

Full Screen

make

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 s := make([]int, 5, 10)4 fmt.Println(s)5 s = make([]int, 5)6 fmt.Println(s)7}8import "fmt"9func main() {10 s := make([]int, 5, 10)11 fmt.Println(s)12 s = append(s, 1)13 fmt.Println(s)14}15import "fmt"16func main() {17 s1 := make([]int, 5, 10)18 s2 := make([]int, 3)19 copy(s1, s2)20 fmt.Println(s1)21 fmt.Println(s2)22}23import "fmt"24func main() {25 m := make(map[string]int)26 fmt.Println(m)27 delete(m, "a")28 fmt.Println(m)29}30import "

Full Screen

Full Screen

make

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(runtime.GOOS)4 fmt.Println(runtime.GOARCH)5 fmt.Println(runtime.NumCPU())6}7import "runtime"8runtime.NumCPU()9Go | NumCPU() vs NumGoroutine()10Go | NumCPU() vs NumCgoCall()11Go | NumCPU() vs NumGoroutine() vs NumCgoCall()12Go | NumCPU() vs NumGoroutine() vs NumCgoCall() vs NumThread()13Go | NumCPU() vs NumGoroutine() vs NumCgoCall() vs NumThread() vs NumCPU()14Go | NumCPU() vs NumGoroutine() vs NumCgoCall() vs NumThread() vs NumCPU() vs NumCgoCall()15Go | NumCPU() vs NumGoroutine() vs NumCgoCall() vs NumThread() vs NumCPU() vs NumCgoCall() vs NumGoroutine()16Go | NumCPU() vs NumGoroutine() vs NumCgoCall() vs NumThread() vs NumCPU() vs NumCgoCall() vs NumGoroutine() vs NumThread()17Go | NumCPU() vs NumGoroutine() vs NumCgoCall() vs NumThread() vs NumCPU() vs NumCgoCall() vs NumGoroutine() vs NumThread() vs NumCPU()18Go | NumCPU() vs NumGoroutine() vs NumCgoCall() vs NumThread() vs NumCPU() vs NumCgoCall() vs NumGoroutine() vs NumThread() vs NumCPU() vs NumCgoCall()19Go | NumCPU() vs NumGoroutine() vs NumCgoCall() vs NumThread() vs NumCPU() vs NumCgoCall()

Full Screen

Full Screen

make

Using AI Code Generation

copy

Full Screen

1func main() {2 build := build.NewBuild()3 buildConfig := build.NewBuildConfig()4 buildRequest := build.NewBuildRequest()5 buildRequestOptions := build.NewBuildRequestOptions()6 buildRequestOptionsEnv := build.NewBuildRequestOptionsEnv()7 buildRequestOptionsLogs := build.NewBuildRequestOptionsLogs()8 buildRequestOptionsLogsFollow := build.NewBuildRequestOptionsLogsFollow()9 buildRequestOptionsLogsStream := build.NewBuildRequestOptionsLogsStream()10 buildRequestOptionsLogsTailLines := build.NewBuildRequestOptionsLogsTailLines()11 buildRequestOptionsNodeSelector := build.NewBuildRequestOptionsNodeSelector()12 buildRequestOptionsOutput := build.NewBuildRequestOptionsOutput()13 buildRequestOptionsOutputPushSecret := build.NewBuildRequestOptionsOutputPushSecret()14 buildRequestOptionsOutputTo := build.NewBuildRequestOptionsOutputTo()15 buildRequestOptionsSource := build.NewBuildRequestOptionsSource()16 buildRequestOptionsSourceBinary := build.NewBuildRequestOptionsSourceBinary()17 buildRequestOptionsSourceDockerfile := build.NewBuildRequestOptionsSourceDockerfile()18 buildRequestOptionsSourceGit := build.NewBuildRequestOptionsSourceGit()19 buildRequestOptionsSourceGitRef := build.NewBuildRequestOptionsSourceGitRef()20 buildRequestOptionsSourceGitURI := build.NewBuildRequestOptionsSourceGitURI()21 buildRequestOptionsSourceSecrets := build.NewBuildRequestOptionsSourceSecrets()

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful