xref: /haiku/build/jam/CommandLineArguments (revision 97901ec593ec4dd50ac115c1c35a6d72f6e489a5)
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:" ;
34				Echo "  image         - A raw disk image." ;
35				Echo "  anyboot-image - A custom image for either CD or disk." ;
36				Echo "  cd-image      - An ISO9660 CD image." ;
37				Echo "  vmware-image  - A VMware disk image." ;
38				Echo "  install       - A Haiku installation in a directory." ;
39				Echo ;
40				Echo "Build profile actions:" ;
41				Echo "  build                - Build a Haiku"
42					"image/installation. This is the default" ;
43				Echo "                         action, i.e. it can be"
44					"omitted." ;
45				Echo "  update <target> ...  - Update the specified targets in"
46					" the Haiku" ;
47				Echo "                         image/installation." ;
48				Echo "  update-all           - Update all targets in the Haiku"
49					"image/installation." ;
50				Echo "  mount                - Mount the Haiku image in the"
51					"bfs_shell." ;
52				Echo ;
53				Echo "For more details on how to customize Haiku builds read" ;
54				Echo "build/jam/UserBuildConfig.ReadMe." ;
55				Exit ;
56			}
57
58			# The "run" target allows for running arbitrary command lines
59			# containing build system targets, which are built and replaced
60			# accordingly.
61			case run : {
62				if $(JAM_TARGETS[2]) {
63					JAM_TARGETS = [ RunCommandLine $(JAM_TARGETS[2-]) ] ;
64				} else {
65					Exit "\"jam run\" requires parameters!" ;
66				}
67			}
68
69			# A target starting with "@" is a build profile.
70			case @* : {
71				HAIKU_BUILD_PROFILE = [ Match "@(.*)" : $(JAM_TARGETS[1]) ] ;
72				HAIKU_BUILD_PROFILE_ACTION = $(JAM_TARGETS[2]:E=build) ;
73				HAIKU_BUILD_PROFILE_PARAMETERS = $(JAM_TARGETS[3-]) ;
74				HAIKU_BUILD_PROFILE_DEFINED = ;
75			}
76
77			case * : {
78				# "update-image", "update-vmware-image", and "update-install"
79				# targets allow for updating only specific targets in the
80				# image/installation dir.
81				if $(JAM_TARGETS[1]) in update-image update-vmware-image
82						update-install {
83					SetUpdateHaikuImageOnly 1 ;
84					HAIKU_INCLUDE_IN_IMAGE on $(JAM_TARGETS[2-]) = 1 ;
85
86					if $(JAM_TARGETS[1]) = update-image {
87						JAM_TARGETS = haiku-image ;
88					} else if $(JAM_TARGETS[1]) = update-vmware-image {
89						JAM_TARGETS = haiku-vmware-image ;
90					} else {
91						JAM_TARGETS = install-haiku ;
92					}
93				}
94			}
95		}
96	}
97}
98