dtolnay / linkme

Safe cross-platform linker shenanigans
Apache License 2.0
626 stars 42 forks source link

Add support for Fuchsia #69

Closed danakj closed 1 year ago

danakj commented 1 year ago

Fuchsia uses the same linker section format as Linux, so it's just a matter of adding Fuchsia to the cfg branches.

Fixes #68.

danakj commented 1 year ago

This is me using the crate locally to register Gtests with C++ that are written in Rust. The tests are collected through linkme, so this demonstates it functioning on Fuchsia:

% out_fuchsia/Release/rust_gtest_interop_unittests
resolving fuchsia-pkg://fuchsia.com/rust_gtest_interop_unittests
Running test 'fuchsia-pkg://fuchsia.com/rust_gtest_interop_unittests#meta/rust_gtest_interop_unittests.cm'
[RUNNING]   main
[00018.011158][43598][43600][intl_property_manager][intl_property_manager] INFO: Launched component
[00018.012279][43598][43600][intl_property_manager][intl_property_manager] INFO: Serving initial profile profile=Profile { locales: Some([LocaleId { id: "en-US" }, LocaleId { id: "nl-NL" }]), calendars: None, time_zones: Some([TimeZoneId { id: "und-u-tz-uslax" }]), temperature_unit: None, __non_exhaustive: () }
[00018.012325][43598][43600][intl_property_manager][intl_property_manager] INFO: Starting server...
[stderr - main]
[41672:3254960519:ERROR:sys_info_fuchsia.cc(216)] Not implemented reached in static int base::SysInfo::NumberOfEfficientProcessorsImpl()
[43225:1704426231:WARNING:icu_util.cc(227)] Could not locate tzdata in config-data. Using built-in timezone database: No such file or directory (2)
***OK***: Ran 10 tests, yay!
[stdout - main]
IMPORTANT DEBUGGING NOTE: batches of tests are run inside their
own process. For debugging a test inside a debugger, use the
--gtest_filter=<your_test_name> flag along with
--single-process-tests.
Using sharding settings from environment. This is shard 0/1
Using 1 parallel jobs.
Note: Google Test filter = Test.*:ExactSuite.ExactTest
[==========] Running 10 tests from 2 test suites.
[----------] Global test environment set-up.
[----------] 9 tests from Test
[ RUN      ] Test.InGrandChildModule
[       OK ] Test.InGrandChildModule (0 ms)
[ RUN      ] Test.InFunctionBodyInChildModule
[       OK ] Test.InFunctionBodyInChildModule (0 ms)
[ RUN      ] Test.WithResultType
[       OK ] Test.WithResultType (0 ms)
[ RUN      ] Test.WithBoxResultType
[       OK ] Test.WithBoxResultType (0 ms)
[ DISABLED ] Test.DISABLED_WithError
[ RUN      ] Test.InTopModule
[       OK ] Test.InTopModule (0 ms)
[ RUN      ] Test.WithCustomMessage
[       OK ] Test.WithCustomMessage (0 ms)
[ RUN      ] Test.InChildModule
[       OK ] Test.InChildModule (0 ms)
[ RUN      ] Test.InFunctionBody
[       OK ] Test.InFunctionBody (0 ms)
[ RUN      ] Test.Paths
[       OK ] Test.Paths (3 ms)
[----------] 9 tests from Test (17 ms total)

[----------] 1 test from ExactSuite
[ RUN      ] ExactSuite.ExactTest
[       OK ] ExactSuite.ExactTest (0 ms)
[----------] 1 test from ExactSuite (0 ms total)

[----------] Global test environment tear-down
[==========] 10 tests from 2 test suites ran. (18 ms total)
[  PASSED  ] 10 tests.

  YOU HAVE 1 DISABLED TEST

[1/10] Test.InGrandChildModule (0 ms)
[2/10] Test.InFunctionBodyInChildModule (0 ms)
[3/10] Test.WithResultType (0 ms)
[4/10] Test.WithBoxResultType (0 ms)
[5/10] Test.InTopModule (0 ms)
[6/10] Test.WithCustomMessage (0 ms)
[7/10] Test.InChildModule (0 ms)
[8/10] Test.InFunctionBody (0 ms)
[9/10] Test.Paths (3 ms)
[10/10] ExactSuite.ExactTest (0 ms)
SUCCESS: all tests passed.
Tests took 0 seconds.
[PASSED]    main

1 out of 1 tests passed...
fuchsia-pkg://fuchsia.com/rust_gtest_interop_unittests#meta/rust_gtest_interop_unittests.cm completed with result: PASSED