GithubHelp home page GithubHelp logo

Comments (6)

Kojoley avatar Kojoley commented on August 17, 2024

You are using OS shell and observing OS command parsing differences, that's obviously not SHELL fault.
I guess you are looking for a cross-platform way to create a file with some content, but unfortunately I don't think B2 provides such an function currently.

from b2.

grisumbras avatar grisumbras commented on August 17, 2024
import print ;
make a.txt : : @write ;
rule write ( target : srcs * : props : ) {
  print.output $(target) ;
  print.text "line1" "line2" : overwrite ;
}

from b2.

fasxmut avatar fasxmut commented on August 17, 2024
import print ;
make a.txt : : @write ;
rule write ( target : srcs * : props : ) {
  print.output $(target) ;
  print.text "line1" "line2" : overwrite ;
}

Thanks I tried. But I can't execute your script as it said args error. And it seems that make rule can not pass variables to actions except file names.
And it is weird that the print.text only works if the target is console, not works on output file.

from b2.

grisumbras avatar grisumbras commented on August 17, 2024

My snippet had a typo (a didn't test it when I posted it). The correct jam script that creates a project-config.jam in current directory is

make project-config.jam : : @write : <location>. ;

rule write ( target : srcs * : props * : ) {
  if "$(var2)" {
    echo "var2 is $(var2)" ;
  } else {
    print.output $(target) ;
    print.text
        "constant var2 : $(var) ;"
        ""
      : overwrite
      ;
  }
}

I did't understand your remarks about passing variables to rules and print.text not working on files, though.

from b2.

fasxmut avatar fasxmut commented on August 17, 2024

My snippet had a typo (a didn't test it when I posted it). The correct jam script that creates a project-config.jam in current directory is

make project-config.jam : : @write : <location>. ;

rule write ( target : srcs * : props * : ) {
  if "$(var2)" {
    echo "var2 is $(var2)" ;
  } else {
    print.output $(target) ;
    print.text
        "constant var2 : $(var) ;"
        ""
      : overwrite
      ;
  }
}

I did't understand your remarks about passing variables to rules and print.text not working on files, though.

I try it again this time, your jamfile script has no errors, and the print.text works on files too.
The passing variables to rules I mean, the rule or actions take variables from the arguments (just like function parameters), not take variables from global scope.

from b2.

grafikrobot avatar grafikrobot commented on August 17, 2024

The passing variables to rules I mean, the rule or actions take variables from the arguments (just like function parameters), not take variables from global scope.

@fasxmut target actions, which is what the print utility module is using for the file output, only take inputs through variables. They can be either global or bound (https://www.bfgroup.xyz/b2/manual/main/index.html#jam.language.rules.action_modifiers). What @grisumbras demonstrated accepting rule arguments like your original example. Can you explain in more details what you are trying to accomplish.

from b2.

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.