library_headers_test.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2020 Google Inc. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package cc
  15. import (
  16. "strings"
  17. "testing"
  18. )
  19. func TestLibraryHeaders(t *testing.T) {
  20. ctx := testCc(t, `
  21. cc_library_headers {
  22. name: "headers",
  23. export_include_dirs: ["my_include"],
  24. }
  25. cc_library_static {
  26. name: "lib",
  27. srcs: ["foo.c"],
  28. header_libs: ["headers"],
  29. }
  30. `)
  31. // test if header search paths are correctly added
  32. cc := ctx.ModuleForTests("lib", "android_arm64_armv8-a_static").Rule("cc")
  33. cflags := cc.Args["cFlags"]
  34. if !strings.Contains(cflags, " -Imy_include ") {
  35. t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags)
  36. }
  37. }
  38. func TestPrebuiltLibraryHeaders(t *testing.T) {
  39. ctx := testCc(t, `
  40. cc_prebuilt_library_headers {
  41. name: "headers",
  42. export_include_dirs: ["my_include"],
  43. }
  44. cc_library_static {
  45. name: "lib",
  46. srcs: ["foo.c"],
  47. header_libs: ["headers"],
  48. }
  49. `)
  50. // test if header search paths are correctly added
  51. cc := ctx.ModuleForTests("lib", "android_arm64_armv8-a_static").Rule("cc")
  52. cflags := cc.Args["cFlags"]
  53. if !strings.Contains(cflags, " -Imy_include ") {
  54. t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags)
  55. }
  56. }