コード例 #1
0
ファイル: file_installer.py プロジェクト: ssi-schaefer/confix
    def __automake_install_private_headers(self, makefile_am):

        # now for the private header files. this is a bit more
        # complicated as we have to do it by hand, using the all-local
        # hook.

        makefile_am.add_all_local('confix-install-local')
        makefile_am.add_clean_local('confix-clean-local')

        install_local_rule = makefile.Rule(targets=['confix-install-local'], prerequisites=[], commands=[])
        clean_local_rule = makefile.Rule(targets=['confix-clean-local'], prerequisites=[], commands=[])
        makefile_am.add_element(install_local_rule)        
        makefile_am.add_element(clean_local_rule)

        for installpath, files in self.__private_headers.iterate_dirs():
            if len(installpath):
                targetdir = '/'.join(['$(top_builddir)', const.LOCAL_INCLUDE_DIR]+installpath)
            else:
                targetdir = '/'.join(['$(top_builddir)', const.LOCAL_INCLUDE_DIR])
                pass
            
            # add mkdir rules for every subdirectory
            makefile_am.add_element(
                makefile.Rule(targets=[targetdir],
                              prerequisites=[],
                              commands=['-$(mkinstalldirs) '+targetdir]))

            # copy files
            for f in files:
                targetfile = '/'.join([targetdir, f])
                makefile_am.add_element(
                    makefile.Rule(targets=[targetfile],
                                  prerequisites=[f],
                                  commands=['-@$(mkinstalldirs) '+targetdir,
                                            'cp -fp $? '+' '+targetdir,
                                            'chmod 0444 '+targetfile]))
                makefile_am.add_element(
                    makefile.Rule(targets=[targetfile+'-clean'],
                                  prerequisites=[],
                                  commands=['rm -f '+targetfile]))
                install_local_rule.add_prerequisite(targetfile)
                clean_local_rule.add_prerequisite(targetfile+'-clean')
                pass
            pass
        pass
コード例 #2
0
def addAsSourceFileToMakeFile (sourcePath,
                               make,
                               BUILD_DIR,
                               ASBUILD_DIR,
                               AS_TOOL_WITH_OPTIONS,
                               includeDirsInCompilerCommand) :
  source = os.path.basename (sourcePath)
  objectFile = BUILD_DIR + "/" + source + ".o"
  objectFileForChecking = BUILD_DIR + "/" + source + ".check.o"
  asObjectFile = ASBUILD_DIR + "/" + source + ".s"
  if sourcePath != "" :
    rule = makefile.Rule ([objectFile], "Assembling " + source)
    rule.mOpenSourceOnError = False
    rule.mCommand += AS_TOOL_WITH_OPTIONS
    rule.mCommand += [sourcePath]
    rule.mCommand += ["-o", objectFile]
    rule.mCommand += includeDirsInCompilerCommand
    rule.mCommand += ["--MD", objectFile + ".dep"]
    rule.mDependences.append (sourcePath)
    rule.mDependences.append ("makefile.json")
    rule.enterSecondaryDependanceFile (objectFile + ".dep", make)
    make.addRule (rule)
#     objectFileList.append (objectFile)
  #--- Add listing file
    listingFile = ASBUILD_DIR + "/" + source + ".list"
    rule = makefile.Rule ([listingFile], "Assembling -> listing " + source)
    rule.mOpenSourceOnError = False
    rule.mCommand += AS_TOOL_WITH_OPTIONS
    rule.mCommand += [sourcePath]
    rule.mCommand += includeDirsInCompilerCommand
    rule.mCommand += ["-o", "/dev/null"]
    rule.mCommand += ["-aln=" + listingFile]
    rule.mDependences.append (sourcePath)
    rule.mDependences.append ("makefile.json")
    make.addRule (rule)
#     asObjectFileList.append (listingFile)
#--- Return ([goal], [objectFile], [listingFile])
  return ([objectFile], [listingFile])
コード例 #3
0
def buildDeployment(PRODUCT, deployment, verbose):
    goal = PRODUCT + ".uf2"
    rule = makefile.Rule([PRODUCT + ".uf2"],
                         "Converting elf to UF2 " + PRODUCT + ".elf")
    rule.mDependences.append(PRODUCT + ".elf")
    rule.mDependences.append("makefile.json")
    ELF2UF2_TOOL_PATH = download_and_install_elf_to_uf2.compile_install_elf2uf2(
    )
    rule.mCommand.append(ELF2UF2_TOOL_PATH)
    if verbose:
        rule.mCommand.append("-v")
    rule.mCommand.append(PRODUCT + ".elf")
    rule.mCommand.append(PRODUCT + ".uf2")
    return (goal, rule)
