Subversion Repositories DevTools

Rev

Rev 4354 | Rev 4370 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4354 Rev 4364
Line 41... Line 41...
41
 
41
 
42
require 5.008_002;
42
require 5.008_002;
43
use strict;
43
use strict;
44
use warnings;
44
use warnings;
45
 
45
 
46
use Getopt::Long;
46
use Getopt::Long qw(:config pass_through);
47
 
47
 
48
use JatsError;
48
use JatsError;
49
use JatsSystem;
49
use JatsSystem;
50
use FileUtils;
50
use FileUtils;
51
use JatsProperties;
51
use JatsProperties;
52
use JatsVersionUtils;
52
use JatsVersionUtils;
53
use ReadBuildConfig;
53
use ReadBuildConfig;
54
use JatsCopy;
54
use JatsCopy;
-
 
55
use ArrayHashUtils;
55
 
56
 
56
#
57
#
57
#   Globals
58
#   Globals
58
#   Command line arguments
59
#   Command line arguments
59
#
60
#
Line 65... Line 66...
65
my $opt_pkgname;
66
my $opt_pkgname;
66
my $opt_pkgversion;
67
my $opt_pkgversion;
67
my $opt_projectname;
68
my $opt_projectname;
68
my $opt_populate;
69
my $opt_populate;
69
my $opt_target = 1;
70
my $opt_target = 1;
-
 
71
my @opt_jlibs;
-
 
72
my @opt_elibs;
-
 
73
my @opt_jars;
70
 
74
 
71
#
75
#
72
#   Configuration
76
#   Configuration
73
#   Map JATS platforms to Shared library targets
77
#   Map JATS platforms to Shared library targets
74
#
78
#
Line 110... Line 114...
110
                "pv=s"          => \$opt_pkgversion,    # string
114
                "pv=s"          => \$opt_pkgversion,    # string
111
                "projectname=s" => \$opt_projectname,   # string
115
                "projectname=s" => \$opt_projectname,   # string
112
                "clean"         => \$opt_clean,         # flag
116
                "clean"         => \$opt_clean,         # flag
113
                "populate"      => \$opt_populate,      # flag
117
                "populate"      => \$opt_populate,      # flag
114
                "target:i"      => \$opt_target,        # Number
118
                "target:i"      => \$opt_target,        # Number
-
 
119
                "Jar=s"         => \@opt_jars,
115
                );
120
                );
116
 
121
 
117
#
122
#
118
#   Restore signal handlers and report parse errors
123
#   Restore signal handlers and report parse errors
119
#
124
#
120
$SIG{__WARN__} = undef;
125
$SIG{__WARN__} = 'DEFAULT';
121
$SIG{__DIE__} = undef;
126
$SIG{__DIE__} = 'DEFAULT';
122
Error('AndroidBuilder. Invalid call options detected') if (!$result);
127
Error('AndroidBuilder. Invalid call options detected') if (!$result);
-
 
128
 
-
 
129
#
-
 
130
#   Process remaining arguments
-
 
131
#   Only --Lname and --lname are valid
-
 
132
#
-
 
133
foreach my $arg (@ARGV) {
-
 
134
    if ($arg =~ m~^[-]{1,2}l(.*)~) {
-
 
135
        push @opt_jlibs, $1;
-
 
136
    } elsif ($arg =~ m~^[-]{1,2}L(.*)~) {
-
 
137
        push @opt_elibs, $1;
-
 
138
    } else {
-
 
139
        ReportError("Invalid option: $arg");
-
 
140
    }
-
 
141
}
123
ErrorDoExit();
142
ErrorDoExit();
124
 
143
 
