p4ruby 2015.2.1313860-x86-mingw32 → 2020.1.2056123-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,10 +6,19 @@ require 'mkmf'
6
6
  require 'net/ftp'
7
7
  require 'P4/version'
8
8
  require 'rbconfig'
9
+ require 'openssl'
9
10
 
10
11
  # Set this to the main version directory we look up in ftp.perforce.com for the P4API
11
12
  # This is ignored if you specify the version on the command line.
12
- P4API_VERSION_DIR = 'r15.2'
13
+ # Changed the hardcoded string so that the version is now derived from version.rb file
14
+ #P4API_VERSION_DIR = 'r19.1'
15
+ def p4api_version_dir
16
+ ver=P4::Version.split(".")
17
+ p4_major = ver[0].chars.last(2).join
18
+ p4_minor = ver[1]
19
+ dir = "r" + p4_major + "." + p4_minor
20
+ end
21
+
13
22
 
14
23
  #==============================================================================
15
24
  # Provide platform variables in P4-specific format
@@ -102,6 +111,15 @@ def calculate_p4osver
102
111
  return ver
103
112
  end
104
113
 
114
+ def gcc
115
+ @gcc ||= calculate_gcc
116
+ end
117
+
118
+ def calculate_gcc
119
+ gcc = RbConfig::CONFIG["GCC"]
120
+ return gcc
121
+ end
122
+
105
123
  def uname_platform
106
124
  @uname_platform ||= calculate_uname_platform
107
125
  end
@@ -155,6 +173,13 @@ def set_platform_opts
155
173
  end
156
174
  end
157
175
 
176
+ def set_platform_cxxflags
177
+ if (p4osname == 'LINUX') && (gcc == 'yes')
178
+ $CXXFLAGS += " -std=c++11 "
179
+ end
180
+ end
181
+
182
+
158
183
  def set_platform_cppflags
159
184
  $CPPFLAGS += "-DOS_#{p4osname} "
160
185
  $CPPFLAGS += "-DOS_#{p4osname}#{p4osver} "
@@ -214,6 +239,7 @@ def set_platform_libs
214
239
  $LDFLAGS += ' -framework CoreFoundation -framework Foundation'
215
240
  end
216
241
  when 'LINUX', 'MINGW32'
242
+ $LDFLAGS += ' -Wl,--allow-multiple-definition'
217
243
  have_library('supc++')
218
244
  end
219
245
  end
@@ -445,13 +471,34 @@ def ftp_download_dir(version)
445
471
  end
446
472
 
447
473
  def filename
474
+ openssl_number = OpenSSL::OPENSSL_VERSION.split(' ')[1].to_s
475
+ openssl_number = openssl_number.slice(0, (openssl_number.rindex('.')))
476
+
448
477
  if RbConfig::CONFIG['target_os'].downcase =~ /nt|mswin|mingw/
449
- 'p4api.zip'
478
+ filename = 'p4api.zip'
479
+ if !openssl_number.to_s.empty?
480
+ case openssl_number.to_s
481
+ when /1.1/
482
+ filename = 'p4api-openssl1.1.1.zip'
483
+ when /1.0/
484
+ filename = 'p4api-openssl1.0.2.zip'
485
+ end
486
+ end
450
487
  else
451
- 'p4api.tgz'
488
+ filename = 'p4api.tgz'
489
+ if !openssl_number.to_s.empty?
490
+ case openssl_number.to_s
491
+ when /1.1/
492
+ filename = 'p4api-glibc2.3-openssl1.1.1.tgz'
493
+ when /1.0/
494
+ filename = 'p4api-glibc2.3-openssl1.0.2.tgz'
495
+ end
496
+ end
452
497
  end
498
+ return filename
453
499
  end
454
500
 
501
+
455
502
  def remote_files_matching(ftp, dir, regex)