コード例 #4
0
    def run(self):
        startTime = time.time()
        #--- Source file list
        SOURCES = self.mDictionary["SOURCES"]
        #--- LIBPM
        LIBPM_DIRECTORY_PATH = self.mDictionary["LIBPM_DIRECTORY_PATH"]
        #--------------------------------------------------------------------------- System
        if self.mCrossCompilation == "":
            (SYSTEM_NAME, MODE_NAME, SYSTEM_RELEASE, SYSTEM_VERSION,
             MACHINE) = os.uname()
            if SYSTEM_NAME == "Darwin":
                MACHINE = "Intel"
            SYSTEM_MACHINE = SYSTEM_NAME + "-" + MACHINE
        else:
            SYSTEM_MACHINE = self.mCrossCompilation
    #--- GMP
        GMP_DIRECTORY_PATH = LIBPM_DIRECTORY_PATH + "/gmp"
        #--- Source directory list
        SOURCES_DIR = self.mDictionary["SOURCES_DIR"]
        #--------------------------------------------------------------------------- Include dirs
        SOURCES_DIR.append(LIBPM_DIRECTORY_PATH + "/bdd")
        SOURCES_DIR.append(LIBPM_DIRECTORY_PATH + "/command_line_interface")
        SOURCES_DIR.append(LIBPM_DIRECTORY_PATH + "/files")
        SOURCES_DIR.append(LIBPM_DIRECTORY_PATH + "/galgas")
        SOURCES_DIR.append(LIBPM_DIRECTORY_PATH + "/galgas2")
        SOURCES_DIR.append(LIBPM_DIRECTORY_PATH + "/gmp")
        SOURCES_DIR.append(LIBPM_DIRECTORY_PATH + "/streams")
        SOURCES_DIR.append(LIBPM_DIRECTORY_PATH + "/time")
        SOURCES_DIR.append(LIBPM_DIRECTORY_PATH + "/strings")
        SOURCES_DIR.append(LIBPM_DIRECTORY_PATH + "/utilities")
        includeDirs = ["-I" + GMP_DIRECTORY_PATH]
        for d in SOURCES_DIR:
            includeDirs.append("-I" + d)
    #--- Make object
        make = makefile.Make(
            self.mGoal, self.mMaxParallelJobs ==
            1)  # Display command utility tool path if sequential build
        #--------------------------------------------------------------------------- Add Compile rule for sources (release)
        #--- Object file directory
        objectDirectory = "../build/cli-objects/makefile-" + self.mTargetName + "-objects"
        #---
        objectFileList = []
        for source in SOURCES:
            objectFile = objectDirectory + "/" + source + ".o"
            objectFileList.append(objectFile)
            sourcePath = make.searchFileInDirectories(source, SOURCES_DIR)
            if sourcePath != "":
                extension = os.path.splitext(source)[1]
                rule = makefile.Rule([objectFile],
                                     self.mCompilationMessage + ": " + source)
                rule.deleteTargetDirectoryOnClean()
                rule.mDependences.append(sourcePath)
                rule.enterSecondaryDependanceFile(objectFile + ".dep", make)
                rule.mCommand += self.mCompilerTool
                rule.mCommand += self.mCompilerReleaseOptions
                rule.mCommand += self.mAllCompilerOptions
                if extension == ".c":
                    rule.mCommand += self.m_C_CompilerOptions
                elif extension == ".cpp":
                    rule.mCommand += self.m_Cpp_CompilerOptions
                rule.mCommand += ["-c", sourcePath]
                rule.mCommand += ["-o", objectFile]
                rule.mCommand += includeDirs
                rule.mCommand += ["-MD", "-MP", "-MF", objectFile + ".dep"]
                make.addRule(rule)
    #--------------------------------------------------------------------------- Add EXECUTABLE link rule
        EXECUTABLE = self.mExecutable + self.mExecutableSuffix
        rule = makefile.Rule([EXECUTABLE],
                             self.mLinkingMessage + ": " + EXECUTABLE)
        rule.mOnErrorDeleteTarget = True
        rule.deleteTargetFileOnClean()
        rule.mDependences += objectFileList
        rule.mDependences.append(self.mJSONfilePath)
        rule.mCommand += self.mLinkerTool
        rule.mCommand += objectFileList
        rule.mCommand += ["-o", EXECUTABLE]
        rule.mCommand += self.mLinkerOptions
        postCommand = makefile.PostCommand(self.mStripMessage + " " +
                                           EXECUTABLE)
        postCommand.mCommand += self.mStripTool
        postCommand.mCommand.append(EXECUTABLE)
        rule.mPostCommands.append(postCommand)
        rule.mPriority = 1
        make.addRule(rule)
        #--------------------------------------------------------------------------- Add Compile rule for sources (debug)
        #--- Object file directory
        debugObjectDirectory = "../build/cli-objects/makefile-" + self.mTargetName + "-debug-objects"
        #---
        debugObjectFileList = []
        for source in SOURCES:
            objectFile = debugObjectDirectory + "/" + source + ".o"
            debugObjectFileList.append(objectFile)
            sourcePath = make.searchFileInDirectories(source, SOURCES_DIR)
            if sourcePath != "":
                extension = os.path.splitext(source)[1]
                rule = makefile.Rule([objectFile], self.mCompilationMessage +
                                     " (debug): " + source)
                rule.deleteTargetDirectoryOnClean()
                rule.mDependences.append(sourcePath)
                rule.enterSecondaryDependanceFile(objectFile + ".dep", make)
                rule.mCommand += self.mCompilerTool
                rule.mCommand += self.mCompilerDebugOptions
                rule.mCommand += self.mAllCompilerOptions
                if extension == ".c":
                    rule.mCommand += self.m_C_CompilerOptions
                elif extension == ".cpp":
                    rule.mCommand += self.m_Cpp_CompilerOptions
                rule.mCommand += ["-c", sourcePath]
                rule.mCommand += ["-o", objectFile]
                rule.mCommand += includeDirs
                rule.mCommand += ["-MD", "-MP", "-MF", objectFile + ".dep"]
                make.addRule(rule)
    #--------------------------------------------------------------------------- Add EXECUTABLE_DEBUG link rule
        EXECUTABLE_DEBUG = self.mExecutable + "-debug" + self.mExecutableSuffix
        rule = makefile.Rule([EXECUTABLE_DEBUG], self.mLinkingMessage +
                             " (debug): " + EXECUTABLE_DEBUG)
        rule.mOnErrorDeleteTarget = True
        rule.deleteTargetFileOnClean()
        rule.mDependences += debugObjectFileList
        rule.mDependences.append(self.mJSONfilePath)
        rule.mCommand += self.mLinkerTool
        rule.mCommand += debugObjectFileList
        rule.mCommand += ["-o", EXECUTABLE_DEBUG]
        rule.mCommand += self.mLinkerOptions
        make.addRule(rule)
        #--------------------------------------------------------------------------- Add Compile rule for sources (lto)
        #--- Object file directory
        objectLTODirectory = "../build/cli-objects/makefile-" + self.mTargetName + "-objects-lto"
        #---
        ltoObjectFileList = []
        for source in SOURCES:
            objectFile = objectLTODirectory + "/" + source + ".o"
            ltoObjectFileList.append(objectFile)
            sourcePath = make.searchFileInDirectories(source, SOURCES_DIR)
            if sourcePath != "":
                extension = os.path.splitext(source)[1]
                rule = makefile.Rule([objectFile], self.mCompilationMessage +
                                     " (lto): " + source)
                rule.deleteTargetDirectoryOnClean()
                rule.mDependences.append(sourcePath)
                rule.enterSecondaryDependanceFile(objectFile + ".dep", make)
                rule.mCommand += self.mCompilerTool
                rule.mCommand += self.mCompilerReleaseOptions
                rule.mCommand += self.mAllCompilerOptions
                rule.mCommand += ["-flto"]
                if extension == ".c":
                    rule.mCommand += self.m_C_CompilerOptions
                elif extension == ".cpp":
                    rule.mCommand += self.m_Cpp_CompilerOptions
                rule.mCommand += ["-c", sourcePath]
                rule.mCommand += ["-o", objectFile]
                rule.mCommand += includeDirs
                rule.mCommand += ["-MD", "-MP", "-MF", objectFile + ".dep"]
                make.addRule(rule)
    #--------------------------------------------------------------------------- Add EXECUTABLE link rule
        EXECUTABLE_LTO = self.mExecutable + "-lto" + self.mExecutableSuffix
        rule = makefile.Rule([EXECUTABLE_LTO],
                             self.mLinkingMessage + ": " + EXECUTABLE_LTO)
        rule.mOnErrorDeleteTarget = True
        rule.deleteTargetFileOnClean()
        rule.mDependences += ltoObjectFileList
        rule.mDependences.append(self.mJSONfilePath)
        rule.mCommand += self.mLinkerTool
        rule.mCommand += ltoObjectFileList
        rule.mCommand += ["-o", EXECUTABLE_LTO]
        rule.mCommand += self.mLinkerOptions
        rule.mCommand += ["-flto"]
        postCommand = makefile.PostCommand(self.mStripMessage + " " +
                                           EXECUTABLE_LTO)
        postCommand.mCommand += self.mStripTool
        postCommand.mCommand.append(EXECUTABLE_LTO)
        rule.mPostCommands.append(postCommand)
        rule.mPriority = 1
        make.addRule(rule)
        #--------------------------------------------------------------------------- Add install EXECUTABLE file rule
        if len(self.mSudoTool) > 0:
            INSTALL_EXECUTABLE = "/usr/local/bin/" + EXECUTABLE
            rule = makefile.Rule([INSTALL_EXECUTABLE],
                                 self.mInstallationgMessage + ": " +
                                 INSTALL_EXECUTABLE)
            rule.mDependences.append(EXECUTABLE)
            rule.mCommand += self.mSudoTool
            rule.mCommand += ["cp", EXECUTABLE, INSTALL_EXECUTABLE]
            make.addRule(rule)
    #--------------------------------------------------------------------------- Add install EXECUTABLE-lto file rule
        if len(self.mSudoTool) > 0:
            INSTALL_EXECUTABLE_LTO = "/usr/local/bin/" + EXECUTABLE_LTO
            rule = makefile.Rule([INSTALL_EXECUTABLE_LTO],
                                 self.mInstallationgMessage + ": " +
                                 INSTALL_EXECUTABLE_LTO)
            rule.mDependences.append(EXECUTABLE)
            rule.mCommand += self.mSudoTool
            rule.mCommand += ["cp", EXECUTABLE_LTO, INSTALL_EXECUTABLE_LTO]
            make.addRule(rule)
    #--------------------------------------------------------------------------- Add install EXECUTABLE-debug file rule
        if len(self.mSudoTool) > 0:
            INSTALL_EXECUTABLE_DEBUG = "/usr/local/bin/" + EXECUTABLE_DEBUG
            rule = makefile.Rule([INSTALL_EXECUTABLE_DEBUG],
                                 self.mInstallationgMessage + " (debug): " +
                                 INSTALL_EXECUTABLE_DEBUG)
            rule.mDependences.append(INSTALL_EXECUTABLE_DEBUG)
            rule.mCommand += self.mSudoTool
            rule.mCommand += ["cp", EXECUTABLE_DEBUG, INSTALL_EXECUTABLE_DEBUG]
            make.addRule(rule)
    #--------------------------------------------------------------------------- Compute jobs
    # make.printRules ()
        make.addGoal("all", [EXECUTABLE, EXECUTABLE_DEBUG],
                     "Build " + EXECUTABLE + " and " + EXECUTABLE_DEBUG)
        make.addGoal("debug", [EXECUTABLE_DEBUG], "Build " + EXECUTABLE_DEBUG)
        make.addGoal("release", [EXECUTABLE], "Build " + EXECUTABLE)
        make.addGoal("lto", [EXECUTABLE_LTO], "Build " + EXECUTABLE_LTO)
        if len(self.mSudoTool) > 0:
            make.addGoal("install-lto", [INSTALL_EXECUTABLE_LTO],
                         "Build and install " + INSTALL_EXECUTABLE_LTO)
            make.addGoal("install-release", [INSTALL_EXECUTABLE],
                         "Build and install " + INSTALL_EXECUTABLE)
            make.addGoal("install-debug", [INSTALL_EXECUTABLE_DEBUG],
                         "Build and install " + INSTALL_EXECUTABLE_DEBUG)

    #--------------------------------------------------------------------------- Run jobs
    # make.printGoals ()
        make.runGoal(self.mMaxParallelJobs, self.mDisplayCommands)
        #--------------------------------------------------------------------------- Ok ?
        make.printErrorCountAndExitOnError()
        displayDurationFromStartTime(startTime)
コード例 #5
0
cppSourceList.append(projfile.ProjectFile("machines/avr/arduino/cores/arduino/HardwareSerial0.cpp", trampoline_base_path))
cppSourceList.append(projfile.ProjectFile("machines/avr/arduino/cores/arduino/HardwareSerial1.cpp", trampoline_base_path))
cppSourceList.append(projfile.ProjectFile("machines/avr/arduino/cores/arduino/HardwareSerial2.cpp", trampoline_base_path))
cppSourceList.append(projfile.ProjectFile("machines/avr/arduino/cores/arduino/HardwareSerial3.cpp", trampoline_base_path))
cppSourceList.append(projfile.ProjectFile("machines/avr/arduino/cores/arduino/HardwareSerial.cpp", trampoline_base_path))
#----------------------------------------------------------------------
#--- Build the object list and the compiler dependancies
#----------------------------------------------------------------------
objectList = []

