コード例 #1
0
func compileLibrary(objectFiles []string, library *types.Library, buildPath string, buildProperties map[string]string, includes []string, verbose bool, warningsLevel string, logger i18n.Logger) ([]string, error) {
	libraryBuildPath := filepath.Join(buildPath, library.Name)

	err := os.MkdirAll(libraryBuildPath, os.FileMode(0755))
	if err != nil {
		return nil, utils.WrapError(err)
	}

	if library.Layout == types.LIBRARY_RECURSIVE {
		objectFiles, err = builder_utils.CompileFilesRecursive(objectFiles, library.SrcFolder, libraryBuildPath, buildProperties, includes, verbose, warningsLevel, logger)
		if err != nil {
			return nil, utils.WrapError(err)
		}
	} else {
		utilitySourcePath := filepath.Join(library.SrcFolder, constants.LIBRARY_FOLDER_UTILITY)
		_, utilitySourcePathErr := os.Stat(utilitySourcePath)
		if utilitySourcePathErr == nil {
			includes = append(includes, utils.WrapWithHyphenI(utilitySourcePath))
		}
		objectFiles, err = builder_utils.CompileFiles(objectFiles, library.SrcFolder, false, libraryBuildPath, buildProperties, includes, verbose, warningsLevel, logger)
		if err != nil {
			return nil, utils.WrapError(err)
		}

		if utilitySourcePathErr == nil {
			utilityBuildPath := filepath.Join(libraryBuildPath, constants.LIBRARY_FOLDER_UTILITY)
			objectFiles, err = builder_utils.CompileFiles(objectFiles, utilitySourcePath, false, utilityBuildPath, buildProperties, includes, verbose, warningsLevel, logger)
			if err != nil {
				return nil, utils.WrapError(err)
			}
		}
	}

	return objectFiles, nil
}
コード例 #2
0
func compileLibrary(library *types.Library, buildPath string, buildProperties properties.Map, includes []string, verbose bool, warningsLevel string, logger i18n.Logger) ([]string, error) {
	if verbose {
		logger.Println(constants.LOG_LEVEL_INFO, "Compiling library \"{0}\"", library.Name)
	}
	libraryBuildPath := filepath.Join(buildPath, library.Name)

	err := utils.EnsureFolderExists(libraryBuildPath)
	if err != nil {
		return nil, i18n.WrapError(err)
	}

	objectFiles := []string{}
	if library.Layout == types.LIBRARY_RECURSIVE {
		objectFiles, err = builder_utils.CompileFilesRecursive(objectFiles, library.SrcFolder, libraryBuildPath, buildProperties, includes, verbose, warningsLevel, logger)
		if err != nil {
			return nil, i18n.WrapError(err)
		}
		if library.DotALinkage {
			archiveFile, err := builder_utils.ArchiveCompiledFiles(libraryBuildPath, library.Name+".a", objectFiles, buildProperties, verbose, logger)
			if err != nil {
				return nil, i18n.WrapError(err)
			}
			objectFiles = []string{archiveFile}
		}
	} else {
		if library.UtilityFolder != "" {
			includes = append(includes, utils.WrapWithHyphenI(library.UtilityFolder))
		}
		objectFiles, err = builder_utils.CompileFiles(objectFiles, library.SrcFolder, false, libraryBuildPath, buildProperties, includes, verbose, warningsLevel, logger)
		if err != nil {
			return nil, i18n.WrapError(err)
		}

		if library.UtilityFolder != "" {
			utilityBuildPath := filepath.Join(libraryBuildPath, constants.LIBRARY_FOLDER_UTILITY)
			objectFiles, err = builder_utils.CompileFiles(objectFiles, library.UtilityFolder, false, utilityBuildPath, buildProperties, includes, verbose, warningsLevel, logger)
			if err != nil {
				return nil, i18n.WrapError(err)
			}
		}
	}

	return objectFiles, nil
}
コード例 #3
0
func compileLibrary(library *types.Library, buildPath string, buildProperties props.PropertiesMap, includes []string, verbose bool, warningsLevel string, logger i18n.Logger) ([]string, error) {
	libraryBuildPath := filepath.Join(buildPath, library.Name)

	err := utils.EnsureFolderExists(libraryBuildPath)
	if err != nil {
		return nil, utils.WrapError(err)
	}

	objectFiles := []string{}
	if library.Layout == types.LIBRARY_RECURSIVE {
		objectFiles, err = builder_utils.CompileFilesRecursive(objectFiles, library.SrcFolder, libraryBuildPath, buildProperties, includes, verbose, warningsLevel, logger)
		if err != nil {
			return nil, utils.WrapError(err)
		}
		if library.DotALinkage {
			archiveFile, err := builder_utils.ArchiveCompiledFiles(libraryBuildPath, library.Name+".a", objectFiles, buildProperties, verbose, logger)
			if err != nil {
				return nil, utils.WrapError(err)
			}
			objectFiles = []string{archiveFile}
		}
	} else {
		utilitySourcePath := filepath.Join(library.SrcFolder, constants.LIBRARY_FOLDER_UTILITY)
		_, utilitySourcePathErr := os.Stat(utilitySourcePath)
		if utilitySourcePathErr == nil {
			includes = append(includes, utils.WrapWithHyphenI(utilitySourcePath))
		}
		objectFiles, err = builder_utils.CompileFiles(objectFiles, library.SrcFolder, false, libraryBuildPath, buildProperties, includes, verbose, warningsLevel, logger)
		if err != nil {
			return nil, utils.WrapError(err)
		}

		if utilitySourcePathErr == nil {
			utilityBuildPath := filepath.Join(libraryBuildPath, constants.LIBRARY_FOLDER_UTILITY)
			objectFiles, err = builder_utils.CompileFiles(objectFiles, utilitySourcePath, false, utilityBuildPath, buildProperties, includes, verbose, warningsLevel, logger)
			if err != nil {
				return nil, utils.WrapError(err)
			}
		}
	}

	return objectFiles, nil
}