* Moved jam argument processing to new build/jam/CommandLineArguments.

* Check the first argument for "help" as well. If given print a somewhat
  helpful text. Consider this my excuse to close ticket #1883. :-)
* Track available and added optional packages and fail, if an optional package
  is requested that doesn't exist. Closes ticket #3332.
* Check for duplicate build profile definitions and fail if encountered.
  Closes ticket #3333.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29298 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2009-02-23 22:33:09 +00:00
parent 24a7f4c285
commit 37aefc9c6f
6 changed files with 136 additions and 54 deletions

14
Jamfile
View File

@ -161,3 +161,17 @@ include [ FDirName $(HAIKU_BUILD_RULES_DIR) FloppyBootImage ] ;
include [ FDirName $(HAIKU_BUILD_RULES_DIR) CDBootImage ] ;
include [ FDirName $(HAIKU_BUILD_RULES_DIR) CDBootPPCImage ] ;
include [ FDirName $(HAIKU_BUILD_RULES_DIR) HaikuCD ] ;
# Check whether all requested optional packages do actually exist.
local package ;
local packageError ;
for package in $(HAIKU_ADDED_OPTIONAL_PACKAGES) {
if ! [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_EXISTS) ] {
Echo "ERROR: Requested optional package \"$(package)\" does not"
"exist." ;
packageError = 1 ;
}
}
if $(packageError) {
Exit ;
}

View File

@ -31,6 +31,7 @@ include BuildConfig ;
include [ FDirName $(HAIKU_BUILD_RULES_DIR) HelperRules ] ;
include [ FDirName $(HAIKU_BUILD_RULES_DIR) MathRules ] ;
include [ FDirName $(HAIKU_BUILD_RULES_DIR) BeOSRules ] ;
include [ FDirName $(HAIKU_BUILD_RULES_DIR) CommandLineArguments ] ;
include [ FDirName $(HAIKU_BUILD_RULES_DIR) ConfigRules ] ;
include [ FDirName $(HAIKU_BUILD_RULES_DIR) DocumentationRules ] ;
include [ FDirName $(HAIKU_BUILD_RULES_DIR) FileRules ] ;

View File

@ -64,58 +64,8 @@ HAIKU_DEFAULT_CD_NAME = haiku-cd.iso ;
HAIKU_DEFAULT_CD_DIR = $(HAIKU_OUTPUT_DIR) ;
HAIKU_DEFAULT_CD_LABEL = Haiku ;
# analyze an optionally replace jam's target parameters
HAIKU_ORIGINAL_JAM_TARGETS = $(JAM_TARGETS) ;
HAIKU_BUILD_PROFILE = ;
if $(JAM_TARGETS) {
switch $(JAM_TARGETS[1]) {
# If the target to be built is "all" (i.e. the default) and we're in
# the output directory, the root directory of the build system, or
# in "src/", we change the target to be built to "haiku-image".
case all : {
if ! $(INVOCATION_SUBDIR) || $(INVOCATION_SUBDIR) = src {
JAM_TARGETS = haiku-image ;
}
}
# The "run" target allows for running arbitrary command lines containing
# build system targets, which are built and replaced accordingly.
case run : {
if $(JAM_TARGETS[2]) {
JAM_TARGETS = [ RunCommandLine $(JAM_TARGETS[2-]) ] ;
} else {
Exit "\"jam run\" requires parameters!" ;
}
}
# A target starting with "@" is a build profile.
case @* : {
HAIKU_BUILD_PROFILE = [ Match "@(.*)" : $(JAM_TARGETS[1]) ] ;
HAIKU_BUILD_PROFILE_ACTION = $(JAM_TARGETS[2]:E=build) ;
HAIKU_BUILD_PROFILE_PARAMETERS = $(JAM_TARGETS[3-]) ;
HAIKU_BUILD_PROFILE_DEFINED = ;
}
case * : {
# "update-image", "update-vmware-image", and "update-install"
# targets allow for updating only specific targets in the
# image/installation dir.
if $(JAM_TARGETS[1]) in update-image update-vmware-image
update-install {
SetUpdateHaikuImageOnly 1 ;
HAIKU_INCLUDE_IN_IMAGE on $(JAM_TARGETS[2-]) = 1 ;
if $(JAM_TARGETS[1]) = update-image {
JAM_TARGETS = haiku-image ;
} else if $(JAM_TARGETS[1]) = update-vmware-image {
JAM_TARGETS = haiku-vmware-image ;
} else {
JAM_TARGETS = install-haiku ;
}
}
}
}
}
# analyze and optionally replace jam's target parameters
ProcessCommandLineArguments ;
# include Timezones/libgccObjects

View File

