Austin Schuh | 94f51e9 | 2017-10-30 19:25:32 -0700 | [diff] [blame^] | 1 | licenses(['notice']) |
| 2 | |
| 3 | genrule( |
| 4 | name = 'wpilib_version', |
| 5 | outs = ['shared/src/WPILibVersion.cpp'], |
| 6 | cmd = '\n'.join([ |
| 7 | "cat > \"$@\" << EOF", |
| 8 | "// Autogenerated file! Do not manually edit this file.", |
| 9 | "#include \"WPILibVersion.h\"", |
| 10 | "const char* GetWPILibVersion() {", |
| 11 | " return \"2018-frc971\";", |
| 12 | "}", |
| 13 | "EOF", |
| 14 | ]), |
| 15 | ) |
| 16 | |
| 17 | _header_dirs = [ |
| 18 | 'wpilibc/src/main/native/include', |
| 19 | #'wpilibc/shared/include', |
| 20 | #'wpilibc/athena/include', |
| 21 | 'hal/src/main/native/include', |
| 22 | 'hal/src/main/native/athena', |
| 23 | 'hal/src/main/native/include/HAL/cpp', |
| 24 | #'hal/include', |
| 25 | #'hal/lib/athena', |
| 26 | ] |
| 27 | |
| 28 | # Names of WPILib "devices" I don't want to deal with making trivial updates to |
| 29 | # chop out various ugliness or have to vet for sanity. |
| 30 | _excluded_devices = [ |
| 31 | 'ADXL345_I2C', |
| 32 | 'ADXL345_SPI', |
| 33 | 'ADXL362', |
| 34 | 'ADXRS450_Gyro', |
| 35 | 'AnalogAccelerometer', |
| 36 | #'AnalogGyro', |
| 37 | 'AnalogPotentiometer', |
| 38 | 'CANJaguar', |
| 39 | 'CANSpeedController', |
| 40 | 'CANTalon', |
| 41 | 'CameraServer', |
| 42 | 'DoubleSolenoid', |
| 43 | 'GamepadBase', |
| 44 | 'GearTooth', |
| 45 | 'GenericHID', |
| 46 | #'GyroBase', |
| 47 | 'IterativeRobot', |
| 48 | 'Jaguar', |
| 49 | 'Joystick', |
| 50 | 'JoystickBase', |
| 51 | #'Log', |
| 52 | #'MotorSafety', |
| 53 | #'MotorSafetyHelper', |
| 54 | 'OSSerialPort', |
| 55 | #'PIDController', |
| 56 | #'PIDSource', |
| 57 | #'PWMSpeedController', |
| 58 | 'Potentiometer', |
| 59 | 'RobotDrive', |
| 60 | 'SD540', |
| 61 | #'SafePWM', |
| 62 | #'SerialHelper', |
| 63 | #'SerialPort', |
| 64 | 'Spark', |
| 65 | #'SpeedController', |
| 66 | 'TalonSRX', |
| 67 | 'Ultrasonic', |
| 68 | 'Victor', |
| 69 | 'XboxController', |
| 70 | #'visa', |
| 71 | ] |
| 72 | |
| 73 | # Whole subdirectories of WPILib we don't want around. |
| 74 | _excluded_directories = [ |
| 75 | #'SmartDashboard', |
| 76 | #'LiveWindow', |
| 77 | #'Commands', |
| 78 | #'Buttons', |
| 79 | #'Filters', |
| 80 | 'LabView', |
| 81 | 'vision', |
| 82 | ] |
| 83 | |
| 84 | # Header files we don't want to have. |
| 85 | _bad_hdrs = ([ |
| 86 | 'wpilibc/src/main/native/include/WPILib.h', |
| 87 | 'hal/src/main/native/include/HAL/LabVIEW/HAL.h', |
| 88 | #'wpilibc/**/Accelerometer.*', |
| 89 | ] + ['**/%s/**' % d for d in _excluded_directories] + |
| 90 | ['**/%s.*' % d for d in _excluded_devices]) |
| 91 | _h_hdrs = glob([d + '/**/*.h' for d in _header_dirs], exclude=_bad_hdrs) |
| 92 | _hpp_hdrs = glob([d + '/**/*.hpp' for d in _header_dirs], exclude=_bad_hdrs) |
| 93 | |
| 94 | cc_library( |
| 95 | name = 'wpilib', |
| 96 | visibility = ['//third_party:__pkg__'], |
| 97 | srcs = glob([ |
| 98 | 'wpilibc/src/main/native/cpp/*.cpp', |
| 99 | 'wpilibc/src/main/native/cpp/interfaces/*.cpp', |
| 100 | 'wpilibc/src/main/native/cpp/LiveWindow/*.cpp', |
| 101 | 'wpilibc/src/main/native/cpp/Commands/*.cpp', |
| 102 | 'wpilibc/src/main/native/cpp/SmartDashboard/*.cpp', |
| 103 | |
| 104 | 'hal/src/main/native/athena/*.cpp', |
| 105 | 'hal/src/main/native/athena/cpp/*.cpp', |
| 106 | 'hal/src/main/native/athena/ctre/*.cpp', |
| 107 | 'hal/src/main/native/shared/handles/*.cpp', |
| 108 | 'wpilibc/src/main/native/cpp/Internal/*.cpp', |
| 109 | ], exclude = ( |
| 110 | ['**/%s/**' % d for d in _excluded_directories] + |
| 111 | ['**/%s.*' % d for d in _excluded_devices] + [ |
| 112 | #'wpilibc/**/Accelerometer.*', |
| 113 | ])) + [ |
| 114 | ':wpilib_version', |
| 115 | ], |
| 116 | copts = [ |
| 117 | '-Wno-unused-parameter', |
| 118 | '-Wno-switch-enum', |
| 119 | '-Wno-attributes', |
| 120 | '-Wno-cast-align', |
| 121 | '-Wno-cast-qual', |
| 122 | '-Wno-deprecated-declarations', |
| 123 | '-Wno-error', |
| 124 | #'-Wno-unused-const-variable', |
| 125 | ], |
| 126 | deps = [ |
| 127 | '//third_party/ntcore_2018:ntcore', |
| 128 | '@allwpilib_ni_libraries_repo_2018//:ni-libraries', |
| 129 | '//aos/common/logging', |
| 130 | ], |
| 131 | hdrs = _h_hdrs + _hpp_hdrs + [ |
| 132 | 'wpilibc/src/main/native/include/circular_buffer.inc', |
| 133 | 'wpilibc/src/main/native/include/SpeedControllerGroup.inc', |
| 134 | ], |
| 135 | includes = _header_dirs, |
| 136 | linkopts = [ |
| 137 | '-lpthread', |
| 138 | ], |
| 139 | defines = [ |
| 140 | 'WPILIB2018=1', |
| 141 | ], |
| 142 | restricted_to = ['//tools:roborio'], |
| 143 | ) |