for sourceFile in cSourceList:
  source = sourceFile.src()
  object = sourceFile.obj("build")
  depObject = sourceFile.dep("build")
  objectList.append(object)
  rule = makefile.Rule([object], "Compiling " + source)
  rule.deleteTargetDirectoryOnClean()
  rule.mDependences.append(source)
  rule.mCommand.append(compiler)
  rule.mCommand += precflags
  rule.mCommand += ["-c", source]
  rule.mCommand += ["-o", object]
  rule.mCommand += ["-MD", "-MP", "-MF", depObject]
  rule.mCommand += cflags
  rule.enterSecondaryDependanceFile (depObject, make)
  make.addRule(rule)

for sourceFile in cppSourceList:
  source = sourceFile.src()
  object = sourceFile.obj("build")
  depObject = sourceFile.dep("build")
trampoline_base_path = "../../trampoline/"

#----------------------------------------------------------------------
#--- Build the source files list
#----------------------------------------------------------------------
oilSourceList = []
sourceList = []

#--- Add generated files
sourceList.append("conf/tpl_app_config.c")

sourceList.append("conf/tpl_dispatch_table.c")
sourceList.append("conf/tpl_invoque.S")
sourceList.append("conf/tpl_interrupts.c")

rule = makefile.Rule(sourceList, "Compiling OIL file " + oilFile)
rule.deleteTargetFileOnClean()
rule.mDeleteTargetOnError = True
rule.mDependences.append(oilFile)
rule.enterSecondaryDependanceFile(oilFileDep, make)
rule.mCommand.append("goil")
rule.mCommand += oilFlags
rule.mCommand.append(oilFile)

make.addRule(rule)
make.addGoal("all", sourceList, "Building all")

if goal == "all" or goal == "clean":
    make.runGoal(maxParallelJobs, maxParallelJobs == 1)

#----------------------------------------------------------------------
コード例 #7
0
def buildCode(GOAL, projectDir, maxConcurrentJobs, showCommand):
    #--------------------------------------------------------------------------- Prepare
    os.chdir(projectDir)
    make = makefile.Make(GOAL)
    make.mMacTextEditor = "TextWrangler"  # "Atom"
    allGoal = []
    #--------------------------------------------------------------------------- Install Linux UDEV rules ?
    platform = dev_platform.getPlatform()
    if (platform == "linux") or (platform == "linux32"):
        import udev_on_linux
        udev_on_linux.installUDEVrulesOnLinux()
#--------------------------------------------------------------------------- Install compiler ?
    BASE_NAME = "arm-none-eabi"
    TOOL_DIR = download_and_install_gccarm.installGCCARMandGetToolDirectory()
    AS_TOOL_WITH_OPTIONS = [
        TOOL_DIR + "/bin/" + BASE_NAME + "-as", "-mthumb", "-mcpu=cortex-m4"
    ]
    COMPILER_TOOL_WITH_OPTIONS = [
        TOOL_DIR + "/bin/" + BASE_NAME + "-gcc", "-mthumb", "-mcpu=cortex-m4"
    ]
    LD_TOOL_WITH_OPTIONS = [TOOL_DIR + "/bin/" + BASE_NAME + "-ld"]
    LD_TOOL_WITH_OPTIONS = COMPILER_TOOL_WITH_OPTIONS
    OBJCOPY_TOOL_WITH_OPTIONS = [TOOL_DIR + "/bin/" + BASE_NAME + "-objcopy"]
    DISPLAY_OBJ_SIZE_TOOL = [TOOL_DIR + "/bin/" + BASE_NAME + "-size"]
    OBJDUMP_TOOL = TOOL_DIR + "/bin/" + BASE_NAME + "-objdump"
    #--------------------------------------------------------------------------- Install Teensy loader CLI ?
    TEENSY_CLI_LOADER_PATH = teensy_cli_loader_builder.buildAndGetPath(
        TOOL_DIR + "/bin")
    #--------------------------------------------------------------------------- Analyze JSON file
    print(makefile.BOLD_GREEN() + "--- Making " + projectDir + makefile.ENDC())
    dictionaire = dictionaryFromJsonFile(projectDir + "/makefile.json")
    #--- TEENSY
    linkerScript = "common-sources/teensy-3-6.ld"
    teensyName = "TEENSY36"
    #--- ASSERTION_GENERATION
    ASSERTION_GENERATION = False
    if ("ASSERTION-GENERATION"
            in dictionaire) and dictionaire["ASSERTION-GENERATION"]:
        ASSERTION_GENERATION = True
#--- CPU_MHZ
    CPU_MHZ = 0
    if "CPU-MHZ" in dictionaire:
        CPU_MHZ = dictionaire["CPU-MHZ"]
#--- SOURCE_FILE_DIRECTORIES
    SOURCE_FILE_DIRECTORIES = []
    if "SOURCE-DIR" in dictionaire:
        SOURCE_FILE_DIRECTORIES = dictionaire["SOURCE-DIR"]
#--- GROUP_SOURCES
    GROUP_SOURCES = False
    if "GROUP-SOURCES" in dictionaire:
        GROUP_SOURCES = dictionaire["GROUP-SOURCES"]
#--- TASK_COUNT
    TASK_COUNT = "0"  # Means TASK_COUNT is not defined by JSON file
    if "TASK-COUNT" in dictionaire:
        TASK_COUNT = str(dictionaire["TASK-COUNT"])
#--- LTO
    usesLTO = False
    if ("LTO" in dictionaire) and dictionaire["LTO"]:
        usesLTO = True
#--- SERVICE
    serviceScheme = ""
    if "SERVICE-SCHEME" in dictionaire:
        serviceScheme = dictionaire["SERVICE-SCHEME"]
#--- SECTION
    sectionScheme = ""
    if "SECTION-SCHEME" in dictionaire:
        sectionScheme = dictionaire["SECTION-SCHEME"]
#--------------------------------------------------------------------------- Directories
    BUILD_DIR = common_definitions.buildDirectory()
    GENERATED_SOURCE_DIR = common_definitions.generatedSourceDirectory()
    PRODUCT_DIR = common_definitions.productDirectory()
    ASBUILD_DIR = common_definitions.asDirectory()
    #--------------------------------------------------------------------------- Build source lists
    includeDirsInCompilerCommand = [
        "-I", GENERATED_SOURCE_DIR, "-I", projectDir
    ]
    H_SOURCE_LIST = []
    CPP_SOURCE_LIST = []
    S_SOURCE_LIST = []
    for f in SOURCE_FILE_DIRECTORIES:
        for root, dirs, files in os.walk(f):
            includeDirsInCompilerCommand += ["-I", root]
            for name in files:
                sourcePath = os.path.join(root, name)
                (b, extension) = os.path.splitext(sourcePath)
                if extension == ".cpp":
                    CPP_SOURCE_LIST.append(sourcePath)
                elif extension == ".h":
                    H_SOURCE_LIST.append(sourcePath)
                elif extension == ".s":
                    S_SOURCE_LIST.append(sourcePath)
                elif extension == ".ld":
                    pass  # Ignored file
                elif extension != "":  # Ceci permet d'ignorer les fichés cachés (dont les noms commencent par un point)
                    print(makefile.MAGENTA() + makefile.BOLD() +
                          "Note: unhandled file " + sourcePath +
                          makefile.ENDC())
#--------------------------------------------------------------------------- Build base header file
    baseHeader_file = GENERATED_SOURCE_DIR + "/base.h"
    H_SOURCE_LIST.insert(0, baseHeader_file)
    rule = makefile.Rule([baseHeader_file], "Build base header file")
    rule.mOpenSourceOnError = False
    rule.mDependences.append("makefile.json")
    rule.mCommand += [
        "python", "../../dev-files/build_base_header_file.py", baseHeader_file,
        str(CPU_MHZ), TASK_COUNT, teensyName,
        "1" if ASSERTION_GENERATION else "0"
    ]
    rule.mPriority = -1
    make.addRule(rule)
    #--------------------------------------------------------------------------- Build all header file
    allHeadersSecondaryDependenceFile = BUILD_DIR + "/all-headers.dep"
    allHeaders_file = GENERATED_SOURCE_DIR + "/all-headers.h"
    rule = makefile.Rule([allHeaders_file, allHeadersSecondaryDependenceFile],
                         "Build all headers file")
    rule.mOpenSourceOnError = False
    rule.mDependences.append("makefile.json")
    rule.mDependences += H_SOURCE_LIST
    rule.mCommand += [
        "python", "../../dev-files/build_all_header_file.py", allHeaders_file,
        allHeadersSecondaryDependenceFile
    ]
    rule.mCommand += H_SOURCE_LIST
    rule.enterSecondaryDependanceFile(allHeadersSecondaryDependenceFile, make)
    rule.mPriority = -1
    make.addRule(rule)
    #--------------------------------------------------------------------------- Build interrupt handler files
    interruptHandlerSFile = GENERATED_SOURCE_DIR + "/interrupt-handlers.s"
    interruptHandlerCppFile = GENERATED_SOURCE_DIR + "/interrupt-handler-helper.cpp"
    S_SOURCE_LIST.append(interruptHandlerSFile)
    CPP_SOURCE_LIST.append(interruptHandlerCppFile)
    rule = makefile.Rule([interruptHandlerSFile, interruptHandlerCppFile],
                         "Build interrupt files")
    rule.mOpenSourceOnError = False
    rule.mDependences += H_SOURCE_LIST
    rule.mDependences.append("makefile.json")
    rule.mDependences.append("../../dev-files/build_interrupt_handlers.py")
    rule.mCommand += ["python", "../../dev-files/build_interrupt_handlers.py"]
    rule.mCommand += [interruptHandlerCppFile]
    rule.mCommand += [interruptHandlerSFile]
    rule.mCommand += [serviceScheme]
    rule.mCommand += [sectionScheme]
    rule.mCommand += H_SOURCE_LIST
    rule.mPriority = -1
    make.addRule(rule)
    #--------------------------------------------------------------------------- Group sources ?
    if GROUP_SOURCES:
        allSourceFile = GENERATED_SOURCE_DIR + "/all-sources.cpp"
        rule = makefile.Rule([allSourceFile], "Group all sources")
        rule.mOpenSourceOnError = False
        rule.mDependences += CPP_SOURCE_LIST
        rule.mDependences.append("makefile.json")
        rule.mCommand += [
            "python", "../../dev-files/build_grouped_sources.py", allSourceFile
        ]
        rule.mCommand += CPP_SOURCE_LIST
        rule.mPriority = -1
        make.addRule(rule)
        CPP_SOURCE_LIST = [allSourceFile]
