summaryrefslogtreecommitdiff
path: root/build3/premake4.lua
blob: 73dbd896538a5b109e4d7f8f0b03a962084364e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705

	solution "0_Bullet3Solution"

	local osversion = os.getversion()
	print(string.format(" %d.%d.%d (%s)",
   		osversion.majorversion, osversion.minorversion, osversion.revision,
   		osversion.description))

	if _ACTION == "vs2010" or _ACTION=="vs2008" then
		buildoptions
		{
			-- Multithreaded compiling
			"/MP",
			-- Disable a few useless warnings
			"/wd4244",
			"/wd4267"
		}
	end

	act = ""

	if _ACTION then
		act = _ACTION
	end

	projectRootDir = os.getcwd() .. "/../"
	print("Project root directory: " .. projectRootDir);
	
	newoption {
		trigger     = "ios",
		description = "Enable iOS target (requires xcode4)"
	}

	newoption
	{
		trigger = "enable_system_glx",
		description = "Try to link against system glx instead of using glad_glx (default)"
	}

	newoption
	{
		trigger = "enable_system_opengl",
		description = "Try to link and use the system OpenGL headers version instead of dynamically loading OpenGL (dlopen is default)"
	}

	newoption
	{
		trigger = "enable_openvr",
		description = "Enable experimental Virtual Reality examples, using OpenVR for HTC Vive and Oculus Rift"
	}
	newoption
	{
		trigger = "enable_system_x11",
		description = "Try to link and use system X11 headers instead of dynamically loading X11 (dlopen is default)"
	}

	newoption
	{
		trigger = "enable_stable_pd",
		description = "Enable Stable PD control in PyBullet"
	}


	newoption
	{
		trigger = "enable_static_vr_plugin",
		description = "Statically link vr plugin (in examples/SharedMemory/plugins/vrSyncPlugin)"
	}
         newoption
        {
                trigger = "enable_static_test_plugin",
                description = "Statically link test plugin (in examples/SharedMemory/plugins/testPlugin)"
        }
         newoption
        {
                trigger = "enable_static_tiny_renderer__plugin",
                description = "Statically link vr plugin (in examples/SharedMemory/plugins/tinyRendererPlugin)"
        }
         newoption
        {
                trigger = "enable_static_pd_control_plugin",
                description = "Statically link vr plugin (in examples/SharedMemory/plugins/pdControlPlugin)"
        }
         newoption
        {
                trigger = "enable_static_collision_filter_plugin",
                description = "Statically link vr plugin (in examples/SharedMemory/plugins/collisionFilterPlugin)"
        }
 
	newoption
	{
		trigger = "enable_physx",
		description = "Allow optional PhysX backend for PyBullet, use pybullet.connect(pybullet.PhysX)."
	}

	newoption
	{
		trigger = "noopengl3",
		description = "Don't compile any OpenGL3+ code"
	}

	newoption
	{
		trigger = "midi",
		description = "Use Midi controller to control parameters"
	}
	
	
	newoption
	{
		trigger = "enable_egl",
		value       = false,
		description = "Build an experimental eglPlugin"
	}

	
	newoption
	{
		trigger = "enable_grpc",
		description = "Build GRPC server/client features for PyBullet/BulletRobotics"
	
	}

	if os.is("Linux") then
                default_grpc_include_dir = "usr/local/include/GRPC"
                default_grpc_lib_dir = "/usr/local/lib"
                default_protobuf_include_dir = "/usr/local/include/protobuf"
                default_protobuf_lib_dir = "/usr/local/lib"
	end

	if os.is("macosx") then
                default_grpc_include_dir = "/usr/local/Cellar/grpc/1.14.1/include"
                default_grpc_lib_dir = "/usr/local/Cellar/grpc/1.14.1/lib"
								default_protobuf_include_dir = "/usr/local/Cellar/protobuf/3.6.0/include"
                default_protobuf_lib_dir = "/usr/local/Cellar/protobuf/3.6.0/lib"
	end

	if os.is("Windows") then
                default_grpc_include_dir = projectRootDir .. "examples/ThirdPartyLibs/grpc/include"
                default_grpc_lib_dir = projectRootDir .. "examples/ThirdPartyLibs/grpc/lib"
                default_protobuf_include_dir =projectRootDir .. "examples/ThirdPartyLibs/grpc/include"
                default_protobuf_lib_dir = projectRootDir .. "examples/ThirdPartyLibs/grpc/lib"
	end
	
	newoption
	{
                        trigger     = "grpc_include_dir",
                        value       = default_grpc_include_dir,
                        description = "(optional) GRPC include directory"
	}

	newoption
	{
                        trigger     = "grpc_lib_dir",
                        value       = default_grpc_lib_dir,
                        description = "(optional) GRPC library directory "
	}


	newoption
        {
                        trigger     = "protobuf_include_dir",
                        value       = default_protobuf_include_dir,
                        description = "(optional) protobuf include directory"
        }

        newoption
        {
                        trigger     = "protobuf_lib_dir",
                        value       = default_protobuf_lib_dir,
                        description = "(optional) protobuf library directory "
        }


	if not _OPTIONS["grpc_lib_dir"] then
		_OPTIONS["grpc_lib_dir"] = default_grpc_lib_dir
	end
	if not _OPTIONS["grpc_include_dir"] then
		_OPTIONS["grpc_include_dir"] = default_grpc_include_dir
	end
	if not _OPTIONS["protobuf_include_dir"] then
		_OPTIONS["protobuf_include_dir"] = default_protobuf_include_dir
	end	
	
	if not _OPTIONS["protobuf_lib_dir"] then
		_OPTIONS["protobuf_lib_dir"] = default_protobuf_lib_dir
	end	
	

	if _OPTIONS["enable_egl"] then
		function initEGL()
			defines {"BT_USE_EGL"}
		end
	end	
	
	
	if _OPTIONS["enable_grpc"] then
	function initGRPC()
	

			print "BT_ENABLE_GRPC"

			print("grpc_include_dir=")
			print(_OPTIONS["grpc_include_dir"])
			print("grpc_lib_dir=")
			print(_OPTIONS["grpc_lib_dir"])
			print("protobuf_include_dir=")
			print(_OPTIONS["protobuf_include_dir"])
			print("protobuf_lib_dir=")
			print(_OPTIONS["protobuf_lib_dir"])
			
			defines {"BT_ENABLE_GRPC"}
			
				if os.is("macosx") then
			 buildoptions { "-std=c++11" }
			 links{ "dl"}
			end
			
			if os.is("Linux") then
			 		buildoptions { "-std=c++11" }
					links{ "dl"}
			end
			
			if os.is("Windows") then
					defines {"_WIN32_WINNT=0x0600"}
					links{ "zlibstatic","ssl","crypto"}
			end

      includedirs {
             projectRootDir .. "examples", _OPTIONS["grpc_include_dir"], _OPTIONS["protobuf_include_dir"],
      }

			if os.is("Windows") then
				configuration {"x64", "debug"}			
						libdirs {_OPTIONS["grpc_lib_dir"] .. "/win64_debug" , _OPTIONS["protobuf_lib_dir"] .. "win64_debug",}
				configuration {"x86", "debug"}
						libdirs {_OPTIONS["grpc_lib_dir"] .. "/win32_debug" , _OPTIONS["protobuf_lib_dir"] .. "win32_debug",}
				configuration {"x64", "release"}
						libdirs {_OPTIONS["grpc_lib_dir"] .. "/win64_release", _OPTIONS["protobuf_lib_dir"] .. "win64_release",}
				configuration {"x86", "release"}
						libdirs {_OPTIONS["grpc_lib_dir"] .. "/win32_release" , _OPTIONS["protobuf_lib_dir"] .. "win32_release",}
				configuration{}
				
				else
				libdirs {_OPTIONS["grpc_lib_dir"], _OPTIONS["protobuf_lib_dir"],}
			end
      
      links { "grpc","grpc++", "grpc++_reflection", "gpr", "protobuf"}
      files { 
      projectRootDir .. "examples/SharedMemory/grpc/ConvertGRPCBullet.cpp",
			projectRootDir .. "examples/SharedMemory/grpc/ConvertGRPCBullet.h",
			projectRootDir .. "examples/SharedMemory/grpc/proto/pybullet.grpc.pb.cpp",
			projectRootDir .. "examples/SharedMemory/grpc/proto/pybullet.grpc.pb.h",
			projectRootDir .. "examples/SharedMemory/grpc/proto/pybullet.pb.cpp",
			projectRootDir .. "examples/SharedMemory/grpc/proto/pybullet.pb.h", }
		end

	end

