CommandLineArguments revision c5b4edb2
1# Rules related to processing of jam command line arguments.
2
3rule ProcessCommandLineArguments
4{
5	# analyze and optionally replace jam's target parameters
6	HAIKU_ORIGINAL_JAM_TARGETS = $(JAM_TARGETS) ;
7	HAIKU_BUILD_PROFILE = ;
8	if $(JAM_TARGETS) {
9		switch $(JAM_TARGETS[1]) {
10			# If the target to be built is "all" (i.e. the default) and we're in
11			# the output directory, the root directory of the build system, or
12			# in "src/", we change the target to be built to "haiku-image".
13			case all : {
14				if ! $(INVOCATION_SUBDIR) || $(INVOCATION_SUBDIR) = src {
15					JAM_TARGETS = haiku-image ;
16				}
17			}
18
19			# Print usage text.
20			case help : {
21				Echo "Individual targets (applications, libraries, drivers,"
22					"...) can be built by just" ;
23				Echo "passing them as arguments to jam. The recommended method"
24					"to build or update a" ;
25				Echo "Haiku image or installation is to use a build profile"
26					"with one of the build" ;
27				Echo "profile actions. Typical command lines using a build"
28					"profile looks like this:" ;
29				Echo "  jam @image" ;
30				Echo "  jam @install update libbe.so" ;
31				Echo "  jam @vmware-image mount" ;
32				Echo ;
33				Echo "Default build profiles (minimal set of packages and"
34					"configuration):" ;
35				Echo "  image            - A raw disk image." ;
36				Echo "  anyboot-image    - A custom image for either CD or"
37					"disk." ;
38				Echo "  cd-image         - An ISO9660 CD image." ;
39				Echo "  vmware-image     - A VMware disk image." ;
40				Echo "  install          - A Haiku installation in a"
41					"directory." ;
42				Echo ;
43				Echo "Nightly build profiles (small set of packages used in"
44                	"nightly builds and default configuration):" ;
45				Echo "  nightly-raw        - A raw disk image." ;
46				Echo "  nightly-anyboot  - A custom image for either CD or"
47					"disk." ;
48				Echo "  nightly-cd       - An ISO9660 CD image." ;
49				Echo "  nightly-vmware   - A VMware disk image." ;
50				Echo ;
51				Echo "Release build profiles (bigger and more complete set of"
52					"packages used in releases and default configuration):" ;
53				Echo "  release-raw      - A raw disk image." ;
54				Echo "  release-anyboot  - A custom image for either CD or"
55					"disk." ;
56				Echo "  release-cd       - An ISO9660 CD image." ;
57				Echo "  release-vmware   - A VMware disk image." ;
58				Echo ;
59				Echo "Bootstrap build profiles (minimal image used for"
60                	"initial build of HPKG packages):" ;
61				Echo "  bootstrap-raw    - A raw disk image." ;
62				Echo "  bootstrap-vmware - A VMware disk image." ;
63				Echo ;
64				Echo "Build profile actions:" ;
65				Echo "  build                - Build a Haiku"
66					"image/installation. This is the default" ;
67				Echo "                         action, i.e. it can be"
68					"omitted." ;
69				Echo "  update <target> ...  - Update the specified targets in"
70					"the Haiku" ;
71				Echo "                         image/installation." ;
72				Echo "  update-all           - Update all targets in the Haiku"
73					"image/installation." ;
74				Echo "  mount                - Mount the Haiku image in the"
75					" bfs_shell." ;
76				Echo ;
77				Echo "Package upload to (git.haiku-os.org/hpkg-upload):" ;
78				Echo "  jam upload-packages <packages ...> " ;
79				Echo ;
80				Echo "Remote repository creation (for testing a set of"
81					" packages):" ;
82				Echo "  jam build-remote-test-repository <packages ...> " ;
83				Echo ;
84				Echo "For more details on how to customize Haiku builds read" ;
85				Echo "build/jam/UserBuildConfig.ReadMe." ;
86				Exit ;
87			}
88
89			# The "run" target allows for running arbitrary command lines
90			# containing build system targets, which are built and replaced
91			# accordingly.
92			case run : {
93				if $(JAM_TARGETS[2]) {
94					JAM_TARGETS = [ RunCommandLine $(JAM_TARGETS[2-]) ] ;
95				} else {
96					Exit "\"jam run\" requires parameters!" ;
97				}
98			}
99
100			# Copy the given set of local package files to the git repository
101			# server, where they will be used for creating a new repository
102			# during the push hook.
103			case upload-packages : {
104				UploadPackages $(JAM_TARGETS[1]) : $(JAM_TARGETS[2-]) ;
105				JAM_TARGETS = $(JAM_TARGETS[1]) ;
106				NotFile $(JAM_TARGETS) ;
107				Always $(JAM_TARGETS) ;
108			}
109
110			# Copy the given set of local package files to the remote repository
111			# and create a new version of that remote repository (useful for
112			# testing the package repository before pushing).
113			case build-remote-test-repository : {
114				BuildRemoteHaikuPortsRepository $(JAM_TARGETS[1])
115					: $(JAM_TARGETS[2-]) ;
116				JAM_TARGETS = $(JAM_TARGETS[1]) ;
117				NotFile $(JAM_TARGETS) ;
118				Always $(JAM_TARGETS) ;
119			}
120
121			# A target starting with "@" is a build profile.
122			case @* : {
123				HAIKU_BUILD_PROFILE = [ Match "@(.*)" : $(JAM_TARGETS[1]) ] ;
124				HAIKU_BUILD_PROFILE_ACTION = $(JAM_TARGETS[2]:E=build) ;
125				HAIKU_BUILD_PROFILE_PARAMETERS = $(JAM_TARGETS[3-]) ;
126				HAIKU_BUILD_PROFILE_DEFINED = ;
127			}
128
129			case * : {
130				# "update-image", "update-vmware-image", and "update-install"
131				# targets allow for updating only specific targets in the
132				# image/installation dir.
133				if $(JAM_TARGETS[1]) in update-image update-vmware-image
134						update-install {
135					SetUpdateHaikuImageOnly 1 ;
136					HAIKU_PACKAGES_UPDATE_ONLY = 1 ;
137					HAIKU_INCLUDE_IN_IMAGE on $(JAM_TARGETS[2-]) = 1 ;
138					HAIKU_INCLUDE_IN_PACKAGES on $(JAM_TARGETS[2-]) = 1 ;
139
140					if $(JAM_TARGETS[1]) = update-image {
141						JAM_TARGETS = haiku-image ;
142					} else if $(JAM_TARGETS[1]) = update-vmware-image {
143						JAM_TARGETS = haiku-vmware-image ;
144					} else {
145						JAM_TARGETS = install-haiku ;
146					}
147				}
148			}
149		}
150	}
151}
152