#--------------------------------------------------------------------------- Build makefile rules
    objectFileList = []
    asObjectFileList = []
    #--- CPP source files
    for sourcePath in CPP_SOURCE_LIST:
        source = os.path.basename(sourcePath)
        objectFile = BUILD_DIR + "/" + source + ".o"
        objectFileForChecking = BUILD_DIR + "/" + source + ".check.o"
        asObjectFile = BUILD_DIR + "/" + source + ".s"
        #--- Checking source
        rule = makefile.Rule([objectFileForChecking], "Checking " + source)
        rule.mOpenSourceOnError = False
        rule.mDependences.append(allHeaders_file)
        rule.mDependences.append(sourcePath)
        rule.mDependences.append("makefile.json")
        rule.enterSecondaryDependanceFile(objectFileForChecking + ".dep", make)
        rule.mCommand += COMPILER_TOOL_WITH_OPTIONS
        rule.mCommand += common_definitions.checkModeOptions()
        rule.mCommand += common_definitions.C_Cpp_optimizationOptions()
        rule.mCommand += common_definitions.Cpp_actualOptions(False)
        rule.mCommand += ["-c", sourcePath]
        rule.mCommand += ["-o", objectFileForChecking]
        rule.mCommand += ["-DSTATIC="]
        rule.mCommand += includeDirsInCompilerCommand
        rule.mCommand += ["-MD", "-MP", "-MF", objectFileForChecking + ".dep"]
        make.addRule(rule)
        rule.mPriority = -1
        allGoal.append(objectFileForChecking)
        #--- Compile source
        rule = makefile.Rule([objectFile], "Compiling " + source)
        rule.mOpenSourceOnError = False
        rule.mCommand += COMPILER_TOOL_WITH_OPTIONS
        rule.mCommand += common_definitions.C_Cpp_optimizationOptions()
        rule.mCommand += common_definitions.Cpp_actualOptions(usesLTO)
        rule.mCommand += ["-g"]
        rule.mCommand += ["-c", sourcePath]
        rule.mCommand += ["-o", objectFile]
        rule.mCommand += ["-DSTATIC=static __attribute__((unused))"
                          ] if GROUP_SOURCES else ["-DSTATIC="]
        rule.mCommand += includeDirsInCompilerCommand
        rule.mCommand += ["-MD", "-MP", "-MF", objectFile + ".dep"]
        rule.mDependences.append(allHeaders_file)
        rule.mDependences.append(sourcePath)
        rule.mDependences.append("makefile.json")
        rule.enterSecondaryDependanceFile(objectFile + ".dep", make)
        make.addRule(rule)
        objectFileList.append(objectFile)
        #--- objdump python source
        objdumpPythonFile = BUILD_DIR + "/" + source + ".objdump.py"
        rule = makefile.Rule([objdumpPythonFile],
                             "Building " + source + ".objdump.py")
        rule.mDependences.append(objectFile)
        rule.mDependences.append("makefile.json")
        rule.mCommand += [
            "python", "../../dev-files/build_objdump.py", OBJDUMP_TOOL, source,
            objdumpPythonFile
        ]
        rule.mPriority = -1
        make.addRule(rule)
        allGoal.append(objdumpPythonFile)
        #--- AS rule
        rule = makefile.Rule([asObjectFile], "Compiling -> s " + source)
        rule.mOpenSourceOnError = False
        rule.mCommand += COMPILER_TOOL_WITH_OPTIONS
        rule.mCommand += common_definitions.C_Cpp_optimizationOptions()
        rule.mCommand += common_definitions.Cpp_actualOptions(usesLTO)
        rule.mCommand += ["-S", sourcePath]
        rule.mCommand += ["-o", asObjectFile]
        rule.mCommand += ["-DSTATIC="]
        rule.mCommand += includeDirsInCompilerCommand
        rule.mCommand += ["-MD", "-MP", "-MF", asObjectFile + ".dep"]
        rule.mDependences.append(sourcePath)
        rule.mDependences.append(allHeaders_file)
        rule.mDependences.append("makefile.json")
        rule.enterSecondaryDependanceFile(asObjectFile + ".dep", make)
        make.addRule(rule)
        #--- AS rule, getting output assembler file
        listingFile = ASBUILD_DIR + "/" + source + ".s.list"
        rule = makefile.Rule([listingFile], "Assembling -> listing " + source)
        rule.mOpenSourceOnError = False
        rule.mCommand += AS_TOOL_WITH_OPTIONS
        rule.mCommand += [asObjectFile]
        rule.mCommand += ["-o", "/dev/null"]
        rule.mCommand += ["-aln=" + listingFile]
        rule.mDependences.append(asObjectFile)
        rule.mDependences.append(allHeaders_file)
        rule.mDependences.append("makefile.json")
        make.addRule(rule)
        asObjectFileList.append(listingFile)
#-- Add ARM S files
    for sourcePath in S_SOURCE_LIST:
        source = os.path.basename(sourcePath)
        objectFile = BUILD_DIR + "/" + source + ".o"
        objectFileForChecking = BUILD_DIR + "/" + source + ".check.o"
        asObjectFile = ASBUILD_DIR + "/" + source + ".s"
        if sourcePath != "":
            rule = makefile.Rule([objectFile], "Assembling " + source)
            rule.mOpenSourceOnError = False
            rule.mCommand += AS_TOOL_WITH_OPTIONS
            rule.mCommand += [sourcePath]
            rule.mCommand += ["-o", objectFile]
            rule.mCommand += includeDirsInCompilerCommand
            rule.mCommand += ["--MD", objectFile + ".dep"]
            rule.mDependences.append(sourcePath)
            rule.mDependences.append("makefile.json")
            rule.enterSecondaryDependanceFile(objectFile + ".dep", make)
            make.addRule(rule)
            objectFileList.append(objectFile)
            #--- Add listing file
            listingFile = ASBUILD_DIR + "/" + source + ".list"
            rule = makefile.Rule([listingFile],
                                 "Assembling -> listing " + source)
            rule.mOpenSourceOnError = False
            rule.mCommand += AS_TOOL_WITH_OPTIONS
            rule.mCommand += [sourcePath]
            rule.mCommand += ["-o", "/dev/null"]
            rule.mCommand += ["-aln=" + listingFile]
            rule.mDependences.append(sourcePath)
            rule.mDependences.append("makefile.json")
            make.addRule(rule)
            asObjectFileList.append(listingFile)
#--------------------------------------------------------------------------- Link for internal flash
    PRODUCT_INTERNAL_FLASH = PRODUCT_DIR + "/product"
    LINKER_SCRIPT_INTERNAL_FLASH = "../../dev-files/" + linkerScript
    allGoal.append(PRODUCT_INTERNAL_FLASH + ".elf")
    #--- Add link rule
    rule = makefile.Rule([PRODUCT_INTERNAL_FLASH + ".elf"],
                         "Linking " + PRODUCT_INTERNAL_FLASH + ".elf")
    rule.mDependences += objectFileList
    rule.mDependences.append(LINKER_SCRIPT_INTERNAL_FLASH)
    rule.mDependences.append("makefile.json")
    rule.mCommand += LD_TOOL_WITH_OPTIONS
    rule.mCommand += objectFileList
    rule.mCommand += ["-T" + LINKER_SCRIPT_INTERNAL_FLASH]
    rule.mCommand.append("-Wl,-Map=" + PRODUCT_INTERNAL_FLASH + ".map")
    rule.mCommand += common_definitions.commonLinkerFlags(usesLTO)
    rule.mCommand += ["-o", PRODUCT_INTERNAL_FLASH + ".elf"]
    make.addRule(rule)
    #--- Add hex rule
    allGoal.append(PRODUCT_INTERNAL_FLASH + ".hex")
    rule = makefile.Rule([PRODUCT_INTERNAL_FLASH + ".hex"],
                         "Hexing " + PRODUCT_INTERNAL_FLASH + ".hex")
    rule.mDependences.append(PRODUCT_INTERNAL_FLASH + ".elf")
    rule.mDependences.append("makefile.json")
    rule.mCommand += OBJCOPY_TOOL_WITH_OPTIONS
    rule.mCommand.append("-O")
    rule.mCommand.append("ihex")
    rule.mCommand.append(PRODUCT_INTERNAL_FLASH + ".elf")
    rule.mCommand.append(PRODUCT_INTERNAL_FLASH + ".hex")
    make.addRule(rule)
    #--------------------------------------------------------------------------- Goals
    make.addGoal("all", allGoal, "Build all")
    make.addGoal("run", allGoal, "Building all and run")
    make.addGoal("view-hex", allGoal, "Building all and show hex")
    make.addGoal("display-obj-size", allGoal,
                 "Build binaries and display object sizes")
    make.addGoal("as", asObjectFileList, "Compile C and C++ to assembly")
    #--------------------------------------------------------------------------- Run jobs
    #make.printRules ()
    #make.checkRules ()
    #   make.writeRuleDependancesInDotFile ("dependances.dot")
    make.runGoal(maxConcurrentJobs, showCommand)
    #--------------------------------------------------------------------------- Ok ?
    make.printErrorCountAndExitOnError()
    #---------------------------------------------------------------------------- "display-obj-size"
    if GOAL == "display-obj-size":
        makefile.runCommand(DISPLAY_OBJ_SIZE_TOOL + objectFileList + ["-t"],
                            "Display Object Size", False, showCommand)