-- _OPTIONS["midi"] = "1";

	newoption
	{
		trigger = "no-demos",
		description = "Don't build demos"
	}

	newoption
	{
		trigger = "no-extras",
		description = "Don't build Extras"
	}

	newoption
	{
		trigger = "standalone-examples",
		description = "Build standalone examples with reduced dependencies."
	}

	newoption
	{
		trigger = "no-clsocket",
		description = "Disable clsocket and clsocket tests (used for optional TCP networking in pybullet and shared memory C-API)"
	}


	newoption
	{
		trigger = "no-enet",
		description = "Disable enet and enet tests (used for optional UDP networking in pybullet and shared memory C-API)"
	}

	newoption
	{
		trigger = "lua",
		description = "Enable Lua scipting support in Example Browser"
	}

	newoption
        {
                trigger = "enable_pybullet",
                description = "Enable high-level Python scripting of Bullet with URDF/SDF import and synthetic camera."
        }

if os.is("Linux") then
 		default_python_include_dir = "/usr/include/python2.7"
 		default_python_lib_dir = "/usr/local/lib/"
end

		
if os.is("Windows") then
 		default_python_include_dir = "C:/Python-3.5.2/include"
 		default_python_lib_dir = "C:/Python-3.5.2/libs"
end

		newoption
    {
			trigger     = "python_include_dir",
			value       = default_python_include_dir,
			description = "Python (2.x or 3.x) include directory"
    }
    
    newoption
    {
			trigger     = "python_lib_dir",
			value       = default_python_lib_dir,
			description = "Python (2.x or 3.x) library directory "
    }

	
	newoption {
		trigger     = "targetdir",
		value       = "path such as ../bin",
		description = "Set the output location for the generated project files"
	}

	newoption
	{
		trigger = "no-test",
		description = "Disable all tests"
	}
	newoption
        {       
                trigger = "test-bullet2",

                description = "Enable Bullet2 LinearMath test"
        }

	newoption
	{
		trigger = "no-gtest",
		description = "Disable unit tests using gtest"
	}

	newoption
	{
		trigger = "no-bullet3",
		description = "Do not build bullet3 libs"
	}

	newoption
	{
		trigger = "double",
		description = "Double precision version of Bullet"
	}

	newoption
	{
		trigger = "clamp-velocities",
		description = "Limit maximum velocities to reduce FP exception risk"
	}
	
	newoption
	{
		trigger = "serial",
		description = "Enable serial, for testing the VR glove in C++"
	}
	
	newoption
	{
		trigger = "audio",
		description = "Enable audio"
	}
	newoption
	{
		trigger = "enable_multithreading",
		description = "enable CPU multithreading for bullet2 libs"
	}
	if _OPTIONS["enable_multithreading"] then
		defines {"BT_THREADSAFE=1"}
	end
	if _OPTIONS["double"] then
		defines {"BT_USE_DOUBLE_PRECISION"}
	end
	if _OPTIONS["clamp-velocities"] then
		defines {"BT_CLAMP_VELOCITY_TO=9999"}
	end

	newoption
	{
		trigger = "dynamic-runtime",
		description = "Enable dynamic DLL CRT runtime"
	}
	configurations {"Release", "Debug"}
	configuration "Release"
		flags { "Optimize", "EnableSSE2", "NoMinimalRebuild", "FloatFast"}
		if not _OPTIONS["dynamic-runtime"] then
			flags { "StaticRuntime" } 
		end
	configuration "Debug"
		defines {"_DEBUG=1"}
		flags { "Symbols" , "NoMinimalRebuild", "NoEditAndContinue" ,"FloatFast"}
		if not _OPTIONS["dynamic-runtime"] then
			flags { "StaticRuntime" } 
		end


	if os.is("Linux") or os.is("macosx") then
		if os.is64bit() then
			platforms {"x64"}
		else
			platforms {"x32"}
		end
	else
		platforms {"x32","x64"}
	end

	configuration {"x32"}
		targetsuffix ("_" .. act)
	configuration "x64"
		targetsuffix ("_" .. act .. "_64" )
	configuration {"x64", "debug"}
		targetsuffix ("_" .. act .. "_x64_debug")
	configuration {"x64", "release"}
		targetsuffix ("_" .. act .. "_x64_release" )
	configuration {"x32", "debug"}
		targetsuffix ("_" .. act .. "_debug" )

	configuration{}

	postfix=""

	if _ACTION == "xcode4" then
		if _OPTIONS["ios"] then
			_OPTIONS["no-bullet3"] = "1"
			_OPTIONS["no-gtest"] = "1"

			postfix = "ios";
			xcodebuildsettings
			{
				'INFOPLIST_FILE = "../../test/Bullet2/Info.plist"',
				'CODE_SIGN_IDENTITY = "iPhone Developer"',
				"SDKROOT = iphoneos",
				'ARCHS = "armv7"',
				'TARGETED_DEVICE_FAMILY = "1,2"',
				'VALID_ARCHS = "armv7"',
			}
		else
			xcodebuildsettings
			{
				'ARCHS = "$(ARCHS_STANDARD_64_BIT)"',
				'VALID_ARCHS = "x86_64"',
--			'SDKROOT = "macosx10.9"',
			}
		end
	end

