Portable makefile creation of directories

前端 未结 3 1253
予麋鹿
予麋鹿 2021-01-06 04:17

I\'m looking to save myself some effort further down the line by making a fairly generic makefile that will put together relatively simple C++ projects for me with minimal m

3条回答
  •  甜味超标
    2021-01-06 04:50

    I solved the portability problem by creating a Python script called mkdir.py and calling it from the Makefile. A limitation is that Python must be installed, but this is most likely true for any version of UNIX.

    #!/usr/bin/env python
    
    # Cross-platform mkdir command.
    
    import os
    import sys
    
    if __name__=='__main__':
        if len(sys.argv) != 2:
            sys.exit('usage: mkdir.py ')
        directory = sys.argv[1]
        try:
            os.makedirs(directory)
        except OSError:
            pass
    

提交回复
热议问题