Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build automation tool. #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iamanandkr95
Copy link
Collaborator

A rudimentary build tool that takes in a name as an argument and then builds the dependencies, ensures all files are present and executes the build command.

@iamanandkr95 iamanandkr95 changed the title Added build and build_test. Build automation tool. Oct 13, 2019
Copy link
Owner

@kaustubh-karkare kaustubh-karkare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start!

FILES = 'files'
COMMAND = 'command'

def __init__(self, build_file=os.path.join(os.getcwd(), 'build.json')):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't really need a default value here, you can just provide this path from the main section.
Create the entire graph here, check for cyclic dependencies and stuff.

:type name: str
"""

for build_instruction in self.build_instructions:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of O(n) search, you can create a Map<name, config>

import sys


class Build(object):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Looks like this class represents a single build.json file, and so can be called "BuildConfig". The individual items inside that are called "BuildRule"s.
  • If you create a map<full_rule_name, BuildRule>, I don't think you need a BuildConfig class.

"""

class BuildSpecs(enum.Enum):
BUILD = 'build.json'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unexpected. The rest of the items are attributes of the BuildRule structure, but this one is the file name, and so inconsistent.

:type files: list
"""

for file in files:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name "file" is not useful, since it isn't clear whether it is a file_name or file_handle or whatever else.



@contextlib.contextmanager
def create_and_change_to_tmpdir(working_directory):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the caller need to provide working_directory? You can just calculate it here.

return build_instruction
return None

def _buildDependencies(self, dependencies):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assumption: A depends on B & C, and both B & C depend on D.

  • Right now, you will build D twice. Can you avoid that?
  • Can you build B & C in parallel? Use subprocess.Popen, but you shouldn't need to use any multithreading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants