Opened 10 years ago

Closed 10 years ago

#3899 closed bug (invalid)

Commandline argument doesn't override UserBuildConfig

Reported by: haiqu Owned by: bonefish
Priority: normal Milestone: R1
Component: Build System Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: x86

Description

This seems to be an issue with Jam. I have just done a complete build targeting a blank partition with:

HAIKU_INSTALL_DIR=/Haiku2 jam -q install-haiku

but the setting in my UserBuildConfig was HAIKU_INSTALL_DIR=/Haiku and the build tried to install to /Haiku which was unexpected behaviour. I fully realize this may be the default behaviour for Jam, but if there's a way to fix it I'd like that, since it goes against proper safe program behaviour.

Change History (3)

in reply to:  description comment:1 by VinDuv, 10 years ago

Replying to haiqu:

since it goes against proper safe program behaviour.

I don't really agree with this.
What if Haiku was using variable names like IMAGE_SIZE, INSTALL_DIR, ROOT_USER_NAME... in the build system ? They could be easily overriden by some environment variables, resulting in platform-dependant misbehaviour.
Also, Jam works on many platforms, and I'm not sure if there is a portable way to get every environment variables on all of them. So IMHO, the current behaviour of jam — overriding build variables with -s, for instance like this : jam -sHAIKU_INSTALL_DIR=/Haiku2 ... — is fine.

comment:2 by stippi, 10 years ago

I think there is an assignment statement in jam which only assigns the variable if it doesn't already have a value. I would need to look up some Jamfiles we have, but maybe someone else can chime in...

comment:3 by bonefish, 10 years ago

Resolution: invalid
Status: newclosed

If you want jam variables to be overridable via environmental vars, you have to use the "?=" assignment operator in your UserBuildConfig -- it assigns only, if the variable isn't set yet. Build profiles always set the HAIKU_{IMAGE,INSTALL}_* variables, not allowing overrides. It should be possible to work around by saving the original environment variable and restoring its value after defining the build profile like this:

local savedInstallDir = $(HAIKU_INSTALL_DIR) ;
...
DefineBuildProfile ...
...
if $(savedInstallDir) {
  HAIKU_INSTALL_DIR = $(savedInstallDir) ;
}
Note: See TracTickets for help on using tickets.