@ -0,0 +1,95 @@
# Rules related to processing of jam command line arguments.
rule ProcessCommandLineArguments
{
# analyze and optionally replace jam's target parameters
HAIKU_ORIGINAL_JAM_TARGETS = $(JAM_TARGETS) ;
HAIKU_BUILD_PROFILE = ;
if $(JAM_TARGETS) {
switch $(JAM_TARGETS[1]) {
# If the target to be built is "all" (i.e. the default) and we're in
# the output directory, the root directory of the build system, or
# in "src/", we change the target to be built to "haiku-image".
case all : {
if ! $(INVOCATION_SUBDIR) || $(INVOCATION_SUBDIR) = src {
JAM_TARGETS = haiku-image ;
}
}
# Print usage text.
case help : {
Echo "Individual targets (applications, libraries, drivers,...)"
" can be built by just" ;
Echo "passing them as arguments to jam. The recommended method"
"to build or update a" ;
Echo "Haiku image or installation is to use a build profile"
"with one of the build" ;
Echo "profile actions. Typical command lines using a build"
"profile looks like this:" ;
Echo " jam @image" ;
Echo " jam @install update libbe.so" ;
Echo " jam @vmware-image mount" ;
Echo ;
Echo "Default build profiles:" ;
Echo " image - A raw disk image." ;
Echo " vmware-image - A VMware disk image." ;
Echo " install - A Haiku installation in a directory." ;
Echo ;
Echo "Build profile actions:" ;
Echo " build - Build a Haiku"
"image/installation. This is the default" ;
Echo " action, i.e. it can be"
"omitted." ;
Echo " update <target> ... - Update the specified targets in"
" the Haiku" ;
Echo " image/installation." ;
Echo " update-all - Update all targets in the Haiku"
"image/installation." ;
Echo " mount - Mount the Haiku image in the"
"bfs_shell." ;
Echo ;
Echo "For more details on how to customize Haiku builds read" ;
Echo "build/jam/UserBuildConfig.ReadMe." ;
Exit ;
}
# The "run" target allows for running arbitrary command lines
# containing build system targets, which are built and replaced
# accordingly.
case run : {
if $(JAM_TARGETS[2]) {
JAM_TARGETS = [ RunCommandLine $(JAM_TARGETS[2-]) ] ;
} else {
Exit "\"jam run\" requires parameters!" ;
}
}
# A target starting with "@" is a build profile.
case @* : {
HAIKU_BUILD_PROFILE = [ Match "@(.*)" : $(JAM_TARGETS[1]) ] ;
HAIKU_BUILD_PROFILE_ACTION = $(JAM_TARGETS[2]:E=build) ;
HAIKU_BUILD_PROFILE_PARAMETERS = $(JAM_TARGETS[3-]) ;
HAIKU_BUILD_PROFILE_DEFINED = ;
}
case * : {
# "update-image", "update-vmware-image", and "update-install"
# targets allow for updating only specific targets in the
# image/installation dir.
if $(JAM_TARGETS[1]) in update-image update-vmware-image
update-install {
SetUpdateHaikuImageOnly 1 ;
HAIKU_INCLUDE_IN_IMAGE on $(JAM_TARGETS[2-]) = 1 ;
if $(JAM_TARGETS[1]) = update-image {
JAM_TARGETS = haiku-image ;
} else if $(JAM_TARGETS[1]) = update-vmware-image {
JAM_TARGETS = haiku-vmware-image ;
} else {
JAM_TARGETS = install-haiku ;
}
}
}
}
}
}

View File

@ -698,16 +698,33 @@ rule AddBootModuleSymlinksToHaikuImage targets
rule AddOptionalHaikuImagePackages packages
{
HAIKU_OPTIONAL_PACKAGE_ADDED on $(packages) = 1 ;
local package ;
for package in $(packages) {
if ! [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_ADDED) ] {
HAIKU_OPTIONAL_PACKAGE_ADDED on $(package) = 1 ;
HAIKU_ADDED_OPTIONAL_PACKAGES += $(package) ;
}
}
}
rule IsOptionalHaikuImagePackageAdded package
{
if ! [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_EXISTS) ] {
HAIKU_OPTIONAL_PACKAGE_EXISTS on $(package) = 1 ;
HAIKU_EXISTING_OPTIONAL_PACKAGES += $(package) ;
}
if [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_ADDED) ] {
return 1 ;
}
return $(HAIKU_ADD_ALL_OPTIONAL_PACKAGES) ;
# If all optional packages are installed, make sure this one is added, too.
if $(HAIKU_ADD_ALL_OPTIONAL_PACKAGES) {
AddOptionalHaikuImagePackages $(package) ;
return 1 ;
}
return ;
}
rule OptionalPackageDependencies package : dependencies

View File

@ -254,6 +254,11 @@ rule DefineBuildProfile name : type : path {
# HAIKU_IMAGE_DIR, respectively HAIKU_INSTALL_DIR or their default
# values will be used instead.
if [ on $(name) return $(HAIKU_BUILD_PROFILE_SPECIFIED) ] {
Exit "ERROR: Build profile \"$(name)\" defined twice!" ;
}
HAIKU_BUILD_PROFILE_SPECIFIED on $(name) = 1 ;
if ! $(HAIKU_BUILD_PROFILE) || $(HAIKU_BUILD_PROFILE) != $(name) {
return ;
}