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