456
503
  ftp.ls(dir.to_s).map { |entry|
457
504
  if match = entry.match(regex)
@@ -499,9 +546,8 @@ def download_api_via_ftp
499
546
  # At one point, we allowed the gem build to just find the most recent p4api build.
500
547
  # P4Ruby probably shouldn't do that by default.
501
548
  #version_dir = find_latest_version_dir(ftp)
502
- version_dir = P4API_VERSION_DIR
503
549
 
504
- dir = ftp_download_dir(version_dir)
550
+ dir = ftp_download_dir(p4api_version_dir)
505
551
  ftp.chdir(dir)
506
552
 
507
553
  puts "downloading #{filename} from #{dir} on ftp.perforce.com"
@@ -536,9 +582,11 @@ set_platform_opts
536
582
  # based solely on platform detection.
537
583
  set_platform_cppflags
538
584
  set_platform_cflags
585
+ set_platform_cxxflags
539
586
 
540
587
  puts "$CPPFLAGS #{$CPPFLAGS}"
541
588
  puts "$CFLAGS #{$CFLAGS}"
589
+ puts "$CXXFLAGS #{$CXXFLAGS}"
542
590
 
543
591
  # Setup additional system library definitions based on platform type before
544
592
  # we setup other libraries, in order to preserve linking order
@@ -554,15 +602,17 @@ resolve_ssl_dirs
554
602
  # If we happen to need SSL on Windows, we also need gdi32
555
603
  if RbConfig::CONFIG['target_os'].downcase =~ /mingw/
556
604
  have_library('gdi32') or raise
605
+ have_library('ole32') or raise
606
+ have_library('crypt32') or raise
557
607
  end
558
608
 
559
- do_ssl = have_library('crypto') and have_library('ssl')
560
-
561
- unless do_ssl
562
- have_library('p4sslstub') or raise
563
- end
564
-
609
+ have_library('crypto') or raise
610
+ have_library('ssl') or raise
565
611
  have_library('supp') or raise
612
+ have_library('p4script_sqlite') or raise
613
+ have_library('p4script_curl') or raise
614
+ have_library('p4script') or raise
615
+ have_library('p4script_c') or raise
566
616
  have_library('rpc') or raise
567
617
  have_library('client') or raise
568
618
 
@@ -577,4 +627,4 @@ create_p4rubyconf_header(version_info, $libs)
577
627
  # don't believe we need to rely on actually.
578
628
  create_header
579
629
 
580
- create_makefile('P4')
630
+ create_makefile('P4')
@@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
30
  *
31
31
  * Author : Tony Smith <tony@perforce.com> or <tony@smee.org>
32
32
  *
33
- * Description : Ruby bindings for the Perforce API.
33
+ * Description : Ruby bindings for the Perforce API.
34
34
  *
35
35
  * vim:ts=8:sw=4
36
36
  ******************************************************************************/
@@ -160,7 +160,7 @@ static VALUE p4_run_tagged( VALUE self, VALUE tagged )
160
160
  flag = 0;
161
161
  else
162
162
  flag = NUM2INT( tagged ) ? 1 : 0;
163
-
163
+
164
164
  int old_value = p4->IsTagged();
165
165
  p4->Tagged( flag );
166
166
 
@@ -196,7 +196,7 @@ static VALUE p4_set_tagged( VALUE self, VALUE toggle )
196
196
  flag = 0;
197
197
  else
198
198
  flag = NUM2INT( toggle ) ? 1 : 0;
199
-
199
+
200
200
  p4->Tagged( flag );
201
201
  return flag ? Qtrue : Qfalse; // Seems to be ignored...
202
202
  }
@@ -489,6 +489,21 @@ static VALUE p4_set_ticket_file( VALUE self, VALUE path )
489
489
  return Qtrue;
490
490
  }
491
491
 
492
+ static VALUE p4_get_trust_file( VALUE self )
493
+ {
494
+ P4ClientApi *p4;
495
+ Data_Get_Struct( self, P4ClientApi, p4 );
496
+ return P4Utils::ruby_string( p4->GetTrustFile().Text() );
497
+ }
498
+
499
+ static VALUE p4_set_trust_file( VALUE self, VALUE path )
500
+ {
501
+ P4ClientApi *p4;
502
+ Data_Get_Struct( self, P4ClientApi, p4 );
503
+ p4->SetTrustFile( StringValuePtr( path ) );
504
+ return Qtrue;
505
+ }
506
+
492
507
  static VALUE p4_get_user( VALUE self )
493
508
  {
494
509
  P4ClientApi *p4;
@@ -541,7 +556,7 @@ static VALUE p4_set_track( VALUE self, VALUE toggle )
541
556
  flag = 0;
542
557
  else
543
558
  flag = NUM2INT( toggle ) ? 1 : 0;
544
-
559
+
545
560
  p4->SetTrack( flag );
546
561
  return flag ? Qtrue : Qfalse; // Seems to be ignored...
547
562
  }
@@ -567,11 +582,37 @@ static VALUE p4_set_streams( VALUE self, VALUE toggle )
567
582
  flag = 0;
568
583
  else
569
584
  flag = NUM2INT( toggle ) ? 1 : 0;
570
-
585
+
571
586
  p4->SetStreams( flag );
