Skip to content

Commit

Permalink
Do not generate the partial packaged source code anymore.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreibancioiu committed May 28, 2024
1 parent 5accc1b commit 79ff809
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
1 change: 0 additions & 1 deletion multiversx_sdk_rust_contract_builder/build_outcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def many_from_folders(cls, build_folder: Path, output_folder: Path) -> Dict[str,
entry.codehash = find_file_in_folder(output_folder, f"{contract_name}.codehash.txt").read_text()
entry.bytecode_path = BuildArtifact.find_in_output(f"{contract_name}.wasm", output_folder)
entry.abi_path = BuildArtifact.find_in_output(f"{contract_name}.abi.json", output_folder)
# This is the whole project source code. The file *.partial-source.json is not listed here - so that it's advertised as little as possible.
entry.src_package_path = BuildArtifact.find_in_output("*.source.json", output_folder)

result[contract_name] = entry
Expand Down
12 changes: 0 additions & 12 deletions multiversx_sdk_rust_contract_builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,13 @@ def build_project(
# The bundle (packaged source code) is created after build, so that Cargo.lock files are included (if previously missing).
create_packaged_source_code(
parent_project_folder=project_within_build_folder,
package_whole_project_src=True,
contract_folder=contract_build_subfolder,
output_folder=output_subfolder,
build_metadata=metadata.to_dict(),
build_options=options.to_dict(),
package_filename=f"{contract_name}-{contract_version}.source.json"
)

create_packaged_source_code(
parent_project_folder=project_within_build_folder,
package_whole_project_src=False,
contract_folder=contract_build_subfolder,
output_folder=output_subfolder,
build_metadata=metadata.to_dict(),
build_options=options.to_dict(),
package_filename=f"{contract_name}-{contract_version}.partial-source.json"
)
outcome.gather_artifacts(contract_build_subfolder, output_subfolder)

return outcome
Expand Down Expand Up @@ -175,7 +165,6 @@ def build_contract(build_folder: Path, output_folder: Path, cargo_target_dir: Pa

def create_packaged_source_code(
parent_project_folder: Path,
package_whole_project_src: bool,
contract_folder: Path,
output_folder: Path,
build_metadata: Dict[str, Any],
Expand All @@ -185,7 +174,6 @@ def create_packaged_source_code(
source_code_files = source_code.get_source_code_files(
project_folder=parent_project_folder,
contract_folder=contract_folder,
include_unrelated_to_contract=package_whole_project_src
)

contract_name, contract_version = get_contract_name_and_version(contract_folder)
Expand Down
16 changes: 6 additions & 10 deletions multiversx_sdk_rust_contract_builder/source_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
def get_source_code_files(
project_folder: Path,
contract_folder: Path,
include_unrelated_to_contract: bool
) -> List[SourceCodeFile]:
"""
Returns the source code files of the specified contract.
If `include_unrelated_to_contract` is True, also returns project files that are not strictly related to the specified contract.
"""
source_code_files: List[SourceCodeFile] = []

Expand All @@ -46,14 +43,13 @@ def get_source_code_files(
for file in files:
source_code_files.append(SourceCodeFile(file, dependency_folder, dependency_depth))

# Finally, add remaining files (unrelated to contract), if desired
files_related_to_contract = set(file.path for file in source_code_files)
# Finally, add remaining files from the project
already_added_files = set(file.path for file in source_code_files)

if include_unrelated_to_contract:
all_files = _get_source_code_files(project_folder)
for file in all_files:
if file not in files_related_to_contract:
source_code_files.append(SourceCodeFile(file, contract_folder, sys.maxsize))
all_files = _get_source_code_files(project_folder)
for file in all_files:
if file not in already_added_files:
source_code_files.append(SourceCodeFile(file, contract_folder, sys.maxsize))

return source_code_files

Expand Down

0 comments on commit 79ff809

Please sign in to comment.