Ejemplo n.º 1
0
    def execute_build(self):
        # PROJECTS ARE RESTRICTED BASED ON THE COMMAND CONTEXT.
        # This provides consistent target semantics across all commands.
        projects = GetTargetProjects(self)

        # PRINT THE PARENTS OF EACH OF THE TARGET.
        immediate_only = not Options.options.allparents
        for project in projects:
            Logs.info('{}: {}'.format(project.name,
                                      GetParents(project, immediate_only)))
Ejemplo n.º 2
0
    def pre_build(self):
        # PRESERVE THE BEHAVIOR OF THE BUILD COMMAND.
        super(ProveContext, self).pre_build()

        # GATHER THE CHILDREN OF ALL PROJECTS.
        # A project expresses parent dependencies using the 'use', 'depends_on', 'runs_after'
        # or dynamic attribute. The children are gathered up front so that the algorithm can
        # efficiently traverse the project tree from parent to children.
        children_by_parent_name = defaultdict(set)
        projects = list(itertools.chain.from_iterable(self.groups))
        for project in projects:
            # Get the immediate parents of the project.
            parent_names = GetImmediateParents(project)

            # Add this project as a child of its parent project.
            for parent_name in parent_names:
                children_by_parent_name[parent_name].add(project)

        # TARGET PROJECTS ARE RESTRICTED BASED ON THE COMMAND CONTEXT.
        # This provides consistent target semantics across all commands.
        target_projects = GetTargetProjects(self)

        # BUILD ALL CHILDREN OF THE GIVEN TARGETS.
        visited_target_names = set()
        while target_projects:
            # VISIT EACH TARGET EXACTLY ONCE.
            target_project = target_projects.pop()
            already_visited = target_project.name in visited_target_names
            if already_visited:
                continue
            else:
                visited_target_names.add(target_project.name)

            # BUILD THE CURRENT PROJECT.
            # If the project has already been built, then the result will be cached.
            target_project.post()

            # VISIT ALL CHILDREN.
            child_projects = children_by_parent_name[target_project.name]
            target_projects.extend(child_projects)
Ejemplo n.º 3
0
    def execute_build(self):
        # PROJECTS ARE RESTRICTED BASED ON THE COMMAND CONTEXT.
        # This provides consistent target semantics across all commands.
        projects = GetTargetProjects(self)

        # PRINT THE PROJECTS' WSCRIPT PATHS (AND OPEN THEM IF REQUESTED).
        for project in projects:
            wscript_path = project.path.make_node(
                Context.WSCRIPT_FILE).abspath()
            Logs.info("{}: {}".format(project.name, wscript_path))

            # Open the wscript if requested, in the default program.
            if Options.options.open:
                OpenFileInDefaultProgram(wscript_path)
Ejemplo n.º 4
0
    def execute_build(self):
        # PROJECTS ARE RESTRICTED BASED ON THE COMMAND CONTEXT.
        # This provides consistent target semantics across all commands.
        projects = GetTargetProjects(self)

        # DELETE ALL OUTPUTS OF EACH PROJECT.
        # This technique will delete outputs for projects that share the same
        # build directory. This limitation is discussed in the class
        # documentation.
        build_dirs = set([project.path.get_bld() for project in projects])
        for build_dir in build_dirs:
            # BUILD DIRECTORIES ARE CREATED BY OTHER COMMANDS.
            # If no other command has been run, they will not exist.
            dir_exists = os.path.exists(build_dir.abspath())
            if not dir_exists:
                continue

            # DELETE FILES AND FOLDERS RECURSIVELY.
            try:
                shutil.rmtree(build_dir.abspath())
            except OSError:
                Logs.warn('Could not delete ' + build_dir.abspath())
Ejemplo n.º 5
0
    def pre_build(self):
        # GATHER THE CHILDREN OF ALL PROJECTS.
        # A project expresses parent dependencies using the 'use', 'depends_on', 'runs_after'
        # or dynamic attribute. The children are gathered up front so that the algorithm can
        # efficiently traverse the project tree from parent to children.
        children_by_parent_name = defaultdict(set)
        projects = list(itertools.chain.from_iterable(self.groups))
        for project in projects:
            # Get the immediate parents of the project.
            parent_names = GetImmediateParents(project)

            # Add this project as a child of its parent project.
            for parent_name in parent_names:
                children_by_parent_name[parent_name].add(project.name)

        # TARGET PROJECTS ARE RESTRICTED BASED ON THE COMMAND CONTEXT.
        # This provides consistent target semantics across all commands.
        target_projects = GetTargetProjects(self)

        # PRINT CHILDREN OF SPECIFIED TARGETS.
        for project in target_projects:
            Logs.info('{}: {}'.format(project.name, sorted(children_by_parent_name[project.name])))
Ejemplo n.º 6
0
    def execute_build(self):
        # LOAD THE TEMPLATE ENVIRONMENT.
        template_dir = self.path.find_node(
            'BuildFramework/Waf/IdeIntegration')
        template_loader = FileSystemLoader(template_dir.abspath())
        template_env = Environment(
            loader = template_loader,
            trim_blocks = True,
            lstrip_blocks = True)

        # PROJECTS ARE RESTRICTED BASED ON THE COMMAND CONTEXT.
        # This provides consistent target semantics across all commands.
        projects = GetTargetProjects(self)

        # GENERATE VISUAL STUDIO PROJECT FILES.
        solution_dirs = set([])
        solution_filepaths = set([])
        for waf_project in projects:
            # LOAD THE PROJECT.
            waf_project.post()
            
            # MAKE SURE THE PROJECT HAS USER WRITTEN FILES.
            # If there are no user written files, then the project generation will fail.
            # This is generally expected to occur when generating the Visual Studio
            # solution for an entire folder that contains generated libraries.  User
            # preference is to have these generated libraries skipped and to generate
            # the solution only with projects that have actual user written code.
            # Note that this behavior is consistent with the behavior for projects 
            # that use features where IDE generation is not supported.
            project = Project(waf_project)
            project_contains_user_written_files = project.HasUserWrittenFiles()
            if not project_contains_user_written_files:
                continue
            
            # EACH SUPPORTED LANGUAGE USES A DIFFERENT FILE FORMAT.
            is_cpp = ('cxx' in waf_project.features)
            is_dot_net = ('dot_net' in waf_project.features)
            is_asp_net_website = ('asp_net_website' in waf_project.features)
            is_asp_net_library = ('asp_net_library' in waf_project.features)
            if is_cpp:
                # GENERATE THE PROJECT FILE.
                self.GenerateCppProjectFile(template_env, waf_project)

                # GENERATE THE FILTER FILE.
                self.GenerateCppFilterFile(template_env, waf_project)

                # TRACK THE SOLUTION DIRECTORIES.
                solution_dirs.add(self.GetOutputDir(waf_project))

            elif is_dot_net:
                # GENERATE THE PROJECT FILE.
                self.GenerateDotNetProjectFile(template_env, waf_project)

                # TRACK THE SOLUTION DIRECTORIES.
                solution_dirs.add(self.GetOutputDir(waf_project))

            elif is_asp_net_library:
                # GENERATE THE PROJECT FILE.
                self.GenerateWebApplicationProjectFile(template_env, waf_project)

                # TRACK THE SOLUTION DIRECTORIES.
                solution_dirs.add(self.GetOutputDir(waf_project))

            elif is_asp_net_website:
                # GENERATE THE WEB SOLUTION.
                solution_filepaths.add(self.GenerateWebSolutionFile(template_env, waf_project))

                # GENERATE THE WEB PROJECT FILE.
                self.GenerateWebProjectFile(template_env, waf_project)

            else:
                continue

        # GENERATE THE VISUAL STUDIO SOLUTION FILES.
        for solution_dir in solution_dirs:
            solution_filepaths.add(self.GenerateSolutionFile(template_env, solution_dir))

        # OPEN THE VISUAL STUDIO PROJECT FILES.
        for solution_filepath in solution_filepaths:
            OpenFileInDefaultProgram(solution_filepath)
Ejemplo n.º 7
0
    def execute_build(self):
        # LOAD THE TEMPLATE ENVIRONMENT.
        template_dir = self.path.find_node('BuildFramework/Waf/IdeIntegration')
        template_loader = FileSystemLoader(template_dir.abspath())
        template_env = Environment(
            loader = template_loader,
            trim_blocks = True,
            lstrip_blocks = True)

        # PROJECTS ARE RESTRICTED BASED ON THE COMMAND CONTEXT.
        # This provides consistent target semantics across all commands.
        projects = GetTargetProjects(self)

        # GENERATE CODE BLOCKS PROJECT FILES.
        workspace_dirs = set([])
        for project in projects:
            # LOAD THE PROJECT.
            project.post()

            # MAKE SURE THE PROJECT HAS USER WRITTEN FILES.
            # If there are no user written files, then the project generation will fail.
            # This is generally expected to occur when generating the project
            # files for an entire folder that contains generated libraries.  User
            # preference is to have these generated libraries skipped and to generate
            # the solution only with projects that have actual user written code.
            # Note that this behavior is consistent with the behavior for projects 
            # that use features where IDE generation is not supported.
            waf_project = Project(project)
            project_contains_user_written_files = waf_project.HasUserWrittenFiles()
            if not project_contains_user_written_files:
                continue

            # EACH SUPPORTED LANGUAGE USES A DIFFERENT FILE FORMAT.
            is_cpp = ('cxx' in project.features)
            if is_cpp:
                # GENERATE THE PROJECT FILE.
                self.GenerateProjectFile(template_env, project)

                # TRACK THE SOLUTION DIRECTORIES.
                workspace_dirs.add(self.GetOutputDir(project))
            else:
                continue

        # AVOID OPENING AN EXCESSIVE NUMBER OF WORKSPACES.
        # Check if the workspaces should be opened.
        if Options.options.open:
            # Prevent opening too many instances of Code::Blocks at once if the user didn't specify targets.
            workspaces_to_open_count = len(workspace_dirs)
            WORKSPACES_TO_OPEN_MAX = 5
            opening_too_many_workspaces = (workspaces_to_open_count > WORKSPACES_TO_OPEN_MAX) and (not Options.options.targets)
            if opening_too_many_workspaces:
                # The user likely forgot to specify a target on the command line.
                error_message = 'Too many workspaces to open: {0}. Did you forget the --targets parameter?'.format(workspaces_to_open_count)
                raise Errors.WafError(error_message)

        # GENERATE THE CODE BLOCKS WORKSPACE FILES.
        for workspace_dir in workspace_dirs:
            workspace_filepath = self.GenerateWorkspaceFile(template_env, workspace_dir)

            # Check if the workspace should be opened.
            if Options.options.open:
                OpenFileInDefaultProgram(workspace_filepath)