125
#
144
#
126
#   Sanity Test
145
#   Sanity Test
127
#
146
#
Line 383... Line 402...
383
#
402
#
384
# Returns         : 
403
# Returns         : 
385
#
404
#
386
sub injectDependencies
405
sub injectDependencies
387
{
406
{
-
 
407
    my @jlist;
-
 
408
    my @liblist;
-
 
409
 
-
 
410
    #
-
 
411
    #   Only if we need to do something
-
 
412
    #
-
 
413
    return unless (@opt_jars || @opt_elibs || @opt_jlibs);
-
 
414
 
-
 
415
    #
-
 
416
    #   Create search entries suitable for the CopyDir
-
 
417
    #   We will delete entries as the files are copied
-
 
418
    #
-
 
419
    foreach my $item ( @opt_jars) {
-
 
420
        UniquePush \@jlist, $item . '.jar';
-
 
421
    }
-
 
422
 
-
 
423
    foreach my $item ( @opt_elibs) {
-
 
424
        UniquePush \@liblist, 'lib' . $item . '.so';
-
 
425
    }
-
 
426
    
-
 
427
    foreach my $item ( @opt_jlibs) {
-
 
428
        UniquePush \@liblist, 'lib' . $item . $opt_gbetype . '.so';
-
 
429
    }
-
 
430
 
-
 
431
 
-
 
432
    #
-
 
433
    #   Where does it go
-
 
434
    #
388
    my $androidLibs = catdir($project_root, 'libs');
435
    my $androidLibs = catdir($project_root, 'libs');
389
    Verbose ("Android libs: $androidLibs");
436
    Verbose ("Android libs: $androidLibs");
390
 
437
 
391
    my @pkg_paths = getPackagePaths("--Interface=$opt_interface");
438
    my @pkg_paths = getPackagePaths("--Interface=$opt_interface");
392
    foreach my $pkg ( @pkg_paths)
439
    foreach my $pkg ( @pkg_paths)
393
    {
440
    {
394
        #
441
        #
395
        #   Copy in all JAR files found in dependent packages
442
        #   Copy in all JAR files found in dependent packages
396
        #
443
        #
397
        my $jarDir = catdir($pkg,'jar'); 
444
        my $jarDir = catdir($pkg,'jar'); 
398
        if (-d $jarDir)
445
        if (-d $jarDir && @jlist)
399
        {
446
        {
400
            Verbose("Jar Dir Found found", $jarDir);
447
            Verbose("Jar Dir Found found", $jarDir);
401
            Message ("Copy in: $jarDir");
448
            Message ("Copy in: $jarDir");
402
            CopyDir ( $jarDir, $androidLibs,
449
            CopyDir ( $jarDir, $androidLibs,
403
                        'Match' => ['*.jar'],
450
                        'Match' => \@jlist,
404
                        'Log' => $opt_verbose + 1,
451
                        'Log' => $opt_verbose + 1,
405
                        'SymlinkFiles' => 1,
452
                        'SymlinkFiles' => 1,
-
 
453
                        'Examine' => sub 
-
 
454
                            {
-
 
455
                                my ($opt) = @_;
-
 
456
                                ArrayDelete \@jlist, $opt->{file};
-
 
457
                            },
406
                        );
458
                        );
407
        }
459
        }
408
 
460
 
409
        #
461
        #
410
        #   Build up the Shared Library structure as used by JNI
462
        #   Build up the Shared Library structure as used by JNI
411
        #   Note: Only support current JATS format
463
        #   Note: Only support current JATS format
412
        #   Copy in .so files and in to process massage the pathname so that
464
        #   Copy in .so files and in to process massage the pathname so that
413
        #   it confirms to that expected by the Android Project
465
        #   it confirms to that expected by the Android Project
414
        #
466
        #
415
        my $libDir = catdir($pkg,'lib');
467
        my $libDir = catdir($pkg,'lib');
416
        if (-d $libDir)
468
        if (-d $libDir && @liblist)
417
        {
469
        {
418
            Verbose("Lib Dir Found found", $libDir);
470
            Verbose("Lib Dir Found found", $libDir);
419
            Message ("Copy in: $libDir");
471
            Message ("Copy in: $libDir");
420
            CopyDir ( $libDir, $androidLibs,
472
            CopyDir ( $libDir, $androidLibs,
421
                        'Match' => ['*.so'],
473
                        'Match' => \@liblist,
422
                        'Log' => $opt_verbose + 1,
474
                        'Log' => $opt_verbose + 1,
423
                        'SymlinkFiles' => 1,
475
                        'SymlinkFiles' => 1,
424
                        'Examine' => sub 
476
                        'Examine' => sub 
425
                            { 
477
                            { 
426
                                my ($opt) = @_;
478
                                my ($opt) = @_;
427
                                foreach my $platform ( keys %SharedLibMap ) {
479
                                foreach my $platform ( keys %SharedLibMap ) {
428
                                    my $replace = $SharedLibMap{$platform};
480
                                    my $replace = $SharedLibMap{$platform};
429
                                    if ($opt->{'target'} =~ s~/$platform/~/$replace/~)
481
                                    if ($opt->{'target'} =~ s~/$platform/~/$replace/~)
430
                                    {
482
                                    {
-
 
483
                                        ArrayDelete \@liblist, $opt->{file};
431
                                        return 1;
484
                                        return 1;
432
                                    }
485
                                    }
433
                                }
486
                                }
434
                                return 0;
487
                                return 0;
435
                            },
488
                            },
436
                        );
489
                        );
437
        }
490
        }
438
    }
491
    }
-
 
492
 
-
 
493
    #
-
 
494
    #   Report files that could not be located. They were deleted from the lists
-
 
495
    #   as they were processed
-
 
496
    #       These are Warnings in populate Mode
-
 
497
    #       and errors at build time
-
 
498
    #
-
 
499
    if (@jlist || @liblist)
-
 
500
    {
-
 
501
        my $fn = $opt_populate ? \&Warning : \&Error; 
-
 
502
        &$fn("External dependencies not found:", @jlist, @liblist);
-
 
503
    }
439
}
504
}
440
 
505
 
441
#-------------------------------------------------------------------------------
506
#-------------------------------------------------------------------------------
442
# Function        : deleteGeneratedFiles 
507
# Function        : deleteGeneratedFiles 
443
#
508
#
Line 465... Line 530...
465
    #   Clean out the 'libs' directory
530
    #   Clean out the 'libs' directory
466
    #       Assume that its populated with 'external' dependencies
531
    #       Assume that its populated with 'external' dependencies
467
    #       Leave the directory - it may have been checked into version control
532
    #       Leave the directory - it may have been checked into version control
468
    #
533
    #
469
    my $androidLibs = catdir($project_root, 'libs');
534
    my $androidLibs = catdir($project_root, 'libs');
470
    RmDirTree(glob(catdir($androidLibs, '*')));
535
    foreach my $item (glob(catdir($androidLibs, '*'))) {
-
 
536
        RmDirTree($item);
-
 
537
    }
471
}
538
}
472
 
539
 
473
 
540