572
587
  return flag ? Qtrue : Qfalse; // Seems to be ignored...
573
588
  }
574
589
 
590
+ static VALUE p4_get_graph( VALUE self )
591
+ {
592
+ P4ClientApi *p4;
593
+ Data_Get_Struct( self, P4ClientApi, p4 );
594
+ return p4->IsGraph() ? Qtrue : Qfalse;
595
+ }
596
+
597
+ static VALUE p4_set_graph( VALUE self, VALUE toggle )
598
+ {
599
+ P4ClientApi *p4;
600
+ Data_Get_Struct( self, P4ClientApi, p4 );
601
+
602
+ // The user might have passed an integer, or it might be a boolean,
603
+ // we convert to int for consistency.
604
+ int flag = 0;
605
+ if( toggle == Qtrue )
606
+ flag = 1;
607
+ else if( toggle == Qfalse )
608
+ flag = 0;
609
+ else
610
+ flag = NUM2INT( toggle ) ? 1 : 0;
611
+
612
+ p4->SetGraph( flag );
613
+ return flag ? Qtrue : Qfalse; // Seems to be ignored...
614
+ }
615
+
575
616
  /*******************************************************************************
576
617
  * Running commands. General purpose Run method and method for supplying
577
618
  * input to "p4 xxx -i" commands
@@ -599,7 +640,7 @@ static VALUE p4_run( VALUE self, VALUE args )
599
640
  char *cmd = StringValuePtr( v );
600
641
  argc = NUM2INT( rb_funcall( flatArgs, idLength, 0 ) );
601
642
 
602
- // Allocate storage on the stack so it's automatically reclaimed
643
+ // Allocate storage on the stack so it's automatically reclaimed
603
644
  // when we exit.
604
645
  char **p4args = ALLOCA_N( char *, argc + 1 );
605
646
 
@@ -917,7 +958,7 @@ static VALUE p4map_new( int argc, VALUE *argv, VALUE pClass )
917
958
 
918
959
  // First arg is the class
919
960
  // pClass = argv[ 0 ];
920
-
961
+
921
962
  // Now instantiate the new object.
922
963
  self = Data_Wrap_Struct( pClass, 0, p4map_free, m );
923
964
  rb_obj_call_init( self, 0, argv );
@@ -1066,7 +1107,7 @@ static VALUE p4map_reverse( VALUE self )
1066
1107
  return rval;
1067
1108
  }
1068
1109
 
1069
- //
1110
+ //
1070
1111
  // P4::Map#translate( string, fwd=true )
1071
1112
  //
1072
1113
  static VALUE p4map_trans( int argc, VALUE *argv, VALUE self )
@@ -1076,7 +1117,7 @@ static VALUE p4map_trans( int argc, VALUE *argv, VALUE self )
1076
1117
  VALUE string;
1077
1118
 
1078
1119
  if( argc < 1 || argc > 2 )
1079
- rb_raise( rb_eArgError,
1120
+ rb_raise( rb_eArgError,
1080
1121
  "Invalid arguments to P4::Map#translate. "
1081
1122
  "Pass the string you wish to translate, and an optional "
1082
1123
  "boolean to indicate whether translation should be in "
@@ -1155,6 +1196,14 @@ static VALUE p4msg_get_text( VALUE self )
1155
1196
  return e->GetText();
1156
1197
  }
1157
1198
 
1199
+ static VALUE p4msg_get_dict( VALUE self )
1200
+ {
1201
+ P4Error * e = 0;
1202
+
1203
+ Data_Get_Struct( self, P4Error, e );
1204
+ return e->GetDict();
1205
+ }
1206
+
1158
1207
  static VALUE p4msg_get_id( VALUE self )
1159
1208
  {
1160
1209
  P4Error * e = 0;
@@ -1197,6 +1246,8 @@ void Init_P4()
1197
1246
  rb_define_method( cP4, "tagged=", RUBY_METHOD_FUNC(p4_set_tagged), 1 );
1198
1247
  rb_define_method( cP4, "track?", RUBY_METHOD_FUNC(p4_get_track) , 0 );
1199
1248
  rb_define_method( cP4, "track=", RUBY_METHOD_FUNC(p4_set_track) , 1 );
1249
+ rb_define_method( cP4, "graph?", RUBY_METHOD_FUNC(p4_get_graph) , 0 );
1250
+ rb_define_method( cP4, "graph=", RUBY_METHOD_FUNC(p4_set_graph) , 1 );
1200
1251
 
1201
1252
 
1202
1253
  // Perforce client settings.
@@ -1228,6 +1279,8 @@ void Init_P4()
1228
1279
  rb_define_method( cP4, "protocol", RUBY_METHOD_FUNC(p4_set_protocol), 2 );
1229
1280
  rb_define_method( cP4, "ticket_file", RUBY_METHOD_FUNC(p4_get_ticket_file), 0 );
1230
1281
  rb_define_method( cP4, "ticket_file=", RUBY_METHOD_FUNC(p4_set_ticket_file), 1 );
1282
+ rb_define_method( cP4, "trust_file", RUBY_METHOD_FUNC(p4_get_trust_file), 0 );
1283
+ rb_define_method( cP4, "trust_file=", RUBY_METHOD_FUNC(p4_set_trust_file), 1 );
1231
1284
  rb_define_method( cP4, "user", RUBY_METHOD_FUNC(p4_get_user) , 0 );
1232
1285
  rb_define_method( cP4, "user=", RUBY_METHOD_FUNC(p4_set_user) , 1 );
1233
1286
  rb_define_method( cP4, "version", RUBY_METHOD_FUNC(p4_get_version) , 0 );
@@ -1327,6 +1380,7 @@ void Init_P4()
1327
1380
  rb_define_method( cP4Msg, "msgid", RUBY_METHOD_FUNC(p4msg_get_id), 0);
1328
1381
  rb_define_method( cP4Msg, "severity", RUBY_METHOD_FUNC(p4msg_get_severity), 0);
1329
1382
  rb_define_method( cP4Msg, "generic", RUBY_METHOD_FUNC(p4msg_get_generic), 0);
1383
+ rb_define_method( cP4Msg, "dictionary", RUBY_METHOD_FUNC(p4msg_get_dict), 0);
1330
1384
  rb_define_method( cP4Msg, "to_s", RUBY_METHOD_FUNC(p4msg_get_text), 0);
1331
1385
 
1332
1386
  // P4::Progress class.
@@ -92,9 +92,19 @@ P4ClientApi::P4ClientApi() : ui( &specMgr )
92
92
  const char *t;
93
93
 
94
94
  henv.GetTicketFile( ticketFile );
95
-
95
+
96
+ if( (t = enviro->Get("P4TICKETS")) )
97
+ ticketFile = t;
98
+
99
+ //
100
+ // Load the current trust file. Start with the default, and then
101
+ // override it if P4TRUST is set.
102
+ //
103
+
104
+ henv.GetTrustFile( trustFile );
105
+
96
106
  if( (t = enviro->Get("P4TICKETS")) )
97
- ticketFile = t;
107
+ trustFile = t;
98
108
 
99
109
  //
100
110
  // Load the current P4CHARSET if set.
@@ -132,7 +142,7 @@ P4ClientApi::GetEnviroFile()
132
142
  return enviro->GetEnviroFile();
133
143
  }
134
144
 
135
- void
145
+ void
136
146
  P4ClientApi::SetApiLevel( int level )
137
147
  {
138
148
  StrBuf b;
@@ -192,7 +202,14 @@ P4ClientApi::SetTicketFile( const char *p )
192
202
  ticketFile = p;
193
203
  }
194
204
 
195
- void
205
+ void
206
+ P4ClientApi::SetTrustFile( const char *p )
207
+ {
208
+ client.SetTrustFile( p );
209
+ trustFile = p;
210
+ }
211
+
212
+ void
196
213
  P4ClientApi::SetDebug( int d )
197
214
  {
198
215
  debug = d;
@@ -241,7 +258,7 @@ P4ClientApi::SetEnv( const char *var, const char *val )
241
258
  // connect to the Perforce server.
242
259
  //
243
260
 
244
- VALUE
261
+ VALUE
245
262
  P4ClientApi::Connect()
246
263
  {
247
264
  if ( P4RDB_COMMANDS )
@@ -288,7 +305,7 @@ P4ClientApi::ConnectOrReconnect()
288
305
  //
289
306
  // Disconnect session
290
307
  //
291
- VALUE
308
+ VALUE
292
309
  P4ClientApi::Disconnect()
293
310
  {
294
311
  if ( P4RDB_COMMANDS )
@@ -306,6 +323,9 @@ P4ClientApi::Disconnect()
306
323
  // Clear the specdef cache.
307
324
  specMgr.Reset();
308
325
 
326
+ // Clear out any results from the last command
327
+ ui.Reset();
328
+
309
329
  return Qtrue;
310
330
  }
311
331
 
@@ -322,7 +342,7 @@ P4ClientApi::Connected()
322
342
  return Qfalse;
323
343
  }
324
344
 
325
- void
345
+ void
326
346
  P4ClientApi::Tagged( int enable )
327
347
  {
328
348
  if( enable )
@@ -359,6 +379,14 @@ void P4ClientApi::SetStreams( int enable )
359
379
  ClearStreamsMode();
360
380
  }
361
381
 
382
+ void P4ClientApi::SetGraph( int enable )
383
+ {
384
+ if ( enable )
385
+ SetGraphMode();
386
+ else
387
+ ClearGraphMode();
388
+ }
389
+
362
390
  int
363
391
  P4ClientApi::GetServerLevel()
364
392
  {
@@ -410,7 +438,7 @@ P4ClientApi::IsIgnored( const char *path )
410
438
  // is raised.
411
439
  //
412
440
 
413
- VALUE
441
+ VALUE
414
442
  P4ClientApi::Run( const char *cmd, int argc, char * const *argv )
415
443
  {
416
444
  // Save the entire command string for our error messages. Makes it
@@ -480,6 +508,9 @@ P4ClientApi::RunCmd( const char *cmd, ClientUser *ui, int argc, char * const *ar
480
508
  if ( IsStreams() && apiLevel > 69 )
481
509
  client.SetVar( "enableStreams", "" );
482
510
 
511
+ if ( IsGraph() && apiLevel > 81 )
512
+ client.SetVar( "enableGraph", "" );
513
+
483
514
  // If maxresults or maxscanrows is set, enforce them now
484
515
  if( maxResults ) client.SetVar( "maxResults", maxResults );
485
516
  if( maxScanRows ) client.SetVar( "maxScanRows", maxScanRows );
@@ -512,7 +543,7 @@ P4ClientApi::RunCmd( const char *cmd, ClientUser *ui, int argc, char * const *ar
512
543
 
513
544
  //
514
545
  // Parses a string supplied by the user into a hash. To do this we need
515
- // the specstring from the server. We try to cache those as we see them,
546
+ // the specstring from the server. We try to cache those as we see them,
516
547
  // but the user may not have executed any commands to allow us to cache
517
548
  // them so we may have to fetch the spec first.
518
549
  //
@@ -540,7 +571,7 @@ P4ClientApi::ParseSpec( const char * type, const char *form )
540
571
  Error e;
541
572
  VALUE v;
542
573
  v = specMgr.StringToSpec( type, form, &e );
543
-
574
+
544
575
  if ( e.Test() )
545
576
  {
546
577
  if( exceptionLevel )
@@ -551,7 +582,7 @@ P4ClientApi::ParseSpec( const char * type, const char *form )
551
582
 
552
583
  return v;
553
584
  }
554
-
585
+
555
586
 
556
587
  //
557
588
  // Converts a hash supplied by the user into a string using the specstring
@@ -577,14 +608,14 @@ P4ClientApi::FormatSpec( const char * type, VALUE hash )
577
608
  }
578
609
  }
579
610
 
580
- // Got a specdef so now we can attempt to convert.
611
+ // Got a specdef so now we can attempt to convert.
581
612
  StrBuf buf;
582
613
  Error e;
583
614
 
584
615
  specMgr.SpecToString( type, hash, buf, &e );
585
616
  if( !e.Test() )
586
617
  return P4Utils::ruby_string( buf.Text() );
587
-
618
+
588
619
  if( exceptionLevel )
589
620
  {
590
621
  StrBuf m;
@@ -620,7 +651,7 @@ P4ClientApi::SpecFields( const char * type )
620
651
 
621
652
  return specMgr.SpecFields( type );
622
653
  }
623
-
654
+
624
655
  //
625
656
  // Raises an exception or returns Qfalse on bad input
626
657
  //
@@ -686,13 +717,13 @@ P4ClientApi::Except( const char *func, const char *msg )
686
717
  StrBuf errors;
687
718
  StrBuf warnings;
688
719
  int terminate = 0;
689
-
720
+
690
721
  m << "[" << func << "] " << msg;
691
722
 
692
723
  // Now append any errors and warnings to the text
693
724
  ui.GetResults().FmtErrors( errors );
694
725
  ui.GetResults().FmtWarnings( warnings );
695
-
726
+
696
727
  if( errors.Length() )
697
728
  {
698
729
  m << "\n" << errors;
@@ -729,4 +760,3 @@ P4ClientApi::Except( const char *func, Error *e )
729
760
  e->Fmt( &m );
730
761
  Except( func, m.Text() );
731
762
  }
732
-