#---------------------------------------------------------------------------- "All" or "run"
    if (GOAL == "all") or (GOAL == "run") or (GOAL == "view-hex"):
        s = runProcessAndGetOutput(DISPLAY_OBJ_SIZE_TOOL + ["-t"] +
                                   [PRODUCT_INTERNAL_FLASH + ".elf"])
        secondLine = s.split('\n')[1]
        numbers = [int(s) for s in secondLine.split() if s.isdigit()]
        print("  ROM code:    " + str(numbers[0]) + " bytes")
        print("  ROM data:    " + str(numbers[1]) + " bytes")
        print("  RAM + STACK: " + str(numbers[2]) + " bytes")
#----------------------------------------------- Run ?
    if GOAL == "run":
        FLASH_TEENSY = [TEENSY_CLI_LOADER_PATH, "-w", "-v", "-mmcu=TEENSY36"]
        print(makefile.BOLD_BLUE() + "Loading Teensy..." + makefile.ENDC())
        runProcess(FLASH_TEENSY + [PRODUCT_INTERNAL_FLASH + ".hex"])
        print(makefile.BOLD_GREEN() + "Success" + makefile.ENDC())
    elif GOAL == "view-hex":
        print(makefile.BOLD_GREEN() + "View hex..." + makefile.ENDC())
        scriptDir = os.path.dirname(os.path.abspath(__file__))
        runProcess([
            "python", scriptDir + "/view-hex.py",
            PRODUCT_INTERNAL_FLASH + ".hex"
        ])
コード例 #8
0
def addCppSourceFileToMakeFile (sourcePath,
                                make,
                                BUILD_DIR,
                                allHeadersSecondaryDependenceFile,
                                COMPILER_TOOL_WITH_OPTIONS,
                                includeDirsInCompilerCommand,
                                usesLTO,
                                GROUP_SOURCES,
                                allHeaders_file,
                                ASBUILD_DIR,
                                AS_TOOL_WITH_OPTIONS) :
  source = os.path.basename (sourcePath)
  objectFile = BUILD_DIR + "/" + source + ".o"
  objectFileForChecking = BUILD_DIR + "/" + source + ".check.o"
  asObjectFile = BUILD_DIR + "/" + source + ".s"
#--- Checking source
  rule1 = makefile.Rule ([objectFileForChecking], "Checking " + source)
  rule1.mOpenSourceOnError = False
  rule1.mDependences.append (allHeadersSecondaryDependenceFile)
#   rule1.mDependences.append (precompiledHeader_file)
  rule1.mDependences.append (sourcePath)
  rule1.mDependences.append ("makefile.json")
  rule1.enterSecondaryDependanceFile (objectFileForChecking + ".dep", make)
  rule1.mCommand += COMPILER_TOOL_WITH_OPTIONS
  rule1.mCommand += ["-x", "c++"]
  rule1.mCommand += common_definitions.checkModeOptions ()
  rule1.mCommand += common_definitions.C_Cpp_optimizationOptions ()
  rule1.mCommand += common_definitions.Cpp_actualOptions (False)
  rule1.mCommand += ["-c", sourcePath]
  rule1.mCommand += ["-o", objectFileForChecking]
  rule1.mCommand += ["-DSTATIC="]
  rule1.mCommand += includeDirsInCompilerCommand
  rule1.mCommand += ["-MD", "-MP", "-MF", objectFileForChecking + ".dep"]
  make.addRule (rule1)
  rule1.mPriority = -1
#   allGoal.append (objectFileForChecking)
#--- Compile source
  rule2 = makefile.Rule ([objectFile], "Compiling " + source)
  rule2.mOpenSourceOnError = False
  rule2.mCommand += COMPILER_TOOL_WITH_OPTIONS
  rule2.mCommand += common_definitions.C_Cpp_optimizationOptions ()
  rule2.mCommand += common_definitions.Cpp_actualOptions (usesLTO)
  rule2.mCommand += ["-g"]
  rule2.mCommand += ["-c", sourcePath]
  rule2.mCommand += ["-o", objectFile]
  rule2.mCommand += ["-DSTATIC=static __attribute__((unused))"] if GROUP_SOURCES else ["-DSTATIC="]
  rule2.mCommand += includeDirsInCompilerCommand
  rule2.mCommand += ["-MD", "-MP", "-MF", objectFile + ".dep"]
  rule2.mDependences.append (allHeadersSecondaryDependenceFile)
##  rule2.mDependences.append (precompiledHeader_file)
  rule2.mDependences.append (sourcePath)
  rule2.mDependences.append ("makefile.json")
  rule2.enterSecondaryDependanceFile (objectFile + ".dep", make)
  make.addRule (rule2)
#   objectFileList.append (objectFile)
#--- AS rule
  rule3 = makefile.Rule ([asObjectFile], "Compiling -> s " + source)
  rule3.mOpenSourceOnError = False
  rule3.mCommand += COMPILER_TOOL_WITH_OPTIONS
  rule3.mCommand += common_definitions.C_Cpp_optimizationOptions ()
  rule3.mCommand += common_definitions.Cpp_actualOptions (usesLTO)
  rule3.mCommand += ["-S", sourcePath]
  rule3.mCommand += ["-o", asObjectFile]
  rule3.mCommand += ["-DSTATIC="]
  rule3.mCommand += includeDirsInCompilerCommand
  rule3.mCommand += ["-MD", "-MP", "-MF", asObjectFile + ".dep"]
  rule3.mDependences.append (sourcePath)
  rule3.mDependences.append (allHeaders_file)
  rule3.mDependences.append ("makefile.json")
  rule3.enterSecondaryDependanceFile (asObjectFile + ".dep", make)
  make.addRule (rule3)
#--- AS rule, getting output assembler file
  listingFile = ASBUILD_DIR + "/" + source + ".s.list"
  rule4 = makefile.Rule ([listingFile], "Assembling -> listing " + source)
  rule4.mOpenSourceOnError = False
  rule4.mCommand += AS_TOOL_WITH_OPTIONS
  rule4.mCommand += [asObjectFile]
  rule4.mCommand += ["-o", "/dev/null"]
  rule4.mCommand += ["-aln=" + listingFile]
  rule4.mDependences.append (asObjectFile)
  rule4.mDependences.append (allHeaders_file)
  rule4.mDependences.append ("makefile.json")
  make.addRule (rule4)
#   asObjectFileList.append (listingFile)
#--- Return ([goal], [objectFile], [listingFile])
  return ([objectFileForChecking], [objectFile], [listingFile])
コード例 #9
0
def buildCode (GOAL, projectDir, maxConcurrentJobs, verbose):
  DEV_FILES_DIR = os.path.dirname (os.path.realpath (__file__))
#   print ("DEV_FILES_DIR: " + DEV_FILES_DIR)
#--------------------------------------------------------------------------- Prepare
  os.chdir (projectDir)
  make = makefile.Make (GOAL)
#   make.mMacTextEditor = "BBEdit" # "Atom"
  allGoal = []
#--------------------------------------------------------------------------- Analyze JSON file
  print (makefile.BOLD_GREEN () + "--- Making " + projectDir + makefile.ENDC ())
  dictionaire = dictionaryFromJsonFile (projectDir + "/makefile.json")
#   print ("JSON DICTIONARY: ")
#   print (dictionaire)
#--------------------------------------------------------------------------- Find target
  targetNameSet = set ()
  foundIRQSectionScheme = False
  for name in os.listdir (DEV_FILES_DIR + "/targets") :
    if not name.startswith ('.') :
      targetNameSet.add (name)
  if not "TARGET" in dictionaire:
    s = "\"TARGET\" is not defined in the makefile.json file; possible values:\n"
    for target in targetNameSet :
      s += "  -  \"" + target + "\"\n"
    print (makefile.BOLD_RED () + s + makefile.ENDC ())
    sys.exit (1)
  targetName = dictionaire ["TARGET"]
  if not targetName in targetNameSet :
    s = "In the makefile.json file, \"TARGET\" value \"" + targetName + "\" is invalid; "
    s += "possible values:\n"
    for target in targetNameSet :
      s += "  -  \"" + target + "\"\n"
    print (makefile.BOLD_RED () + s + makefile.ENDC ())
    sys.exit (1)
  TARGET_DIR = DEV_FILES_DIR + "/targets/" + targetName
  sys.path.append (TARGET_DIR + "/deployment")
  import deployment