-- comment-out for now, URDF reader needs exceptions
--	flags { "NoRTTI", "NoExceptions"}
--	defines { "_HAS_EXCEPTIONS=0" }
--printf ( _OPTIONS["targetdir"] )

	targetdir( _OPTIONS["targetdir"] or "../bin" )
	location("./" .. act .. postfix)

	
	
	if not _OPTIONS["python_include_dir"] then
			_OPTIONS["python_include_dir"] = default_python_include_dir
	end
	
	if not _OPTIONS["python_lib_dir"] then
			_OPTIONS["python_lib_dir"] = default_python_lib_dir
	end

if os.is("Linux") then
                default_glfw_include_dir = "usr/local/include/GLFW"
                default_glfw_lib_dir = "/usr/local/lib/"
		default_glfw_lib_name = "glfw3"
end

if os.is("macosx") then
		default_glfw_include_dir = "/usr/local/Cellar/glfw/3.2.1/include"
		default_glfw_lib_dir = "/usr/local/Cellar/glfw/3.2.1/lib"
		default_glfw_lib_name = "glfw"
end

if os.is("Windows") then
                default_glfw_include_dir = "c:/glfw/include"
                default_glfw_lib_dir = "c:/glfw/lib"
		default_glfw_lib_name = "glfw3"
