Skip to content

Commit 4c46ad4

Browse files
[projmgr] Do not generate linker script when --dry-run
Signed-off-by: Torbjörn SVENSSON <[email protected]>
1 parent 4b20cb5 commit 4c46ad4

File tree

7 files changed

+314
-1
lines changed

7 files changed

+314
-1
lines changed

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2307,7 +2307,7 @@ bool ProjMgrWorker::CheckConfigPLMFiles(ContextItem& context) {
23072307
}
23082308

23092309
void ProjMgrWorker::SetDefaultLinkerScript(ContextItem& context) {
2310-
if (context.linker.script.empty()) {
2310+
if (context.linker.script.empty() && !m_dryRun) {
23112311
const string& compilerRoot = GetCompilerRoot();
23122312
string linkerScript;
23132313
error_code ec;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/1.0.0/tools/projmgr/schemas/cproject.schema.json
2+
3+
project:
4+
description: Project 3_5
5+
components:
6+
- component: CORE
7+
- component: Device:RteTest Generated Component:RteTestSimple
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "RTE_Components.h"
2+
3+
int main (void) {
4+
return 1;
5+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/1.0.0/tools/projmgr/schemas/csolution.schema.json
2+
3+
solution:
4+
target-types:
5+
- type: TypeA
6+
device: RteTestGen_ARMCM0
7+
8+
build-types:
9+
- type: Debug
10+
compiler: GCC
11+
12+
projects:
13+
- project: ./TestProject3_5/TestProject3_5.cproject.yml
14+
15+
output-dirs:
16+
outdir: $Project$/outdir/
17+
18+
generators:
19+
options:
20+
- generator: RteTestGeneratorIdentifier
21+
path: $Project$/gendir/
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
build-gen:
2+
generated-by: csolution version 2.1.0+p16-gf314eb6d
3+
current-generator:
4+
id: RteTestGeneratorIdentifier
5+
from-pack: ARM::[email protected]
6+
solution: ${DEVTOOLS(data)}/TestSolution/dryrun_noldscript.csolution.yml
7+
project: ${DEVTOOLS(data)}/TestSolution/TestProject3_5/TestProject3_5.cproject.yml
8+
context: TestProject3_5.Debug+TypeA
9+
compiler: GCC
10+
device: ARM::RteTestGen_ARMCM0
11+
device-pack: ARM::[email protected]
12+
processor:
13+
core: Cortex-M0
14+
packs:
15+
- pack: ARM::[email protected]
16+
path: ${DEVTOOLS(packs)}/ARM/RteTestGenerator/0.1.0
17+
- pack: ARM::[email protected]
18+
path: ${DEVTOOLS(packs)}/ARM/RteTest_DFP/0.2.0
19+
define:
20+
- _RTE_
21+
define-asm:
22+
- _RTE_
23+
add-path:
24+
- ${DEVTOOLS(data)}/TestSolution/TestProject3_5/RTE/_Debug_TypeA
25+
add-path-asm:
26+
- ${DEVTOOLS(data)}/TestSolution/TestProject3_5/RTE/_Debug_TypeA
27+
output-dirs:
28+
intdir: ${DEVTOOLS(data)}/TestSolution/tmp
29+
outdir: ${DEVTOOLS(data)}/TestSolution/TestProject3_5/outdir
30+
rtedir: ${DEVTOOLS(data)}/TestSolution/TestProject3_5/RTE
31+
output:
32+
- type: elf
33+
file: TestProject3_5.elf
34+
components:
35+
- component: ARM::Device:RteTest Generated Component:[email protected]
36+
from-pack: ARM::[email protected]
37+
selected-by: Device:RteTest Generated Component:RteTestSimple
38+
files:
39+
- file: ${DEVTOOLS(packs)}/ARM/RteTestGenerator/0.1.0/Templates/RteTest.gpdsc.template
40+
category: other
41+
version: 1.0.0
42+
generator:
43+
id: RteTestGeneratorIdentifier
44+
from-pack: ARM::[email protected]
45+
- component: ARM::RteTest:[email protected]
46+
condition: Cortex-M Device
47+
from-pack: ARM::[email protected]
48+
selected-by: CORE
49+
implements: RteTest:[email protected]
50+
files:
51+
- file: ${DEVTOOLS(packs)}/ARM/RteTest_DFP/0.2.0/Doc/html/index.html
52+
category: doc
53+
version: 0.1.1
54+
apis:
55+
- api: RteTest:[email protected]
56+
from-pack: ARM::[email protected]
57+
implemented-by: ARM::RteTest:[email protected]
58+
files:
59+
- file: https://arm-software.github.io/CMSIS_5/Pack/html/pdsc_apis_pg.html
60+
category: doc
61+
version: 1.1.2
62+
generators:
63+
- generator: RteTestGeneratorIdentifier
64+
from-pack: ARM::[email protected]
65+
path: ${DEVTOOLS(data)}/TestSolution/TestProject3_5/gendir
66+
gpdsc: ${DEVTOOLS(data)}/TestSolution/TestProject3_5/gendir/RteTestGen_ARMCM0/RteTest.gpdsc
67+
command:
68+
win:
69+
file: ${DEVTOOLS(packs)}/ARM/RteTestGenerator/0.1.0/Generator with spaces/script.bat
70+
arguments:
71+
- RteTestGen_ARMCM0
72+
- ${DEVTOOLS(data)}/TestSolution/TestProject3_5/TestProject3_5.Debug+TypeA.cprj
73+
- ${DEVTOOLS(packs)}/ARM/RteTestGenerator/0.1.0
74+
- ${DEVTOOLS(data)}/TestSolution/tmp/TestProject3_5.Debug+TypeA.cbuild-gen.yml
75+
- /foo=bar
76+
linux:
77+
file: ${DEVTOOLS(packs)}/ARM/RteTestGenerator/0.1.0/Generator with spaces/script.sh
78+
arguments:
79+
- RteTestGen_ARMCM0
80+
- ${DEVTOOLS(data)}/TestSolution/TestProject3_5/TestProject3_5.Debug+TypeA.cprj
81+
- ${DEVTOOLS(packs)}/ARM/RteTestGenerator/0.1.0
82+
- ${DEVTOOLS(data)}/TestSolution/tmp/TestProject3_5.Debug+TypeA.cbuild-gen.yml
83+
- --foo=bar
84+
mac:
85+
file: ${DEVTOOLS(packs)}/ARM/RteTestGenerator/0.1.0/Generator with spaces/script.sh
86+
arguments:
87+
- RteTestGen_ARMCM0
88+
- ${DEVTOOLS(data)}/TestSolution/TestProject3_5/TestProject3_5.Debug+TypeA.cprj
89+
- ${DEVTOOLS(packs)}/ARM/RteTestGenerator/0.1.0
90+
- ${DEVTOOLS(data)}/TestSolution/tmp/TestProject3_5.Debug+TypeA.cbuild-gen.yml
91+
- --foo=bar
92+
constructed-files:
93+
- file: ${DEVTOOLS(data)}/TestSolution/TestProject3_5/RTE/_Debug_TypeA/RTE_Components.h
94+
category: header
95+
licenses:
96+
- license: <unknown>
97+
packs:
98+
- pack: ARM::[email protected]
99+
components:
100+
- component: ARM::Device:RteTest Generated Component:[email protected]
101+
- license: <unknown>
102+
license-agreement: ${DEVTOOLS(packs)}/ARM/RteTest_DFP/0.2.0/Doc/license.txt
103+
packs:
104+
- pack: ARM::[email protected]
105+
components:
106+
- component: ARM::RteTest:[email protected]
107+
- component: RteTest:CORE(API)
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
build:
2+
generated-by: csolution version 1.6.0
3+
solution: ../genfiles.csolution.yml
4+
project: TestProject3_5.cproject.yml
5+
context: TestProject3_5.Debug+TypeA
6+
compiler: GCC
7+
device: ARM::RteTestGen_ARMCM0
8+
processor:
9+
core: Cortex-M0
10+
packs:
11+
- pack: ARM::[email protected]
12+
path: ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0
13+
- pack: ARM::[email protected]
14+
path: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0
15+
define:
16+
- _RTE_
17+
define-asm:
18+
- _RTE_
19+
add-path:
20+
- RTE/_Debug_TypeA
21+
- ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0/Include
22+
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/ARMCM0/Include
23+
add-path-asm:
24+
- RTE/_Debug_TypeA
25+
- ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0/Include
26+
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/ARMCM0/Include
27+
output-dirs:
28+
intdir: ../tmp/TestProject3_5/TypeA/Debug
29+
outdir: outdir
30+
rtedir: RTE
31+
output:
32+
- type: elf
33+
file: TestProject3_5.elf
34+
components:
35+
- component: ARM::Device:RteTest Generated Component:[email protected]
36+
from-pack: ARM::[email protected]
37+
selected-by: Device:RteTest Generated Component:RteTestGenFiles
38+
generator:
39+
id: RteTestGeneratorIdentifier
40+
from-pack: ARM::[email protected]
41+
files:
42+
- file: ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0/Templates/RteTest.gpdsc.template
43+
category: genAsset
44+
version: 1.0.0
45+
- file: ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0/Templates/RteTestGen.h.template
46+
category: genHeader
47+
version: 1.0.0
48+
- file: ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0/Templates/RteTestGen.c.template
49+
category: genSource
50+
version: 1.0.0
51+
- file: RTE/Device/RteTestGen_ARMCM0/RteTestGen.params
52+
category: genParams
53+
attr: config
54+
version: 0.9.0
55+
- component: ARM::Device:Startup&RteTest [email protected]
56+
condition: ARMCM0 RteTest
57+
from-pack: ARM::[email protected]
58+
selected-by: Startup
59+
files:
60+
- file: RTE/Device/RteTestGen_ARMCM0/gcc_arm.ld
61+
category: linkerScript
62+
attr: config
63+
version: 2.0.0
64+
- file: RTE/Device/RteTestGen_ARMCM0/startup_ARMCM0.c
65+
category: sourceC
66+
attr: config
67+
version: 2.0.3
68+
- file: RTE/Device/RteTestGen_ARMCM0/system_ARMCM0.c
69+
category: sourceC
70+
attr: config
71+
version: 1.0.0
72+
- component: ARM::RteTest:[email protected]
73+
condition: Cortex-M Device
74+
from-pack: ARM::[email protected]
75+
selected-by: CORE
76+
generators:
77+
- generator: RteTestGeneratorIdentifier
78+
from-pack: ARM::[email protected]
79+
path: gendir
80+
gpdsc: gendir/RteTestGen_ARMCM0/RteTest.gpdsc
81+
command:
82+
win:
83+
file: ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0/Generator with spaces/script.bat
84+
arguments:
85+
- RteTestGen_ARMCM0
86+
- ../TestProject3_5.Debug+TypeA.cprj
87+
- ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0
88+
- ../../tmp/TestProject3_5/TypeA/Debug/TestProject3_5.Debug+TypeA.cbuild-gen.yml
89+
- /foo=bar
90+
linux:
91+
file: ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0/Generator with spaces/script.sh
92+
arguments:
93+
- RteTestGen_ARMCM0
94+
- ../TestProject3_5.Debug+TypeA.cprj
95+
- ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0
96+
- ../../tmp/TestProject3_5/TypeA/Debug/TestProject3_5.Debug+TypeA.cbuild-gen.yml
97+
- --foo=bar
98+
mac:
99+
file: ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0/Generator with spaces/script.sh
100+
arguments:
101+
- RteTestGen_ARMCM0
102+
- ../TestProject3_5.Debug+TypeA.cprj
103+
- ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0
104+
- ../../tmp/TestProject3_5/TypeA/Debug/TestProject3_5.Debug+TypeA.cbuild-gen.yml
105+
- --foo=bar
106+
linker:
107+
script: RTE/Device/RteTestGen_ARMCM0/gcc_arm.ld
108+
constructed-files:
109+
- file: RTE/_Debug_TypeA/RTE_Components.h
110+
category: header
111+
licenses:
112+
- license: <unknown>
113+
packs:
114+
- pack: ARM::[email protected]
115+
components:
116+
- component: ARM::Device:RteTest Generated Component:[email protected]
117+
- license: <unknown>
118+
license-agreement: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Doc/license.txt
119+
packs:
120+
- pack: ARM::[email protected]
121+
components:
122+
- component: ARM::Device:Startup&RteTest [email protected]
123+
- component: ARM::RteTest:[email protected]
124+
- component: RteTest:CORE(API)

tools/projmgr/test/src/ProjMgrGeneratorUnitTests.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,55 @@ TEST_F(ProjMgrGeneratorUnitTests, DryRun) {
207207
EXPECT_NE(string::npos, gpdscContent.find("<component generator=\"RteTestGeneratorIdentifier\""));
208208
}
209209

210+
TEST_F(ProjMgrGeneratorUnitTests, DryRunNoLdScript) {
211+
char* argv[7], *envp[2];
212+
string gcc = "GCC_TOOLCHAIN_11_2_1=" + testinput_folder;
213+
envp[0] = (char*)gcc.c_str();
214+
envp[1] = (char*)'\0';
215+
216+
StdStreamRedirect streamRedirect;
217+
const string& csolution = testinput_folder + "/TestSolution/dryrun_noldscript.csolution.yml";
218+
argv[1] = (char*)"run";
219+
argv[2] = (char*)"--solution";
220+
argv[3] = (char*)csolution.c_str();
221+
argv[4] = (char*)"-g";
222+
argv[5] = (char*)"RteTestGeneratorIdentifier";
223+
argv[6] = (char*)"--dry-run";
224+
225+
const string generatorInputFile = testinput_folder + "/TestSolution/tmp/TestProject3_5.Debug+TypeA.cbuild-gen.yml";
226+
const string generatorDestination = testinput_folder + "/TestSolution/TestProject3_5/gendir";
227+
const string targetGPDSC = generatorDestination + "/RteTestGen_ARMCM0/RteTest.gpdsc";
228+
const string rteDir = testinput_folder + "/TestSolution/TestProject3_5/RTE";
229+
230+
RteFsUtils::RemoveDir(generatorDestination);
231+
RteFsUtils::RemoveDir(rteDir);
232+
233+
EXPECT_EQ(0, ProjMgr::RunProjMgr(7, argv, envp));
234+
235+
ProjMgrTestEnv::CompareFile(testinput_folder + "/TestSolution/ref/TestProject3_5.Debug+TypeA.cbuild-gen.yml", generatorInputFile, ProjMgrTestEnv::StripAbsoluteFunc);
236+
237+
EXPECT_EQ(true, RteFsUtils::Exists(generatorInputFile));
238+
EXPECT_EQ(false, RteFsUtils::Exists(rteDir + "/Device"));
239+
EXPECT_EQ(false, RteFsUtils::Exists(targetGPDSC));
240+
EXPECT_EQ(false, RteFsUtils::Exists(generatorDestination));
241+
242+
// Expect that the GPDSC content was printed to stdout, enclosed within the begin and end marks
243+
auto outStr = streamRedirect.GetOutString();
244+
string beginGpdscMark = "-----BEGIN GPDSC-----\n";
245+
string endGpdscMark = "-----END GPDSC-----\n";
246+
auto beginGpdscMarkIndex = outStr.find(beginGpdscMark);
247+
auto endGpdscMarkIndex = outStr.find(endGpdscMark);
248+
EXPECT_NE(string::npos, beginGpdscMarkIndex);
249+
EXPECT_NE(string::npos, endGpdscMarkIndex);
250+
auto gpdscContentIndex = beginGpdscMarkIndex + beginGpdscMark.size();
251+
auto contentLength = endGpdscMarkIndex - gpdscContentIndex;
252+
string gpdscContent = outStr.substr(gpdscContentIndex, contentLength);
253+
254+
// Check that the GPDSC content seems OK (the full reference GPDSC file is not easily available from the test for comparison)
255+
EXPECT_EQ(0, gpdscContent.find("<?xml"));
256+
EXPECT_NE(string::npos, gpdscContent.find("<component generator=\"RteTestGeneratorIdentifier\""));
257+
}
258+
210259
TEST_F(ProjMgrGeneratorUnitTests, PdscAndGpdscWithSameComponentName) {
211260
char* argv[6], * envp[2];
212261
string gcc = "GCC_TOOLCHAIN_11_2_1=" + testinput_folder;

0 commit comments

Comments
 (0)