populate_dir

/*
 * populate_dir - populate directory with attributes.创建属性文件来填充目录
 * @kobj: object we're working on.我们正在处理的object
 *
 * 大部分的子系统有一套默认属性,并与其一起注册。在object注册的时候,
 * 循环子系统的默认属性并为子系统创建属性文件是极好的。
 */
static int populate_dir(struct kobject *kobj)
{
        struct kobj_type *t = get_ktype(kobj);
        struct attribute *attr;
        int error = 0;
        int i;

        if (t && t->default_attrs) {
                for (i = 0; (attr = t->default_attrs[i]) != NULL; i++) {
                        error = sysfs_create_file(kobj, attr);
                        if (error)
                                break;
                }
        }
        return error;

}


文件/linux/sysfs.h

static inline int __must_check sysfs_create_file(struct kobject *kobj,
const struct attribute *attr)
{
return sysfs_create_file_ns(kobj, attr, NULL);
}


文件/fs/sysfs/file.c

/**
 * sysfs_create_file_ns - 根据ns为object创建一个属性文件
 * @kobj: object we're creating for
 * @attr: 属性描述符
 * @ns: 新文件属于的命名空间
 */
int sysfs_create_file_ns(struct kobject *kobj, const struct attribute *attr,
const void *ns)
{
        BUG_ON(!kobj || !kobj->sd || !attr);

        return sysfs_add_file_mode_ns(kobj->sd, attr, false, attr->mode, ns);
}


文件/fs/sysfs/file.c  要不还是别深究了吧,没有文档的,没人看的懂

int sysfs_add_file_mode_ns(struct kernfs_node *parent,
  const struct attribute *attr, bool is_bin,
  umode_t mode, const void *ns)
{
struct lock_class_key *key = NULL;
const struct kernfs_ops *ops;
struct kernfs_node *kn;
loff_t size;


if (!is_bin) {
struct kobject *kobj = parent->priv;
const struct sysfs_ops *sysfs_ops = kobj->ktype->sysfs_ops;


/* every kobject with an attribute needs a ktype assigned */
if (WARN(!sysfs_ops, KERN_ERR
"missing sysfs attribute operations for kobject: %s\n",
kobject_name(kobj)))
return -EINVAL;


if (sysfs_ops->show && sysfs_ops->store)
ops = &sysfs_file_kfops_rw;
else if (sysfs_ops->show)
ops = &sysfs_file_kfops_ro;
else if (sysfs_ops->store)
ops = &sysfs_file_kfops_wo;
else
ops = &sysfs_file_kfops_empty;


size = PAGE_SIZE;
} else {
struct bin_attribute *battr = (void *)attr;


if (battr->mmap)
ops = &sysfs_bin_kfops_mmap;
else if (battr->read && battr->write)
ops = &sysfs_bin_kfops_rw;
else if (battr->read)
ops = &sysfs_bin_kfops_ro;
else if (battr->write)
ops = &sysfs_bin_kfops_wo;
else
ops = &sysfs_file_kfops_empty;


size = battr->size;
}


#ifdef CONFIG_DEBUG_LOCK_ALLOC
if (!attr->ignore_lockdep)
key = attr->key ?: (struct lock_class_key *)&attr->skey;
#endif
kn = __kernfs_create_file(parent, attr->name, mode, size, ops,
 (void *)attr, ns, true, key);
if (IS_ERR(kn)) {
if (PTR_ERR(kn) == -EEXIST)
sysfs_warn_dup(parent, attr->name);
return PTR_ERR(kn);
}
return 0;
}