#--------------------------------------------------------------------------- Install compiler ?
  BASE_NAME = "arm-none-eabi"
  TOOL_DIR = download_and_install_gccarm.installGCCARMandGetToolDirectory ()
#--------------------------------------------------------------------------- Target Dictionary
  targetDictionary = dictionaryFromJsonFile (TARGET_DIR + "/helpers/target-parameters.json")
#--------------------------------------------------------------------------- Configure compiler
  gccOptions = targetDictionary ["GCC-OPTIONS"]
  AS_TOOL_WITH_OPTIONS = [TOOL_DIR + "/bin/" + BASE_NAME + "-as"]
  AS_TOOL_WITH_OPTIONS += gccOptions
  COMPILER_TOOL_WITH_OPTIONS = [TOOL_DIR + "/bin/" + BASE_NAME + "-gcc"]
  COMPILER_TOOL_WITH_OPTIONS += gccOptions
#   LD_TOOL_WITH_OPTIONS = [TOOL_DIR + "/bin/" + BASE_NAME + "-ld"]
  LD_TOOL_WITH_OPTIONS = COMPILER_TOOL_WITH_OPTIONS
  # OBJCOPY_TOOL_WITH_OPTIONS = [TOOL_DIR + "/bin/" + BASE_NAME + "-objcopy"]
  DISPLAY_OBJ_SIZE_TOOL = [TOOL_DIR + "/bin/" + BASE_NAME + "-size"]
#   OBJDUMP_TOOL = TOOL_DIR + "/bin/" + BASE_NAME + "-objdump"
#--------------------------------------------------------------------------- Parse JSON dictinary
#--- SCHEME
  if "SCHEME" in dictionaire:
    SCHEME = dictionaire ["SCHEME"]
    schemeFilePath = TARGET_DIR + "/schemes/" + SCHEME + ".json"
    if os.path.exists (schemeFilePath) :
      schemeDictionary = dictionaryFromJsonFile (schemeFilePath)
      dictionaire ["UNUSED-IRQ-SCHEME"] = schemeDictionary ["UNUSED-IRQ-SCHEME"]
      dictionaire ["IRQ-SECTION-SCHEME"] = schemeDictionary ["IRQ-SECTION-SCHEME"]
      dictionaire ["SERVICE-SCHEME"] = schemeDictionary ["SERVICE-SCHEME"]
      dictionaire ["SECTION-SCHEME"] = schemeDictionary ["SECTION-SCHEME"]
      dictionaire ["SOURCES-IN-DEV-DIR"] = schemeDictionary ["SOURCES-IN-DEV-DIR"]
    else:
      print (makefile.RED () + makefile.BOLD () + "Unknow scheme '" + SCHEME + "'" + makefile.ENDC ())
      sys.exit (1)
#--- CPU_MHZ
  CPU_MHZ = 0
  if "CPU-MHZ" in dictionaire:
    CPU_MHZ = dictionaire ["CPU-MHZ"]
#--- ASSERTION_GENERATION
  ASSERTION_GENERATION = False
  if "ASSERTION-GENERATION" in dictionaire :
    ASSERTION_GENERATION = dictionaire ["ASSERTION-GENERATION"]
#--- USER SOURCE_FILE_DIRECTORIES
  SOURCE_FILE_DIRECTORIES = []
  if "SOURCE-DIR" in dictionaire :
    SOURCE_FILE_DIRECTORIES = dictionaire ["SOURCE-DIR"]
#--- SYSTEM SOURCE_FILE_DIRECTORIES
  if "SOURCES-IN-DEV-DIR" in dictionaire :
    sourcesInDevDir = dictionaire ["SOURCES-IN-DEV-DIR"]
    for d in sourcesInDevDir :
      SOURCE_FILE_DIRECTORIES.append (TARGET_DIR + "/sources/" + d)
#--- GROUP_SOURCES
  GROUP_SOURCES = False
  if "GROUP-SOURCES" in dictionaire:
    GROUP_SOURCES = dictionaire ["GROUP-SOURCES"]
#--- TASK_COUNT
  TASK_COUNT = "0" # Means TASK_COUNT is not defined by JSON file
  if "TASK-COUNT" in dictionaire :
    TASK_COUNT = str (dictionaire ["TASK-COUNT"])
#--- LTO
  usesLTO = False
  if "LTO" in dictionaire :
    usesLTO = dictionaire ["LTO"]
#--- SERVICE
  serviceScheme = ""
  if "SERVICE-SCHEME" in dictionaire :
    serviceScheme = dictionaire ["SERVICE-SCHEME"]
#--- SECTION
  sectionScheme = ""
  if "SECTION-SCHEME" in dictionaire :
    sectionScheme = dictionaire ["SECTION-SCHEME"]
#--- IRQ SECTION
  irqSectionScheme = ""
  if "IRQ-SECTION-SCHEME" in dictionaire :
    irqSectionScheme = dictionaire ["IRQ-SECTION-SCHEME"]
#--- UNUSED IRQ
  unusedIRQScheme = ""
  if "UNUSED-IRQ-SCHEME" in dictionaire :
    unusedIRQScheme = dictionaire ["UNUSED-IRQ-SCHEME"]
#--- DEPLOYMENT
  selectedDeployments = []
  if "DEPLOYMENT" in dictionaire :
    selectedDeployments = dictionaire ["DEPLOYMENT"]
#--------------------------------------------------------------------------- Directories
  BUILD_DIR = common_definitions.buildDirectory ()
  GENERATED_SOURCE_DIR = common_definitions.generatedSourceDirectory ()
  PRODUCT_DIR = common_definitions.productDirectory ()
  ASBUILD_DIR = common_definitions.asDirectory ()
#--------------------------------------------------------------------------- Build source lists
  includeDirsInCompilerCommand = ["-I", GENERATED_SOURCE_DIR]
  H_SOURCE_SET = set ()
  H_SOURCE_LIST = []
  CPP_SOURCE_LIST = []
  S_SOURCE_LIST = []
  for f in SOURCE_FILE_DIRECTORIES :
    for root, dirs, files in os.walk (f) :
      includeDirsInCompilerCommand += ["-I", root]
      for name in files:
        sourcePath = os.path.join (root, name)
        (b, extension) = os.path.splitext (sourcePath)
        if extension == ".cpp" :
          CPP_SOURCE_LIST.append (sourcePath)
        elif extension == ".h" :
          H_SOURCE_LIST.append (sourcePath)
          if sourcePath in H_SOURCE_SET :
            print (makefile.BOLD_RED () + "Duplicated header file \"" + sourcePath + "\"" + makefile.ENDC ())
          H_SOURCE_SET.add (sourcePath)
        elif extension == ".s" :
          S_SOURCE_LIST.append (sourcePath)
        elif extension == ".hs" :
          pass # Ok
        elif extension == ".ld" :
          pass # Ok
        elif extension != "" : # Ceci permet d'ignorer les fichés cachés (dont les noms commencent par un point)
          print (makefile.MAGENTA () + makefile.BOLD () + "Note: unhandled file " + sourcePath + makefile.ENDC ())
#--------------------------------------------------------------------------- Build base header file
  baseHeader_file = GENERATED_SOURCE_DIR + "/base.h"
  H_SOURCE_LIST.insert (0, baseHeader_file)
  rule = makefile.Rule ([baseHeader_file], "Build base header file")
  rule.mOpenSourceOnError = False
  rule.mDependences.append ("makefile.json")
  rule.mCommand += [DEV_FILES_DIR + "/build_base_header_file.py", baseHeader_file, str (CPU_MHZ), TASK_COUNT, targetName, "1" if ASSERTION_GENERATION else "0"]
  rule.mPriority = -1
  make.addRule (rule)
#--------------------------------------------------------------------------- Build all header file
  allHeadersSecondaryDependenceFile = BUILD_DIR + "/all-headers.dep"
  allHeaders_file = GENERATED_SOURCE_DIR + "/all-headers.h"
  rule = makefile.Rule ([allHeaders_file, allHeadersSecondaryDependenceFile], "Build all headers file")
  rule.mOpenSourceOnError = False
  rule.mDependences.append ("makefile.json")
  rule.mDependences += H_SOURCE_LIST
  rule.mCommand += [DEV_FILES_DIR + "/build_all_header_file.py", allHeaders_file, allHeadersSecondaryDependenceFile]
  rule.mCommand += H_SOURCE_LIST
  rule.enterSecondaryDependanceFile (allHeadersSecondaryDependenceFile, make)
  rule.mPriority = -1
  make.addRule (rule)
