Python
2014.05.29 14:00

[Sconscript] Install method

조회 수 8641 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print

Once a program is built, it is often appropriate to install it in another directory for public use. 

우선 프로그램이 빌드된 후 , 많은 경우 공용의 목적을 위하여 다른 디렉토리에 프로그램을 설치하는 것이 적절하다.


You use the Install method to arrange for a program, or any other file, to be copied into a destination directory:

이럴때, install method를 통하여 프로그램이나 파일을 목적 디렉토리에 복사할 수 있다.


env = Environment()

hello = env.Program(’hello.c’)

env.Install(’/usr/bin’, hello)


Note, however, that installing a file is still considered a type of file "build." 

This is important when you remember that the default behavior of SCons is to build files in or below the current directory. 


If, as in the example above, you are installing files in a directory outside of the top-level SConstruct file’s directory tree, 

you must specify that directory (or a higher directory, such as /) for it to install anything there:

위와 같은 스크립트의 내용으로 빌드를 한다면 아래와 같이 특정 저장위치에 파일을 설치하기 위하여 디렉토리를 지정해줘야 한다.


% scons -Q

cc -o hello.o -c hello.c

cc -o hello hello.o


% scons -Q /usr/bin

Install file: "hello" as "/usr/bin/hello"


 It can, however, be cumbersome to remember (and type) the specific destination directory in which the program (or any other file) should be installed. This is an area where the Alias function comes in handy, allowing you, for example, to create a pseudo-target named install that can expand to the specified destination directory:


하지만, 위와 같이 목적지 디렉토리이름을 기억하는 것은 부담스럽기 때문에 "alias"을 통하여 사용하는 것이 또 하나의 방법이다.


env = Environment()

hello = env.Program(’hello.c’)

env.Install(’/usr/bin’, hello)

env.Alias(’install’, ’/usr/bin’)


This then yields the more natural ability to install the program in its destination as follows:


% scons -Q

cc -o hello.o -c hello.c

cc -o hello hello.o


% scons -Q install

Install file: "hello" as "/usr/bin/hello"



13.1. Installing Multiple Files in a Directory

You can install multiple files into a directory simply by calling the Install function multiple times:


env = Environment()

hello = env.Program(’hello.c’)

goodbye = env.Program(’goodbye.c’)

env.Install(’/usr/bin’, hello)

env.Install(’/usr/bin’, goodbye)

env.Alias(’install’, ’/usr/bin’)


Or, more succinctly, listing the multiple input files in a list (just like you can do with any other builder):

좀 더 간결하게 두 개 이상의 입력 파일에 대하여 list로 표현이 가능하다.


env = Environment()

hello = env.Program(’hello.c’)

goodbye = env.Program(’goodbye.c’)

env.Install(’/usr/bin’, [hello, goodbye])

env.Alias(’install’, ’/usr/bin’)


Either of these two examples yields:


% scons -Q install

cc -o goodbye.o -c goodbye.c

cc -o goodbye goodbye.o

Install file: "goodbye" as "/usr/bin/goodbye"

cc -o hello.o -c hello.c

cc -o hello hello.o

Install file: "hello" as "/usr/bin/hello"



13.2. Installing a File Under a Different Name


The Install method preserves the name of the file when it is copied into the destination directory. 

"install" 함수는 목적지 디렉토리로 복사되었을 때, 파일의 이름을 지정하는 것도 가능하다.


If you need to change the name of the file when you copy it, use the InstallAs function:



env = Environment()

hello = env.Program(’hello.c’)

env.InstallAs(’/usr/bin/hello-new’, hello)

env.Alias(’install’, ’/usr/bin’)


This installs the hello program with the name hello-new as follows:


% scons -Q install

cc -o hello.o -c hello.c



13.3. Installing Multiple Files Under Different Names


Lastly, if you have multiple files that all need to be installed with different file names, you can either call

the InstallAs function multiple times, or as a shorthand, you can supply same-length lists for both the target and source arguments:

마지막으로, 2개 파일을 빌드 후, 이름을 변경하여 install 하려고 할 경우, list를 사용하여 아래와 같이 구현이 가능하다.


env = Environment()

hello = env.Program(’hello.c’)

goodbye = env.Program(’goodbye.c’)

env.InstallAs([’/usr/bin/hello-new’,’/usr/bin/goodbye-new’],[hello, goodbye])

env.Alias(’install’, ’/usr/bin’)


In this case, the InstallAs function loops through both lists simultaneously, and copies each source file

into its corresponding target file name:


% scons -Q install

cc -o goodbye.o -c goodbye.c

cc -o goodbye goodbye.o

Install file: "goodbye" as "/usr/bin/goodbye-new"

cc -o hello.o -c hello.c

cc -o hello hello.o

Install file: "hello" as "/usr/bin/hello-new"


[출처] [Sconscript] Install method|작성자 hyunsung1026



Dreamy의 코드 스크랩

내가 모으고 내가 보는

List of Articles
번호 분류 제목 날짜 조회 수 추천 수
326 LINUX [Shell Script] Bash 파일 유무 체크하는 방법과 파일 존재 검사 옵션 2017.05.16 21460 0
325 LINUX [Shell Script] Bash 실행결과를 변수에 담기 2017.05.16 13546 0
» Python [Sconscript] Install method 2014.05.29 8641 0
323 PHP [PHP] .php 확장자 없이 URL 접속하기 2020.10.26 4777 0
322 일반 [PDK] PDK에서 난수 발생 함수 2006.05.04 36987 0
321 PHP [MySQL] 뷰 생성하기(VIEW 생성하기) 2022.10.12 1167 0
320 JAVA [Java] 자바에서 콜백(Callback) 구현하기 2017.03.15 26189 0
319 JAVA [JAVA] 람다식 기본 예제 1 (map, filter, reduce, collect) 2022.11.04 1440 0
318 HTML5 [Javascript] Promise 이해하기 2018.01.04 5889 0
317 HTML5 [Javascript] Javascript Patterns 요약 secret 2018.01.16 0 0
316 일반 [HTML] 복사해서 사용가능한 5개의 실용적인 List Style 예제 2015.11.03 7248 0
315 Android [GIT] git stash 사용하기 2012.10.22 31341 0
314 Android [Git] git add 취소하기, git commit 취소하기, git push 취소하기 2021.09.30 5663 0
313 Android [GIT 사용법] 초보자가 알아두면 좋을 명령어 정리 1 2011.12.26 66738 0
312 Android [GIT 사용법] 다른 branch와의 차이점 찾아보기 2012.08.16 21907 0
목록
Board Pagination ‹ Prev 1 ... 8 9 10 11 12 13 14 15 16 17 ... 34 Next ›
/ 34

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소

Designed by sketchbooks.co.kr / sketchbook5 board skin

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5