end

	

	
	if not _OPTIONS["glfw_lib_dir"] then
		_OPTIONS["glfw_lib_dir"] = default_glfw_lib_dir
	end
	if not _OPTIONS["glfw_include_dir"] then
		_OPTIONS["glfw_include_dir"] = default_glfw_include_dir
	end
	if not _OPTIONS["glfw_lib_name"] then
		_OPTIONS["glfw_lib_name"] = default_glfw_lib_name
	end	

	

	newoption
    {
			trigger     = "glfw_include_dir",
			value       = default_glfw_include_dir,
			description = "GLFW 3.x include directory"
    }
   
	 newoption
    {
                        trigger     = "glfw_lib_name",
                        value       = default_glfw_lib_name,
                        description = "GLFW 3.x library name (glfw, glfw3)"
    }
 
    newoption
    {
			trigger     = "glfw_lib_dir",
			value       = default_glfw_lib_dir,
			description = "(optional) GLFW 3.x library directory "
    }
    
    newoption
    {
			trigger     = "enable_glfw",
			value       = false,
			description = "(optional) use GLFW 3.x library"
    }
    
	if _OPTIONS["enable_glfw"] then
		defines {"B3_USE_GLFW"}
		
		function initOpenGL()
		includedirs {
					projectRootDir .. "examples/ThirdPartyLibs/glad"
			}
		
			includedirs {
				_OPTIONS["glfw_include_dir"],
			}
			
			libdirs {
				_OPTIONS["glfw_lib_dir"]
			}
			links { _OPTIONS["glfw_lib_name"]}
			files { projectRootDir .. "examples/ThirdPartyLibs/glad/glad.c" }
		end
		function findOpenGL3()
			return true
		end
		function initGlew()
		end
		function initX11()
		links {"X11", "dl","pthread"}

		end
		
	else
		dofile ("findOpenGLGlewGlut.lua")
		if (not findOpenGL3()) then
			defines {"NO_OPENGL3"}
		end
	end

	

	dofile ("findOpenCL.lua")
	dofile ("findDirectX11.lua")
	
	
	
	language "C++"


	
	
	

	if _OPTIONS["audio"] then
		include "../examples/TinyAudio"
	end

	if _OPTIONS["serial"] then
		include "../examples/ThirdPartyLibs/serial"
	end

	if not _OPTIONS["no-demos"] then
		include "../examples/ExampleBrowser"
		include "../examples/RobotSimulator"
		include "../examples/OpenGLWindow"
		include "../examples/ThirdPartyLibs/Gwen"
		include "../examples/HelloWorld"
		include "../examples/SharedMemory"
		include "../examples/ThirdPartyLibs/BussIK"

		if _OPTIONS["lua"] then
		   include "../examples/ThirdPartyLibs/lua-5.2.3"
		end
		if _OPTIONS["enable_pybullet"] then
		  include "../examples/pybullet"
		end
		include "../examples/SimpleOpenGL3"

		if _OPTIONS["standalone-examples"] then
			
			include "../examples/TinyRenderer"
			include "../examples/BasicDemo"
			include "../examples/InverseDynamics"
			include "../examples/ExtendedTutorials"
			include "../examples/MultiThreading"
		end

		if not _OPTIONS["no-test"] then
			include "../test/SharedMemory"
		end
	end

	if _OPTIONS["midi"] then
		include "../examples/ThirdPartyLibs/midi"
	end
	
	if not _OPTIONS["no-clsocket"] then
		defines {"BT_ENABLE_CLSOCKET"}
		include "../examples/ThirdPartyLibs/clsocket"		
		include "../test/clsocket"
	end

	if not _OPTIONS["no-enet"] then
				defines {"BT_ENABLE_ENET"}

				include "../examples/ThirdPartyLibs/enet"
				include "../test/enet/nat_punchthrough/client"
				include "../test/enet/nat_punchthrough/server"
				include "../test/enet/chat/client"
				include "../test/enet/chat/server"
	end

	 if _OPTIONS["no-bullet3"] then
                print "--no-bullet3 implies --no-demos"
                _OPTIONS["no-demos"] = "1"
        else
                include "../src/Bullet3Common"
                include "../src/Bullet3Geometry"
                include "../src/Bullet3Collision"
                include "../src/Bullet3Dynamics"
                include "../src/Bullet3OpenCL"
                include "../src/Bullet3Serialize/Bullet2FileLoader"
        end

        if _OPTIONS["no-extras"] then
                print "--no-extras implies --no-demos"
                _OPTIONS["no-demos"] = "1"
        else
                include "../Extras"
        end

	if not _OPTIONS["no-test"] then
                if _OPTIONS["test-bullet2"] then
		include "../test/Bullet2"
		end

		if not _OPTIONS["no-gtest"] then
			include "../test/gtest-1.7.0"
--			include "../test/hello_gtest"
			include "../test/collision"
			include "../test/BulletDynamics/pendulum"
			if not _OPTIONS["no-bullet3"] then
				if not _OPTIONS["no-extras"] then
					include "../test/InverseDynamics"
				end
				include "../test/TestBullet3OpenCL"
			end
			if not _OPTIONS["no-demos"] then
				-- Gwen is only used for demos
				include "../test/GwenOpenGLTest"
			end
		end
	end

	include "../src/BulletInverseDynamics"
 	include "../src/BulletSoftBody"
	include "../src/BulletDynamics"
	include "../src/BulletCollision"
	include "../src/LinearMath"
	if _OPTIONS["enable_physx"] then
		include "../src/physx"
	end