#--------------------------------------------------------------------------- Build precompiled header file
#   allHeadersSecondaryDependenceFile = GENERATED_SOURCE_DIR + "/all-headers.h"
#   precompiledHeader_file = GENERATED_SOURCE_DIR + "/all-headers.h.gch"
#   rule = makefile.Rule ([precompiledHeader_file], "Build Precompiled header file")
#   rule.mOpenSourceOnError = False
#   rule.mDependences.append ("makefile.json")
#   rule.mDependences.append (allHeadersSecondaryDependenceFile)
#   rule.mCommand += COMPILER_TOOL_WITH_OPTIONS
#   rule.mCommand += ["-DSTATIC=static __attribute__((unused))"] if GROUP_SOURCES else ["-DSTATIC="]
#   rule.mCommand += common_definitions.checkModeOptions ()
#   rule.mCommand += common_definitions.C_Cpp_optimizationOptions ()
#   rule.mCommand += common_definitions.Cpp_actualOptions (False)
#   rule.mCommand += includeDirsInCompilerCommand
#   rule.mCommand += ["-x", "c++-header", allHeadersSecondaryDependenceFile]
#   rule.mCommand += ["-o", precompiledHeader_file]
#   rule.mPriority = -1
#   make.addRule (rule)
#   allGoal.append (precompiledHeader_file)
#--------------------------------------------------------------   --- Build interrupt handler files
  interruptHandlerSFile = GENERATED_SOURCE_DIR + "/interrupt-handlers-assembly.s"
  interruptHandlerCppFile = GENERATED_SOURCE_DIR + "/interrupt-handlers-cpp.cpp"
  S_SOURCE_LIST.append (interruptHandlerSFile)
  CPP_SOURCE_LIST.append (interruptHandlerCppFile)
  rule = makefile.Rule ([interruptHandlerSFile, interruptHandlerCppFile], "Build interrupt files")
  rule.mOpenSourceOnError = False
  rule.mDependences += H_SOURCE_LIST
  rule.mDependences.append ("makefile.json")
  rule.mDependences.append (DEV_FILES_DIR + "/build_interrupt_handlers.py")
  if serviceScheme != "" :
    rule.mDependences.append (TARGET_DIR + "/generators-service/" + serviceScheme + "/service_generator.py")
  if sectionScheme != "" :
    rule.mDependences.append (TARGET_DIR + "/generators-section/" + sectionScheme + "/section_generator.py")
  if irqSectionScheme != "" :
    rule.mDependences.append (TARGET_DIR + "/generators-irq-section/" + irqSectionScheme + "/irq_section_generator.py")
  if unusedIRQScheme != "" :
    rule.mDependences.append (TARGET_DIR + "/generators-unused-irq/" + unusedIRQScheme + "/unused_irq_generator.py")
  rule.mCommand += [DEV_FILES_DIR + "/build_interrupt_handlers.py"]
  rule.mCommand += [TARGET_DIR]
  rule.mCommand += [interruptHandlerCppFile]
  rule.mCommand += [interruptHandlerSFile]
  rule.mCommand += [serviceScheme]
  rule.mCommand += [sectionScheme]
  rule.mCommand += [irqSectionScheme]
  rule.mCommand += [unusedIRQScheme]
  rule.mCommand += H_SOURCE_LIST
  rule.mPriority = -1
  make.addRule (rule)
#--------------------------------------------------------------------------- Group sources ?
  if GROUP_SOURCES :
    allSourceFile = GENERATED_SOURCE_DIR + "/all-sources.cpp"
    rule = makefile.Rule ([allSourceFile], "Group all sources")
    rule.mOpenSourceOnError = False
    rule.mDependences += CPP_SOURCE_LIST
    rule.mDependences.append ("makefile.json")
    rule.mCommand += [DEV_FILES_DIR + "/build_grouped_sources.py", allSourceFile]
    rule.mCommand += CPP_SOURCE_LIST
    rule.mPriority = -1
    make.addRule (rule)
    CPP_SOURCE_LIST = [allSourceFile]
#--------------------------------------------------------------------------- Build makefile rules
  objectFileList = []
  asObjectFileList = []
#--- CPP source files
  for sourcePath in CPP_SOURCE_LIST :
    (goals, objectFiles, listingFiles) = addCppSourceFileToMakeFile (
      sourcePath,
      make,
      BUILD_DIR,
      allHeadersSecondaryDependenceFile,
      COMPILER_TOOL_WITH_OPTIONS,
      includeDirsInCompilerCommand,
      usesLTO,
      GROUP_SOURCES,
      allHeaders_file,
      ASBUILD_DIR,
      AS_TOOL_WITH_OPTIONS
    )
    allGoal += goals
    objectFileList += objectFiles
    asObjectFileList += listingFiles
#-- Add ARM S files
  for sourcePath in S_SOURCE_LIST :
    (objectFiles, listingFiles) = addAsSourceFileToMakeFile (
      sourcePath,
      make,
      BUILD_DIR,
      ASBUILD_DIR,
      AS_TOOL_WITH_OPTIONS,
      includeDirsInCompilerCommand
    )
    objectFileList += objectFiles
    asObjectFileList += listingFiles
#--------------------------------------------------------------------------- Enumerate deployments
  deploymentDictionary = deployment.deploymentDictionary ()
#--------------------------------------------------------------------- - Check selected deployments
  objectFileListDictionary = dict ()
  for selectedDeployment in selectedDeployments :
    objectFileListDictionary [selectedDeployment] = list (objectFileList)
    if not selectedDeployment in deploymentDictionary.keys () :
      s = "Invalid deployment \"" + selectedDeployment + "\"; possible values:\n"
      for dep in deploymentDictionary.keys () :
        s += "  - \"" + dep + "\"\n"
      print (makefile.BOLD_RED () + s + makefile.ENDC ())
      sys.exit (1)
#--------------------------------------------------------------- Additional source for deployement
  for selectedDeployment in selectedDeployments :
    additionalSourceDirectory = deployment.additionalSourceDirectoryForDeployment (selectedDeployment)
    if additionalSourceDirectory != "" :
      fullDirPath = TARGET_DIR + "/deployment/" + additionalSourceDirectory
      for name in sorted (os.listdir (fullDirPath)) :
        sourcePath = os.path.join (fullDirPath, name)
        (b, extension) = os.path.splitext (sourcePath)
        if extension == ".cpp" :
          (goals, objectFiles, listingFiles) = addCppSourceFileToMakeFile (
            sourcePath,
            make,
            BUILD_DIR,
            allHeadersSecondaryDependenceFile,
            COMPILER_TOOL_WITH_OPTIONS,
            includeDirsInCompilerCommand,
            usesLTO,
            GROUP_SOURCES,
            allHeaders_file,
            ASBUILD_DIR,
            AS_TOOL_WITH_OPTIONS
          )
          allGoal += goals
          objectFileListDictionary [selectedDeployment] += objectFiles
          asObjectFileList += listingFiles
        elif extension == ".s" :
          (objectFiles, listingFiles) = addAsSourceFileToMakeFile (
            sourcePath,
            make,
            BUILD_DIR,
            ASBUILD_DIR,
            AS_TOOL_WITH_OPTIONS,
            includeDirsInCompilerCommand
          )
          objectFileListDictionary [selectedDeployment] += objectFiles
          asObjectFileList += listingFiles
        elif extension != "" : # Ceci permet d'ignorer les fichés cachés (dont les noms commencent par un point)
          print (makefile.MAGENTA () + makefile.BOLD () + "Note: unhandled file " + sourcePath + makefile.ENDC ())

#--------------------------------------------------------------------------- Build deployment files
  runGoalDictionary = dict ()
  for selectedDeployment in selectedDeployments :
    runGoalDictionary ["run-" + selectedDeployment] = selectedDeployment
    linkerScript = deploymentDictionary [selectedDeployment]
    LINKER_SCRIPT = TARGET_DIR + "/deployment/" + linkerScript
    PRODUCT = PRODUCT_DIR + "/deployment-" + selectedDeployment
    allGoal.append (PRODUCT + ".elf")
  #--- Add link rule
    rule = makefile.Rule ([PRODUCT + ".elf"], "Linking " + PRODUCT + ".elf")
    rule.mDependences += objectFileListDictionary [selectedDeployment]
    rule.mDependences.append (LINKER_SCRIPT)
    rule.mDependences.append ("makefile.json")
    rule.mCommand += LD_TOOL_WITH_OPTIONS
    rule.mCommand += objectFileListDictionary [selectedDeployment]
    rule.mCommand += ["-T" + LINKER_SCRIPT]
    rule.mCommand.append ("-Wl,-Map=" + PRODUCT + ".map")
    rule.mCommand += common_definitions.commonLinkerFlags (usesLTO)
    rule.mCommand += ["-o", PRODUCT + ".elf"]
    make.addRule (rule)
    make.addGoal ("run-" + selectedDeployment, allGoal, "Building " + selectedDeployment + " deployment and run")
  #--- Add deployment rules
    (goal, rule) = deployment.buildDeployment (PRODUCT, selectedDeployment, verbose)
    allGoal.append (goal)
    make.addRule (rule)
