Loading etc/install_symlink.go +9 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ func init() { func RegisterInstallSymlinkBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("install_symlink", InstallSymlinkFactory) ctx.RegisterModuleType("install_symlink_host", InstallSymlinkHostFactory) } // install_symlink can be used to install an symlink with an arbitrary target to an arbitrary path Loading @@ -37,6 +38,14 @@ func InstallSymlinkFactory() android.Module { return module } // install_symlink can be used to install an symlink to an arbitrary path on the host. func InstallSymlinkHostFactory() android.Module { module := &InstallSymlink{} module.AddProperties(&module.properties) android.InitAndroidMultiTargetsArchModule(module, android.HostSupported, android.MultilibCommon) return module } type InstallSymlinkProperties struct { // Where to install this symlink, relative to the partition it's installed on. // Which partition it's installed on can be controlled by the vendor, system_ext, ramdisk, etc. Loading etc/install_symlink_test.go +36 −0 Original line number Diff line number Diff line Loading @@ -133,3 +133,39 @@ func TestErrorOnInstalledPathStartingWithSlash(t *testing.T) { } `) } var prepareForInstallSymlinkHostTest = android.GroupFixturePreparers( android.PrepareForTestWithAndroidBuildComponents, android.FixtureRegisterWithContext(RegisterInstallSymlinkBuildComponents), ) func TestInstallSymlinkHostBasic(t *testing.T) { result := prepareForInstallSymlinkHostTest.RunTestWithBp(t, ` install_symlink_host { name: "foo", installed_location: "bin/foo", symlink_target: "aa/bb/cc", } `) buildOS := result.Config.BuildOS.String() foo := result.ModuleForTests("foo", buildOS+"_common").Module() androidMkEntries := android.AndroidMkEntriesForTest(t, result.TestContext, foo) if len(androidMkEntries) != 1 { t.Fatalf("expected 1 androidmkentry, got %d", len(androidMkEntries)) } symlinks := androidMkEntries[0].EntryMap["LOCAL_SOONG_INSTALL_SYMLINKS"] if len(symlinks) != 1 { t.Fatalf("Expected 1 symlink, got %d", len(symlinks)) } if !strings.HasSuffix(symlinks[0], "bin/foo") { t.Fatalf("Expected symlink install path to end in bin/foo, got: %s", symlinks[0]) } if !strings.Contains(symlinks[0], "host") { t.Fatalf("Expected symlink install path to contain `host`, got: %s", symlinks[0]) } } Loading
etc/install_symlink.go +9 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ func init() { func RegisterInstallSymlinkBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("install_symlink", InstallSymlinkFactory) ctx.RegisterModuleType("install_symlink_host", InstallSymlinkHostFactory) } // install_symlink can be used to install an symlink with an arbitrary target to an arbitrary path Loading @@ -37,6 +38,14 @@ func InstallSymlinkFactory() android.Module { return module } // install_symlink can be used to install an symlink to an arbitrary path on the host. func InstallSymlinkHostFactory() android.Module { module := &InstallSymlink{} module.AddProperties(&module.properties) android.InitAndroidMultiTargetsArchModule(module, android.HostSupported, android.MultilibCommon) return module } type InstallSymlinkProperties struct { // Where to install this symlink, relative to the partition it's installed on. // Which partition it's installed on can be controlled by the vendor, system_ext, ramdisk, etc. Loading
etc/install_symlink_test.go +36 −0 Original line number Diff line number Diff line Loading @@ -133,3 +133,39 @@ func TestErrorOnInstalledPathStartingWithSlash(t *testing.T) { } `) } var prepareForInstallSymlinkHostTest = android.GroupFixturePreparers( android.PrepareForTestWithAndroidBuildComponents, android.FixtureRegisterWithContext(RegisterInstallSymlinkBuildComponents), ) func TestInstallSymlinkHostBasic(t *testing.T) { result := prepareForInstallSymlinkHostTest.RunTestWithBp(t, ` install_symlink_host { name: "foo", installed_location: "bin/foo", symlink_target: "aa/bb/cc", } `) buildOS := result.Config.BuildOS.String() foo := result.ModuleForTests("foo", buildOS+"_common").Module() androidMkEntries := android.AndroidMkEntriesForTest(t, result.TestContext, foo) if len(androidMkEntries) != 1 { t.Fatalf("expected 1 androidmkentry, got %d", len(androidMkEntries)) } symlinks := androidMkEntries[0].EntryMap["LOCAL_SOONG_INSTALL_SYMLINKS"] if len(symlinks) != 1 { t.Fatalf("Expected 1 symlink, got %d", len(symlinks)) } if !strings.HasSuffix(symlinks[0], "bin/foo") { t.Fatalf("Expected symlink install path to end in bin/foo, got: %s", symlinks[0]) } if !strings.Contains(symlinks[0], "host") { t.Fatalf("Expected symlink install path to contain `host`, got: %s", symlinks[0]) } }