WARNING: /D/study/zynq7020_project/build/tmp/work/x86_64-linux/gcc-cross-arm/11.2.0-r0/temp/run.sstate_unpack_package.46848:155 exit 2 from 'tar -xvzf /D/study/zynq7020_project/build/sstate-cache/universal/61/3c/sstate:gcc-cross-arm:x86_64-xilinx-linux-gnueabi:11.2.0:r0:x86_64_arm:7:613c43f166f8bdd0a123f6a23e4105c73926800ec4e7820f4725b9a05c15f024_populate_sysroot.tgz' WARNING: Backtrace (BB generated script): #1: sstate_unpack_package, /D/study/zynq7020_project/build/tmp/work/x86_64-linux/gcc-cross-arm/11.2.0-r0/temp/run.sstate_unpack_package.46848, line 155 #2: main, /D/study/zynq7020_project/build/tmp/work/x86_64-linux/gcc-cross-arm/11.2.0-r0/temp/run.sstate_unpack_package.46848, line 165 ERROR: Error executing a python function in exec_func_python() autogenerated: The stack trace of python calls that resulted in this exception/failure was: File: 'exec_func_python() autogenerated', lineno: 2, function: <module> 0001: *** 0002:do_populate_sysroot_setscene(d) 0003: File: '/D/study/zynq7020_project/components/yocto/layers/core/meta/classes/staging.bbclass', lineno: 132, function: do_populate_sysroot_setscene 0128:do_populate_sysroot[sstate-outputdirs] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/${PN}" 0129:do_populate_sysroot[sstate-fixmedir] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/${PN}" 0130: 0131:python do_populate_sysroot_setscene () { *** 0132: sstate_setscene(d) 0133:} 0134:addtask do_populate_sysroot_setscene 0135: 0136:def staging_copyfile(c, target, dest, postinsts, seendirs): File: '/D/study/zynq7020_project/components/yocto/layers/core/meta/classes/sstate.bbclass', lineno: 789, function: sstate_setscene 0785: 0786: 0787:def sstate_setscene(d): 0788: shared_state = sstate_state_fromvars(d) *** 0789: accelerate = sstate_installpkg(shared_state, d) 0790: if not accelerate: 0791: msg = "No sstate archive obtainable, will run full task instead." 0792: bb.
03-24
include(FetchContent) include(ExternalProject) cmake_minimum_required(VERSION 3.16.0) project(SWMM5Plus VERSION 1.0.2) enable_language (Fortran) find_package (Python3 COMPONENTS Interpreter) set(testing_available ON) set(CPACK_SET_DESTDIR ON) function(check_python_dependencies module) message(STATUS "Looking for Python module '${module}'") execute_process(COMMAND pip show ${module} OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE EXIT_CODE_PIPSHOW ) if (NOT ${EXIT_CODE_PIPSHOW} EQUAL 0) set(testing_available OFF PARENT_SCOPE) message(WARNING "\nMissing Python module '${module}'\n**Testing unavailable**\nPlease run python_dependencies.sh\n") else() message(STATUS "'${module}' found") endif() endfunction() if (NOT (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" OR CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM")) message(FATAL_ERROR "Intel Fortran compiler not found. Found ${CMAKE_Fortran_COMPILER_ID} instead. This project supports Intel Fortran (ifort) and IntelLLVM (ifx).") else() message(STATUS "Detected Intel Fortran compiler: ${CMAKE_Fortran_COMPILER_ID}") endif() function(commentout IN_FILE line_num) file (STRINGS ${IN_FILE} LINES) file(WRITE ${IN_FILE} "") set(line_counter 1) foreach(LINE IN LISTS LINES) if (${line_counter} STREQUAL line_num) string(PREPEND LINE "//") endif() MATH(EXPR line_counter "${line_counter}+1") file(APPEND ${IN_FILE} "${LINE}\n") endforeach() endfunction() get_filename_component(build_configuration ${CMAKE_BINARY_DIR} NAME) if (build_configuration STREQUAL "build") set(default_build_type "Release") message(STATUS "Building inside '${build_configuration}' named folder, setting configuration as '${default_build_type}'") elseif (build_configuration STREQUAL "dwflow") set(default_build_type "Release") message(STATUS "Building inside '${build_configuration}' named folder, setting configuration as '${default_build_type}'") message(WARNING "Lines [249-252] will be commented out from 'interface/src/dwflow.c'") elseif(build_configuration STREQUAL "debug") set(default_build_type "Debug") message(STATUS "Building inside '${build_configuration}' named folder, setting configuration as '${default_build_type}'") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback -debug extended") endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -lm -lpthread -shared -fcommon") #set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -coarray=distributed -ldl") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -coarray=shared -fPIC -traceback") set(FETCHCONTENT_QUIET OFF) set(BUILD_COARRAY_NUM_IMAGES 1 CACHE STRING "Set up the number of processors to use for parallel SWMM5+.") set(BUILD_HDF5 "C:/Users/Admin/gw20250625/SWMM5plus-v-1.0.2/build/_deps/hdf5-src") set(hdf5_SOURCE_DIR "C:/Users/Admin/gw20250625/SWMM5plus-v-1.0.2/build/_deps/hdf5-src") set(HDF5_INCLUDE_DIR "C:/Users/Admin/gw20250625/SWMM5plus-v-1.0.2/build/_deps/hdf5-src/include") set(HDF5_LIB_DIR "C:/Users/Admin/gw20250625/SWMM5plus-v-1.0.2/build/_deps/hdf5-src/lib") set(json_fortran_SOURCE_DIR "C:/Users/Admin/gw20250625/SWMM5plus-v-1.0.2/build/json-fortran-src") if (DEFINED ENV{HDF5_DIR}) set(BUILD_HDF5 $ENV{HDF5_DIR}) endif() FetchContent_Declare( epaswmm5 URL https://github.com/USEPA/Stormwater-Management-Model/archive/v5.1.13.tar.gz ) FetchContent_Declare( json_fortran GIT_REPOSITORY https://github.com/jacobwilliams/json-fortran.git GIT_TAG 3ab8f98209871875325c6985dd0e50085d1c82c2 #Release 8.3.0 GIT_PROGRESS ON ) FetchContent_Declare( hdf5 GIT_REPOSITORY https://github.com/HDFGroup/hdf5.git GIT_TAG 3e847e003632bdd5fdc189ccbffe25ad2661e16f #Release 1.12.2 GIT_PROGRESS ON ) Fetchcontent_MakeAvailable(epaswmm5) FetchContent_GetProperties(json_fortran hdf5) if(NOT json_fortran_POPULATED) FetchContent_Populate(json_fortran) endif() FetchContent_Populate(hdf5) ExternalProject_Add(hdf5 SOURCE_DIR "C:/Users/Admin/gw20250625/SWMM5plus-v-1.0.2/build/_deps/hdf5-src" CONFIGURE_COMMAND FC=ifort ${hdf5_SOURCE_DIR}/configure --enable-fortran --without-zlib BINARY_DIR ${hdf5_BINARY_DIR} BUILD_COMMAND ${MAKE} COMMAND make install) set(HDF5_LIB_DIR ${hdf5_BINARY_DIR}/hdf5/lib/) set(HDF5_INCLUDE_DIR ${hdf5_BINARY_DIR}/hdf5/include/) set(HDF5_LIBRARIES ${hdf5_BINARY_DIR}/hdf5/lib/libhdf5hl_fortran.a ${hdf5_BINARY_DIR}/hdf5/lib/libhdf5_hl.a ${hdf5_BINARY_DIR}/hdf5/lib/libhdf5_fortran.a ${hdf5_BINARY_DIR}/hdf5/lib/libhdf5.a) set(BUILD_HDF5 ${hdf5_BINARY_DIR}) set(HDF5_FOUND ON) #Following sh script file(COPY ${epaswmm5_SOURCE_DIR}/src/ DESTINATION ${CMAKE_SOURCE_DIR}/interface/src) file(COPY ${CMAKE_SOURCE_DIR}/interface/api.h DESTINATION ${CMAKE_SOURCE_DIR}/interface/src) file(COPY ${CMAKE_SOURCE_DIR}/interface/api.c DESTINATION ${CMAKE_SOURCE_DIR}/interface/src) file(COPY ${CMAKE_SOURCE_DIR}/interface/api_error.h DESTINATION ${CMAKE_SOURCE_DIR}/interface/src) file(COPY ${CMAKE_SOURCE_DIR}/interface/api_error.c DESTINATION ${CMAKE_SOURCE_DIR}/interface/src) file(READ ${CMAKE_SOURCE_DIR}/interface/add_to_controls.c CONTROLS) file(READ ${CMAKE_SOURCE_DIR}/interface/add_to_funcs.h FUNCS) file(APPEND ${CMAKE_SOURCE_DIR}/interface/src/controls.c "${CONTROLS}") file(APPEND ${CMAKE_SOURCE_DIR}/interface/src/funcs.h "${FUNCS}") message(STATUS "Appended to controls.c and funcs.h") file(READ ${CMAKE_SOURCE_DIR}/interface/add_to_lid.c LIDC) file(READ ${CMAKE_SOURCE_DIR}/interface/add_to_lid.h LIDH) file(APPEND ${CMAKE_SOURCE_DIR}/interface/src/lid.c "${LIDC}") file(APPEND ${CMAKE_SOURCE_DIR}/interface/src/lid.h "${LIDH}") message(STATUS "Appended to lid.c and lid.h") if (build_configuration STREQUAL "dwflow") commentout(${CMAKE_SOURCE_DIR}/interface/src/dwflow.c 248) commentout(${CMAKE_SOURCE_DIR}/interface/src/dwflow.c 249) commentout(${CMAKE_SOURCE_DIR}/interface/src/dwflow.c 250) commentout(${CMAKE_SOURCE_DIR}/interface/src/dwflow.c 251) commentout(${CMAKE_SOURCE_DIR}/interface/src/dwflow.c 252) message(STATUS "Commented out lines [248-252] from 'interface/src/dwflow.c'") endif() file(GLOB SWMM_SOURCES ${CMAKE_SOURCE_DIR}/interface/src/*.c ${CMAKE_SOURCE_DIR}/interface/src/*.h ) file(GLOB SWMM5X_SOURCES ${json_fortran_SOURCE_DIR}/src/json_kinds.F90 ${json_fortran_SOURCE_DIR}/src/json_parameters.F90 ${json_fortran_SOURCE_DIR}/src/json_string_utilities.F90 ${json_fortran_SOURCE_DIR}/src/json_value_module.F90 ${json_fortran_SOURCE_DIR}/src/json_file_module.F90 ${json_fortran_SOURCE_DIR}/src/json_module.F90 ${CMAKE_SOURCE_DIR}/utility/*.f90 ${CMAKE_SOURCE_DIR}/special_elements/*.f90 ${CMAKE_SOURCE_DIR}/definitions/*.f90 ${CMAKE_SOURCE_DIR}/interface/c_library.f90 ${CMAKE_SOURCE_DIR}/interface/interface.f90 ${CMAKE_SOURCE_DIR}/initialization/*.f90 ${CMAKE_SOURCE_DIR}/geometry/*.f90 ${CMAKE_SOURCE_DIR}/timeloop/*.f90 ${CMAKE_SOURCE_DIR}/output/*.f90 ${CMAKE_SOURCE_DIR}/finalization/*.f90 ${CMAKE_SOURCE_DIR}/main/*.f90 ) #Targets #add_library(swmm5 SHARED # ${SWMM_SOURCES} #) set_target_properties(swmm5 PROPERTIES LINKER_LANGUAGE C CXX_STANDARD 14) add_executable(SWMM5p ${SWMM5X_SOURCES} ) target_include_directories(SWMM5p PUBLIC ${HDF5_INCLUDE_DIR} ) target_link_directories(SWMM5p PUBLIC ${HDF5_LIB_DIR} ) target_link_libraries(SWMM5p PUBLIC ${HDF5_LIBRARIES} ) add_dependencies(SWMM5p hdf5) #Testing check_python_dependencies(tornado) check_python_dependencies(tabulate) check_python_dependencies(h5py) check_python_dependencies(swmmtoolbox) # Tests defined in separate file: ctest/CMakeLists.txt if (testing_available) enable_testing() message(STATUS "Making tests available") add_subdirectory(ctest) endif() #INSTALLATION install(TARGETS SWMM5p DESTINATION bin) install(TARGETS swmm5 DESTINATION lib) #cpack set(CPACK_PACKAGE_CONTACT "NCIMM") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "NCIMM") set(CPACK_DEBIAN_PACKAGE_DEPENDS "intel-hpckit") include(CPack) 以上是我配置swmm5+的CMakeLists.txt,这样配置后,HDF5配置不成功,不能生成 HDF5.mod 文件
最新发布
06-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值