# PARTICULAR PURPOSE.
";
-# These constants are returned by the lang_*_rewrite functions.
-# LANG_SUBDIR means that the resulting object file should be in a
-# subdir if the source file is. In this case the file name cannot
-# have '..' components.
-use constant LANG_IGNORE => 0;
-use constant LANG_SUBDIR => 2;
-
# These are used when keeping track of whether an object can be built
# by two different paths.
use constant COMPILE_LIBTOOL => 1;
# Nothing to do.
'_finish' => sub { });
-# Vala
+# Vala.
register_language ('name' => 'vala',
'Name' => 'Vala',
'config_vars' => ['VALAC'],
'compile' => '$(VALAC) $(AM_VALAFLAGS) $(VALAFLAGS)',
'ccer' => 'VALAC',
'compiler' => 'VALACOMPILE',
- 'extensions' => ['.vala'],
- 'output_extensions' => sub { (my $ext = $_[0]) =~ s/vala$/c/;
- return ($ext,) },
+ 'extensions' => ['.vala', '.vapi'],
+ # Vala compilation must be handled in a special way, so
+ # nothing to do or return here.
+ 'output_extensions' => sub { },
'rule_file' => 'vala',
'_finish' => \&lang_vala_finish,
'_target_hook' => \&lang_vala_target_hook,
}
}
- # Note: computed subr call. The language rewrite function
- # should return one of the LANG_* constants. It could
- # also return a list whose first value is such a constant
- # and whose second value is a new source extension which
- # should be applied. This means this particular language
- # generates another source file which we must then process
- # further.
- my $subr = \&{'lang_' . $lang->name . '_rewrite'};
- defined &$subr or $subr = sub { return LANG_SUBDIR; };
- my ($r, $source_extension)
- = &$subr ($directory, $base, $extension,
- $obj, $have_per_exec_flags, $var);
- # Skip this entry if we were asked not to process it.
- next if $r == LANG_IGNORE;
+ # NOTE: computed subr calls here.
+
+ # The language ignore function can ask not to preprocess
+ # a source file further.
+ my $subr_ignore = \&{'lang_' . $lang->name . '_ignore'};
+ next if defined &$subr_ignore
+ and &$subr_ignore ($directory, $base, $extension);
+ # The language rewrite function can return a new source
+ # extension which should be applied. This means this
+ # particular language generates another source file which
+ # we must then process further. This happens, for example,
+ # with yacc and lex.
+ my $subr_rewrite = \&{'lang_' . $lang->name . '_rewrite'};
+ $subr_rewrite = sub { } unless defined &$subr_rewrite;
+ my $source_extension = &$subr_rewrite ($directory, $base,
+ $extension, $obj,
+ $have_per_exec_flags,
+ $var);
# Now extract linker and other info.
$linker = $lang->linker;
# If rewrite said it was ok, put the object into a
# subdir.
- if ($r == LANG_SUBDIR && $directory ne '')
- {
- $object = $directory . '/' . $object;
- }
+ $object = $directory . '/' . $object
+ unless $directory eq '';
# If the object file has been renamed (because per-target
# flags are used) we cannot compile the file with an
[@specifics, %transform]);
}
}
- elsif ($extension eq '.vapi')
- {
- # Explicitly pass vala headers through. This is a bit of an
- # hack, but good enough FTM.
- next;
- }
else
{
# Assume the user has defined a proper explicit or pattern
#
# Functions to handle files of each language.
-# Each 'lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
-# simple formula: Return value is LANG_SUBDIR if the resulting object
-# file should be in a subdir if the source file is, LANG_PROCESS if
-# file is to be dealt with, LANG_IGNORE otherwise.
-
# Much of the actual processing is handled in
# handle_single_transform. These functions exist so that
# auxiliary information can be recorded for a later cleanup pass.
uniq_part => 'AM_PROG_CC_C_O per-target');
}
}
-
- return LANG_SUBDIR;
+ # Not a useless use of return: the caller of this subroutine will
+ # behave differently if a value is actually returned, and since perl
+ # returns the value of the last expressions seen by default, we
+ # need to explicitly return and undefined value.
+ return undef;
}
-# Rewrite a single header file.
-sub lang_header_rewrite
+# Header files are simply ignored.
+sub lang_header_ignore { 1; }
+
+# Vala '.vapi' are a kind of header files as well, and should
+# not be processed into compilation rules.
+ sub lang_vala_ignore
{
- # Header files are simply ignored.
- return LANG_IGNORE;
+ my ($directory, $base, $ext) = @_;
+ return ($ext =~ m/\.vapi$/ ? 1 : 0);
}
# Rewrite a single Vala source file.
sub lang_vala_rewrite
{
my ($directory, $base, $ext) = @_;
-
- (my $newext = $ext) =~ s/vala$/c/;
- return (LANG_SUBDIR, $newext);
+ $ext =~ s/vala$/c/;
+ return $ext;
}
# Rewrite a single yacc/yacc++ file.
sub lang_yacc_rewrite
{
my ($directory, $base, $ext) = @_;
-
- (my $newext = $ext) =~ tr/y/c/;
- return (LANG_SUBDIR, $newext);
+ $ext =~ tr/y/c/;
+ return $ext;
}
sub lang_yaccxx_rewrite { lang_yacc_rewrite (@_); };
sub lang_lex_rewrite
{
my ($directory, $base, $ext) = @_;
-
- (my $newext = $ext) =~ tr/l/c/;
- return (LANG_SUBDIR, $newext);
+ $ext =~ tr/l/c/;
+ return $ext;
}
sub lang_lexxx_rewrite { lang_lex_rewrite (@_); };
-# Rewrite a single Java file.
-sub lang_java_rewrite
-{
- return LANG_SUBDIR;
-}
-
# The lang_X_finish functions are called after all source file
# processing is done. Each should handle defining rules for the
# language, etc. A finish function is only called if a source file of