Giter Club home page Giter Club logo

Comments (2)

xhd2015 avatar xhd2015 commented on September 25, 2024

The target func declaration to be match against:

{
    "kind": "func|var|const",
    "pkg":"pkg",
    "name":"xxx",
    "main_module": true|false,
    "closure": true|false,
    "stdlib": true|false,
    "exported": true|false,
    "generic": true|false
}

So the json config is a set of rules to check if a target will be included , excluded or remain default.


for _ target  := range targets {
  var result string
  for _, rule := range rules {
       ok = match(rule, target)
       if ok != "" {
           result = rule.action
            break
       }
  }
  if result == "" {
        result = checkDefault()
  }
   if result == "exclude" {
        remove target
  }
}

The json config then becomes a list of rules:

{
    "rules":[{pkg:"*", func:"*", closure: "true|false", stdlib:"true|false|*", main_module: true|false, action:"exclude"}]
}

Examples:

  • filter out all closures:
{
    "rules": [{closure:"true", action:"exclude"}]
}
  • include only main modules' functions
{
    "rules": [{main_module:"true", action:"include"},{any:true, action:"exclude"}]
}

Implementation of match(rule,target):

func match(rule Rule,target Target) bool {
    if rule.Any {
        return true 
    }
    if rule.MainModule != nil && *rule.MainModule != target.MainModule {
         return false
    }
    // can use comma to denote a string list, meaning any matches
    if rule.Pkg != "" && !matchWild(rule.Pkg, target.Pkg){
         return false
    }
    ...
    return true
}

And since this affects the compile results, so it's content should be part of the build cache. A rough design is to append md5 of the config to the build cache path.

from xgo.

xhd2015 avatar xhd2015 commented on September 25, 2024

A new option is added: --options-from-file options.json

from xgo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.