Added a new fancy build system feature called "build profiles".
Especially people building various kinds of images with different settings may want to have a look at the respective section in the UserBuildConfig.ReadMe. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24757 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -45,4 +45,15 @@ include [ FDirName $(HAIKU_BUILD_RULES_DIR) BuildSetup ] ;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# If a build profile was specified on the command line, now is the time to
|
||||||
|
# check whether it is unknown or one of the default profiles.
|
||||||
|
if $(HAIKU_BUILD_PROFILE) && ! $(HAIKU_BUILD_PROFILE_DEFINED) {
|
||||||
|
# define the obvious default profiles
|
||||||
|
if $(HAIKU_BUILD_PROFILE) in image vmware-image install {
|
||||||
|
DefineBuildProfile $(HAIKU_BUILD_PROFILE) : $(HAIKU_BUILD_PROFILE) ;
|
||||||
|
} else {
|
||||||
|
Exit "Build profile" $(HAIKU_BUILD_PROFILE) "not defined." ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PrepareConfigVariables ;
|
PrepareConfigVariables ;
|
||||||
|
|||||||
+50
-24
@@ -43,37 +43,63 @@ HAIKU_CONTAINER_GRIST on $(HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME) = CDBootImage ;
|
|||||||
HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME)
|
HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME)
|
||||||
= HAIKU_CD_BOOT_IMAGE_INSTALL_TARGETS ;
|
= HAIKU_CD_BOOT_IMAGE_INSTALL_TARGETS ;
|
||||||
|
|
||||||
|
# Haiku image/install defaults
|
||||||
|
HAIKU_DEFAULT_IMAGE_NAME = haiku.image ;
|
||||||
|
HAIKU_DEFAULT_IMAGE_DIR = $(HAIKU_OUTPUT_DIR) ;
|
||||||
|
HAIKU_DEFAULT_VMWARE_IMAGE_NAME = haiku.vmdk ;
|
||||||
|
HAIKU_DEFAULT_INSTALL_DIR = /Haiku ;
|
||||||
|
HAIKU_DEFAULT_IMAGE_SIZE ?= 100 ; # 100 MB
|
||||||
|
|
||||||
|
|
||||||
# analyze an optionally replace jam's target parameters
|
# analyze an optionally replace jam's target parameters
|
||||||
HAIKU_ORIGINAL_JAM_TARGETS = $(JAM_TARGETS) ;
|
HAIKU_ORIGINAL_JAM_TARGETS = $(JAM_TARGETS) ;
|
||||||
|
HAIKU_BUILD_PROFILE = ;
|
||||||
if $(JAM_TARGETS) {
|
if $(JAM_TARGETS) {
|
||||||
# If the target to be built is "all" (i.e. the default) and we're in the
|
switch $(JAM_TARGETS[1]) {
|
||||||
# output directory, the root directory of the build system, or in "src/", we
|
# If the target to be built is "all" (i.e. the default) and we're in
|
||||||
# change the target to be built to "haiku-image".
|
# the output directory, the root directory of the build system, or
|
||||||
if $(JAM_TARGETS) = all {
|
# in "src/", we change the target to be built to "haiku-image".
|
||||||
if ! $(INVOCATION_SUBDIR) || $(INVOCATION_SUBDIR) = src {
|
case all : {
|
||||||
JAM_TARGETS = haiku-image ;
|
if ! $(INVOCATION_SUBDIR) || $(INVOCATION_SUBDIR) = src {
|
||||||
|
JAM_TARGETS = haiku-image ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# The "run" target allows for running arbitrary command lines containing
|
# The "run" target allows for running arbitrary command lines containing
|
||||||
# build system targets, which are built and replaced accordingly.
|
# build system targets, which are built and replaced accordingly.
|
||||||
} else if $(JAM_TARGETS[1]) = run && $(JAM_TARGETS[2]) {
|
case run : {
|
||||||
local run = [ RunCommandLine $(JAM_TARGETS[2-]) ] ;
|
if $(JAM_TARGETS[2]) {
|
||||||
JAM_TARGETS = $(run) ;
|
JAM_TARGETS = [ RunCommandLine $(JAM_TARGETS[2-]) ] ;
|
||||||
|
} else {
|
||||||
|
Exit "\"jam run\" requires parameters!" ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# "update-image", "update-vmware-image", and "update-install" targets allow
|
# A target starting with "@" is a build profile.
|
||||||
# for updating only specific targets in the image/installation dir.
|
case @* : {
|
||||||
} else if $(JAM_TARGETS[1]) = update-image
|
HAIKU_BUILD_PROFILE = [ Match "@(.*)" : $(JAM_TARGETS[1]) ] ;
|
||||||
|| $(JAM_TARGETS[1]) = update-vmware-image
|
HAIKU_BUILD_PROFILE_ACTION = $(JAM_TARGETS[2]:E=build) ;
|
||||||
|| $(JAM_TARGETS[1]) = update-install {
|
HAIKU_BUILD_PROFILE_PARAMETERS = $(JAM_TARGETS[3-]) ;
|
||||||
SetUpdateHaikuImageOnly 1 ;
|
HAIKU_BUILD_PROFILE_DEFINED = ;
|
||||||
HAIKU_INCLUDE_IN_IMAGE on $(JAM_TARGETS[2-]) = 1 ;
|
}
|
||||||
|
|
||||||
if $(JAM_TARGETS[1]) = update-image {
|
case * : {
|
||||||
JAM_TARGETS = haiku-image ;
|
# "update-image", "update-vmware-image", and "update-install"
|
||||||
} else if $(JAM_TARGETS[1]) = update-vmware-image {
|
# targets allow for updating only specific targets in the
|
||||||
JAM_TARGETS = haiku-vmware-image ;
|
# image/installation dir.
|
||||||
} else {
|
if $(JAM_TARGETS[1]) in update-image update-vmware-image
|
||||||
JAM_TARGETS = install-haiku ;
|
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 ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -495,14 +495,14 @@ AddGroupToHaikuImage users : 100 : ;
|
|||||||
|
|
||||||
|
|
||||||
# Set image name and directory defaults and locate the image.
|
# Set image name and directory defaults and locate the image.
|
||||||
HAIKU_IMAGE_NAME ?= haiku.image ;
|
HAIKU_IMAGE_NAME ?= $(HAIKU_DEFAULT_IMAGE_NAME) ;
|
||||||
HAIKU_IMAGE_DIR ?= $(HAIKU_OUTPUT_DIR) ;
|
HAIKU_IMAGE_DIR ?= $(HAIKU_DEFAULT_IMAGE_DIR) ;
|
||||||
HAIKU_IMAGE ?= $(HAIKU_IMAGE_NAME) ;
|
HAIKU_IMAGE = $(HAIKU_IMAGE_NAME) ;
|
||||||
HAIKU_IMAGE_SIZE ?= 100 ; # 100 MB
|
HAIKU_IMAGE_SIZE ?= $(HAIKU_DEFAULT_IMAGE_SIZE) ; # 100 MB
|
||||||
MakeLocate $(HAIKU_IMAGE) : $(HAIKU_IMAGE_DIR) ;
|
MakeLocate $(HAIKU_IMAGE) : $(HAIKU_IMAGE_DIR) ;
|
||||||
|
|
||||||
# Set the default installation directory.
|
# Set the default installation directory.
|
||||||
HAIKU_INSTALL_DIR ?= /Haiku ;
|
HAIKU_INSTALL_DIR ?= $(HAIKU_DEFAULT_INSTALL_DIR) ;
|
||||||
|
|
||||||
# the pseudo target all image contents is attached to
|
# the pseudo target all image contents is attached to
|
||||||
NotFile $(HAIKU_IMAGE_CONTAINER_NAME) ;
|
NotFile $(HAIKU_IMAGE_CONTAINER_NAME) ;
|
||||||
@@ -590,8 +590,8 @@ _BuildHaikuImage install-haiku : 0 ;
|
|||||||
|
|
||||||
|
|
||||||
# build the VMware image
|
# build the VMware image
|
||||||
HAIKU_VMWARE_IMAGE_NAME ?= haiku.vmdk ;
|
HAIKU_VMWARE_IMAGE_NAME ?= $(HAIKU_DEFAULT_VMWARE_IMAGE_NAME) ;
|
||||||
HAIKU_VMWARE_IMAGE ?= $(HAIKU_VMWARE_IMAGE_NAME) ;
|
HAIKU_VMWARE_IMAGE = $(HAIKU_VMWARE_IMAGE_NAME) ;
|
||||||
MakeLocate $(HAIKU_VMWARE_IMAGE) : $(HAIKU_IMAGE_DIR) ;
|
MakeLocate $(HAIKU_VMWARE_IMAGE) : $(HAIKU_IMAGE_DIR) ;
|
||||||
|
|
||||||
_BuildHaikuImage $(HAIKU_VMWARE_IMAGE) : true : true ;
|
_BuildHaikuImage $(HAIKU_VMWARE_IMAGE) : true : true ;
|
||||||
|
|||||||
@@ -227,3 +227,121 @@ actions RunCommandLine1 {
|
|||||||
$(COMMAND_LINE)
|
$(COMMAND_LINE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark - DefineBuildProfile
|
||||||
|
|
||||||
|
|
||||||
|
rule DefineBuildProfile name : type : path {
|
||||||
|
# DefineBuildProfile <name> : <type> [ : <path> ]
|
||||||
|
#
|
||||||
|
# Makes a build profile known. Build profiles can be used to define
|
||||||
|
# different sets of settings for Haiku images/installations. For each
|
||||||
|
# profile the default actions "build", "update", and "mount" (the latter
|
||||||
|
# only for disks or image types) will be available (i.e. can be specified
|
||||||
|
# as second parameter on the jam command line). They will build an image
|
||||||
|
# or installation, update only given targets, respectively just mount the
|
||||||
|
# image or disk using the bfs_shell.
|
||||||
|
#
|
||||||
|
# <name> - The name of the build profile.
|
||||||
|
# <type> - The type of the build profile. Must be one of "image" (plain
|
||||||
|
# disk image), "vmware-image" (VMware disk image), "disk"
|
||||||
|
# (actual partition or hard disk device), "install" (installation
|
||||||
|
# in a directory), or "custom" (user-defined).
|
||||||
|
# <path> - The path associated with the profile. Depending on the profile
|
||||||
|
# type, this is the path to the disk image/VMware image, hard
|
||||||
|
# disk/partition device, or the installation directory. If the
|
||||||
|
# parameter is omitted, the value of the HAIKU[_VMWARE]_IMAGE_NAME,
|
||||||
|
# HAIKU_IMAGE_DIR, respectively HAIKU_INSTALL_DIR or their default
|
||||||
|
# values will be used instead.
|
||||||
|
|
||||||
|
if ! $(HAIKU_BUILD_PROFILE) || $(HAIKU_BUILD_PROFILE) != $(name) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
HAIKU_BUILD_PROFILE_DEFINED = 1 ;
|
||||||
|
|
||||||
|
# split path into directory path and name
|
||||||
|
local targetDir = $(path:D) ;
|
||||||
|
local targetName = $(path:BS) ;
|
||||||
|
|
||||||
|
# Jam's path splitting produces an empty string, if a component doesn't
|
||||||
|
# exist. That's a little unhandy for checks.
|
||||||
|
if $(targetDir) = "" {
|
||||||
|
targetDir = ;
|
||||||
|
}
|
||||||
|
if $(targetName) = "" {
|
||||||
|
targetName = ;
|
||||||
|
}
|
||||||
|
|
||||||
|
targetDir ?= $(HAIKU_IMAGE_DIR) ;
|
||||||
|
targetDir ?= $(HAIKU_DEFAULT_IMAGE_DIR) ;
|
||||||
|
|
||||||
|
# "disk" is "image" with HAIKU_DONT_CLEAR_IMAGE
|
||||||
|
if $(type) = "disk" {
|
||||||
|
type = "image" ;
|
||||||
|
HAIKU_DONT_CLEAR_IMAGE = 1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
local buildTarget ;
|
||||||
|
local startOffset ;
|
||||||
|
|
||||||
|
switch $(type) {
|
||||||
|
case "image" : {
|
||||||
|
targetName ?= $(HAIKU_IMAGE_NAME) ;
|
||||||
|
targetName ?= $(HAIKU_DEFAULT_IMAGE_NAME) ;
|
||||||
|
HAIKU_IMAGE_DIR = $(targetDir) ;
|
||||||
|
HAIKU_IMAGE_NAME = $(targetName) ;
|
||||||
|
buildTarget = haiku-image ;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "vmware-image" : {
|
||||||
|
targetName ?= $(HAIKU_VMWARE_IMAGE_NAME) ;
|
||||||
|
targetName ?= $(HAIKU_DEFAULT_VMWARE_IMAGE_NAME) ;
|
||||||
|
HAIKU_IMAGE_DIR = $(targetDir) ;
|
||||||
|
HAIKU_VMWARE_IMAGE_NAME = $(targetName) ;
|
||||||
|
buildTarget = haiku-vmware-image ;
|
||||||
|
startOffset = --start-offset 65536 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "install" : {
|
||||||
|
path ?= $(HAIKU_INSTALL_DIR) ;
|
||||||
|
path ?= $(HAIKU_DEFAULT_INSTALL_DIR) ;
|
||||||
|
HAIKU_INSTALL_DIR = $(path) ;
|
||||||
|
buildTarget = install-haiku ;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "custom" : {
|
||||||
|
# user-defined -- don't do anything
|
||||||
|
return 1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
case * : {
|
||||||
|
Exit "Unsupported build profile type: " $(type) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch $(HAIKU_BUILD_PROFILE_ACTION) {
|
||||||
|
case "build" : {
|
||||||
|
JAM_TARGETS = $(buildTarget) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "update" : {
|
||||||
|
JAM_TARGETS = $(buildTarget) ;
|
||||||
|
SetUpdateHaikuImageOnly 1 ;
|
||||||
|
HAIKU_INCLUDE_IN_IMAGE on $(HAIKU_BUILD_PROFILE_PARAMETERS) = 1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "mount" : {
|
||||||
|
if $(type) = "install" {
|
||||||
|
Exit "Build action \"mount\" not supported for profile type"
|
||||||
|
"\"install\"." ;
|
||||||
|
}
|
||||||
|
|
||||||
|
local commandLine = :<build>bfs_shell $(startOffset)
|
||||||
|
\"$(targetName:D=$(targetDir))\" ;
|
||||||
|
JAM_TARGETS = [ RunCommandLine $(commandLine) ] ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1 ;
|
||||||
|
}
|
||||||
|
|||||||
@@ -147,6 +147,78 @@ AddUserToHaikuImage walter : 1000 : 100 : /boot/home : /bin/bash
|
|||||||
AddGroupToHaikuImage party : 101 : baron walter ;
|
AddGroupToHaikuImage party : 101 : baron walter ;
|
||||||
|
|
||||||
|
|
||||||
|
# Build Profiles
|
||||||
|
|
||||||
|
# A build profile is a named set of settings for building a Haiku image or
|
||||||
|
# installation. The following lines define five different build profiles:
|
||||||
|
# disk - Installation on device /dev/sda57. All optional packages will be
|
||||||
|
# included. Profile type "disk" implies "HAIKU_DONT_CLEAR_IMAGE = 1".
|
||||||
|
# qemu - A plain 200 MB disk image (type "image") named "haiku-qemu.image".
|
||||||
|
# Since only the image name is given, the default location will be
|
||||||
|
# chosen for the image, unless HAIKU_IMAGE_DIR has been set
|
||||||
|
# beforehand.
|
||||||
|
# vmware - A 400 MB VMware image (type "vmware-image"). It will not be zeroed,
|
||||||
|
# if not necessary. The optional packages Development and Pe will be
|
||||||
|
# installed. No image name or path is given, so the defaults
|
||||||
|
# ("haiku.vmdk" in the generated directory) will be used, unless the
|
||||||
|
# respective variables are set.
|
||||||
|
# crash - Similar to the vmware profile, but created at a specific location
|
||||||
|
# and 1 GB size. Furthermore a "crash-tests" directory will be copied
|
||||||
|
# to the image.
|
||||||
|
# install - Installation in directory "/Haiku2" (type "install").
|
||||||
|
|
||||||
|
DefineBuildProfile disk : disk : "/dev/sda57" ;
|
||||||
|
DefineBuildProfile qemu : image : "haiku-qemu.image" ;
|
||||||
|
DefineBuildProfile vmware : vmware-image ;
|
||||||
|
DefineBuildProfile crash : vmware-image
|
||||||
|
: "/home/foobar/vmware/Virtual Machines/CrashOMatic/CrashOMatic.vmdk" ;
|
||||||
|
DefineBuildProfile install : install : /Haiku2 ;
|
||||||
|
|
||||||
|
switch $(HAIKU_BUILD_PROFILE) {
|
||||||
|
case "disk" : {
|
||||||
|
HAIKU_ADD_ALL_OPTIONAL_PACKAGES = 1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "qemu" : {
|
||||||
|
HAIKU_IMAGE_SIZE = 200 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "vmware" : {
|
||||||
|
HAIKU_IMAGE_SIZE = 400 ;
|
||||||
|
HAIKU_DONT_CLEAR_IMAGE = 1 ;
|
||||||
|
AddOptionalHaikuImagePackages Development Pe ;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "crash" : {
|
||||||
|
HAIKU_IMAGE_SIZE = 1024 ;
|
||||||
|
HAIKU_DONT_CLEAR_IMAGE = 1 ;
|
||||||
|
AddOptionalHaikuImagePackages Development Pe ;
|
||||||
|
CopyDirectoryToHaikuImage home Desktop : $(HAIKU_TOP)/../crash-tests ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# By specifying the build profile name as first (non-option) parameter on the
|
||||||
|
# jam command line prefixed by an "@" character, the profile will be selected.
|
||||||
|
# The second parameter specifies the action to be performed, further optional
|
||||||
|
# parameters may follow. Jam command line examples:
|
||||||
|
#
|
||||||
|
# jam -q @disk build
|
||||||
|
# -> Equivalent to running "jam -q haiku-image" with the settings for the
|
||||||
|
# "disk" profile. "build" is the default action, so it could even be
|
||||||
|
# omitted.
|
||||||
|
# jam -q @vmware update kernel
|
||||||
|
# -> Equivalent to running "jam -q update-vmware-image kernel" with the
|
||||||
|
# settings for the "vmware" profile.
|
||||||
|
# jam -q @crash mount
|
||||||
|
# -> Enters the bfs_shell mounting the image specified by the "crash" profile.
|
||||||
|
#
|
||||||
|
# Note, that the build system will automatically define the build profiles
|
||||||
|
# "image", "vmware-image", and "install", unless they are already defined in
|
||||||
|
# the UserBuildConfig. They correspond to the respective build profile types
|
||||||
|
# and use the values of the variables HAIKU[_VMWARE]_IMAGE_NAME,
|
||||||
|
# HAIKU_IMAGE_DIR, HAIKU_INSTALL_DIR, respectively their default values.
|
||||||
|
# "jam -q @image" will therefore be equivalent to "jam -q haiku-image".
|
||||||
|
|
||||||
|
|
||||||
# Creating Sourceable Shell Scripts
|
# Creating Sourceable Shell Scripts
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user