Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

Fix gleam publish writing wrong OTP app name in metadata

+49 -6
+7
CHANGELOG.md
··· 240 240 directly matches branch when existing variables with same exist in outer 241 241 scope. 242 242 ([Andrey Kozhev](https://github.com/ankddev)) 243 + 244 + - Fixed a bug where `gleam publish` wrote the wrong application name into the 245 + published package metadata for dependencies whose Hex package name differs 246 + from their internal OTP application name. This caused Mix-based projects to 247 + fail to build when they depended on Gleam packages with transitive 248 + dependencies. 249 + ([Logan Bresnahan](https://github.com/LoganBresnahan))
+42 -6
compiler-cli/src/publish.rs
··· 421 421 }) 422 422 .collect(); 423 423 424 + // Build a lookup from hex package name to OTP application name 425 + let hex_to_otp_app = manifest 426 + .packages 427 + .iter() 428 + .filter_map(|package| { 429 + package 430 + .otp_app 431 + .as_ref() 432 + .map(|otp_app_name| (package.name.clone(), otp_app_name.clone())) 433 + }) 434 + .collect::<HashMap<_, _>>(); 435 + 424 436 // Build the project to check that it is valid 425 437 let built = build::main( 426 438 paths, ··· 528 540 let src_files = project_files(Utf8Path::new(""))?; 529 541 let contents_tar_gz = contents_tarball(&src_files, &generated_files)?; 530 542 let version = "3"; 531 - let metadata = metadata_config(&built.root_package.config, &src_files, &generated_files)?; 543 + let metadata = metadata_config( 544 + &built.root_package.config, 545 + &hex_to_otp_app, 546 + &src_files, 547 + &generated_files, 548 + )?; 532 549 533 550 // Calculate checksum 534 551 let mut hasher = sha2::Sha256::new(); ··· 574 591 575 592 fn metadata_config<'a>( 576 593 config: &'a PackageConfig, 594 + hex_to_otp_app: &'a HashMap<EcoString, EcoString>, 577 595 source_files: &[Utf8PathBuf], 578 596 generated_files: &[(Utf8PathBuf, String)], 579 597 ) -> Result<String> { ··· 591 609 .map(|(name, requirement)| match requirement { 592 610 Requirement::Hex { version } => Ok(ReleaseRequirement { 593 611 name, 612 + otp_app: hex_to_otp_app 613 + .get(name) 614 + .map(EcoString::as_str) 615 + .unwrap_or(name.as_str()), 594 616 requirement: version, 595 617 }), 596 618 _ => Err(Error::PublishNonHexDependencies { ··· 810 832 requirement: &'a Range, 811 833 // Support alternate repositories at a later date. 812 834 // repository: String, 835 + otp_app: &'a str, 813 836 } 814 837 impl ReleaseRequirement<'_> { 815 838 pub fn as_erlang(&self) -> String { 816 839 format!( 817 840 r#" 818 - {{<<"{app}"/utf8>>, [ 819 - {{<<"app">>, <<"{app}"/utf8>>}}, 841 + {{<<"{name}"/utf8>>, [ 842 + {{<<"app">>, <<"{otp_app}"/utf8>>}}, 820 843 {{<<"optional">>, false}}, 821 844 {{<<"requirement">>, <<"{requirement}"/utf8>>}} 822 845 ]}}"#, 823 - app = self.name, 846 + name = self.name, 847 + otp_app = self.otp_app, 824 848 requirement = self.requirement, 825 849 ) 826 850 } ··· 860 884 requirements: vec![ 861 885 ReleaseRequirement { 862 886 name: "wibble", 887 + otp_app: "wibble", 863 888 requirement: &req1, 864 889 }, 865 890 ReleaseRequirement { 866 891 name: "wobble", 892 + otp_app: "wobble", 893 + requirement: &req2, 894 + }, 895 + ReleaseRequirement { 896 + name: "weeble_erl", 897 + otp_app: "weeble", 867 898 requirement: &req2, 868 899 }, 869 900 ], ··· 891 922 {<<"app">>, <<"wobble"/utf8>>}, 892 923 {<<"optional">>, false}, 893 924 {<<"requirement">>, <<"~> 1.2"/utf8>>} 925 + ]}, 926 + {<<"weeble_erl"/utf8>>, [ 927 + {<<"app">>, <<"weeble"/utf8>>}, 928 + {<<"optional">>, false}, 929 + {<<"requirement">>, <<"~> 1.2"/utf8>>} 894 930 ]} 895 931 ]}. 896 932 {<<"files">>, [ ··· 913 949 ..Default::default() 914 950 }; 915 951 assert_eq!( 916 - metadata_config(&config, &[], &[]), 952 + metadata_config(&config, &HashMap::new(), &[], &[]), 917 953 Err(Error::PublishNonHexDependencies { 918 954 package: "provided".into() 919 955 }) ··· 931 967 ..Default::default() 932 968 }; 933 969 assert_eq!( 934 - metadata_config(&config, &[], &[]), 970 + metadata_config(&config, &HashMap::new(), &[], &[]), 935 971 Err(Error::PublishNonHexDependencies { 936 972 package: "provided".into() 937 973 })