#     sys.path.pop ()
  #--- Write deployment script
    pythonScriptFilePath = projectDir + "/2-run-" + selectedDeployment + "-via-usb.py"
    if not os.path.exists (pythonScriptFilePath) :
      f = open (DEV_FILES_DIR + "/deployment-script.py.txt", "r")
      genericScript = f.read ()
      f.close ()
      pythonScriptContents = genericScript.replace ("DEPLOYMENT", "run-" + selectedDeployment)
      f = open (pythonScriptFilePath, "wt")
      f.write (pythonScriptContents)
      f.close ()
      #---
      mode = os.stat (pythonScriptFilePath).st_mode
      # print (mode)
      mode += 0o0100 # Add execute permission
      # print (mode)
      os.chmod (pythonScriptFilePath, mode)
#--------------------------------------------------------------------------- Goals
  make.addGoal ("all", allGoal, "Build all")
  make.addGoal ("view-hex", allGoal, "Building all and show hex")
  make.addGoal ("display-obj-size", allGoal, "Build binaries and display object sizes")
  make.addGoal ("as", asObjectFileList, "Compile C and C++ to assembly")
#--------------------------------------------------------------------------- Run jobs
  #make.printRules ()
  #make.checkRules ()
#   make.writeRuleDependancesInDotFile ("dependances.dot")
  make.runGoal (maxConcurrentJobs, verbose)
#--------------------------------------------------------------------------- Ok ?
  make.printErrorCountAndExitOnError ()
#---------------------------------------------------------------------------- "display-obj-size"
  if GOAL == "display-obj-size" :
    makefile.runCommand (DISPLAY_OBJ_SIZE_TOOL + objectFileList + ["-t"], "Display Object Size", False, verbose)
#---------------------------------------------------------------------------- "All" or "run"
  if GOAL == "all" :
    for selectedDeployment in selectedDeployments :
      PRODUCT = PRODUCT_DIR + "/deployment-" + selectedDeployment
      s = runProcessAndGetOutput (DISPLAY_OBJ_SIZE_TOOL + ["-t"] + [PRODUCT + ".elf"])
      secondLine = s.split('\n')[1]
      numbers = [int(s) for s in secondLine.split() if s.isdigit()]
      print ("Deployment \"" + selectedDeployment + "\":")
      print ("  Code:             " + str (numbers [0]) + " bytes")
      print ("  Initialized data: " + str (numbers [1]) + " bytes")
      print ("  RAM + STACK:      " + str (numbers [2]) + " bytes")
#---------------------------------------------------------------------------- Run ?
  if GOAL in runGoalDictionary.keys () :
    selectedDeployment = runGoalDictionary [GOAL]
    PRODUCT = PRODUCT_DIR + "/deployment-" + selectedDeployment
    DEPLOYMENT_DIR = TARGET_DIR + "/deployment"
    deployment.performDeployment (DEPLOYMENT_DIR, PRODUCT, selectedDeployment)
コード例 #10
0
ファイル: makefile_am.py プロジェクト: ssi-schaefer/confix
    def __init__(self):
        # free lines to be output.

        self.__lines = []

        # AUTOMAKE_OPTIONS.

        self.__automake_options = makefile.Set(name='AUTOMAKE_OPTIONS',
                                               values=[],
                                               mitigate=False)

        # SUBDIRS.

        self.__subdirs = makefile.List(name='SUBDIRS',
                                       values=[],
                                       mitigate=True)

        # "Makefile elements": Rule and List objects.

        self.__elements = []

        # sets of filenames that will come to rest in EXTRA_DIST,
        # MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, and
        # MAINTAINERCLEANFILES, respectively.

        self.__extra_dist = makefile.Set(name='EXTRA_DIST',
                                         values=[],
                                         mitigate=True)
        self.__mostlycleanfiles = makefile.Set(name='MOSTLYCLEANFILES',
                                               values=[],
                                               mitigate=True)
        self.__cleanfiles = makefile.Set(name='CLEANFILES',
                                         values=[],
                                         mitigate=True)
        self.__distcleanfiles = makefile.Set(name='DISTCLEANFILES',
                                             values=[],
                                             mitigate=True)
        self.__maintainercleanfiles = makefile.Set(name='MAINTAINERCLEANFILES',
                                                   values=[],
                                                   mitigate=True)

        # AM_CFLAGS, AM_CXXFLAGS, AM_LFLAGS, AM_YFLAGS. we collect
        # them in a dictionary to keep them unique. (keys are the
        # flags themselves, data is irrelevant.)

        self.__am_cflags = makefile.Set(name='AM_CFLAGS',
                                        values=[],
                                        mitigate=True)
        self.__am_cxxflags = makefile.Set(name='AM_CXXFLAGS',
                                          values=[],
                                          mitigate=True)
        self.__am_lflags = makefile.Set(name='AM_LFLAGS',
                                        values=[],
                                        mitigate=True)
        self.__am_yflags = makefile.Set(name='AM_YFLAGS',
                                        values=[],
                                        mitigate=True)

        # source files (_SOURCES) of compound objects (i.e. libraries
        # and executables).

        self.__compound_sources = CompoundListManager(unique=True,
                                                      extension='SOURCES')

        # _LDFLAGS specific to an executable or a library.

        self.__compound_ldflags = CompoundListManager(unique=False,
                                                      extension='LDFLAGS')

        # _LIBADD for compound objects.

        self.__compound_libadd = CompoundListManager(unique=True,
                                                     extension='LIBADD')

        # _LDADD for compound objects.

        self.__compound_ldadd = CompoundListManager(unique=True,
                                                    extension='LDADD')

        # _DEPENDENCIES for compound objects.

        self.__compound_dependencies = CompoundListManager(
            unique=True, extension='DEPENDENCIES')

        # AM_CPPFLAGS. includepath and commandline macros make their
        # way into AM_CPPFLAGS. we maintain them separately because
        # they have different overriding semantics.

        self.__includepath = []
        self.__have_includedir = {}

        self.__cmdlinemacros = {}

        # generic way to register files (programs, libraries, etc.)
        # that will be built, and eventually installed. for example,
        # 'lib_LIBRARIES' is a list of library names that have to be
        # built (ok, we only build one library in a module, but that's
        # another story). other examples are 'bin_PROGRAMS', or
        # 'check_PROGRAMS'.

        # the structure is a dictionary, with the keys being the
        # variables (such as 'lib_LIBRARIES'), and the data being
        # dictionaries that have as keys the filenames that the
        # variable holds. sounds complicated, see the
        # add_dir_primary() method for more.

        self.__dir_primary = {}

        # directories where files will be installed to
        # {symbolicname -> (dirname, {family -> filelist})}

        # for example:

        # {'publicheader_WXUtils': ('$(includedir)/WX/Utils',
        #                           {'HEADERS': ['error.h',
        #                                        'errortrace.h',
        #                                        'error_impl.h',
        #                                        'error_macros.h']})}

        # note that we predefine the default directories (for
        # include_HEADERS, or data_DATA, for example) -- these must
        # not be explicitly defined in Makefile.am.

        self.__install_directories = {
            '': Makefile_am.DirectoryDefinition(dirname=None)
        }

        # TESTS_ENVIRONMENT. a dictionary (string->string) that
        # contains the environment for test programs.

        self.__tests_environment = {}

        # BUILT_SOURCES. list of files that must be built before
        # everything else is built.

        self.__built_sources = makefile.Set(name='BUILT_SOURCES',
                                            values=[],
                                            mitigate=True)

        # hook-targets to be made after the local (module) thing is
        # over. see the "all-local:" and "clean-local:" hook target
        # documentation in the automake manual.

        self.__all_local = makefile.Rule(targets=['all-local'])
        self.__clean_local = makefile.Rule(targets=['clean-local'])
        self.__install_data_local = makefile.Rule(
            targets=['install-data-local'])
        self.__distclean_local = makefile.Rule(targets=['distclean-local'])
        self.__mostlyclean_local = makefile.Rule(targets=['mostlyclean-local'])
        self.__maintainer_clean_local = makefile.Rule(
            targets=['maintainer-clean-local'])

        pass
コード例 #11
0
    "dom.cpp",
    "../../src/TrackSet.cpp",
    "../../src/Track.cpp",
    "../../src/PathSet.cpp",
    "../../src/HeadedTrackSet.cpp",
    "../../unix/Arduino.cpp",
    "../../unix/HardwareSerial.cpp"
]
objectList = []
for source in sourceList:
#--- Add compile rules
  src = os.path.basename(os.path.dirname(source)) + "/" + os.path.basename(source)
  object = "objects/" + src + ".o"
  depObject = object + ".dep"
  objectList.append (object)
  rule = makefile.Rule ([object], "Compiling " + source) # Release 2
  rule.deleteTargetDirectoryOnClean ()
  rule.mDependences.append (source)
  rule.mCommand.append ("g++")
#  rule.mCommand += ["-std=c++11"]
  rule.mCommand += ["-I../../src"]
  rule.mCommand += ["-I../../unix"]
  rule.mCommand += ["-I../../examples/dom"]
  rule.mCommand += ["-c", source]
  rule.mCommand += ["-o", object]
  rule.mCommand += ["-MD", "-MP", "-MF", depObject]
  rule.enterSecondaryDependanceFile (depObject, make)
  rule.mPriority = os.path.getsize (scriptDir + "/" + source)
#  rule.mOpenSourceOnError = True
  make.addRule (rule)
#--- Add linker rule